step_sequencer 1.0.6 → 1.0.7

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
  SHA1:
3
- metadata.gz: 75a694b928505f59f1e10c1378e5ca6fc0258da6
4
- data.tar.gz: 5575c13783e126aa1da243cee88d5a1ac7521b56
3
+ metadata.gz: 35e70912bfa1e7b6f09f3934f4f8937333aeb62e
4
+ data.tar.gz: 734b86e139fd8d55bb65a94b8db6edadb4e26a56
5
5
  SHA512:
6
- metadata.gz: 15a27f5c1310bc03794a4ca1710a59917faf28700c2ea7b35cb1f35ba1d0a757b6633f40b399ba80cf6f597154d2168d86b46458406ad8b21cfd50e4d568763e
7
- data.tar.gz: 8feb17c505798fa16b602c626fa2e47d0e6bf41a338e0413135c45089d5a2b37f6b5318de2ecd0a3436b25d1b6c41c805243bd236c05dd4e87346bd7d1960ed4
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
- #### Depedencies
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
- #### Installing
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
- #### Usage
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
- **`StepSequencer::SoundBuilder`**
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
- This offers only one public method, `.build`, which is drastically overloaded
35
- and dispatches to a number of other classes (each of which is responsible for
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
- new_filenames = builder.build(
62
- sources: filenames.shift,
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_ (returns array of paths, one for each source)
98
+ _change speed_
71
99
 
72
100
  ```rb
73
- new_filenames = builder.build(
74
- sources: new_filenames,
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_ (returns array of paths, one for each source)
109
+ _change pitch_
81
110
 
82
111
  ```rb
83
- new_filenames = builder.build(
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_ (returns array of paths, one for each source)
122
+ _loop_
93
123
 
94
124
  ```rb
95
- new_filenames = builder.build(
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_ (returns array of paths, one for each source)
133
+ _slice_
103
134
 
104
135
  ```rb
105
- new_filenames = builder.build(
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_ (returns single path)
146
+ _combine_
115
147
 
116
148
  ```rb
117
- new_filenames = builder.build(
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_ (returns single path)
158
+ _overlay_
126
159
 
127
160
  ```rb
128
- new_filenames = builder.build(
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
- **`StepSequencer::SoundPlayer`**
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 descending scale, there is 1 row for each note
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
- #### Todos
241
+ ## Todos
209
242
 
210
243
  - precompile the grid into a single mp3. this will result in optimal playback
211
- - make a nice REPL
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
- #### Tests
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
@@ -6,5 +6,9 @@ class StepSequencer::CLI < Thor
6
6
  def test
7
7
  StepSequencer::Tests.run
8
8
  end
9
+ desc "repl", "start repl"
10
+ def repl
11
+ StepSequencer::REPL.run
12
+ end
9
13
  end
10
14
  StepSequencer::CLI.start ARGV
@@ -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
@@ -16,7 +16,7 @@ class StepSequencer::SoundBuilder::DefaultEffects::Combine < protocol
16
16
  # `sox #{sources.join(" ")} #{outfile}`
17
17
 
18
18
  class << self
19
- public
19
+ private
20
20
  def generate_outfile_path(sources)
21
21
  "#{output_dir}/#{SecureRandom.urlsafe_base64}.mp3"
22
22
  end
@@ -11,7 +11,7 @@ class StepSequencer::SoundBuilder::DefaultEffects::Gain < protocol
11
11
  end
12
12
 
13
13
  class << self
14
- public
14
+ private
15
15
  def build_outfile_path path, value
16
16
  "#{output_dir}/#{SecureRandom.urlsafe_base64}.mp3"
17
17
  end
@@ -13,7 +13,7 @@ class StepSequencer::SoundBuilder::DefaultEffects::Loop < protocol
13
13
  end
14
14
 
15
15
  class << self
16
- public
16
+ private
17
17
  def build_outfile_path
18
18
  "#{output_dir}/#{SecureRandom.urlsafe_base64}.mp3"
19
19
  end
@@ -15,7 +15,7 @@ class StepSequencer::SoundBuilder::DefaultEffects::Overlay < protocol
15
15
  end
16
16
 
17
17
  class << self
18
- public
18
+ private
19
19
  def build_outfile_path
20
20
  "#{output_dir}/#{SecureRandom.urlsafe_base64}.mp3"
21
21
  end
@@ -23,7 +23,7 @@ class StepSequencer::SoundBuilder::DefaultEffects::Pitch < protocol
23
23
  end
24
24
 
25
25
  class << self
26
- public
26
+ private
27
27
  def build_outfile_name(source, value)
28
28
  "#{output_dir}/#{SecureRandom.urlsafe_base64}.mp3"
29
29
  end
@@ -15,7 +15,7 @@ class StepSequencer::SoundBuilder::DefaultEffects::Slice < protocol
15
15
  end
16
16
 
17
17
  class << self
18
- public
18
+ private
19
19
  def build_outfile_path
20
20
  "#{output_dir}/#{SecureRandom.urlsafe_base64}.mp3"
21
21
  end
@@ -11,7 +11,7 @@ class StepSequencer::SoundBuilder::DefaultEffects::Speed < protocol
11
11
  end
12
12
 
13
13
  class << self
14
- public
14
+ private
15
15
  def build_outfile_path path, value
16
16
  "#{output_dir}/#{SecureRandom.urlsafe_base64}.mp3"
17
17
  end
@@ -10,7 +10,7 @@ class StepSequencer::SoundBuilder::EffectsComponentProtocol
10
10
 
11
11
  class << self
12
12
 
13
- public
13
+ private
14
14
 
15
15
  # Helper method to call other effects
16
16
  def builder
@@ -1,6 +1,3 @@
1
- require 'espeak'
2
- require 'method_source'
3
-
4
1
  # =============================================================================
5
2
  # A custom test runner. The tests themselves are in test_cases.rb
6
3
  # Usage: StepSequencer::Tests.run
@@ -1,5 +1,7 @@
1
- require 'byebug'
2
1
  require 'securerandom'
2
+ require 'pry'
3
+ require 'espeak'
4
+ require 'method_source'
3
5
 
4
6
  Thread.abort_on_exception = true
5
7
 
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module StepSequencer
2
- VERSION = '1.0.6'
2
+ VERSION = '1.0.7'
3
3
  end
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.6
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