Luke De Feo
Luke De Feo

Reputation: 2165

Aftertouch / Pressure Midi command not working in AVFoundation

I am using AVAudioUnitSampler to play some midi sounds, i have a soundfont loaded and have sucessfully use start note, stop note and apply pitch bend midi commands. I am now trying to incorporate aftertouch or pressure commands as it is called in AVFoundation.

So my code looks roughly like this (simplified):

self.midiAudioUnitSampler.startNote(60, withVelocity: 60, onChannel: 0)
//some time later... 
self.midiAudioUnitSampler.sendPressure(20, onChannel: 0)

The note is humming away but the send pressure commands seem to have no effect on the sound output. I have tried using send pressure and sendPressureForKey to and no luck.

What am i doing wrong or am I misunderstanding what sendPressure does? I expect it to change the volume of the note after it is played.

Btw i have a setup where the note is being played and i have a separate Control to fire pressureCommands into the samplee at some time after the note playback has been started.

Upvotes: 1

Views: 263

Answers (1)

sven7
sven7

Reputation: 758

My guess is that the sampler does not know what to do with aftertouch messages. If you want to change the volume of the note (and any other notes playing) you could send your value to parameter 7 (volume) instead:

self.midiAudioUnitSampler.sendController(7, withValue: 20, onChannel: 0)

From my experience I have the feeling that the sampler does responds to MIDI controller 7.

Upvotes: 1

Related Questions