Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 31

Thread: HOWTO: LOW LATENCY AUDIO the easy way

  1. #11
    Join Date
    Mar 2005
    Beans
    6,040

    Re: HOWTO: LOW LATENCY AUDIO the easy way

    As an alternative, you can install the corresponding linux-restricted-modules package for your new kernel, assuming there is one.
    Previously known as 23meg

  2. #12
    Join Date
    Sep 2005
    Location
    Canada
    Beans
    86
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: LOW LATENCY AUDIO the easy way

    It doesn't look like there is any

  3. #13
    Join Date
    Oct 2005
    Location
    IN, USA
    Beans
    274

    Re: HOWTO: LOW LATENCY AUDIO the easy way

    thank you! This howto helped out a lot!!! I wouldn't have know where to start otherwise.

    I just tried the realtime-lsm module and it has improved my audio responsiveness ... here is a list of everything I did. A word of warning ... I am still new to Ubuntu so all these steps may not be needed

    -----

    HOWTO SETUP REALTIME-LSM FOR BREEZY (DEFAULT KERNEL)

    EDIT: BEFORE TRYING THIS, SEE POST #18 IN THIS THREAD ... WHICH SHOWS A BETTER APPROACH USING RTLIMITS. I'D RECOMMEND USING REALTIME-LSM AS YOUR LAST OPTION. ANYWAYS:

    1. first, I configured Breazy to use alsa for input and output. In Gnome, this is set at:
    System -> Preferences -> Multimedia Systems Selector

    2. I added universe repository to Synaptic Package Manager...

    If you're not sure how to do this, see

    https://wiki.ubuntu.com/AddingRepositoriesHowto
    https://wiki.ubuntu.com/SynapticHowto
    https://wiki.ubuntu.com/AptGetHowto?...ct=AptGetHowTo

    3. then i installed the realtime module

    Code:
    #switched to super user for convenience .. always use care as superuser
    sudo -i
    
    # you'll need to install headers for your version of linux
    # you can do:
    apt-get install linux-headers-$(uname -r)
    
    # you'll need the module-assistant too
    apt-get install module-assistant
    
    # install jack tools
    apt-get install jackd libjack0.80.0-dev qjackctl
    
    #get and build realtime-lsm
    # note: i got an error at this step saying roughly
    # some kernel sources are unconfigured.
    # i figure this was from something else I caused.  I ignored.
    
    m-a update
    m-a prepare
    m-a get realtime-lsm
    m-a get realtime-lsm-source
    m-a build realtime-lsm-source
    m-a install realtime-lsm
    4. reboot the computer. you may get error if you try to do a modprobe. i don't know why, and thougth it would take more time to figure out than to reboot. the module should be loaded when the computer restarts.

    5. create a start script for loading jack. i called the file 'jackstart' ... you can of course name yours anything. note: this might not be needed, but i didn't see anything in /etc/init.d that was related to jack

    --start script--
    Code:
    #!/bin/bash
    
    /usr/bin/jackd --realtime -d alsa -d hw -r 44100 -p 2048 -n 2 &
    --end script--

    # also changed group to audio for this script
    chgrp audio jackstart

    6. now almost done. i tried starting jack using this script, and then ardour, but it still didn't seem to be in realtime. so i opened up the jack control panel:

    Code:
    qjackctl
    go to Settings. check the "realtime" option. if jackd is running it will tell you to restart jack, you can stop jack and restart with:


    Code:
    killall jackd
    and then use the custom script to restart (assuming you are in the same directory):

    Code:
    ./jackstart
    then i tested ardour and hydrogen. both had improved audio performance. no xruns.

    7. Ardour notes:

    ardour is a multitrack recording package. I tested ardour a bit more with multitracking. I could still hear a bit of latency (like one beat of delay) when recording. but after thinking about it, i realized the sound was delayed because it was taking a long path:

    (a) going from the instrument into (b) the mixer, then (c) going into the computer, (d) then processed, (e) then be returned to the mixer, and (f) sent to my ear.

    i assume this is unavoidable? (I've never used a computer to record before) a simple trick to eliminate this is to always click 'record' and 'mute' for the track you are currently working with. i use a mackie mixer, so i can hear the sound from the source directly, rather than piping through the computer. in other words, suppose I record track 2, while listening to track 1.

    1. i hear track 1 coming from the computer, into the mixer
    2. i record and mute track 2. so, i hear track 2 (what I'm playing) straight from the mixer
    3. when i playback, I unmute track 2. the two tracks are synced up perfectly.

    hope this is helpful... it is late now, so i'll work on this some more later.

    edit:
    by default realtime-lsm should start automatically when the computer boots. To disable realtime-lsm, edit the file:

    Code:
    /etc/default/realtime
    and change 'yes' to 'no', at:

    Code:
    # enable loading of module at startup
    ENABLE=yes
    Last edited by yaaarrrgg; December 13th, 2005 at 04:45 AM.

  4. #14

    Re: HOWTO: LOW LATENCY AUDIO the easy way

    I would love to see this howto integrated into something like the Automatix script. This would be a good way to troubleshoot the methodology, too.
    "A smooth sea never made a skilled mariner"
    My kickawesome web design business...powered by Ubuntu

  5. #15
    Join Date
    Oct 2005
    Beans
    40

    Re: HOWTO: LOW LATENCY AUDIO the easy way

    --start script--
    Code:
    #!/bin/bash
    
    /usr/bin/jackd --realtime -d alsa -d hw -r 44100 -p 2048 -n 2 &
    --end script--

    nope, this is your problem here -p 2048 by setting the period to 2048 that gives you a latency of probably 92ms wich is horrible if you need to hear what you record WITH plugins.
    basicly try and lower the period to 64 if it works ok, then you've got yourself a 2.9ms latency wich is amazing. if jack doesn't start, then raise the period to 128 wich is still a good 5.6ms. If you still get problems, try raising the latency again. I find it easier to start jack via the qjackctl app wich has a great configuration setup.
    anything under 10ms should be reasonably "good" you probably will hear a delay if you are close or over 10ms!
    the lower the better!
    I'm glad that people enjoy this how-to and even happier that people add their insights to this particular task.

    thanx

  6. #16
    Join Date
    Nov 2005
    Beans
    28

    Re: HOWTO: LOW LATENCY AUDIO the easy way

    Cheers mathieujohnson, thanks for this HOWTO, it's good to know you can run a Demudi low latency kernel on Ubuntu.

    However, I didn't understand everything yet, but from what I read, it seems that realtime-lsm is deprecated and there's something new built into the kernel already, it's called rtlimits. If anybody wants to look into it, here's a description of this approach.

    It is mentioned that there's a tool called set_rtlimits that can help in reaching realtime mode for specified applications. I tried it, and it seems to work with the standard breezy kernel, but I still have to test it thoroughly.

    If anybody else has experiences with this, I would be interested to hear about it. Maybe this is another option to achieve low latency on Ubuntu.

  7. #17
    Join Date
    Apr 2005
    Beans
    228

    Re: HOWTO: LOW LATENCY AUDIO the easy way

    I'm having problems with this.

    1) The low-latency kernel doesn't work for me (the nvidia drivers apparently are the problem; it also complains about the s20powerd startup script.)

    2) I installed set_rtlimits, which don't work for me -- I tried
    set_rtlimits -d -r=1 /usr/bin/jackd -dalsa -dhw:1 -r44100 -p1024 -n2
    ...
    set_rtlimits -d -r=100 /usr/bin/jackd -dalsa -dhw:1 -r44100 -p1024 -n2

    ...and got xruns in every case.

    3) m-a get realtime-lsm-source

    ...failed until I had installed realtime-lsm and realtime-lsm-source using synaptic. From what I understand in the above, it should work without that step. I do have multiverse & universe enabled.

    4) Even after installing realtime-lsm & realtime-lsm-source, m-a build realtime-lsm-source fails to build.

    5) Using qjackctl or the commandline, --realtime fails.

    6) The only sweet spot for me is -p2048, which isn't exactly instantaneous (but is OK). I'd expect better though -- I have an AMD 3400, with 1GB RAM, outputting to an M-Audio Delta 44.

    So, what can I do to reduce latency?

    Thanks
    Reuben

  8. #18
    Join Date
    Oct 2005
    Location
    IN, USA
    Beans
    274

    Re: HOWTO: LOW LATENCY AUDIO the easy way

    Ahhh, thank you all for the replies... corrected some of my notes too. My frame buffer was way too large. Makes more sense now.

    I just tried the rtlimits solution too. For me, this seemed to be a lot easier to work with than realtime-lsm. Also, it is already merged in the kernel, so makes more sense to use it. More details on how I set mine up:

    note: The computer I'm testing this on is nothing special...just a basic t2682 emachine: 2.6 Ghtz with 256 MB of memory, running Ubuntu 5.10 with very few modificatons. Couple things I already have setup:

    1. first, I configured Breezy to use "alsa" for input and output. In Gnome, this is set at:
    System -> Preferences -> Multimedia Systems Selector

    2. Also I added universe repository to Synaptic Package Manager... and I have previously installed:

    build-essential, linux-headers-2.6.12-9-386, jackd, libjack0.80.0-dev, qjackctl, and ardour

    If you're not sure how to do this, see:
    https://wiki.ubuntu.com/AddingRepositoriesHowto
    https://wiki.ubuntu.com/SynapticHowto
    https://wiki.ubuntu.com/AptGetHowto?...ct=AptGetHowTo

    3. Also, if you have installed realtime-lsm, it is probably a good idea to deactivate it. Not sure what would happen if you run both these at the same time.

    -----

    HOWTO SETUP RTLIMITS (FOR BREEZY DEFAULT KERNEL)

    Code:
    #switching to superuser... working in tmp directory
    sudo -i
    cd /tmp
    
    #get and unpack set_rtlimits program
    wget http://www.physics.adelaide.edu.au/~jwoithe/set_rtlimits-1.1.0.tgz
    tar xvzf set_rtlimits-1.1.0.tgz
    cd set_rtlimits-1.1.0
    
    # this should compile the program and install
    # note though... 
    # i've already installed linux-headers and build-essential with apt-get
    make
    make install
    For me, this compiled and installed without any errors. To configure it now, you'll need to add the programs you'll invoke in the config file /etc/set_rtlimits.conf

    For me, the file looks like this (my username is kevins)
    Code:
    # Configuration file for set_rtlimits.  Format is:
    #
    #   username   program   max_nice_priority  max_realtime_priority
    
    kevins  /usr/bin/jackd  -1  100
    kevins  /usr/bin/ardour -1  100
    Now you are ready to go. I wrote a quick script to launch jackd and ardour, (although there are probably countless better ways to do this).

    Code:
    #!/bin/bash
    # this is a simple script for starting jack and ardour
    # i usually don't have jackd running so i kill it after exiting
    
    # NOTES ON THE OPTIONS:
    
    # 1. the jackd "-n" option:
    # determines the number buffers your hardware supports
    # my cheap card supports "2" ... left and right channels?
    
    # 2. the jackd "-p" option:
    # determine the period  (or frame size...must be a multiple of 2).
    # the smaller, the less latency. although if it's too small, you'll get 'xruns'
    # (meaning your hardware can't keep up). possible values, for example, are:
    #       64  (excellent)
    #       128 (good)
    #       256 (ok)
    
    # 3. the set_rtlimits "-r" option:
    # sets the priority "-r" for jack and ardour between 1 (low) and 100 (high)
    # 30 seems to be a good choice for jack, with ardour slightly smaller
    
    # start the apps in realtime mode
    killall jackd
    set_rtlimits -r=30 /usr/bin/jackd -R -d alsa -d hw -r 44100 -p 256 -n 2 &
    set_rtlimits -r=25 /usr/bin/ardour
    killall jackd
    This should launch ardour and jack in realtime. If you get xruns, then you might experiment with different priorities and frame size. For me, ardour reports having 5.6 millisecond latency, and is very solid. Tried 2.9 millisecond delay, but occasionally there was an xrun with the default breezy kernel.

    -----

    SUMMARY OF THE 3 METHODS LISTED IN THIS HOWTO, RANKED BY PERFORMANCE

    1. demudi kernel: Very solid! for me, Ardour reports 1.5 ms latency (since using two buffers). Of course with a different kernel, there's a chance a few things could need to be recompiled to run. For example, my system seems to work perfectly except my wierd wireless internet card.

    2. rtlimits: For me, ardour reports 5.6 ms latency. Works with default breezy kernel (not as fast as demudi though). also, this is already integrated into the kernel, and a good choice if you don't use the demudi kernel.

    3. realtime-lsm: Ardour reports 5.6 latency. Also works with default breezy kernel. A bit harder to set up than rtlimits. Also, seemed like something was a bit flakey a few times. For best results, start jackd from the control panel qjackctl, and be sure to check setup. be sure to check "realtime", and try setting the priority to "30".

    -----

    yeah.. it would be nice if automatix had a sound studio package that included things like ardour, rosegarden, and hydrogen. Incredible apps, but setting them up can be difficult. Intially I almost gave up on Ardour.
    Last edited by yaaarrrgg; February 1st, 2006 at 02:46 AM.

  9. #19
    Join Date
    Nov 2005
    Beans
    28

    Re: HOWTO: LOW LATENCY AUDIO the easy way

    Ha, yaaarrrgg, thanks for the detailed description how to use set_rtlimits. I was prepared to do this to help reuben, but you beat me to it and saved me some work.

    reuben, can you test yaaarrrgg's way for set_rtlimits? It should work then, I'm doing the same and getting jack to run in realtime mode.

    Remember that you need to start every application via set_rtlimits -r..., not only jackd, and that every such application needs a corresponding entry in /etc/set_rtlimits.conf.

    Edit: yaaarrrgg, why do you "killall jackd" at the very last line in your jack/ardour starter script? Wouldn't this kill jack after you just started it?
    Last edited by Sanne; December 11th, 2005 at 04:37 PM.

  10. #20
    Join Date
    Oct 2005
    Location
    IN, USA
    Beans
    274

    Re: HOWTO: LOW LATENCY AUDIO the easy way

    Quote Originally Posted by Sanne
    Edit: yaaarrrgg, why do you "killall jackd" at the very last line in your jack/ardour starter script? Wouldn't this kill jack after you just started it?
    I start jackd as a background process (with the '&' at the end), but not ardour. So, the last line is not executed until after ardour is closed. For now, I don't use jackd for anything other than ardour. Not sure how other people use jack though ...

Page 2 of 4 FirstFirst 1234 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
  •