audio_hero 0.1.6 → 0.1.7
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 +4 -4
- data/README.md +10 -0
- data/lib/audio_hero/version.rb +1 -1
- data/lib/audio_hero.rb +28 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef34f4875f7612753b03ea02a76a00d805321be6
|
4
|
+
data.tar.gz: da6f18a75cf510220b496687da290cdb1554003e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/lib/audio_hero/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|