class Alda::InlineLisp
An inline lisp event. An Alda::EventContainer
containing an Alda::InlineLisp
can be derived using event list sugar. See Alda::EventList#method_missing
.
Sometimes you need help from Alda::LispIdentifier
.
It serves as attributes in alda codes.
Alda::Score.new do tempo! 108 quant! 200 piano_ c e g violin_ g2 e4 end
Here, tempo! 108
and quant! 200
are inline lisp events and serves for alda attributes.
It can participate in the sequence sugar if it is at the end of the sequence.
Alda::Score.new do piano_ c d e quant 200 g o! c o? c2 end
You can operate a score by purely using inline lisp events.
Alda::Score.new do part 'piano' key_sig [:d, :major] note pitch :d note pitch :e note pitch(:f), duration(note_length 2) end
When using event list sugar to create inline lisp events, note that it is not previously defined as a variable. See Alda::SetVariable
and Alda::GetVariable
.
Alda::Score.new do piano_ p barline.event.class # => Alda::InlineLisp barline__ c d e f p barline.event.class # => Alda::GetVariable end
Whether it is an Alda::SetVariable
, Alda::InlineLisp
, or Alda::GetVariable
is intelligently determined.
Alda::Score.new do piano_ p((tempo 108).event.class) # => Alda::InlineLisp p tempo { c d }.event.class # => Alda::SetVariable p tempo.event.class # => Alda::GetVariable p((tempo 60).event.class) # => Alda::InlineLisp p to_s # => "piano: (tempo 108) tempo = [c d]\n tempo (tempo 60)" end
If you want, you can generate lisp codes using ruby.
Alda::Score.new do println reduce _into_, {}, [{dog: 'food'}, {cat: 'chow'}] end.save 'temp.clj' `clj temp.clj` # => "[[:dog food] [:cat chow]]\n"
Attributes
The arguments passed to the lisp function.
Its elements can be any object that responds to to_alda_code
and detach_from_parent
.
The function name of the lisp function
Public Class Methods
Creates a new Alda::InlineLisp
.
The underlines “_” in head
will be converted to hyphens “-”.
# File lib/alda-rb/event.rb, line 315 def initialize head, *args @head = head.to_s.gsub ?_, ?- @args = args end
Public Instance Methods
Alda::Event#on_contained
# File lib/alda-rb/event.rb, line 324 def on_contained super @args.detach_from_parent end
# File lib/alda-rb/event.rb, line 320 def to_alda_code "(#{head} #{args.map(&:to_alda_code).join ' '})" end