Discussion:
OpenBSD Sound
Samuel Proulx
2007-10-31 13:17:05 UTC
Permalink
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 ; )
Benjamin M. A'Lee
2007-10-31 14:19:06 UTC
Permalink
Post by Samuel Proulx
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 ; )
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 :: ***@subvert.org.uk
Subvert Technologies :: http://subvert.org.uk/
Nick Guenther
2007-10-31 14:47:20 UTC
Permalink
Post by Samuel Proulx
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 ; )
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
Christian Weisgerber
2007-10-31 16:06:24 UTC
Permalink
Post by Nick Guenther
You'll probably want http://ports.openbsd.nu/audio/esound.
Yup.
Post by Nick Guenther
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.
Benoit Chesneau has done some promising work on a PulseAudio port,
and it's on my to-do list, but I haven't quite gotten around to it.
Post by Nick Guenther
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.
It's a question of how much work you want to do in the kernel.
Merging audio streams in different formats and sampling rates is a
bit of a pain and I think our audio hackers don't really want to
do resampling in the kernel.
--
Christian "naddy" Weisgerber ***@mips.inka.de
Jacob Meuser
2007-10-31 21:22:15 UTC
Permalink
Post by Christian Weisgerber
Post by Nick Guenther
You'll probably want http://ports.openbsd.nu/audio/esound.
Yup.
Post by Nick Guenther
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.
Benoit Chesneau has done some promising work on a PulseAudio port,
and it's on my to-do list, but I haven't quite gotten around to it.
I've been working on it. libtool issues and crashing (use after
free()) problems are slowing me down. at this point, I'm unsure
whether it's really any better than esound.

OTOH, I've been rather impressed with artsd. recording audio from
radio(4) while listening to streaming mp3s using the same sound card
(in -current of course). is that even possible with esound? kinda
sucks though, that aRTs is being retired in kde4.
Post by Christian Weisgerber
Post by Nick Guenther
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.
It's a question of how much work you want to do in the kernel.
Merging audio streams in different formats and sampling rates is a
bit of a pain and I think our audio hackers don't really want to
do resampling in the kernel.
probably not; at least not anytime soon.

something for "newbie hackers" to work on: an ISC licensed audio daemon.
--
***@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
Dorian Büttner
2007-11-02 11:42:29 UTC
Permalink
On Wednesday 31 October 2007 22:22:15 Jacob Meuser wrote:
[...]
Post by Jacob Meuser
probably not; at least not anytime soon.
something for "newbie hackers" to work on: an ISC licensed audio daemon.
Sorry for hijacking this thread, propably anyone has a quick hint to make my
audio work in kde.

Built /usr/src/regress/sys/dev/audio/obj as described here
http://www.nabble.com/NVIDIA-MCP51-HD-Audio-azalia-problems-t4629307.html
and autest -r 48000 delivers good quality tone.

relevant dmesg seems to be this one:
azalia0 at pci0 dev 27 function 0 "Intel 82801GB HD Audio" rev 0x02: apic 2
int
21 (irq 10)
azalia0: host: High Definition Audio rev. 1.0
azalia0: codec: Realtek/0x0862 (rev. 0.1), HDA version 1.0
azalia0: codec: Motorola/0x3055 (rev. 7.0), HDA version 1.0
azalia0: codec[1]: No support for modem function groups
azalia0: codec[1]: No audio function groups
audio0 at azalia0

However this doesn't seem to be a driver problem since autest passed with
success. It's just that kde doesn't detect the device, where can I look at to
nail down the problem? pkg_info contains either esound and arts.

