Digital Music Composition/Sequencing

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Sequencing is the stringing together of a precisely-timed sequence of commands to the computer to make sound. The commands can be things like “play an audio sample” or “send a note-on command on this MIDI channel to this MIDI port” or “select the instrument for a MIDI channel”. In the old days, there was a clear distinction between sequencers, which knew how to record, edit and play back sequences of MIDI commands, but had no ability to record or play back sound on their own, and sound sources, which knew how to respond to MIDI commands by producing actual sound. These days, most applications can do at least something of both.

For simplicity, we will start with a pair of applications and use them for clearly-separated functions: Qtractor for MIDI sequencing, and Qsynth for making sound.

Qsynth is actually a GUI front-end to the command-line application FluidSynth, which is capable of loading SoundFont files that define the sounds to produce. In particular, we will load the SoundFont file from the fluid-soundfont-gm package, which should be installed as /usr/share/sounds/sf2/FluidR3_GM.sf2. This gives us a high-quality General MIDI instrument set.

These apps will require JACK to be running, as you previously learned how to do.

Notation: Traditional Versus Piano-Roll[edit | edit source]

Western music has evolved its own centuries-old traditional musical notation, and there are composers who prefer to use this. On the other hand, it is a complex thing to write, and while there is computer software like LilyPond that is capable of generating good-quality notation, it is generally considered impractical to have to work at this level during the creative process: for example, well-known composers came up with their own shorthand, unintelligible to anyone except their own skilled copyists, to speed up their ability to write music, which tells you all you need to know about how cumbersome such notation is to write!

A simpler alternative is piano-roll notation, where the notes are laid out as rectangular blocks on a two-dimensional chart, with time on the horizontal axis and pitch on the vertical axis, the width of the blocks denoting their time duration. This is a very easy format, both for humans to interpret, and to create, edit and display in computer software, and it is the notation used by Qtractor and several other music applications.

Qsynth[edit | edit source]

Qsynth main window

Here is what Qsynth looks like when you first launch it. Note the little tab at the bottom that says “Qsynth1”: this is actually the name of an engine, which is what Qsynth calls a running instance of FluidSynth. The same Qsynth GUI can control multiple engines, which show up in JACK with their own audio output and MIDI input ports. All those control knobs (and the buttons on the left) apply to the currently-active engine tab.

Engine setup

When you click the “+” icon next to the first tab (or click the “Setup...” button for an existing engine), you get this setup dialog. Note in particular, in the MIDI setup tab (as shown), you have a choice of MIDI driver: you can choose the item “alsa_seq” from this menu to have the MIDI input port show up under the “ALSA” tab in QjackCtl’s Connections window, or “jack” to put it under the “MIDI” tab. It is probably best to put things under the “MIDI” connections tab wherever possible, and rely on a2jmidid to redirect all the leftover “ALSA” connections to this same tab.

You can delete an engine by right-clicking on the tab name and selecting “Delete” from the menu. Note you can’t delete the first engine.

Loading a SoundFont

But before FluidSynth can make a sound, it needs to load a SoundFont. Here, in the “Soundfonts” tab of the engine setup window, I have clicked the “Open...” button and chosen the previously-mentioned FluidR3 General MIDI SoundFont.

Default channel preset

Next, click the “Channels” button for this engine, and you should see the default preset, with the “Yamaha Grand Piano” sound assigned to MIDI channel 1, and the remaining channels unassigned.

Now if you load up a virtual keyboard app like the previously-described vmpk or JACK Keyboard, and wire up the audio and MIDI connections similarly to how we did previously with ZynAddSubFX, you should be able to play some notes with this default piano sound.

Right-click on any of the channel lines in this window, and a menu will appear with items “Edit...”, “Unset” and “Refresh”. The “Edit...” item brings up a dialog that lets you assign any of the instruments from the SoundFont file to this channel, while “Unset” clears the instrument assignment. (Presumably “Refresh” is to get the display back in sync should the FluidSynth instance have its settings changed through some other channel.) Try choosing another sound on channel 2, and then in your virtual keyboard application, switch between channels 1 and 2, playing some notes each time, and hear the difference.

Qtractor[edit | edit source]

Qtractor at initial launch

When you first launch Qtractor, its main window should look something like this. A project in Qtractor will consist of a number of files:

  • A session file, with extension .qtr. This contains the overall settings for your project. The session will consist of one or more tracks to be played simultaneously (representing different parts in the instrumentation of your piece); information about these tracks will also be saved in the session file.
  • One or more clip files, which can be of two types: Standard MIDI files for MIDI data, or Ogg Vorbis files (by default) for audio data. Each track in the session will reference one or more clips, to be played in sequence. The same clip can be reused more than once at different points in a track (or in different tracks). This allows you to have repeating segments in your music piece, such that any edits to the clip will immediately take effect everywhere that clip is used, without having to make edits in multiple places.

I recommend the first thing you do when starting a new project is create a new directory for it. Then save the .qtr file in this directory, and all associated clip files that you create will be saved along with it. This keeps things tidy and helps avoid confusion between clip files belonging to different projects. So the initial steps for a new project are:

  • Create a project directory.
  • Launch Qtractor, or use its File→New menu item to start a new, initially empty project.
  • Bring up the File→Properties dialog. In here you assign a name to the session and specify the Session Directory, where the clip files get saved; put whatever name you like for the session, and for the latter, choose the directory you previously created for this project. Feel free to make any other adjustments to the session properties you wish before clicking OK.
  • Next, do File→Save As... to create the initial .qtr file. (You can always Save again after making subsequent changes to the project, like adding actual tracks and clips; this initial Save is just to tell Qtractor where to put things.) The file picker that comes up will default to the session directory. Accept this default for the directory, and choose a suitable name for the session file; the default is to use the session name you entered earlier, and it makes sense to stick with this.
  • Now you can go on to add actual tracks and clips to your project.

Loading Instrument Definitions[edit | edit source]

Before actually going on to create any tracks, it is helpful if Qtractor can actually give names to the instrument banks. You do this by selecting the View→Instruments menu item, which brings up a window like at right, but initially empty. Click the “Import...” button, and select the same FluidR3_GM SoundFont file you loaded into Qsynth. This will populate all the lists with information, most of which is only viewable, not clickable (apart from expanding/collapsing groups by clicking “>” symbols); the only things you seem to able to click are the filename entries in the list at the upper right, to reorder or remove them.

JACKing In[edit | edit source]

If you check your JACK connections, you will see that Qtractor has automatically connected its audio to the System output. However, its MIDI port remains unconnected. Qtractor seems to have no support for native JACK MIDI connections, so you will either find it under the “ALSA” tab in QjackCtl’s Connections window, or under the a2j group managed by a2jmidid in the “MIDI” tab.

In the illustration at right, we are relying on a2jmidid to bring Qtractor’s source port into the “MIDI” tab, because we configured Qsynth to use JACK MIDI natively. Another option would be to reconfigure Qsynth to use ALSA MIDI, and then the connection can be made under the “ALSA” tab without the need for a2jmidid. Remember that the choice of MIDI connection type can be set in Qsynth individually for each engine.

Start A Track[edit | edit source]

Now, let’s add a track to our project. Select the Track→Add Track... menu item, and a dialog should appear like this.

Choose MIDI for the Type, and additional relevant options will appear.

In the MIDI/Instrument section, click the popup menu showing “(No instrument)”, and you will see there is also the option “FluidR3_GM”, as a result of your previously loading instrument names from this file. Pick that, and note how the “Bank:” field now shows “FluidR3_GM Bank 0”. This bank contains the main General MIDI instruments, which will be fine.

Now you can choose one of the instruments from this bank for your track.

What I have found is that track instrument selection is not reliable. When you reopen a previously-saved project, the track instrument assignments are not correctly propagated to the synthesizer. Perhaps this is because the MIDI connections have not yet been made, so the track-assignment MIDI commands are in fact being sent, but are being lost. Thus, I find it is better to put explicit MIDI program-change commands in the clips.

Click OK when you are happy with your settings, and Qtractor’s main window should now look something like this.

Note the following two important areas marked in the above window:

  • The track info area, outlined in purple, shows some information about the track, as well as providing R(ecord), M(ute) and S(olo) buttons. You can change the track settings at any time by selecting the Track→Track Properties... menu item, or by double-clicking in this info area.
  • The timeline area, outlined in olive green. This shows the actual clips making up each track, arranged in time.
  • The time ruler, outlined in orange.

The allocation of space between the areas shown in the window is just the default: you can change their relative sizes by dragging on the boundaries between them.

Note the red vertical line that is initially at the left edge of the timeline area, with a little triangle at its top: this is the “play head”, showing the current time position in the piece at which to start playing. You can move this to any time position by control-clicking or shift-clicking the left or middle mouse buttons at an appropriate point in the timeline area or the time ruler.

Create A Clip[edit | edit source]

Now let’s add a clip to your track. Make sure the track is selected, by clicking on it in either the track info or timeline areas. Select the Clip→New... menu item, and a new window will appear.

Notes Area
Values Area
Events Area

The following are the main areas of this window:

  • The area in the blue frame is a virtual keyboard where you can click to hear the sounds of the chosen instrument, regardless of any notes in the clip and without making changes to the clip.
  • The notes area in orange is where you can see the notes making up your clip, and add notes and edit notes by clicking. Note the two-dimensional display; pitch on the vertical axis (corresponding to the keys on the virtual keyboard) and time on the horizontal axis. The menu near the top of the window framed in the same colour lets you choose “Key Press” instead of “Note On” events, but I’m not sure what the effect of this is, so leave it at “Note On”.
  • The values area in purple shows various kinds of MIDI channel values that can be adjusted for each note: the corresponding menu near the top of the window framed in the same colour lets you choose what kind of MIDI events to show and edit in this window: note velocity, pitch bend and so on. You can only view and edit one kind of event at a time.
  • The large area framed in green at the right shows you a low-level display of all the MIDI events in the clip. Here you can make more detailed adjustments of the parameters for each event; for example, you can type in exact numbers for controller parameters, if you want.

Note the vertical scrollbar to the right of the notes area: this lets you choose the range of pitches visible in this area and on the virtual keyboard. Note also the “+” and “-” magnifying-glass icons just below this scrollbar; they let you zoom the pitch range in and out.

Below the values area is a horizontal scrollbar, which controls the range of time in your clip visible in both the notes and values area. Again, this has magnifying-glass icons to let you zoom the time range in and out.

Mouse control: Rolling your mouse wheel scrolls along the pitch axis, while rocking the wheel sideways scrolls along the time axis. Holding down CTRL while rolling the wheel zooms both the pitch and time magnification together.

Your first note!

Click within the notes area: you will hear a note sound, and a rectangular bar appear representing the note you just created. There is also an entry for this note event in the events area at the right.

If you hover the mouse over the interior part of this bar, you will the pointer change to a hand, and some information about the note appear in a bubble. You can click and drag at this point to reposition the note both in pitch and in time.

If you hover the mouse over the left or right edges of the bar, you will see the pointer change to a horizontal double-headed arrow. This allows you to reposition just the start or the end of the note in time, while keeping the other end (and the pitch) the same.

You can click with the left mouse button in an empty area to place another note, or click an existing note to select it. Shift-click to add another note to the selection, or control-click to remove it from the selection. Press DEL to delete all selected notes. You can also drag on a selected note to move it (and any other selected notes) up or down in pitch, or left and right in time. You can undo the last operation with CTRL-Z, or redo it with CTRL-SHIFT-Z. Qtractor provides audible feedback every time you add, click on or move a note, by playing the note.

Play Head And Edit Head[edit | edit source]

The clip window has a time ruler, just like the main Qtractor window. It also shows the same red vertical line, marking the current playback position, at the same time position as the main Qtractor window. The same mouse clicks that set the play head position in one window will work in the other window.

Clicking and dragging in the time ruler without holding down a modifier key sets the edit range; this is marked by blue vertical lines, and is used to mark the limits of the Edit→Select→Range command (CTRL-R).

See also[edit | edit source]