note2

Midi note output
Author: Johannes Taelman
License: BSD
Github: jaffa/ctrl/note2.axo

Inlets

frac32.bipolar note (-64..63)

frac32.bipolar note2

frac32.positive velocity

frac32.positive velo2

bool32.rising trigger

bool32.rising trig2

Outlets

None

Parameters

int32 ch1

int32 ch2

Attributes

combo d

Declaration
int ntrig1;
int lastnote1;

int ntrig2;
int lastnote2;
Init
ntrig1 = 0;

ntrig2 = 0;
Control Rate
// Ch1 //
{
  if ((inlet_trig1 > 0) && !ntrig1) {
    lastnote1 = (64 + (inlet_note1 >> 21)) & 0x7F;
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_ON + (param_ch1 - 1), lastnote1,
              inlet_velo1 >> 20);
    ntrig1 = 1;
  }
  if (!(inlet_trig1 > 0) && ntrig1) {
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_OFF + (param_ch1 - 1), lastnote1,
              __USAT(inlet_velo1 >> 20, 7));
    ntrig1 = 0;
  }
}

// Ch2 //
{
  if ((inlet_trig2 > 0) && !ntrig2) {
    lastnote2 = (64 + (inlet_note2 >> 21)) & 0x7F;
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_ON + (param_ch2 - 1), lastnote2,
              inlet_velo2 >> 20);
    ntrig2 = 1;
  }
  if (!(inlet_trig2 > 0) && ntrig2) {
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_OFF + (param_ch2 - 1), lastnote2,
              __USAT(inlet_velo2 >> 20, 7));
    ntrig2 = 0;
  }
}

Privacy

© 2024 Zrna Research