note8

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

Inlets

frac32.positive velocity

frac32.positive velo2

frac32.positive velo3

frac32.positive velo4

frac32.positive velo5

frac32.positive velo6

frac32.positive velo7

frac32.positive velo8

bool32.rising trigger

bool32.rising trig2

bool32.rising trig3

bool32.rising trig4

bool32.rising trig5

bool32.rising trig6

bool32.rising trig7

bool32.rising trig8

frac32.bipolar note (-64..63)

frac32.bipolar note2

frac32.bipolar note3

frac32.bipolar note4

frac32.bipolar note5

frac32.bipolar note6

frac32.bipolar note7

frac32.bipolar note8

Outlets

None

Parameters

int32 ch1

int32 ch2

int32 ch3

int32 ch4

int32 ch5

int32 ch6

int32 ch7

int32 ch8

Attributes

combo d

Declaration
int ntrig1;
int lastnote1;

int ntrig2;
int lastnote2;

int ntrig3;
int lastnote3;

int ntrig4;
int lastnote4;

int ntrig5;
int lastnote5;

int ntrig6;
int lastnote6;

int ntrig7;
int lastnote7;

int ntrig8;
int lastnote8;
Init
ntrig1 = 0;

ntrig2 = 0;

ntrig3 = 0;

ntrig4 = 0;

ntrig5 = 0;

ntrig6 = 0;

ntrig7 = 0;

ntrig8 = 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;
  }
}

// Ch3 //
{
  if ((inlet_trig3 > 0) && !ntrig3) {
    lastnote3 = (64 + (inlet_note3 >> 21)) & 0x7F;
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_ON + (param_ch3 - 1), lastnote3,
              inlet_velo3 >> 20);
    ntrig3 = 1;
  }
  if (!(inlet_trig3 > 0) && ntrig3) {
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_OFF + (param_ch3 - 1), lastnote3,
              __USAT(inlet_velo3 >> 20, 7));
    ntrig3 = 0;
  }
}

// Ch4 //
{
  if ((inlet_trig4 > 0) && !ntrig4) {
    lastnote4 = (64 + (inlet_note4 >> 21)) & 0x7F;
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_ON + (param_ch4 - 1), lastnote4,
              inlet_velo4 >> 20);
    ntrig4 = 1;
  }
  if (!(inlet_trig4 > 0) && ntrig4) {
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_OFF + (param_ch4 - 1), lastnote4,
              __USAT(inlet_velo4 >> 20, 7));
    ntrig4 = 0;
  }
}

// Ch5 //
{
  if ((inlet_trig5 > 0) && !ntrig5) {
    lastnote5 = (64 + (inlet_note5 >> 21)) & 0x7F;
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_ON + (param_ch5 - 1), lastnote5,
              inlet_velo5 >> 20);
    ntrig5 = 1;
  }
  if (!(inlet_trig5 > 0) && ntrig5) {
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_OFF + (param_ch5 - 1), lastnote5,
              __USAT(inlet_velo5 >> 20, 7));
    ntrig5 = 0;
  }
}

// Ch6 //
{
  if ((inlet_trig6 > 0) && !ntrig6) {
    lastnote6 = (64 + (inlet_note6 >> 21)) & 0x7F;
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_ON + (param_ch6 - 1), lastnote6,
              inlet_velo6 >> 20);
    ntrig6 = 1;
  }
  if (!(inlet_trig6 > 0) && ntrig6) {
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_OFF + (param_ch6 - 1), lastnote6,
              __USAT(inlet_velo6 >> 20, 7));
    ntrig6 = 0;
  }
}

// Ch7 //
{
  if ((inlet_trig7 > 0) && !ntrig7) {
    lastnote7 = (64 + (inlet_note7 >> 21)) & 0x7F;
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_ON + (param_ch7 - 1), lastnote7,
              inlet_velo7 >> 20);
    ntrig7 = 1;
  }
  if (!(inlet_trig7 > 0) && ntrig7) {
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_OFF + (param_ch7 - 1), lastnote7,
              __USAT(inlet_velo7 >> 20, 7));
    ntrig7 = 0;
  }
}

// Ch8 //
{
  if ((inlet_trig8 > 0) && !ntrig8) {
    lastnote8 = (64 + (inlet_note8 >> 21)) & 0x7F;
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_ON + (param_ch8 - 1), lastnote8,
              inlet_velo8 >> 20);
    ntrig8 = 1;
  }
  if (!(inlet_trig8 > 0) && ntrig8) {
    MidiSend3((midi_device_t)attr_d, MIDI_NOTE_OFF + (param_ch8 - 1), lastnote8,
              __USAT(inlet_velo8 >> 20, 7));
    ntrig8 = 0;
  }
}

Privacy

© 2024 Zrna Research