USB based linux for live performance?

Post fully complete "how to" guides and tutorials here. This is a great place to get feedback on stuff you might put in the wiki.

Moderators: MattKingUSA, khz

Shadow_7
Established Member
Posts: 175
Joined: Tue Jun 08, 2010 3:35 pm

USB based linux for live performance?

Post by Shadow_7 »

I'm pretty versed in linux, but I am not too familiar with other distros besides debian and ubuntu. I'm looking for a USB bootable (as in limited write flash drive) version of linux. With a realtime low latency kernel and jackd for running fluidsynth. A drummer in a band I'm in has an older Roland TD-7 and wants to lower the latency of the event versus the generated sounds on his laptop.

I have an old M-Audio Keystation 49e. And I can get it working on my ubuntu desktop.

$ fluidsynth -C no -R no -g 1 -j -a jack /usr/share/sounds/sf2/FluidR3_GM.sf2

The "-j -a jack" is "-a pulseaudio" on his ubuntu install. And "-g 1" is "-g 5" on his system. And then manually connecting the keyboard to the synth.

$ aconnect 28 128

the input and output numbers can vary so I use aconnect -i and -o and -o -l to verify things ofc.

> select 0 1 128 000

In fluidsynth to select the drum soundfont.


This works for me, but the drummer is not so versed in linux. And his windows is too high in latency to prove useful for live performance, or even rehearsals. He is techy enough to have installed ubuntu, and for me to walk him through the above method via email. But I'd like a bootable usb linux version that automates this procedure and is optimized for this purpose. And I'm currently at a loss for distros specific to this. I'd like at least /var/log and /tmp to be in a ramdisk to eliminate / minimize writes to the usb stick since it's flash based.

I'll probably figure this out on my own, but it'd be nice if someone else has traveled this road and has some recommendations. He is not techy enough to tell me specifics on his machine like Intel or AMD, but I'm sure I'll find that out come crunch time. Recommendations for drum soundfonts will also be appreciated. I'm a trombone player and an applications developer on a good day. Mostly legacy tech, so not much in marketable skills. I had a midi class in junior college in the 80s, but not much of that tech applies these days once you get past a midi to usb converter anyway. We've gone with the TD-7 because lugging 4x bass drums and drum stands is a bit much for most performances for a single player.


So to break it down:

Problem == latency

Solution == USB bootable linux (I hope)


My current progress at the moment:

* I have made an ubuntustudio LiveDVD and have gotten my keyboard working with fluidsynth with drum sounds using it. Without having to download anything after booting.

* I have verified that I can boot from a USB flash drive by setting up a memtest bootable install on my stick. All of my computers are at least 5 years old. (stupid economy)

* We have verified that he can get sounds from his TD-7 in linux with fluidsynth. So there shouldn't be any software or hardware road blocks. But he still thinks he can best linux with windows in terms of latency. Insert old dog, new trick analogy.

* I have reconfigured my desktop to use jackd under pulseaudio. But this seems to have created other issues. Like youtube vids now stutter in audio. And not too hideous for midi use I guess, but I wouldn't want to perform with this setup, even if I was a keyboard player.

* I have an 8GB USB thumb drive to sacrifice for this cause.


I'd rather not have pulse or anything other than a minimal base system for fluidsynth and jack. I don't even care for a gui if this can all be scripted to happen at boot. Input welcome. Like how would I pass select 0 1 128 000 to fluidsynth, without having to manually do that after it launches. I suppose I could delve deep and create a custom font with 000 000 (default) as drum sounds. But I'd rather not. The ultimate goal is to hook it all up, plug in the usb stick, power up the laptop and it just works.

Thanks in advance.
User avatar
raboof
Established Member
Posts: 1855
Joined: Tue Apr 08, 2008 11:58 am
Location: Deventer, NL
Has thanked: 50 times
Been thanked: 74 times
Contact:

Re: USB based linux for live performance?

Post by raboof »

Shadow_7 wrote:not too familiar with other distros besides debian and ubuntu. I'm looking for a USB bootable (as in limited write flash drive) version of linux.
I think I'd probably just install Debian on the USB disk and configure it like you would configure a system normally.
Shadow_7
Established Member
Posts: 175
Joined: Tue Jun 08, 2010 3:35 pm

Re: USB based linux for live performance?

Post by Shadow_7 »

My experience with debian hasn't been all joy for audio needs. I generally need to recompile something. Like jack or timidity or alsa with sequencer support. And other quirks. Ubuntu has been a lot less customization out of the box. But is by no means a model of efficiency.
User avatar
raboof
Established Member
Posts: 1855
Joined: Tue Apr 08, 2008 11:58 am
Location: Deventer, NL
Has thanked: 50 times
Been thanked: 74 times
Contact:

Re: USB based linux for live performance?

