step_sequencer 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +74 -39
- data/bin/step_sequencer +4 -0
- data/lib/step_sequencer/repl.rb +14 -0
- data/lib/step_sequencer/sound_builder/default_effects/combine.rb +1 -1
- data/lib/step_sequencer/sound_builder/default_effects/gain.rb +1 -1
- data/lib/step_sequencer/sound_builder/default_effects/loop.rb +1 -1
- data/lib/step_sequencer/sound_builder/default_effects/overlay.rb +1 -1
- data/lib/step_sequencer/sound_builder/default_effects/pitch.rb +1 -1
- data/lib/step_sequencer/sound_builder/default_effects/slice.rb +1 -1
- data/lib/step_sequencer/sound_builder/default_effects/speed.rb +1 -1
- data/lib/step_sequencer/sound_builder/effects_component_protocol.rb +1 -1
- data/lib/step_sequencer/tests.rb +0 -3
- data/lib/step_sequencer.rb +3 -1
- data/lib/version.rb +1 -1
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35e70912bfa1e7b6f09f3934f4f8937333aeb62e
|
4
|
+
data.tar.gz: 734b86e139fd8d55bb65a94b8db6edadb4e26a56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcf615d12d4924b6b6066a413c714acc08ae94f776d0f4af63617908fb109720f712ea73d996d5071229b7de9c73fb866920d0f8656da91129d7c5cd9ded0a52
|
7
|
+
data.tar.gz: 0e864b28ece6903840a12fec93f38db3de186b7802e504ef46b69e51b666650a6efd9f4daf9b0e8c24c63a632d874adcb0ea87afffd48ffd95a01d680b7a8a23
|
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
## Step Sequencer
|
2
2
|
|
3
|
-
#### About
|
4
|
-
|
5
3
|
This is a Ruby tool to play mp3 files in a step sequencer.
|
6
4
|
|
7
|
-
It also handles polyrhythmic playback and building sounds using effects like
|
5
|
+
It also handles polyrhythmic playback and building sounds using effects like
|
6
|
+
loop, combine, slice, overlay, combine, gain, speed, and pitch
|
7
|
+
|
8
|
+
## Setup
|
8
9
|
|
9
|
-
|
10
|
+
### Dependencies
|
10
11
|
|
11
12
|
Some external programs need to be installed:
|
12
13
|
|
@@ -14,7 +15,7 @@ Some external programs need to be installed:
|
|
14
15
|
|
15
16
|
To run the tests, the program `espeak` is also required.
|
16
17
|
|
17
|
-
|
18
|
+
### Installing
|
18
19
|
|
19
20
|
```sh
|
20
21
|
gem install step_sequencer
|
@@ -24,42 +25,69 @@ gem install step_sequencer
|
|
24
25
|
require 'step_sequencer'
|
25
26
|
```
|
26
27
|
|
27
|
-
|
28
|
+
### Configuration
|
29
|
+
|
30
|
+
The main point of config is to set the location that files are generated to.
|
31
|
+
This program creates a lot of mp3s and doesn't automatically delete any of them.
|
32
|
+
By default, the location is `./.step_sequencer/generated` which is a _relative
|
33
|
+
path_. That means it's dependent on which directory the command was run from.
|
34
|
+
To use an absolute path instead, set the `STEP_SEQUENCER_OUTPUT_DIR` environment
|
35
|
+
variable.
|
36
|
+
|
37
|
+
## REPL
|
38
|
+
|
39
|
+
There is a Ruby-based REPL that ships with the gem.
|
40
|
+
Launch it from shell with:
|
41
|
+
|
42
|
+
```sh
|
43
|
+
step_sequencer repl
|
44
|
+
```
|
45
|
+
|
46
|
+
and type 'help' or 'quit'. It will show the names of some helper functions
|
47
|
+
that have been made available.
|
48
|
+
Still, the REPL assumes familiarity with the underlying Ruby API.
|
49
|
+
|
50
|
+
## Ruby API
|
28
51
|
|
29
52
|
There are two main components: `StepSequencer::SoundBuilder` and
|
30
53
|
`StepSequencer::SoundPlayer`
|
31
54
|
|
32
|
-
|
55
|
+
### StepSequencer::SoundBuilder
|
56
|
+
|
57
|
+
This offers only one public method, `.build`, which is overloaded
|
58
|
+
and dispatches to a number of other classes (each of which is responsible for
|
59
|
+
a single effect).
|
60
|
+
|
61
|
+
_note_
|
33
62
|
|
34
|
-
|
35
|
-
|
36
|
-
a single effect). The definitions of these can be found in the source code at
|
37
|
-
`lib/step_sequencer/sound_builder/default_effects/`. To add a custom effect,
|
38
|
-
use one of the existing ones as a template and then add a reference to the class
|
39
|
-
in the `StepSequencer::SoundBuilder::EffectsComponents` hash.
|
63
|
+
> The definitions of the default effects can be found in the source code at `lib/step_sequencer/sound_builder/default_effects/`. To add a custom effect, use one of the existing ones as a template and then add a reference to the class
|
64
|
+
in the `StepSequencer::SoundBuilder::EffectsComponents` hash.
|
40
65
|
|
41
|
-
Here is an example. It takes a single input mp3 and creates 12 new ones,
|
66
|
+
Here is an example of using the builder. It takes a single input mp3 and creates 12 new ones,
|
42
67
|
spanning the "equal temperament" tuning.
|
43
68
|
|
44
69
|
```rb
|
45
|
-
# returns nested array (array of generated sounds for each source)
|
46
70
|
builder = StepSequencer::SoundBuilder
|
47
71
|
filenames = builder.build(
|
48
72
|
sources: ["middle_c.mp3"],
|
49
73
|
effect: :Scale,
|
50
74
|
args: [{scale: :equal_temperament}]
|
51
|
-
)
|
75
|
+
).first
|
76
|
+
# the :Scale effect returns a nested array (one array for each input source)
|
77
|
+
# so after calling .first, filenames refers to a regular array of 12 file paths.
|
52
78
|
```
|
53
79
|
|
54
80
|
The `:Scale` effect also allows an `inverse: true` key in `args` which will
|
55
81
|
set all pitch change values to their inverse (creating a descending scale).
|
56
82
|
|
83
|
+
Right now there is only the equal temperament option, more may be added later.
|
84
|
+
|
57
85
|
Now say I want to apply a 150% gain to all these files:
|
58
86
|
|
59
87
|
```rb
|
60
88
|
# returns array of paths, one for each source
|
61
|
-
|
62
|
-
sources: filenames
|
89
|
+
filenames = builder.build(
|
90
|
+
sources: filenames
|
63
91
|
effect: :Gain,
|
64
92
|
args: [{value: 1.5}]
|
65
93
|
)
|
@@ -67,20 +95,22 @@ new_filenames = builder.build(
|
|
67
95
|
|
68
96
|
Other builtin effects:
|
69
97
|
|
70
|
-
_change speed_
|
98
|
+
_change speed_
|
71
99
|
|
72
100
|
```rb
|
73
|
-
|
74
|
-
|
101
|
+
# returns array of paths, one for each source
|
102
|
+
filenames = builder.build(
|
103
|
+
sources: filenames,
|
75
104
|
effect: :Speed,
|
76
105
|
args: [{value: 0.5}]
|
77
106
|
)
|
78
107
|
```
|
79
108
|
|
80
|
-
_change pitch_
|
109
|
+
_change pitch_
|
81
110
|
|
82
111
|
```rb
|
83
|
-
|
112
|
+
# returns array of paths, one for each source
|
113
|
+
filenames = builder.build(
|
84
114
|
sources: filenames,
|
85
115
|
effect: :Pitch,
|
86
116
|
args: [{value: 2}]
|
@@ -89,20 +119,22 @@ new_filenames = builder.build(
|
|
89
119
|
# However the `speed_correction: false` arg will prevent this.
|
90
120
|
```
|
91
121
|
|
92
|
-
_loop_
|
122
|
+
_loop_
|
93
123
|
|
94
124
|
```rb
|
95
|
-
|
125
|
+
# returns array of paths, one for each source
|
126
|
+
filenames = builder.build(
|
96
127
|
sources: filenames,
|
97
128
|
effect: :Loop,
|
98
129
|
args: [{times: 1.5}]
|
99
130
|
)
|
100
131
|
```
|
101
132
|
|
102
|
-
_slice_
|
133
|
+
_slice_
|
103
134
|
|
104
135
|
```rb
|
105
|
-
|
136
|
+
# returns array of paths, one for each source
|
137
|
+
filenames = builder.build(
|
106
138
|
sources: filenames,
|
107
139
|
effect: :Slice,
|
108
140
|
args: [{start_time: 0.5, end_time: 1}] # A 0.5 second slice
|
@@ -111,10 +143,11 @@ new_filenames = builder.build(
|
|
111
143
|
)
|
112
144
|
```
|
113
145
|
|
114
|
-
_combine_
|
146
|
+
_combine_
|
115
147
|
|
116
148
|
```rb
|
117
|
-
|
149
|
+
# returns single path
|
150
|
+
path = builder.build(
|
118
151
|
sources: filenames,
|
119
152
|
effect: :Combine,
|
120
153
|
args: [{filename: "foo.mp3"}], # filename arg is optional,
|
@@ -122,10 +155,11 @@ new_filenames = builder.build(
|
|
122
155
|
)
|
123
156
|
```
|
124
157
|
|
125
|
-
_overlay_
|
158
|
+
_overlay_
|
126
159
|
|
127
160
|
```rb
|
128
|
-
|
161
|
+
# returns single path
|
162
|
+
path = builder.build(
|
129
163
|
sources: filenames,
|
130
164
|
effect: :Overlay,
|
131
165
|
args: [{filename: "foo.mp3"}], # filename arg is optional,
|
@@ -138,10 +172,9 @@ As the above examples illustrate, `#build` is always given an array of sources
|
|
138
172
|
it's empty, `args` is always a array, the signature of which is dependent on the
|
139
173
|
specific effects component's implementation.
|
140
174
|
|
141
|
-
|
175
|
+
### StepSequencer::SoundPlayer
|
142
176
|
|
143
|
-
Playing sounds is a two part process. First, the player must be initialized,
|
144
|
-
which is when the sounds are mapped to rows.
|
177
|
+
Playing sounds is a two part process. First, the player must be initialized, which is when the sounds are mapped to rows.
|
145
178
|
|
146
179
|
For example, say I want to plug in the sounds I created earlier using
|
147
180
|
`StepSequencer::SoundBuilder#build`. I have 12 sounds and I want to give each
|
@@ -155,7 +188,7 @@ After `#initialize`, only one other method needs to get called, and that's `play
|
|
155
188
|
As you might have expected by now, it's overloaded as well:
|
156
189
|
|
157
190
|
```rb
|
158
|
-
# This will play the
|
191
|
+
# This will play the ascending scale, there is 1 row for each note
|
159
192
|
player.play(
|
160
193
|
tempo: 240
|
161
194
|
string: <<-TXT
|
@@ -205,12 +238,14 @@ something like `sleep 0.5 while player.playing`
|
|
205
238
|
as 16th notes at 120 BPM, use a tempo of 480. The default is 120.
|
206
239
|
- The player isn't set up to be manipulated while playing. Use a new instance instead.
|
207
240
|
|
208
|
-
|
241
|
+
## Todos
|
209
242
|
|
210
243
|
- precompile the grid into a single mp3. this will result in optimal playback
|
211
|
-
-
|
244
|
+
- support inlining effect directives into the grid (not just a separate build
|
245
|
+
stage). Part of this could be supporting different note flags, such as whole notes,
|
246
|
+
half notes, etc.
|
212
247
|
|
213
|
-
|
248
|
+
## Tests
|
214
249
|
|
215
250
|
The tests are found in lib/step_sequencer/tests.rb. They are not traditional
|
216
251
|
unit tests since the value cannot be automatically determined to be correct.
|
@@ -225,4 +260,4 @@ step_sequencer test
|
|
225
260
|
```
|
226
261
|
|
227
262
|
They can also be run from code: `require 'step_sequencer'` then
|
228
|
-
`StepSequencer::Tests.run`.
|
263
|
+
`StepSequencer::Tests.run`.
|
data/bin/step_sequencer
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
class StepSequencer::REPL
|
2
|
+
|
3
|
+
# Makes all the instance methods of Helpers available to REPL
|
4
|
+
# The binding.pry here is not a remnant of bug-hunting,
|
5
|
+
# this is how the REPL starts
|
6
|
+
def self.start
|
7
|
+
self::Helpers.new.instance_exec { binding.pry }
|
8
|
+
end
|
9
|
+
|
10
|
+
class Helpers
|
11
|
+
# todo
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/lib/step_sequencer/tests.rb
CHANGED
data/lib/step_sequencer.rb
CHANGED
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: step_sequencer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- max pleaner
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.10'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.10'
|
55
69
|
description: ''
|
56
70
|
email: maxpleaner@gmail.com
|
57
71
|
executables:
|
@@ -64,6 +78,7 @@ files:
|
|
64
78
|
- lib/step_sequencer.rb
|
65
79
|
- lib/step_sequencer/example.rb
|
66
80
|
- lib/step_sequencer/refinements.rb
|
81
|
+
- lib/step_sequencer/repl.rb
|
67
82
|
- lib/step_sequencer/sound_builder.rb
|
68
83
|
- lib/step_sequencer/sound_builder/default_effects.rb
|
69
84
|
- lib/step_sequencer/sound_builder/default_effects/combine.rb
|