Sound recording in .net
Author
Discussion

julian64

Original Poster:

14,325 posts

286 months

Tuesday 6th November 2007
quotequote all
anyone managed it. Soundplayer is a good idea, but when it comes to sound recording I can't find any examples. Lots of do it in directsound but no examples. frown

dilbert

7,741 posts

263 months

Tuesday 6th November 2007
quotequote all
Can you still get the Win32Api in there?


typedef struct [grr
WORD wFormatTag;
WORD nChannels;
DWORD nSamplesPerSec;
DWORD nAvgBytesPerSec;
WORD nBlockAlign;
WORD wBitsPerSample;
WORD cbSize;
]grr WAVEFORMATEX;


void CALLBACK waveInProc(
HWAVEIN hwi,
UINT uMsg,
DWORD_PTR dwInstance,
DWORD_PTR dwParam1,
DWORD_PTR dwParam2
);

MMRESULT waveInOpen(
LPHWAVEIN phwi,
UINT_PTR uDeviceID,
LPWAVEFORMATEX pwfx,
DWORD_PTR dwCallback,
DWORD_PTR dwCallbackInstance,
DWORD fdwOpen
);

MMRESULT waveInStart(
HWAVEIN hwi
);

MMRESULT waveInStop(
HWAVEIN hwi
);

MMRESULT waveInClose(
HWAVEIN hwi
);


Actually it seems as though it's the multimedia API, so it might just be the same for .NET.

As far as I remember you prepare a group of buffers, and pass them to the interface, the callback is called each time a buffer is filled, you empty out the buffer, and pass it back to the interface.

Wav file format is just 16bit audio data with the left and right channels interleaved on 16bit boundaries. The data is at 44KHz rate. The file has about ten bytes at the top to specify the format. You can do others, but everyting will recognise that format.

Edited by dilbert on Tuesday 6th November 18:13