Class NoteEvent

Abstraction of MIDI Note On and Note Off events.

Handles both.

See also:

Info:

  • License: MIT
  • Author: Pedro Alves Valentim

Functions

NoteEvent:new (fields) Creates a new NoteEvent.

Methods

NoteEvent:print () Prints event's data in a human-friendly style
NoteEvent:set_pitch (pitch) Sets NoteEvent's pitch
NoteEvent:set_duration (duration) Sets NoteEvent's duration
NoteEvent:set_rest (rest) Sets NoteEvent's rest
NoteEvent:set_velocity (velocity) Sets NoteEvent's velocity
NoteEvent:set_sequential (sequential) Sets NoteEvent's sequential property
NoteEvent:set_repetition (repetition) Sets NoteEvent's repetition
NoteEvent:set_channel (channel) Sets NoteEvent's channel
NoteEvent:get_pitch () Gets pitch(es) of NoteEvent
NoteEvent:get_duration () Gets duration of NoteEvent
NoteEvent:get_rest () Gets rest duration of NoteEvent
NoteEvent:get_velocity () Gets velocity of NoteEvent
NoteEvent:get_sequential () Gets sequentiallity of NoteEvent
NoteEvent:get_repetition () Gets repetition value of NoteEvent
NoteEvent:get_channel () Gets channel # of NoteEvent


Functions

NoteEvent:new (fields)
Creates a new NoteEvent. Receives a fields table as parameter. This table is expected to have some (or all) of these fields:

Name Type Description
pitch string, number or array Note (or array of notes) to be triggered. Can be a string or valid MIDI note code. Format for string is C#4.
duration string or array How long the note should sound.
  • 1 : whole
  • 2 : half
  • d2 : dotted half
  • 4 : quarter
  • d4 : dotted quarter
  • 8 : eighth
  • 8t : eighth triplet
  • d8 : dotted eighth
  • 16 : sixteenth
  • Tn : where n is an explicit number of ticks
If an array of durations is passed then the sum of the durations will be used. Default: 4
rest string Rest before sounding note. Takes same values as duration. Default: 0
velocity number How loud the note should sound, values 1-100. Default: 50
sequential boolean If true then array of pitches will be played sequentially as opposed to simulatanously. Default: false
repetition number How many times this event should be repeated. Default: 1
channel number MIDI channel to use. Default: 1

Note: pitch is the only required field

Parameters:

  • fields a table containing NoteEvent's proprieties

Returns:

    new NoteEvent object

Methods

NoteEvent:print ()
Prints event's data in a human-friendly style
NoteEvent:set_pitch (pitch)
Sets NoteEvent's pitch

Parameters:

  • pitch takes the same values as the pitch field passed to the constructor.

Returns:

    NoteEvent with new pitch
NoteEvent:set_duration (duration)
Sets NoteEvent's duration

Parameters:

  • duration takes the same values as the duration field passed to the constructor.

Returns:

    NoteEvent with new duration
NoteEvent:set_rest (rest)
Sets NoteEvent's rest

Parameters:

  • rest takes the same values as the rest field passed to the constructor.

Returns:

    NoteEvent with new rest
NoteEvent:set_velocity (velocity)
Sets NoteEvent's velocity

Parameters:

  • velocity number loudness of the note sound. Values from 1-100.

Returns:

    NoteEvent with new velocity
NoteEvent:set_sequential (sequential)
Sets NoteEvent's sequential property

Parameters:

  • sequential bool true to play the pitches (if pitch is an array) sequentially.

Returns:

    NoteEvent with new sequential property
NoteEvent:set_repetition (repetition)
Sets NoteEvent's repetition

Parameters:

  • repetition number number of times this NoteEvent will be repeated.

Returns:

    NoteEvent with new repetition
NoteEvent:set_channel (channel)
Sets NoteEvent's channel

Parameters:

  • channel number MIDI channel # (1-16).

Returns:

    NoteEvent with new channel
NoteEvent:get_pitch ()
Gets pitch(es) of NoteEvent

Returns:

    NoteEvent's pitch value
NoteEvent:get_duration ()
Gets duration of NoteEvent

Returns:

    NoteEvent's duration value
NoteEvent:get_rest ()
Gets rest duration of NoteEvent

Returns:

    NoteEvent's rest value
NoteEvent:get_velocity ()
Gets velocity of NoteEvent

Returns:

    NoteEvent's velocity value
NoteEvent:get_sequential ()
Gets sequentiallity of NoteEvent

Returns:

    NoteEvent's sequential value
NoteEvent:get_repetition ()
Gets repetition value of NoteEvent

Returns:

    NoteEvent's repetition value
NoteEvent:get_channel ()
Gets channel # of NoteEvent

Returns:

    NoteEvent's channel value
generated by LDoc 1.4.6 Last updated 2020-02-28 01:36:33