GenericPlugin

GenericPlugin

The GenericPlugin class is a lightweight implementation designed for quick experimentation and protoyping of bespoke processors.

It has been designed to solve common view and midi management problems with the native Scripter API while keepin file size low and performance relatively high. .

The needsTiming, needsResets and params properties have been intentionally left out of the base implementation and you are encouraged to add them to subclasses only as needed.

Constructor

new GenericPlugin()

See:
Example
class BespokePlugin extends GenericPlugin {

  // @lends Scripter.NeedsTimingInfo
  get needsTiming () {
    return true
  }

  // @lends Scripter.ResetParameterDefaults
  get needsDefaults () {
    return false
  }

  // @lends Scripter.PluginParameters
  get params () {
    return [{ type: "text", name: this.constructor.name }]
  }

  // intercept midi events and scripter events as needed...
}

// Instantiate and deploy the plugin, printing the integration keys to console
BespokePlugin.deploy()
 .forEach(Trace)

Extends

Methods

getEventName(event) → {string}

Determine the name of a Scripter MIDI event.

NOTE: in earlier editions of Logic Pro X, determining the name of an event was as simple as checking the event constructors name Trace(event.constructor.name) // e.g. "NoteOn" This method compares the midi status code to a known list of event name correlates to accomodate.

Parameters:
Name Type Description
event Event

Any Scripter MIDI event

Returns:
Type:
string

The name of the MIDI event

onChannelPressure(event) → {number}

Manage a ChannelPressure event.

See:
Parameters:
Name Type Description
event ChannelPressure

A ChannelPressure event

Returns:
Type:
number

The beatPos that the event was sent at

onControlChange(event) → {number}

Manage a ControlChange event.

See:
Parameters:
Name Type Description
event ControlChange

A ControlChange event

Returns:
Type:
number

The beatPos that the event was sent at

onEvent(event) → {number}

Manage a generic Event instance.

See:
Parameters:
Name Type Description
event PitchBend

A generic Event instance

Returns:
Type:
number

The beatPos that the event was sent at

onMidi(midi) → {number}

Manage calls to Scripter.HandleMIDI.

This implementation filters out midi events to appropriate hanlders to facilitate quick interception of key events.

See:
Parameters:
Name Type Description
midi Event

A Scripter MIDI event

Returns:
Type:
number

The beatPos that the midi event was sent at

Example
class Transposer {
  get params () {
    return [
      {
        ID: "semitones"
      , name: "Semitones"
      , type: "lin"
      , defaultValue: 0
      , minValue: -12
      , maxValue: 12
      }
    ]
  }

  onNote (noteOnOrOff) {
    noteOnOrOff.pitch += this.semitones
    return super.onNote(noteOnOrOff)
  }
}

onNote(event) → {number}

Manage a NoteOn or NoteOff event.

See:
Parameters:
Name Type Description
event NoteOff | NoteOn

A NoteOff or NoteOn event

Returns:
Type:
number

The beatPos that the event was sent at

onNoteOff(event) → {number}

Manage a NoteOff event.

See:
Parameters:
Name Type Description
event NoteOff

A NoteOff event

Returns:
Type:
number

The beatPos that the event was sent at

onNoteOn(event) → {number}

Manage a NoteOn event.

See:
Parameters:
Name Type Description
event NoteOn

A NoteOn event

Returns:
Type:
number

The beatPos that the event was sent at

onParam(key, val) → {void}

Manage calls to Scripter.ParameterChanged.

This implementation essentially treats the plugin itself as a "ParamViewModel".

Given onParam is called with a parameter index and data value When the param as a property named ID Then ID is treated as a property key of the plugin And the data value is assigned to the plugin.

This enables the use of properties to store parameter state and also provides the convenience of property interceptors for advanced use cases

Parameters:
Name Type Description
key number

The index of a param

val number

The new value of the param

Returns:
Type:
void
Example
class MidiStop extends GenericPlugin {
  get params () {
    return [
      {
        ID: "midiStop"
      , type: "momentary"
      , name: "MIDI Stop"
      }
    ]
  }

  set midiStop (any) {
    this.engine.MIDI.allNotesStop()
  }
}

onPitchBend(event) → {number}

Manage a PitchBend event.

See:
Parameters:
Name Type Description
event PitchBend

A TargetEvent event

Returns:
Type:
number

The beatPos that the event was sent at

onPolyPressure(event) → {number}

Manage a PolyPressure event.

See:
Parameters:
Name Type Description
event PolyPressure

A PolyPressure event

Returns:
Type:
number

The beatPos that the event was sent at

onProgramChange(event) → {number}

Manage a ProgramChange event.

See:
Parameters:
Name Type Description
event ProgramChange

A ProgramChange event

Returns:
Type:
number

The beatPos that the event was sent at

onTargetEvent(event) → {number}

Manage a TargetEvent event.

See:
Parameters:
Name Type Description
event TargetEvent

A TargetEvent event

Returns:
Type:
number

The beatPos that the event was sent at

sendMidi(event) → {number}

Send a Scripter MIDI event using any one of the four avalable midi dispatch methods

When beatPos is missing Then event.send is used When beatPos is a postive nunber Then event.sendAtBeat is used When beatPos is a negative number Then event.sendAfterBeats is used with beatPos flipped to positive number When beatPos is a string (postive or negative) Then event.sendAfterMilliseconds is used with beatPos cast to positive number

Parameters:
Name Type Description
event Event

Any supported Scripter MIDI Event instance.

Returns:
Type:
number

The beatPos at which the event was sent.