Пример #1
0
 void OnAudioFilterRead(float[] data, int channels)
 {
     System.Array.Clear(data, 0, data.Length);
     if (multiplexer.isRunning())
     {
         multiplexer.GetBuffer(IN_PORT, data);
     }
 }
Пример #2
0
 // Dont add to the audio filter callback for control, use the AudioSource instead.
 void OnAudioFilterRead(float[] buffer, int channels)
 {
     if (multiplexer.isRunning())
     {
         /* force to mono*/
         if (channels == 2)
         {
             for (int i = 0, j = 0; i < BUFFER_SIZE; i++, j += 2)
             {
                 monodata[i] = buffer[j] + buffer[j + 1];
             }
         }
         System.Array.Copy(monodata, multiplexer.combinedBuffers[trackNumber], BUFFER_SIZE);
     }
     // We need to zero the buffer after copying it,
     // otherwise it will play in unity as well
     System.Array.Clear(buffer, 0, buffer.Length);
 }