recommended setup for recording piano over midi-to-usb

You're new to the LinuxSampler world? You don't know where to start and nothing works? Here's the place to ask for help.
Post Reply
gertjan
Newbie
Posts: 4
Joined: Sun Aug 14, 2011 2:41 pm

recommended setup for recording piano over midi-to-usb

Post by gertjan » Sun Aug 14, 2011 3:39 pm

Hi all,

I have only recently discovered the linuxsampler project and I am very interested to start working with it. What I hope to achieve is to connect my electric piano through midi-to-usb, and use linuxsampler for both direct playback and recording using (intitially, at least) the Maestro Concert Grand sound bank. If hope I am right to assume that linuxsampler is the proper tool for that job.

I have not before tried to connect my midi-to-usb cable in linux and I lack the most basic understanding of how things are supposed to function. I have no experience with jackd, and one of the things I cannot answer for myself is if it is a required component for the straightforward (right?) task I have in mind. I have made an initial attempt, compiling libgig, gigtools, linuxsampler (with only alsa support) and jsampler, plugging in the cable and hoping for the best. That approach, unsurprisingly, failed to work (though I did see a connection between my midi cable and linuxsampler in qjackctl at some point...)

Not knowing what a proper setup looks like I decided not to search in the dark for too long but to turn here for advice. What I would like to know are which components are required for my purpose (jackd? rosegarden?) and, preferably, what practical steps to take to verify the setup. I haven't been able to find a good guide online, nor any relevant post on this forum, so any pointers to what I might have missed would be very helpful.

Thanks in advance!

Gertjan

PS The link to the Maestro Concert Grand sound bank under Free Sample Libraries appears to be broken; I found my copy at http://sonimusicae.free.fr/matshelgesso ... ro-en.html.

Alex
Moderator
Posts: 316
Joined: Wed Jan 23, 2008 9:08 pm

Re: recommended setup for recording piano over midi-to-usb

Post by Alex » Sun Aug 14, 2011 6:56 pm

Gertjan,

here's a link to a bit of a linuxsampler walkthrough that may help a bit.

https://github.com/ccherrett/oom/wiki/Linuxsampler


The basics are as follows:

If you compile LS as an ALSA and JACK midi port capable sampler, then your hardware usb midi keyboard is likely to show up as an ALSA device, and you'll be able to connect it directly (in qjackctl) to LS ALSA midi ports.

I suggest here that you recompile LS with both ALSA and JACK audio and midi ports, and quite possibly save yourself a bit of hassle, and you can run LS either using ALSA or jack audio, which means you have the option to run jack, or not.

To give you a rough picture, ALSA is basically concerned with your hardware devices directly. You can run LS at this level directly, but will have to do so with all alsa audio and midi ports, and that requires you to have your "devices", like for example your midi keyboard, mapped and connected in a certain way. For ALSA audio, you're directly concerned with running LS directly "connected" to your soundcard, via your ALSA module. I assume from what you've written, that you can at least produce sound in the computer.

JACK is a software server that sits in userspace, and directs "traffic" in and out of your ALSA "driver", or module. When jack is running, it "takes control" of the alsa devices for itself, and from there you can pretty well attach any jack capable app, to any other jack capable app, by using a patchbay, like Qjackctl.

To use an analogy, JACK is a bit like a mushroom.
The "roots" are ALSA, and the "umbrella" is the jack server sitting on top, which is in userspace. (your access as a normal user.) The umbrella is yours, and you can make as big or small as you want it to be, with as many or few ports as you want, depending on the capabilities of your hardware.

...................................................

If you have your audio and midi setup ok so far, then i suggest you check out the link above, or go through the documentation in www.linuxsampler.org. The link directs you to the linuxsampler page of the Openoctavemidi LS page of the quick start manual, in which i've had a stab at trying to make using LS with something like OOM (www.openoctave.org) as simple as it can be in linux.

If that page helps, but you, or any LS users, can see where improvements might be made in the LS page text, then i'm all ears for suggestions, or additions to that page. At OOM we intend to document apps we use for the OpenOctaveProject (linux) as simply as possible for what is, we hope, the best first time user experience we can present.

Once we have it fine tuned and up to date, then it can be added to the LS site as a more generic guide to LS usage.

I hope that helps. I'm away for a little while (few days), but i'll check in and see how you got on after that.

Onwards and Upwards,

Alex.

gertjan
Newbie
Posts: 4
Joined: Sun Aug 14, 2011 2:41 pm

Re: recommended setup for recording piano over midi-to-usb

Post by gertjan » Sun Aug 14, 2011 7:21 pm

Thanks Alex that's the sort of information I had hoped for! I will start working through it and report back here shortly.

gertjan
Newbie
Posts: 4
Joined: Sun Aug 14, 2011 2:41 pm

Re: recommended setup for recording piano over midi-to-usb

Post by gertjan » Thu Aug 18, 2011 12:51 am

I just gave this beast another stab and finally got it to move!

Yesterday I had already made some progress with Fantasia, when I managed to load in the Maestro Concert Grand and click on the on screen piano to produce a sound - a small victory. But to get anything out of the real piano was just not happening. Until just now it occurred to me to try swapping the input/output MIDI connectors, which somehow made a world of difference. I did use them before, long ago, but I did not remember that I had to connect input to output.. :-/

So now I am able to play the Maestro and it sounds phenomenal. Very, very happy.

I will document my steps here a little bit for the benefit of people reaching this forum like me before, not being able to get the thing to operate. Of course many of my observations are dependent on my specific hardware and installation, but I guess it's anything to go by. For reference, I'm running Ubuntu 11.04 with the 2.6.38-10-generic kernel, with all linuxsampler components built from a recent subversion checkout (rev 2233).

First: the cable. When I plug in the MIDI cable I notice the line "usbcore: registered new interface driver snd-usb-audio" in dmesg, and two new devices showing up in /dev/snd: controlC1 and midiC1D0. This was the case even when the cable was connected improperly. However, when I checked for response to key presses with "cat /dev/snd/midiC1D0", nothing showed up. In contrast, connected properly, the block device is seen to produce a steady stream of bytes, with additional ones showing up on key press. For me this was a good way to check if the hardware bit was functioning properly.

Next the software. I switched from JS_Classic to Fantasia following Alex's very helpful walkthrough, with linuxsampler running in a terminal. Then 1) under MIDI Devices, I click the power on button, and "create" with all settings left at default (ALSA), and 2) under Audio Devices, again, the power button and "create". Then 3) in the middle section, the power button and "Load instrument" to select the Maestro gig file that I downloaded before, leaving the instrument index at 0-Maestro Concert Grand. At that point the on screen piano lights up, and clicking it generates the Maestro sound. The order of things seems to be very important: if I start with loading the gig file Fantasia warns of "Assigning instrument: No audio output device connected to sampler channel". Creating a MIDI and Audio device after that doesn't help, no instrument will be loaded until resetting the program and executing the steps in proper order..

The real piano does not yet work at this point; for this the correct ALSA_SEQ needs to be checked in the created MIDI device. For me it is 20:0, although I could also simply tick all the boxes (I don't know the downside to that but for initial testing it should be good to know that it works). The correct number can be looked up in qjackctl where under Connect, and then the ALSA tab, my device shows up as "20:ESI MIDI Mate", the 20 corresponding with the ALSA_SEQ. With that box ticked, a piano key press has the same result as clicking on the virtual keyboard: highlighting the button and playing the sound.

Exporting this configuration from Fantasia resulted in the following LSCP script:

Code: Select all

RESET
SET VOLUME 0.35
CREATE MIDI_INPUT_DEVICE ALSA NAME='LinuxSampler'
SET MIDI_INPUT_PORT_PARAMETER 0 0 NAME='Port 0'
SET MIDI_INPUT_PORT_PARAMETER 0 0 ALSA_SEQ_BINDINGS='20:0'
CREATE AUDIO_OUTPUT_DEVICE ALSA ACTIVE=true CHANNELS=2 SAMPLERATE=44100 CARD='0,0' FRAGMENTS=2 FRAGMENTSIZE=128
SET AUDIO_OUTPUT_CHANNEL_PARAMETER 0 0 NAME='Channel 0'
SET AUDIO_OUTPUT_CHANNEL_PARAMETER 0 1 NAME='Channel 1'
REMOVE MIDI_INSTRUMENT_MAP ALL
ADD CHANNEL
SET CHANNEL MIDI_INPUT_DEVICE 0 0
SET CHANNEL MIDI_INPUT_PORT 0 0
SET CHANNEL MIDI_INPUT_CHANNEL 0 0
LOAD ENGINE GIG 0
SET CHANNEL VOLUME 0 1.0
SET CHANNEL MIDI_INSTRUMENT_MAP 0 NONE
SET CHANNEL AUDIO_OUTPUT_DEVICE 0 0
LOAD INSTRUMENT NON_MODAL '/home/gertjan/Downloads/maestro_concert_grand_v2.gig' 0 0
I did try the Jack route, too, but that was before I realized that the MIDI cable was not properly connected. So I managed to produce sound but no input. Now that the cable issue is fixed I assume that that part will also work, but for now I see no reason to go back there with ALSA working, which seems just fine for my purpose.

The thing I have not figured out yet is the preemp/realtime issue that I read about in the linuxsampler docs. I don't know if any of that is active in the stock Ubuntu kernel. When I run linuxsampler as normal user I get the "can't mlockall() memory" warning and occasional clicking noises; as root I get no warnings and no clicks (so far), just a lot of "stream not available in time!" messages. Now I must note that I am doing all this on a tiny netbook and I am already more than a bit surprised that it works as well as it does. Still, I wonder if there is a way around running this as root.

OK well I hope that will be of some use to anyone. I'm off to figure out how to do recordings now! :D

gertjan
Newbie
Posts: 4
Joined: Sun Aug 14, 2011 2:41 pm

Re: recommended setup for recording piano over midi-to-usb

Post by gertjan » Sat Aug 20, 2011 10:43 am

Some more findings and experiences. I hope that people can comment on some of the questions that I raise, because I haven't got it all figured out yet. But to some extent I have achieved my goals.

First to continue on my previous post, the mlockall issue was easily solved by adding myself to the audio group, which activated the settings that were already put in place by jackd in /etc/security/limits.d/audio.conf. So that one affected both jackd and linuxsampler and performance is satisfactory.

However, experimenting a bit more with jackd I noticed a lag that is just long enough to be annoying, that I don't notice with ALSA. I don't know if that is fixable (faster computer? kernel patches?) but actually for simple recordings ALSA in combination with arecordmidi works for me. Sound is a tiny bit clicky still sometimes but I'm assuming that does not affect the MIDI recording, and it's more than good enough not to be distracted by it playing.

Of course, for post processing I would like to have maximum quality. This does not need to be realtime and ideally I would just tell linuxsampler to convert the MIDI file to WAV, taking all the time and effort it requires. I have not been able to find something like that though. Instead the only option that I see is to play and record in real time, and hope that the computer won't hickup. For this I use jack now, because clearly the lag doesn't matter here and the buffering does result in a crip sound. So far I managed this with both Open Octave and Rosegarden, using qjackctl to connect under ALSA the sequencer's MIDI output to Midi Through, then under MIDI system:midi_capture_1 to LinuxSampler:midi_in_0, and under Audio LinuxSampler:0 and :1 to the sequencer's recording input. Does that sound like the proper way of doing things? Is it possible to make a direct MIDI link to linuxsampler without going through ALSA's Midi Through?

On the topic of sequencers, what I am mainly looking for right now is a tool that allows me to break up recordings and rearrange them, using the bits that I like (and where I don't make mistakes - I'm not a very solid player) to get a bit closer to what I actually intended. Obviously I prefer to do that in MIDI space to not have to worry about reverb. What would be a good tool for this? Maybe it's a learning curve, but in Open Octave, Rosegarden, and Muse, it didn't seem like a very intuitive operation. A fourth, seq24, I didn't manage to operate because it refused to open the MIDI recording and didn't show up in qjackctl. Are there any tools that I missed that might be good for my sort of cutting and paste?

To maximize chances, here is a quick summary of my main questions:
  • Is it possible to convert MIDI files to WAV using linuxsampler not in realtime, as a post processing step?
  • Is there a way to connect a sequencer to linuxsampler directly, without going through ALSA?
  • What is the recommended sequencer for rearranging and piecing together bits of different recordings?
Curious for answers!

ccherrett
Advanced User
Posts: 162
Joined: Wed Jan 23, 2008 11:24 pm
Contact:

Re: recommended setup for recording piano over midi-to-usb

Post by ccherrett » Sun Oct 02, 2011 6:38 am

gertjan wrote:What is the recommended sequencer for rearranging and piecing together bits of different recordings?
Open Octave Midi of course :)

http://www.openoctave.org
Christopher Cherrett
Founder of The Open Octave Project
http://www.openoctave.org

Post Reply