Skip to contentSkip to conversation

USB device gives wrong data?

DISCUSSION william estrada 3 participants 4 messages Oct 19, 2007 – Oct 22, 2007 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi group,

I think I have found a problem with the USB sound driver? It appears
that the current drive returns a x'81' for silence but it should be a x'7f'.

When I use my laptop's sound device and record without a mic, I get
a file full of x'7f's. If I do the same with my cheap-o USB device I get a file full of x'81's. The sound quality from the laptop is unacceptable, so that is way I want to use the USB device.

I have written a recording program that I have a 'silence' filter
that filters out segments of dead air. It works with the laptop's sound device but not the USB device. The filter works by remove x'7f's after allowing a selectable amount. I get the results using arecord which does not have the filtering.

The USB device is a C -Media Electronics, Inc. I am running FC6.

Quoted 12 lines

[root@laptop ~]# lsmod |grep snd

snd_usb_audio          81985  0 
snd_usb_lib            21057  1 snd_usb_audio
snd_rawmidi            28481  1 snd_usb_lib
snd_hwdep              13637  1 snd_usb_audio
snd_ali5451            27853  1 
snd_ac97_codec         99813  1 snd_ali5451
snd_ac97_bus            6593  1 snd_ac97_codec
snd_seq_dummy           8133  0 
snd_seq_oss            37057  0 
snd_seq_midi_event     11841  1 snd_seq_oss
snd_seq                57009  5 snd_seq_dummy,snd_seq_oss,snd_seq_midi_event
Quoted 8 lines
snd_seq_device         12365  4 snd_rawmidi,snd_seq_dummy,snd_seq_oss,snd_seq
snd_pcm_oss            46433  0 
snd_mixer_oss          20545  1 snd_pcm_oss
snd_pcm                80965  4 snd_usb_audio,snd_ali5451,snd_ac97_codec,snd_pcm_oss
snd_timer              26693  2 snd_seq,snd_pcm
snd                    58181  140 snd_usb_audio,snd_rawmidi,snd_hwdep,snd_ali5451,snd_ac97_codec,snd_seq_oss,snd_seq,snd_seq_device,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_timer
soundcore              12193  1 snd
snd_page_alloc         14281  1 snd_pcm

Where do I report this 'bug' or how do I fix it?

Thanks for your time. Sorry for the multiple posting, not sure where is
should have gone.

Signature · 11 lines
William Estrada
[email protected]
Mt-Umunhum-Wireless.net ( http://Mt-Umunhum-Wireless.net )
Ymessenger: MrUmunhum


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
#1 lore raw
Quoted 3 lines · william estrada

I think I have found a problem with the USB sound driver? It appears that the current drive returns a x'81' for silence but it should be a x'7f'.

The USB audio driver returns whatever data is sent by the device

Quoted 3 lines

When I use my laptop's sound device and record without a mic, I get a file full of x'7f's. If I do the same with my cheap-o USB device I get a file full of x'81's.

For unsigned 8-bit samples, silence is x'80'.

Apparently, both devices have some DC offset and are quite noisy.

Quoted 4 lines

I have written a recording program that I have a 'silence' filter that filters out segments of dead air. It works with the laptop's sound device but not the USB device. The filter works by remove x'7f's after allowing a selectable amount.

Your filter should be able to detect silence even when noise is present.

Quoted 1 line

Sorry for the multiple posting, not sure where is should have gone.

The the linux-audio-dev list, of course. ;-)

Regards,
Clemens

#2 lore raw

Clemens,

I respect your options and appreciate your time, but from what I have read,
for a U8 format, silence is represented by a x'7F'. Do you have a source for your option?

In pcm_misc.c seems to support your statement:

Quoted 1 line

static struct pcm_format_data pcm_formats[SNDRV_PCM_FORMAT_LAST+1] = {

.
.

Quoted 3 lines
	[SNDRV_PCM_FORMAT_U8] = {
		.width = 8, .phys = 8, .le = -1, .signd = 0,
		.silence = { 0x80 },

So I guess I need to make my filter flexible to match the current hardware
device driver?

How would you filter out noise? I am new to these interfaces and would like
to find a good place to get more information about filters, noise, etc. Any URLs that you could recommend?

Thanks again for your time.

William Estrada
[email protected]
Mt-Umunhum-Wireless.net ( http://Mt-Umunhum-Wireless.net )
Ymessenger: MrUmunhum

Quoted 30 lines · Clemens Ladisch
Quoted 3 lines · william estrada

I think I have found a problem with the USB sound driver? It appears that the current drive returns a x'81' for silence but it should be a x'7f'.

The USB audio driver returns whatever data is sent by the device

Quoted 3 lines

When I use my laptop's sound device and record without a mic, I get a file full of x'7f's. If I do the same with my cheap-o USB device I get a file full of x'81's.

For unsigned 8-bit samples, silence is x'80'.

Apparently, both devices have some DC offset and are quite noisy.

Quoted 4 lines

I have written a recording program that I have a 'silence' filter that filters out segments of dead air. It works with the laptop's sound device but not the USB device. The filter works by remove x'7f's after allowing a selectable amount.

Your filter should be able to detect silence even when noise is present.

Quoted 1 line

Sorry for the multiple posting, not sure where is should have gone.

The the linux-audio-dev list, of course. ;-)

Regards,
Clemens

A message that is not in the archive (sent off-list or not yet received): 471CD6BE.4090209-rB/[email protected]

#4 lore raw

Silence must be detected as a series of near equal samples, the absolute value of a sample tells you nothing.

Given that the device produces PCM, it will contain an analog-to-digital converter (ADC), which *should* be designed to yield the 0x80 value, but manufacturing variables may conspire to produce a small offset and noise.

Offset. There will usually be some residual DC offset in an ADC design. Most of the DC offset is removed with capacitors in series on the signal path. DC offset moves the noise of silence in one direction away from the zero point.

Noise. Sampling noise in the ADC will cause the final bit to vary, so a chain of 0x80 0x7f 0x80 0x7f in any length and order might be received for a silent input. This noise will vary according to temperature, and other environmental factors. Classic sources of noise are interference from radio transmitters, and earth loop hum.

The kernel source file pcm_misc.c provides silence values for use by the kernel in generating silence, not in recognising it. Therefore these values should not be used in a discussion of whether a device is providing valid silence.

Quoted 2 lines · william estrada

So I guess I need to make my filter flexible to match the current hardware device driver?

You should make any filter flexible enough to match all hardware, and that way it will most reliably detect silence.

Quoted 1 line

How would you filter out noise?

You can filter out DC offset by measuring the offset you have, and subtracting this measurement from your samples.

It is not possible to filter out ADC noise, because this noise is inherent in the design of the ADC. There are advanced techniques that can be done during manufacturing, but you're not at that stage in the product lifecycle.

However, you could measure the noise, and see if your measurements are reduced by adding a balun to the audio cable, or by stabilising the temperature of the device, or by isolating the ground loop.

For example, if I connect some instrument to the Mic or Line In of one of my sound cards, the outer ring of the connector is anchored to electrical ground on my computer. The path through the safety ground cable back to the instrument will usually cause a hum. Using an audio transformer on the path from the instrument to the sound card may fix this.

Signature · 1 line
James Cameron    mailto:quozl-kJBlkiJxCS/[email protected]     http://quozl.netrek.org/