NotePlayer Kit

Realbasic's use of QT Musical Instruments (the noteplayer control) is about the worst I can possibly think of. In order to play a single note that STOPS, you have to create not only a noteplayer, but also a timer to stop the note, and a button to play the note. What a waste of time!

  NotePlayer Kit fixes this. This class adds two very useful methods to the NotePlayer control: ParseLine and Play. Anyone who's ever used QBasic or GW-Basic will feel right at home with the ParseLine command. It works just like the Play command in these languages. Here's a sample.

  NotePlayer.ParseLine "t240 C D E F G O+ L4 A L2. B L2 C"

  In this sample, the first line tells the NotePlayer what to prepare to play. The syntax is relatively simple. Everything is seperated by spaces. To play a note, simply type its name. To change the octave, type O+ or O-. To change the length of the notes, type L followed by a number. Here's the complete list:

Letter What it does
Tnum   Changes the tempo. The number is the number of quarter notes in a minute.
Lnum [.]   Changes the length of notes. The number is a length. (1=whole note, 4=quarter, etc.) A dot works the same way it does in real music. Anything is valid, even a 57th note (though it's hard to stamp your foot to).
pnum   Pauses for num. p8 would be an eighth rest, p1 would be a whole rest, etc.
inum   Changes the emphasis on the notes. The higher the number, the louder the notes, and vice-versa.
O{+;-}   Changes the octave. + increases it, and - decreases it. Middle C is in octave 5. All octaves start with A.
A-G[#;-]   Plays a note. The letter is the name of the note. A # raises it by a half-step, and a - lowers it one half step. You can use as many as you want (i.e., A###- is valid).

  After you've entered the music using ParseLine, simply use the play method to play it. Music plays in the background, and uses its own special thread, so that you don't have to worry about it. If you try to start playing music while other music is still playing, nothing will happen. You can find if there is any music playing by using the .IsPlaying boolean.

  And there are still two more goodies! NotePlayer Kit works with all 128 instruments. And, best of all, it has a Speed property. 1.0 is normal speed. 2.0 is double speed, 0.5 is half-speed, and so on. Woohoo!

  That's not all though. NotePlayer Kit also comes with a list and popupmenu class that automatically fill with the names of all 128 instruments–in order.

  Don't you just want to...
Download noteplayerkit.sit.hqx 7.5K

Back to the main page