audio-playback 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: eecccbe6c5faee30c7857d77f3d89e230b435f2a
4
- data.tar.gz: 4621a617d40eaa1b923642b6caec93595e7fd40d
3
+ metadata.gz: 86feb1c8a53cb706283d6aefbf0cbee23d028ca8
4
+ data.tar.gz: 8679d8cc6876bedd0cce0a22878b424c2fda5e80
5
5
  SHA512:
6
- metadata.gz: 582c662be9f91bb72c4958e0978b852beef42a0cdcf2c9a552452a3a870f8832165db47075bc0ccd3def87cefbcc901af26b52555b26e8b3da3bd5febddefcc3
7
- data.tar.gz: 8f7c7cb70b298584fa091806139453a0e6a634263fbbbe7a463f69ec6e4450c5b3aa427b89782567c867d321e794d41f76a13f34f5bd300acd2d7dedc9075127
6
+ metadata.gz: 48cf6147b24c28099b0e32cf04cbadde493405ab99da91a102603850cd5c6588d3485814bccf8ca73c6227ae74f4c9be6f65df9ced1e7554d1440f7d0da78133
7
+ data.tar.gz: 723554296063b7c2169e7ec20b6197a47c18b5088cc5ef9e45723871a271db2c1dd65ef2565e4ae345dcc8999c9d41547147228168b29dc469d5e9b8dce6c1c6
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2015 Ari Russo
1
+ Copyright 2015-2016 Ari Russo
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -94,4 +94,4 @@ More Ruby code examples:
94
94
 
95
95
  Licensed under Apache 2.0, See the file LICENSE
96
96
 
97
- Copyright (c) 2015 [Ari Russo](http://arirusso.com)
97
+ Copyright (c) 2015-2016 [Ari Russo](http://arirusso.com)
@@ -24,7 +24,7 @@ require "audio-playback/sound"
24
24
  # Play audio files
25
25
  module AudioPlayback
26
26
 
27
- VERSION = "0.0.5"
27
+ VERSION = "0.0.6"
28
28
 
29
29
  # Convenience method to play an audio file
30
30
  # @param [Array<::File>, Array<String>, ::File, String] file_paths
@@ -70,14 +70,22 @@ module AudioPlayback
70
70
 
71
71
  private
72
72
 
73
+ # Open the stream resource for playback
74
+ # @param [Playback] playback
75
+ # @return [Boolean]
73
76
  def open_stream(playback)
74
77
  @userdata = playback.data.to_pointer
75
78
  FFI::PortAudio::API.Pa_OpenStream(@stream, @input, @output, @freq, @frames, @flags, @method, @userdata)
79
+ true
76
80
  end
77
81
 
82
+ # Reset the stream and continue playback
83
+ # @param [Playback] playback
84
+ # @return [Boolean]
78
85
  def continue(playback)
79
86
  playback.reset
80
87
  open_stream(playback)
88
+ true
81
89
  end
82
90
 
83
91
  # Initialize the callback that's fired when the stream exits
@@ -23,7 +23,7 @@ module AudioPlayback
23
23
  attr_reader :buffer_size, :channels, :data, :output, :num_channels, :sounds, :stream
24
24
  def_delegators :@sounds, :audio_files
25
25
  def_delegators :@data, :reset
26
-
26
+
27
27
  # @param [Array<Sound>, Sound] sounds
28
28
  # @param [Output] output
29
29
  # @param [Hash] options
@@ -40,10 +40,14 @@ module AudioPlayback
40
40
  report(options[:logger]) if options[:logger]
41
41
  end
42
42
 
43
+ # Sample rate of the playback sound
44
+ # @return [Fixnum]
43
45
  def sample_rate
44
46
  @sounds.last.sample_rate
45
47
  end
46
48
 
49
+ # Size of the playback sound
50
+ # @return [Fixnum]
47
51
  def size
48
52
  @sounds.map(&:size).max
49
53
  end
@@ -24,7 +24,7 @@ module AudioPlayback
24
24
  data = sound.data
25
25
  data = ensure_array_frames(data)
26
26
  data = to_frame_objects(data)
27
- data = build_channels(data, playback) if !channels_match?(playback, sound)
27
+ data = build_channels(data, playback) unless channels_match?(playback, sound)
28
28
  data
29
29
  end
30
30
 
@@ -19,6 +19,8 @@ module AudioPlayback
19
19
  populate
20
20
  end
21
21
 
22
+ # Reset the stream metadata
23
+ # @param [Boolean]
22
24
  def reset
23
25
  indexes = [
24
26
  Playback::METADATA.index(:pointer),
@@ -31,9 +33,9 @@ module AudioPlayback
31
33
  # A C pointer version of the audio data
32
34
  # @return [FFI::Pointer]
33
35
  def to_pointer
34
- pointer = FFI::LibC.malloc(@playback.data_size)
35
- pointer.write_array_of_float(@data.flatten)
36
- pointer
36
+ @pointer ||= FFI::LibC.malloc(@playback.data_size)
37
+ @pointer.write_array_of_float(@data.flatten)
38
+ @pointer
37
39
  end
38
40
 
39
41
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audio-playback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Russo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-17 00:00:00.000000000 Z
11
+ date: 2016-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest