Class: Sox::Cmd
Overview
Process audio files using the sox
shell command.
Constant Summary
Constants included from Shell
Instance Attribute Summary collapse
-
#effects ⇒ Object
readonly
Returns the value of attribute effects.
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#add_input(file_path, input_options = {}) ⇒ Sox::Cmd
Add input file with its options.
-
#initialize(options = {}) ⇒ Cmd
constructor
A new instance of Cmd.
-
#run ⇒ Boolean
Run ‘sox` command.
-
#set_effects(effects) ⇒ Sox::Cmd
Set effects on the output file.
-
#set_options(options) ⇒ Sox::Cmd
Set global options.
-
#set_output(file_path, output_options = {}) ⇒ Sox::Cmd
Set output file and its options.
Methods included from Shell
Constructor Details
#initialize(options = {}) ⇒ Cmd
19 20 21 22 23 |
# File 'lib/sox/cmd.rb', line 19 def initialize( = {}) @options = @inputs = [] @effects = {} end |
Instance Attribute Details
#effects ⇒ Object (readonly)
Returns the value of attribute effects.
16 17 18 |
# File 'lib/sox/cmd.rb', line 16 def effects @effects end |
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
16 17 18 |
# File 'lib/sox/cmd.rb', line 16 def inputs @inputs end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/sox/cmd.rb', line 16 def @options end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
16 17 18 |
# File 'lib/sox/cmd.rb', line 16 def output @output end |
Instance Method Details
#add_input(file_path, input_options = {}) ⇒ Sox::Cmd
Add input file with its options.
31 32 33 34 |
# File 'lib/sox/cmd.rb', line 31 def add_input(file_path, = {}) @inputs << Sox::File.new(file_path, ) self end |
#run ⇒ Boolean
Run ‘sox` command. Raise Error on fail.
77 78 79 80 81 82 83 |
# File 'lib/sox/cmd.rb', line 77 def run raise(Sox::Error, "Output is missing, specify it with `set_output`") unless @output raise(Sox::Error, "Inputs are missing, specify them with `add_input`") if @inputs.empty? cmd = CommandBuilder.new(@inputs, @output, @options, @effects).build sh(cmd) end |
#set_effects(effects) ⇒ Sox::Cmd
Set effects on the output file. See man sox section EFFECTS
. It receives the effect name as a hash key and the effect arguments as hash values which can be a string or an array of strings. If an effect has no arguments just pass true
as the value.
59 60 61 62 |
# File 'lib/sox/cmd.rb', line 59 def set_effects(effects) @effects = effects self end |
#set_options(options) ⇒ Sox::Cmd
Set global options. See man sox section Global Options.
69 70 71 72 |
# File 'lib/sox/cmd.rb', line 69 def () @options = self end |