rsox 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,63 @@
1
+ require 'rsox'
2
+
3
+ describe 'effect' do
4
+ before :each do
5
+ @rs = RSox.new
6
+ end
7
+
8
+ it 'example0.c' do
9
+ input = @rs.open_read 'file2.mp3'
10
+ input.signal.channels.should == 2
11
+
12
+ output = @rs.open_write 'file.out.wav', input.signal
13
+
14
+ chain = @rs.chain input, output
15
+
16
+ chain.add('input', input).should == SOX_SUCCESS
17
+ chain.add('vol', '3dB').should == SOX_SUCCESS
18
+ chain.add('flanger').should == SOX_SUCCESS
19
+ chain.add('output', output).should == SOX_SUCCESS
20
+
21
+ chain.flow.should == SOX_SUCCESS
22
+ end
23
+
24
+ it 'reverbs' do
25
+ input = @rs.open_read 'file2.mp3'
26
+ output = @rs.open_write 'file2.out.mp3', input.signal
27
+
28
+ chain = @rs.chain input, output
29
+ chain.add 'input', input
30
+ chain.add 'reverb'
31
+ chain.add 'output', output
32
+
33
+ chain.flow.should == SOX_SUCCESS
34
+ end
35
+
36
+ it 'block output' do
37
+ input = @rs.open_read 'file2.mp3'
38
+ output = @rs.open_write 'file2.out.mp3', input.signal
39
+
40
+ puts @rs.buffer_size
41
+ @rs.buffer_size = 16384
42
+
43
+ chain = @rs.chain input, output
44
+ chain.add 'input', input
45
+ #chain.add 'reverb'
46
+ chain.add 'block' do |ary|
47
+ $stderr.puts "#{ary.inspect}: #{ary.length} #{ary.at(0)} #{ary[0]} #{ary[ary.size-1]}"
48
+ #puts ary.at(0)
49
+ #puts ary.size
50
+ #$stderr.puts "ruby: block call |#{ary.inspect}|"
51
+ #File.open('file2.out.mp3.2', 'wb') {|f| f.write ary.pack('l*') }
52
+
53
+ `rm -f file3.mp3`
54
+ z = [ary.size]
55
+ (0..ary.size-1).each do |idx|
56
+ z.push ary[idx]
57
+ end
58
+ File.open('file3.mp3', 'ab') {|f| f.write z.pack('l*') }
59
+ end
60
+
61
+ chain.flow.should == SOX_SUCCESS
62
+ end
63
+ end
@@ -0,0 +1,44 @@
1
+ require 'rsox'
2
+
3
+ describe 'general' do
4
+ before :each do
5
+ @rs = RSox.new
6
+ end
7
+
8
+ it 'just works' do
9
+ i = @rs.open_read 'file.mp3'
10
+ i.class.to_s.should == 'RSoxFormat'
11
+ i.signal.class.to_s.should == 'RSoxSignal'
12
+ end
13
+
14
+ it 'decode mp3 & encode pcm wav' do
15
+ input = @rs.open_read 'file.mp3'
16
+
17
+ sig = input.signal
18
+ sig.bits.should == 16
19
+ sig.channels.should == 2
20
+ sig.channels = 1
21
+
22
+ enc = input.encoding
23
+ #enc.bps.should == 320
24
+
25
+ output = @rs.open_write 'file.wav', input.signal
26
+
27
+ buf = RSoxBuffer.new 4096
28
+ buf.length.should == 4096
29
+
30
+ if (readed = input.read buf) > 0
31
+ wrote = output.write buf, readed
32
+ readed.should == wrote
33
+ end
34
+
35
+ #input.close.should == 0
36
+ #output.close.should == 0
37
+ end
38
+
39
+ it 'checks buffer' do
40
+ buffer = RSoxBuffer.new
41
+ buffer.length.should == 2048
42
+ end
43
+
44
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rsox
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Farid Bagishev
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-06 00:00:00 +05:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: RSox provides simple interface to libSoX, the Swiss Army knife of audio manipulation
22
+ email: farid@bagishev.ru
23
+ executables: []
24
+
25
+ extensions:
26
+ - ext/extconf.rb
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - README.md
31
+ - ext/extconf.rb
32
+ - ext/rsox.c
33
+ - setup.rb
34
+ - spec/effect_spec.rb
35
+ - spec/general_spec.rb
36
+ has_rdoc: true
37
+ homepage: https://github.com/afhbl/rsox
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options: []
42
+
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ segments:
51
+ - 0
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.3.7
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: libSoX binding for Ruby
68
+ test_files: []
69
+