musa-dsl 0.26.8 → 0.26.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1598e463290a813acd81f7d4c2a380c2b4f904c266505efb1c0c76295a2e891
4
- data.tar.gz: 7b6c53ec4109d923f6aab5a1c250672b87a0c1bcc275c0e3359e769b01dd9371
3
+ metadata.gz: ae2aa7f3e4406ef09886be36604113bb854d1f92c985a6e6bfda534520939652
4
+ data.tar.gz: 3e7ca1f99dc0dee8b2a2969a19807b9b6902caed27d94278503536d4787a664d
5
5
  SHA512:
6
- metadata.gz: 8178a6d752685d3ae592c1e80374b85cba4f59ffdcc556d358d1f0c9a2787812421a74c6c247b890b80e05bf221ce3b490a60d2201361041419b0ca4e42f93cc
7
- data.tar.gz: bfd208048b17a2e4f5374eedda0bd5dd5b2d6eb7268a867c63523477da6170f2a7a340d2dca8ab719467c58efd9662fed221118301d3d321c8176cb9785f380b
6
+ metadata.gz: 7b9d8fc55338beb1dbcb3b78e44738ecf5a51e478d75a8f2fb18f51e52c63e3038b6ffc05304aec34297097795e6e14adbe2055ac0267d2aa7a94ada8cb71d57
7
+ data.tar.gz: '098e5f968aad5bbd2eff7a7ed3c268c9411db65952be5824d02af06147ab00a185bb3d4eeff0a23e8ce8648919c400b9891393d2e19426c215fd102467fb7364'
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
  gem 'rubocop', group: 'development'
5
- gem 'rubocop', group: 'development'
6
- gem 'rubocop', group: 'development'
@@ -6,7 +6,7 @@ module Musa::Neumas
6
6
  def initialize(scale, base_duration: nil, transcriptor: nil, base: nil)
7
7
  @base_duration = base_duration
8
8
  @base_duration ||= base[:duration] if base
9
- @base_duration ||= Rational(1,4)
9
+ @base_duration ||= Rational(1, 4)
10
10
 
11
11
  base ||= { grade: 0, octave: 0, duration: @base_duration, velocity: 1 }
12
12
 
@@ -123,6 +123,8 @@ module Musa
123
123
  "trying to print a message in MusaLCE but the client is not connected. Ignoring message \'#{message} \'."
124
124
  end
125
125
  end
126
+
127
+ nil
126
128
  end
127
129
 
128
130
  private
@@ -202,8 +202,8 @@ module Musa
202
202
  end
203
203
 
204
204
  def eval_command(block, value_parameters, key_parameters)
205
- _value_parameters = value_parameters ? value_parameters.collect { |e| subcontext.eval_element(e) } : []
206
- _key_parameters = key_parameters ? key_parameters.transform_values { |e| subcontext.eval_element(e) } : {}
205
+ _value_parameters = value_parameters&.collect { |e| subcontext.eval_element(e) } || []
206
+ _key_parameters = key_parameters&.transform_values { |e| subcontext.eval_element(e) } || {}
207
207
 
208
208
  # used instance_exec because the code on block comes from a neumalang source, so the correct
209
209
  # execution context is the neumalang context (no other context has any sense)
@@ -37,7 +37,7 @@ module Musa
37
37
  end
38
38
 
39
39
  private def _reset_timing
40
- @position = @position_mutex.synchronize { 1r - @tick_duration }
40
+ @position = @position_mutex.synchronize { 1r + @offset - @tick_duration }
41
41
  end
42
42
 
43
43
  private def _quantize_position(position, warn: true)
@@ -13,11 +13,13 @@ module Musa
13
13
  module Sequencer
14
14
  class BaseSequencer
15
15
  attr_reader :beats_per_bar, :ticks_per_beat
16
+ attr_reader :offset
16
17
  attr_reader :running_position
17
18
  attr_reader :everying, :playing, :moving
18
19
  attr_reader :logger
19
20
 
20
21
  def initialize(beats_per_bar = nil, ticks_per_beat = nil,
22
+ offset: nil,
21
23
  logger: nil,
22
24
  do_log: nil, do_error_log: nil, log_position_format: nil)
23
25
 
@@ -35,6 +37,8 @@ module Musa
35
37
  @logger.debug! if do_log
36
38
  end
37
39
 
40
+ @offset = offset || 0r
41
+
38
42
  if beats_per_bar && ticks_per_beat
39
43
  @beats_per_bar = Rational(beats_per_bar)
40
44
  @ticks_per_beat = Rational(ticks_per_beat)
@@ -9,6 +9,7 @@ module Musa
9
9
 
10
10
  def_delegators :@sequencer,
11
11
  :beats_per_bar, :ticks_per_beat, :ticks_per_bar, :tick_duration,
12
+ :offset,
12
13
  :size, :empty?,
13
14
  :on_debug_at, :on_error, :on_fast_forward, :before_tick,
14
15
  :raw_at,
@@ -25,6 +26,7 @@ module Musa
25
26
 
