Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ target :wavesync do
library 'shellwords'
library 'securerandom'
library 'tmpdir'
library 'tempfile'
library 'io-console'
library 'optparse'
end
17 changes: 11 additions & 6 deletions lib/wavesync/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# rbs_inline: enabled

require 'fileutils'
require 'tempfile'
require 'streamio-ffmpeg'
require_relative 'file_converter'

Expand Down Expand Up @@ -66,18 +67,22 @@ def sync(target_library_path, device, pad: false)

bpm = audio.bpm
if (copied || converted) && device.bpm_source == :acid_chunk && bpm && target_path.extname.downcase == '.wav'
temp_path = "#{target_path}.tmp"
AcidChunk.write_bpm(target_path.to_s, temp_path, bpm)
FileUtils.mv(temp_path, target_path.to_s)
Tempfile.create(['wavesync', '.wav']) do |local_temp_file|
local_temp_file.close
AcidChunk.write_bpm(target_path.to_s, local_temp_file.path, bpm)
FileUtils.install(local_temp_file.path, target_path.to_s)
end
end

if converted && source_format.file_type == 'wav' && target_path.extname.downcase == '.wav'
source_cue_points = audio.cue_points
if source_cue_points.any?
rescaled_cue_points = rescale_cue_points(source_cue_points, audio.sample_rate, target_format.sample_rate || audio.sample_rate)
temp_path = "#{target_path}.tmp"
CueChunk.write(target_path.to_s, temp_path, rescaled_cue_points)
FileUtils.mv(temp_path, target_path.to_s)
Tempfile.create(['wavesync', '.wav']) do |local_temp_file|
local_temp_file.close
CueChunk.write(target_path.to_s, local_temp_file.path, rescaled_cue_points)
FileUtils.install(local_temp_file.path, target_path.to_s)
end
end
end

Expand Down
Loading