Class: Hornetseye::AlsaInput
- Inherits:
-
Object
- Object
- Hornetseye::AlsaInput
- Defined in:
- lib/hornetseye-alsa/alsainput.rb,
lib/hornetseye-alsa/docs.rb
Overview
Class for capturing audio samples from an ALSA device
Instance Attribute Summary collapse
-
#channels ⇒ Integer
readonly
Number of audio channels.
-
#rate ⇒ Integer
readonly
Get the sampling rate of the sound device.
Class Method Summary collapse
-
.new(pcm_name = 'default', rate = 48000, channels = 2, periods = 8, frames = 1024) ⇒ AlsaInput
Open a sound device for input.
-
.orig_new ⇒ AlsaInput
Alias for native constructor.
Instance Method Summary collapse
-
#avail ⇒ Integer
Space available for recording to the audio buffer.
-
#close ⇒ AlsaInput
Close the audio device.
-
#delay ⇒ Integer
Number of samples available for retrieval.
-
#orig_read ⇒ Node
Alias for native method.
-
#prepare ⇒ AlsaInput
Reset the sound device.
-
#read(samples) ⇒ Node
Read specified number of samples from the sound device.
Instance Attribute Details
#channels ⇒ Integer (readonly)
Number of audio channels
33 34 35 |
# File 'lib/hornetseye-alsa/docs.rb', line 33 def channels @channels end |
#rate ⇒ Integer (readonly)
Get the sampling rate of the sound device
The sampling rate may be different to the desired sampling rate specified in the constructor.
28 29 30 |
# File 'lib/hornetseye-alsa/docs.rb', line 28 def rate @rate end |
Class Method Details
.new(pcm_name = 'default', rate = 48000, channels = 2, periods = 8, frames = 1024) ⇒ AlsaInput
Open a sound device for input
Open the specified sound device for reading. Note that the desired sample rate may not be supported. In that case the sound library will choose a sampling rate near the desired one.
53 54 55 56 |
# File 'lib/hornetseye-alsa/alsainput.rb', line 53 def new( pcm_name = 'default', rate = 48000, channels = 2, periods = 8, frames = 1024 ) orig_new pcm_name, rate, channels, periods, frames end |
.orig_new ⇒ AlsaInput
Alias for native constructor
32 |
# File 'lib/hornetseye-alsa/alsainput.rb', line 32 alias_method :orig_new, :new |
Instance Method Details
#avail ⇒ Integer
Space available for recording to the audio buffer
45 46 |
# File 'lib/hornetseye-alsa/docs.rb', line 45 def avail end |
#close ⇒ AlsaInput
Close the audio device
38 39 |
# File 'lib/hornetseye-alsa/docs.rb', line 38 def close end |
#delay ⇒ Integer
Number of samples available for retrieval
51 52 |
# File 'lib/hornetseye-alsa/docs.rb', line 51 def delay end |
#orig_read ⇒ Node
Alias for native method
65 |
# File 'lib/hornetseye-alsa/alsainput.rb', line 65 alias_method :orig_read, :read |
#prepare ⇒ AlsaInput
Reset the sound device
57 58 |
# File 'lib/hornetseye-alsa/docs.rb', line 57 def prepare end |
#read(samples) ⇒ Node
Read specified number of samples from the sound device
Audio data is read from the input buffer.
A blocking read operation is used. I.e. the program is blocked until there is sufficient data available in the audio input buffer.
82 83 84 |
# File 'lib/hornetseye-alsa/alsainput.rb', line 82 def read(samples) MultiArray.import SINT, orig_read(samples).memory, channels, samples end |