diff --git a/ruby/lib/jam_ruby/models/jam_track_mixdown.rb b/ruby/lib/jam_ruby/models/jam_track_mixdown.rb index bc2ffed1f..f1841e365 100644 --- a/ruby/lib/jam_ruby/models/jam_track_mixdown.rb +++ b/ruby/lib/jam_ruby/models/jam_track_mixdown.rb @@ -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) diff --git a/ruby/lib/jam_ruby/models/jam_track_mixdown_package.rb b/ruby/lib/jam_ruby/models/jam_track_mixdown_package.rb index 4a73079f2..cc9714599 100644 --- a/ruby/lib/jam_ruby/models/jam_track_mixdown_package.rb +++ b/ruby/lib/jam_ruby/models/jam_track_mixdown_package.rb @@ -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 diff --git a/ruby/lib/jam_ruby/resque/jam_track_mixdown_packager.rb b/ruby/lib/jam_ruby/resque/jam_track_mixdown_packager.rb index 2f9184e25..77aeb0054 100644 --- a/ruby/lib/jam_ruby/resque/jam_track_mixdown_packager.rb +++ b/ruby/lib/jam_ruby/resque/jam_track_mixdown_packager.rb @@ -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 diff --git a/ruby/spec/jam_ruby/models/jam_track_mixdown_spec.rb b/ruby/spec/jam_ruby/models/jam_track_mixdown_spec.rb index 7bd5c2557..8da940afd 100644 --- a/ruby/spec/jam_ruby/models/jam_track_mixdown_spec.rb +++ b/ruby/spec/jam_ruby/models/jam_track_mixdown_spec.rb @@ -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 diff --git a/web/app/assets/javascripts/react-components/PopupMediaControls.js.jsx.coffee b/web/app/assets/javascripts/react-components/PopupMediaControls.js.jsx.coffee index a923804fb..ae0a58368 100644 --- a/web/app/assets/javascripts/react-components/PopupMediaControls.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/PopupMediaControls.js.jsx.coffee @@ -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)