Page 1 of 1 [ 8 posts ] 

ahayes
Veteran
Veteran

User avatar

Joined: 2 Dec 2006
Gender: Male
Posts: 9,506

30 Mar 2007, 7:17 pm

How do you interpret sheet music?

I want to take some sheet music and feed it into a computer program that will play it through a PC speaker.

Specifically I need to know from the sheet what note to play(among the options of CDEFGAB on C4, or if it isn't among those what the frequency of the note I should play is in terms of hz) and how long to play it in terms of milliseconds, and how much time should be in between notes (again in terms of milliseconds, or fractions of a second at least).



atxa
Velociraptor
Velociraptor

User avatar

Joined: 3 Jun 2006
Age: 53
Gender: Male
Posts: 464
Location: Can

31 Mar 2007, 7:47 pm

ahayes wrote:
how long to play it in terms of milliseconds, and how much time should be in between notes (again in terms of milliseconds, or fractions of a second at least).


Do you know about music theory ?

You should know how BPM and note duration work, and you should use mathematic with that.

I already did a 20 seconds song with Turbo Pascal and it took me like 6 hours.

Exemple:

If the BPM (Beat per minute) is 60.
The length of the Whole note is 4 seconds
The length of the half note is 2 seconds
The length of the quarter note is 1 seconds
The length of a Flag is half of a seconds

If the BPM (Beat per minute) is 120, you divide everything by 2 ...

So you should do a function who will tell to the computer how long to play a note in milliseconds versus the BPM.

Give me 2 or 3 lines of code to play a note for 1 second, and I'll try do give you more explanation about the mathematic for that function.

Do you speak french, cause it could be easier.



Todd489
Veteran
Veteran

User avatar

Joined: 24 Jan 2007
Gender: Male
Posts: 997

31 Mar 2007, 8:16 pm

4/4 next to the Treble Clef sign means 60 BPM, 4/8 means 120 BPM. The top number represents the number of beats in a measure and the bottom represents the duration of a quarter note (4 meaning 1 beat, 8 meaning 2, etc.) That's called Time Signature. The note duration is controlled by changing the appearance of the note on the staff. Circle with no tail is a whole note (4 beats), circle with tail is half note (2 beats), filled in circle with tail is quarter note (1 beat), and circle with tail and flag is eigth note (1/2 beat). Add more flags to divide it up more (example: 16th note would have two flags, 32nd note would have three). What letter the note is (CDEFGAB etc) depends on the position of the note on the lines and spaces of the staff. The bottom "line" is E3 and the top is F4. The bottom "space" is F3 and the top space is E4. The number next to the note is the octave it's in on a standard keyboard, with 3 being the middle keys. To move up or down an octave (example C2 or B#5) you must make another staff above or below the original. To sharpen or flatten a note, simply draw in the (#) or (b) next to the note. I would recommend getting a copy of Guitar Pro 5 as it is much easier to use than Pascal or Powertab and allows you to use TAB notation alongside the sheet music if you get lost. It also has virtually any instrument you could want and allows for up to 16 simoultaneous instruments.

I hope that helps in some way. I'd draw up some diagrams but I'm way too tired right now. Feel free to ask questions, though.



jonathan79
Veteran
Veteran

User avatar

Joined: 1 Mar 2006
Age: 45
Gender: Male
Posts: 524
Location: FoCo

31 Mar 2007, 11:32 pm

I would recommend that you simply try to find the songs online as midi files. Inputing every single note of a song into a computer is time consuming.


_________________
Only a miracle can save me; too bad I don't believe in miracles.


ahayes
Veteran
Veteran

User avatar

Joined: 2 Dec 2006
Gender: Male
Posts: 9,506

01 Apr 2007, 3:23 am

It's not as hard as you think.

The program I have now is set up so that you type a string of the notes you want to play and they are "streamed" into an object that plays them.
cdefgab
I.E. to play twinkle twinkle little star:

Code:
//this play object looks at the incoming string and plays the corresponding note for 100ms, and an inaudible sound for 100ms for other characters
Play play1;
char *notes1 = "c c g g a a g";
char *notes2 = "f f e e d d c";
char *pause = "  ";
play1 << notes1 << pause << notes2 << pause << notes2 << pause << notes2 << pause << notes1 << pause << notes2;



jonathan79
Veteran
Veteran

User avatar

Joined: 1 Mar 2006
Age: 45
Gender: Male
Posts: 524
Location: FoCo

01 Apr 2007, 4:05 am

ahayes wrote:
It's not as hard as you think.

The program I have now is set up so that you type a string of the notes you want to play and they are "streamed" into an object that plays them.
cdefgab
I.E. to play twinkle twinkle little star:
Code:
//this play object looks at the incoming string and plays the corresponding note for 100ms, and an inaudible sound for 100ms for other characters
Play play1;
char *notes1 = "c c g g a a g";
char *notes2 = "f f e e d d c";
char *pause = "  ";
play1 << notes1 << pause << notes2 << pause << notes2 << pause << notes2 << pause << notes1 << pause << notes2;


Oh, I thought you were going to try an input a concert piece, not twinkle twinkle. If thats the case, then by all means, go for it.


_________________
Only a miracle can save me; too bad I don't believe in miracles.


Jonny
Velociraptor
Velociraptor

User avatar

Joined: 9 Feb 2005
Gender: Male
Posts: 440
Location: London

01 Apr 2007, 4:30 am

Once you learn the above.

Get the free http://www.finalemusic.com/notepad/ and start typing away.

I think the same company do a piece of software which allows you to scan and it will automagically interpret the sheet music.

Export the MIDI and use some quality samples and away you go!



atxa
Velociraptor
Velociraptor

User avatar

Joined: 3 Jun 2006
Age: 53
Gender: Male
Posts: 464
Location: Can

01 Apr 2007, 9:55 am

If you want to get some ideas on music program, you can give a look at Musix (Linux Live CD), maybe there is some source code on it.