Skip to content

class SF::SoundBufferRecorder
inherits SF::SoundRecorder #

Specialized SoundRecorder which stores the captured audio data into a sound buffer

SF::SoundBufferRecorder allows to access a recorded sound through a SF::SoundBuffer, so that it can be played, saved to a file, etc.

It has the same simple interface as its base class (start(), stop()) and adds a function to retrieve the recorded sound buffer (buffer()).

As usual, don't forget to call the available?() function before using this class (see SF::SoundRecorder for more details about this).

Usage example:

if SF::SoundBufferRecorder.available?
  # Record some audio data
  recorder =
  # [...]

  # Get the buffer containing the captured audio data
  buffer = recorder.buffer

  # Save it to a file (for example...)

See also: SF::SoundRecorder



#buffer : SoundBuffer#

Get the sound buffer containing the captured audio data

The sound buffer is valid only after the capture has ended. This function provides a read-only access to the internal sound buffer, but it can be copied if you need to make any modification to it.

Returns: Read-only access to the sound buffer

View source



View source

#on_process_samples(samples : Array(Int16) | Slice(Int16)) : Bool#

Process a new chunk of recorded samples

  • samples - Pointer to the new chunk of recorded samples
  • sample_count - Number of samples pointed by samples

Returns: True to continue the capture, or false to stop it

View source

#on_start : Bool#

Start capturing audio data

Returns: True to start the capture, or false to abort it

View source


Stop capturing audio data

View source