Advertisement

Generating a single midi note and playing it immediately

Started by April 12, 2004 04:10 PM
1 comment, last by Freysi 20 years, 7 months ago
Not sure whether I''m in the right forum for this... All I need to do is to generate a midi note and play it immediately. Like for example playing a note whenever a ball strikes a surface. I''ve tried using DirectMusic but got totally lost in all the crap surrounding it. I actually had no problem getting DirectMusic to play a pre-existing midi file, but generating a singular event and playing is another story. Can anybody help?
Do you want to play a random note or the same one? Either way, if you can get a MIDI file to play then you can get a DM segment to play just as easily.

The simplest way would be to write a script in DMP which does what you like, then call that subroutine from within your program every time the event takes place.

Give me a bit more info and I''ll help you out.
Advertisement

You need to generate a note-on event to start the note and a note-off event (with the same channel and the same note) to end the note. There needs to be a delay between them otherwise the note will be too short, so you''re program will need to know when to go back and do the note-off, unless you have some way around that.

How to generate the events using DirectMusic is beyond me, I only know about it in Allegro, and it only takes a few lines.

This topic is closed to new replies.

Advertisement