Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


blending audio data


can someone tell me how to blend audio data (its voice data actually) from a byte array point of view ? so lets say ive got 2 arrays of audio data, and each array is 10 bytes long:

array1 -> 0x01, 0x02, 0x03, 0x04, 0x05, 0x01, 0x02, 0x03, 0x04, 0x05
array2 -> 0x06, 0x05, 0x09, 0x05, 0x04, 0x10, 0x0A, 0x06, 0x0B, 0x03

what i want to do is to blend/combine/merge these into one array. note i dont want to concatenate one onto the other, to give me a 20 byte array, i want to play both arrays at the same time. for example, if array one was someone saying 'hello', and array 2 was someone saying 'goodbye', then in the merged array you would hear both people saying 'hello' and 'goodbye' at the same time. is this even possible ?

a bit of background on what im doing - im making a VOIP system using the WAV api in a C# app. im using the GSM610 codec, and the result is that the average bytes per second recorded from the microphone is 6500 bytes. because the buffer size is 650 bytes, so each client sends 650 bytes of voice data to the server every 10th of a second, thus resulting in 6500 bytes per sec.

the server must then forward these 650 bytes onto all other clients. so if only 2 clients are connected to the server, this is fine, because client A sends 650 bytes to the server, and the server forwards these onto client B. in this case client B is playing client A's voice data at the same rate as client A recorded it. however when a third client C is introduced, now both client A and client C are sending 650 bytes to client B = 1300 bytes. if another client connected, this would now be 650 * 3 = 1950 bytes and so on....but each client only processes 6500 bytes per second, hence things start to sound wrong.

so i need a way of merging each set of 650 bytes into one set of 650 bytes, and then send this merged set to each client. is this performed using a bitwise operation on each byte for example ?


  • darasandarasan Posts: 2

    Mixing (or blending) digital audio is just the sample-by-sample sum of the audio values. So if you have two buffers of audio data, create a third buffer of the same size and for each position in the new buffer, add the 2 values of the other buffers together and copy this new value into the third buffer. The third buffer will then contain the 2 channels mixed together.

    Out of interest, what API / library are you using to process audio data?


  • Would Adobe Audition work? :-D
Sign In or Register to comment.