Click to See Complete Forum and Search --> : Problem with recording from multiple microphones


semiramis
September 18th, 2008, 12:36 PM
Hello Everyone

I'm trying to write an application which gets input voice from 4 different microphones & saves them in four different files.
I've succeeded getting the voices simultaneously, but I can't save them in four different files. I used FileStream method to create files & to write into them; I could create them but all 4input audios go(mix) into the one file while 3 others are left empty. I've used 4seperate threads for 4 audio inputs, & winmm.dll to catch audio from inputs, as well as an M-Audio Delta1010-LT sound card.
I'm using visual studio 2005 & C# on windows platform.
How should I do that?
I appreciate any kind of help, As I need urgent help Confused

I've used a mthod to start capturing called start()
& a class called WaveInRecorder that uses winmm.dll to capture voice, to get available devices & to choose the device to capture voice from.

Here is a sample for two microphones:


private void Start()
{
ThreadStart ts1 = new ThreadStart(doit1);
ThreadStart ts2 = new ThreadStart(doit2);
t1 = new Thread(ts1);
t2 = new Thread(ts2);
t1.Start();
t2.Start();
}

private void doit1()
{

String filename = FilenameBox.Text;
String ending = ".wav";
RecorderOutputStream = new MemoryStream();
WaveLib.WaveFormat fmt = new WaveLib.WaveFormat(44100, 16, 2);
m_Recorder = new WaveLib.WaveInRecorder(Int16.Parse(SoundDeviceBox.Text), fmt, 2048, 1, new WaveLib.BufferDoneEventHandler(DataArrived));

fs = new FileStream(filename + ending, System.IO.FileMode.Create);
}

private void doit2()
{

String filename1 = FilenameBox1.Text;
String ending = ".wav";
RecorderOutputStream1 = new MemoryStream();
WaveLib.WaveFormat fmt = new WaveLib.WaveFormat(44100, 16, 2);
m_Recorder1 = new WaveLib.WaveInRecorder(Int16.Parse(SoundDeviceBox1.Text), fmt, 2048, 1, new WaveLib.BufferDoneEventHandler(DataArrived1));

fs1 = new FileStream(filename1 + ending, System.IO.FileMode.Create);
}
//& These are my DataArrived functions :

private void DataArrived(IntPtr data, int size)
{
if (m_RecBuffer == null || m_RecBuffer.Length < size)
m_RecBuffer = new byte[size];
System.Runtime.InteropServices.Marshal.Copy(data, m_RecBuffer, 0, size);
RecorderOutputStream.Write(m_RecBuffer, 0, m_RecBuffer.Length);
}

private void DataArrived1(IntPtr data, int size)
{
if (m_RecBuffer1 == null || m_RecBuffer1.Length < size)
m_RecBuffer1 = new byte[size];
System.Runtime.InteropServices.Marshal.Copy(data, m_RecBuffer1, 0, size);
RecorderOutputStream.Write(m_RecBuffer1, 0, m_RecBuffer1.Length);
}





Thanks in forward Smile

joe1985
September 20th, 2008, 01:18 PM
Where is m_Recorder declared?

And did you resolve this issue?