Using MIDI generation one

Introduction

If there is an external MIDI keyboard and the soundcard does not have a MIDI synthesizer to convert MIDI requests (e.g. “Start playing a B flat using a piano sound moderately loudly”) into sounds, then a ‘soft’ MIDI synthesizer is required. Timidity is one such soft-synth; fluidsynth is another.
Once the ability to service incoming MIDI requests has been added to the system then it is possible to allow human beings to easily issue such requests with a MIDI keyboard.
Using a sequencer applications facilitates changing the instrument, recording sequences, editing them, etc. Rosegarden is one such sequencer.

Procedure

  1. Run the following command:
    apt-get -y install timidity freepats fluidsynth \
                       fluid-soundfont-gm rosegarden \
                       lilypond playmidi pmidi

    (Rosegarden will complain if lilypond is not installed. playmidi is only to be installed because it contains example .mid files which can be used to test timidity. pmidi is only installed because it can read a .mid file and send MIDI events to a MIDI synthesizer, such as the Timidity soft-synth.)

Testing

  1. Connect the MIDI keyboard; on my MIDI keyboard it is the ‘MIDI in’ fork of the MIDI cable which must be connected to it!
  2. To test Timidity, follow the following sub-procedure:
    1. Verify that timidity can communicate with the ALSA hardware and can read the just-made changes to its config file by running:
      timidity -B2,8 -Os -EFreverb=0 /usr/share/doc/playmidi/examples/jazz.mid.gz
    2. Later, to run Timidity in ALSA server mode, use the following command:
      timidity -iA -B2,8 -Os -EFreverb=0 &
  3. To test Fluidsynth, follow the following sub-procedure:
    1. Download SF2 files
    2. If your downloads come in zipped sfark format, then download sfarkxtc from here.
    3. Run:
      fluidsynth -a alsa <soundfont-path>
  4. Use the following commands to verify that the soft synth provided by Timidity server or fluidsynth and the MIDI keyboard are both seen by the OS, as in this example:
    user$ pmidi -l
    Port Client name Port name
    14:0 Midi Through Midi Through Port-0
    20:0 E-MU XMidi1X1 E-MU XMidi1X1 MIDI 1
    128:0 FLUID Synth (2723) Synth input port (2723:0)
    user$
  5. Use the following commands to plumb the MIDI keyboard directly to the MIDI soft-synth:
    user$ aconnect <keyboard-MIDI-port> <softsynth-MIDI-port>
    which, in the above example would be:
    user$ aconnect 20:0 128:0
  6. Play the keyboard! Piano sounds should be heard.
  7. Unplumb the just made connection with the command:
    user$ aconnect -x
  8. Run the command:
    user$ rosegarden &
  9. Configure Rosegarden as follows:
    1. From the ‘Studio‘ menu, select ‘Manage MIDI devices‘. In the ‘Play devices’ section of the window, delete unconnected devices.
    2. If using Timidity, which provides many different instruments, then from the same screen, select ‘General MIDI device‘, click on ‘Import‘ and then select the instrument definition table appropriate to the patch set in use by Timidity (for me this meant selecting GM.rgd) and at the ‘Import from Device …’ window, click ‘OK‘.
    3. In the ‘Record devices’ section of the same window, delete unconnected devices and then mark the remaining device as the ‘Current device‘.
    4. Close the ‘Manage MIDI Devices’ window by clicking ‘Close‘.
    5. From the ‘Tracks‘ menu, select ‘Set Instrument‘, then select ‘General MIDI Synth‘ and then select ‘General MIDI Synth #1‘.
    6. Note that these settings are not saveable (either from ‘Settings’, ‘Save settings’ or when songs are saved).
  10. Play they keyoard! Piano sounds should be heard.
  11. In the ‘Instrument Parameters’ section of the window, on the left, click the ‘Program‘ checkbox and verify that other instruments may be selected from the pull-down list and that the correct sounds are generated.

See also