Thanks,
Dorian
Peter N. M. Hansteen
2007-11-02 11:53:21 UTC
Permalink
Post by Dorian Büttner
However this doesn't seem to be a driver problem since autest passed with
success. It's just that kde doesn't detect the device, where can I look at to
nail down the problem? pkg_info contains either esound and arts.
Several Thinkpad users including myself have found that by default the
output volume is set to zero, and sounds start happening after you've
pushed the "sound volume up" button for a few seconds. That may or
may not be relevant to your particular situation, but I thought it
worth mentioning.
--
Peter N. M. Hansteen, member of the first RFC 1149 implementation team
http://bsdly.blogspot.com/ http://www.datadok.no/ http://www.nuug.no/
"Remember to set the evil bit on all malicious network traffic"
delilah spamd[29949]: 85.152.224.147: disconnected after 42673 seconds.
Jacob Meuser
2007-11-02 12:07:54 UTC
Permalink
Post by Dorian Büttner
[...]
Post by Jacob Meuser
probably not; at least not anytime soon.
something for "newbie hackers" to work on: an ISC licensed audio daemon.
Sorry for hijacking this thread, propably anyone has a quick hint to make my
audio work in kde.
Built /usr/src/regress/sys/dev/audio/obj as described here
http://www.nabble.com/NVIDIA-MCP51-HD-Audio-azalia-problems-t4629307.html
and autest -r 48000 delivers good quality tone.
azalia0 at pci0 dev 27 function 0 "Intel 82801GB HD Audio" rev 0x02: apic 2
int
21 (irq 10)
azalia0: host: High Definition Audio rev. 1.0
azalia0: codec: Realtek/0x0862 (rev. 0.1), HDA version 1.0
azalia0: codec: Motorola/0x3055 (rev. 7.0), HDA version 1.0
azalia0: codec[1]: No support for modem function groups
azalia0: codec[1]: No audio function groups
audio0 at azalia0
However this doesn't seem to be a driver problem since autest passed with
success. It's just that kde doesn't detect the device, where can I look at to
nail down the problem? pkg_info contains either esound and arts.
is artsd running?

$ pgrep -l artsd

is the audio device opened for playback?

$ audioctl play.open

is it actuall artsd that has /dev/sound opened? (artsd uses /dev/sound
instead of /dev/audio)

$ fstat /dev/sound

if all those are yes, then see if it works:

$ artscat file.wav

oh, and since you have azalia, you may need to tell artsd to resample
to 48kHz. K Menu -> Settings -> Sounds & Multimedia -> Sound System
In the Hardware tab. Check "Use custom sampling rate", set it to
48000 Hz. or manually starts artsd with 'artsd -r 48000'.
--
***@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
Dorian Büttner
2007-11-02 12:42:33 UTC
Permalink
Post by Jacob Meuser
Post by Dorian Büttner
[...]
Post by Jacob Meuser
probably not; at least not anytime soon.
something for "newbie hackers" to work on: an ISC licensed audio daemon.
Sorry for hijacking this thread, propably anyone has a quick hint to make
my audio work in kde.
Built /usr/src/regress/sys/dev/audio/obj as described here
http://www.nabble.com/NVIDIA-MCP51-HD-Audio-azalia-problems-t4629307.html
and autest -r 48000 delivers good quality tone.
azalia0 at pci0 dev 27 function 0 "Intel 82801GB HD Audio" rev 0x02: apic
2 int
21 (irq 10)
azalia0: host: High Definition Audio rev. 1.0
azalia0: codec: Realtek/0x0862 (rev. 0.1), HDA version 1.0
azalia0: codec: Motorola/0x3055 (rev. 7.0), HDA version 1.0
azalia0: codec[1]: No support for modem function groups
azalia0: codec[1]: No audio function groups
audio0 at azalia0
However this doesn't seem to be a driver problem since autest passed with
success. It's just that kde doesn't detect the device, where can I look
at to nail down the problem? pkg_info contains either esound and arts.
is artsd running?
$ pgrep -l artsd
2299 artsd
Post by Jacob Meuser
is the audio device opened for playback?
$ audioctl play.open
play.open=0
seems not to be 'yes'? it is read-only variable.
Post by Jacob Meuser
is it actuall artsd that has /dev/sound opened? (artsd uses /dev/sound
instead of /dev/audio)
$ fstat /dev/sound
empty table
Post by Jacob Meuser
$ artscat file.wav
oh, and since you have azalia, you may need to tell artsd to resample
to 48kHz. K Menu -> Settings -> Sounds & Multimedia -> Sound System
In the Hardware tab. Check "Use custom sampling rate", set it to
48000 Hz. or manually starts artsd with 'artsd -r 48000'.
done, but didn't help. Shouldn't artsd appear in the list of available
soundsystems, btw?

