* make aac work, validate that pitch & speed are integer

This commit is contained in:
Seth Call 2015-09-12 13:49:30 -05:00
parent c57e7fd527
commit d5fd7b6384
5 changed files with 52 additions and 9 deletions

View File

@ -66,6 +66,14 @@ module JamRuby
if !tweaked
errors.add(:settings, 'have nothing specified')
end
if parsed["speed"] && !parsed["speed"].is_a?(Integer)
errors.add(:settings, 'has non-integer speed')
end
if parsed["pitch"] && !parsed["pitch"].is_a?(Integer)
errors.add(:settings, 'has non-integer pitch')
end
end
def self.create(name, description, user, jam_track, settings)

View File

@ -45,7 +45,7 @@ module JamRuby
end
end
def self.create(mixdown, file_type, sample_rate, encrypt)
def self.create(mixdown, file_type, sample_rate, encrypt_type)
package = JamTrackMixdownPackage.new
package.jam_track_mixdown = mixdown
@ -53,6 +53,7 @@ module JamRuby
package.sample_rate = sample_rate
package.signed = false
package.signing = false
package.encrypt_type = encrypt_type
package.save
package
end

View File

@ -331,8 +331,11 @@ module JamRuby
@speed_mix_file
else
# otherwise we need to convert from lastly created file to correct
output = File.join(tmp_dir, "output.#{@mixdown_pacakge.file_type}")
cmd("sox \"#{@speed_mix_file}\" \"#{output}\"")
output = File.join(tmp_dir, "output.#{@mixdown_package.file_type}")
raise 'unknown file_type' if @mixdown_package.file_type != JamTrackMixdownPackage::FILE_TYPE_AAC
cmd("ffmpeg -i \"#{@speed_mix_file}\" -c:a libfdk_aac -b:a 128k \"#{output}\"")
output
end
end

View File

@ -33,12 +33,43 @@ describe JamTrackMixdown do
count.should eq(1)
end
it "validates settings" do
invalid = FactoryGirl.build(:jam_track_mixdown, settings: {}.to_json)
invalid.save
invalid.errors.any?.should be_true
invalid.errors["settings"].should eq(["have nothing specified"])
describe "settings" do
it "validates empty settings" do
invalid = FactoryGirl.build(:jam_track_mixdown, settings: {}.to_json)
invalid.save
invalid.errors.any?.should be_true
invalid.errors["settings"].should eq(["have nothing specified"])
end
it "validates speed numeric" do
invalid = FactoryGirl.build(:jam_track_mixdown, settings: {"speed": "5"}.to_json)
invalid.save
invalid.errors.any?.should be_true
invalid.errors["settings"].should eq(["has non-integer speed"])
end
it "validates pitch numeric" do
invalid = FactoryGirl.build(:jam_track_mixdown, settings: {"pitch": "5"}.to_json)
invalid.save
invalid.errors.any?.should be_true
invalid.errors["settings"].should eq(["has non-integer pitch"])
end
it "validates speed not-float" do
invalid = FactoryGirl.build(:jam_track_mixdown, settings: {"speed": 5.5}.to_json)
invalid.save
invalid.errors.any?.should be_true
invalid.errors["settings"].should eq(["has non-integer speed"])
end
it "validates pitch not-float" do
invalid = FactoryGirl.build(:jam_track_mixdown, settings: {"pitch": 10.5}.to_json)
invalid.save
invalid.errors.any?.should be_true
invalid.errors["settings"].should eq(["has non-integer pitch"])
end
end
end

View File

@ -294,7 +294,7 @@ mixins.push(Reflux.listenTo(JamTrackStore, 'onJamTrackChanged'))
mixdown = {jamTrackID: @state.jamTrack.id, name: name, settings: {speed:speed, pitch: pitch}}
package_settings = {file_type: 'ogg', encrypt_type: 'jkz'}
package_settings = {file_type: 'aac', encrypt_type: null}
JamTrackMixdownActions.create(mixdown, package_settings, @createMixdownDone, @createMixdownFail)