Pregunta

I'm currently trying to use the Ausampler Unit efficiently. I used the code from apple's sample: https://developer.apple.com/library/ios/#samplecode/LoadPresetDemo/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011214-Intro-DontLinkElementID_2

The downside seems to be that it instantly stops a note/sampe if the same note comes in again. So if I send e.g. midi note 60 with the trombone preset loaded. And then while holding this I send note 60 again. It cuts off the first note event. Does anyone know if/how it is possible to hold every single note till a note off event (of this specific note) comes in?

Other question: How can I change the volume of a note after it has been send? E.g. I sent midi note 60 and 70 with 100 velocity. While note 60 still plays I want to reduce the volue but keep note 70 up. This would be called midi aftertouch.

Hope you can help :)

¿Fue útil?

Solución

The AUSampler (kAudioUnitSubType_Sampler) is monotimbral (reference and here) so in order to play two notes of the same pitch simultaneously, you will need two "instruments" - i.e. to instances of the AUSampler. In my projects, I have found that this doesn't add much to the memory overhead since the sound resources get shared.

As for aftertouch - I haven't explored that but it seems like the property you want is kAUGroupParameterID_KeyPressure_FirstKey (References here, and maybe here).

Supporting the kAUGroupParameterID_KeyPressure parameter indicates to 
hosts that your audio unit supports polyphonic "aftertouch" key pressure.

Each of the 128 MIDI key numbers can have its own value for polyphonic 
aftertouch. To respond to aftertouch for a particular key, your audio 
unit needs to support an additional parameter specifically for that key. 
The aftertouch parameter ID for a given MIDI key is equal to the MIDI
key number plus 256. For example, the aftertouch parameter ID for MIDI 
key #60 (middle C) is:

60 + kAUGroupParameterID_KeyPressure_FirstKey = 316

If you get aftertouch working, post back some sample code.

Otros consejos

The accepted answer is WRONG. Timbre and Polyphony are two different things. Mono timbral means that the midi device (in this case the AUSampler instance) can only play a single INSTRUMENT/PATCH at the same time, that has nothing to do with the amount of concurrent notes it can play for that single instrument. A multi timbral device on the other hand, can play several instruments/patches (midi channels) at the same time. The polyphony seems to be limited and hardcoded to 2 notes in the iOS version of the AUSampler and there seems to be no public api to change that.

I don't think that AUSampler is limited to two note polyphony. I am just doing research for my project and it is very important for me.

Have a look at this piano keyboard plugin, author of it mentioned that it was made with AUSampler and from video you can see that it plays four note chords easily.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top