Todo se entiende mejor con un ejemplo este es el código rttl de la melodía silent night es importante que te bases solo en esta melodía para entender como pasar de rttl a las notas de la librería notes por que las otras dos están modificadas cambie la octava y el tiempo y por lógica no le vas a encontrar relación.
silent night=noche de paz
Aquí el código rttl :
Silent Night: d=4,o=5,b=140:
f#., 8g#, f#, d#., p, 8p, f#., 8g#, f#, d#., p, 8p, 2c#6, c#6, a#., p, 8p, 2b, b, f#., p, 8p, 2g#, g#, b., 8a#, g#, f#., 8g#, f#, d#., p, 8p, 2g#, g#, b., 8a#, g#, f#., 8g#, f#, d#., p, 8p, 2c#6, c#6, e.6, 8c#6, a#, 2b., 2d#6, p, 8p, b
codigo ccs:
#include <tones.c>
#define SIZE 54
const struct note
{
long tone;
long length;
}noche_de_paz[SIZE] = {
Fb_note[1],750, Gb_note[1],250,Fb_note[1],500, Db_note[1],500, P_note[1],500,
P_note[1],250, Fb_note[1],750, Gb_note[1],250, Fb_note[1],500, Db_note[1],500,
P_note[1],500, P_note[1],250, Cb_note[2],500, Ab_note[1],750, P_note[1],500,
P_note[1],250, B_note[1],1000, B_note[1],500, Fb_note[1],750, P_note[1],500,
P_note[1],250, Gb_note[1],1000, Gb_note[1],500, B_note[1],750, Ab_note[1],250,
gb_note[1],500, Fb_note[1],750, Gb_note[1],250, Fb_note[1],500, Db_note[1],750,
P_note[1],500, P_note[1],250, Gb_note[1],1000, Gb_note[1],500, B_note[1],750,
A_note[1],250, Gb_note[1],500, Fb_note[1],750, Gb_note[1],250, FB_note[1],500,
D_note[1],750, P_note[1],500, P_note[1],250, Cb_note[2],1000, Cb_note[2],500,
E_note[2],750, Cb_note[2],250, Ab_note[1],500, B_note[1],998, Db_note[2],1000,
P_note[1],500, P_note[1],250, B_note[1],500};
#define SIZE2 25
const struct note2
{
long tone2;
long length2;
}jingle_bell[SIZE2] = {
B_note[1],500, B_note[1],500,B_note[1],500, P_note[1],125, B_note[1],500,
B_note[1],500, B_note[1],500, P_note[1],125, B_note[1],250,D_note[2],250
G_note[1],250, A_note[1],250, B_note[1],500, C_note[2],250, C_note[2],250,
C_note[2],500, B_note[1],250, B_note[1],250, B_note[1],500, B_note[1],250,
A_note[1],250, A_note[1],250, B_note[1],250, A_note[1],500, D_note[2],250};
#define SIZE3 42
const struct note3
{
long tone3;
long length3;
}litte_dankey[SIZE3] = {
E_note[1],250, E_note[1],250,G_note[1],1000, E_note[1],500, F_note[1],250,
F_note[1],250, A_note[1],1000,F_note[1],500, E_note[1],250, E_note[1],250,
G_note[1],1000, E_note[1],500,D_note[1],1000, P_note[1],1000, E_note[1],250,
E_note[1],250, G_note[1],1000,E_note[1],500, F_note[1],250, F_note[1],250,
A_note[1],1000, F_note[1],500,G_note[1],250, G_note[1],250, B_note[1],1000,
G_note[1],500, C_note[2],1000,P_note[1],1000, C_note[2],1000, C_note[2],500,
C_note[1],500, B_note[1],750,A_note[1],250, G_note[1],1000, A_note[1],500,
B_note[1],250, A_note[1],250,G_note[1],1000, A_note[1],500, B_note[1],250,
A_note[1],250, G_note[1],1000};
void main()
{ int i;
INT J;
INT K;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
// TODO: USER CODE!!
while(TRUE)
{
for(i=0; i<SIZE; ++i)
{
generate_tone(noche_de_paz[i].tone,noche_de_paz[i].length);
delay_ms(75);
}
delay_ms(2000);
for(j=0; j<SIZE2; ++j)
{
generate_tone(jingle_bell[j].tone2,jingle_bell[j].length2);
delay_ms(20);
}
delay_ms(2000);
for(K=0; K<SIZE3; ++K)
{
generate_tone(litte_dankey[K].tone3,litte_dankey[K].length3);
delay_ms(75);
}
delay_ms(2000);
}
}