FMOD and underlying DLS Instruments being played by Midi


(Michael Sutton) #1

I am integrating FMOD in a game (Sansar). Currently I can play a midi file which I assumes is playing the midi file using a DLS instrument. A few questions before I dive into the low level programming:

  • Can you load your own DLS (For example a custom SF2 file of mine converted to DLS)?
  • If you can load that, how do you point the MIDI file being played to that DLS instrument instead of the default one?
  • Can you play a note from the DLS instrument directly in code rather than bringing in a precanned midi file?

That being said, what I am trying to do is build an instrument in the game. I have it working and it plays a sample with an offset for an instrument (say a piano). The problem I have since it is just playing the sample it only plays for the length of the sample (i.e. it doesn’t play the loopable portion that is available by looking in the WAV file and playing it like a DLS or SF2 instrument. So, I am looking for a way that the sound will keep playing as long as I am pressing the key down on my keyboard and when I release it will stop playing the loopable portion of the WAV file. So, I am hoping to somehow get at the DLS instrument directly with code commands instead of it just being a simple midi player.


(Brett Paterson) #2
  1. Yes you can use any DLS you want
  2. FMOD_CREATESOUNDEXINFO has this member
    const char dlsname; / [w] Optional. Specify 0 to ignore. Filename for a DLS sample set when loading a MIDI file. If not specified, on Windows it will attempt to open /windows/system32/drivers/gm.dls or /windows/system32/drivers/etc/gm.dls, on Mac it will attempt to load /System/Library/Components/CoreAudio.component/Contents/Resources/gs_instruments.dls, otherwise the MIDI will fail to open. Current DLS support is for level 1 of the specification. */
  3. Yes, but it wont have the envelope applied, just the raw sounds. I dont think you can retrieve the DLS object from the MIDI sound, but you can load the DLS yourself and play the sounds with Sound::getSubSound