login
Header Space

 
 

Re: OpenBSD Sound

Previous thread: ath0 degraded in current? by Denis Doroshenko on Wednesday, October 31, 2007 - 8:05 am. (2 messages)

Next thread: Re: OpenBSD kernel janitors by Theo de Raadt on Wednesday, October 31, 2007 - 10:40 am. (15 messages)
To: <misc@...>
Subject: OpenBSD Sound
Date: Wednesday, October 31, 2007 - 9:17 am

Hello,

I have been using obsd as my primary desktop for a while now and i have a question about the sound system , is there a way to play 
two sounds at the same time ? Example watching youtube videos with opera and playing some music in the background with mpd or xmms . 
thank you for your time  ; )
To: Samuel Proulx <traumator@...>
Cc: OpenBSD <misc@...>
Date: Saturday, November 3, 2007 - 8:09 am

No there isn't. That's where the kernel fails in the virtualization of
hardware.

For example if I have music playing in the background, Audacity cannot open
the soundcard for recording. Can you imagine an operating system where if
Firefox was writing a webpage to the disk, your e-mail client couldn't read
a mail folder from the disk?

But Linux suffers from the same problem. Then there are some kind of
castle in the air solutions like esd or arts. I tried that on Linux. arts
segfaults periodically, esd plays the wrong pitch. It's like if you had
a special daemon running that would virtualize the harddisk for your browser
and e-mail client - a crap solution.

The proper natural solution is to implement this in the kernel where it belongs
to according to what they told us on the lectures - I have done a master degree
in operating systems, networks and compilers. They said that the kernel should
virtualize the hardware so each app thinks it's alone on the system. 

But that involves realtime resampling, Hann windows and finite impulse response
filters and that's work.  Especially for kernel people who are familiar with
locks and scheduling, but not with fourier transform and convolution.
To: Karel Kulhavy <clock@...>
Cc: <misc@...>
Date: Saturday, November 3, 2007 - 4:38 pm

you obviously have had much more instruction in programming than myself.
I have only taken 1 college level course in programming; you have
masters dergees.

but who has actually worked to find and fix simple math and programming
errors in audio?

not you.

talk all you want.  I'll start listening when you actually do something.

and comparing a sound card to a hard drive?  you sure you have master
degrees in computing?  a much better comparison would be a sound card
and a video card.  guess what?  we have a video server for multiple
concurrent video display.  I suppose X is a castle in the sky and
you would rather have all things X does done in the kernel?

-- 
jakemsr@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
To: Samuel Proulx <traumator@...>, misc@openbsd.org <misc@...>
Date: Wednesday, October 31, 2007 - 10:51 am

And still one thing

When I was try OpenBSD (I think that was 3.8),I use WindowMaker,Xmms and lots
of other packages and sound goes well (video together with music and
etc.).Maybe part of dmesg from your system will be useful for somebody of us.

-----Original Message-----
From: owner-misc@openbsd.org [mailto:owner-misc@openbsd.org] On Behalf Of
Samuel Proulx
Sent: Wednesday, October 31, 2007 2:17 PM
To: misc@openbsd.org
Subject: OpenBSD Sound

Hello,

I have been using obsd as my primary desktop for a while now and i have a
question about the sound system , is there a way to play two sounds at the
same time ? Example watching youtube videos with opera and playing some music
in the background with mpd or xmms .
thank you for your time  ; )
To: Tomas Bodzar <Tomas.Bodzar@...>
Cc: Samuel Proulx <traumator@...>, misc@openbsd.org <misc@...>
Date: Wednesday, October 31, 2007 - 11:06 am

Some *BSD systems are adjusting PCM driver support to allow multiple
process to open /dev/dsp / /dev/audio multiple times in-exclusively,
mitigating the needs for piss-poor software API multiplex'ing solutions
a-la ARTS/ESD.

~BAS
To: misc@openbsd.org <misc@...>
Date: Wednesday, October 31, 2007 - 5:30 pm

oh?  NetBSD lets /dev/audio be opened non-exclusively, but AFAICS,
there's no real mixing involved.  just a hack to let stupid programs
open /dev/audio twice.

piss-poor, artsd?  really?  have you tried it in -current?  I have not
seen any PRs, nor even any comments about artsd.  I use it daily.  for
both recording and playback.

esd, yeah, piss-poor.  or rather, a classic example of everyone and his
brother "contributing".  IMO, anyway.

-- 
jakemsr@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
To: misc@openbsd.org <misc@...>
Date: Wednesday, October 31, 2007 - 11:23 am

On 10/31/07, Brian A Seklecki (Mobile)

Oh awesome! Is /Open/BSD one of those?

-Nick
To: Nick Guenther <kousue@...>
Cc: misc@openbsd.org <misc@...>
Date: Wednesday, October 31, 2007 - 12:48 pm

