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.
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.