26
27
  def initialize(beats_per_bar = nil,
27
28
  ticks_per_beat = nil,
29
+ offset: nil,
28
30
  sequencer: nil,
29
31
  logger: nil,
30
32
  do_log: nil, do_error_log: nil, log_position_format: nil,
@@ -34,6 +36,7 @@ module Musa
34
36
 
35
37
  @sequencer = sequencer
36
38
  @sequencer ||= BaseSequencer.new beats_per_bar, ticks_per_beat,
39
+ offset: offset,
37
40
  logger: logger,
38
41
  do_log: do_log,
39
42
  do_error_log: do_error_log,
@@ -39,7 +39,7 @@ module Musa
39
39
  def eval_condition
40
40
  if @ticks
41
41
  @ticks -= 1
42
- @ticks > 0
42
+ @ticks.positive?
43
43
  else
44
44
  @block.call
45
45
  end
@@ -12,6 +12,7 @@ module Musa
12
12
  def initialize(clock,
13
13
  beats_per_bar = nil,
14
14
  ticks_per_beat = nil,
15
+ offset: nil,
15
16
  sequencer: nil,
16
17
  before_begin: nil,
17
18
  on_start: nil,
@@ -22,6 +23,8 @@ module Musa
22
23
 
23
24
  beats_per_bar ||= 4
24
25
  ticks_per_beat ||= 24
26
+ offset ||= 0r
27
+
25
28
  do_log ||= false
26
29
 
27
30
  @clock = clock
@@ -41,7 +44,7 @@ module Musa
41
44
  @do_log = do_log
42
45
 
43
46
  @sequencer = sequencer
44
- @sequencer ||= Musa::Sequencer::Sequencer.new beats_per_bar, ticks_per_beat, logger: logger, do_log: @do_log
47
+ @sequencer ||= Musa::Sequencer::Sequencer.new beats_per_bar, ticks_per_beat, offset: offset, logger: logger, do_log: @do_log
45
48
 
46
49
  @clock.on_start do
47
50
  do_on_start
@@ -91,6 +94,7 @@ module Musa
91
94
  position += Rational(midi_beats, 4 * @sequencer.beats_per_bar) if midi_beats
92
95
  position += Rational(beats, @sequencer.beats_per_bar) if beats
93
96
 
97
+ position += @sequencer.offset
94
98
  position -= @sequencer.tick_duration
95
99
 
96
100
  raise ArgumentError, "undefined new position" unless position
data/lib/musa-dsl.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Musa
2
- VERSION = '0.26.8'.freeze
2
+ VERSION = '0.26.10'.freeze
3
3
  end
4
4
 
5
5
  require_relative 'musa-dsl/core-ext'
data/musa-dsl.gemspec CHANGED
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'musa-dsl'
3
- s.version = '0.26.8'
4
- s.date = '2023-05-30'
3
+ s.version = '0.26.10'
4
+ s.date = '2023-10-30'
5
5
  s.summary = 'A simple Ruby DSL for making complex music'
6
6
  s.description = 'Musa-DSL: A Ruby framework and DSL for algorithmic sound and musical thinking and composition'
7
7
  s.authors = ['Javier Sánchez Yeste']
8
8
  s.email = 'javier.sy@gmail.com'
9
- s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|samples)/}) }
9
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|samples|\.github)/}) }
10
10
  s.homepage = 'https://github.com/javier-sy/musa-dsl'
11
11
  s.license = 'LGPL-3.0'
12
12
 
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.26.8
4
+ version: 0.26.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Sánchez Yeste
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-30 00:00:00.000000000 Z
11
+ date: 2023-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger
@@ -125,7 +125,6 @@ executables: []
125
125
  extensions: []
126
126
  extra_rdoc_files: []
127
127
  files:
128
- - ".github/workflows/gem-test-and-push.yml"
129
128
  - ".gitignore"
130
129
  - Gemfile
131
130
  - LICENSE.md
@@ -255,7 +254,7 @@ homepage: https://github.com/javier-sy/musa-dsl
255
254
  licenses:
256
255
  - LGPL-3.0
257
256
  metadata: {}
258
- post_install_message:
257
+ post_install_message:
259
258
  rdoc_options: []
260
259
  require_paths:
261
260
  - lib
@@ -271,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
270
  version: '0'
272
271
  requirements: []
273
272
  rubygems_version: 3.1.6
274
- signing_key:
273
+ signing_key:
275
274
  specification_version: 4
276
275
  summary: A simple Ruby DSL for making complex music
277
276
  test_files: []
@@ -1,48 +0,0 @@
1
- name: Generate gem and push to rubygems repository
2
-
3
- on:
4
- push:
5
- branches: [ master ]
6
- pull_request:
7
- branches: [ master ]
8
-
9
- jobs:
10
- test:
11
- runs-on: ubuntu-latest
12
- strategy:
13
- matrix:
14
- ruby-version: ['2.7.8']
15
-
16
- steps:
17
- - uses: actions/checkout@v2
18
- - name: Set up Ruby
19
- uses: ruby/setup-ruby@v1
20
- with:
21
- ruby-version: ${{ matrix.ruby-version }}
22
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
23
- - name: Run tests
24
- run: bundle exec rspec -t \~slow
25
-
26
- build:
27
- name: Build + Publish
28
- runs-on: ubuntu-latest
29
- needs: test
30
- permissions:
31
- contents: read
32
- packages: write
33
-
34
- steps:
35
- - uses: actions/checkout@v3
36
- - name: Set up Ruby 2.7.8
37
- uses: ruby/setup-ruby@v1
38
- with:
39
- ruby-version: 2.7.8
40
-
41
- - name: Publish to RubyGems
42
- run: |
43
- mkdir -p $HOME/.gem
44
- touch $HOME/.gem/credentials
45
- chmod 0600 $HOME/.gem/credentials
46
- printf -- "---\n:rubygems_api_key: ${{secrets.GEM_HOST_API_KEY}}\n" > $HOME/.gem/credentials
47
- gem build *.gemspec
48
- gem push *.gem