I'm trying to play instrument of several .wav samples using AudioKit.
I've tried so far:
- Using
AKSampler(with underlyingAVAudioUnitSampler) – it worked fine, but I can't figure out how to control ADSR envelope here – callingstopwill stop note immediately. - Another way is to use
AKSamplePlayerfor each sample and play it, manually settingrateso it play the right note. I can (possibly?) then connectAKAmplitudeEnvelopeto each sample player. But if I want to play 5 notes of the same sample simultaneously, I would need 5 instances ofAKSamplePlayer, which seems like wasting resources.
I also tried to find a way to just push raw audio samples to the AudioKit output buffer, making mixing and sample interpolation by myself (in C, probably?). But didn't find how to do it :(
What is the right way to make a multi-sampled instrument using AudioKit? I feel like it must be a fairly simple task.