ruby-audio 1.1.1 → 1.2.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.
- data/Rakefile +1 -1
- data/lib/ruby-audio/buffer.rb +9 -1
- data/spec/buffer_spec.rb +27 -1
- metadata +2 -2
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ require 'spec/rake/spectask'
|
|
6
6
|
|
7
7
|
spec = Gem::Specification.new do |s|
|
8
8
|
s.name = 'ruby-audio'
|
9
|
-
s.version = '1.
|
9
|
+
s.version = '1.2.0'
|
10
10
|
s.summary = 'ruby-audio wraps around libsndfile to provide simplified sound reading and writing support to ruby programs'
|
11
11
|
s.authors = ['Stephen Augenstein']
|
12
12
|
s.email = 'perl.programmer@gmail.com'
|
data/lib/ruby-audio/buffer.rb
CHANGED
@@ -10,8 +10,16 @@ module RubyAudio
|
|
10
10
|
# buf = RubyAudio::Buffer.float(1000)
|
11
11
|
# buf = RubyAudio::Buffer.new("float", 1000, 1)
|
12
12
|
class Buffer < CBuffer
|
13
|
+
include Enumerable
|
14
|
+
|
15
|
+
def each
|
16
|
+
self.size.times do |i|
|
17
|
+
yield self[i]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
13
21
|
[:short, :int, :float, :double].each do |type|
|
14
22
|
eval "def self.#{type}(frames, channels=1); self.new(:#{type}, frames, channels); end"
|
15
23
|
end
|
16
24
|
end
|
17
|
-
end
|
25
|
+
end
|
data/spec/buffer_spec.rb
CHANGED
@@ -59,4 +59,30 @@ describe RubyAudio::Buffer do
|
|
59
59
|
buf[4] = 140
|
60
60
|
buf2[4].should == 100
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
|
+
context ".each" do
|
64
|
+
before(:each) do
|
65
|
+
@buf = RubyAudio::Buffer.int(10, 2)
|
66
|
+
10.times do |i|
|
67
|
+
@buf[i] = [i, i]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should yield the elements in order" do
|
72
|
+
i = 0
|
73
|
+
@buf.each do |left, right|
|
74
|
+
left.should == i
|
75
|
+
right.should == i
|
76
|
+
i += 1
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it "shouldn't do anything on an empty buffer" do
|
81
|
+
buf = RubyAudio::Buffer.int(0, 2)
|
82
|
+
|
83
|
+
buf.each do
|
84
|
+
fail "This shouldn't be executed"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-audio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Augenstein
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-25 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|