Skip to content

Commit

Permalink
fix spectrogram/cacher bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
cofiem committed Nov 7, 2012
1 parent 6b7e762 commit d8e55a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 6 additions & 1 deletion lib/modules/file_cacher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ def self. create_audio_segment(modify_parameters = {})

# create the cached audio file in each of the possible paths
target_possible_paths = Cache::possible_paths(Cache::cached_audio_storage_paths,target_file)
target_possible_paths.each { |path| Audio::modify source_existing_paths.first, path, modify_parameters }
target_possible_paths.each { |path|
# ensure the subdirectories exist
FileUtils.mkpath(File.dirname(path))
# create the audio segment
Audio::modify source_existing_paths.first, path, modify_parameters
}
target_existing_paths = Cache::existing_paths(Cache::cached_audio_storage_paths,target_file)
end

Expand Down
7 changes: 2 additions & 5 deletions lib/modules/spectrogram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ def self.generate(source, target, modify_parameters)
raise ArgumentError, "Window size must be one of ''#{window_options.join(', ')}', given '#{modify_parameters[:window]}'." unless window_options.include? modify_parameters[:window].to_i

colours_available = colour_options.map { |k, v| "#{k} (#{v})" }.join(', ')
raise ArgumentError, "Colour must be one of '#{colours_available}', given '#{modify_parameters[:colour]}'." unless colour_options.include? modify_parameters[:colour]



raise ArgumentError, "Colour must be one of '#{colours_available}', given '#{modify_parameters[:colour]}'." unless colour_options.include? modify_parameters[:colour].to_sym

# sox command to create a spectrogram from an audio file
command = "#@sox_path -V \"#{source}\" -n #@sox_arguments_sample_rate spectrogram -r -l -a #@sox_arguments_output \"#{target}\""
command = "#@sox_path -V \"#{source}\" -n #@sox_arguments_sample_rate #@sox_arguments_spectrogram #@sox_arguments_output \"#{target}\""

# run the command and wait for the result
stdout_str, stderr_str, status = Open3.capture3(command)
Expand Down

0 comments on commit d8e55a8

Please sign in to comment.