Delay while recording piano input
Matthew Martinez
I connected my digital piano to my laptop via a JACK cable and an USB sound card adapter.
After running pactl load-module module-loopback latency_msec=1 I am able to hear live sounds from piano. Also, I can record them using Audacity.
A major problem that I have is that they are just a little bit delayed. That affects song recording so I cannot follow the song rhythm properly.
Is there any way to fix this problem? Maybe installing low latency kernel? How can I do that?
52 Answers
- In Audacity preferences "recording" tab, you will find a latency setting to correct the delayed playing while recording: try to increase both values .
Best latency is obtained using Ardour and Jack server:
sudo apt-get install ardourwill install both. No need to change the kernel but the file /etc/security/limits.conf must be edited as root: runsudo gedit /etc/security/limits.confin a terminal and add these 3 lines at the end:@audio - rtprio 99 @audio - memlock unlimited @audio - nice -19You must be in the audio group. Check using the
idcommand and if needed runsudo adduser $USER audioor if you prefer, install users and group management): click advanced for your user then select "use audio device" to be in audio group then reboot .
Running Ardour will auto-launch jack sound server ( temporarily disabling pulseaudio).
In the session window, give a project name. In the audio configuration tab (see Note 2) set a 256 buffer size for good latency ( higher value for higher latency in case you experience "xruns" (clicks) while recording. You will see corresponding latency in ms: it is good if less than 10ms, very good under 5ms, some modern pc can go under 1 or 2 ms . In option tab, verify that real time is selected. Click start.
Then, in the Ardour main window, add a track and click its "r"record button, and start record from transport bar . It should record fine, if not: have a look at this Ardour tutorial.
Tip: Press shift+e to get a mixer strip for setting track connections and level as shown in the tutorial.
Note: If no audio is recorded or getting distorded or low level, verify Alsa audio layer capture lauching alsamixer in a terminal, or more easily, install and run gnome-alsamixer:
- Set rec mode on the relevant fader, generally capture fader
- Set level using the capture, mic, mic boost faders.
Note2: "audio configuration" tab in "Session windows" is displayed when you first launch Ardour: it can be used to set jack parameters (buffer, latency, real time). When you rerun ardour, it is not displayed until you kill jackd (command: killall jackd). But you have the same setting for latency in the jack menu in the main Ardour window or in qjackctl (another application to control and set jack parameters outside Ardour)
You may try installing:
Low latency kernel:
sudo apt-get install linux-lowlatencyOn boot press Shift, to get Grub boot menu, then choose advanced.
Similar question: Is it possible to install two kernels and choose one on startup?
Default Ubuntu Studio settings:
sudo apt-get install ubuntustudio-default-settingswhich contains some audio settings like
lib/udev/rules.d/40-timer-permissions.rules# make precisian timers accessable to audio group and MIDI # # created Sep 3 2012 KERNEL=="rtc0", GROUP="audio" KERNEL=="hpet", GROUP="audio"(I haven't tried it)