Question

I am trying to play midi notes with help of sf2 files using AUSampler audio unit. I was able to start and stop note fine using MusicDeviceMIDIEvent function as below.

noteCommand =   kMIDIMessage_NoteOn << 4 | 0;
MusicDeviceMIDIEvent (samplerUnit, noteCommand, note, velocity, 0);

The note stops after sometime even if I don't call MusicDeviceMIDIEvent function with NoteOff message.

Is there any way to get this note play on until I call the MusicDeviceMIDIEvent with NoteOff? or should the sf2 file be created in a different way so that it contains different sound files for note attack, note sustain etc and the AUSampler unit automatically takes care of playing the sustain sound till NoteOff is called?

Thanks.

Was it helpful?

Solution

You need to set it up in your sf2 file or AUPreset, if you use those. For AUPresets, here's Apple's Tech Note TN2283:

Looping is specified using a Region List property (kAudioFilePropertyRegionList) describing a segment of looped audio data and can be set with the AudioFileSetProperty API.

Here's a long tutorial on using Garageband to set up a looping AUSampler. AU Lab also can generate AUPresets.

For sf2, a youtube video showing how to set up looping. Not clear what software he is using. If you are feeling adventurous, you could try building the open source Swami for OSX

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top