Jerry:
Use MusicDeviceStartNote and MusicDeviceStopNote -- these are alternative APIs (to MusicDeviceMIDIEvent) for playing notes and while they will not necessarily work with all audio/MIDI devices, they will work with the DLS and seem to be fine with most audio units I have tried using them with.
The last argument to MusicDeviceStartNote is a reference to a MusicDeviceNoteParam which can hold fractional pitches (and fractional velocities if you want them).
This will work much better than pitch bend which operates on all notes in the channel rather than on individual notes.
(assuming instance variables graph and synthnode are set up...)
- (void)startNote:(Byte*)message ofSize:(int)size withFraction:(float)frac { AudioUnit synthUnit; int channel = message[0] & 0x0F; Boolean isRunning = NO; MusicDeviceNoteParams noteInfo; ComponentResult err; NoteInstanceID midiPitch = message[1]; noteInfo.argCount = 2; noteInfo.mPitch = midiPitch + frac; noteInfo.mVelocity = (float)message[2]; .....
AUGraphIsRunning(graph, &isRunning); if (isRunning) { AUGraphGetNodeInfo (graph, synthNode, NULL, NULL, NULL, &synthUnit); MusicDeviceInstrumentID instrumentID = [self currentInstrumentOnChannel:channel]; err = MusicDeviceStartNote(synthUnit, instrumentID, channel, &midiPitch, 0, ¬eInfo); } .....
}
Yours, Keith Hamel
|