THanks,
Dorian
Dorian Büttner
2007-11-02 13:23:27 UTC
Permalink
Post by Dorian Büttner
Post by Jacob Meuser
Post by Dorian Büttner
[...]
Post by Jacob Meuser
probably not; at least not anytime soon.
something for "newbie hackers" to work on: an ISC licensed audio daemon.
Sorry for hijacking this thread, propably anyone has a quick hint to
make my audio work in kde.
Built /usr/src/regress/sys/dev/audio/obj as described here
http://www.nabble.com/NVIDIA-MCP51-HD-Audio-azalia-problems-t4629307.ht
ml and autest -r 48000 delivers good quality tone.
apic 2 int
21 (irq 10)
azalia0: host: High Definition Audio rev. 1.0
azalia0: codec: Realtek/0x0862 (rev. 0.1), HDA version 1.0
azalia0: codec: Motorola/0x3055 (rev. 7.0), HDA version 1.0
azalia0: codec[1]: No support for modem function groups
azalia0: codec[1]: No audio function groups
audio0 at azalia0
However this doesn't seem to be a driver problem since autest passed
with success. It's just that kde doesn't detect the device, where can I
look at to nail down the problem? pkg_info contains either esound and
arts.
is artsd running?
$ pgrep -l artsd
2299 artsd
Post by Jacob Meuser
is the audio device opened for playback?
$ audioctl play.open
play.open=0
seems not to be 'yes'? it is read-only variable.
Post by Jacob Meuser
is it actuall artsd that has /dev/sound opened? (artsd uses /dev/sound
instead of /dev/audio)
$ fstat /dev/sound
empty table
Post by Jacob Meuser
$ artscat file.wav
oh, and since you have azalia, you may need to tell artsd to resample
to 48kHz. K Menu -> Settings -> Sounds & Multimedia -> Sound System
In the Hardware tab. Check "Use custom sampling rate", set it to
48000 Hz. or manually starts artsd with 'artsd -r 48000'.
done, but didn't help. Shouldn't artsd appear in the list of available
soundsystems, btw?
THanks,
Dorian
ok I removed the auto-suspend checkbox in the control center audio settings.
After restarting the system I now have better values:
$ audioctl play.rate
play.rate=48000
$ audioctl play.open
play.open=1
$ artscat testcase.wav
plays fine :)) however kde doesn't. There seems to be the glue missing between
the artsd and the kde sound system?
Daniel
2007-11-02 13:41:18 UTC
Permalink
Post by Dorian Büttner
Post by Dorian Büttner
Post by Jacob Meuser
Post by Dorian Büttner
[...]
Post by Jacob Meuser
probably not; at least not anytime soon.
something for "newbie hackers" to work on: an ISC licensed audio daemon.
Sorry for hijacking this thread, propably anyone has a quick
hint to make my audio work in kde.
Built /usr/src/regress/sys/dev/audio/obj as described here
http://www.nabble.com/NVIDIA-MCP51-HD-Audio-azalia-problems-t46
29307.ht ml and autest -r 48000 delivers good quality tone.
azalia0 at pci0 dev 27 function 0 "Intel 82801GB HD Audio" rev
0x02: apic 2 int
21 (irq 10)
azalia0: host: High Definition Audio rev. 1.0
azalia0: codec: Realtek/0x0862 (rev. 0.1), HDA version 1.0
azalia0: codec: Motorola/0x3055 (rev. 7.0), HDA version 1.0
azalia0: codec[1]: No support for modem function groups
azalia0: codec[1]: No audio function groups
audio0 at azalia0
However this doesn't seem to be a driver problem since autest
passed with success. It's just that kde doesn't detect the
device, where can I look at to nail down the problem? pkg_info
contains either esound and arts.
is artsd running?
$ pgrep -l artsd
2299 artsd
Post by Jacob Meuser
is the audio device opened for playback?
$ audioctl play.open
play.open=0
seems not to be 'yes'? it is read-only variable.
Post by Jacob Meuser
is it actuall artsd that has /dev/sound opened? (artsd uses
/dev/sound instead of /dev/audio)
$ fstat /dev/sound
empty table
Post by Jacob Meuser
$ artscat file.wav
oh, and since you have azalia, you may need to tell artsd to
resample to 48kHz. K Menu -> Settings -> Sounds & Multimedia ->
Sound System In the Hardware tab. Check "Use custom sampling
rate", set it to 48000 Hz. or manually starts artsd with 'artsd
-r 48000'.
done, but didn't help. Shouldn't artsd appear in the list of
available soundsystems, btw?
THanks,
Dorian
ok I removed the auto-suspend checkbox in the control center audio
$ audioctl play.rate
play.rate=48000
$ audioctl play.open
play.open=1
$ artscat testcase.wav
plays fine :)) however kde doesn't. There seems to be the glue
missing between the artsd and the kde sound system?
If you mean the kde system notification sounds are not working check
this:

