notegen

Created by Panaiotis
© 2001 by Panaiotis. All rights reserved.

General

Variation on makenote. Eliminates holes created when a short note sends a note-off before another generated note on the same pitch has been completed. makenote generates a noteoff for each noteon. notegen sends noteon and noteoff messages in a slightly more discriminating manner.

Input

  bang turns all pending notes off and clears notegen for pitches with pending activity.
  panic sends note-offs to all pitches and clears notegen of all pending activity.

notegen operates in one of three mode that determine its behavior when a note-on is initiated while a previous note of the same pitch is still active. In all cases, the new release velocity replaces the old release velocity. The modes are:

  sustain new note is ignored if it will end before old note, otherwise the new end-time replaces the old. Good with instruments that sustain indefinitely. Not necessarily good for instruments with natural decay.
  reattack same as sustain. In addition notegen sends an immediate note-on. This is overall the most useful mode. The overall effect is two articulations of two notes that end at the end of the latest end time. (see below for diagram)
  offon same as reattack. In addition notegen releases the old note before reattacking it, even if the old note would have been released later. Some synthesizers need this.

Additional input

  pvc notegen sends note count, velocity, and pitch out their respective outlets appropriate to send to xnoteout. Channel information is ignored.
  midilist notegen sends a list through leftmost outlet ready to send directly through midiout. It includes channel information. The list must be broken up by iter before being sent to midiout. Useful for sending to mtr to create standard midi files. (Write to me for an application that changes mtr to standard midi format 1 file.)
  int in leftmost inlet current pitch, initiates output.
  in1 velocity-on level.
  in2 velocity-off level.
  in3 duration in ms.
  in4 on/off status determines the behavior when a pitch value is received in the leftmost inlet. Values
   

-1 decrease the note-on count. Send note-off if note count is 0.
0 send note-off immediately and clear that pitch of current activity.
1 send note-on and increase the note count.

  in5 midichannel. Only affects output when in midilist mode. Wraps channels greater than 16.

Arguments

(optional)

  symbol mode: sustain, reattack, offon.
  ints velocity on, release velocity, duration in ms.

Output

From right to left:

  int/list int in pvc mode (default) pitch. List in midilist mode: noteon/noetoff cmd, pitch, velocity.
  int velocity on in pvc mode. Nothing in midilist mode.
  int release velocity in pvc mode. Nothing in midilist mode.
  int 0 = noteoff, non 0 = noteon count (send to xnoteon)

Examples

In the examples below, two notes are played (stream 1 and stream 2). Below the stream are representations of the behavior of makenote and followed by the three modes of notegen.

  Mode   First note on ---- 2nd note on ---- 1st note off ---- 2nd note off
Example 1                  
Stream 1     C4on --------- ----- ---------------- ----- C4off    

Stream 2

        C4on --------- ----- ----------------- ----- C4off

makenote

    C4on --------- ----- ----------------- ----- C4off silence

notegen

sustain   C4on --------- ----- ---------------- ----- ----------------- ----- C4off

notegen

reattack   C4on --------- ----- C4on ----- ----------------- ----- C4off

notegen

offon   C4on --------- ----- C4off: C4on ----- ----------------- ----- C4off
Example 2                  

Stream 1

        C4on --------- ----- C4off    

Stream 2

    C4on --------- ----- ---------------- ----- ----------------- ----- C4off

makenote

    C4on --------- ----- ---------------- ----- C4off silence

notegen

sustain   C4on --------- ----- ---------------- ----- ----------------- ----- C4off

notegen

reattack   C4on --------- ----- C4on --------- ----- ----------------- ----- C4off

notegen

offon   C4on --------- ----- C4off: C4on ----- ----------------- ----- C4off

See also

makenote