Post by raboof »

Shadow_7 wrote:My experience with debian hasn't been all joy for audio needs. I generally need to recompile something. Like jack or timidity or alsa with sequencer support. And other quirks. Ubuntu has been a lot less customization out of the box.
I'd be interested if you can remember any specifics - for a big part the multimedia stuff should be fairly well-synchronized between Ubuntu and Debian. Much of the packaging work is done by a team of people consisting of both Debian'ers and Ubuntu'ers (and people who don't pick sides :) ).
User avatar
English Guy
Established Member
Posts: 525
Joined: Wed Oct 17, 2012 7:28 pm
Location: England
Has thanked: 8 times
Been thanked: 7 times

Re: USB based linux for live performance?

Post by English Guy »

I regularly use Ubuntu Studio on a keypen (for indoor use, not live I must add) and it performs quite well. If you use unetbootin to install it to the pendrive it can create a file (casper-rw) that will store your changes, so you can install the software you need if it is not part of the basic package.

If you are using a windows system that does not have a Linux swap partition it is possible to create a swap file & use that, though I have only done this from the command line & never seen a GUI tool to do it.
Shadow_7
Established Member
Posts: 175
Joined: Tue Jun 08, 2010 3:35 pm

Re: USB based linux for live performance?

Post by Shadow_7 »

I haven't really used windows since like 2002.

A few more discoveries with ubuntu. I started jack before XFCE just to see how things differ. Using the 44100 sample rate that matches the soundfonts. And the difference in latency was noticeable. Pulseaudio is definitely not that way to go. Further research shows that pulse only works with 48kHz sample rates (until ubuntu adopts the newer 2.0+ verion anyway). I wasn't really able to track down how pulseaudio launches jackd when you layer them like that. Always -T -ndefault -T -d alsa as the parameters. Which defaults to 48kHz. This adds extra latency since the soundfonts are sampled at 44.1kHz which is normal since that is the sample rate of CDs.

It's been a while since I've installed debian so those quirks might have been addressed already. It's been a while since I've installed ubuntu for that matter. I think this install was 10.04 when it was originally done. Currently at 11.10, and probably should advance to 12.10 now. But a 2GB download didn't really appeal to me in terms of pending updates.

I used this guide to layer jack under pulseaudio.

http://trac.jackaudio.org/wiki/WalkThro ... ulseOnJack

But when running things this way videos via web browser aka flash for youtube and hulu has stuttering audio. The only fix I've managed so far is to move ~/.pulse/default.pa to ~/ and restart pulseaudio. And of course the browser afterwards too.

$ mv ~/.pulse/default.pa ~/
$ pulseaudio --kill
$ pulseaudio --start

And videos that are run via flash in the browser don't stutter on the audio track. Just invert the mv command parameters and restart again to go back to using jack under pulseaudio. Most certainly more headache than it's worth in my opinion.

Other quirks are if you have the pulse audio over jackd setup. And have pulse stopped. If you use alsamixer to change the sample rate of the soundcard to 44100. Pulseaudio doesn't start with that connection refused error. Change the sample rate back to 48000 and pulse starts fine. Maybe just an Ice1712 quirk with multi and samplerates. If pulse is running you can't change the first sample rate with alsamixer, stuck at 48000 of course.
User avatar
English Guy
Established Member
Posts: 525
Joined: Wed Oct 17, 2012 7:28 pm
Location: England
Has thanked: 8 times
Been thanked: 7 times

Re: USB based linux for live performance?

Post by English Guy »

If you dislike pulse audio, I think you will find AVLinux makes a point of not having it.
Shadow_7
Established Member
Posts: 175
Joined: Tue Jun 08, 2010 3:35 pm

Re: USB based linux for live performance?

Post by Shadow_7 »

Here's what I've done so far. Following this guide I installed a debian linux base system on a hard drive partition from an already running debian install. And by using the specified file located on a burned CDROM image that I mounted during the process.

http://www.debian.org/releases/stable/i ... 03.html.en

This guide is incomplete from an admin perspective. There are extra steps to have a useable system. Like assigning a password to root(passwd), creating a user(useradd), creating the users home directory(mkdir), assigning a password for the user(passwd), setting a shell for that user(chsh), and adding the group permissions (/etc/group) to do this audio thing from that user. After which I was able to boot into my fresh install of a minimal debian system and install and configure extra packages the normal way. The chroot environment in the above guide is limited as in lacks the /dev/pty stuffs that are needed to run some of the installed software from the chroot environment. It also omits steps needed to install makedev, to run MAKEDEV, which you can't use anyway as udev is in play, so a little moot.

