LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Choppy sound Recording (https://www.linuxquestions.org/questions/linux-software-2/choppy-sound-recording-576825/)

Xvium 08-13-2007 03:15 PM

Choppy sound Recording
 
Hey all I'm using PClinuxOS and a program called ardour to record. I start the qtjackctl then run ardour and i have my guitar plugged into my line in. which is enabled in alsa mixer. the sound records but sounds really bad and choppy. I'm set to 44100khz and the latency is set to 1024. what can i do to fix this?

studioj 08-14-2007 12:32 PM

there are a couple or many ways to aproach this.
first the easy stuff.
don't use qjackcnl i have seen with some setups it causes too much resources to divert to updating the gui readout.
just start jack with the line you find in ~/.jackdrc from the command line.
next is to make x a little more nice. xorg really sucks resources. try a line like.
renice +2 -p `ps -C Xorg -o pid=`
use less or more "+2" as you can get away with and still have x resond ok.
next and this is the most important thing is the buffer settings. generally the slower your sound hardware the larger buffers you need. this is the line i use to start jackd.
jackd -R -P70 -dalsa -dhw:0 -r44100 -p512 -n2
you can try the 1024 setting you had above for -p or greater. i think don't change other settings or add other flags.
next is you ~/.asoundrc where you can change the period and buffer settings for the soundcard itself. i give you mine as an example to start with or look at. it has alternate settings commented out you can play with. if you don't understand just post back.
Code:

pcm.jackplug {
                type plug
                slave { pcm "jack" }
        }

        pcm.jack {
                type jack
                playback_ports {
                        0 alsa_pcm:playback_1
                        1 alsa_pcm:playback_2
                }
                        capture_ports {
                        0 alsa_pcm:capture_1
                        1 alsa_pcm:capture_2
                }

        }

pcm.dsp {
    type plug
  # slave.pcm "dmixer"
    slave.pcm "duplex"
}

pcm.dsp0 {
    type plug
  # slave.pcm "dmixer"
    slave.pcm "duplex"
}



# this makes native ALSA apps default to using dmix
pcm.!default {
    type plug
  # slave.pcm "dmixer"
    slave.pcm "duplex"
 
}

ctl.!default {
        type hw         
        card 0
        }

pcm.dmixer  {
        type dmix
        ipc_key 1024
        slave {
            pcm "hw:0,0"
        #  period_time 0 # set to 0 lets period size and buffer size do everything
            period_time 2 # this is the general standard even though often is set to 0
        #  period_time 84000
        #  period_size 512
            period_size 1024 # oss period frames this is the one shown as hardware
        #    period_size 128
        #  period_size 2048
        #  period_size 4096 # not great to go over this
        #  buffer_time 340000
        #  buffer_size 16384 # this is the one shown as hardware but causes huge mess
        #  buffer_size 8192
        #  buffer_size 4096
            buffer_size 2052 # this is the one i use
            rate 44100 # can let card decide this on it's own this one is what hardware says
        #  rate 48000

        }
        bindings {
            0 0
            1 1
        }
    }
 
    ctl.dmixer {
        type hw
        card 0
    }

    ctl.mixin {
        type hw
        card 0
    }

    pcm.duplex{
        type asym
        playback.pcm "dmixer"
        capture.pcm "mixin"
      }

pcm.mixin {
        type dsnoop
        ipc_key 5978293        # must be unique for all dmix plugins!!!!
        ipc_key_add_uid yes
        slave {
                pcm "hw:0,0"
                channels 2
                period_size 1024
        #      period_size 1026
        #        buffer_size 4096
                buffer_size 2052
                rate 44100
      #                periods 0
                period_time 2
        }
        bindings {
                0 0
                0 1
        }
    }

pcm.ladspadelay {
type ladspa
slave.pcm "plughw:0,0";
path "/usr/lib/ladspa";
plugins [
{
label delay_5s
input {
controls [ 0.8 0.3 ]
}
}
]
}

pcm.delay {

type plug

slave.pcm "ladspadelay";
}


pcm.ladspacompress {
type ladspa
slave.pcm "plughw:0,0";

path "/usr/lib/ladspa";

plugins [
{
label dysonCompress
input {
#peak limit, release time, fast ratio, ratio
controls [1.0 0.1 0.1 0.9]
}
}
]
}

pcm.compress {

type plug

slave.pcm "ladspacompress";
}

next is to mess with rt irq priority settings.
look at
cat /proc/interrupts
pick out the one for rtc and your sound card then set them like this.
chrt -f -p 82 `pidof "IRQ 11"`
chrt -f -p 98 `pidof "IRQ 8"`
where 8 for me is rtc and 11 is my soundcard so adjust as needed.
last is to mess with harware latency settings
look at
lspci -v
find your soundcard
my soundcard is 04:08.0
you can try settings like
setpci -v -s '04:08.0' latency_timer=48
setpci -v -s '04:08.0' latency_timer=78
setpci -v -s '04:08.0' latency_timer=ff
and see what works the best.
generally larger latency settings give larger bursts and better throughput.
you might also be able to turn down video driver latency or even increase latency across the pci bus itself and see if it helps.
post back if you can't get it going. there is kernel junk to do if you have to.


All times are GMT -5. The time now is 09:07 AM.