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

User avatar
raboof
Established Member
Posts: 1699
Joined: Tue Apr 08, 2008 11:58 am
Location: Deventer, NL
Contact:

Re: USB based linux for live performance?

Post by raboof »

Shadow_7 wrote:Something to say capture the input midi triggered note and send it along...
For that the 'ALSA' tab of the 'Connections' window of qjackctl should work
"OR"... tweak it to send along another triggered event / note?
Try QMidiRoute from AlsaModularSynth, or, for even more control, (q)mididings.
At this stage I don't know what "events" are being triggered by the drum synth.
kmidimon

User avatar
autostatic
Established Member
Posts: 1728
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Contact:

Re: USB based linux for live performance?

Post by autostatic »

raboof wrote:Try QMidiRoute from AlsaModularSynth, or, for even more control, (q)mididings.
Afaik qmididings doesn't exist. There is livedings but that doesn't allow you to create mididings scripts. mididings is a great tool by the way.

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

Re: USB based linux for live performance?

Post by Shadow_7 »

I found a typo in my grub.cfg on the stick. I was using --set <UUID> and not --set=root <UUID> on the search line. Making the correction now allows me to use the configfile method to boot using the grub config on the stick after booting grub from a cdrom.

grub> insmod ohci
grub> insmod usb
grub> insmod part_msdos
grub> insmod ext2
grub> ls
grub> configfile (usb0a,msdos2)/boot/grub/grub.cfg

And that's a lot easier to remember than a long UUID that I have to type fat finger free twice.

-----

I installed debian on a 2nd stick (SDHC card + reader) and I'm currently working a write up for that to post here. Complete with a few gotchas for doing a 64 bit install (chroot) from a 32 bit install (64 bit machine) that hasn't been updated in a few years. An old debian install that was at least 2 years out of date, if not a few years more than that. It was setup to play java games in a web browser, before java had a 64 bit jre plugin for web browsers. Which probably isn't as ancient as that sounds.

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

Re: USB based linux for live performance?

Post by Shadow_7 »

I guess I'll stop beating around the bush and post what I've got for the install steps so far. Use at your own risk, your devices may use different hardware names and the like. But here's the command by command blow of how I setup my current 32gb PNY stick with debian sid linux. Based in part on the debian guide linked to in earlier posts. Additional notes to follow, these steps only get you a basic bootable usb linux. You can do a lot of extra install stuff before you do any writes to the usb device. Plus a variety of administrative stuff not listed in this post. Like setting up a user account.

##### Prepare to use ar and debootstrap to build our base installation #####

Code: Select all

$ mkdir work
$ mkdir install
$ cd work
$ wget -c http://cdimage.debian.org/debian-cd/6.0.6/i386/iso-cd/debian-6.0.6-i386-netinst.iso
$ su
# mkdir /mnt/loop
# mount -o loop debian-6.0.6-i386-netinst.iso /mnt/loop
# exit
$ cp -v /mnt/loop/pool/main/d/debootstrap/debootstrap-udeb_1.0.26+squeeze1_all.udeb .
$ su
# umount /mnt/loop
# apt-get install binutils debootstrap
# exit
In my case I used the home directory of my current debian based linux to build the installation.

##### Make and prepare our new installation #####

Code: Select all

$ ar -x debootstrap-udeb_1.0.26+squeeze1_all.udeb
$ cd ../install
$ su
# tar -xzvpf ../work/data.tar.gz
# /usr/sbin/debootstrap --arch i386 squeeze /home/user/install http://ftp.us.debian.org/debian
# cp /etc/fstab /home/user/install/etc/
# nano ./etc/apt/sources.list
And I opted to upgrade to sid from squeeze right out the gate.

##### Chroot into our new installation #####

Code: Select all

# mount -t proc none /home/user/install/proc
# mount --rbind /dev /home/user/install/dev
# LANG=C chroot /home/user/install /bin/bash
# apt-get update
# apt-get install binutils debootstrap dselect
# dpkg --clear-avail
# dselect
# apt-get install linux-image-686
# passwd
Don't forget to set the password for root or it might be hard to use your new installation.