Version 6.0.6 of debian at the moment. Installing fluidsynth with apt-get installed way more than I wanted to dependancy wise. And does not grab lash as a dependancy even though this version is lash specific. About 30 seconds of complaints from fluidsynth when you start it, until you install lash. I also installed icewm, xorg, iceape (firefox?). And I was able to run jackd natively at 44.1kHz. And fluidsynth tied into that. With aconnect to bind the usb midi keyboard to fluidsynth. Success in terms of almost instantaneous latency after some effort. Normally I use select 0 1 128 000 for drum sounds, but this didn't work at first until I did select 10 1 128 000. After which select 0 1 128 000 works to swap the sound font in use. I'm still unsure what that first number is (channel?) for the fluidsynth command line prompt. I always thought it was the device id as shown in settings.

The lash thing is new to me, hopefully it is a solution to a boot and use out of the box configuration. Now to transfer the HDD install to the USB stick and make it bootable. Anyone done this before? Do I treat it like any other HDD. My normal route is the take a tarball of an existing install. Then mkfs a filesystem on the destination, and extract that tarball onto the destination. Do the necessary fstab adjustment and install a bootloader and it works. Does this work for the USB stick too? So many other options it seems with syslinux and unetbootin clogging up my google search hits. I'll likely tweak the install to minimize writes before doing this step. I'm not sure if having a ramdisk and putting a copy of the sf2 into it and then running fluidsynth from the sf2 image in ramdisk would improve things latecy wise. But I guess I'll find out.
User avatar
English Guy
Established Member
Posts: 525
Joined: Wed Oct 17, 2012 7:28 pm
Location: England
Has thanked: 8 times
Been thanked: 7 times

Re: USB based linux for live performance?

Post by English Guy »

There is a piece of software called remastersys that is for turning a running system in to a live CD. I have successfully used it on Bodhi, which is Debian/Ubuntu based.
http://www.geekconnection.org/remastersys/
Shadow_7
Established Member
Posts: 175
Joined: Tue Jun 08, 2010 3:35 pm

Re: USB based linux for live performance?

Post by Shadow_7 »

After much over-thinking the solution was relatively simple to have a bootable USB stick.

Partition the stick, create the filesystem, untar the files of the existing 2nd install, mod the fstab (correctly). Then boot that install by modifying your desktops grub. And once up and running in the usb distro, run grub-install against the usb stick and modify accordingly. One caveat is to use the UUID version of the device in the grub config and fstab line(easily discovered by blkid), instead of old school /dev/ names. Sometimes the system boots with the stick as /dev/sdc, sometimes /dev/sdg. And on my desktops' cmos/bios there's actually 2 options to boot usb as HDD or CDROM.

I was really overthinking this as netbootin and syslinux are options, and a majority of the google hits. But those are geared towards booting iso images of linux. I didn't really want to delve into creating one of those (yet). I need the persistance of .bash_history to quickly redo at boot what I've already done. Someday I might get around to scripting those commands or getting up to speed with lash to have it do the needed configurations.

In the meantime, my old laptop doesn't support USB booting, but does have a boot from network option. So I'm currently looking into that in order to boot the USB stick on that laptop. It's HDD is toast, and the optical drive is basically blind and unable to read discs. It's a well used laptop dating back to 2006. The cursors keys are falling off, the fan hasn't worked in years, but it used to be useful to browse game guides while playing the game on another machine. Before it's HDD crashed.

And I guess a bit moot for the drummers purpose at this point. He did manage to find a different audio driver and modify his windows setup in a way to lower significantly the latency. There's still some imo, but his computing machine is better than mine so it's tollerable. In the mid-range of native jack or pulse over jack on my machine (0.5g ram / single 2GHz cpu) in terms of latency. Always nice to have a backup, and still worth pursuing once an untethered option is acquired and power management becomes an issue.
User avatar
English Guy
Established Member
Posts: 525
Joined: Wed Oct 17, 2012 7:28 pm
Location: England
Has thanked: 8 times
Been thanked: 7 times

Re: USB based linux for live performance?

Post by English Guy »

If your laptop boots from a CD you can use super grub boot disk to boot from a pendrive.

I still use version 1

http://www.supergrubdisk.org/
varpa
Established Member
Posts: 509
Joined: Fri Feb 25, 2011 6:40 pm
Been thanked: 13 times

Re: USB based linux for live performance?

Post by varpa »

You might want to look at AVLinux which can be booted from a USB stick. Its already designed for that.
Shadow_7
Established Member
Posts: 175
Joined: Tue Jun 08, 2010 3:35 pm

Re: USB based linux for live performance?

Post by Shadow_7 »

My findings so far. My laptops bios does not support booting from USB.


Work arounds at the moment.


Plop Boot Manager - burned a cdrom image (plpbt.iso) - just worked to boot the usb.

Caveats:
- physically remove the defective drive or the linux boot hangs on trying to probe it.
- grub.cfg must contain the UUID in ALL of the needed places. Update-grub added a couple /dev/ elements which failed to boot.
-- but from plop manager which boots the grub on the stick, you can go "c" for command mode and manually enter what exists on the desktop that booted that stick. With UUID's where needed. Then change your grub.cfg once booted. Or mount it on another machine and do that step.


For booting from a grub rescue disc. "grub-mkrescue"
- you have to insmod the USB drivers manually. "c" from grub menu if it doesn't automatically kick you there by default.
- insmod uhci
- insmod ohci
- insmod usb
- usb
(this lists the device, so progress, if it doesn't, well, that's a problem)
(then enter all the entries from the grub.cfg of the desktop that booted the stick with quirks)
(being careful to replace any /dev/ with the UUID=(and the ID) for me it looks something like the below)
- insmod part_msdos
- insmod ext2
- set root='(hd0,1)'
(partition 2 for my stick, partition 1 is a failed ms-dos syslinux attempt / partition)
- search --no-floppy --fs-uuid --set=root <UUID>
- linux /vmlinuz root=UUID=<UUID>
- initrd /initrd.img
- boot
(where <UUID> is the horridly long ID that is the device)
(and " - " represents the grub prompt, probably should have used grub> instead)


The plpbt.iso burned CD is an obvious less tedious choice.

Granted that the machine in question does not always successfully read an optical disc at boot. But enough attempts and it does eventually. And since this machine doesn't have a working fan, removing the links for flash and java from the /plugin/ path of the web browser is a good idea. If only because I hate web pages that use 80% cpu resources for relatively static information. So anyway, bootable usb linux on a relatively ancient laptop is a success. With a bootable CD to get there from here, if only for booting it. Modern machines should be a lot more plug and play.

EDIT: corrected untyped words in grub launch details.
Shadow_7
Established Member
Posts: 175
Joined: Tue Jun 08, 2010 3:35 pm

Re: USB based linux for live performance?

Post by Shadow_7 »

To shorten my booting USB steps from a default mkfs-rescue CD for grub2.

grub> insmod ohci
grub> insmod usb
grub> insmod part_msdos
grub> insmod ext2

That's all that's needed to access the files (vmlinuz / initrd.img) and read the file system. The uhci module is not what my laptop uses, but it might be what yours uses.

grub> usb
(to verify that it sees the device)

grub> ls
(to list the devices and partitions as known to grub)

In my case the device is known to grub as usb0a. And the linux partiton is (usb0a,msdos2).

grub> set root='(usb0a,msdos2)'
grub> search --no-floppy --fs-uuid --set=root <UUID>
grub> linux (usb0a,msdos2)/vmlinuz root=UUID=<UUID>
grub> initrd (usb0a,msdos2)/initrd.img
grub> boot

Where <UUID> is the overly long unique ID, and UUID is NOT. And it boots. It is possible to goto to the menu that is on the usb stick for grub with:

grub> configfile (usb0a,msdos2)/boot/grub/grub.cfg

But it wont boot from that menu in this manner. It would be nice if it could. To pass kernel parms and not have to manually type them plus the overly long UUID. I'm still working on special entries in that menu to make it work. If it does I should be able to bypass having to type the UUID steps and can just use the configfile route. But I'm not holding my breath, it may be chainloading grub at that point with no mechanism to load the usb modules from the usb stck. Ultimately I'll probably settle for plpbt or make a custom grub rescue disc with the intended menu from the stick.

Just to clarify if my relic of a laptop supported booting from USB, none of the above steps would be necessary. It would just work.
Shadow_7
Established Member
Posts: 175
Joined: Tue Jun 08, 2010 3:35 pm

Re: USB based linux for live performance?

Post by Shadow_7 »

I suppose I should ask. I'm not that up to speed on midi stuff (in linux or otherwise). I'm a trombone player by training. And military MOS career BITD. However short lived. But... Is there a midi middle man of sorts already in place? To bridge between midi device and one or more instances of fluidsynth? For my purposes a roland TD-7 drum machine. Something to say capture the input midi triggered note and send it along... "OR"... tweak it to send along another triggered event / note? At this stage I don't know what "events" are being triggered by the drum synth. And it would be nice if I could tweak it software wise and not have to program the rather aged machine pre-Midi->Usb converter.

At the last rehearsal some strange voltage circumstance occured where the TD-7 was power cycled and the sounds changed. Possibly reverting to defaults? If I could capture and forward those as desired / intended that would be nice(regardless of what events are sent). Perhaps some volume adjustments, or multiple soundfonts to cherry pick the best sound per event for the intention. Versus trusting the GM default soundfont to meet all needs. In my experience just knowing that something "exists" in linux is 95% of the battle. I would rather reroute the events, with a semi-intuitive interface than create a custom soundfont relative to the source input device.
Post Reply