alda-rb 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +18 -0
- data/.gitignore +2 -2
- data/CHANGELOG.md +296 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile +3 -2
- data/Gemfile.lock +56 -0
- data/README.md +58 -7
- data/Rakefile +2 -2
- data/alda-rb.gemspec +30 -25
- data/examples/bwv846_prelude.rb +3 -3
- data/examples/clapping_music.rb +1 -1
- data/examples/dot_accessor.rb +1 -1
- data/examples/dynamics.rb +22 -0
- data/examples/entropy.rb +2 -2
- data/examples/hanon.rb +2 -2
- data/examples/marriage_d_amour.rb +114 -0
- data/examples/multi_poly.rb +2 -2
- data/examples/track-volume.rb +32 -0
- data/examples/variables-2.rb +16 -0
- data/exe/alda-irb +32 -0
- data/lib/alda-rb/commandline.rb +176 -33
- data/lib/alda-rb/error.rb +93 -9
- data/lib/alda-rb/event.rb +441 -49
- data/lib/alda-rb/event_list.rb +57 -10
- data/lib/alda-rb/patches.rb +88 -14
- data/lib/alda-rb/repl.rb +330 -61
- data/lib/alda-rb/utils.rb +47 -0
- data/lib/alda-rb/version.rb +1 -1
- data/lib/alda-rb.rb +1 -0
- metadata +74 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41c00c8e704980367ff2ca3cef0028e08cd5483106a0df2d89bc70644fea33a1
|
4
|
+
data.tar.gz: da32c375756258266cd4eee3818d8697f2ced17605f2bfe19db69e9eebffa5ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc03761923a96fd3c596cd034ef86f51f26b0b8055e33287e8fff772f1f1c062de55f0a009f07930c7bea8b2f9c491246b70ae44dc37aeec388cbc5f0669971f
|
7
|
+
data.tar.gz: f578e781ba699b774c9a22f30b65f8dd1c734d09fa4cd32d49416874cbab96203efd9b357ef9740854864ff445b408b4a55c85aaabdf236337b889f488819850
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 2.7.0
|
14
|
+
- name: Run the default task
|
15
|
+
run: |
|
16
|
+
gem install bundler
|
17
|
+
bundle install
|
18
|
+
bundle exec rake
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,296 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## v0.3.1 (2023-06-03)
|
4
|
+
|
5
|
+
New features and new API:
|
6
|
+
|
7
|
+
- Added Alda::NREPLServerError#status.
|
8
|
+
- Added Alda::env.
|
9
|
+
- Alda::down? and Alda::up? is now useful in \Alda 2.
|
10
|
+
- Added Alda::REPL#reline.
|
11
|
+
|
12
|
+
BREAKING changes of API:
|
13
|
+
|
14
|
+
- Now `status` should be specified as a parameter of Alda::NREPLServerError::new.
|
15
|
+
|
16
|
+
Fixed bugs:
|
17
|
+
|
18
|
+
- Fixed: `alda-irb` does not run correctly in Ruby 3.
|
19
|
+
- Fixed: cannot handle unknown-op error of nREPL server.
|
20
|
+
- Fixed: an excess message printed when exiting \REPL on Windows.
|
21
|
+
|
22
|
+
Other changes:
|
23
|
+
|
24
|
+
- Fixed dependencies.
|
25
|
+
- Fixed some changelog of 0.3.0.
|
26
|
+
- Added a gem badge in README.
|
27
|
+
- Updated bundler version.
|
28
|
+
|
29
|
+
## v0.3.0 (2023-05-29)
|
30
|
+
|
31
|
+
### Changes for \Alda 2
|
32
|
+
|
33
|
+
Added API for support \Alda 2 while still being able to support \Alda 1:
|
34
|
+
|
35
|
+
- Added Alda::COMMANDS_FOR_VERSIONS and Alda::GENERATIONS.
|
36
|
+
- Added Alda::generation, which can be `:v1` or `:v2`.
|
37
|
+
Specifically, one of the values in the array Alda::GENERATIONS.
|
38
|
+
- Added Alda::v1?, Alda::v2?, Alda::v1!, Alda::v2! (See Alda::GENERATIONS).
|
39
|
+
- Added Alda::deduce_generation.
|
40
|
+
- Added Alda::GenerationError.
|
41
|
+
- In Alda::Chord#to_alda_code, considering an undocumented breaking change about chords,
|
42
|
+
the behavior is slightly different for \Alda 1 and \Alda 2.
|
43
|
+
- Added Thread#inside_alda_list.
|
44
|
+
- Added Alda::REPL#message and Alda::REPL#raw_message.
|
45
|
+
|
46
|
+
APIs that are modified to support \Alda 2:
|
47
|
+
|
48
|
+
- (BREAKING CHANGE!) Changed Alda::COMMANDS from an array of symbols into a hash.
|
49
|
+
The keys are the names of the commands,
|
50
|
+
and the values are arrays of generations where the command is available.
|
51
|
+
- Because \Alda 2 does not have the notion of down and up, if we are in v2,
|
52
|
+
Alda::down? will always return false and Alda::up? will always return true.
|
53
|
+
- Array#to_alda_code and Hash#to_alda_code behaves differently for \Alda 1 and \Alda 2 regarding
|
54
|
+
[a breaking change](https://github.com/alda-lang/alda/blob/master/doc/alda-2-migration-guide.md#attribute-syntax-has-changed-in-some-cases).
|
55
|
+
|
56
|
+
Documents that modified for notice about \Alda 2:
|
57
|
+
|
58
|
+
- Alda::[], Alda::up?, Alda::down?, Alda::COMMANDS.
|
59
|
+
- Alda::EventList#method_missing.
|
60
|
+
- Alda::InlineLisp.
|
61
|
+
- Array#to_alda_code, Hash#to_alda_code.
|
62
|
+
- Alda::REPL.
|
63
|
+
- Alda::CommandLineError#port.
|
64
|
+
|
65
|
+
Examples that are modified to work in \Alda 2:
|
66
|
+
|
67
|
+
- clapping_music,
|
68
|
+
- dot_accessor,
|
69
|
+
- marriage_d_amour.
|
70
|
+
|
71
|
+
### New things
|
72
|
+
|
73
|
+
New features:
|
74
|
+
|
75
|
+
- Added warnings about structures that probably trigger errors in \Alda.
|
76
|
+
See Alda::EventContainer#check_in_chord, Alda::EventList#method_missing.
|
77
|
+
- Now you can specify a parameter in Alda::Event#detach_from_parent to exclude some
|
78
|
+
classes of parents that will be detached from.
|
79
|
+
- (Potentially BREAKING) Alda::Event#detach_from_parent now tries to detach the topmost container
|
80
|
+
instead of the event itself from the parent.
|
81
|
+
- Added a commandline program called `alda-irb`. See Alda::REPL.
|
82
|
+
- Traceback of exception will also be printed now if an Interrupt is caught in \REPL.
|
83
|
+
- <kbd>Ctrl</kbd>+<kbd>C</kbd> can now be used to discard the current input in \REPL.
|
84
|
+
- Now, Alda::REPL takes better care of indents.
|
85
|
+
- Added no-color mode and no-preview mode for \REPL.
|
86
|
+
- Now Alda::REPL::TempScore#score and Alda::REPL::TempScore#map output in blue color.
|
87
|
+
|
88
|
+
New APIs:
|
89
|
+
|
90
|
+
- Added Alda::Raw.
|
91
|
+
- Added Alda::Utils::warn, Alda::Utils::win_platform?,
|
92
|
+
Alda::Utils::snake_to_slug, Alda::Utils::slug_to_snake.
|
93
|
+
- Added Alda::Event#is_event_of?. It is overridden in Alda::EventContainer#is_event_of?.
|
94
|
+
- Added Alda::Event#== and Alda::EventList#==. It is overridden in many subclasses.
|
95
|
+
- Added Alda::EventContainer#check_in_chord.
|
96
|
+
- Added Alda::EventList#l.
|
97
|
+
- Added Alda::EventList#raw.
|
98
|
+
- Added Alda::REPL#color, Alda::REPL#preview.
|
99
|
+
- Added Alda::REPL#setup_repl, Alda::REPL#readline.
|
100
|
+
- Added Alda::REPL::TempScore#new_score, Alda::REPL::TempScore#score_text,
|
101
|
+
Alda::REPL::TempScore#score_data, Alda::REPL::TempScore#score_events.
|
102
|
+
- Added Alda::pipe.
|
103
|
+
- Added Alda::processes.
|
104
|
+
- Added Alda::NREPLServerError.
|
105
|
+
- Added Alda::GenerationError::assert_generation.
|
106
|
+
|
107
|
+
Slightly improved docs:
|
108
|
+
|
109
|
+
- Alda::EventContainer#event.
|
110
|
+
- The overriding `to_alda_code`'s and `on_contained`'s.
|
111
|
+
- Alda::Sequence, Alda::Sequence::RefineFlatten#flatten.
|
112
|
+
- The patches to Ruby's core classes.
|
113
|
+
- Kernel.
|
114
|
+
- Alda::EventList::new.
|
115
|
+
- Alda::OrderError::new.
|
116
|
+
- Alda::InlineLisp.
|
117
|
+
- Alda::OrderError#expected.
|
118
|
+
|
119
|
+
Much better docs:
|
120
|
+
|
121
|
+
- Alda::EventContainer#/.
|
122
|
+
- Alda::EventList#on_contained.
|
123
|
+
- Alda::REPL::TempScore.
|
124
|
+
|
125
|
+
New examples:
|
126
|
+
|
127
|
+
- dynamics,
|
128
|
+
- track-volume,
|
129
|
+
- variables-2.
|
130
|
+
|
131
|
+
### BREAKING changes
|
132
|
+
|
133
|
+
Removed APIs:
|
134
|
+
|
135
|
+
- Removed Alda::SetVariable#original_events.
|
136
|
+
- Removed Alda::repl. Now calling `Alda.repl` will trigger commandline `alda repl`.
|
137
|
+
For the old REPL function, use `Alda::REPL.new.run` instead.
|
138
|
+
- Removed Alda::REPL::TempScore#history.
|
139
|
+
|
140
|
+
Modified APIs or features:
|
141
|
+
|
142
|
+
- Now Alda::REPL#play_score does not call Alda::REPL#try_command.
|
143
|
+
- Alda::Score#load now use Alda::Raw instead of an Alda::InlineLisp to load a file.
|
144
|
+
|
145
|
+
### Fixed bugs
|
146
|
+
|
147
|
+
- Fixed: sometimes Alda::Event#parent returns wrong result
|
148
|
+
because it is not updated in some cases.
|
149
|
+
- Fixed (potentially BREAKING): Hash#to_alda_code returns `[[k1 v1] [k2 v2]]`.
|
150
|
+
Now, it returns `{k1 v1 k2 v2}`.
|
151
|
+
- Use reline instead of readline in Alda::REPL
|
152
|
+
because Ruby 3.3 is dropping the shipment of readline-ext.
|
153
|
+
|
154
|
+
### Others
|
155
|
+
|
156
|
+
- Added changelog.
|
157
|
+
- Modified the homepage and changelog URI in gemspec.
|
158
|
+
- Fixed the email in code of conduct.
|
159
|
+
|
160
|
+
## v0.2.1 (2020-08-13)
|
161
|
+
|
162
|
+
- Fixed the bug in `examples/bwv846_prelude.rb`.
|
163
|
+
The file isn't changed when the version change
|
164
|
+
from [v0.1.4](#v014-2020-04-23) to [v0.2.0](#v020-2020-05-08)
|
165
|
+
but the new features in 0.2.0 made some codes in that file stop working.
|
166
|
+
|
167
|
+
## v0.2.0 (2020-05-08)
|
168
|
+
|
169
|
+
- Separated `alda-rb.rb` into several files.
|
170
|
+
- REPL now supports `map`, `score`, and `new`.
|
171
|
+
- Added a lot of docs. Can be seen [here](https://ulysseszh.github.io/doc/alda-rb).
|
172
|
+
- Added Alda::Event#detach_from_parent.
|
173
|
+
- Fixed the bug that dot accessor of Alda::Part does not return the container (or the part itself).
|
174
|
+
- Added Alda::LispIdentifier.
|
175
|
+
- Fixed Alda::EventList#import now returns `nil`.
|
176
|
+
- Added some unit tests.
|
177
|
+
- Fixed the bug that creating an Alda::GetVariable occasionally crashes.
|
178
|
+
- Fixed bug that inline lisp is mistakenly interpreted as set-variable.
|
179
|
+
|
180
|
+
## v0.1.4 (2020-04-23)
|
181
|
+
|
182
|
+
- The Ruby requirements become `">= 2.7"`, so update your Ruby.
|
183
|
+
- Added a colorful REPL! Run Alda::repl and see.
|
184
|
+
```
|
185
|
+
$ ruby -ralda-rb -e "Alda.repl"
|
186
|
+
> puts status
|
187
|
+
[27713] Server up (2/2 workers available, backend port: 33245)
|
188
|
+
> piano_ c d e f
|
189
|
+
[piano: c d e f]
|
190
|
+
> 5.times do
|
191
|
+
> c
|
192
|
+
> end
|
193
|
+
c c c c c
|
194
|
+
> puts history
|
195
|
+
[piano: c d e f]
|
196
|
+
c c c c c
|
197
|
+
> play
|
198
|
+
> save 'temp.alda'
|
199
|
+
> puts `cat temp.alda`
|
200
|
+
[piano: c d e f]
|
201
|
+
c c c c c
|
202
|
+
> system 'rm temp.alda'
|
203
|
+
> exit
|
204
|
+
```
|
205
|
+
- More than 2 events written together will become an Alda::Sequence object
|
206
|
+
(contained by an Alda::EventContainer).
|
207
|
+
Events that can use such sugar includes:
|
208
|
+
part (supports dot accessor), note, rest, octave, voice, marker, at-marker.
|
209
|
+
```ruby
|
210
|
+
Alda::Score.new { p((c d e).event.class) } # => Alda::Sequence
|
211
|
+
```
|
212
|
+
- Added: `o!` means octave up, `o?` means octave down. This is to be compatible with the sugar above.
|
213
|
+
- 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.
|
214
|
+
```ruby
|
215
|
+
Alda::Score.new { piano_ c o? b? o! c o? b? }.to_s
|
216
|
+
# => "[piano: c < b- > c < b-]"
|
217
|
+
```
|
218
|
+
- Added attr accessor Alda::Event#container.
|
219
|
+
- Fixed the bug occurring when one uses a dot accessor wrongly.
|
220
|
+
- Added Alda::Sequence::join to join several events into a flatten sequence.
|
221
|
+
- Fixed the bug in `examples/alternate_endings.rb`.
|
222
|
+
- Some of the examples are rewritten using the new sugar feature.
|
223
|
+
- Assign an alda variable by using a method ending with 2 underlines, or pass a block for it. The following three are equivalent:
|
224
|
+
```ruby
|
225
|
+
Alda::Score.new { var__ c d e; piano_ var }
|
226
|
+
```
|
227
|
+
```ruby
|
228
|
+
Alda::Score.new { var { c d e }; piano_ var }
|
229
|
+
```
|
230
|
+
```ruby
|
231
|
+
Alda::Score.new { var__ { c d e }; piano_ var }
|
232
|
+
```
|
233
|
+
This one is slightly different but has the same effect:
|
234
|
+
```ruby
|
235
|
+
Alda::Score.new { var__ c, d, e; piano_ var }
|
236
|
+
```
|
237
|
+
The name of a variable can be same as that of a lisp function if there is no ambiguity.
|
238
|
+
- The message of Alda::CommandLineError is optimized.
|
239
|
+
- Added Alda::OrderError, which is used instead of RuntimeError, representing a disorder of events.
|
240
|
+
```ruby
|
241
|
+
Alda::Score.new do
|
242
|
+
motif = f4 f e e d d c2
|
243
|
+
g4 f e d c2
|
244
|
+
p @events.size # => 2
|
245
|
+
c4 c g g a a g2 motif
|
246
|
+
rescue OrderError => e
|
247
|
+
p @events.size # => 1
|
248
|
+
p e.expected # => #<Alda::EventContainer:...>
|
249
|
+
p e.got # => #<Alda::EventContainer:...>
|
250
|
+
end
|
251
|
+
```
|
252
|
+
- The block passed to an Alda::EventList object is now called in Alda::Event#on_contained, so `@parent`, `@container` etc can be gotten inside.
|
253
|
+
- Alda::EventList can access methods in `@parent`.
|
254
|
+
- Canceled Alda::method_missing. Use meta-programming to define methods instead. You can now use `include Alda` to import such commands.
|
255
|
+
```ruby
|
256
|
+
include Alda
|
257
|
+
version # => "Client version: 1.4.1\nServer version: [27713] 1.4.1\n"
|
258
|
+
```
|
259
|
+
- Added Kernel#alda. It runs `alda` at command line and does not capture the output.
|
260
|
+
```ruby
|
261
|
+
alda 'version'
|
262
|
+
```
|
263
|
+
- Use Alda::[] to specify command options (not subcommand options):
|
264
|
+
```ruby
|
265
|
+
Alda[quiet: true].play code: 'piano: c d e f' # => ""
|
266
|
+
```
|
267
|
+
The options specified will be remembered. Invoke `Alda::clear_options` to forget them.
|
268
|
+
- Added Alda::CommandLineError#port.
|
269
|
+
```ruby
|
270
|
+
begin
|
271
|
+
Alda[port: 1108].play code: 'y'
|
272
|
+
rescue CommandLineError => e
|
273
|
+
e.port # => 1108
|
274
|
+
end
|
275
|
+
```
|
276
|
+
- Added Alda::Score#save and Alda::Score#load to save and load \Alda files.
|
277
|
+
```ruby
|
278
|
+
Alda::Score.new { c d e }.save 'temp.alda'
|
279
|
+
File.read 'temp.alda' # => "[c d e]\n"
|
280
|
+
```
|
281
|
+
|
282
|
+
## v0.1.2 (2020-04-16)
|
283
|
+
|
284
|
+
- Added examples
|
285
|
+
- Fixed bug when writing `key_sig b: [:flat]`
|
286
|
+
- Added sequence sugar(s) and alternative repetition sugar (`%`) (see examples/alternate_endings.rb)
|
287
|
+
- Write options naturally for alda command line (`Alda.play code: 'piano: c'`)
|
288
|
+
- Can pass scores to alda command line (`Alda.play code: Alda::Score.new`)
|
289
|
+
- Added Alda::Score#parse, Alda::Score#export, and Alda::Score#to_s
|
290
|
+
- Fixed bug when writing `+o/c`
|
291
|
+
- Added support for dot accessor (see example/dot_accessor.rb)
|
292
|
+
- Fixed some mistakes in docs and README
|
293
|
+
|
294
|
+
## v0.1.0 (2020-04-15)
|
295
|
+
|
296
|
+
The original version.
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
|
55
55
|
## Enforcement
|
56
56
|
|
57
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at
|
58
|
+
reported by contacting the project team at UlyssesZhan@gmail.com. All
|
59
59
|
complaints will be reviewed and investigated and will result in a response that
|
60
60
|
is deemed necessary and appropriate to the circumstances. The project team is
|
61
61
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
alda-rb (0.3.1)
|
5
|
+
bencode
|
6
|
+
colorize
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.4.2)
|
12
|
+
bencode (0.8.2)
|
13
|
+
colorize (0.8.1)
|
14
|
+
json (2.6.3)
|
15
|
+
minitest (5.18.0)
|
16
|
+
parallel (1.23.0)
|
17
|
+
parser (3.2.2.1)
|
18
|
+
ast (~> 2.4.1)
|
19
|
+
psych (5.1.0)
|
20
|
+
stringio
|
21
|
+
rainbow (3.1.1)
|
22
|
+
rake (12.3.3)
|
23
|
+
rdoc (6.5.0)
|
24
|
+
psych (>= 4.0.0)
|
25
|
+
regexp_parser (2.8.0)
|
26
|
+
rexml (3.2.5)
|
27
|
+
rubocop (1.51.0)
|
28
|
+
json (~> 2.3)
|
29
|
+
parallel (~> 1.10)
|
30
|
+
parser (>= 3.2.0.0)
|
31
|
+
rainbow (>= 2.2.2, < 4.0)
|
32
|
+
regexp_parser (>= 1.8, < 3.0)
|
33
|
+
rexml (>= 3.2.5, < 4.0)
|
34
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
35
|
+
ruby-progressbar (~> 1.7)
|
36
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
37
|
+
rubocop-ast (1.28.1)
|
38
|
+
parser (>= 3.2.1.0)
|
39
|
+
ruby-progressbar (1.13.0)
|
40
|
+
stringio (3.0.6)
|
41
|
+
unicode-display_width (2.4.2)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
x86_64-linux
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
alda-rb!
|
48
|
+
bencode
|
49
|
+
colorize
|
50
|
+
minitest (~> 5.0)
|
51
|
+
rake (~> 12.0)
|
52
|
+
rdoc
|
53
|
+
rubocop
|
54
|
+
|
55
|
+
BUNDLED WITH
|
56
|
+
2.4.13
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# alda-rb
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/alda-rb)
|
4
|
+
|
3
5
|
A Ruby library for live-coding music with [Alda](https://alda.io/).
|
4
6
|
Also provides an alda DSL in Ruby.
|
5
7
|
|
@@ -21,7 +23,7 @@ Or install it yourself as:
|
|
21
23
|
|
22
24
|
## Usage
|
23
25
|
|
24
|
-
[Install Alda](https://
|
26
|
+
[Install Alda](https://alda.io/install),
|
25
27
|
and try the following Ruby codes yourself:
|
26
28
|
|
27
29
|
```ruby
|
@@ -56,21 +58,70 @@ Alda::Score.new do
|
|
56
58
|
end.play
|
57
59
|
```
|
58
60
|
|
61
|
+
There is also an interactive mode.
|
62
|
+
You can run it by running `alda-irb` in your command line if you installed the gem.
|
63
|
+
Run `bundle exec alda-irb` instead if you installed it using the bundler.
|
64
|
+
|
65
|
+
```plain
|
66
|
+
$ alda-irb
|
67
|
+
> p processes.last
|
68
|
+
{:id=>"dus", :port=>34317, :state=>nil, :expiry=>nil, :type=>:repl_server}
|
69
|
+
> piano_; c d e f
|
70
|
+
piano: [c d e f]
|
71
|
+
> 5.times do
|
72
|
+
. c
|
73
|
+
> end
|
74
|
+
c c c c c
|
75
|
+
> score_text
|
76
|
+
piano: [c d e f]
|
77
|
+
c c c c c
|
78
|
+
> play
|
79
|
+
Playing...
|
80
|
+
> save 'temp.alda'
|
81
|
+
> puts `cat temp.alda`
|
82
|
+
piano: [c d e f]
|
83
|
+
c c c c c
|
84
|
+
> system 'rm temp.alda'
|
85
|
+
> exit
|
86
|
+
```
|
87
|
+
|
88
|
+
You can also use it to programmatically communicate with the nREPL server:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
repl = Alda::REPL.new
|
92
|
+
repl.message :eval_and_play, code: 'piano: c d e f' # => nil
|
93
|
+
repl.message :eval_and_play, code: 'g a b > c' # => nil
|
94
|
+
repl.message :score_text # => "piano: [c d e f]\ng a b > c\n"
|
95
|
+
repl.message :eval_and_play, code: 'this will cause an error' # (raises Alda::NREPLServerError)
|
96
|
+
```
|
97
|
+
|
59
98
|
## Development
|
60
99
|
|
61
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
100
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
101
|
+
Then, run `rake test` to run the tests.
|
102
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
62
103
|
|
63
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
104
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
105
|
+
To release a new version, update the version number in `version.rb`,
|
106
|
+
and then run `bundle exec rake release`,
|
107
|
+
which will create a git tag for the version,
|
108
|
+
push git commits and tags,
|
109
|
+
and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
64
110
|
|
65
111
|
## Contributing
|
66
112
|
|
67
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/UlyssesZh/alda-rb.
|
68
|
-
|
113
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/UlyssesZh/alda-rb.
|
114
|
+
This project is intended to be a safe, welcoming space for collaboration,
|
115
|
+
and contributors are expected to adhere to the
|
116
|
+
[code of conduct](https://github.com/UlyssesZh/alda-rb/blob/master/CODE_OF_CONDUCT.md).
|
69
117
|
|
70
118
|
## License
|
71
119
|
|
72
|
-
The gem is available as open source under the terms of the
|
120
|
+
The gem is available as open source under the terms of the
|
121
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
73
122
|
|
74
123
|
## Code of Conduct
|
75
124
|
|
76
|
-
Everyone interacting in the alda-rb project's codebases, issue trackers,
|
125
|
+
Everyone interacting in the alda-rb project's codebases, issue trackers,
|
126
|
+
chat rooms and mailing lists is expected to follow the
|
127
|
+
[code of conduct](https://github.com/UlyssesZh/alda-rb/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -4,8 +4,8 @@ require 'rdoc/task'
|
|
4
4
|
|
5
5
|
RDoc::Task.new do |t|
|
6
6
|
t.main = 'README.md'
|
7
|
-
t.
|
8
|
-
|
7
|
+
t.rdoc_dir = 'doc'
|
8
|
+
t.rdoc_files.include 'README.md', 'CODE_OF_CONDUCT.md', 'CHANGELOG.md', 'LICENSE.txt', 'lib/**/*.rb'
|
9
9
|
t.options << '--tab-width'
|
10
10
|
t.options << '2'
|
11
11
|
end
|
data/alda-rb.gemspec
CHANGED
@@ -3,29 +3,34 @@
|
|
3
3
|
require_relative 'lib/alda-rb/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
6
|
+
spec.name = "alda-rb"
|
7
|
+
spec.version = Alda::VERSION
|
8
|
+
spec.authors = ["Ulysses Zhan"]
|
9
|
+
spec.email = ["UlyssesZhan@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{A Ruby library for live-coding music with Alda.}
|
12
|
+
# spec.description = %q{TODO: Write a longer description or delete this line.}
|
13
|
+
spec.homepage = "https://ulysseszh.github.io/doc/alda-rb"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/UlyssesZh/alda-rb"
|
21
|
+
spec.metadata["changelog_uri"] = "https://ulysseszh.github.io/doc/alda-rb/CHANGELOG_md.html"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_runtime_dependency 'bencode'
|
33
|
+
spec.add_runtime_dependency 'colorize'
|
34
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
35
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
31
36
|
end
|
data/examples/bwv846_prelude.rb
CHANGED
@@ -15,13 +15,13 @@ class Alda::Sequence
|
|
15
15
|
/(?<letter>[a-g][-+_]*)(?<octave>\d*)/ =~ pitch
|
16
16
|
octave = @@last_octave ||= '4' if octave.empty?
|
17
17
|
result = Alda::Note.new "o#{@@last_octave = octave} #{letter}", duration
|
18
|
-
|
18
|
+
@events.push result.tap { _1.parent = self }
|
19
19
|
result
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
Alda::Score.new do
|
24
|
-
piano_ tempo 60
|
24
|
+
piano_; tempo 60
|
25
25
|
%w[
|
26
26
|
c e g c5 e
|
27
27
|
c4 d a d5 f
|
@@ -62,7 +62,7 @@ Alda::Score.new do
|
|
62
62
|
v3 r8 s{ notes.each { absolute _1, '16' } }*2
|
63
63
|
end * 2
|
64
64
|
end
|
65
|
-
|
65
|
+
raw <<~ENDING
|
66
66
|
V1:
|
67
67
|
o2 c1 | c1 | c1~1s
|
68
68
|
V2:
|
data/examples/clapping_music.rb
CHANGED
data/examples/dot_accessor.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'alda-rb'
|
4
|
+
|
5
|
+
Alda::Score.new do
|
6
|
+
piano_
|
7
|
+
c8
|
8
|
+
pppppp; d
|
9
|
+
ppppp; e
|
10
|
+
pppp; f
|
11
|
+
ppp; g
|
12
|
+
l :pp; a
|
13
|
+
l :p; b
|
14
|
+
mp; o! c
|
15
|
+
mf; o? b
|
16
|
+
l :f; a
|
17
|
+
ff; g
|
18
|
+
fff; f
|
19
|
+
ffff; e
|
20
|
+
fffff; d
|
21
|
+
ffffff; c4
|
22
|
+
end.play
|
data/examples/entropy.rb
CHANGED
@@ -13,8 +13,8 @@ Alda::Score.new do
|
|
13
13
|
if rand < REST_RATE
|
14
14
|
pause ms.()
|
15
15
|
octave rand OCTAVE_UPPER
|
16
|
-
note pitch('abcdefg'[rand 7].to_sym,
|
17
|
-
%i[sharp flat natural].sample), ms.()
|
16
|
+
note pitch(['abcdefg'[rand 7].to_sym,
|
17
|
+
%i[sharp flat natural].sample]), ms.()
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/examples/hanon.rb
CHANGED
@@ -22,8 +22,8 @@ end
|
|
22
22
|
|
23
23
|
class Alda::Sequence
|
24
24
|
def play_solfege solfege
|
25
|
-
v1; octave solfege.octave; note pitch solfege.letter
|
26
|
-
v2; octave solfege.octave-1; note pitch solfege.letter
|
25
|
+
v1; octave solfege.octave; note pitch [solfege.letter]
|
26
|
+
v2; octave solfege.octave-1; note pitch [solfege.letter]
|
27
27
|
end
|
28
28
|
def play_hanon ary, octave, delta
|
29
29
|
solfeges = ary.map { Solfege.new _1, octave }
|