0
\$\begingroup\$

I am working on Active Noise Cancellation Project. I came across a problem, where the signal is getting attenuated as the audio bit depth changes from PC data to Microcontroller and I cannot understand it!
My circutit :I connected Audio Output(Head phones) of PC[which is supposed to be analog signal] to Audio IN of NI myRIO 1900 device using AUX cable (two way 3.5mm jack cable). I have a pre-recorded signal(.wav) of sinusoidal waveform with Amplitude 1, Frequency 2kHz, 40000 Sample Rate, 80 Number of Samples, Bit depth( bits per sample) = 16.
Now, I just played .wav file using windows media player and tried to record the waveform on NI myRIO module. Surprisingly, I am getting an attenuation of the signal corresponding to the volume reduction in PC(not linear!!). Only I can see the waveform in microcontroller close to amplitude 1, when I increased the volume of the system to 100%. Please explain this !!

The ADC of NI myRIO has its Resolution as 12 bits but the audio Output(.wav file) is 16 bit data. I am expecting it does not have to matter except in quantization errors, as at the PC Audio Out, the audio data should be converted to analog and and again at the 'NI myRIO Audio In', this analog signal will be sampled! (please correct me if I am wrong !)
Another question is, I have tried the same with sinusoidal sound of Amplitude 2.5, now the audio signal is clipped off at 1V above and below -1V. enter image description here
ADC(NI myRIO) nominal range is 2.499V to -2.5V! Is it bacause of the bit depth conversion?
Please explain these things !TQ
EDIT: I am not converting either 16 bit digital data to 12 bit digital data neither 12 to 16 !! I happen to have a 16 bit audio data, when I played this through windows media player will get converted to analog signal at head phones terminal, and I am feeding this ANALOG Signal to an ADC of NI myRIO, which has 12 bit resolution.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Had a hard time understanding your question. But when you increase the bit depth, you have to align the most significant bit. Probably you are copying 12 bit data into 16 bit words and aligning the least significant bit? \$\endgroup\$
    – user57037
    Nov 13, 2015 at 2:38
  • \$\begingroup\$ I think the output of your PC is clipping. Your intuition about bit depth not being a factor is correct as far as I can tell. \$\endgroup\$
    – Daniel
    Nov 13, 2015 at 3:36
  • \$\begingroup\$ @mkeith Apologies for 'confusing queston'. I have re framed the question little bit for better understanding. I am not copying 12 bit data to 16 bit words ! \$\endgroup\$
    – charansai
    Nov 13, 2015 at 10:42

3 Answers 3

0
\$\begingroup\$

After you've added more info to your question, it would seem that the cause is less to do with the sampling (bit) depth and more to do with the analog connection between two systems.

It looks like you are reaching the limits of the PC's audio output. PCs use line level output, which ranges from +1V to -1Volt. That lines up with the level you are seeing on the myRUI 1900 - you've got a chart there showing the signal in ranging from 1V to -1V which is to be expected.

The signal is clipped because your signal is being clipped by the PC. If you try to send a signal out of the PC with an amplitude that is too high, it will be clipped.

It might be clipping in software before it hits the hardware, or it might be clipping in the hardware. Some parts of the volume controls are in the hardware, some parts are in the software.

The parts of the volume controlling in software can amplify a signal to the point that it can't be represented in 16Bits anymore and gets clipped.

The parts of the volume control in hardware can amplify the signal to the point that the output amplifier itself clips.


In summary:

  1. You cannot generate a signal with a PC that will cause a full scale input on the myRUI 1900. The PC simply cannot generate a signal with the needed voltage range.
  2. Cranking up the volume on the PC to try to force a higher level will only cause clipping, which results in the signal you have captured with the myRUI 1900.
\$\endgroup\$
1
  • \$\begingroup\$ It is true! I think the clipping is happening at software level, because whatever be the system volume, if the amplitude of sin is above 1V , then it is getting clipped ( even with lowest volumes also). Also these line in/out voltages will vary depending on the sound cards that we are using ! Built in sound card of PC is giving 1.6V amplitude for sine wave of 1V amplitude with 100% volume rise, whereas if I use external sound card, I am getting 1V amplitude same as that of sin wave. Thank you ! \$\endgroup\$
    – charansai
    Nov 14, 2015 at 14:49
1
\$\begingroup\$
Surprisingly, I am getting an attenuation of the signal corresponding to the volume reduction in PC(not linear!!). Only I can see the waveform in microcontroller close to amplitude 1, when I increased the volume of the system to 100%. Please explain this !!

Humans don't perceive sound intensity linearly, but rather logarithmically. For a series of doublings in sound power is perceived as a linear volume series. This has been well known for over a century, so the people that designed the volume control in your PC software know this too. To give you what you will perceive as a linear volume control means actually varying the voltage exponentially. This is why the voltage drops quickly from maximum as the volume is turned down only a little.

\$\endgroup\$
0
\$\begingroup\$

I came across this strange problem, where the signal is getting attenuated as the audio bit depth changes and I cannot understand it!

You have a 12 bit resolution signal and you convert it to 16 bits. One of two things happen. Either: -

  1. The original 12 bits are mapped to the top 12 bits of the 16 bit number and the lower 4 bits of the new 16 bit number are set to 0 or,
  2. The original 12 bits are mapped to the lower 12 bits of the 16 bit number and the upper 4 bits set to zero.

Number 1 will make no difference in the loudness of your signal and #2 will significantly reduce the amplitude by 16:1 whilst retaining the same signal to noise ratio (not a bad thing).

So why is #2 preferred? An example would be when mixing sounds digitally. You can now add 16 such converted waveforms and avoid clipping. You can't really do anything with #1 that you couldn't already do when it was 12 bit format.

\$\endgroup\$
4
  • \$\begingroup\$ I am sorry, can you answer my basic question? If we have .wav audio file(encoded with 16 bit data), Is the output of PC through headphones an analog signal or still 16 bit digital data !? Simply, will my PC have DAC at headphones output terminal ?? Seems like my question framing is not good, everybody misunderstood( I think!). I am not doing 12 bit to 16 bit data conversion. I happen to have a 12 bit resolution ADC in microcontroller(myRIO) and I can only play .wav files in any media player when they are encoded with 8 bit or 16 bit! \$\endgroup\$
    – charansai
    Nov 13, 2015 at 10:11
  • \$\begingroup\$ Headphones are analogue and there will be a DAC in your sound card - a speaker doesn't know what a digital signal is therefore conversion to analogue is a MUST. BTW, I've copied your first query into my answer right at the top - maybe it is you who have forgotten what the question is? \$\endgroup\$
    – Andy aka
    Nov 13, 2015 at 10:19
  • \$\begingroup\$ Hmm k, I thought you are answering the whole question :) \$\endgroup\$
    – charansai
    Nov 13, 2015 at 10:22
  • \$\begingroup\$ Well maybe you need to re-phrase it - from what I suspect there is a much simpler version of your question waiting to be teased out. Now I've answered your first question and what appears to be a supplementary question about where the DAC is when connecting headphones. Try a simpler approach. \$\endgroup\$
    – Andy aka
    Nov 13, 2015 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.