CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2008
    Posts
    6

    Problem with recording from multiple microphones

    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

  2. #2
    Join Date
    Jun 2007
    Posts
    16

    Re: Problem with recording from multiple microphones

    Where is m_Recorder declared?

    And did you resolve this issue?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured