< Back to IRCAM Forum

MIDI handling in v1.0-410

Hi everyone,

Really enjoy using Antescofo! I’ve been running some experiments using a Yamaha Disklavier, and noticed that score following is a little more erratic compared to the traditional audio listening system.

I noticed in the release notes the following:
" * version starting from september 2016 (after 0.93 and for the official distributions, from 1.0) rely on the new listening module.
This improved listening machine is more robust with resonant instrument (including piano with pedal), it handles some play mode and has an improved handling of timing information. However, it may be sensitive to silence in some configuration and the handling of midi is less efficient (if this a concern, midi can be handled at the level of the Antescofo program itself, see the how-to section)."

Is there a part of the manual that I can find how to handle midi at the level of Antescofo?

Thank you so much!

Well… section A simple, algorithmic, midi follower is still to be written :frowning:

In the file midi_follower.asco.txt (4.5 KB) there is a simple algorithmic midi follower. The example is monophonic but can be easily extended to handle chords. There are three advantages with the approach developed in this file.


  1. You write your score as usual in antescofo.

You launch a ::midi_follower($XXX) process in your score when you want to take midi events into account, and you specify with $XXX when it should stop (uncomment the TEST part and you will see how it how it works). This allows you to switch between normal tracking and algorithmic midi tracking if needed.

To specify the posiion (in beat) where the midi follower should stop, we use the following trick: the position of a musical event with a label XXX is denoted by $XXX if this variable is not used elsewhere in the score.

The events to follow are received by the variable $pitch_in which receives the midi note from Max via a message setvar.

Take a look at function @make_pitch_tab to understand how we access to the list of the pitches of the musical events in the score.


  1. There is no difference in transport management.

As the midi score is rendered by the antescofo score, you can use antescofo::nextevent during the performance to advance antescofo in case the musician missed a note, use start_from as you like during rehearsals, etc.


  1. This algorithmic midi follower manages a notion of error.

If we receive the the right midi note, we do nextevent. Otherwise, we go into error mode and wait for the next notes. In error mode, we accept all the notes from the current note up to a horizon (here defined as 2 notes ahead). If the note sent is one of these two notes, we advance to the note to the received note and continue in normal mode.

You can easily invent other strategies according to your needs, or deactivate this management.


The score handled here is monophonic (only NOTE as musical events). You can make evolve the algorithmic midi follow-up to treat the CHORDs (for example one can wait 2/3 of the notes of the chord starting from the the first note received from the chord, in a time which corresponds to the half of the duration of the chord). This is not done in the current example.

Handling TRILL or MULTI is more problematic. You can “unfold” such event “by hand” to have only NOTEs and CHORDs.


Hope this helps.
1 Like

Thank you! That really helps - managed to get it working!

Just a note here: We will be adding official support for polyphonic MIDI score following sometime this year. Stay tuned.