Audio recording in C# ... how?

  • Thread starter Thread starter Meng Zhuo
  • Start date Start date
M

Meng Zhuo

Hi

I would like to record audio from my mixer source (microphone,
line-in, midi...) to wave (PCM) format (filename is known) ... that's
all. I've been looking for a really long time now on the internet, The
Code Project, forums ... everywhere, the only thing I can find is how
to play audio files and some XML stuff. It's the first time I have to
create a C# audio program, so ... ;)

Thanks to anyone who can tell me how to do this
 
Meng Zhuo said:
Hi

I would like to record audio from my mixer source (microphone,
line-in, midi...) to wave (PCM) format (filename is known) ... that's
all. I've been looking for a really long time now on the internet, The
Code Project, forums ... everywhere, the only thing I can find is how
to play audio files and some XML stuff. It's the first time I have to
create a C# audio program, so ... ;)

Thanks to anyone who can tell me how to do this

You need to use DirectX, specifically DirectShow I believe. It's quite
complicated to get DirectShow up and running in C# but once you do it would
be fairly easy to achieve what you want. First, download and install the
DirectX 9 SDK and then have a look at these samples:

http://www.codeproject.com/cs/media/directshownet.asp

https://sourceforge.net/projects/directshownet/

Also have a look at the samples in the DirectX SDK as well as the help file
provided with it. There is a direct show book provided by microsoft that is
excellent which I got second hand off amazon for $12.

Michael
 
Meng,

You obviously didn't check out the Code Project well enough. Here is a
link to an article with code:

http://www.codeproject.com/cs/media/cswavrec.asp

There are other coding examples for recording found at the Code
Project. In fact, I used code from this source to create an application
that lets me record from sound cards.

By the way, you don't need DirectShow. Either DirectSound or the
WaveIn/WaveOut APIs will suffice.

Best Regards
Johann Blake
 
Meng,

You obviously didn't check out the Code Project well enough. Here is a
link to an article with code:

http://www.codeproject.com/cs/media/cswavrec.asp

There are other coding examples for recording found at the Code
Project. In fact, I used code from this source to create an application
that lets me record from sound cards.

By the way, you don't need DirectShow. Either DirectSound or the
WaveIn/WaveOut APIs will suffice.

Best Regards
Johann Blake

Ok, i decided to follow your solution :)

The thing is now, i think my program is finished, there's only one
little thing i have troubles solving now. The audio mixer is set to
record from midi, the midi is played after pressing a button, pressing
the same button starts recording the Wave ... i see in the example on
Code Project there is a buffer for recording (m_Fifo). How do i store
it's data into a wave-file? In the example i also find a
openFileDialog, but it's never used :). I tried just dumping data in
files in different ways, but i always get a message like invalid audio
file.

Thanks again,
Meng Zhuo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top