Triggers
It is possible to have 
MMA  sequences to be automatically played
only when certain conditions apply. This is controlled by a
TRIGGER.
TRIGGERs are available for all tracks with the exception of
MELODY and SOLO. TRIGGERs are not saved in
GROOVES.26.1
Once you understand the concept of a TRIGGER, we think you'll
find them very useful. Suppose, for example, that you only want a
chord to be played on a track when the chord changes. First of all you
need to create a chord track:
      
        | Begin Chord-1 Voice Piano1
 Octave 5
 Sequence {1 1 90 * 4} // chords on 1,2,3 and 4
 End
 | 
      
If you used this with the following data:
      
you will get chords sounding on each beat in the bar.
To enable a trigger to only sound when the chord changes:
      
Now, the chord will sound on beats 1 and 3 of the first bar and 1 and
2 of the second.
With that under our belts, let's have a look at all options available:
First, commands which do not require an additional option:
- 
- Auto
- This keyword signals that a trigger should occur
    at any point when a chord is changed. In this case you do
    not need (nor should you have) a BEATS option. Note: For
    this command and REST the actual point for the trigger is
    the exact point of the chord/rest change (this could be at an
    offset like 1.1415).
 
- Off
- Turns the trigger for the specified track off. This is
    the same as having a TRIGGER command with no arguments. No
    other commands are permitted with an ``off'' setting.
 
- Rest
- This keyword signals that a trigger should occur
    at any point where a rest starts. In this way you can
    handle a rest like a ``special'' chord.
 
 
The following commands are set in the OPTION=VALUE format:
- 
- Beats
- A comma separated list of beats for your trigger. Note
    that this is ignored if you have set one of the keywords
    AUTO or REST. The beats can be any legal offset into
    the bar (in 4/4 this would include 1, 2.4 and even
    3.9).
 
- Bars
- The bars of the sequence to apply the trigger to. For
    example (assuming a four bar sequence):
       
        | Chord-1 Trigger Auto Bars=1,3 |  
 
would limit the sequence to chord changes occurring in the first
    and third (of four) bars of each sequence in the song.
 
 
- Cnames
- A list of chord names which are checked against the
    active chord at each point of the BEATS list. Example:
       
        | Chord-Test Trigger Beats=1,2,3,4 Cnames=Cm,E7,FM7 |  
 
If the chord name is not in the specified list, no trigger is
    activated.
 
 
- Ctonics
- A list of base chord names which are checked against
    the active chord at each point of the BEATS list. Example:
       
        | Chord-Test Trigger Beats=1,2,3,4 Ctonics= C,E,F |  
 
If the tonic of the chord is not in the specified list, no trigger
    is activated.
 
 
- CTypes
- A list of chord types (e.g., ``m'', ``7'', ``dim'')
    which are checked against the active chord at each point of
    theBEATS list. Example:
       
        | Chord-Test Trigger Beats=1,2,3,4 Ctypes=m,m7,dim7 |  
 
If the chord-type is not in the specified list, no trigger is
    activated.
 
 
- Count
- The number of patterns to use from the sequence. If you
    have a sequence of four events (like the example at the start of
    this section) only the first event is used. However, by setting
    the count to a value:
       
        | Chord-1 Trigger Auto Count=2 |  
 
more of the patterns will be used. No pattern will start past the
    end of the current bar. The above example doesn't really make a
    lot of sense, but with a sequence like:
 
       
        | Chord-1 Sequence {1 3 90; 1.3 3 90; 1.6 3 90} |  
 
and a COUNT of 3 you can have a triplet play for each
    trigger point.
 
 
- Measures
- You can limit the trigger events to specific
    measures. For example:
       
        | Chord-1 Trigger Auto Measures=1,5,9 |  
 
will cause trigger events to be played only when a chord changes
    in bars 1, 5 or 9.26.2 Please note that the bar numbers
    are not checked against the actual bar numbers in your song (which
    can be hard to calculate after repeats and endings), but with the
    number label in the file. So a trigger command in the above
    example will apply to all of the following bars, regardless of the
    order of the numbering:
 
       
