class Mass::Sequence
A sequence of patterns that is played in order immediately as it is defined.
Attributes
_bpm[R]
Beats per minute speed of the sequence
@attr_reader [Integer]
_midi[R]
MIDI driver used to power all notes in the sequence.
@attr_reader [UniMIDI::Output]
name[R]
Name of this sequence
@attr_reader [String]
Public Class Methods
define(name, **params, &block)
click to toggle source
Define a new sequence into the global namespace
@param [String] name @options [KeywordArguments] params @param [Proc] block @return [Mass::Sequence]
# File lib/mass/sequence.rb, line 35 def self.define(name, **params, &block) new name, **params, &block end
new(name, bpm: 100) { || ... }
click to toggle source
@param [String] name @option [Integer] bpm - defaults to 100
# File lib/mass/sequence.rb, line 22 def initialize(name, bpm: 100) @name = name @_bpm = bpm @_midi ||= UniMIDI::Output.gets yield if block_given? end
Public Instance Methods
bpm(new_bpm)
click to toggle source
Change BPM.
@param [Integer] new_bpm @example
bpm 128
# File lib/mass/sequence.rb, line 45 def bpm(new_bpm) @_bpm = new_bpm end
pattern(**params, &block)
click to toggle source
Create a pattern. See the docs on Mass::Pattern
for more information about its requirements.
@options [KeywordArguments] params @options [Proc] block @example
pattern name: 'verse', bars: 1 do note 8, pitch: 'C4' note 8, pitch: 'C3' note 8, pitch: 'A3' note 8, pitch: 'B4' note 8, pitch: 'C4' note 8, pitch: 'Gb2' note 8, pitch: 'C4' rest 8 end
# File lib/mass/sequence.rb, line 66 def pattern(**params, &block) Pattern.create(**params.merge(sequence: self), &block) end