(additional administrative things here)

##### Exit the chroot and make a snapshot of this installation #####

Code: Select all

# exit
# umount /home/user/install/dev/pts
# umount /home/user/install/dev
# umount /home/user/install/proc
# tar -cvpf ../work/snapshot_i386_YYYYMMDD.tar ./*
##### Prepare the USB medium to receive this installation #####

Code: Select all

# cat /proc/partitions
# cfdisk /dev/sdg
# partprobe /dev/sdg
# mkfs.ext2 -L pny32gb -U ba55c1ef-0b0e-c0da-5010-5ca1ed121234 /dev/sdg2
# mount /dev/sdg2 /mnt/somelocation
# cd /mnt/somelocation
# tar -xvpf /home/user/work/snapshot_i386_YYYYMMDD.tar
# nano /mnt/somelocation/etc/fstab
# cd /home/user
# umount /mnt/somelocation
The initial cat to identify what your usb device is actually named. If you cat /proc/partitions before you insert it, and after the difference is the new device. (in theory). You may want to do any write / read tests on the new device first to make sure you didn't get a dud.

##### Adjust a bootloader to boot this new bootable installation of linux #####

Code: Select all

# nano /etc/grub/40_custom
# update-grub
In my case I'm using my existing bootloader to boot the usb device first. And I installed grub to the distro, but not the hardware before making the tarball.

##### If all went well we're running the new install #####

Code: Select all

# cat /proc/partitions
# mount
# grub-install --force /dev/sdc
# update-grub
The MBR region of these things seems excessively small. So we have to force it, and I made two partitions, the first one is never used, and just there to allow extra overwrite space. Which may or may not actually be needed. In either case I have to --force it, or it never actually writes to the device. The device name of course changed when it was booted.

##### Boot the USB linux from it's own bootloader #####

Code: Select all

# shutdown -r now
If all went well you'll have a linux install that you can boot from any x86 device that can boot USB (assuming i386 or better). Or boot a cd version of grub to use to boot the usb device. This works for me anyway. Although my current laptop requires the CD to boot the USB stick. My main desktop uses the ESC key to get to the boot usb option. Another desktop uses F10, and yet another uses F12. So not without a few quirks.

If speed and responsiveness is of concern you might want to use a c6 or better flash card and a reader. My 32gb PNY is my newest and highest capacity stick and by far the slowest stick. But it's cute. Running it and web browsing has a lot of delays while the browser cache's content.

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

Re: USB based linux for live performance?

Post by Shadow_7 »

Additional administrative steps. These can be done after you're booted into your USB linux or while in the chroot before making a tarball. Although certain things like configuring X are more easily done after booting the new installation. Unfortunately I don't know of any debian admin tools that walk you through the steps of setting up a new system after you've installed it and booted. In days of old base-config did this task, but not anymore. So configuring timezone, hostname, network, users, and other things are now a manual approach when installing linux this route. Or if you skipped over those steps when you used some other approach.

So here's the basics, by no means comprahensive. And most everything past setting up a user is kind of moot if you never connect to a network and have all the packages you'll ever need to use already installed. NOTE: I'm not a linux admin by trade.


I ran into issues on at least one of my usb efforts where the available package list was horribly out of whack. So this fixed it.

Code: Select all

# dpkg --clear-avail
# dselect
In this case you just need to run the update portion.


##### More packages #####

Code: Select all

# apt-get update
# apt-get dist-upgrade
# apt-get install grub dselect jackd qjackctl
As long as you have a network connection you can apt-get install packages at any time.


##### Setup a USER #####

Code: Select all

# adduser --home /home/someuser --shell /bin/bash someuser
# usermod -G audio,video,games,cdrom someuser
If the home directory of the user wasn't created you need to do that manual. This can happen if you use useradd instead of adduser. As both are valid ways to create new users. If you don't set the shell, dash is the default in debian. One noticeable feature of dash (if you default there) is that tab completion fails.

Code: Select all

# ls -al /home/someuser
# mkdir /home/someuser
# chown someuser:someuser /home/someuser
##### Setup a TIMEZONE #####

Code: Select all

# dpkg-reconfigure tzdata

Current defaults are not to my liking so I created a .bashrc file. This tames java to use less RAM. And keeps commands I run more than once in a row on the command line (cli) out of my .bash_history.

Code: Select all

$ echo 'export HISTCONTROL=ignoredups' >> ~/.bashrc
$ echo 'export JAVA_OPTS="-Xmx128m -Xms128m"' >> ~/.bashrc

##### setup a hostname #####

Code: Select all

# echo "usb" > /etc/hostname
# nano /etc/hosts

Code: Select all

127.0.0.1 usb.doesitmatter.doesitmatter usb localhost
Not exactly an ideal setup. They say that the fqdn should not have the same ip as localhost.


##### /etc/grub/40_custom #####

Code: Select all

menuentry 'Debian Sid i386 - PNY' --class debian --class gnu-linux --class gnu --class os {
	load_video
	insmod gzio
	insmod uhci
	insmod ohci
	insmod usb
	insmod part_msdos
	insmod ext2
###	set root='(hd0,msdos4)'
	search --no-floppy --fs-uuid --set=root ba55c1ef-0b0e-c0da-5010-5ca1ed121234
	echo	'Loading Linux PNY 32GB USB stick...'
	linux	/boot/vmlinuz-3.2.0-4-686-pae root=UUID=ba55c1ef-0b0e-c0da-5010-5ca1ed121234 ro 
	echo	'Loading initial ramdisk ...'
	initrd	/boot/initrd.img-3.2.0-4-686-pae
}
This file will get merged with /boot/grub/grub.cfg when you run update-grub. In my case I used my existing desktop and it's bootloader to initially boot the usb stick.


##### /etc/fstab #####

Code: Select all

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid	0	0
UUID=ba55c1ef-0b0e-c0da-5010-5ca1ed121234 /    ext2 rw,errors=remount-ro,noatime,nodiratime 0 1
tmpfs	/tmp	tmpfs	defaults,noatime,mode=1777	0	0
noatime and nodiratime are there to lower the number of writes to the USB device. They have a limited number of writes, and ext2 appears to be the filesystem of choice because of wear leveling attributes. We don't have a swap space in this setup so be aware than when you run out of RAM, linux just starts killing off applications. So don't go to crazy while running linux from a usb stick. Just watching a youtube video longer than an hour in length can exceed your RAM capacity. If this is your intended way for long term running of linux, you may consider using other devices for high write areas like /var, /tmp, and /home. And as a swap space.

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

Re: USB based linux for live performance?

Post by Shadow_7 »

I seemed to have inherited a laptop from my sister-in-law. Some acquaintence of hers wanted her to wipe the harddrive and toss their old laptop. So I wiped the hard drive and installed linux on that laptop. About the same specs as my old laptop, but it's hardrive still works, and the fan on it works to (unlike my old laptop). The video card is worse, but the cpu is faster.

It's kind of depressing how little (web browser wise) you can do with only 0.5GB of RAM these days. Anything flash / adobe runs almost completely on swap. I wouldn't exactly call that running though, more like waiting. And if it's ads that swap every 30 seconds, an endless cycle of waiting with no results. As in stop the browser, disable flash, and maybe you could get something useful done.


Onto the live performance portion I guess.


The asoundrc file to default to jackd: /home/someuser/.asoundrc

Code: Select all

defaults.pcm.card 2

pcm.!default {
  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
  }
}

ctl.mixer0 {
  type hw
  card 2
}

Starting jackd:

Code: Select all

jackd -R -P60 -p128 -d alsa -d hw:2 -r 44100 -s -m -S

Starting fluidsynth:

Code: Select all

fluidsynth -l -s -C no -R no -a jack -r 44100 -g 1 -j -o audio.periods=2 /usr/share/sounds/sf2/FluidR3_GM.sf2
For some reason I needed the extra options on jackd to get this to gel. Or it tried to start jackd even though one was running. WIth other caveats, like jackd needs dbus, dbus need X11, so much for having a lot of free RAM to play with. AKA system min req is at least 0.5GB of RAM. And you'll need a lightweight window manager if you don't have a lot of RAM. I'm currently using IceWM.


On the plus side, I've found qmidiroute and that does what I wanted with intercepting "unknown" midi events and re-routing them to any channel or note (or type). On the down side if you only want to re-assign one out of a series of notes, you need 3 maps. The one for the note, one for the notes below and one for the notes above. If you don't break it up like that you'll get the redirected note and the original note. On the plus side it looks like you can use events (like notes) to send things like program changes. I haven't yet figured out a way to use aconnect to route the output to fluidsynth, but qjackctl does that portion just fine.

I might have prefered to not use any gui elements to maximize RAM. But since the version of jackd that comes in debian sid seems to require a gui (by requiring dbus, which requires X11), that's sort of shot at the lowest possible level. At least not without dropping back to my programmer roots and compiling stuff.

As far as the hardware currently in play:
- Dell Inspiron 1150 laptop
- M-Audio Keystation 49e
- M-Audio MobilePre

I'll still need additional hardware for the current plan. Either a midi to midi cable to run the Roland drum machine through my 49e, or a midi to USB type cable to make the old(er) drum machine behave like the 49e does. Any tips for getting that stuff would be nice. Craigslist was doable when gas was $2 a gallon, but 80 miles round trip costs more than those type of items these days in gas only. And music stores these days seem less common than toll roads.

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

Re: USB based linux for live performance?

Post by Shadow_7 »

A qmidiroute quirk I guess.

After you save your settings, when you reload those saved settings. Notes seem to default to Offset, even though they may still show as Fixed and were saved as Fixed. So I have to change my notes setting (for the output) from what shows as Fixed to Fixed so it is Fixed and otherwise works as expected (as saved). I should probably file a bug report, as it doesn't seem like that's intended / expected behavior. In my case I setup tabs for each individual sound since I still don't know what will be sent from the drum machine and I may not have a midi keyboard to find the intended notes on location.

With this current setup, I'm basically using 4 applications.
jackd + fluidsynth + qmidiroute + qjackctl

jackd to connect to the soundcard
fluidsynth to act as a software synth which connects to jackd
qmidiroute to micro-manage midi events
qjackctl to connect the midi device to qmidiroute and to connect qmidiroute to fluidsynth

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

Re: USB based linux for live performance?

Post by Shadow_7 »

I'm having decent success using two instances of qmidiroute and two instances of fluidsynth to use two different soundfonts from the same midi keyboard input. Which will be a drum machine come sunday. Caveats include having to manually connect the 2nd instance of fluidsynth to jackd from qjackctl at the audio tab. And launching qmidiroute first so the connection lines between the keyboard and the instances of qmidiroute do not cross other connection lines, but more for cosmetic reasons than functional ones. Be sure to turn off logging (on by default in qmidiroute) once you have your routes setup, the performance benefit of turning that off is noticeable. Most of the reason for going this route is that I like the tom / bass drum sounds of one soundfont, and the snare and cymbal sound of a different soundfont. But I'm not the drummer, so who knows what they'll want.

Any recommendations for drum soundfonts?

For the band in question I need multiple bass drums like a marching band bass line. The accoustic version has four different sized bass drums on angled stands. Which is why we've gone electronic because that's half of a trailer when doing parades on a trailer with acoustic drums. Unfortunately most soundfonts don't seem to have multiple bass drums, but do have multiple toms which ring a bit too long for my tastes. And are probably an octave too high.

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

Re: USB based linux for live performance?

Post by Shadow_7 »

As I discover vkeybd. But it doesn't appear to have any defaults that let it run. But here's what I used to get it up and running.

Code: Select all

# modprobe snd-seq
$ export LANG=C
$ vkeybd --device alsa --channel 0 --drum 9 --octave 8 key /usr/share/vkeybd/vkeybd.list
And then you can save config and just launch with "vkeybd" after that. The default octave is 3 if you want a smaller keyboard. But 8 octaves still fits on this 1024x768 display. Just connect it up like a regular keyboard in qjackctl. Although there's no touch sensitivity so you have to set a volume level (127 is default). And I have to change the octave by lowering key from 24 to 12. This centers the full range of sounds on the virtual keyboard. And this setting does not save with save config. At first glance anyway.

Pablo
Established Member
Posts: 1270
Joined: Thu Apr 17, 2008 9:57 pm

Re: USB based linux for live performance?

Post by Pablo »

For a virtual midi keyboard, see also vmpk.

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

Re: USB based linux for live performance?

Post by Shadow_7 »

I found vmpk this morning. And it does launch out of the box.

-----

I bought an M-Audio Uno for midi to usb from the drum machine. I would have rather have gotten the Edirol, but no one stocks that off the shelf. 0x0763:0x0150 for the device number and it is not accommodated in the midisport-firmware udev rules. And running fxload manually gives a Broken pipe error, something about CPUCS (+/- from memory). It seems to work without the firmware, but the USB LED blinks. And qmidiroute shows some oddities. Unknown event (66) when the 49e is off once. And Unknown event (42) every half a second when on. The events that I'm interested in do get received by qmidiroute, but it'd be nice to not have the extra stuff. If only to know things are as they should be. I did have to add a usbfs entry in /etc/fstab to get that far with fxload. Otherwise I should get an opportunity to take this thing around the block tomorrow. If the drum machine is there, I was out of town last rehearsal.

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

Re: USB based linux for live performance?

Post by Shadow_7 »

We tried it on the TD7, but the midi events coming out of the controller for it had a significant delay. In proximity of a half a second. Cpu usage on the laptop was < 5%. And the delay was between the trigger and when qmidiroute showed an event had happened. So back to the controller doing the leg work. Since it would have taken way to long to reprogram the unit. Perhaps some other time.

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

Re: USB based linux for live performance?

Post by Shadow_7 »

The M-Audio Uno also has a blinking usb light in windows vista 32 bit (home basic) as well. I guess that's just what it does. And I still hate windows, days of updates later, and still the same horrid OS. I was hoping for an ihx file like those loaded by fxload and udev rules for the other midi devices. The whole point of even booting to windows in the first place. Otherwise the .inf for windows seems to suggest that the ma_cmidi files are for the UNO (0x0150 model) as far as win drivers go. But I completely lack any windows midi software to test it's functionality in windows with windows drivers. But at least I have a few more google search terms.

I guess I could just daisy chain multiple qmidiroute instances to filter off the unknown events from the active log and just pass along the key events in linux. If it's even viable to use this for live performance with latency issues and other quirks. Dreaming of future days when things like Raspberry Pi has better specs and could do most of this. ARMv8+ with 1GB+ of RAM for < $50? Just an ARMv6 with 0.5GB of RAM in it's current form.

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

Re: USB based linux for live performance?

Post by Shadow_7 »

An update I suppose. The new netinst image comes with an .tar.xz file so the tar extract is different. So use -xJvpf as the flags. Also 7.1.0 is code named wheezy, so that's different from the previously mentioned stuff.

User avatar
autostatic
Established Member
Posts: 1728
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Contact:

Re: USB based linux for live performance?

Post by autostatic »

Shadow_7 wrote:ARMv8+ with 1GB+ of RAM for < $50?
If you're OK with ARMv7 then you might want to check out an Android TV stick like the MK808. I've been hacking my way on these devices lately to see if I can do something useful with them with respect to Linux audio. I've gotten quite far and am close to a usable set-up. I've also acquired a BeagleBone Black recently for the same purpose.

Post Reply