OSS4 sampling rate

OSS specific Linux discussion (x86/amd64)

Moderators: cesium, dev, kodachi, hannu

OSS4 sampling rate

Postby radar_5 » Tue Oct 27, 2009 4:14 pm

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??
radar_5
New Member
 
Posts: 9
Joined: Sun Jun 15, 2008 5:16 pm

Re: OSS4 sampling rate

Postby igorzwx » Tue Oct 27, 2009 5:44 pm

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.
igorzwx
Supporter
 
Posts: 987
Joined: Sun Jun 28, 2009 9:31 pm

Re: OSS4 sampling rate

Postby cesium » Tue Oct 27, 2009 8:55 pm

That rate is set by "vmixctl" utility. "sudo vmixctl rate /dev/dsp 44100" should allow you to make the desired change.
cesium
Developer
 
Posts: 902
Joined: Sun Aug 12, 2007 12:51 am

Re: OSS4 sampling rate

Postby radar_5 » Tue Oct 27, 2009 9:27 pm

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!
radar_5
New Member
 
Posts: 9
Joined: Sun Jun 15, 2008 5:16 pm

Re: OSS4 sampling rate

Postby igorzwx » Tue Oct 27, 2009 9:54 pm

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)
igorzwx
Supporter
 
Posts: 987
Joined: Sun Jun 28, 2009 9:31 pm

Re: OSS4 sampling rate

Postby radar_5 » Tue Oct 27, 2009 10:02 pm

thanks igor, but what are you trying to tell me :?:
radar_5
New Member
 
Posts: 9
Joined: Sun Jun 15, 2008 5:16 pm

Re: OSS4 sampling rate

Postby igorzwx » Tue Oct 27, 2009 10:18 pm

these are test files.

if you play them and hear some strange sounds, your sound system does not work well.
igorzwx
Supporter
 
Posts: 987
Joined: Sun Jun 28, 2009 9:31 pm

Re: OSS4 sampling rate

Postby radar_5 » Tue Oct 27, 2009 10:33 pm

Interesting!
why are they difficult for the audio system??
radar_5
New Member
 
Posts: 9
Joined: Sun Jun 15, 2008 5:16 pm

Re: OSS4 sampling rate

Postby igorzwx » Tue Oct 27, 2009 10:56 pm

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.
igorzwx
Supporter
 
Posts: 987
Joined: Sun Jun 28, 2009 9:31 pm

Re: OSS4 sampling rate

Postby radar_5 » Wed Oct 28, 2009 12:34 am

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..
Last edited by radar_5 on Wed Oct 28, 2009 12:48 am, edited 1 time in total.
radar_5
New Member
 
Posts: 9
Joined: Sun Jun 15, 2008 5:16 pm

Re: OSS4 sampling rate

Postby igorzwx » Wed Oct 28, 2009 12:48 am

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.
igorzwx
Supporter
 
Posts: 987
Joined: Sun Jun 28, 2009 9:31 pm

Re: OSS4 sampling rate

Postby radar_5 » Wed Oct 28, 2009 1:10 am

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!
radar_5
New Member
 
Posts: 9
Joined: Sun Jun 15, 2008 5:16 pm


Return to Linux

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron