sonic-pi-akai-apc-mini 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +45 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +26 -16
- data/README.md +14 -8
- data/init_dev.rb +2 -2
- data/lib/sonic-pi-akai-apc-mini/api.rb +23 -13
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e22ca44cac58f96c92d2685b033e3bbb8ace73a5dd575122b2d4c87225f1cd0
|
4
|
+
data.tar.gz: f2273913fb975c228dcfeaec78688d5f2a01796923e16b8742831a8a3ca41511
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dce12edb6302ba1684359557cc7b58762ad170be9f6e4f01d5e714d4e42d331c6d43809840c6a0879cd6d2db03bb719ae8434ca8f34fded24d9c20c36dd9be2
|
7
|
+
data.tar.gz: 51a3b9d32f674ece955a83f420ae1a3bb0b61527169a59a8a3d23f5df26d4655311357d9350be2073243130764d5e43419a22fe72a4106935e1c7867ea145701
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [0.3.0] - 2022-02-10
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- This CHANGELOG ;)
|
15
|
+
- `set_fader` method
|
16
|
+
|
17
|
+
### Other
|
18
|
+
|
19
|
+
- Integration specs for fader related methods
|
20
|
+
|
21
|
+
## [0.2.0] - 2022-01-29
|
22
|
+
|
23
|
+
### Added
|
24
|
+
|
25
|
+
- Experimental support for APC Key 25
|
26
|
+
- `example.rb`
|
27
|
+
|
28
|
+
### Changed
|
29
|
+
|
30
|
+
- The `initialize_akai` method now requires the model name (`:apc_mini` or
|
31
|
+
`:apc_key_25`) as argument.
|
32
|
+
|
33
|
+
### Other
|
34
|
+
|
35
|
+
- `init_dev.rb` helper to work on development
|
36
|
+
- Some unit specs (grid mapping logic)
|
37
|
+
|
38
|
+
## [0.1.0] - 2022-01-09
|
39
|
+
|
40
|
+
Initial release.
|
41
|
+
|
42
|
+
[unreleased]: https://github.com/porras/sonic-pi-akai-apc-mini/compare/v0.3.0...HEAD
|
43
|
+
[0.3.0]: https://github.com/porras/sonic-pi-akai-apc-mini/compare/v0.2.0...v0.3.0
|
44
|
+
[0.2.0]: https://github.com/porras/sonic-pi-akai-apc-mini/compare/v0.1.0...v0.2.0
|
45
|
+
[0.1.0]: https://github.com/porras/sonic-pi-akai-apc-mini/releases/tag/v0.1.0
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,36 +1,38 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sonic-pi-akai-apc-mini (0.
|
4
|
+
sonic-pi-akai-apc-mini (0.3.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ast (2.4.2)
|
10
|
+
byebug (11.1.3)
|
10
11
|
diff-lcs (1.5.0)
|
12
|
+
docile (1.4.0)
|
11
13
|
parallel (1.21.0)
|
12
14
|
parser (3.1.0.0)
|
13
15
|
ast (~> 2.4.1)
|
14
|
-
rainbow (3.
|
16
|
+
rainbow (3.1.1)
|
15
17
|
rake (13.0.6)
|
16
18
|
regexp_parser (2.2.0)
|
17
19
|
rexml (3.2.5)
|
18
|
-
rspec (3.
|
19
|
-
rspec-core (~> 3.
|
20
|
-
rspec-expectations (~> 3.
|
21
|
-
rspec-mocks (~> 3.
|
22
|
-
rspec-core (3.
|
23
|
-
rspec-support (~> 3.
|
24
|
-
rspec-expectations (3.
|
20
|
+
rspec (3.11.0)
|
21
|
+
rspec-core (~> 3.11.0)
|
22
|
+
rspec-expectations (~> 3.11.0)
|
23
|
+
rspec-mocks (~> 3.11.0)
|
24
|
+
rspec-core (3.11.0)
|
25
|
+
rspec-support (~> 3.11.0)
|
26
|
+
rspec-expectations (3.11.0)
|
25
27
|
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
-
rspec-support (~> 3.
|
27
|
-
rspec-mocks (3.
|
28
|
+
rspec-support (~> 3.11.0)
|
29
|
+
rspec-mocks (3.11.0)
|
28
30
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
-
rspec-support (~> 3.
|
30
|
-
rspec-support (3.
|
31
|
-
rubocop (1.
|
31
|
+
rspec-support (~> 3.11.0)
|
32
|
+
rspec-support (3.11.0)
|
33
|
+
rubocop (1.25.1)
|
32
34
|
parallel (~> 1.10)
|
33
|
-
parser (>= 3.
|
35
|
+
parser (>= 3.1.0.0)
|
34
36
|
rainbow (>= 2.2.2, < 4.0)
|
35
37
|
regexp_parser (>= 1.8, < 3.0)
|
36
38
|
rexml
|
@@ -41,20 +43,28 @@ GEM
|
|
41
43
|
parser (>= 3.0.1.1)
|
42
44
|
rubocop-rake (0.6.0)
|
43
45
|
rubocop (~> 1.0)
|
44
|
-
rubocop-rspec (2.
|
46
|
+
rubocop-rspec (2.8.0)
|
45
47
|
rubocop (~> 1.19)
|
46
48
|
ruby-progressbar (1.11.0)
|
49
|
+
simplecov (0.21.2)
|
50
|
+
docile (~> 1.1)
|
51
|
+
simplecov-html (~> 0.11)
|
52
|
+
simplecov_json_formatter (~> 0.1)
|
53
|
+
simplecov-html (0.12.3)
|
54
|
+
simplecov_json_formatter (0.1.3)
|
47
55
|
unicode-display_width (2.1.0)
|
48
56
|
|
49
57
|
PLATFORMS
|
50
58
|
x86_64-linux
|
51
59
|
|
52
60
|
DEPENDENCIES
|
61
|
+
byebug
|
53
62
|
rake
|
54
63
|
rspec
|
55
64
|
rubocop
|
56
65
|
rubocop-rake
|
57
66
|
rubocop-rspec
|
67
|
+
simplecov
|
58
68
|
sonic-pi-akai-apc-mini!
|
59
69
|
|
60
70
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -71,7 +71,7 @@ Finally, it is possible to use the same fader for two different things, with two
|
|
71
71
|
play :c4, amp: fader(0, (0.8..1.5)), pan: fader(0, :pan)
|
72
72
|
```
|
73
73
|
|
74
|
-
\*In
|
74
|
+
\*In reality, `(0..0.999)`. The reason is that there are many parameters with range [0, 1), that is, between 0 and 1 but **not** 1, for example a synth's `res` (resonance). This weird default helps with this case while making no difference for the normal case. If you **really** need to be able to get to 1, then pass `(0..1)` explicitly.
|
75
75
|
|
76
76
|
#### `attach_fader(n, node, property, [target-values])`
|
77
77
|
|
@@ -94,20 +94,28 @@ live_loop :drums do
|
|
94
94
|
end
|
95
95
|
```
|
96
96
|
|
97
|
-
In this case, at the moment it is not possible to attach the same fader to two different controls. But you can combine **one** `attach_fader` with as many `fader` as you want.
|
98
|
-
|
99
97
|
`attach_fader` uses `control` under the hood, which means:
|
100
98
|
|
101
99
|
* The property needs to be one that can be changed while the sound is playing. Refer to the documentation of each synth and fx.
|
102
100
|
* It will be affected by the corresponding `_slide` options. It could be said that _it doesn't play very well with any non-zero value in the corresponding `_slide` option_, but in reality pretty cool effects can be created by mixing them.
|
103
101
|
|
104
|
-
####
|
102
|
+
#### `set_fader(n, [target-values]) { |value| ... }`
|
103
|
+
|
104
|
+
There is another variant, lower level, which can be used for anything, but the most typical use case is to connect the fader to some general option like `set_volume!` or `set_mixer_control!`.
|
105
105
|
|
106
|
-
|
106
|
+
```
|
107
|
+
set_fader(8) { |v| set_volume! v }
|
108
|
+
```
|
109
|
+
|
110
|
+
#### Important notes about faders
|
111
|
+
|
112
|
+
1. Because MIDI works with events, it is not possible for Sonic Pi to know the initial position of a fader until it is moved and its new value is sent. Until then, it is assumed it is set to zero. So, two little advices:
|
107
113
|
|
108
114
|
* Start your performances with the faders physically set to zero, to match that assumption. Move them to the desired position _before_ evaluating the code that will read them.
|
109
115
|
* The lights above the faders are used as a hint to avoid this problem: they will be off when Sonic Pi _thinks_ they're set at zero, and on when it _thinks_ they're set at non-zero. If you see a fader physically not at zero but with the light off, move it slightly, so that Sonic Pi learns where it is :)
|
110
116
|
|
117
|
+
2. At the moment it is not possible to apply `attach_fader`/`set_fader` to the same fader twice (the second definition _wins_). But you can combine **one** `attach_fader`/`set_fader` with as many `fader` as you want.
|
118
|
+
|
111
119
|
### Switches
|
112
120
|
|
113
121
|
Each button in the grid can be used as a boolean switch, for any purpose (typically, triggering a sound or not). You could use a fader to map `amp` (and set it to zero when you don't want to hear it), but faders are scarce and there are 64 buttons in the grid :)
|
@@ -224,9 +232,7 @@ If you want to remove a free play mapping (so that the buttons are again availab
|
|
224
232
|
|
225
233
|
* A `selector` that actually works
|
226
234
|
* Free play with samples
|
227
|
-
*
|
228
|
-
* Using it to control the mixer (`set_mixer_control!`, etc.)
|
229
|
-
* Attaching the same fader to different nodes, or different properties of the same node
|
235
|
+
* Make it possible to attach/set the same fader more than once
|
230
236
|
* Better performance and stability in general
|
231
237
|
|
232
238
|
## Contributing
|
data/init_dev.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# Script to be used in development. Instead of `require '.../init
|
2
|
-
#
|
1
|
+
# Script to be used in development. Instead of `require '.../init'` from
|
2
|
+
# SonicPi, `load '.../init_dev.rb'` and code will be reloaded on each Alt+R.
|
3
3
|
|
4
4
|
dir = File.join(__dir__, 'lib', 'sonic-pi-akai-apc-mini')
|
5
5
|
|
@@ -8,7 +8,9 @@ module SonicPiAkaiApcMini
|
|
8
8
|
# [0,1) as range and throw an error when passed 1 (e.g. tb303 synth's res).
|
9
9
|
# It's not the most common usecase, but for the common use case it makes no
|
10
10
|
# difference so I think it's a good default.
|
11
|
-
|
11
|
+
DEFAULT_TARGET = (0..0.999).freeze
|
12
|
+
|
13
|
+
def fader(n, target = DEFAULT_TARGET)
|
12
14
|
# TODO: Try to optimize speed, there is some latency because the
|
13
15
|
# controller send a lot of events (too much granularity). It is in theory
|
14
16
|
# possible to save some of it by `get`ting the value directly instead of
|
@@ -17,9 +19,21 @@ module SonicPiAkaiApcMini
|
|
17
19
|
Helpers.normalize(value, target)
|
18
20
|
end
|
19
21
|
|
20
|
-
def attach_fader(n, node, property, target =
|
21
|
-
|
22
|
-
|
22
|
+
def attach_fader(n, node, property, target = DEFAULT_TARGET)
|
23
|
+
set_fader(n, target) do |value|
|
24
|
+
control node, property => value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_fader(n, target = DEFAULT_TARGET, &block)
|
29
|
+
# first we just call the block with the current value, or 0
|
30
|
+
block.call(Helpers.normalize(get("fader_#{n}", 0), target))
|
31
|
+
# and set a loop that will cal it again on every change
|
32
|
+
live_loop "global_fader_#{n}" do
|
33
|
+
use_real_time
|
34
|
+
value = sync("fader_#{n}")
|
35
|
+
block.call(Helpers.normalize(value, target))
|
36
|
+
end
|
23
37
|
end
|
24
38
|
|
25
39
|
def loop_rows(duration, rows)
|
@@ -86,16 +100,14 @@ module SonicPiAkaiApcMini
|
|
86
100
|
# and the corresponding light is turned on/off.
|
87
101
|
live_loop :faders do
|
88
102
|
use_real_time
|
89
|
-
|
90
|
-
|
103
|
+
note_number, value = sync(Controller.model.midi_event(:control_change))
|
104
|
+
fader_number = note_number - Controller.model.fader_offset
|
105
|
+
set "fader_#{fader_number}", value
|
91
106
|
if Controller.model.fader_light_offset
|
92
|
-
|
107
|
+
light_note_number = note_number + Controller.model.fader_light_offset
|
108
|
+
midi_note_on light_note_number,
|
93
109
|
value.zero? ? Controller.model.light_off : Controller.model.light_red
|
94
110
|
end
|
95
|
-
if attachment = get("attached_fader_#{n - Controller.model.fader_offset}")
|
96
|
-
normalized_value = Helpers.normalize(value, attachment[:target])
|
97
|
-
control attachment[:node], attachment[:property] => normalized_value
|
98
|
-
end
|
99
111
|
end
|
100
112
|
|
101
113
|
# Manages the buttons in the grid, both as switches, selectors, and to
|
@@ -132,5 +144,3 @@ module SonicPiAkaiApcMini
|
|
132
144
|
end
|
133
145
|
end
|
134
146
|
end
|
135
|
-
|
136
|
-
include SonicPiAkaiApcMini::API
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sonic-pi-akai-apc-mini
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Gil
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -21,6 +21,7 @@ files:
|
|
21
21
|
- ".rspec"
|
22
22
|
- ".rubocop.yml"
|
23
23
|
- ".ruby-version"
|
24
|
+
- CHANGELOG.md
|
24
25
|
- CODE_OF_CONDUCT.md
|
25
26
|
- Gemfile
|
26
27
|
- Gemfile.lock
|