Skip to content

Commit

Permalink
fixed up mark's dodgy conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
atruskie committed Nov 2, 2012
2 parents e3f8767 + 4b18251 commit ef59459
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 124 deletions.
112 changes: 0 additions & 112 deletions .idea/bioacoustic-workbench.iml

This file was deleted.

1 change: 0 additions & 1 deletion app/models/permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class Permission < ActiveRecord::Base
# enumerations
enumerize :level, :in => [:owner, :writer, :reader, :none], :default => :none, predicates: true


# validation
validates :level, :presence => true
validate :anonymous_permission_can_only_be_read_or_none
Expand Down
2 changes: 2 additions & 0 deletions lib/modules/audio_sox.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'OS'

module AudioSox
include OS
@sox_path = if OS.windows? then "./vendor/bin/sox/windows/sox.exe" else "sox" end
Expand Down
17 changes: 6 additions & 11 deletions lib/modules/spectrogram.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require 'OS'
require 'open3'

module Spectrogram
@sox_path = if OS.windows? then "./vendor/bin/sox/windows/sox.exe" else "sox" end
@sox_arguments_verbose = "-V"
Expand All @@ -16,13 +13,8 @@ module Spectrogram
# An existing image file will not be overwritten.
# possible parameters: :window :colour :format
def self.generate(source, target, modify_parameters)

# check for existing image, and do not overwrite
if File.exist?(target)
Rails.logger.warn "Target path for spectrogram generation already exists: #{target}."
return [ "", "", "", source, File.exist?(source), target, File.exist?(target) ]
end

raise ArgumentError, "Target path for spectrogram generation already exists: #{target}." unless !File.exist?(target)

# 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 \"#{target}\""

Expand All @@ -31,7 +23,10 @@ def self.generate(source, target, modify_parameters)

# log the command
Rails.logger.debug "Spectrogram generation return status #{status.exitstatus}. Command: #{command}"


# check for source file problems
raise ArgumentError, "Source file was not a valid audio file: #{source}." if stderr_str.include? 'FAIL formats: can\'t open input file'

# package up all the available information and return it
result = [ stdout_str, stderr_str, status, source, File.exist?(source), target, File.exist?(target) ]
end
Expand Down
Binary file removed public/tests/TestAudio1.wav
Binary file not shown.
Binary file removed public/tests/TorresianCrow.wav
Binary file not shown.

0 comments on commit ef59459

Please sign in to comment.