synth_blocks 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/synth_blocks/mod/adsr.rb +9 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9e4c687fc841d59a5e910589e7cd8d584ad84bc6079ef508a02969afb547690
4
- data.tar.gz: 7f3e2170fb0559f07b151784b16e835f032d10ab397b49ebc7477d5026aef3c4
3
+ metadata.gz: 7b48b18ff126e75f9b5cf3eedf13a9c7b3d80d09c2d2daa35366143ac57ee319
4
+ data.tar.gz: f092bdb9ce66e45f45217839c7c3bec68c0778a78956f0738841e1ce4ce9bc5e
5
5
  SHA512:
6
- metadata.gz: a0a01ec77eb1d4b51ad402f82f3566e2ca9f79d37eb13eb27d5c9702f077c8c1da06b079afe248d1c710025285ac2db24a0d33e4dd6d43674b58f6a68c1682d5
7
- data.tar.gz: fe8407848935beac13adb2f90a01a38762ebd0692d2f1265f1e24ff7813d0534c030ed58756ae81e092d8a3165cbbf7c82784608defda93bcaef3bfc16b3ed50
6
+ metadata.gz: 560831bb8cf63cf5532d16e89653982fdebd0af5393a3910ef139cfc6b068517fe89a33a1fc33ecdf0bbda643c0fc90184331c256ef4cc45067d19fe2368e5a7
7
+ data.tar.gz: 294b32b51dc7a6c1430b38d0b3ac1ab03e1c7fc18191e9ddb420ec1fed2f6d08bd91b209b1e3a5484b32228fa4ead1406598271e41dc2831c077071fa6b0e913
@@ -56,26 +56,26 @@ module SynthBlocks
56
56
  return @value = sustain
57
57
  end
58
58
  else # release
59
- if t <= attack # when released in attack phase
59
+ if released <= attack # when released in attack phase
60
60
  attack_level = linear(@start_value, 1, attack, released)
61
- return linear(attack_level, 0, release, t - released)
61
+ return [linear(attack_level, 0, release, t - released), 0].max
62
62
  end
63
- if t > attack && t < attack_decay # when released in decay phase
63
+ if released > attack && released <= attack_decay # when released in decay phase
64
64
  decay_level = linear(1.0, sustain, decay, released - attack)
65
- return @value = linear(decay_level, 0, release, t - released)
65
+ return @value = [linear(decay_level, 0, release, t - released), 0].max
66
66
  end
67
- if t >= attack_decay && t < released + release # normal release
68
- return @value = linear(sustain, 0, release, t - released)
69
- end
70
- if t >= released + release # after release
71
- return @value = 0.0
67
+ if released > attack_decay # normal release
68
+ return @value = [linear(sustain, 0, release, t - released), 0].max
72
69
  end
73
70
  end
71
+ 0.0
74
72
  end
75
73
 
76
74
  private
77
75
 
78
76
  def linear(start, target, length, time)
77
+ return start if time == 0
78
+ return target if length == 0
79
79
  (target - start) / length * time + start
80
80
  end
81
81
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synth_blocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Krutisch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-04 00:00:00.000000000 Z
11
+ date: 2020-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest