ossaudiodev problem: sawtooth noise

P

Peter Pearson

The following code uses ossaudiodev to read 1000 values from
my sound card at a rate of 12,000 samples per second:

*********** begin code ***********

import ossaudiodev as o
import struct

d = o.open( "r" )
_, _, _ = d.setparameters( o.AFMT_S16_LE,
1, # channels
12000, # samples/s
True ) # strict
n_samples = 1000
bytes = d.read( 2 * n_samples )
for x in struct.unpack( "<%dh" % n_samples, bytes ):
print( "%d" % x )
d.close()

************* end code ************

When I select a sample rate that is not a power of 2 times
3000 samples/second, a strong and very regular sawtooth is
superimposed on the signal. At some sampling frequencies,
it appears as a rising sawtooth, and at other sampling
frequencies it is a declining sawtooth, so I'm presumably
lost in some aliasing wilderness. As best I can tell,
it's a 48 KHz sawtooth.

Am I doing something wrong?

Is ossaudiodev the wrong choice for capturing sound-card
data?

Thanks for any helpful comments.
 
G

Gabriel Genellina

En Mon, 19 Jan 2009 21:57:04 -0200, Peter Pearson
The following code uses ossaudiodev to read 1000 values from
my sound card at a rate of 12,000 samples per second:

When I select a sample rate that is not a power of 2 times
3000 samples/second, a strong and very regular sawtooth is
superimposed on the signal. At some sampling frequencies,
it appears as a rising sawtooth, and at other sampling
frequencies it is a declining sawtooth, so I'm presumably
lost in some aliasing wilderness. As best I can tell,
it's a 48 KHz sawtooth.

That could be a hardware and/or driver limitation. By example, an
AC97-compliant chipset may provide a fixed rate of 48000 samples/second --
any sample rate conversion must be done by other means, if possible at all.
 
P

Peter Pearson

En Mon, 19 Jan 2009 21:57:04 -0200, Peter Pearson


That could be a hardware and/or driver limitation. By example, an
AC97-compliant chipset may provide a fixed rate of 48000 samples/second --
any sample rate conversion must be done by other means, if possible at all.

Oh! As a matter of fact, my "soundcard" *is* AC97-compliant
("VT8233/A/8235/8237", according to Sysinfo). So . . . this
sawtooth might result from some software, somewhere in the bucket
brigade between me and the hardware, attempting to perform
sample-rate conversion? The 48 KHz coincidence seems very
significant.

Thanks.
 
G

Gabriel Genellina

En Fri, 23 Jan 2009 14:36:46 -0200, Peter Pearson
Oh! As a matter of fact, my "soundcard" *is* AC97-compliant
("VT8233/A/8235/8237", according to Sysinfo). So . . . this
sawtooth might result from some software, somewhere in the bucket
brigade between me and the hardware, attempting to perform
sample-rate conversion? The 48 KHz coincidence seems very
significant.

Yep. Google found this for me:
http://mail-index.netbsd.org/port-i386/2003/02/18/0003.html

Using a sample rate that is a sub-multiple of 48000 is perhaps a safe
approach.
 
P

Peter Pearson

En Fri, 23 Jan 2009 14:36:46 -0200, Peter Pearson


Yep. Google found this for me:
http://mail-index.netbsd.org/port-i386/2003/02/18/0003.html

Using a sample rate that is a sub-multiple of 48000 is perhaps a safe
approach.

Back around the time I installed Ubuntu's Hardy Heron, several
copies of this line appeared in /var/log/user.log.0:
Jan 4 21:32:53 eleodes pulseaudio[6437]: alsa-util.c: \
Device front:0 doesn't support 44100 Hz, changed to 48000 Hz.

So I suppose I'll just restrict myself to well-behaved frequencies.
I'm not sure what "sub-multiple" means, but all the successful
frequencies I've found over 1 KHz have been multiples of 1.5 KHz that
evenly divide 48 KHz. Frequencies showing large sawtooths include
2, 4, 8, 10, and 16 KHz.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Newbie... 2
Making a soundcard object 0
multi track audio card accessing 0

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,266
Latest member
DavidaAlla

Latest Threads

Top