Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: HOWTO: Software mixing with JACK and oss2jack

  1. #1
    Join Date
    Dec 2005
    Location
    Germany
    Beans
    179
    Distro
    Ubuntu 9.10 Karmic Koala

    Lightbulb HOWTO: Software mixing with JACK and oss2jack

    HOWTO: Sound mixing in software with JACK and oss2jack

    I originally wrote this HOWTO for Breezy some months ago. Then I wrote an updated and cleaned up version for Dapper and I also updated my packages used by this HOWTO. Lately I update all stuff to be used on Feisty (NEW), too. The old one for Breezy is still around: http://www.ubuntuforums.org/showpost...90&postcount=6

    Problem: ALSA supports software mixing by its dmix plugin (for sound cards which do not support that in hardware). dmix is working with most ALSA applications. But, there are some ALSA applications which do not work with dmix, they just block the whole ALSA device (as if dmix wasn't there).
    Furthermore OSS apps which are forced to use ALSA OSS emulation can't be dmix'd, they also block the whole sound device.
    So, this HOWTO is for those of you who use OSS only applications and want them to be able to play sound at the same time, without using wrappers for sound servers or general ones (e.g. aoss).
    Examples of OSS only applications are: Skype (< 1.3.x), TeamSpeak2, Audacity, ET, ...


    PROBLEM: this HOWTO & TeamSpeak2
    Some months ago it was discovered and confirmed by several people that TeamSpeak2 doesn't work with the software used in this HOWTO any more (crash, "Runtime error ...", "Segmentation fault"), although it used to work with the old HOWTO on Breezy. I still don't have any glue why. It's very very strange. As with Dapper, this problem also exists on Feisty - sorry.


    PROBLEM 2: this HOWTO & Feisty & Audacity
    Till now, I couldn't convince Audacity to work through it's OSS output feature - neither playing nor recording works for me. This hasn't been confirmed by others yet, so if you try it, tell me about your findings!


    Solution: Sound servers: artsd (KDE), esd, polyp (GNOME), ... others. Sound applications have to have special output drivers to use them and most have.
    But some applications don't have such drivers. Then you would have to use wrappers (artsdsp, esdsp) which "try" to catch the calls of the applications (in userspace) and reroute them to their sound servers.
    These wrappers sometimes work great (artsdsp/KDE) or bad (esddsp/GNOME) (at least on my computer).

    Solution described here: Use of JACK as sound server (although JACK is more than a sound server, I know ...) and oss2jack, a special tool which emulates an OSS device and reroutes the data to JACK.
    Then all OSS only application will be able to open the sound device at the same time and play at the same time.
    For other applications (all true ALSA applications) there two alternatives now, which depend on how jackd is started (commandline arguments):

    (jack-only-alternative) This is the original one, used in this HOWTO till now. jackd blocks the whole ALSA sound device and all other sound applications will have to use application specific jackd output drivers/plugins (like xmms, mplayer, ... have) and play through jackd.

    (NEW) (jack-as-dmix/dsnoop-client-alternative) This is the second, the new one. Here jackd is started with the commandline arguments "-P dmix -C dsnoop" and therefore jackd will act as a dmix/dsnoop client, which means that ALSA applications which also use dmix/dsnoop can still use the sound device and play at the same time. This means, that you don't have to reconfigure any of your ALSA applications (esd, totem, xmms, mplayer ...) - they just play their sound as usual (through dmix/dsnoop).
    The drawback is, that you cannot use the commandline argument "-p 256" anymore and therefore you might get latency problems (default is a value of 1024 (frames per period), which may be too much)!

    The steps (1. to 10.) you see below, are marked with the bold words from above if they only apply to one specific alternative. You will see, that the second alternative effectivly uses steps 1 to 3, 5, 6.B and 7. only!



    Important assumptions made in this HOWTO: You are using Ubuntu 6.06 (Dapper) or Ubuntu 7.04 (Feisty) with GNOME and ALSA. Your sound card (hardware) basically works.

    Note 1: I'm neither an expert in sound stuff nor an ubuntu developer, so tell me, if I'm saying something wrong.

    Note 2: If you really need *perfect* sound mixing, IMO you will still have to buy a "real" sound card with a sound chip which is able to do it in hardware.
    Back then, when I started to write this HOWTO, I tested this solution with xmms, mplayer playing files and talking to somebody in skype at the same time. I also tested it with TS2 and ET at the same time.


    Installing needed packages:

    1. Add the following (my) repository to your /etc/apt/sources.list file:

    Dapper
    Code:
    deb http://neogate.homelinux.org/debian/ dapper sound

    Feisty
    Code:
    deb http://neogate.homelinux.org/debian/ feisty sound
    Don't forget to update your package system. To do this you can do:

    Code:
    sudo apt-get update
    2.A Then install jackd from dapper and oss2jack
    from the repository given above by typing:

    Code:
    sudo apt-get install jackd oss2jack
    NOTE: During the installation of the package "oss2jack" you'll get asked 2 questions.
    The first one says "Do you want to disable the ALSA OSS modules?". For this HOWTO to work, you have to choose "Yes".
    The second question says: "Do you want to unload the ALSA OSS modules now?". You may choose "Yes" here, too. You could do that manually, too (see step 7), but it won't hurt to let the installation try to unload them.

    Now do step 2.B OR step 2.C, NOT BOTH, only one of them depending on the kernel you have installed:
    2.B In my repository are pre-build kernel modules for dapper kernel 2.6.15-23, 2.6.15-25, 2.6.15-26, 2.6.15-28, 2.6.15-29 and feisty kernel 2.6.20-15, 2.6.20-16. If you have installed one of these kernels, do:

    Code:
    sudo apt-get install fusd-kor-module-`uname -r` fusd-kor
    2.C If you have an other dapper/feisty kernel or a selfmade one, you will have to install fusd-kor-source instead of the pre-build module and build your own fusd-kor-module package.
    So, first you have to prepare your system for module compilation. To do that, install module-assistant:

    Code:
    sudo apt-get install module-assistant
    sudo m-a prepare
    sudo apt-get install gcc-`grep LINUX_COMPILER /usr/src/linux/include/linux/compile.h | sed 's/.* \([0-9]\+\.[0-9]\+\).*/\1/'`
    The second command will make module-assitant (m-a) install the needed linux-headers packages. (If you have a selfmade linux-kernel package, you (probably) will have to manually install your own linux-headers package.) The last command here, makes sure that you have got installed the right version of gcc (GNU C Compiler).

    Then, install fusd-kor-source and build your own fusd-kor-module packages:

    Code:
    sudo apt-get install fusd-kor-source
    sudo m-a a-i fusd-kor
    sudo apt-get install fusd-kor
    In the second command m-a will do all the stuff needed to configure, build and install your own fusd-kor-module package automatically. The last command installs the package "fusd-kor".

    NOTE on step 2.B and 2.C: During the installation of the package "fusd-kor" you'll get asked 2 questions.
    The first one says "Do you want the fusd-kor kernel module to be loaded during the boot process?". For this HOWTO to work, you have to choose "Yes".
    The second question says: "If needed, you can specify commandline parameters ...". Do not enter anything there, leave it blank.

    Now do step 3.A OR step 3.B, NOT BOTH, only one of them depending on the kernel you have installed:
    3.A I also installed the realtime kernel module, so that jackd and oss2jack are able to run with a higher priority. In my repository are pre-build kernel modules for dapper kernel 2.6.15-23, 2.6.15-25, 2.6.15-26, 2.6.15-28, 2.6.15-29 and feisty kernel 2.6.20-15, 2.6.20-16. If you have installed one of these kernels, do first:

    Code:
    sudo apt-get install realtime-lsm-module-`uname -r`
    then
    Code:
    sudo apt-get install realtime-lsm
    3.B If you have an other dapper/feisty kernel or a selfmade one, you will have to install realtime-lsm-source instead of the pre-build module and build your own realtime-lsm-module package.
    So, first you have to prepare your system for module compilation. To do that, install module-assistant:

    Code:
    sudo apt-get install module-assistant
    sudo m-a prepare
    sudo apt-get install gcc-`grep LINUX_COMPILER /usr/src/linux/include/linux/compile.h | sed 's/.* \([0-9]\+\.[0-9]\+\).*/\1/'`
    The second command will make module-assitant (m-a) install the needed linux-headers packages. (If you have a selfmade linux-kernel package, you (probably) will have to manually install your own linux-headers package.) The last command here, makes sure that you have got installed the right version of gcc (GNU C Compiler).

    Then, install realtime-lsm-source and build your own realtime-lsm-module packages:

    Code:
    sudo apt-get install realtime-lsm-source realtime-lsm
    sudo m-a a-i realtime-lsm
    In the last command m-a will do all the stuff needed to configure, build and install your own realtime-lsm-module package automatically.

    4. (jackd-only-alternative) Usually the package "libesd-alsa0" is installed to allow esd to output to ALSA. But since we are going to use JACK (and jackd blocks the ALSA sound device by default), you need to replace "libesd-alsa0" with "libesd0", which enables esd to output to OSS devices.

    Code:
    sudo apt-get install libesd0
    This way, esd (which is responsible for all "GNOME desktop sounds") will output its stuff to our emulated OSS device by oss2jack.


    5. To be able to run jackd and oss2jack with a higher priority, you have to make sure that you are a member of the "audio" group. This is also needed due to the owner/group settings of the device files of the kfusd kernel module. If in doubt, do:

    Code:
    sudo adduser <your_username> audio

    Start jackd and oss2jack after login (automatically)

    6.A (jackd-only-alternative) GNOME automatically starts its esd (GNOME's sound server) after login, so that you can hear the login sound etc. In the first section you configured esd to output to OSS devices (step 4.).
    So we need to start our jackd/oss2jack combination before esd gets started. To do that we use the ~/.gnomerc file, which is executed before any GNOME stuff gets started after login. You will find the script I use in /usr/share/doc/oss2jack/examples/.gnomerc , so copy it over to your home directory:

    Code:
    cp /usr/share/doc/oss2jack/examples/.gnomerc ~/.gnomerc
    I admit, that my script is some kind of a (dirty) hack ... just in case you wonder about the loop at the end for example.
    Note that this script assumes, that you followed step 3. That means: in theory you could do without step 3, but that's not recommended. You would have to edit the script and remove the "nice" adjustments and run jackd/oss2jack without higher (realtime) priority.


    6.B (jackd-as-dmix/dsnoop-client-alternative) We need to start our jackd/oss2jack combination after login. To do that we use the ~/.gnomerc file, which is executed before any GNOME stuff gets started. You will find the script I use in /usr/share/doc/oss2jack/examples/.gnomerc-dmixsnoop , so copy it over to your home directory:

    Dapper/Feisty
    Code:
    cp /usr/share/doc/oss2jack/examples/.gnomerc-dmixsnoop ~/.gnomerc
    I admit, that my script is some kind of a (dirty) hack ... just in case you wonder about the loop at the end for example.
    Note that this script assumes, that you followed step 3. That means: in theory you could do without step 3, but that's not recommended. You would have to edit the script and remove the "nice" adjustments and run jackd/oss2jack without higher (realtime) priority.

    If you are using Feisty you may also copy the example file /usr/share/doc/oss2jack/examples/.asoundrc to your home directory:

    Feisty
    Code:
    cp /usr/share/doc/oss2jack/examples/.asoundrc ~/.asoundrc
    It contains a configuration item which creates a mixer element named "dmix". If this is not there, jackd complains about not being able to open a mixer device.


    It's nearly done

    7. Only needed if you don't want to reboot now. You will have to load the realtime module manually. Next time you do a reboot it will get loaded automatically (step 3). Furthermore you have to unload the ALSA OSS emulation modules. If you choose to unload them during the installtion of the package oss2jack (step 2.A), they shouldn't be there anymore, but it doesn't hurt to "rmmod" them again (so there might appear an error message saying "ERROR: Module XXXX does not exist ..." - just ignore it). On future reboots they will be prevented from being loaded automatically, too (step 2.A).

    Code:
    sudo /etc/init.d/realtime start
    
    sudo /etc/init.d/fusd-kor start
    sudo rmmod snd-pcm-oss
    sudo rmmod snd-mixer-oss
    So, the first command should suffice here, the other three are just there to really make sure that nothing bad happened during the steps above while loading and unloading.

    NOTE: If your are using Feisty, this step 7 shouldn't be necessary at all. But again: it can't hurt.

    8. If you didn't reboot in step 7, now at least you have to logout and login again, so that your ~/.gnomerc script gets executed.


    Configuring software

    9. (jackd-only-alternative) Usually gstreamer is installed and configured to autodetect and chose one output "method". But - same reason as with esd (step 4.) - we need it to output to our emulated OSS device by oss2jack. Go to:

    System -> Preferences -> Multimedia Systems Selector

    and chose OSS (output and input). If this menuitem does not exist, start the Multimedia Systems Selector by this command:

    Code:
    gstreamer-properties
    and chose OSS (output and input).

    In Feisty there is another dialog, which might need some changes:

    System -> Preferences -> Sound

    In tab "Devices" you might have to chose "OSS" explicitly - but ATM I'm not sure about "for what" these configuration items are really good for. The default, called "Autodetect", just works in my case.



    10.A (jackd-only-alternative) Configuring (other) sound applications

    In general, it is a good idea to leave the configuration of your applications alone - at least at the beginning. Try them, if they still work and if not, change teir configuration.

    Here is a list of applications and with which output driver I used them:

    - esd ... oss (configured above, step 4.)
    - gstreamer ... oss (configured above, step 9.)

    - xmms ... jack
    - mplayer ... jack in Dapper, oss in Feisty
    - vlc ... oss
    - gxine/xine ... oss
    - licq ... use "esdplay" in Licq Menu -> Options -> OnEvent: Command
    - wine ... oss (wine might need a patch, not sure at the moment, see the resources section below)

    Note that the tool "esdplay" mentioned above is contained in the package "esound-clients". If you need "esdplay" (e.g. if you use licq) you have to install it:

    Code:
    sudo apt-get install esound-clients


    10.B (jackd-as-dmix/dsnoop-client-alternative) Configuring (other) sound applications

    As already mentioned, using jackd as a simple dmix/dsnoop client has the advantage of not having to reconfigure any ALSA application. jackd is just one more client to the ALSA library's software mixing feature (dmix/dsnoop) - like all other ALSA applications are (esd, xmms, mplayer, totem, vlc, ...).


    NOTE on step 10.A and 10.B : Applications like Audacity, Skype, ET, ... can use OSS only, so they will use our emulated OSS device by oss2jack.


    (Other) resources around this HOWTO

    - Little (external) "homepage" of this HOWTO http://neogate.homelinux.org/howto-oss2jack/

    - oss2jack: http://fort.xdas.com/~kor/oss2jack/

    - JACK: http://jackit.sourceforge.net/

    ================================================== ===================
    END OF HOWTO
    ================================================== ===================


    If you don't like the result of this HOWTO or if you have to reverse the whole thing because of some other reason, here's a list, what you have to do to switch back to ALSA/dmix. I used the same step numbers as in my HOWTO:

    6. Remove ~/.gnomerc, ~/.asoundrc and terminate the tools:

    Code:
    rm ~/.gnomerc ~/.asoundrc
    killall esd
    killall oss2jack
    killall jackd
    9. (jackd-only-alternative) Go to

    System -> Preferences -> Multimedia Systems Selector

    and select Autodetect for input and ALSA for output. If this menuitem does not exist, start the Multimedia Systems Selector by this command:

    Code:
    gstreamer-properties
    and select Autodetect for input and ALSA for output.

    4. (jackd-only-alternative) Replace the package "libesd0" with "libesd-alsa0", by doing:

    Code:
    sudo apt-get install libesd-alsa0

    2.A(B|C) + 3. Now uninstall the rest of the software packages installed by the HOWTO:

    Code:
    sudo apt-get remove --purge oss2jack fusd-kor* jackd realtime-lsm*
    2.A If you don't want to reboot now, you have to load the ALSA OSS emulation modules again:

    Code:
    sudo modprobe snd-mixer-oss
    sudo modprobe snd-pcm-oss
    8. Now at least you have to logout and login again, so that esd is getting started again by GNOME.
    Last edited by joft; September 2nd, 2007 at 09:55 AM. Reason: Added pre-compiled modules for dapper kernel 2.6.15-29 .

  2. #2
    Join Date
    Jun 2006
    Beans
    2

    Re: HOWTO: Software mixing with JACK and oss2jack

    thanks, it works ^^

  3. #3
    Join Date
    Jul 2006
    Beans
    1

    Re: HOWTO: Software mixing with JACK and oss2jack

    Not working for me.

    Before:

    cedega wow : sound ok but not width Teamspeak (this is my probleme)

    After:

    cedega wow : no sound
    Teamspeak : crash on starting


    i ve do some test to see if process is load, everythings like to be good.


    The procedure to go back work fine.

    thank for howto.

  4. #4
    Join Date
    Dec 2005
    Location
    Germany
    Beans
    179
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: HOWTO: Software mixing with JACK and oss2jack

    Hi mmaura,

    Quote Originally Posted by mmaura View Post
    Not working for me.

    Before:

    cedega wow : sound ok but not width Teamspeak (this is my probleme)

    After:

    cedega wow : no sound
    Teamspeak : crash on starting


    i ve do some test to see if process is load, everythings like to be good.
    hmmm, the first step for finding out what's going wrong probably would be to look for the output of jackd and oss2jack. For this you would have to remove your .gnomerc and start jackd and oss2jack by hand (after login, in terminal).

    In one terminal:
    Code:
    jackd -R -d alsa -p 256
    and in another one:
    Code:
    oss2jack
    Ah, another idea: does esd (Desktop sounds, ...) work after such a TS crash? If not, this may indicate a crash of oss2jack/jackd. So you most probably will see something in the output of them.

    Quote Originally Posted by mmaura View Post
    The procedure to go back work fine.
    Thanks for your feedback.

  5. #5
    Join Date
    Jan 2006
    Beans
    37

    Re: HOWTO: Software mixing with JACK and oss2jack

    Will this fix flash randomly having no sound for me?

  6. #6
    Join Date
    Jul 2006
    Beans
    2

    Re: HOWTO: Software mixing with JACK and oss2jack

    it's not really working for me ...

    using your script, i got system sounds, but oss2jack did not work. after removing your script and starting jackd and oss2jack in terminals, i get the following:

    Code:
    delay of 6561.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6565.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6573.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6556.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6521.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6567.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6565.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6564.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6517.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6569.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6565.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6568.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6571.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6554.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6567.000 usecs exceeds estimated spare time of 5224.000; restart ...
    delay of 6568.000 usecs exceeds estimated spare time of 5224.000; restart ...
    in the jackd terminal, and oss2jack returns a nice

    Code:
    Hello from the restart thread
    have you got any idea what went wrong?

  7. #7
    Join Date
    Dec 2005
    Location
    Germany
    Beans
    179
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: HOWTO: Software mixing with JACK and oss2jack

    Hi,

    Quote Originally Posted by linuxfan128 View Post
    Will this fix flash randomly having no sound for me?
    Oh, I am not an flash expert .... but I heard about the "flash problem". If the third-party-binary-only flash plugin uses OSS and is NOT able to use ALSA, then you will certainly have sound problems with flash - simply because if you have another sound application running/has opened a sound device, that application will block flash.

    Keep in mind: This and and the whole HOWTO is only true for sound cards/chips which don't support hardware mixing. So if you have a sound card which does support hw mixing and flash does not work, this HOWTO won't help.


    Quote Originally Posted by schang View Post
    it's not really working for me ...

    using your script, i got system sounds, but oss2jack did not work.
    That doesn't make sense as long as you mean the "GNOME Desktop sounds" by "system sounds". In step 4 of the HOWTO we instruct esd to use OSS instead of ALSA by replacing esd's library. And OSS is provided by oss2jack.
    So, "system sounds work" means esd works - which means that oss2jack and thus jackd is working, too.

    Quote Originally Posted by schang View Post
    after removing your script and starting jackd and oss2jack in terminals, i get the following:

    <....>

    in the jackd terminal, and oss2jack returns a nice

    Code:
    Hello from the restart thread
    have you got any idea what went wrong?
    The message you received from oss2jack is ok. And in general messages by jackd are ok, too. At least I cannot see anything bad in your messages.

    Can you check sound with XMMS (with JACK output plugin) for example? So we can see if jackd really works. Then you could check if oss2jack creates the device (/dev/dsp and /dev/mixer). They have to exist - otherwise there really is something wrong with oss2jack (while oss2jack is running - check with "ps fx" - once started (e.g. in a termnial) oss2jack shouldn't stop!).

  8. #8
    Join Date
    Jul 2006
    Beans
    2

    Re: HOWTO: Software mixing with JACK and oss2jack

    well, oss2jack is now working properly. clearly a user problem on this one.

    but now i've got exactly the same problem as mmaura. TS crashes on start, with runtime errors and a segfault. it seems like it's a problem with the latest TS release... could you please check your TS version?

  9. #9
    Join Date
    Dec 2005
    Location
    Germany
    Beans
    179
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: HOWTO: Software mixing with JACK and oss2jack

    Hi,

    Quote Originally Posted by schang View Post
    but now i've got exactly the same problem as mmaura. TS crashes on start, with runtime errors and a segfault. it seems like it's a problem with the latest TS release... could you please check your TS version?
    Code:
    -rwxr-xr-x root/root   1641148 2003-08-29 16:20:22 usr/local/TeamSpeak2RC2/TeamSpeak.bin
    Bad news ... TS does not work any more here, too. At the moment I'm a bit clueless, because TS did work under breezy and as I said in my HOWTO, I just update the HOWTO and the packages (for dapper). Therefore I used new upstream versions of oss2jack and fusd-kor in contrast to the versions I used in the HOWTO for breezy.

    Perhaps these new versions have a bug - but, since the errors are segfaults, I think there is a bug in TS, too.

    I am sorry - I will check the whole situation by using my old packages - just give me some time.

  10. #10
    Join Date
    Oct 2005
    Beans
    40

    Re: HOWTO: Software mixing with JACK and oss2jack

    THANK YOU SO MUCH!!!!

    seriously, I've been looking for this exact thing for months!

    I have always wanted to run everything audio related through jack.
    I run a studio based on linux so jack is a spectacular tool and now not having to close my music to open ardour or hydrogent or wathever app I feel like using, its just great!

    I knew there was a way to go!

    thanx again!

    Mathieu

Page 1 of 4 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •