-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mark
committed
Oct 23, 2012
1 parent
0b2c340
commit abea0e5
Showing
5 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Audio | ||
|
||
@sox_path = "./vendor/bin/sox/windows/sox.exe" | ||
|
||
@sox_arguments_info = "--info" | ||
@@my_logger ||= Logger.new("#{Rails.root}/log/my.log") | ||
|
||
def self.info(source) | ||
# sox command to create a spectrogram from an audio file | ||
command = "#{@sox_path} #{@sox_arguments_info} \"#{source}\"" | ||
|
||
# run the command and wait for the result | ||
stdout_str, stderr_str, status = Open3.capture3(command) | ||
|
||
# get the audio file information from the stdout_str | ||
something = stdout_str.each_line { |substr| p substr.index(':') } | ||
|
||
# package up all the available information and return it | ||
result = [ stdout_str, stderr_str, status, File.exist?(source), something ] | ||
|
||
end | ||
def self.segment(source, destination) | ||
# sox command to create a spectrogram from an audio file | ||
command = "#{@sox_path} #{@sox_arguments_verbose} \"#{source}\" #{@sox_arguments_output_audio} #{@sox_arguments_sample_rate} #{@sox_arguments_spectrogram} #{@sox_arguments_output} \"#{destination}\"" | ||
|
||
# run the command and wait for the result | ||
stdout_str, stderr_str, status = Open3.capture3(command) | ||
|
||
# package up all the available information and return it | ||
result = [ stdout_str, stderr_str, status, File.exist?(source), File.exist?(destination) ] | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Spectrogram | ||
@sox_path = "./vendor/bin/sox/windows/sox.exe" | ||
@sox_arguments_verbose = "-V" | ||
@sox_arguments_output_audio = "-n" | ||
@sox_arguments_sample_rate = "rate 22050" | ||
@sox_arguments_spectrogram = "spectrogram -m -r -l -a -q 249 -w hann -y 257 -X 43.06640625 -z 100" | ||
@sox_arguments_output = "-o" | ||
@@my_logger ||= Logger.new("#{Rails.root}/log/my.log") | ||
def self.generate(source, destination) | ||
# sox command to create a spectrogram from an audio file | ||
command = "#{@sox_path} #{@sox_arguments_verbose} \"#{source}\" #{@sox_arguments_output_audio} #{@sox_arguments_sample_rate} #{@sox_arguments_spectrogram} #{@sox_arguments_output} \"#{destination}\"" | ||
# run the command and wait for the result | ||
stdout_str, stderr_str, status = Open3.capture3(command) | ||
# package up all the available information and return it | ||
result = [ stdout_str, stderr_str, status, File.exist?(source), File.exist?(destination) ] | ||
end | ||
end |
Binary file not shown.
Binary file not shown.