Class: Wavify::DSL::TrackBuilder 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 Method Summary collapse

Constructor Details

#initialize(track_definition) ⇒ TrackBuilder

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 TrackBuilder.

Parameters:



776
777
778
# File 'lib/wavify/dsl.rb', line 776

def initialize(track_definition)
  @track = track_definition
end

Instance Method Details

#chords(notation, default_octave: nil, voicing: nil) ⇒ 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.

Defines chord notation.



801
802
803
# File 'lib/wavify/dsl.rb', line 801

def chords(notation, default_octave: nil, voicing: nil)
  @track.chords!(notation, default_octave: default_octave, voicing: voicing)
end

#effect(name, **params) ⇒ 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.

Adds an effect to the track.



824
825
826
# File 'lib/wavify/dsl.rb', line 824

def effect(name, **params)
  @track.effect!(name, **params)
end

#envelope(**params) ⇒ 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.

Defines an ADSR envelope and validates required parameters.



811
812
813
814
815
816
817
818
819
820
821
# File 'lib/wavify/dsl.rb', line 811

def envelope(**params)
  required = %i[attack decay sustain release]
  missing = required - params.keys
  raise Wavify::SequencerError, "missing envelope params: #{missing.join(', ')}" unless missing.empty?

  supported = required + %i[hold curve]
  unknown = params.keys - supported
  raise Wavify::SequencerError, "unsupported envelope params: #{unknown.join(', ')}" unless unknown.empty?

  @track.envelope!(**params)
end

#gain(db) ⇒ 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.

Sets track gain in dB.



829
830
831
# File 'lib/wavify/dsl.rb', line 829

def gain(db)
  @track.gain!(db)
end

#key(root, scale = :major) ⇒ 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.

Quantizes note and chord pitches to a key/scale.



806
807
808
# File 'lib/wavify/dsl.rb', line 806

def key(root, scale = :major)
  @track.key!(root, scale)
end

#notes(notation, resolution: nil, default_octave: nil) ⇒ 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.

Defines note notation and parser options.



796
797
798
# File 'lib/wavify/dsl.rb', line 796

def notes(notation, resolution: nil, default_octave: nil)
  @track.notes!(notation, resolution: resolution, default_octave: default_octave)
end

#pan(position) ⇒ 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.

Sets track pan position.



834
835
836
# File 'lib/wavify/dsl.rb', line 834

def pan(position)
  @track.pan!(position)
end

#pattern(name_or_notation, notation = nil, resolution: nil) ⇒ 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.

Delegates pattern definition to the underlying track.



781
782
783
# File 'lib/wavify/dsl.rb', line 781

def pattern(name_or_notation, notation = nil, resolution: nil)
  @track.pattern!(name_or_notation, notation, resolution: resolution)
end

#sample(name, path = nil, **options) ⇒ 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.

Registers a sample mapping.



786
787
788
# File 'lib/wavify/dsl.rb', line 786

def sample(name, path = nil, **options)
  @track.sample!(name, path, **options)
end

#synth(waveform, **options) ⇒ 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.

Configures synth waveform/options.



791
792
793
# File 'lib/wavify/dsl.rb', line 791

def synth(waveform, **options)
  @track.synth!(waveform, **options)
end