Simultaneously generate multiple sine waves into sample buffer for audio unit (iOS) -


given array (of changing length) of frequencies , amplitudes, can generate single audio buffer on sample sample basis includes tones in array? if not, best way generate multiple tones in single audio unit? have each note generate it's own buffer sum output buffer? wouldn't same thing doing @ once?

working on ios app generates notes touches, considering using stk don't want have send note off messages, rather generate sinusoidal tones notes i'm holding in array. each note needs produce 2 sinusoids, varying frequency , amplitude. 1 note may playing same frequency different note note off message @ frequency cause problems. want manage amplitude (adsr) envelopes each note outside of audio unit. want response time fast possible i'm willing work/learning keep audio stuff low level can.

i've been working sine wave single tone generator examples. tried doubling 1 of these, like:

buffer[frame] = (sin(theta1) + sin(theta2))/2

incrementing theta1/theta2 frequency1/frequency2 on sample rate, (i realize not efficient calling sin() ) aliasing effects. i've yet find example multiple frequencies or data sources other reading audio file.

any suggestions/examples? had each note generate own audio unit, gave me latency touch note sounding (and seems inefficient too). newer level of programming digital audio in general, please gentle if i'm missing obvious.

yes of course can, can whatever inside render callback. when set call up, can pass in pointer object.

that object contain on off states each tone. in fact object contain method responsible filling buffer. ( make sure object nonatomic if property -- otherwise artefacts due locking issues )

what trying achieve? need generate on-the-fly?

if so, run risk of overloading remoteio audio unit's render callback, give glitches , artefacts

you might away on simulator , move on device , find mysteriously isn't working more because running on 50 times less processor, , 1 callback cannot complete before next 1 arrives

having said, can away lot

i have made 12 tone player can simultaneously play number of individual tones

all have ring buffer each tone (i using quite complex waveform takes lot of time, in fact calculate first time application run , subsequently load file), , maintain read-head , enabled flag each ring.

then add in render callback, , handles fine on device, if 12 playing together. know documentation tells not this, recommends using callback in order fill 1 buffer another, can away lot, , pita code sort of buffering system calculates on different thread.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -