Showing posts with label Ubuntu Studio. Show all posts
Showing posts with label Ubuntu Studio. Show all posts

Wednesday, 18 September 2013

Music production with Linux (part I). Routing sound with Pulseaudio & JACK

I have decided to document some of the stuff that one needs to know in order to make music with Linux and the idea is to write a number of posts covering different aspects of music creation.

The platform I'll be using throughout these posts is Ubuntu Studio 13.04 (64 bits), and first of all I wanted to write here the settings to properly and easily route all the sound generated in the computer.

Many standard applications use Pulseaudio, and only the more musically oriented ones (and not all) use JACK (JACK Audio Connection Kit), so it is interesting to know how to mix all of them together, so let's see some examples:

* Route pulseaudio stuff to JACK, so that we can, for example, listen to YouTube videos while making music with JACK-aware applications.

In UbuntuStudio, JACK Sink and JACK Source module are already installed, so the whole thing is very simple. We can start the JACK server with QJackCtl, and we will see that by default a connection from PulseAudio JACK Sink to system is already done, so JACK will route the audio of any application that goes to PulseAudio JACK Sink to the system for playback.


So now we just have to make sure that PulseAudio application will send their audio to the JACK Sink and all should be set. We do this with pavucontrol (PulseAudio Volume Control), and just select PulseAudio JACK Sink as the fallback output device.



With that in place, we both PulseAudio and JACK applications can live together happily.






 * Routing audio input, for example to record a Skype call

In order to record a Skype call we also need to change the fallback input device in pavucontrol to be PulseAudio JACK Source. With the system -> PulseAudio JACK Source connection in QJackCtl, the microphone data will be sent to JACK Source, and after setting JACK Source as the fallback input device, Skype will get that as the input for the Microphone. At the same time we can record the whole conversation for example with Audacity by also connecting JACK Sink -> JACK Source (JACK Sink will give us the audio coming from skype, otherwise we would only record what is coming from our microphone). As an example:




When this is correctly set, we can add all sorts of extra routing to our audio. For example, in the previous example with Skype, perhaps we would like to add some filters to our voice? We only need to change the routing in QJackCtl, so we do not send the system directly to JACK Source, but we route it through some other module. In the following example, I route it through the application jack_rack in order to apply some basic distortion to it.



I think you get the idea by now...

By the way, in order to get the previous screencasts, I just used Kazam, and again selecting JACK Sink and JACK Source as the devices to record from, as can be seen below:



Tuesday, 8 January 2013

Creating a MIDI part for duet practice

I wanted to get a decent-ish silicon partner to play a guitar duet, so I ended up with the following steps:

1.- Enter the basic music score

The first step is to get the music score for the second voice in the computer. I could either enter the "perfect" score and then tweak for some rhythmic/melodic changes or the other way around. I'm not a keyobard player, so the second option is out for me, though this is easy with, for example, MusE, where I can get a "live" MIDI stuff recorded, and then I could fix errors. In my case, better to start with a "perfect" score and then try to add some rhythmic/melodic changes.

So, to get the score in MIDI format I found that a pretty fast option is to use Denemo (to get the MIDI keyboard working, you probably have to follow the steps in http://www.denemo.org/Using+a+Midi+Keyboard). For a first version of the MIDI file I will need only the JACK server and Denemo. Denemo launches its own FluidSynth, so we don't need another one. The only thing we need is to connect the output of the LPK25 to that FluidSynth instance, as in:


With this in place, entering the score is a piece of cake. We do in in two steps: first we enter the rhythm, by using the PC keyboard: to enter notes of different durations we just press the numbers from 0-7, and to enter rests of the corresponding durations Alt+[0-7]. With this, we have a score with the same note, but with the right durations, something like:


Once that is done, we can move to the beginning of the score, and with the help of the MIDI keyboard enter the actual notes. You don't need to enter them accurately in time, just enter them as you can, and Denemo will place them consecutively to match the previously entered rhythm pattern. At the end, we get something like:


In order to better control the duration (and later on the volume) for the bass and the melody lines, I prefer to enter them as separate MIDI tracks. Otherwise (or to enter chords), you can enter various notes by pressing the Alt key in the PC keyboard.

My final alpha-score looks now like:



In order to add some dynamics, I export it as a MIDI file. Denemo has been nice to use, but we don't need it anymore. Now we open Qsynth and Rosegardend, connect them appropriately, import the MIDI file, and now we have a basic version of the duo part that we can tweak with Rosegarden. 

2.- Add some dynamics in Rosegarden

Getting a polished MIDI file is quite a lot of work, but as a minimum we should be able to make some tempo changes, and some crescendos, diminuendos, etc. All of this can be done with Rosegarden.

First of all, we transpose it 12 semitones down, to get to the real frequency of the guitar. Then each track can have different volume levels, and we usually add some reverb:



Then, from the Notation Editor window, we can add crescendos and diminuendos, and by looking at the velocity editor below, we can also stress and silence individual notes at will:



And by using tempo changes, we can use different tempos, tempos that ramp up gradually to the next tempo, sudden tempo changes, etc., in order to make it sound more musical:



Now, for practice, I would like to take this music and slow it down, and slowly get to the final playing speed. If you only have on tempo in the whole composition, then that is not a problem as you can just change the tempo to apply to the whole piece and that's it. But if you made several tempo changes, then we need some other way. Not very elegant, but you can use the Segment-> Stretch or Squash option. First, start with a very low tempo, one that would be OK for practice, then when the piece is finished, you can use Stretch or Squash applied to all the tracks at the same time, so you can make it play faster than the original (I think that you cannot make it slower than the original time of the composition, hence the advice to set the initial tempo at practice speed. Probably you can get around this by adding empty extra bars at the beginning, so Rosegarden will have room to stretch the notes, but I haven't tried this).



As I said, this solution is not very elegant, since after applying it, then you will see that the tempo has not changed, but all the notes have been squashed together to occupy a smaller number of bars. Now, if you try to use the Metronome or see the score in the Notation Editor you will not like it, but if you work only with the slow tempo until you are satisfied with the result, and then just use the squashing option to play faster as your skill progresses, then this should be enough. But I'll be in the lookout for a better way to do this.

So that's it. With this in place, I can now play together with Rosegarden, and when I'm ready I can route it to Ardour (for example), and mix it with my own guitar input to get a final silicon-human duet.

Friday, 7 January 2011

AKAI LPK25 MIDI Keyboard

The three kings were good (and very musical) to me this year. One of the things that they brought me was a small MIDI keyboard (AKAI LPK25). This is a very small keyboard, but very convenient for quick note entry (the computer keyboard feels very awkward for this).



Quickly after unwrapping it I set it to try it in my laptop, which has Ubuntu Studio 10.04 (64 bits) installed. For me, the most important feature is just to be able to quickly "type" a music score into a music notation software, so I decided to try with MuseScore. The section MIDI keyboard in the MuseScore documentation looked like I would have no problems, but though the keyboard was recognized and note entry was possible in a contrived way, it was not as expected. The blame was on the version of MuseScore, which in this version of Ubuntu Studio was 0.9.6 (revision: 2613). Luckily, Toby Smithe maintains a PPA with a more recent and stable version of MuseScore. Following the instructions in the PPA page and upgrading (via Synaptic the packages musescore-soundfont-gm, musescore and musescore-common), brings MuseScore up to verion 0.9.6.2 (revision: 3400), and with it note entry with my LPK25 is as advertised in the documentation. Now it is time to do some music with it...

Thursday, 19 November 2009

Turning my netbook into a music partner...

Recently I bought an Acer AS1810T netbook, and I have decided to tune it so that it can become a music partner (artificial accompaniments for when no human partner is around :-)). I just started toying with Ubuntu Studio, but some things didn't quite work. I will persevere and will post here about my progress...

...

and the whole thing was a lot easier than I thought. Basically I went first for a Ubuntu 9.10 (x86_64) install. Almost everything worked out-of-the-box (sound, wifi, webcam...). And after that I just consulted this guide, which just involves downloading loads of stuff, adding myself to the audio group and modifying the file limits.conf

Then, I installed Rosegarden and then I changed a line in the file /etc/default/grub (and then run update-grub as root):
GRUB_HIDDEN_TIMEOUT=0 becomes # GRUB_HIDDEN_TIMEOUT=0 (so that I have the option of selecting the Real Time kernel, otherwise it goes into normal kernel and Rosegarden and friends will not work OK).

Then configure QSynth to include the soundfonts available at /usr/share/sounds/sf2

And at last I run Jack, QSynth, and Rosegarden, and I can get to play beatifully (and with no Xruns) a basic MIDI file. Good stuff....

(By the way, I also get GNU Solfege, a great aid in training my ear for the quickly approaching music exams...)