KDE Control Center / Sound & Multimedia / System Notifications:
Bottom Right corner -> [Player Settings] button.

HTH,

Daniel
Dorian Büttner
2007-11-02 13:59:13 UTC
Permalink
On Friday 02 November 2007 14:41:18 Daniel wrote:
[...]
Post by Daniel
Post by Dorian Büttner
ok I removed the auto-suspend checkbox in the control center audio
$ audioctl play.rate
play.rate=48000
$ audioctl play.open
play.open=1
$ artscat testcase.wav
plays fine :)) however kde doesn't. There seems to be the glue
missing between the artsd and the kde sound system?
If you mean the kde system notification sounds are not working check
Bottom Right corner -> [Player Settings] button.
HTH,
Daniel
No kde doesn't play anything at all, kmixer doesn't have any available device.
Dorian Büttner
2007-11-02 18:56:19 UTC
Permalink
No, it didn't.
Actually tryin' a fresh install - slightly remember that it did work on the
fresh install. I'll let you know.
Dorian,
One wild guess: does it change when you start KDE as root?
HTH,
Stijn
Post by Dorian Büttner
[...]
Post by Daniel
Post by Dorian Büttner
ok I removed the auto-suspend checkbox in the control center audio
$ audioctl play.rate
play.rate=48000
$ audioctl play.open
play.open=1
$ artscat testcase.wav
plays fine :)) however kde doesn't. There seems to be the glue
missing between the artsd and the kde sound system?
If you mean the kde system notification sounds are not working check
Bottom Right corner -> [Player Settings] button.
HTH,
Daniel
No kde doesn't play anything at all, kmixer doesn't have any available device.
Samuel Proulx
2007-10-31 15:11:06 UTC
Permalink
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 ?
Post by Nick Guenther
Post by Samuel Proulx
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 ; )
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
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
Karel Kulhavy
2007-11-03 12:21:35 UTC
Permalink
Post by Nick Guenther
Post by Samuel Proulx
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 ; )
Unix has always been kind of weak in this area. You need a mixer of
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.

CL<
Post by Nick Guenther
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
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
Tomas Bodzar
2007-10-31 14:51:50 UTC
Permalink
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-***@openbsd.org [mailto:owner-***@openbsd.org] On Behalf Of
Samuel Proulx
Sent: Wednesday, October 31, 2007 2:17 PM
To: ***@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 ; )
Brian A Seklecki (Mobile)
2007-10-31 15:06:15 UTC
Permalink
Post by Tomas Bodzar
And still one thing
When I was try OpenBSD (I think that was 3.8),I use WindowMaker,Xmms and lots
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
Nick Guenther
2007-10-31 15:23:31 UTC
Permalink
On 10/31/07, Brian A Seklecki (Mobile)
Post by Brian A Seklecki (Mobile)
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.
Oh awesome! Is /Open/BSD one of those?

