android - openSL Enqueue plays buffers only one after another ? Why not mixed? -


in opensl when create simplebufferqueue, why plays buffers 1 after ? how scenario helpful ? more practical usage when can create 5 or more buffers , can play them mixed/simultaneously enque buffer !

as of now, way play sounds creating multiple simple buffer queue audioplayers.

please , correct if reading wrong in opensl documentation !

opensl es designed useful audio api. advanced audio workstation apps, synthesizer apps, etc. possibly going have lot of effects , internal mixing done programmers. portability of design , code, that's needed somewhere put output.

with opensl, if want play sounds simultaneously, should mix them , load buffers mixed sound. easiest way add them sample-by-sample. assuming each sound can achieve maximum headroom, divide number of input sounds. (this division can make volume bit low, takes effort around it, assuming clipping unacceptable.)

to mix 2 sounds, when create sample of output (i.e., data enqueued), this:

out[i] = (snd1[i] + snd2[i])/2; 

(you may want optimize math, watch out data types, , might use different indices.)

in general:

out[i] = (snd1[i] + ... + sndn[i])/n; 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -