Class: Hornetseye::AlsaInput
- Defined in:
- docs/hornetseye-alsa/lib/hornetseye-alsa/alsainput.rb,
docs/hornetseye-alsa/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) ⇒ AlsaInput
Open a sound device for input.
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.
-
#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 'docs/hornetseye-alsa/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 'docs/hornetseye-alsa/lib/hornetseye-alsa/docs.rb', line 28 def rate @rate end |
Class Method Details
.new(pcm_name = 'default', rate = 48000, channels = 2) ⇒ 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.
51 52 53 |
# File 'docs/hornetseye-alsa/lib/hornetseye-alsa/alsainput.rb', line 51 def new(pcm_name = 'default', rate = 48000, channels = 2) orig_new pcm_name, rate, channels end |
Instance Method Details
#avail ⇒ Integer
Space available for recording to the audio buffer
45 46 |
# File 'docs/hornetseye-alsa/lib/hornetseye-alsa/docs.rb', line 45 def avail end |
#close ⇒ AlsaInput
Close the audio device
38 39 |
# File 'docs/hornetseye-alsa/lib/hornetseye-alsa/docs.rb', line 38 def close end |
#delay ⇒ Integer
Number of samples available for retrieval
51 52 |
# File 'docs/hornetseye-alsa/lib/hornetseye-alsa/docs.rb', line 51 def delay end |
#prepare ⇒ AlsaInput
Reset the sound device
57 58 |
# File 'docs/hornetseye-alsa/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.
79 80 81 |
# File 'docs/hornetseye-alsa/lib/hornetseye-alsa/alsainput.rb', line 79 def read(samples) MultiArray.import SINT, orig_read(samples).memory, channels, samples end |