Module nwcPlayContext

Object class for emulating play context.

This class requires level 2 for the nwcut#nwcut.setlevel property.

Type nwcPlayContext

nwcPlayContext.Clef

The current clef

nwcPlayContext.ClefOctave

The current clef octave

nwcPlayContext.Ending1Context

Contains needed context at the prior first ending, which is used for context in later endings

nwcPlayContext:FindTieIndex(o)

Finds an existing note tie for the current nwcNotePos object, or the string tie spec stored in the nwcPlayContext.Ties table.

nwcPlayContext:GetBarNum()

Get the current bar/measure number.

nwcPlayContext:GetNoteAccidental(notepos)

Calculate the note accidental for the current nwcNotePos object.

nwcPlayContext:GetNoteMidiPitch(notepos)

Calculate the Midi note number for the current nwcNotePos object.

nwcPlayContext:GetNoteName(notepos)

Calculate the note name for the current nwcNotePos object.

nwcPlayContext:GetOctaveShift()

Get the current clef octave shift.

nwcPlayContext:GetPlayPitchShift()

Get the current pitch shift.

nwcPlayContext:GetScientificPitchOctave(notepos)

Calculate the octave for the current nwcNotePos object.

nwcPlayContext.ID

Contains the name of the object type (nwcPlayContext)

nwcPlayContext.Key

An associative array of note names, each tracking the number of semitone shift present in the current key signature

nwcPlayContext.KeyTonic

The current key signature Tonic (a note name, one of C,D,E,F,G,A,B)

nwcPlayContext.NextBarNum

The current bar/measure number

nwcPlayContext.PendingBarIncrement

When on, the bar count needs to be incremented at the next note

nwcPlayContext.RunKey

An associative array of note names, each tracking the number of semitone shift in the current measure that should be applied to notes without an accidental assigned

nwcPlayContext.SeenFirstEnding

Indicates when a first ending has been encountered and Ending1Context contains valid information to restore context in later endings

nwcPlayContext.Slur

True when a slur is currently running

nwcPlayContext.Ties

A list of currently running note ties, stored as a string with the accidental and noteposition of each tie

nwcPlayContext.Transposition

The current number of semitones of transposition applied during play back

nwcPlayContext.new()

Constructs a new nwcPlayContext object.

nwcPlayContext:put(o)

Updates the running context with the current nwcItem.

Type nwcPlayContext

Field(s)

#string nwcPlayContext.Clef

The current clef

#string nwcPlayContext.ClefOctave

The current clef octave

#table nwcPlayContext.Ending1Context

Contains needed context at the prior first ending, which is used for context in later endings

nwcPlayContext:FindTieIndex(o)

Finds an existing note tie for the current nwcNotePos object, or the string tie spec stored in the nwcPlayContext.Ties table.

Parameter

  • o : the note position object nwcNotePos or a accidental/position string

Return values

  1. #number: If found, the index into the nwcPlayContext.Ties table is returned

  2. #boolean: False is returned if a tie is not currently running at the position

nwcPlayContext:GetBarNum()

Get the current bar/measure number.

Return value

#number: The current bar number

nwcPlayContext:GetNoteAccidental(notepos)

Calculate the note accidental for the current nwcNotePos object.

Parameter

Return value

#string: The note accidental charactacter

nwcPlayContext:GetNoteMidiPitch(notepos)

Calculate the Midi note number for the current nwcNotePos object.

Parameter

Return value

#number: The Midi note number

nwcPlayContext:GetNoteName(notepos)

Calculate the note name for the current nwcNotePos object.

Parameter

Return value

#string: The note name

nwcPlayContext:GetOctaveShift()

Get the current clef octave shift.

Return value

#number: The current octave shift (one of -1, 0, or 1)

nwcPlayContext:GetPlayPitchShift()

Get the current pitch shift.

Return value

#number: The current pitch shift (in + or - semitones)

nwcPlayContext:GetScientificPitchOctave(notepos)

Calculate the octave for the current nwcNotePos object.

Parameter

Return value

#number: The note octave

#string nwcPlayContext.ID

Contains the name of the object type (nwcPlayContext)

#table nwcPlayContext.Key

An associative array of note names, each tracking the number of semitone shift present in the current key signature

#string nwcPlayContext.KeyTonic

The current key signature Tonic (a note name, one of C,D,E,F,G,A,B)

#number nwcPlayContext.NextBarNum

The current bar/measure number

#boolean nwcPlayContext.PendingBarIncrement

When on, the bar count needs to be incremented at the next note

#table nwcPlayContext.RunKey

An associative array of note names, each tracking the number of semitone shift in the current measure that should be applied to notes without an accidental assigned

#boolean nwcPlayContext.SeenFirstEnding

Indicates when a first ending has been encountered and Ending1Context contains valid information to restore context in later endings

#boolean nwcPlayContext.Slur

True when a slur is currently running

#table nwcPlayContext.Ties

A list of currently running note ties, stored as a string with the accidental and noteposition of each tie

#number nwcPlayContext.Transposition

The current number of semitones of transposition applied during play back

nwcPlayContext.new()

Constructs a new nwcPlayContext object.

If the nwcut#nwcut.setlevel property has not been previously set, then constructing a nwcPlayContext object will set the default nwcItem level to 2.

Return value

#nwcPlayContext: A new nwcPlayContext object.

nwcPlayContext:put(o)

Updates the running context with the current nwcItem.

This should be called for each object returned from nwcut#nwcut.items. This function requires a level 2 instance of nwcItem (refer to the nwcut#nwcut.setlevel property).

Parameter

Copyright © 2020 NoteWorthy Software™, Inc.
All Rights Reserved.