Page 1 of 1

OSS4 sampling rate

Posted: Tue Oct 27, 2009 4:14 pm
by radar_5
Hi, i was playing with PureData, generating some sine waves. I noticed that the audio
quality was much better (no popping and clicking) when PureData output sampling rate
was set to 48000 Hz matching the audio device sampling rate (by default PD outputs at 44100 Hz).

My question is - I have other audio apps working at 44100 Hz (xmms for example),
can I change OSS4 sampling rate to 44100 and will that improve sound quality??

Re: OSS4 sampling rate

Posted: Tue Oct 27, 2009 5:44 pm
by igorzwx
You may try to change such things:

vmix0-enable ON|OFF (currently ON)
vmix0-src <Fast|Low|Medium|High|High+|Production|OFF> (currently Production)

How to create test file

1. Audacity -> Generate -> Silence (5 seconds are enough)

2. Effects -> Nyquist prompt

3. type the command:

(mult (sum (hzosc 10) (hzosc 19500)) 0.45)

or copy-and-paste to Nyquist prompt (paste with Ctrl+V).

This produces a simple mix of 10Hz and 19500Hz (sine waves)

Export this as wave.

Re: OSS4 sampling rate

Posted: Tue Oct 27, 2009 8:55 pm
by cesium
That rate is set by "vmixctl" utility. "sudo vmixctl rate /dev/dsp 44100" should allow you to make the desired change.

Re: OSS4 sampling rate

Posted: Tue Oct 27, 2009 9:27 pm
by radar_5
cesium wrote:That rate is set by "vmixctl" utility. "sudo vmixctl rate /dev/dsp 44100" should allow you to make the desired change.


wow, much better (at least for a sine wave), thanks!

Re: OSS4 sampling rate

Posted: Tue Oct 27, 2009 9:54 pm
by igorzwx
These are hard things:

1. product (sin[2Hz])(sin[15Hz])

(mult (mult (hzosc 2) (hzosc 15)) 0.9)


2. (sin[1950Hz]) + (sin[2Hz])(sin[15Hz])

(mult (sum (mult (hzosc 2) (hzosc 15)) (hzosc 19500)) 0.45)


Maxima

(%i1) sin(a)*sin(b);
(%o1) sin(a)*sin(b)
(%i2) trigreduce(%);
(%o2) cos(b-a)/2-cos(b+a)/2

15Hz + 2Hz = 17Hz
15Hz - 2Hz = 13Hz

(mult (hzosc 17) 0.9)

Re: OSS4 sampling rate

Posted: Tue Oct 27, 2009 10:02 pm
by radar_5
thanks igor, but what are you trying to tell me :?:

Re: OSS4 sampling rate

Posted: Tue Oct 27, 2009 10:18 pm
by igorzwx
these are test files.

if you play them and hear some strange sounds, your sound system does not work well.

Re: OSS4 sampling rate

Posted: Tue Oct 27, 2009 10:33 pm
by radar_5
Interesting!
why are they difficult for the audio system??

Re: OSS4 sampling rate

Posted: Tue Oct 27, 2009 10:56 pm
by igorzwx
Imagine such thing:

tanh ((sin(a) + sin(b))

the result will be a strange mix (overtones, shift, etc.)

This is a non-linear transformation of the sound signal.
The effect is very similar to that of PulseAudio.
vmix is much softer than PulseAudio, but nevertheless.

------------------------------------------------------------------------------
Edit:
Perception of sound
http://en.wikipedia.org/wiki/Sound#Perception_of_sound
For humans, hearing is normally limited to frequencies between about 12 Hz and 20,000 Hz (20 kHz)[2], although these limits are not definite. The upper limit generally decreases with age. Other species have a different range of hearing. For example, dogs can perceive vibrations higher than 20 kHz.

Re: OSS4 sampling rate

Posted: Wed Oct 28, 2009 12:34 am
by radar_5
are you talking about harmonic distortions caused by compression? and that vmix uses "soft clipping"?

I think the popping sounds I've heard was not related to compression but to
44100->48000 resampling, I don't know how it is done in OSS4 but I guess if the
interpolation is not perfect then the sine wave will be distorted and you get other tones.

just guessing though..

Re: OSS4 sampling rate

Posted: Wed Oct 28, 2009 12:48 am
by igorzwx
I do not know what is the cause.

What is obvious:

1. You should not hear 10Hz

2. You should not hear 20kHz

3. You should not hear 10Hz + 20kHz

If you hear sounds playing such files, something is wrong.

Re: OSS4 sampling rate

Posted: Wed Oct 28, 2009 1:10 am
by radar_5
Ok I did your 10hz + 20khz test
- I didn't hear any sound when both PureData and /dev/dsp had the same sampling frequency.
- there was lot of popping when sampling frequencies did not match
- im getting older, cannot hear anything above 14khz :oops: (or is it my cheap earphones..)
that was really interesting, thanks!