carrierwave-audio 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5cfd9c0f3a67df48a91532f5fc4824efade4cd07
4
- data.tar.gz: 56886d59465e49ade882804c82d07596280ca0e4
3
+ metadata.gz: 727554e942f93928cf0a5fe38da5c5bbe6943ecc
4
+ data.tar.gz: cc8bfc6ad0ec24c02725d477bd64c3bc7ca8df4c
5
5
  SHA512:
6
- metadata.gz: 8c6693acb8a3a42eb9cbeb7ff5f1a8e80b50e1ab7c97a36ebd71c4dcf3384efd7e95c9997ec9c9f8f3fddc471e77cacb3bfcc0288772d8cbce517f7d512fe761
7
- data.tar.gz: 8e1af9bdd51d822b47f88b056c572d75398fecc449a74c45f540848b894f1bf6f6ec13028265f62727c40391eaa0127c2b1665041be8ee8352d883bec64bd763
6
+ metadata.gz: 54736000293f383b639c5fde95575b33a1d61cfc731719d5e31113a52f21687eb1e65eb5e754845b86fbd081968eed4fe98d70cb89a1fd9b70e312c85643d1c1
7
+ data.tar.gz: c5b3cb7b4907e8c0ca04f64c3368dcd7755f0c7dc379ab19fd2a87f870158fd0140c9f19a5867f84e3895ad8657386d68b5f777fdc99f408ca1496c231b9b38a
@@ -86,16 +86,30 @@ module CarrierWave
86
86
  @log = Log.new(options[:logger])
87
87
  @log.start!
88
88
 
89
- ext = File.extname(source)
90
- input_options = { type: ext.gsub(/\./, '') }
91
-
89
+ source_samplerate = Soxi::Wrapper.file(source).samplerate.to_i
90
+ watermark_samplerate = Soxi::Wrapper.file(watermark_file_path).samplerate.to_i
92
91
  watermark_ext = File.extname(watermark_file_path)
93
92
  watermark_options = { type: watermark_ext.gsub(/\./, '') }
93
+ converted_watermark = watermark_file_path
94
+ if source_samplerate != watermark_samplerate
95
+ converted_watermark = tmp_filename(source: source, format: watermark_ext, prefix: "cnvt_wtmk")
96
+ @log.timed("\nConverting watermarked file to source samplerate of #{source_samplerate}...") do
97
+ convert_file(
98
+ input_file_path: watermark_file_path,
99
+ input_options: watermark_options,
100
+ output_file_path: converted_watermark,
101
+ output_options: output_options_for_format(watermark_options[:type]).merge(rate: source_samplerate)
102
+ )
103
+ end
104
+ end
105
+
106
+ ext = File.extname(source)
107
+ input_options = { type: ext.gsub(/\./, '') }
94
108
  final_filename = tmp_filename(source: source, format: format, prefix: "wtmk")
95
109
  @log.timed("\nCombining source file and watermark, limiting final output...") do
96
110
  combiner = Sox::Cmd.new(combine: :mix)
97
111
  combiner.add_input source, input_options
98
- combiner.add_input watermark_file_path, watermark_options
112
+ combiner.add_input converted_watermark, watermark_options
99
113
  combiner.set_output final_filename, output_options_for_format(format)
100
114
  combiner.set_effects({ trim: "0 =#{Soxi::Wrapper.file(source).seconds}", vol: "0 db 0.01" })
101
115
  combiner.run
@@ -1,5 +1,5 @@
1
1
  module CarrierWave
2
2
  module Audio
3
- VERSION = '1.0.7'
3
+ VERSION = '1.0.8'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-audio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trevor Hinesley