makenote

Makenote, an object the handles the 3 parameters associated with standard midi playback, note, velocity and notelength. Its a bit like Pure Data's makenote object, hence the name. There is midi port selector and midi channel build into the object, to make it simple to work with.
Author: Jaffasplaffa
License: BSD
Github: jaffa/midi/makenote.axo

Inlets

bool32.rising trigger

frac32.bipolar delay

frac32.bipolar t

frac32.positive v

Outlets

None

Parameters

frac32.s.map Transpose

frac32.u.map Velocity

int32 channel

bool32.mom Trigger

frac32.s.map.klineartime.exp Length

Attributes

combo d

Declaration
int32_t val;
int ntrig;

// drj/midi/note_tx
int ntrigmidi;
int lastnote;
Init
val = 0;
ntrig = 0;
ntrigmidi = 0;
Control Rate
bool Trigger = inlet_tr || param_Trigger;
bool Gate;
if ((Trigger > 0) && !ntrig) {
  val = 1 << 30;
  ntrig = 1;
  Gate = 1;
} else {
  if (!(Trigger > 0))
    ntrig = 0;
  if (val > 0) {
    int32_t t;
    MTOF(-param_Length - inlet_l, t);
    val -= t >> 3;
    if (val <= 0)
      Gate = 0;
    else
      Gate = 1;
  } else
    Gate = 0;
}

int32_t Transpose = inlet_t + param_Transpose;
int32_t Velocity = inlet_v + param_Velocity;

if ((Gate > 0) && !ntrigmidi) {
  lastnote = (64 + (Transpose >> 21)) & 0x7F;
  MidiSend3((midi_device_t)attr_d, MIDI_NOTE_ON + (param_channel - 1), lastnote,
            Velocity >> 20);
  ntrigmidi = 1;
}
if (!(Gate > 0) && ntrigmidi) {
  MidiSend3((midi_device_t)attr_d, MIDI_NOTE_OFF + (param_channel - 1),
            lastnote, __USAT(Velocity >> 20, 7));
  ntrigmidi = 0;
}

Privacy

© 2024 Zrna Research