audio_stream 1.2.3 → 1.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d68afffda6b1f4c82e28430669330ef49e22c7765d70264686cc6011428ade0e
4
- data.tar.gz: 783d2ab1c2f6a69e783064a581c472d66e8f1139e8da208715b4edfef3999dfe
3
+ metadata.gz: '00808bca83da43c81bd03e94f420f7ecce53b9211450c76a09d6d1856edf8be2'
4
+ data.tar.gz: 64d161eedf393c991fe2692aa7328afceed56e926fed3101f92dbc862b820446
5
5
  SHA512:
6
- metadata.gz: 1a4c6364f40be8a8125d1c08124a4b4b2e81e955e9f17dff7189f353bca537f581fe6beaba2d3044b61f3eb389e02a2e34531d6f618fee82808371ad4e73e987
7
- data.tar.gz: 7c6b41a5baec7931ac771aee1838ed614b13cefd3134fe4e7954ac26993e59b98c33e2a55512ad95a457e64c5af5954f5bc746c0c09814156b15c934a2a01a1c
6
+ metadata.gz: 4665c0f70102e40057ec0f799f21a8d422bd9ce395f74b7075f22cad0d7024ed8701e682cf644df55822055cf6720dacbb499de0766958dfa17bc46d6d0039b3
7
+ data.tar.gz: 0be2c27573b1918ac6a01ffaa0b678c44338630415c28a3b13c06b432888c8b467f9443ad26b1e326aab9b4d2277eecb5268b8d541189f5827c35109443a93c9
@@ -13,13 +13,15 @@ module AudioStream
13
13
  @connection = Thread.start {
14
14
  stream.connect
15
15
  }
16
+ self
16
17
  end
17
18
 
18
19
  def disconnect
19
20
  if @connection
20
- @connection.join
21
+ @connection.kill
21
22
  @connection = nil
22
23
  end
24
+ self
23
25
  end
24
26
 
25
27
  def stream
@@ -22,12 +22,17 @@ module AudioStream
22
22
  def disconnect
23
23
  if @inbuf
24
24
  @inbuf.stop
25
- super
25
+ @inbuf = nil
26
26
  end
27
+ super
27
28
  end
28
29
 
29
30
  def each(&block)
30
31
  Enumerator.new do |y|
32
+ if !@inbuf
33
+ raise Error, "Device is not connected. You need to exec #{self.class.name}.connect: #{name}"
34
+ end
35
+
31
36
  channels = @dev.input_stream.channels
32
37
  buf = Buffer.float(@soundinfo.window_size, channels)
33
38
 
@@ -17,8 +17,8 @@ module AudioStream
17
17
  def disconnect
18
18
  if @sound && !@sound.closed?
19
19
  @sound.close
20
- super
21
20
  end
21
+ super
22
22
  end
23
23
 
24
24
  def seek(frames, whence=IO::SEEK_SET)
@@ -28,7 +28,11 @@ module AudioStream
28
28
 
29
29
  def each(&block)
30
30
  Enumerator.new do |y|
31
- buf = Buffer.float(@soundinfo.window_size, @sound.info.channels)
31
+ if !@sound || @sound.closed?
32
+ raise Error, "File is not opened. You need to exec #{self.class.name}.connect: #{@path}"
33
+ end
34
+
35
+ buf = Buffer.float(@soundinfo.window_size, @soundinfo.channels)
32
36
  while @sound.read(buf)!=0
33
37
  buf.real_size = buf.size
34
38
  y << buf.clone
@@ -11,7 +11,9 @@ module AudioStream
11
11
  end
12
12
 
13
13
  def disconnect
14
- @sound.close
14
+ if @sound && !@sound.closed?
15
+ @sound.close
16
+ end
15
17
  end
16
18
 
17
19
  def on_next(input)
@@ -8,7 +8,7 @@ module AudioStream
8
8
  @level = level
9
9
  @feedback = feedback
10
10
 
11
- @delaysample = soundinfo.samplerate * time / 1000.0
11
+ @delaysample = (soundinfo.samplerate * time).round
12
12
  @delaybuf0 = Array.new(@delaysample, 0.0)
13
13
  @delaybuf1 = Array.new(@delaysample, 0.0)
14
14
  @seek = 0
@@ -2,6 +2,10 @@ module AudioStream
2
2
  class SoundInfo < RubyAudio::SoundInfo
3
3
  attr_accessor :window_size
4
4
 
5
+ def framerate
6
+ self.samplerate.to_f / self.window_size
7
+ end
8
+
5
9
  def clone
6
10
  SoundInfo.new(channels: channels, samplerate: samplerate, format: format, window_size: window_size)
7
11
  end
@@ -1,3 +1,3 @@
1
1
  module AudioStream
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audio_stream
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshida Tetsuya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-19 00:00:00.000000000 Z
11
+ date: 2019-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler