Hi Tim, how are you doing?
I finally managed to send some audio data to sysvad microphone, but the sound
has some ditortion. Let me tell what I’m doing in details:
1 - I’m using a sample program from MS CaptureSharedEventDriven, to capture audio
using the real microphone from my system.
2 - The mix information from the real microphone is:
Num channels: 2
bits per sample: 32
samples per second: 48000
avg bytes per second: 384000
Block align: 8
3 - The MS sample captures audio and saves it in a wave file so, I needed to change it a little to not add
the wave header and only save the raw data in a file.
4 - From my client app, I’m sending the captured raw buffer to sysvad
via IOCTL.
5 - From sysvad, I needed to set the default format of the virtual mic I’m using to same as the raw format:
{
WAVE_FORMAT_EXTENSIBLE,
2,
48000,
384000,
8,
32,
sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX)
},
STATIC_AUDIO_SIGNALPROCESSINGMODE_DEFAULT,
&MicArray2PinSupportedDeviceFormats[SIZEOF_ARRAY(MicArray2PinSupportedDeviceFormats)-1].DataFormat
5 - From WriteBytes, I’m copying data from private buffer to dmaBuffer on this way:
ULONG runWrite = min(ByteDisplacement, m_ulDmaBufferSize - bufferOffset);
if (m_pExtensionData != NULL && m_pDmaBuffer != NULL) {
ULONG ulRemainingOffset = m_ulSpaceAvailable - m_ulExtensionDataPosition;
UINT32 frameSize = ((UINT32)m_pWfExt->Format.wBitsPerSample / 8) * m_pWfExt->Format.nChannels;
UINT32 framesToCopy = ulRemainingOffset / frameSize;
UINT32 bytesToCopy = min(runWrite, framesToCopy * frameSize);
if (bytesToCopy > 0 && ulRemainingOffset >= bytesToCopy) {
RtlCopyMemory(m_pDmaBuffer + bufferOffset, m_pExtensionData, bytesToCopy);
m_pExtensionData += bytesToCopy;
m_ulExtensionDataPosition += bytesToCopy;
}
else {
DPF(D_TERSE, ("***No room to advance ulRemainingOffset %lu", ulRemainingOffset));
//Call tone generator instead copy data from audio file
m_ToneGenerator.GenerateSine(m_pDmaBuffer + bufferOffset, runWrite);
}
}
bufferOffset = (bufferOffset + runWrite) % m_ulDmaBufferSize;
ByteDisplacement -= runWrite;
6 - After data is loaded to dmaBuffer, I run the CaptureSharedEventDriven program again and capture audio from sysvad virtual microphone.
My intention with this test is to copy captured audio data to dmaBuffer and after it reaches the end, fill it
wiht noise by calling GenerateSine function.
I could achieve the goal, partially The problem is, the audio is there but it’s very distorced.
I’m not sure if the problem is in the logic to copy the captured data into the buffer, the process to generate the raw buffer or some misconfiguration caused by the changes I did on the microphone format pin.
Do you have any idea about what can be causing this distortion? Any information or documentation you have would help me a lot!
Thanks