audio_hero 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c70b8a3e6428d14a447828fce06ae77f5c8b890
4
- data.tar.gz: c1c59b50519a00aec1336fbf45b4b7dc02d7c01c
3
+ metadata.gz: ef34f4875f7612753b03ea02a76a00d805321be6
4
+ data.tar.gz: da6f18a75cf510220b496687da290cdb1554003e
5
5
  SHA512:
6
- metadata.gz: d1b8aa51c4dec053e0158fadee1525d08958fbf7350496f1ce49b06e1b636deaaa6595922224ecf54787ad6e209c407472d1b96ee9a93eef1093dd0f841f4311
7
- data.tar.gz: fb5a777a713d610da244b54b976654a3f41c536b5c2fd75538c203156be1e9ab694021cfecdc9fcca92f8b193a1e8cd5998233a7525841d531881c9487221b37
6
+ metadata.gz: 54052b312fd2e532b6a8298dc9cce2a8b286717047c12ee48b28d37426167d088152e8b50c2dd81ae575d9b1b1c2ddcd33627de0f23c291304a248d1df181093
7
+ data.tar.gz: 83253909044197527bdc4f5e924b0bf239f29c6189c350ec3de4e83059d9d01f99165681720745ea7a04a65e4122296aab29a863c279dfc2c2757b3504213925
data/README.md CHANGED
@@ -80,6 +80,16 @@ Options(hash):
80
80
  * output_filename (base filename, default to "out". If using custom version of SOX, use "%,1c" for starttime and use "%1,1c-%1,1d" for starttime-endtime as filename)
81
81
  * gc (no default, set to "true" to auto close! input file)
82
82
 
83
+ ###Concatenate multiple audio files into one
84
+
85
+ ```ruby
86
+ file_array = ["file/location/1.mp3","file/location/2.mp3","file/location/3.mp3"]
87
+ file = AudioHero::Sox.new(file_array).concat({output_format: "mp3")
88
+ ```
89
+ Options(hash):
90
+ * output_format (default to "wav")
91
+
92
+
83
93
  ###Stats
84
94
  Get statistics report on audio file (support up to 2 channels).
85
95
 
@@ -1,3 +1,3 @@
1
1
  module AudioHero
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/audio_hero.rb CHANGED
@@ -107,6 +107,23 @@ module AudioHero
107
107
  Dir["#{dir}/**/*#{format}"]
108
108
  end
109
109
 
110
+ # Concat takes in an array of audio files (same format) and concatenate them.
111
+ def concat(options={})
112
+ output_format = options[:output_format] ? options[:output_format] : "wav"
113
+ dst = Tempfile.new(["out", ".#{output_format}"])
114
+ files = get_array(@file)
115
+ begin
116
+ parameters = files.dup
117
+ parameters << ":dest"
118
+ parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ")
119
+ success = Cocaine::CommandLine.new("sox", parameters).run(:dest => get_path(dst))
120
+ rescue => e
121
+ raise AudioHeroError, "There was an error joining #{@file}"
122
+ end
123
+ # no garbage collect option for join
124
+ dst
125
+ end
126
+
110
127
  def stats(options={})
111
128
  input_format = options[:input_format] ? options[:input_format] : "mp3"
112
129
  begin
@@ -178,6 +195,8 @@ module AudioHero
178
195
  File.basename(file.path)
179
196
  when File
180
197
  File.basename(file.path)
198
+ when Array
199
+ nil
181
200
  else
182
201
  raise AudioHeroError, "Unknown input file type #{file.class}"
183
202
  end
@@ -196,6 +215,15 @@ module AudioHero
196
215
  end
197
216
  end
198
217
 
218
+ def get_array(file)
219
+ case file
220
+ when Array
221
+ file
222
+ else
223
+ raise AudioHeroError, "Unknown input file type #{file.class}"
224
+ end
225
+ end
226
+
199
227
  def garbage_collect(file)
200
228
  case file
201
229
  when String
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audio_hero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - litenup
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-26 00:00:00.000000000 Z
11
+ date: 2016-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler