anyone have or know of example source code for 24-bit 2..n channel
audio recording?
I couldn't find anything actually useful on MSDN either (even the
description of WAVEFORMATEXTENSIBLE is very badly written). I can't
use DirectSound because the project is in VC6.0 and the DirectX SDK
is not available for VC6.
Also I'm a bit puzzled as to why 24-bit recording does not work
properly. WinXP Pro, Audigy 2 NX external 24-bit and on-board cheapo
16-bit. With my code 16-bit recording works fine on both, but with
24-bit only on the cheapo 16-bit but not the Audigy.
In GoldWave, both cards record fine with 24-bit (apparently using
WDM/WinMM and not directx).
This is the waveformatextensible used:
/* Init Extensible wave-format structure (>16-bit) */
sWaveFormatPcmEx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
sWaveFormatPcmEx.Format.nChannels = NUM_IN_OUT_CHANNELS;
// container size:
sWaveFormatPcmEx.Format.wBitsPerSample = sizeof(_SAMPLE) * 8;
sWaveFormatPcmEx.Format.nSamplesPerSec = SOUNDCRD_SAMPLE_RATE;
sWaveFormatPcmEx.Format.nBlockAlign = NUM_IN_OUT_CHANNELS *
sizeof(_SAMPLE);
sWaveFormatPcmEx.Format.nAvgBytesPerSec = sWaveFormatEx.nBlockAlign
* sWaveFormatEx.nSamplesPerSec;
sWaveFormatPcmEx.Format.cbSize = 22;
sWaveFormatPcmEx.dwChannelMask = SPEAKER_FRONT_LEFT |
SPEAKER_FRONT_RIGHT;
sWaveFormatPcmEx.Samples.wValidBitsPerSample = BITS_PER_SAMPLE;
sWaveFormatPcmEx.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
where
#define SOUNDCRD_SAMPLE_RATE 48000
#define NUM_IN_OUT_CHANNELS 2
#define BITS_PER_SAMPLE 24
#define NUM_SOUND_BUFFERS_IN 24
typedef signed long _SAMPLE;
_SAMPLE* psSoundcardBuffer[NUM_SOUND_BUFFERS_IN];
Nothing wrong so far, or..? I also tried unsigned long for _SAMPLE,
no difference for the Audigy. Only when BITS_PER_SAMPLE is set to 16
then it will start working on the Audigy too, still with typedef
unsigned long _SAMPLE.
lpwavehdrs set up like
/* Set struct entries */
m_WaveInHeader[iBufNum].lpData = (LPSTR) &
psSoundcardBuffer[iBufNum][0];
m_WaveInHeader[iBufNum].dwBufferLength = iBufferSizeIn *
BYTES_PER_SAMPLE;
m_WaveInHeader[iBufNum].dwFlags = 0;
/* Prepare wave-header */
waveInPrepareHeader(m_WaveIn, &m_WaveInHeader[iBufNum],
sizeof(WAVEHDR));
and wave device is opened like
result = waveInOpen(&m_WaveIn, iCurInDev,
(WAVEFORMATEX*)&sWaveFormatPcmEx,
(DWORD) m_WaveInEvent, NULL,
CALLBACK_EVENT);
The actual code is zipped at
http://drm.sourceforge.net/forums/index.php?act=Attach&type=post&id=747
and in .\windows\Source\Sound.cpp, Sound.h
Any ideas? Or any example code suggestions?
Or can there somehow be a difference in WAVEFORMATEXTENSIBLE in
WinMM vs DirectX!?
- Jan
> Hi,
>
> anyone have or know of example source code for 24-bit 2..n channel
> audio recording?
>
> I couldn't find anything actually useful on MSDN either (even the
> description of WAVEFORMATEXTENSIBLE is very badly written). I can't
> use DirectSound because the project is in VC6.0 and the DirectX SDK
> is not available for VC6.
...
> Any ideas? Or any example code suggestions?
Try setting the channelMask to 0. You should not have a channelmask for
recording, it's behaviour is undefined.
> Or can there somehow be a difference in WAVEFORMATEXTENSIBLE in
> WinMM vs DirectX!?
There normally isn't, but I know that Creative doesn't support
multi-channel with winMM and perhaps it doesn't support other extensible
formats as well. I have a test program if you need it.
-Chris
Thanks. Couldn't get back to try this until now, though. I tried your
suggestion, but even with dwChannelMask = 0 it does not work (records
only silence).
Odd that the recording behaviour of dwChannelMask is left undefined even
in http://www.microsoft.com/whdc/device/audio/multichaud.mspx#ENLAC,
e.g. for mono recording it would be just perfect to select the source
channel. Well well.
>>Or can there somehow be a difference in WAVEFORMATEXTENSIBLE in
>>WinMM vs DirectX!?
>
> There normally isn't, but I know that Creative doesn't support
> multi-channel with winMM and perhaps it doesn't support other extensible
> formats as well.
That could of course very well be the case :|
> I have a test program if you need it.
Thanks, that'd be great! If you have a download link, or could email it
then my address is jwagner át cc . hut . fi (should still have a few ten
megs free space there)
- Jan