Please don't number your bars like this! It's just an example.
 
 
- Override
- By default, when a bar is parsed and the trigger
    command does not create any events 
MMA  will generate an
    empty bar for the track. However, by setting OVERRIDE=TRUE
    the original sequence for the track will be used. Use of this
    command (in conjunction with the SEQUENCE command) lets you
    have different patterns for bars with and without a trigger
    response.
 
- Sequence
- By default, a TRIGGER will use the
    SEQUENCE defined for the track. This command defines a
    different sequence to use. This can be useful in toggling between
    the track sequence and the trigger's by turning the trigger on and
    off. Define the sequence in the normal manner:
       
        | Chord-1 Trigger Auto Sequence = {1 3 90; 1.33 3 80; 1.66 3
      70} |  
 
Only one sequence is permitted in a trigger command.
 
 
- Sticky
- This is a convience option to set the STICKY
    bit for the current track. Its effect is the same as described here. When using the option in a
    TRIGGER line you must include the ``='' as in:
    
      
        | Drum-Triangle Trigger Sticky=True |  
 
 
- Truncate
- The duration of the notes in the sequence used by a
    trigger are, normally, left as defined. If you are using short
    notes, this works just fine. But, if the durations are longer you
    can end up with overlapping notes. The TRUNCATE command
    forces 
MMA  to truncate the duration of each note to the lesser
    of what is specifed, the start of the next pattern or the end of
    the current bar.
 
 
Things to note:
- A TRIGGER will always override a SEQUENCE in a
  track (almost: see the OVERRIDE option). So, if you have a
  sequence set, it will never be played if a trigger is active ...
  whether the trigger is activated or not. You should also note that
  RIFFs override triggers ... which make riffs a convenient
  method of disabling triggers for one or more bars.
When combining various options you should note the hierarchy of
  
MMA 's decision tree:
  
 
- If the BARS or MEASURES options have been set
    and the current bar is not in the list, no trigger is enabled,
 
- If there is no sequence (either from the track sequence or the
    trigger sequence option), no trigger is enabled,
 
- Regardless of the current mode (Chord, Rest or Beats) a new
    sequence is created. If this is an empty sequence ... again no
    trigger.
 
- the CNAME, CTONIC and CTYPE commands act
    to limit the BEATS.
 
 
If any of the above conditions result in ``no trigger'', no events
  will be generated. You can force events with the use of the
  OVERRIDE option (above).
 
An empty line:
 
       
will reset all options to the default and disable the trigger.
 
 
- For the CNAMES, CTONICS and CTYPES
  limiters:
 
- Using ROMAN notation, the chord name will be the value
    of the roman numeral (e.g., ``I'', ``vii''); however, the tonic
    and type will be correctly derived.
 
- The TRANSPOSE settings have no effect on the chord
    names and tonics.
 
- POLYCHORDS will have only the root (left side) of the
    name saved (the chords ``C'' and ``C¦D'' are identical
    for the purposes of a trigger).
 
- If you have more than one of these options set, only the first
    (in order of CNAMES, CTONICS and CTYPES) is
    used.
 
 
 
- You may get better results by creating a main track and copy
  that to a trigger track.
 
- A TRIGGER command always starts with all options set to
  default.
 
- Triggers are not saved as part of a GROOVE. However,
  there is no reason you can't save a trigger command in a macro (in a
  library file) and call that from your song file.
If you want a trigger to sound across different grooves you must set
  the track for the trigger to STICKY (details
  here). If you don't, all
  the settings for the track will be reset when a GROOVE
  command is issued.
 
 
A number of example files are included in the distribution in the
directory egs/trigger.
Footnotes
- ...GROOVES.26.1
- If triggers were part of a groove, the
  triggers a user creates would disappear on a groove change. Probably
  not what is expected.
- ... 9.26.2
- This is a good reason to number each
      bar in your song, as recommended here.
Bob van der Poel
2016-06-11