zappa 0.0.1 → 0.1.0
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/ROADMAP.md +10 -10
- data/lib/zappa/segment.rb +11 -7
- data/lib/zappa/version.rb +1 -1
- data/lib/zappa/wave.rb +37 -7
- data/spec/segment_spec.rb +1 -1
- data/spec/wave_spec.rb +7 -0
- data/zappa.gemspec +1 -1
- 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: 7451348ebf69ebf1dcfcccdb63e9a4f1b639aa46
|
4
|
+
data.tar.gz: cde7d8e96634e6e974cffd61b7d657e0ec6411e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e776a7938072269a5cc3065b915c3c92317989ee05a4595abbaa7b3b4b862c5239309010a717c3c14182bd7124a152d9ee429a689f9ba57370e807d2230fcf4e
|
7
|
+
data.tar.gz: c356ed13032cf939aed42c4ea63a68cd73c7ed621dbde65213dae121551a930d0ca57462d1b1f54f1871f530a20444962d0474ff713f209280f042972e648a10
|
data/ROADMAP.md
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
0.
|
1
|
+
0.1 - Basic editing
|
2
2
|
-------------------
|
3
3
|
- Install ffmpeg + dependencies on MacOS X
|
4
4
|
- Import: WAV
|
5
5
|
- Export: WAV
|
6
6
|
|
7
7
|
|
8
|
-
0.
|
8
|
+
0.2 - Slicing
|
9
9
|
-------------
|
10
10
|
- Slice segments into smaller parts (by time or samples)
|
11
11
|
- Join segments
|
12
12
|
|
13
13
|
|
14
|
-
0.
|
14
|
+
0.3 - DSP - Basic
|
15
15
|
----------------
|
16
16
|
- Amplify signals by DB
|
17
17
|
- Calculate RMS
|
@@ -20,21 +20,21 @@
|
|
20
20
|
- Phase Invert
|
21
21
|
|
22
22
|
|
23
|
-
0.
|
23
|
+
0.4 - Multi Format Exporting
|
24
24
|
----------------------------
|
25
25
|
- Import: MP3, OGG, M4A, FLAC, AIFF
|
26
26
|
- Export: MP3, OGG, M4A, FLAC, AIFF
|
27
27
|
|
28
|
-
0.
|
28
|
+
0.5 - OS Support
|
29
29
|
----------------
|
30
30
|
- OS: Windows, Linux, Mac Support
|
31
31
|
|
32
32
|
|
33
|
-
Release - 0
|
33
|
+
Release - 1.0 Basic DSP Platform
|
34
34
|
==============================
|
35
35
|
|
36
36
|
|
37
|
-
|
37
|
+
1.1 - DSP - Filters - Basic
|
38
38
|
---------------------------
|
39
39
|
|
40
40
|
- DSP: Low Pass Filter
|
@@ -42,19 +42,19 @@ Release - 0.1 Basic DSP Platform
|
|
42
42
|
- DSP: Notch Filter
|
43
43
|
|
44
44
|
|
45
|
-
|
45
|
+
1.2 DSP - Time Effects
|
46
46
|
----------------------
|
47
47
|
- Speed Up / Down
|
48
48
|
- Reverse
|
49
49
|
- Fade In / Fade Out
|
50
50
|
|
51
51
|
|
52
|
-
|
52
|
+
1.3 - DSP - Equalizer
|
53
53
|
---------------------
|
54
54
|
- 8 Chan EQ
|
55
55
|
|
56
56
|
|
57
|
-
|
57
|
+
1.4 - DSP - Dynamics
|
58
58
|
----------------------
|
59
59
|
|
60
60
|
- DSP: Compressor
|
data/lib/zappa/segment.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'tempfile'
|
2
|
+
require 'open3'
|
3
|
+
require 'pry'
|
2
4
|
|
3
5
|
module Zappa
|
4
6
|
class Segment
|
@@ -16,11 +18,12 @@ module Zappa
|
|
16
18
|
@source = Wave.new(safe_copy(path))
|
17
19
|
end
|
18
20
|
|
19
|
-
def to_file(path
|
21
|
+
def to_file(path)
|
20
22
|
raise FileError.new('No data in Segment') if @source.nil?
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
cmd = 'ffmpeg -i ' + @source.file_path + ' -y -f wav ' + path
|
24
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
25
|
+
raise ('Cannot export to' + path ) unless wait_thr.value.success?
|
26
|
+
end
|
24
27
|
end
|
25
28
|
|
26
29
|
def ==(other)
|
@@ -31,9 +34,10 @@ module Zappa
|
|
31
34
|
|
32
35
|
def safe_copy(path)
|
33
36
|
tmp = Tempfile.new('zappa')
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
cmd = 'ffmpeg -i ' + path + ' -vn -y -f wav ' + tmp.path
|
38
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
39
|
+
raise ('Cannot open file ' + path ) unless wait_thr.value.success?
|
40
|
+
end
|
37
41
|
tmp.path
|
38
42
|
end
|
39
43
|
end
|
data/lib/zappa/version.rb
CHANGED
data/lib/zappa/wave.rb
CHANGED
@@ -3,10 +3,11 @@
|
|
3
3
|
module Zappa
|
4
4
|
class Wave
|
5
5
|
attr_accessor :format, :data, :data_size, :file_path
|
6
|
-
SUBCHUNKS = %
|
6
|
+
SUBCHUNKS = %q('fmt', 'data')
|
7
7
|
KNOWN_FMT_SIZE = 16
|
8
8
|
|
9
9
|
def initialize(path)
|
10
|
+
@header = {}
|
10
11
|
@format = {}
|
11
12
|
@data = {}
|
12
13
|
|
@@ -20,6 +21,35 @@ module Zappa
|
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
24
|
+
def update
|
25
|
+
raw_file = pack_riff_header + pack_fmt + pack_data
|
26
|
+
File.write(@file_path, raw_file)
|
27
|
+
end
|
28
|
+
|
29
|
+
def pack_riff_header
|
30
|
+
hdr = ''
|
31
|
+
hdr += @header[:chunk_id]
|
32
|
+
hdr += [@header[:chunk_size]].pack('V')
|
33
|
+
hdr += @header[:format]
|
34
|
+
end
|
35
|
+
|
36
|
+
def pack_fmt
|
37
|
+
fmt = 'fmt '
|
38
|
+
fmt += [16].pack('V')
|
39
|
+
fmt += [@format[:audio_format]].pack('v')
|
40
|
+
fmt += [@format[:channels]].pack('v')
|
41
|
+
fmt += [@format[:sample_rate]].pack('V')
|
42
|
+
fmt += [@format[:byte_rate]].pack('V')
|
43
|
+
fmt += [@format[:block_align]].pack('v')
|
44
|
+
fmt += [@format[:bits_per_sample]].pack('v')
|
45
|
+
end
|
46
|
+
|
47
|
+
def pack_data
|
48
|
+
data = 'data'
|
49
|
+
data += [@data[:size]].pack('V')
|
50
|
+
data += @data[:data]
|
51
|
+
end
|
52
|
+
|
23
53
|
def unpack_wav
|
24
54
|
unpack_riff_header
|
25
55
|
while @data[:data].nil?
|
@@ -28,11 +58,11 @@ module Zappa
|
|
28
58
|
end
|
29
59
|
|
30
60
|
def unpack_riff_header
|
31
|
-
chunk_id = @file.read(4)
|
32
|
-
|
33
|
-
format = @file.read(4)
|
34
|
-
raise FileFormatError.new('Format is not WAVE') unless format == 'WAVE'
|
35
|
-
raise FileFormatError.new('ID is not RIFF') unless chunk_id == 'RIFF'
|
61
|
+
@header[:chunk_id] = @file.read(4)
|
62
|
+
@header[:chunk_size] = @file.read(4).unpack('V').first
|
63
|
+
@header[:format] = @file.read(4)
|
64
|
+
raise FileFormatError.new('Format is not WAVE') unless @header[:format] == 'WAVE'
|
65
|
+
raise FileFormatError.new('ID is not RIFF') unless @header[:chunk_id] == 'RIFF'
|
36
66
|
end
|
37
67
|
|
38
68
|
def unpack_subchunk
|
@@ -58,7 +88,7 @@ module Zappa
|
|
58
88
|
|
59
89
|
def unpack_data
|
60
90
|
@data[:size] = @file.read(4).unpack('V').first
|
61
|
-
@data[:data] = @file.read(@
|
91
|
+
@data[:data] = @file.read(@data[:size])
|
62
92
|
end
|
63
93
|
|
64
94
|
def unpack_unknown
|
data/spec/segment_spec.rb
CHANGED
@@ -25,7 +25,7 @@ describe Zappa::Segment do
|
|
25
25
|
describe '#to_file' do
|
26
26
|
it 'exports the segment to a wav file' do
|
27
27
|
tmp = Tempfile.new('zappa-spec')
|
28
|
-
subject.to_file(tmp.path
|
28
|
+
subject.to_file(tmp.path)
|
29
29
|
expect(Zappa::Wave.new(WAV_IN)).to eq(Zappa::Wave.new(tmp.path))
|
30
30
|
end
|
31
31
|
|
data/spec/wave_spec.rb
CHANGED
@@ -16,6 +16,13 @@ describe Zappa::Wave do
|
|
16
16
|
expect(w.format).to eq(fmt_header)
|
17
17
|
end
|
18
18
|
|
19
|
+
it 'updates file without altering it' do
|
20
|
+
orig = Zappa::Wave.new(WAV_IN)
|
21
|
+
orig.update
|
22
|
+
current = Zappa::Wave.new(WAV_IN)
|
23
|
+
expect(orig).to eq(current)
|
24
|
+
end
|
25
|
+
|
19
26
|
it 'raises error for incorrect path' do
|
20
27
|
expect { Zappa::Wave.new(WAV_EX) }.to raise_error(Zappa::FileError)
|
21
28
|
end
|
data/zappa.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Varun Srinivasan']
|
10
10
|
spec.email = ['varunsrin@gmail.com']
|
11
11
|
spec.summary = 'Ruby gem for manipulating audio files.'
|
12
|
-
spec.description = ''
|
12
|
+
spec.description = 'Write a longer description. Optional.'
|
13
13
|
spec.homepage = ''
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zappa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Varun Srinivasan
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description: Write a longer description. Optional.
|
70
70
|
email:
|
71
71
|
- varunsrin@gmail.com
|
72
72
|
executables: []
|