Class: Wavify::DSL::ArrangementBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wavify/dsl.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

:nodoc: all

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeArrangementBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ArrangementBuilder.



844
845
846
# File 'lib/wavify/dsl.rb', line 844

def initialize
  @sections = []
end

Instance Attribute Details

#sectionsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



842
843
844
# File 'lib/wavify/dsl.rb', line 842

def sections
  @sections
end

Instance Method Details

#section(name, bars:, tracks:, repeat: 1, tempo: nil, beats_per_bar: nil, markers: []) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
# File 'lib/wavify/dsl.rb', line 848

def section(name, bars:, tracks:, repeat: 1, tempo: nil, beats_per_bar: nil, markers: [])
  unless bars.is_a?(Integer) && bars.between?(1, Wavify::Sequencer::Engine::MAX_BARS)
    raise Wavify::SequencerError, "bars must be an Integer in 1..#{Wavify::Sequencer::Engine::MAX_BARS}"
  end
  unless repeat.is_a?(Integer) && repeat.between?(1, Wavify::Sequencer::Engine::MAX_SECTION_REPEAT)
    raise Wavify::SequencerError, "repeat must be an Integer in 1..#{Wavify::Sequencer::Engine::MAX_SECTION_REPEAT}"
  end
  if tempo && !(tempo.is_a?(Numeric) && tempo.respond_to?(:finite?) && tempo.finite? && tempo.positive?)
    raise Wavify::SequencerError, "tempo must be a positive finite Numeric"
  end
  if beats_per_bar && !(beats_per_bar.is_a?(Integer) && beats_per_bar.positive?)
    raise Wavify::SequencerError, "beats_per_bar must be a positive Integer"
  end

  names = Array(tracks).map(&:to_sym)

  @sections << SongDefinition::Section.new(
    name: name.to_sym,
    bars: bars,
    tracks: names,
    repeat: repeat,
    tempo: tempo,
    beats_per_bar: beats_per_bar,
    markers: Array(markers).map(&:to_sym)
  )
end