class Haematite::Sequencer
- Haematite::Sequencer
- Reference
- Object
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.crConstructors
-
.new(synth : Synthesizer)
Creates a new
Sequencer
instance.
Instance Method Summary
- #currentTime : Int64
-
#finished? : Bool
True if the current MIDI is not looping and has finished playing, or false otherwise.
-
#play(file : SequencedFile, loopSong : Bool)
Plays the given
SequencedFile
. -
#play(file : Path | String, loopSong : Bool)
Loads a song from the given file, then plays it.
-
#position : Tuple(Int64, Int64)
Returns two two values: the first value is the current play time for the MIDI sequencer.
-
#render(left : Slice(Float64), right : Slice(Float64)) : Bool
Renders audio to
left
andright
. -
#reset
Resets playback to the beginning.
-
#speed : Float32
The playback speed modifier.
-
#speed=(val : Float32)
Sets the playback speed modifier.
-
#stop
Stops playback and resets the associated
Synthesizer
. - #synth : Synthesizer
Instance methods inherited from module Haematite::AudioRenderer
render(dest : Array(Float64) | Slice(Float64), pool : RemiLib::ArrayPool(Float64)) : Boolrender(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
Instance Method Detail
True if the current MIDI is not looping and has finished playing, or false otherwise.
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.
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
.
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.
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.