musa-dsl 0.26.1 → 0.26.2

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: 7c2f6d36cc5f3c4693e45e47e82ea57a8a7cb12cd3e4e8566a33c8b1be198417
4
- data.tar.gz: b392ad73c0097ac15f3b66140e43c19859aaece1f5a0dd9612e3a2d7bbd188fd
3
+ metadata.gz: f7f400c1a2c9841fc229ddb34343788eb688c4ab627e3f5ad8d4bcb57bd9ab90
4
+ data.tar.gz: f0a0bf769dc19d17fc54818f83ca92174b223a503fb1f5145b996ac743bc0a1a
5
5
  SHA512:
6
- metadata.gz: e801b2e5190aa4364679b472ffb34f68643a12f86d685942debf09ab38f651712d724e2ad215f1177657a34cbc2c673d77ff5cea4a24433966a97339e2df3120
7
- data.tar.gz: 875ee51602f569b4c823ccce5efdac7fb67696ee5b0b205a69b93ced1c12768c8828be846e91dca77ec4ae49bfbb3726946b99af7fb5fba136ed23c584d5d6d0
6
+ metadata.gz: d35323bf0ef3686f839fcbdc4683fe3c7a05e9de99b4fab7a365f55576fd125704b52833bbea89bfae11db3c70d9d34a2fb2a2400252bd6fedf1d881483000ce
7
+ data.tar.gz: bf02e13897e2441ce2d48c82a0ac9d1a2ba25ba244a22597597232710fb18efd688c8f5228fa94ef8956f9fea9818725c251d122dfe05086d4e745e1c745538c
@@ -16,16 +16,20 @@ module Musa::Datasets
16
16
 
17
17
  attr_accessor :base_duration
18
18
 
19
+ # TODO create a customizable MIDI velocity to score dynamics bidirectional conversor
20
+ # ppp = 16 ... fff = 127 (-5 ... 4) the standard used by Musescore 3 and others starts at ppp = 16
21
+ VELOCITY_MAP = [1, 8, 16, 33, 49, 64, 80, 96, 112, 127].freeze
22
+
19
23
  def to_pdv(scale)
20
24
  pdv = {}.extend PDV
21
25
  pdv.base_duration = @base_duration
22
26
 
23
27
  if self[:grade]
24
28
  pdv[:pitch] = if self[:silence]
25
- :silence
26
- else
27
- scale[self[:grade]].sharp(self[:sharps] || 0).octave(self[:octave] || 0).pitch
28
- end
29
+ :silence
30
+ else
31
+ scale[self[:grade]].sharp(self[:sharps] || 0).octave(self[:octave] || 0).pitch
32
+ end
29
33
  end
30
34
 
31
35
  if self[:duration]
@@ -41,9 +45,19 @@ module Musa::Datasets
41
45
  end
42
46
 
43
47
  if self[:velocity]
44
- # ppp = 16 ... fff = 127 (-5 ... 4) the standard used by Musescore 3 and others starts at ppp = 16
45
- # TODO create a customizable MIDI velocity to score dynamics bidirectional conversor
46
- pdv[:velocity] = [1, 8, 16, 33, 49, 64, 80, 96, 112, 127][self[:velocity] + 5]
48
+ index = if (-5..4).cover?(self[:velocity])
49
+ self[:velocity]
50
+ else
51
+ self[:velocity] < -5 ? -5 : 4
52
+ end
53
+
54
+ index_min = index.floor
55
+ index_max = index.ceil
56
+
57
+ velocity = VELOCITY_MAP[index_min + 5] +
58
+ (VELOCITY_MAP[index_max + 5] - VELOCITY_MAP[index_min + 5]) * (self[:velocity] - index_min)
59
+
60
+ pdv[:velocity] = velocity
47
61
  end
48
62
 
49
63
  (keys - NaturalKeys).each { |k| pdv[k] = self[k] }
@@ -52,7 +66,7 @@ module Musa::Datasets
52
66
  end
53
67
 
54
68
  def to_neuma
55
- @base_duration ||= Rational(1,4)
69
+ @base_duration ||= Rational(1, 4)
56
70
 
57
71
  attributes = []
58
72
 
data/lib/musa-dsl.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Musa
2
- VERSION = '0.26.1'.freeze
2
+ VERSION = '0.26.2'.freeze
3
3
  end
4
4
 
5
5
  require_relative 'musa-dsl/core-ext'
data/musa-dsl.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'musa-dsl'
3
- s.version = '0.26.1'
4
- s.date = '2021-11-23'
3
+ s.version = '0.26.2'
4
+ s.date = '2021-11-25'
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']
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.1
4
+ version: 0.26.2
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: 2021-11-23 00:00:00.000000000 Z
11
+ date: 2021-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger