step_sequencer 1.0.9 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67affdea7861f5d586e34a4f50684dff3f74bbfa
4
- data.tar.gz: 9813101ea22693d209eab0e7b1ff9ccb7ca966ee
3
+ metadata.gz: a1a99a39b5af66339839e11d3bfeba26a8ed4e90
4
+ data.tar.gz: a87451ab93c254931775e24a6e6f67504c5293e8
5
5
  SHA512:
6
- metadata.gz: b2f3ffbad7e5e899e5e4f89d2b2c51cd8c5f9496acce582eea2c2c0120baba8beb6c82a719c74e990f723120f0752e4820d6aa061c88ae8743a8eeadaf0aa1e4
7
- data.tar.gz: 627ae1c677444aa8ad8933a4d3c44f8ef9914769a471de7d439782be5e2caa0e3752c68bfe6e14b672ad136d705572e2775e1677fcaeffd47f616ae81e0036c6
6
+ metadata.gz: d1e463dcc91df228ad719392a574ef81f0beb2fb51d0d9ba21a4b3ea33925be0155c49d9af5b204c5768be3151c58cf072efbd31a102a205b0af550216621a37
7
+ data.tar.gz: 8f7d39fbcb03d282d1708fb4881813fbaaa12b53b310375e87b44a033708f834320ee1d5dc0058cbea1ca30f66353d5e193d5a8838673b9cd4306bfa93dd45e1
@@ -3,12 +3,151 @@ class StepSequencer::REPL
3
3
  # Makes all the instance methods of Helpers available to REPL
4
4
  # The binding.pry here is not a remnant of bug-hunting,
5
5
  # this is how the REPL starts
6
- def self.start
7
- self::Helpers.new.instance_exec { binding.pry }
6
+ def self.run
7
+ self::Helpers.new.instance_exec do
8
+ docs
9
+ Pry.start(self)
10
+ end
8
11
  end
9
12
 
10
13
  class Helpers
11
- # todo
14
+
15
+ HelpSections = {
16
+ play: "
17
+ Usage: play #{"\"<path>\"".blue}
18
+ - plays the file in its own thread using mpg123
19
+ - hides the output
20
+ ",
21
+ combine: "
22
+ Usage: combine #{"\"[<paths>]\"".blue}
23
+ - note that this combines them sequentially.
24
+ for concurrent playback, use overlay
25
+ - returns a single path.
26
+ ",
27
+ gain: "
28
+ Usage: gain #{"\"<path>\"".blue}, #{"<value>".blue}
29
+ - <value> is a float, e.g. 0.5 for half and 2.0 for double
30
+ - returns a single path
31
+ ",
32
+ loop: "
33
+ Usage: loop #{"\"<path>\"".blue}, #{"<num_times>".blue}
34
+ - <num_times> can be a int or a float. if it's a float, then the last
35
+ loop will include only part of the original sample.
36
+ - returns a single path
37
+
38
+ ",
39
+ overlay: "
40
+ Usage: overlay #{"\"[<paths>]\"".blue}
41
+ - combines files so they play on top of one another
42
+ - returns a single path
43
+ ",
44
+ pitch: "
45
+ Usage: pitch #{"\"<path>\"".blue}, #{"<value>".blue}, #{"<speed_correct>".blue}
46
+ - <value> here is a integer/float, e.g. 0.5 for half and 2.0 for double.
47
+ - <speed_correct> defaults to true. It will prevent the pitch shift from
48
+ changing the speed.
49
+ - returns a single path
50
+ ",
51
+ scale: "
52
+ Usage: scale #{"\"<path>\"".blue}, #{"<inverse>".blue}
53
+ - This will generate 12 notes of the equal temperament tuning
54
+ - <inverse> defaults to false. If true then the generated notes will
55
+ be downtuned from the original (descending).
56
+ ",
57
+ slice: "
58
+ Usage: slice #{"\"<path>\"".blue} #{"<start>".blue} #{"<end>".blue}
59
+ - <start> and <end> are floats referring to a number of seconds.
60
+ Providing values of 2.0 and 3.5 would create a 1.5 second slice
61
+ - returns a single path
62
+ ",
63
+ speed: "
64
+ Usage: speed #{"\"<path>\"".blue} #{"<value>".blue}
65
+ - <value> is a integer/float, e.g. 0.5 for half and 2.0 for double
66
+ - returns a single path
67
+ "
68
+ }
69
+
70
+ def docs(section=nil)
71
+ section = section.to_sym if section
72
+ if section && (doc = self.class::HelpSections[section])
73
+ puts HelpSections[section]
74
+ elsif section
75
+ puts "
76
+ docs section #{section} not found.
77
+ Enter #{"docs".blue} to see a list of sections
78
+ ".red
79
+ else
80
+ puts "
81
+ StepSequencer
82
+ #{"================"}
83
+
84
+ Usage: docs #{"\"command\"".blue}
85
+ where #{"command".blue} is one of:
86
+ #{self.class::HelpSections.keys.join(", ")}
87
+ "
88
+ end
89
+ end
90
+
91
+ def builder
92
+ StepSequencer::SoundBuilder
93
+ end
94
+
95
+ def combine(paths)
96
+ builder.build(
97
+ sources: paths, effect: :Combine
98
+ )
99
+ end
100
+
101
+ def gain(path, val)
102
+ builder.build(
103
+ sources: [path], effect: :Gain, args: [value: val]
104
+ )[0]
105
+ end
106
+
107
+ def loop(path, times)
108
+ builder.build(
109
+ sources: [path], effect: :Loop, args: [times: val]
110
+ )[0]
111
+ end
112
+
113
+ def overlay(paths)
114
+ builder.build(
115
+ sources: paths, effect: :Overlay
116
+ )
117
+ end
118
+
119
+ def pitch(path, val, speed_correct=true)
120
+ builder.build(
121
+ sources: [path], effect: :Pitch,
122
+ args: [{times: val, speed_correction: speed_correct}]
123
+ )[0]
124
+ end
125
+
126
+ def scale(path, inverse)
127
+ builder.build(
128
+ sources: [path], effect: :Scale,
129
+ args: [{scale: :equal_temperament, inverse: inverse}]
130
+ )[0]
131
+ end
132
+
133
+ def slice(path, start_time, end_time)
134
+ builder.build(
135
+ sources: [path], effect: :Slice,
136
+ args: [{start_time: start_time, end_time: end_time}]
137
+ )[0]
138
+ end
139
+
140
+ def speed(path, val)
141
+ builder.build(
142
+ sources: [path], effect: :Speed,
143
+ args: [{value: val}]
144
+ )[0]
145
+ end
146
+
147
+ def play(path)
148
+ Thread.new { `mpg123 #{path} 2> /dev/null` }
149
+ end
150
+
12
151
  end
