• Advertisement

Archived

This topic is now archived and is closed to further replies.

Generating a single midi note and playing it immediately

This topic is 5063 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

  • Advertisement