no; character devices (such as /dev/audio) keep per-unit state
(encoding, rate, ...). To mix multiple audio streams per-stream
state must be kept. That's why arts/esd/jack/... exist.

-- Alexandre
To: Alexandre Ratchov <alex@...>
Cc: OpenBSD <misc@...>
Date: Saturday, November 3, 2007 - 8:40 am

You don't need arts/esd/jack because of this. This can be solved in kernel.
The kernel opens the audio device for the highest common sampling rate
from those requested, or, if the rate cannot be switched without an
audible glitch, for the highest hardware available (48 or 96kHz, or
user-configured if it should be too much burden).

Then if the kernel has it 48 and the app opens 44.1, the kernel resamples.
According to Nyquist theorem, you first need to emulate the reconstruction
lowpass filter with 22.05kHz programatically, and then resample the
output stream at 48kHz and send it out. This requires an intermediate
stream at least common multiple, for this ugly case it's 2352 kHz. But
you actually don't have to shove data at 2352 kHz sampling rate in the
kernel, since you use only every 49th sample for the output. So some nifty
math or multipass filter does the job, for the expense of your brain exploding.

Now how the lowpass is done. It has to be really sharp otherwise you get
an 8-bit-era-like ringing in the sound. And it must not have large delay
(you don't want to hear the explosion in your Quake a second later) and
also not computationally expensive.

The suitable type of filter is called finite impulse response (FIR) and
it's just a naiive convolution with a short kernel. Now how to calculate
this kernel to get the best response? You make your kernel and imagine
it's cyclically wrapped. Then you calculate through FFT the ideal response
into it - that's perfectly sharp. But now since the response won't be
cyclically wrapped but occurs just once in the time and have zero strecthing
into both infinities, we have to fix this.

You take a Hann window http://en.wikipedia.org/wiki/Hann_window and apply that
and you got it. Hann window is just one cycle of a sine wave plus minus some
pushing around. You don't even need a sin for this, you can calculate it with
complex multiplication of one pre-calculated complex number.

How long do you make your kernel? The longer the kernel, the...
To: Karel Kulhavy <clock@...>
Cc: OpenBSD <misc@...>
Date: Saturday, November 3, 2007 - 12:36 pm

that's not exact; you're talking about upsampling. So you need to
resample first and then you apply the pass-low filter. But we're

that isn't necessary because we don't need FFT to obtain filter
coefficients (they can be determined at initialization). But I'm

afaik, most of us have followed math curses too and understand
pretty well Fourier transforms and fitlering and we know how to
implement this stuff too. I'm not against resampling and mixing but
audio(4) driver is the wrong place for it.

-- Alexandre
To: Karel Kulhavy <clock@...>
Cc: Alexandre Ratchov <alex@...>, OpenBSD <misc@...>
Date: Saturday, November 3, 2007 - 10:21 am

so, the kernel would mix multiple sound sources coming at
different rates?

but, /dev/audio uses a character device. like ratchov@ (new audio
developer) wrote, these keep per-unit state, not per-stream state.

even ignoring whether it's actually desirable to have the kernel
do resampling (a quick perusal of the list archives should reveal
what developers think about that), with a character device you

no, it couldn't.


can you imagine an operating system where if Firefox was printing a
web page, your e-mail client could print an email on the same printer
at the same time?

just because some software which can mix audio sucks, doesn't mean
that all software which can mix audio has to suck.
To: Stuart Henderson <stu@...>
Cc: OpenBSD <misc@...>
Date: Saturday, November 3, 2007 - 11:40 am

Without resampling the illusion of having the soundcard just for you would

The opener actually does some kind of ioctl on the device. So if one opener
does ioctl that he wants 32 kHz and another that he wants 22.05kHz then you
know which bitrate to use for each of them. Why do you think you cannot track

Yes every Unix has it. The lpr and lpd - if Firefox and e-mail clients are
printing at the same time, they get assigned different print jobs and

What do you mean with the term "suck"?  No matter how good app you write it
always breaks the basic principle - that hw virtualization should be done by
the kernel and not some kind of userland app.

CL&lt;
To: OpenBSD <misc@...>
Date: Saturday, November 3, 2007 - 6:14 pm

Sigh, I hoped he had grown up somewhat or learned something.

Still the wrong edge!

---chefren
To: OpenBSD <misc@...>
Date: Saturday, November 3, 2007 - 12:29 pm

So, you want to integrate printer queueing and PostScript interpretation
in a kernel to have some kind of perfectly virtualized /dev/printer
that eats PS or PCL depending on what ioctls you call and munges the
data to whatever the particular printer wants?
Why do it in userland when you can do it in the kernel!

-- 
Jussi Peltola
To: Karel Kulhavy <clock@...>
Cc: Alexandre Ratchov <alex@...>, OpenBSD <misc@...>
Date: Saturday, November 3, 2007 - 9:44 am

Hello,

This thread has been really interesting.


Mplayer is GPL, so be careful about lifting code.

-- 
Best Regards

Edd

---------------------------------------------------
http://students.dec.bournemouth.ac.uk/ebarrett
To: Edd Barrett <vext01@...>
Cc: OpenBSD <misc@...>
Date: Saturday, November 3, 2007 - 10:23 am

Then one can use the code at least as an algorithm reference. Can easily
happen that they use a different interface - blocking vs. nonblocking,
callback vs. not callback etc. - which will make the code unusable anyway.
To: Karel Kulhavy <clock@...>
Cc: Edd Barrett <vext01@...>, OpenBSD <misc@...>
Date: Saturday, November 3, 2007 - 12:03 pm

"one", as in "someone who doesn't just talk talk talk talk".

Or perhaps much more clearly stated "one" means "someone other than Karel".

gonna setup a web page first, for your non-project?  a wiki?
and a mailing list?
To: OpenBSD <misc@...>
Date: Sunday, November 4, 2007 - 1:55 pm

Not until they pick a catchy name and a mascot.
To: Nick Guenther <kousue@...>
Cc: misc@openbsd.org <misc@...>
Date: Wednesday, October 31, 2007 - 12:40 pm

no.  but you hit the jackpot!

kernel janitor list:
1.  make audio play 2 sounds at once.

see how easy that was?
To: OpenBSD-Misc <misc@...>
Date: Wednesday, October 31, 2007 - 10:47 am

Unix has always been kind of weak in this area. You need a mixer of
some sort to do this. Not /dev/mixer, which controls audio volumes for
the different hardware devices, but a software mixer.
You'll probably want http://ports.openbsd.nu/audio/esound. There's
something called Pulse which is intended as a drop in (but superior)
replacement for esound, and someone () ported it to OpenBSD, but it's
not in the tree yet.
Reading http://www.pulseaudio.org/wiki/PerfectSetup might be
enlightening; it describes how to configure each program you want to
use to use pulse.

Looking around some more, here's something like how you'd have to
configure mpd to use esound:
audio_output {
        type      "ao"
        driver    "esd"
        options   "host=jurp5-desktop:16001"
        name      "esd"
}

Yes, you need to have each program direct it's output to the mixer,
there's no way (as far as I know) to sneakily make /dev/audio be a
software mixer. I don't know if the reason there's no /dev/audio_mix
is technical, or if it's just that no one's done the work, or if it's
just a tradition now.

-Nick
To: Nick Guenther <kousue@...>
Cc: OpenBSD <misc@...>
Date: Saturday, November 3, 2007 - 8:21 am

Unix started like a typewriter. But then the multimedia came. And now try to
rebuild a typewriter into a VHS recorder. OK a magnetic tape instead of ink
tape, we keep the two spools, cut the platten to get the head drum, the keys
will be put on the remote control, but now what should we make the tape
loading mechanism from?

Can be seen that ambitious plans that seem to run fine at the beginning may
suddenly come to a screeching halt.

Apart from sound, the picture part is problematic on Unix too.  My X Window
system autorepeat suddenly starts to race with cosmic speed if something
prints with high speed in a different xterm (for example search in a lot
of small files in the Midnight Commander). Sometimes the X Window system
hangs with a screen filled with psychedelic colours upon startx and I have
to reboot the machine. Closing the lid sometimes switches the output to the
external LCD, sometimes not, and sometimes it produces shaking, noisy,
out of sync corrupted signal.

This is because instead of virtualizing the picture hardware in the kernel,
which is the idea of operating system, it's done by some dodgy third-party
application OpenBSD project has really no control over.

You may stop worrying about this stuff when you realize your video recorder
was rebuilt from a typewriter.
To: <misc@...>
Date: Wednesday, October 31, 2007 - 11:11 am

thank for the information  . I just tried esound  , it worked nice 
with mpd.. but it seem that there is no way to make it work with opera ? 
I have looked on google  and from what i have read  im supposed to use 
the esddsp program but it didnt come with the esound package ; ( is it 
because it incompatible with openbsd ?
To: Samuel Proulx <traumator@...>
Cc: <misc@...>
Date: Wednesday, October 31, 2007 - 10:19 am

Try something like esound or pulseaudio; they run in the background and connect
to your sound card, and opera/xmms/whatever else connect to them instead of
directly to the sound card.

-- 
Benjamin A'Lee :: benjamin.alee@subvert.org.uk
Subvert Technologies :: http://subvert.org.uk/
Previous thread: ath0 degraded in current? by Denis Doroshenko on Wednesday, October 31, 2007 - 8:05 am. (2 messages)

Next thread: Re: OpenBSD kernel janitors by Theo de Raadt on Wednesday, October 31, 2007 - 10:40 am. (15 messages)
speck-geostationary