class Haematite::Sequencer

Overview

A sequencer that can play back files with MIDI data.

Note that this class does not provide thread safety. If you want to do playback control and render a waveform in separate threads, you must ensure that the associated methods/functions will not be called simultaneously.

Included Modules

Defined in:

haematite/sequencer.cr

Constructors

Instance Method Summary

Instance methods inherited from module Haematite::AudioRenderer

render(dest : Array(Float64) | Slice(Float64), pool : RemiLib::ArrayPool(Float64)) : Bool
render(dest : Array(Float32) | Slice(Float32), pool : RemiLib::ArrayPool(Float64)) : Bool
render(left : Slice(Float64), right : Slice(Float64)) : Bool
render(dest : Array(Float64) | Slice(Float64) | Array(Float32) | Slice(Float32)) : Bool
render

Constructor Detail

def self.new(synth : Synthesizer) #

Creates a new Sequencer instance.


Instance Method Detail

def currentTime : Int64 #

def finished? : Bool #

True if the current MIDI is not looping and has finished playing, or false otherwise.


def play(file : SequencedFile, loopSong : Bool) #

Plays the given SequencedFile. If loopSong is true, then the file is looped once it reaches the end or a loop point, otherwise it is not looped.


def play(file : Path | String, loopSong : Bool) #

Loads a song from the given file, then plays it. If loopSong is true, then the song is looped once it reaches the end or a loop point, otherwise it is not looped.

The format of the song is automatically determined. If it is not a supported format, this will raise an UnsupportedFormatError.


def position : Tuple(Int64, Int64) #

Returns two two values: the first value is the current play time for the MIDI sequencer. The second value is the same as MidiFile#length. Time values are always in microseconds.

If no MIDI file is loaded into the sequencer, this always returns 0 and 0.


def render(left : Slice(Float64), right : Slice(Float64)) : Bool #

Renders audio to left and right. This returns true if the song is not finished, or if the sequencer is set to loop. Otherwise this returns false when the song is finished and there is nothing left to render.


def reset #

Resets playback to the beginning.


def speed : Float32 #

The playback speed modifier.


def speed=(val : Float32) #

Sets the playback speed modifier. This must be greater than zero.


def stop #

Stops playback and resets the associated Synthesizer.


def synth : Synthesizer #