Search code examples
matlabaudiousbaudio-recordingdistortion

USB Audio, distortion in low bits


I've implemented a PIC32 as a USB sound card, using USB Audio Class 1. I'm sending a sawtooth signal from the microcontroller to the PC(windows 7, 64 bit), as 16-bit samples:

in decimal:

000
800
1600
2400
.. so on

then i try recording the received audio using Audacity, with MME -driver, as .wav or .raw. I use MATLAB to open and inspect the data, and there i see data like:

000
799
1599
2400
..

The distortion varies from -1 to +1 bit pr sample.. Anyone have any idea where the problem might be.? Windows-audio drivers.?


Solution

  • I solved my problem..

    The problem was caused by the application i used to record the data, and the method i used.. I used Audacity, which supports the old windows MME audio API, and the DirectSound API. These are relatively high-level API's apparently, and are the cause of the distortion. About the Windows Core Audio APIs

    Instead i used another program, called Reaper, it has an option to record using ASIO og WASAPI. This solves my problem. I've checked every sample in an 2 hour .wav file, using MATLAB, and it is completely bit-perfect.

    I was probably some quantization error, but it was caused by the API. ASIO and WASAPI gave me bit-perfect sound, MME and DirectSound gave me a distorted signal.