-Nick
Ted Unangst
2007-10-31 16:40:50 UTC
Permalink
Post by Nick Guenther
On 10/31/07, Brian A Seklecki (Mobile)
Post by Brian A Seklecki (Mobile)
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.
Oh awesome! Is /Open/BSD one of those?
no. but you hit the jackpot!

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

see how easy that was?
Alexandre Ratchov
2007-10-31 16:48:20 UTC
Permalink
Post by Nick Guenther
On 10/31/07, Brian A Seklecki (Mobile)
Post by Brian A Seklecki (Mobile)
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.
Oh awesome! Is /Open/BSD one of those?
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
Karel Kulhavy
2007-11-03 12:40:37 UTC
Permalink
Post by Alexandre Ratchov
Post by Nick Guenther
On 10/31/07, Brian A Seklecki (Mobile)
Post by Brian A Seklecki (Mobile)
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.
Oh awesome! Is /Open/BSD one of those?
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.
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 more
computationally intensive, but the sharper the transition so you lose less of
the high frequencies.

mplayer has to do this stuff all the time so it's full of this code. It does it
not only to accomodate for various sample rates, but also when you slow down or
speed up your video. Maybe the code could be taken from mplayer.

CL<
Post by Alexandre Ratchov
-- Alexandre
Edd Barrett
2007-11-03 13:44:02 UTC
Permalink
Hello,

This thread has been really interesting.
Post by Karel Kulhavy
Maybe the code could be taken from mplayer.
Mplayer is GPL, so be careful about lifting code.
--
Best Regards

Edd

---------------------------------------------------
http://students.dec.bournemouth.ac.uk/ebarrett
Karel Kulhavy
2007-11-03 14:23:34 UTC
Permalink
Post by Samuel Proulx
Hello,
This thread has been really interesting.
Post by Karel Kulhavy
Maybe the code could be taken from mplayer.
Mplayer is GPL, so be careful about lifting code.
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.

CL<
Post by Samuel Proulx
--
Best Regards
Edd
---------------------------------------------------
http://students.dec.bournemouth.ac.uk/ebarrett
Theo de Raadt
2007-11-03 16:03:03 UTC
Permalink
Post by Karel Kulhavy
Post by Edd Barrett
Post by Karel Kulhavy
Maybe the code could be taken from mplayer.
Mplayer is GPL, so be careful about lifting code.
Then one can use the code at least as an algorithm reference.
"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?
Steve Shockley
2007-11-04 17:55:12 UTC
Permalink
Post by Theo de Raadt
gonna setup a web page first, for your non-project? a wiki?
and a mailing list?
Not until they pick a catchy name and a mascot.

Stuart Henderson
2007-11-03 14:21:27 UTC
Permalink
Post by Karel Kulhavy
Post by Alexandre Ratchov
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.
You don't need arts/esd/jack because of this. This can be solved in kernel.
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
*can't track the state of each stream* e.g. which bitrate to use.
Post by Karel Kulhavy
mplayer has to do this stuff all the time so it's full of this code. It does it
not only to accomodate for various sample rates, but also when you slow down or
speed up your video. Maybe the code could be taken from mplayer.
no, it couldn't.
Post by Karel Kulhavy
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?
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.
Karel Kulhavy
2007-11-03 15:40:31 UTC
Permalink
Post by Stuart Henderson
Post by Karel Kulhavy
Post by Alexandre Ratchov
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.
You don't need arts/esd/jack because of this. This can be solved in kernel.
so, the kernel would mix multiple sound sources coming at
different rates?
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
Without resampling the illusion of having the soundcard just for you would
be gone.
Post by Stuart Henderson
what developers think about that), with a character device you
*can't track the state of each stream* e.g. which bitrate to use.
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
the state of each of them?
Post by Stuart Henderson
Post by Karel Kulhavy
mplayer has to do this stuff all the time so it's full of this code. It does it
not only to accomodate for various sample rates, but also when you slow down or
speed up your video. Maybe the code could be taken from mplayer.
no, it couldn't.
Post by Karel Kulhavy
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?
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?
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
everything prints all right.
Post by Stuart Henderson
just because some software which can mix audio sucks, doesn't mean
that all software which can mix audio has to suck.
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<
Jussi Peltola
2007-11-03 16:29:55 UTC
Permalink
Post by Karel Kulhavy
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.
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
chefren
2007-11-03 22:14:21 UTC
Permalink
CL<
Sigh, I hoped he had grown up somewhat or learned something.

