Noty.nxc
From RoboWiki
/* noty.nxc
Program hra melodiu zadanu v poli a na display vykresluje
noty, ktoreho hra. Naeditujte si svoju oblubenu melodiu...
Autor: Adam
*/
/*vo funkcii ,,void Noty" sa budu podla freq vykreslovat noty */
#include "NXCdefs.h"
#define c 262 //definovanie not
#define d 294
#define e 330
#define f 349
#define g 392
#define a 440
#define h 495
#define c2 524
#define h
void Noty(int freq, int i /*int y*/) //definovanie funkcie noty
{
switch (freq)
{
case 262 : {
CircleOut(i, 20, 2);
LineOut(i+2, 20, i+2, 40);
};break;
case 294 : {
CircleOut(i, 22, 2);
LineOut(i+2, 22, i+2, 42);
};break;
case 330 : {
CircleOut(i, 25, 2);
LineOut(i+2, 25, i+2, 45);
};break;
case 349 : {
CircleOut(i, 27, 2);
LineOut(i+2, 27, i+2, 47);
};break;
case 392 : {
CircleOut(i, 30, 2);
LineOut(i+2, 30, i+2, 50);
};break;
case 440 : {
CircleOut(i, 32, 2);
LineOut(i+2, 32, i+2, 52);
};break;
case 495 : {
CircleOut(i, 35, 2);
LineOut(i+2, 35, i+2, 55);
};break;
case 524 : {
CircleOut(i, 37, 2);
LineOut(i+2, 37, i+2, 57);
};break;
}
}
int tony[28]={c,c,e,g,c2,c2,g,f,f,e,e,d,d,c,c,c,e,g,c2,c2,g,f,f,e,e,d,d,c};
task main()
{
int freq; //premenna freq
int i; //iteracna premenna
LineOut(0, 20, 99, 20); //notova osnova
LineOut(0, 25, 99, 25);
LineOut(0, 30, 99, 30);
LineOut(0, 35, 99, 35);
LineOut(0, 40, 99, 40);
for(i=0; i<ArrayLen(tony); i++)
{
Noty(tony[i], 15*(i%7));
PlayTone(tony[i],100);
Wait(200);
if(i%7==6)
{
ClearScreen(); //vycisti LCD
LineOut(0, 20, 99, 20); //notova osnova
LineOut(0, 25, 99, 25);
LineOut(0, 30, 99, 30);
LineOut(0, 35, 99, 35);
LineOut(0, 40, 99, 40);
}
}
}