Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ADSR in iOS, sample code?

I've been searching for some examples that show how to do ADSR in iOS using audio samples (preferably WAV files with loop points, but thats secondary). I guess most people who write a sampler/synth app use audio unit for this. Does any one know a good code example that shows ADSR in any iOS audio library?

like image 628
lukebuehler Avatar asked Oct 31 '25 16:10

lukebuehler


2 Answers

In the new iOS SDK 5.0 there's now a Sampler Audio Unit! Which can do ADSR envelopes.

The presets demo shows how to use the sampler: http://developer.apple.com/library/ios/#samplecode/LoadPresetDemo/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011214

If you want to load different sound formats to play this article is helpful: https://developer.apple.com/library/mac/#technotes/tn2283/_index.html

And here's the iOS documentation reference: http://developer.apple.com/library/ios/#documentation/AudioUnit/Reference/AUComponentServicesReference/Reference/reference.html#//apple_ref/doc/uid/TP40007291

like image 64
lukebuehler Avatar answered Nov 03 '25 09:11

lukebuehler


you can find (a very basic) one in the Apple's SinSynth sample. That is an AU, but it should demonstrate how one would apply a envelope to an audio buffer. i don't remember - it may simply be an ASR, but adding a fourth stage is simple once you have understood the existing program. The implementation is right in the note's render.

Envelope Generators are not platform specific.

musicdsp.org will be a better resource if you want more than a push in the right direction.

like image 31
justin Avatar answered Nov 03 '25 08:11

justin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!