13
152
 
14
153
  end
@@ -16,7 +16,7 @@ class StepSequencer::SoundBuilder::DefaultEffects::Combine < protocol
16
16
  # `sox #{sources.join(" ")} #{outfile}`
17
17
 
18
18
  class << self
19
- private
19
+ public
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
- private
14
+ public
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
- private
16
+ public
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
- private
18
+ public
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
- private
26
+ public
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
- private
18
+ public
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
- private
14
+ public
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
- private
13
+ public
14
14
 
15
15
  # Helper method to call other effects
16
16
  def builder
@@ -18,7 +18,7 @@ class StepSequencer::SoundBuilder
18
18
  end
19
19
 
20
20
  class << self
21
- private
21
+ public
22
22
  def effects_components
23
23
  StepSequencer::SoundBuilder::EffectsComponents
24
24
  end
@@ -42,7 +42,7 @@ class StepSequencer::SoundPlayer
42
42
  @limit = nil # an upper limit for steps_played, defaults to no limit
43
43
  end
44
44
 
45
- private
45
+ public
46
46
 
47
47
  def build_matrix_from_string(string)
48
48
  string.tr(" ", '').gsub(/\#.+$/, '').split("\n").map(&:chars).map do |chars|
@@ -1,7 +1,7 @@
1
1
  # =============================================================================
2
2
  # A custom test runner. The tests themselves are in test_cases.rb
3
3
  # Usage: StepSequencer::Tests.run
4
- # The private method run_test_collection can also be used; it's more modular.
4
+ # The public method run_test_collection can also be used; it's more modular.
5
5
  # =============================================================================
6
6
 
7
7
  class StepSequencer::Tests
@@ -24,13 +24,13 @@ class StepSequencer::Tests
24
24
  # shared 'around' hook for tests
25
25
  def self.run_test_case(test_class, fn_name, test_case)
26
26
  speak_fn_name fn_name
27
- puts fn_name
27
+ puts fn_name.yellow
28
28
  test_class.method(fn_name).source.display
29
29
  test_case.call
30
30
  end
31
31
 
32
32
  class << self
33
- private
33
+ public
34
34
 
35
35
  def builder_tests
36
36
  StepSequencer::Tests::TestCases::Builder
@@ -86,7 +86,7 @@ class StepSequencer::Tests
86
86
 
87
87
  # Helpers made available to test cases (if they include the module)
88
88
  module TestCaseHelpers
89
- private
89
+ public
90
90
  def asset_path(name)
91
91
  Gem.find_files("step_sequencer/test_assets/#{name}.mp3")[0]
92
92
  end
@@ -2,6 +2,7 @@ require 'securerandom'
2
2
  require 'pry'
3
3
  require 'espeak'
4
4
  require 'method_source'
5
+ require 'colored'
5
6
 
6
7
  Thread.abort_on_exception = true
7
8
 
data/lib/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module StepSequencer
2
- VERSION = '1.0.9'
2
+ VERSION = '1.1.0'
3
3
 
4
4
  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.9
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - max pleaner
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: colored
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.2'
69
83
  description: ''
70
84
  email: maxpleaner@gmail.com
71
85
  executables: