Converting voltages to PCM audio



Hello everyone,

I'm recording audio with a data acquisition card from the speaker
cables. When recording, I get an array of unsigned short integer
values. These I need to convert to PCM audio. Everything works quite
nicely, except the fact that a lot of noise occurs in the PCM file. I'm
using Measurement Computings PCI-DAS6036 -card, and I have tried this
also with a simulated National Instruments PCI-4462 -card (the
simulated card only gives a sine wave).

What I have done is that first I reduce the received unsigned short
values to scale them on the signed short value range (these are from
MCC card, NI card gives voltages which I multiply to match the signed
short value range). After that I write these values to a file with the
following code:

std::ofstream fd;
fd.open(fName, std::ios::out | std::ios::trunc | std::ios::binary);
short tmp = 0;
char byteConvert[2];
for (int i = 0; i < sampleCount; i++)
{
// "scale" to range from -32768 - 32767
tmp = (adData[i] - reduce);

byteConvert[0] = tmp >> 8;
byteConvert[1] = tmp;

// little-endian -format
fd << byteConvert[1] << byteConvert[0];
}
fd.close();

And when this so called audio is played, it has a _lot_ of noise in it
that can not be heard from the speakers or when recording from sound
card. Waveform is correct and you can hear the actual audio playing.
So, is there something I'm missing? Can I convert the received values
directly to PCM format?

And last, but not least, please forgive me if this was an inappropriate
choice for a newsgroup to ask about this matter.

Best regards,
vesse

.



Relevant Pages

  • Re: Converting voltages to PCM audio (programming related)
    ... I'm recording audio with a data acquisition card from the speaker ... These I need to convert to PCM audio. ...
    (comp.dsp)
  • Re: Why are sound ioctl calls so slow?
    ... to go downstairs and fetch the paper before audio would start to play. ... My reference is NetBSD from more than a year ago, ... In particular, when playing back audio on one card, starting or ending ... Comparably, when making a recording, and then starting or ending audio ...
    (freebsd-current)
  • Re: OT: Digitizing My LP Collection
    ...  My cheap phono preamp and on-board audio aren't ... sound card will cover this without difficulty. ... I do favor using a card with more than 16 bits of real linear capture ... Recording and processing vinyl takes an unreasonable amount of time, ...
    (sci.electronics.design)
  • Re: Shaky image
    ... the capture card isn't used right? ... see a way to solve this IRQ sharing problem because it is a mini PC ... > that the audio is at 1.0x "real time" this means, in general, if there ... Do you have any problems if you play a recording using Media Player ...
    (microsoft.public.windows.mediacenter)
  • Re: Shaky image
    ... I recall MCE user had a problem with HT enabled, however, I don't remember ... > between the Hauppauge capture card and the nVidia VGA. ... >> are any problems with the audio there will also be problems with the ... Do you have any problems if you play a recording using Media Player ...
    (microsoft.public.windows.mediacenter)