musa-dsl 0.14.31 → 0.14.32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0d0e02c2e0316db71806cd4a1370c6f7488d074c7f0c56f9debefa68e041d14
4
- data.tar.gz: 4d6e5c5f7dcd225ed5cb4f2f01129fa12a15be16253f5bfcb8cedf07c1bb6296
3
+ metadata.gz: 38849caa61ab0d2381beb2b3dfc85686c9b7592b027dfd5a4f1f3aadae60ae7d
4
+ data.tar.gz: cdea129555d1bba7a5933cf71a522852463196a27fdca1ac39e10d8d0aca2dcb
5
5
  SHA512:
6
- metadata.gz: d7872920c8d0b01d28ea8359a7bccb84937820dcb1ce4cb98a158c351ac46f9e5a802d5986b6e7b584f3c527dd9be65e2df75d31dc5fa7394296dc2123ed4b5d
7
- data.tar.gz: a2dae59c40f1e713593a691e93ba989ee3aed3fe176b7da81e01aec579db83afc1c91d082c2915150249ab55a124c5f45f15fc99f506cc1cbdc3fb6a5d237d83
6
+ metadata.gz: 9ae1524d885d66a1d6dc5e1cb4d88e17d069e38cd6a98c3ce8fe4131b2fb2e2df09490e3e2fbcb657a6e35a6ce27f363734e742393d10af5300502262b8d44a1
7
+ data.tar.gz: 7b8186dd41f7243f2b1b168929a845efa93a6028c13ff286628b505de7515cb91b4c4861c89c1a1759ab9fb3512bb042b0e20821ff300458e9fec671b9304975
@@ -333,9 +333,11 @@ class Musa::BaseSequencer
333
333
  nil
334
334
  end
335
335
 
336
- def _move(every: nil, from:, to: nil, step: nil, duration: nil, till: nil, right_open: nil, on_stop: nil, after_bars: nil, after: nil, &block)
336
+ def _move(every: nil, from:, to: nil, step: nil, duration: nil, till: nil, function: nil, right_open: nil, on_stop: nil, after_bars: nil, after: nil, &block)
337
337
 
338
338
  raise ArgumentError, "Cannot use duration: #{duration} and till: #{till} parameters at the same time. Use only one of them." if till && duration
339
+ raise ArgumentError, "Invalid use: 'function:' parameter is incompatible with 'step:' parameter" if function && step
340
+ raise ArgumentError, "Invalid use: 'function:' parameter needs 'to:' parameter not nil" if function && !to
339
341
 
340
342
  # from, to, step, every
341
343
  # from, to, step, (duration | till)
@@ -347,6 +349,10 @@ class Musa::BaseSequencer
347
349
  step = -step if step && to && ((step > 0 && to < from) || (step < 0 && from < to))
348
350
  right_open ||= false
349
351
 
352
+ function ||= proc { |ratio| ratio }
353
+ function_range = 1r
354
+ function_offset = 0r
355
+
350
356
  start_position = position
351
357
 
352
358
  if duration || till
@@ -358,12 +364,24 @@ class Musa::BaseSequencer
358
364
  every = Rational(effective_duration, steps + right_open_offset)
359
365
 
360
366
  elsif to && !step && !every
361
- step = (to - from) / (effective_duration * @ticks_per_bar - right_open_offset)
367
+ function_range = to - from
368
+ function_offset = from
369
+
370
+ from = 0r
371
+ to = 1r
372
+
373
+ step = 1r / (effective_duration * @ticks_per_bar - right_open_offset)
362
374
  every = @tick_duration
363
375
 
364
376
  elsif to && !step && every
377
+ function_range = to - from
378
+ function_offset = from
379
+
380
+ from = 0r
381
+ to = 1r
382
+
365
383
  steps = effective_duration / every
366
- step = (to - from) / (steps - right_open_offset)
384
+ step = 1r / (steps - right_open_offset)
367
385
 
368
386
  elsif !to && step && every
369
387
  # ok
@@ -383,7 +401,6 @@ class Musa::BaseSequencer
383
401
  end
384
402
  end
385
403
 
386
-
387
404
  binder = KeyParametersProcedureBinder.new(block)
388
405
 
389
406
  every_control = EveryControl.new(@event_handlers.last, capture_stdout: true, duration: duration, till: till, on_stop: on_stop, after_bars: after_bars, after: after)
@@ -399,7 +416,7 @@ class Musa::BaseSequencer
399
416
 
400
417
  parameters = binder.apply(control: control)
401
418
 
402
- yield value, **parameters
419
+ yield function.call(value) * function_range + function_offset, **parameters
403
420
 
404
421
  if to && (value >= to && step.positive? || value <= to && step.negative?)
405
422
  control.stop
@@ -227,8 +227,8 @@ class Musa::BaseSequencer
227
227
  control
228
228
  end
229
229
 
230
- def move(every: nil, from: nil, to: nil, step: nil, duration: nil, till: nil, right_open: nil, on_stop: nil, after_bars: nil, after: nil, &block)
231
- control = _move every: every, from: from, to: to, step: step, duration: duration, till: till, right_open: right_open, on_stop: on_stop, after_bars: after_bars, after: after, &block
230
+ def move(every: nil, from: nil, to: nil, step: nil, duration: nil, till: nil, function: nil, right_open: nil, on_stop: nil, after_bars: nil, after: nil, &block)
231
+ control = _move every: every, from: from, to: to, step: step, duration: duration, till: till, function: function, right_open: right_open, on_stop: on_stop, after_bars: after_bars, after: after, &block
232
232
 
233
233
  @moving << control
234
234
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'musa-dsl'
3
- s.version = '0.14.31'
4
- s.date = '2019-10-03'
3
+ s.version = '0.14.32'
4
+ s.date = '2019-10-05'
5
5
  s.summary = 'A simple Ruby DSL for making complex music'
6
6
  s.description = 'Musa-DSL: A Ruby DSL for algorithmic music composition, device language neutral (MIDI, OSC, etc)'
7
7
  s.authors = ['Javier Sánchez Yeste']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: musa-dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.31
4
+ version: 0.14.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Sánchez Yeste
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-03 00:00:00.000000000 Z
11
+ date: 2019-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: citrus