Class Flexinome

The Flexinome, much like the Metronome, is an implementation of the IMetronome interface, and is used for converting millisecond updates in time, into beat updates in time.

The Flexinome differs from the Metronome though, in that it fully embraces the IMetronome's concept of separating quarter notes from beats, allowing a lot of flexibility in how bars can be divided up, with some beats stretching out to last longer than others.

This means that if you had a 4 beat clip, it could be played infinitely many ways, just by passing it into a ClipPlayer that's linked to a Flexinome, and altering the time signature that it's using.

To better understand how this works, please take a look at the IMetronome and TimeSig documentation.

Hierarchy

  • MetronomeBase

    Hierarchy

    • Flexinome

Implements

Constructors

  • Parameters

    • tempo: number

      The tempo to run the flexinome at.

    • timeSig: TimeSig = null

      The time signature for the flexinome to use. If not provided then the flexinome defaults to common time (4/4).

    Returns Flexinome

Accessors

  • get bar(): number
  • Records what bar the flexinome is currently on.

    This just returns barTracker.value.

    Returns number

  • get barBeat(): number
  • Records how many beats have passed within the current bar.

    This just returns barBeatTracker.value.

    Returns number

  • get barBeatTracker(): PropertyTracker<number>
  • Records the difference in bar beat values, enabling inspection of the beat within the current bar from one update cycle to the next.

    Returns PropertyTracker<number>

  • get barQuarterNote(): number
  • Records how many quarter notes have passed within the current bar

    This just returns barQuarterNoteTracker.value.

    Returns number

  • get barQuarterNoteTracker(): PropertyTracker<number>
  • Records the difference in bar quarter note values, enabling inspection of the quarter note within the current bar from one update cycle to the next.

    Returns PropertyTracker<number>

  • get barTracker(): PropertyTracker<number>
  • Records the bar number in the previous update vs the current one.

    Returns PropertyTracker<number>

  • get enabled(): boolean
  • Gets whether the flexinome is currently enabled to run.

    Returns boolean

  • set enabled(value: boolean): void
  • Sets whether the flexinome is currently enabled to run.

    Parameters

    • value: boolean

    Returns void

  • get isFinished(): boolean
  • Returns true if the Flexinome has been instructed to stop everything by the finish() method.

    Returns boolean

  • get ref(): string
  • Provides a way of identifying flexinomes so they can be easily retrieved later

    Returns string

  • set ref(value: string): void
  • Parameters

    • value: string

    Returns void

  • get tempo(): number
  • Get the current flexinome tempo.

    Returns number

  • set tempo(value: number): void
  • Set the current flexinome tempo.

    Parameters

    • value: number

    Returns void

  • get tempoMultiplier(): number
  • Get the tempo multiplier. This allows defining the tempo in terms of other duration values than just quarter notes. For example, if tempo == 120:

    tempoMultiplier == 1 means ♩ = 120

    tempoMultiplier == 0.5 means ♪ = 120

    tempoMultiplier == 1.5 means ♩. = 120

    The default value is 1.

    Returns number

  • set tempoMultiplier(value: number): void
  • Set the tempo multiplier. This allows defining the tempo in terms of other duration values than just quarter notes. For example, if tempo == 120:

    tempoMultiplier == 1 means ♩ = 120

    tempoMultiplier == 0.5 means ♪ = 120

    tempoMultiplier == 1.5 means ♩. = 120

    Valid values are technically all positive numbers, though in reality only numbers that correspond to common musical note durations make sense.

    Parameters

    • value: number

    Returns void

  • get timeSig(): TimeSig
  • Get the current flexinome time signature.

    Returns TimeSig

  • set timeSig(value: TimeSig): void
  • Set the flexinome time signature.

    Note: This doesn't actually change the time signature straight away, but instead stores it so that the time signature changes on the start of the next bar.

    Parameters

    Returns void

  • get totalBeat(): number
  • How many beats have passed in total since the flexinome started.

    This just returns totalBeatTracker.value.

    Returns number

  • get totalBeatTracker(): PropertyTracker<number>
  • Records the difference in total beats passed, enabling inspection of the total beat change from one update cycle to the next.

    Returns PropertyTracker<number>

  • get totalQuarterNote(): number
  • How many quarter notes have passed in total since the flexinome started.

    This just returns totalQuarterNoteTracker.value.

    Returns number

  • get totalQuarterNoteTracker(): PropertyTracker<number>
  • Records the difference in total quarter notes passed, enabling inspection of the total quarter note change from one update cycle to the next.

    Returns PropertyTracker<number>

  • get typeName(): string
  • Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable.

    Returns string

Methods

  • This takes in a beat and returns true if the flexinome is currently at it, or has only just passed it in the bar within the last update cycle.

    Returns

    Parameters

    • beat: number

      The beat to test if we've recently passed.

    Returns boolean

  • This takes in a beat division and checks if the metronome is currently at some multiple of that division within the current bar, returning what multiple of the division we're currently at. For example: atBarBeatMultiple(0.5) returns 0 if we're at beat 0, 1 if we're at beat 0.5, 2 if we're at beat 1, etc. If not at a multiple of the division, then -1 is returned.

    Parameters

    • division: number

      The beat division to check if the metronome is at a multiple of.

    Returns number

  • This takes a quarter note and returns true if the flexinome is currently at it, or has only just passed it in the bar within the last update cycle.

    Returns

    Parameters

    • quarterNote: number

      The quarter note to test if we've recently passed.

    Returns boolean

  • This takes in a quarter note division and checks if the metronome is currently at some multiple of that division within the current bar, returning what multiple of the division we're currently at. For example: atBarQuarterNoteMultiple(0.5) returns 0 if we're at QN 0, 1 if we're at QN 0.5, 2 if we're at QN 1, etc. If not at a multiple of the division, then -1 is returned.

    Parameters

    • division: number

      The beat division to check if the metronome is at a multiple of.

    Returns number

  • Calling this tells the flexinome to stop whatever it's doing and that it will no longer be used.

    Returns void

  • This method allows for setting the metronome to a specific position.

    Note though, that the bar-related values are calculated under the assumption that the metronome's current time signature is the one that it always has.

    Parameters

    • totalQuarterNote: number

      The new position, as measured in quarter notes.

    Returns void

  • This method is intended to be called by a clock to provide regular updates. It should be called by consumers of the library.

    Returns

    Parameters

    • msDelta: number

      How many milliseconds have passed since the last update cycle.

    Returns boolean

  • This method is exposed primarily for the TickReceiver, so it can get a metronome to update, using its own calculation of how many quarter notes to update by.

    This method should not be called by consumers of the library.

    Returns

    Parameters

    • qnDelta: number

      The number of quarter notes to update the metronome by.

    Returns boolean

  • Provides a way for setting the ref through a chained function call. For example:

    clock.addChild(new Flexinome(120, TimeSig.commonTime).withRef('metronome'));
    

    Returns

    The calling object.

    Parameters

    • ref: string

      The ref to set on the object.

    Returns IClockChild

Generated using TypeDoc