module Negasonic::DSL

Public Instance Methods

instrument(name, synth:, volume: nil, &block) click to toggle source
# File lib/negasonic/dsl.rb, line 26
def instrument(name, synth:, volume: nil, &block)
  instrument = Negasonic::Instrument.find(name) ||
               Negasonic::Instrument.add(name)

  synth_node = Negasonic::Instrument::Synth.send(synth, { volume: volume })

  instrument.tap do |i|
    i.instance_eval(&block)
    i.connect_nodes(synth_node)
  end
end
part(instrument:, &block) click to toggle source
# File lib/negasonic/dsl.rb, line 3
def part(instrument:, &block)
  the_instrument = Negasonic::Instrument.find(instrument)

  the_loop = Negasonic::LoopedEvent::Part.new(the_instrument.input_node)
  the_loop.instance_eval(&block)
  the_loop.start
end
pattern(instrument:, interval:, type:, notes:) click to toggle source
# File lib/negasonic/dsl.rb, line 19
def pattern(instrument:, interval:, type:, notes:)
  the_instrument = Negasonic::Instrument.find(instrument)

  Negasonic::LoopedEvent::Pattern.new(the_instrument.input_node, notes)
                                 .start(interval, type)
end
sequence(instrument:, interval: , &block) click to toggle source
# File lib/negasonic/dsl.rb, line 11
def sequence(instrument:, interval: , &block)
  the_instrument = Negasonic::Instrument.find(instrument)

  the_loop = Negasonic::LoopedEvent::Sequence.new(the_instrument.input_node)
  the_loop.instance_eval(&block)
  the_loop.start(interval)
end