Still the wrong edge!

---chefren
Alexandre Ratchov
2007-11-03 16:36:58 UTC
Permalink
Post by Karel Kulhavy
Post by Alexandre Ratchov
Post by Nick Guenther
On 10/31/07, Brian A Seklecki (Mobile)
Post by Brian A Seklecki (Mobile)
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.
Oh awesome! Is /Open/BSD one of those?
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.
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.
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
going off-topic.
Post by Karel Kulhavy
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.
that isn't necessary because we don't need FFT to obtain filter
coefficients (they can be determined at initialization). But I'm
again off-topic.
Post by Karel Kulhavy
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 more
computationally intensive, but the sharper the transition so you lose less of
the high frequencies.
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
Jacob Meuser
2007-10-31 21:30:44 UTC
Permalink
Post by Brian A Seklecki (Mobile)
Post by Tomas Bodzar
And still one thing
When I was try OpenBSD (I think that was 3.8),I use WindowMaker,Xmms and lots
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.
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.
--
***@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
Unix Fan
2007-10-31 15:49:01 UTC
Permalink
This is an interesting topic, I also noticed that multiple applications couldn't open /dev/audio at the same time...



Doesn't this make it impossible to record and listen to audio from ones microphone at the same time? quite... archaic don't you all agree?
Alexandre Ratchov
2007-10-31 16:42:14 UTC
Permalink
Post by Unix Fan
This is an interesting topic, I also noticed that multiple
applications couldn't open /dev/audio at the same time...
Doesn't this make it impossible to record and listen to audio
from ones microphone at the same time? quite... archaic don't you
all agree?
you don't need to open /dev/audio twice to play and record in
full-duplex. The current audio(4) API allows apps to play and
record simultaneously.

-- Alexandre
Jacob Meuser
2007-10-31 21:41:13 UTC
Permalink
Post by Unix Fan
This is an interesting topic, I also noticed that multiple applications couldn't open /dev/audio at the same time...
Doesn't this make it impossible to record and listen to audio from ones microphone at the same time? quite... archaic don't you all agree?
archaic is the idea that you would need two programs, or that a single
program would need to open /dev/audio twice, for such purpose.
--
***@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
Craig Findlay
2007-11-01 02:23:15 UTC
Permalink
I am having trouble using a Maxtor OneTouch external drive (an older
model 250GB drive) on a 4.1 Ipex Celeron box. I suspect that the drive
itself is the problem but I wanted to get some other opinion.

The most recent error resulted in the following output: The first part
is when I plugged the drive in, the second when the error occurred while
running an rdiff-backup process using the drive as the destination.

umass0 at uhub6 port 4 configuration 1 interface 0
umass0: Maxtor OneTouch, rev 2.00/2.00, addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets
sd0 at scsibus1 targ 1 lun 0: <Maxtor, OneTouch, 0200> SCSI0 0/direct fixed
sd0: 239371MB, 239371 cyl, 64 head, 32 sec, 512 bytes/sec, 490232832 sec
total

umass0: Invalid CSW: sig 0xd0d0ea80 should be 0x53425355
umass0: Invalid CSW: sig 0xd0d0ea80 should be 0x53425355
umass0: at uhub6 port 4 (addr 2) disconnected
umass0: BBB bulk-in stall clear failed, IOERROR

