Class: StepSequencer::REPL::Helpers
- Inherits:
-
Object
- Object
- StepSequencer::REPL::Helpers
- Defined in:
- lib/step_sequencer/repl.rb
Constant Summary collapse
- HelpSections =
{ play: " Usage: play #{"\"<path>\"".blue} - plays the file in its own thread using mpg123 - hides the output ", combine: " Usage: combine #{"\"[<paths>]\"".blue} - note that this combines them sequentially. for concurrent playback, use overlay - returns a single path. ", gain: " Usage: gain #{"\"<path>\"".blue}, #{"<value>".blue} - <value> is a float, e.g. 0.5 for half and 2.0 for double - returns a single path ", loop: " Usage: loop #{"\"<path>\"".blue}, #{"<num_times>".blue} - <num_times> can be a int or a float. if it's a float, then the last loop will include only part of the original sample. - returns a single path ", overlay: " Usage: overlay #{"\"[<paths>]\"".blue} - combines files so they play on top of one another - returns a single path ", pitch: " Usage: pitch #{"\"<path>\"".blue}, #{"<value>".blue}, #{"<speed_correct>".blue} - <value> here is a integer/float, e.g. 0.5 for half and 2.0 for double. - <speed_correct> defaults to true. It will prevent the pitch shift from changing the speed. - returns a single path ", scale: " Usage: scale #{"\"<path>\"".blue}, #{"<inverse>".blue} - This will generate 12 notes of the equal temperament tuning - <inverse> defaults to false. If true then the generated notes will be downtuned from the original (descending). ", slice: " Usage: slice #{"\"<path>\"".blue} #{"<start>".blue} #{"<end>".blue} - <start> and <end> are floats referring to a number of seconds. Providing values of 2.0 and 3.5 would create a 1.5 second slice - returns a single path ", speed: " Usage: speed #{"\"<path>\"".blue} #{"<value>".blue} - <value> is a integer/float, e.g. 0.5 for half and 2.0 for double - returns a single path " }
Instance Method Summary collapse
- #builder ⇒ Object
- #combine(paths) ⇒ Object
- #docs(section = nil) ⇒ Object
- #gain(path, val) ⇒ Object
- #loop(path, times) ⇒ Object
- #overlay(paths) ⇒ Object
- #pitch(path, val, speed_correct = true) ⇒ Object
- #play(path) ⇒ Object
- #scale(path, inverse) ⇒ Object
- #slice(path, start_time, end_time) ⇒ Object
- #speed(path, val) ⇒ Object
Instance Method Details
#builder ⇒ Object
91 92 93 |
# File 'lib/step_sequencer/repl.rb', line 91 def builder StepSequencer::SoundBuilder end |
#combine(paths) ⇒ Object
95 96 97 98 99 |
# File 'lib/step_sequencer/repl.rb', line 95 def combine(paths) builder.build( sources: paths, effect: :Combine ) end |
#docs(section = nil) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/step_sequencer/repl.rb', line 70 def docs(section=nil) section = section.to_sym if section if section && (doc = self.class::HelpSections[section]) puts HelpSections[section] elsif section puts " docs section #{section} not found. Enter #{"docs".blue} to see a list of sections ".red else puts " StepSequencer #{"================"} Usage: docs #{"\"command\"".blue} where #{"command".blue} is one of: #{self.class::HelpSections.keys.join(", ")} " end end |
#gain(path, val) ⇒ Object
101 102 103 104 105 |
# File 'lib/step_sequencer/repl.rb', line 101 def gain(path, val) builder.build( sources: [path], effect: :Gain, args: [value: val] )[0] end |
#loop(path, times) ⇒ Object
107 108 109 110 111 |
# File 'lib/step_sequencer/repl.rb', line 107 def loop(path, times) builder.build( sources: [path], effect: :Loop, args: [times: val] )[0] end |
#overlay(paths) ⇒ Object
113 114 115 116 117 |
# File 'lib/step_sequencer/repl.rb', line 113 def (paths) builder.build( sources: paths, effect: :Overlay ) end |
#pitch(path, val, speed_correct = true) ⇒ Object
119 120 121 122 123 124 |
# File 'lib/step_sequencer/repl.rb', line 119 def pitch(path, val, speed_correct=true) builder.build( sources: [path], effect: :Pitch, args: [{times: val, speed_correction: speed_correct}] )[0] end |
#play(path) ⇒ Object
147 148 149 |
# File 'lib/step_sequencer/repl.rb', line 147 def play(path) Thread.new { `mpg123 #{path} 2> /dev/null` } end |
#scale(path, inverse) ⇒ Object
126 127 128 129 130 131 |
# File 'lib/step_sequencer/repl.rb', line 126 def scale(path, inverse) builder.build( sources: [path], effect: :Scale, args: [{scale: :equal_temperament, inverse: inverse}] )[0] end |
#slice(path, start_time, end_time) ⇒ Object
133 134 135 136 137 138 |
# File 'lib/step_sequencer/repl.rb', line 133 def slice(path, start_time, end_time) builder.build( sources: [path], effect: :Slice, args: [{start_time: start_time, end_time: end_time}] )[0] end |
#speed(path, val) ⇒ Object
140 141 142 143 144 145 |
# File 'lib/step_sequencer/repl.rb', line 140 def speed(path, val) builder.build( sources: [path], effect: :Speed, args: [{value: val}] )[0] end |