[ad_1]
Can we play a couple of sound on the similar time by the output audiounit?
I’m engaged on a voice chat software and nearly reached the final stage, however I’m on the lookout for a option to hear a couple of individual on the similar time, however I have no idea the place to look… any assist to listen to extra then one at similar time,
i exploit udp ship array bytes convert to AudioBuffer..
and making an attempt to resize audiobuffers so as to add extra knowledge uncooked from 2 array bytes acquired from server however did not work as effectively, one thing robotic nostril occur…
Dec
// set description's
AudioComponentDescription desc = new AudioComponentDescription()
{
ComponentType = AudioComponentType.Output,
ComponentSubType = (int)AudioTypeOutput.VoiceProcessingIO,
ComponentFlags = 0,
ComponentFlagsMask = 0,
ComponentManufacturer = AudioComponentManufacturerType.Apple
};
personal AudioUnitStatus OutputAudio(AudioUnitRenderActionFlags actionFlags, AudioTimeStamp timeStamp, uint busNumber, uint numberFrames, AudioBuffers knowledge)
{
knowledge = new AudioBuffers(1);
// size the buffer audio play
int lengthBytes = 1024 * 2;
// array of array bytes
byte[][] buffers = new byte[2][];
// verify if there buffer in queuen
if (Levels[0].Depend > 0 && Levels[1].Depend > 0)
{
buffers[0] = Levels[0].Dequeue();
buffers[1] = Levels[1].Dequeue();
// resize to at least one array bytes.
buffers[0] = Resize(buffers[0], buffers[1]);
// set measurement buffer.
lengthBytes = buffers[0].Size;
}
else if (Levels[0].Depend > 0)
{
buffers[0] = Levels[0].Dequeue();
}
else
{
return AudioUnitStatus.NoConnection;
}
if (buffers[0] != null)
// set measurement buffer.
lengthBytes = buffers[0].Size;
// create a brand new audiobuffer
knowledge[0] = new AudioBuffer()
{
Information = Marshal.AllocHGlobal((int)lengthBytes * 2),
DataByteSize = (int)lengthBytes * 2,
NumberChannels = 1
};
// set motion flag
actionFlags = 0;
// resize the audioBuffer
var standing = AudioUnit.Render(ref actionFlags, timeStamp, 1, numberFrames, knowledge);
Debug.WriteLine("Debug ::{0} Measurement::{1}", standing, knowledge[0].DataByteSize);
// verify if the buffer did not nullable.
if (buffers[0] != null)
{
unsafe
{
IntPtr output = knowledge[0].Information;
var outputPtr = (byte*)output.ToPointer();
}
// play audiobuffer.
return AudioUnitStatus.NoError;
}
// set mute
return AudioUnitStatus.NoConnection;
}
Thanks very a lot for the assistance
[ad_2]
