View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Peter Billam > MIDI-ALSA-1.20 > midiecho


Annotate this POD

View/Report Bugs
Source   Latest Release: MIDI-ALSA-1.22


midiecho - Simulates tape-delay echo, on MIDI files or on real-time MIDI


 # on midi-files (e.g. *.mid ) :
 midiecho -c 3 fn            # echo will be added to midi channel 3
 midiecho -c 3 -d 450,450,450 fn      # three echoes at 450 mS gaps
 midiecho -c 3 -d 450,450 -s 30 fn  # each echo is (MIDI) 30 softer
 midiecho -c 2 -d 450 -e 5 -s 30 fn # the echo appears on channel 5
 midiecho -c 3 -d 40 -e 4 -w 10 -s 0    # Automatic-Double-Tracking
 midiecho filename          #  defaults: midiecho -c 0 -d 300 -s 30
 muscript -midi f.txt | midiecho -c 1 -d 300 -s 25 -e 2 >f.mid

 # on real-time (raw) midi :
 ~> xterm -g 80x16+1+1 -exec 'midiecho -i 32 -d 22 -c 3 -e 4' &
 ~> midiecho -i 32:0 -o 128:0 -c 3 -d 450,400 -e 4,5
 ALSA client 129                midiecho pid=2157
 Input port 129:0 is connected from 32:0
 Ouput port 129:1 is connected to 128:0
 Echo is being applied to input channel 3
 Delay 450 ms, to Channel 4, Softer by 25
 Delay 400 ms, to Channel 5, Softer by 25
 Up, n=New echo, q=Quit
 midiecho -c 3 -d 450,400 -e 3,3 -s 25,25


Simulates a tape-delay echo on a particular MIDI-channel by issuing repeated note_on events with diminishing volume. Since version 2.0, the -i and -o options allow midiecho to work on real-time (raw) midi inputs, as well as on midi files.

Midiecho sounds best if the -e or -E option is used, to assign the echoes to different MIDI-channels; this avoids notes being restarted before they have finished. Without -e, midiecho works much better on transient sounds, e.g. banjo, or snare-drum.

If the -e option is not being used, then the echo note is played on the same channel as the original note. If this leaves your synth chopping of lots of notes (when the original note is not finished by the time the echo note starts), then your synth is probably stateless, and you should try invoking midiecho with the -S option.

Since version 2.5, the -E option works like the -e option, except not just the Note-On and Note-Off events are echoed, but also the Control-Change and Pitch-Bend events.

Since version 2.6, the delays are incremental (since the previous delay) not absolute (since the original note); this is a bug-fix, but it was a well-established bug.

Version 3.0 brings major changes, involving some loss of backward-compatibility. Since version 3.0:

Coming Soon: currently, echo can only be applied to one channel. Over the next couple of releases this restriction may be removed. To make this possible, a more compact notation may be introduced to replace the -d, -e, -m, -n, -p and -w options:

 midiecho -c 0 d300e1p0cc73=95cc10=15 d300e2p74cc10=103


-c 3

Echo will be added to midi Channel 3. The channels are numbered from 0...15 If -c is not specified, the default channel is 0. Currently, midiecho can only add echoes to one channel at once; the other channels pass through unaltered.

-d 350,300,250

The echo notes will be Delayed at gaps of 350, 300, and 250 mS, which means at 350, 300 and 250 mS after the previous. If -d is not specified, the default delay is just 300 mS

-e 4,5,4

The Echoes are produced not on the original (-c) channel but on the channels 4 then 5 then 4 again (in this example there are three echoes). This is a really useful option :-)

As one example usage, you might have set up your synth's channel 4 and 5 with the same patch (instrumental sound) as the original channel (e.g. 3), but panned to different places in the stereo image. This creates a very realistic echo-effect.

Another example usage could be to set up the echo-channels with a completely different sound, maybe something atmospheric or ethereal.

Another example usage could be to set up the echo-channels with a different patch, and use a 1ms delay, thus doubling the original channel with a different sound.

If the number of echo-channels (-e) is fewer than the number of delays in the -d list, then the last echo-channel is repeated as necessary.

-n 38,40

Echo will be added only to midi Notes 38 and 40. This option is mainly useful with General-MIDI channel 9, which represents a drumkit, with each note representing a different drum, see

In this -c 9 -n 38,40 example, echoes would only be added to the Acoustic Snare and the Electric Snare sounds.

-p 74,93

The channels specifed by the -e option will be preset to use MIDI-Patches 74 and 93 (in this example).

-w 8

The echo will be changed by the pitch-Wheel up 8 cents (hundredth's of a semitone).

This can be used in conjunction with the -e, -d and -s options to produce the "Automatic-Double-Tracking" effect, e.g. midiecho -c 3 -e 4 -d 40 -w -10 -s 0

which assumes that the original channel 3 is panned over to one extreme, and the echo-channel 4 is set up with the same patch but panned over the other way. It then produces an "echo" of the same volume and just 40mS late and just 10 cents lower. Because the two sounds are in different speakers they don't beat with each other, and sound almost like two instruments playing in unison.

With larger parameters, it can be used to produce doubling at a large interval; e.g. -d 10 -w 1200 causes the original voice to be doubled (with a delay of 10ms) at the octave (1200 cents).

-s 35,20

The first delayed note is 35 (MIDI) Softer than the original, and the second is 20 softer still. If the number of softenings (-e) is fewer than the number of delays in the -d list, then the last softening is repeated as necessary. If an echo ends up with zero volume or less, then it is suppressed.

If -s is not specified, by default each echo is 30 softer than the previous.


You'll need to use the -S option if you're not using -e, and if the sythesiser you're going to be using is Stateless. In other words, if the sythesiser does not keep a count of how many note_on's there have been on a given note, and switches the note off if receives even just one note_off command. So if your synth seems to be chopping off lots of notes, you should try invoking midiecho with the -S option.

-i 32:0 or -i ProKeys

This option puts midiecho into raw-midi (or real-time, or midi-on-the-wire) mode, and takes the midi-data from the specified port.

The port is specified as an ALSA-port; you can check out the available ports with the command arecordmidi -l or aconnect -il.

Since Version 3.6, you may supply a comma-separated list of ports, e.g. -i 28:0,32

-o 128:0 or -o TiMidity

This option puts midiecho into raw-midi mode and sets the ouput-port to which the midi output will be sent. You can check out the available ports with the command aplaymidi -l or aconnect -ol. The default ouput-port (if only -i option is present) is the environment variable $ALSA_OUTPUT_PORTS

Since Version 3.6, you may supply a comma-separated list of ports, e.g. -o Roland,128:1


Peter J Billam


Based on the MIDI::Perl CPAN module in midi-file mode, and the MIDI::ALSA CPAN module in real-time mode.

syntax highlighting: