New version 0.1.4
New features:
- The Ruby requirements become
">= 2.7"
, so update your Ruby. - Added a colorful REPL! Run
Alda::repl
and see.
$ ruby -ralda-rb -e "Alda.repl"
> puts status
[27713] Server up (2/2 workers available, backend port: 33245)
> piano_ c d e f
[piano: c d e f]
> 5.times do
> c
> end
c c c c c
> puts history
[piano: c d e f]
c c c c c
> play
> save 'temp.alda'
> puts `cat temp.alda`
[piano: c d e f]
c c c c c
> system 'rm temp.alda'
> exit
- More than 2 events written together will become an
Sequence
object (contained by aEventContainer
). Events that can use such sugar includes: part (supports dot accessor), note, rest, octave, voice, marker, at-marker.
Alda::Score.new { p((c d e).event.class) } # => Alda::Sequence
- Added:
o!
means octave up,o?
means octave down. This is to be compatible with the sugar above. - Similarly added:
!
at the end of a note means sharp, and?
for flat,_
for natural. It conflicts with slur, so__
means slur, and___
means slur and natural.
Alda::Score.new { piano_ c o? b? o! c o? b? }.to_s
# => "[piano: c < b- > c < b-]"
- Added attr accessor
Event#container
. - Fixed the bug occurring when one uses a dot accessor wrongly.
- Added
Sequence::join
to join several events into a flatten sequence. - Fixed the bug in
examples/alternate_endings.rb
. - Some of the examples are rewritten using the new sugar feature.
- Assign an alda variable by using a method ending with 2 underlines, or pass a block for it. The following three are equivalent:
Alda::Score.new { var__ c d e; piano_ var }
Alda::Score.new { var { c d e }; piano_ var }
Alda::Score.new { var__ { c d e }; piano_ var }
This one is slightly different but has the same effect:
Alda::Score.new { var__ c, d, e; piano_ var }
The name of a variable can be same as that of a lisp function if there is no ambiguity.
- The message of
CommandLineError
is optimized. - Added
OrderError
, which is used instead ofRuntimeError
, representing a disorder of events.
Alda::Score.new do
motif = f4 f e e d d c2
g4 f e d c2
p @events.size # => 2
c4 c g g a a g2 motif
rescue OrderError => e
p @events.size # => 1
p e.expected # => #<Alda::EventContainer:...>
p e.got # => #<Alda::EventContainer:...>
end
- The block passed to an
EventList
object is now called inEvent#on_contained
, so@parent
,@container
etc can be gotten inside. EventList
can access methods in@parent
.- Canceled
Alda::method_missing
. Use meta-programming to define methods instead. You can now useinclude Alda
to import such commands.
include Alda
version # => "Client version: 1.4.1\nServer version: [27713] 1.4.1\n"
- Added
Kernel#alda
. It runsalda
at command line and does not capture the output.
alda 'version'
- Use
Alda::[]
to specify command options (not subcommand options):
Alda[quiet: true].play code: 'piano: c d e f' # => ""
The options specified will be remembered. Invoke Alda::clear_options
to forget them.
- Added
CommandLineError#port
.
begin
Alda[port: 1108].play code: 'y'
rescue CommandLineError => e
e.port # => 1108
end
- Added
Score#save
andScore#load
to save and load Alda files.
Alda::Score.new { c d e }.save 'temp.alda'
File.read 'temp.alda' # => "[c d e]\n"