Any help is appreciated. Mostly when this happens the drive ends up
uncleanly mounted and fsck is needed to fix various disk errors.

The current USB controller is a VIA VT83C572 on a PCI card, but I also
had similar problems with an Intel 82801DB controller that is on the MB.

Cheers,
Craig
Edwards, David (JTS)
2007-11-01 02:55:30 UTC
Permalink
Post by Tomas Bodzar
-----Original Message-----
On Behalf Of Craig Findlay
Sent: Thursday, 1 November 2007 12:53 PM
Subject: USB drive problem
I am having trouble using a Maxtor OneTouch external drive (an older
model 250GB drive) on a 4.1 Ipex Celeron box. I suspect that the drive
itself is the problem but I wanted to get some other opinion.
The most recent error resulted in the following output: The first part
is when I plugged the drive in, the second when the error
occurred while
running an rdiff-backup process using the drive as the destination.
umass0 at uhub6 port 4 configuration 1 interface 0
umass0: Maxtor OneTouch, rev 2.00/2.00, addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets
sd0 at scsibus1 targ 1 lun 0: <Maxtor, OneTouch, 0200> SCSI0
0/direct fixed
sd0: 239371MB, 239371 cyl, 64 head, 32 sec, 512 bytes/sec,
490232832 sec
total
umass0: Invalid CSW: sig 0xd0d0ea80 should be 0x53425355
umass0: Invalid CSW: sig 0xd0d0ea80 should be 0x53425355
umass0: at uhub6 port 4 (addr 2) disconnected
umass0: BBB bulk-in stall clear failed, IOERROR
I've not seen the "Invalid CSW" bit but I've found that the error
"bulk-in stall clear failed" can be related to the power supply to the
disk.

I've seen that error with external USB laptop drives powered from the
USB cable without a separate external power source.

ciao
dave
---
Dave Edwards
frantisek holop
2007-11-01 16:43:45 UTC
Permalink
hmm, on Thu, Nov 01, 2007 at 01:23:15PM +1100, Craig Findlay said that
Post by Craig Findlay
umass0: BBB bulk-in stall clear failed, IOERROR
definitely try another USB cable too.
a flakey cable produces a lot of different errors.
i was bitten by this in the past.

-f
--
show me a sane man and i will cure him for you. -- c. jung
Jacob Meuser
2007-11-02 21:21:52 UTC
Permalink
resending, sorry if this is a dup.
Post by Dorian Büttner
No kde doesn't play anything at all, kmixer doesn't have any available device.
ah, you have kdemultimedia installed. there were a couple issues
with that port that mostly broke arts, but have been fixed in the
last few days. either uninstall kdemultimedia, or update to
kdemultimedia-3.5.8p0.
--
***@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
Dorian Büttner
2007-11-03 23:55:23 UTC
Permalink
Post by Jacob Meuser
resending, sorry if this is a dup.
Post by Dorian Büttner
No kde doesn't play anything at all, kmixer doesn't have any available device.
ah, you have kdemultimedia installed. there were a couple issues
with that port that mostly broke arts, but have been fixed in the
last few days. either uninstall kdemultimedia, or update to
kdemultimedia-3.5.8p0.
kdemultimedia is deinstalled, and I thaught I could easily work around
by using amarok instead. But that would not work since the kde
soundsystem already was in use of the audio. To make this issue somewhat
sillier, kandalf came up pointing me to artsdsp which I found out to be
the wrong lane, either.
Lastly, on further googling, I found your libxine patch which enables
the usage of artsd and that seems to be sufficient for now.

Thanks,
Dorian
Karel Kulhavy
2007-11-03 12:09:48 UTC
Permalink
Post by Samuel Proulx
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
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.

CL<
Post by Samuel Proulx
in the background with mpd or xmms . thank you for your time ; )
Jacob Meuser
2007-11-03 20:38:38 UTC
Permalink
Post by Karel Kulhavy
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.
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?
--
***@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
Loading...