# Thread: musical notes using sound()

1. ## musical notes using sound()

where can I find info on using the sound() and delay() to produce musical notes?

2. Are you wanting to know how to use them, or how you can use them to make musical notes?

3. I want to know how to use them to make musical notes.

4. ok. sound() will always go until it is stopped. you stop sound() with nosound(). But if you put them right under another you will get no sound:

/////
sound();
nosound();
//////

but if you put delay() between them, the sound will last longer.

////
sound(600);
delay(1000);
nosound();
/////
this will play a semi-high pitch sound for one second.
It is best if you create a function for it:
//////
int music(int pitch, int time)
{
sound(pitch);
delay(time);
nosound();
return(0);
}
/////
so then you can use it like this:

/////
int main()
{
music(600,1000);
return 0;
}
////

which will produce the same sound.
Simple enough?

5. So does anyone know the frequencies of musical notes?

Additionally, does anyone know if it is possible to overlay one frequency of sound with another?

6. Yes, but I was looking for a table of some sort that listed all that information for all of the notes(C,C#,A,etc). I've been studying another language called Turing. It has a function called play() that accepts a string. So play("AB>C<") would play normal A,B, and a high pitch Middle C.

7. There is a problem in doing this. A is 440 Hz and every other incarnation of A (in other octaves) is 440 * a power of 2 (880, 1760, etc). This also works in the other direction (220, 110, etc). This applies to every note, therefore the problem is that a semitone (distance between 2 adjecent notes) is different for each adjecent pair. It is in fact logarithmic. Unless you can find some sort of table you are going to have trouble.