Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to play different notes from a wav file

Status
Not open for further replies.

darkrider

Computer
Nov 4, 2006
1
One interesting thing about music is that notes repeat
%% themselves. So for example there are multiple A's and multiple C's.Though they have the same label, their frequency is different. From one C to the next the frequency doubles. So since middle C is at 261.6 Hz
then the next C would be at 523.2 Hz. The interval between these two notes is called an octave. Starting at C,
%% they would be C, C#, D, D#, E, F, F#, G, G#, A, A#, B, C. To move to the next note we can multiply the frequency by 2^(1/12) which means the notes are equally spaced.

How can i write a function that takes in a note and will play that note.

i know the sinusoid is defined as y(t)=A*cos *pi*f*t+phase).

I just need to create samples at the right frequency for each note.Make the amplitude 1, and the phase at 0. Play in the octave startingwith middle C. Middle A is defined to be exactly 440 Hz. So middle Cis 440/(2^(9/12)) which is about 261.6. We divide since are moving down
steps. I have to use a sampling frequency of 8000 Hz.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor