Class: Awaaz::Decoders::Mp3Decoder

Inherits:
BaseDecoder show all
Includes:
Utils::ViaShell
Defined in:
lib/awaaz/decoders/mp3_decoder.rb

Overview

The Mp3Decoder class provides decoding functionality for .mp3 files within the Awaaz gem.

It inherits from BaseDecoder and uses the Utils::ViaShell mixin to perform decoding via shell commands (e.g., Sox).

Examples:

Basic usage

decoder = Awaaz::Decoders::Mp3Decoder.new(file_path: "song.mp3")
samples = decoder.load

See Also:

Since:

  • 0.1.0

Instance Method Summary collapse

Methods inherited from BaseDecoder

#available_options, default_available_options, #initialize, load, set_available_options

Constructor Details

This class inherits a constructor from Awaaz::Decoders::BaseDecoder

Instance Method Details

#loadObject

Loads and processes an MP3 file.

This method:

  1. Validates that the file has a .mp3 extension.

  2. Uses Utils::ViaShell#shell_load to load raw audio data.

  3. Passes the loaded data to BaseDecoder#process for further handling.

Returns:

  • (Object)

    The processed audio data (return type depends on BaseDecoder#process).

Raises:

  • (ArgumentError)

    If the file does not have a .mp3 extension.

Since:

  • 0.1.0



39
40
41
# File 'lib/awaaz/decoders/mp3_decoder.rb', line 39

def load
  process(*shell_load(sox_options: { raw: true }))
end