arduino-audio-tools
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AACEncoderFDK Class Reference

Encodes PCM data to the AAC format and writes the result to a stream This is basically just a wrapper using https://github.com/pschatzmann/arduino-fdk-aac. More...

#include <CodecAACFDK.h>

Inheritance diagram for AACEncoderFDK:
AudioEncoder AudioWriter AudioInfoSupport

Public Member Functions

 AACEncoderFDK (Print &out_stream)
 
AudioInfo audioInfo ()
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
 
bool begin ()
 
virtual bool begin (AudioInfo info)
 Opens the encoder
More...
 
virtual bool begin (int input_channels=2, int input_sample_rate=44100, int input_bits_per_sample=16)
 Opens the encoder
More...
 
aac_fdk::AACEncoderFDK * driver ()
 
void end ()
 
UINT getParameter (const AACENC_PARAM param)
 
const char * mime ()
 Provides the mime type of the encoded result.
 
 operator bool ()
 
virtual void setAfterburner (bool afterburner)
 This parameter controls the use of the afterburner feature. The afterburner is a type of analysis by synthesis algorithm which increases the audio quality but also the required processing power. It is recommended to always activate this if additional memory consumption and processing power consumption is not a problem. If increased MHz and memory consumption are an issue then the MHz and memory cost of this optional module need to be evaluated against the improvement in audio quality on a case by case basis. More...
 
void setAudioInfo (AudioInfo from) override
 Defines the Audio Info.
 
virtual void setAudioObjectType (int aot)
 Audio object type. See ::AUDIO_OBJECT_TYPE in FDK_audio.h. More...
 
virtual void setBitrate (int bitrate)
 Total encoder bitrate. This parameter is
mandatory and interacts with ::AACENC_BITRATEMODE. More...
 
void setOutput (Print &out_stream)
 Defines the output.
 
virtual void setOutputBufferSize (int outbuf_size)
 Set the Output Buffer Size object. More...
 
int setParameter (AACENC_PARAM param, uint32_t value)
 
virtual void setSpectralBandReplication (int eld_sbr)
 Configure SBR independently of the chosen Audio Object Type ::AUDIO_OBJECT_TYPE. This parameter is for ELD audio object type only. More...
 
virtual void setVariableBitrateMode (int vbr)
 Bitrate mode. Configuration can be different kind of bitrate configurations: More...
 
size_t write (const uint8_t *data, size_t len)
 

Protected Member Functions

void writeBlocking (Print *out, uint8_t *data, size_t len)
 

Protected Attributes

aac_fdk::AACEncoderFDK * enc =nullptr
 
AudioInfo info
 

Detailed Description

Encodes PCM data to the AAC format and writes the result to a stream This is basically just a wrapper using https://github.com/pschatzmann/arduino-fdk-aac.

Author
Phil Schatzmann

Member Function Documentation

◆ begin() [1/2]

virtual bool begin ( AudioInfo  info)
inlinevirtual

Opens the encoder

Parameters
info
Returns
int

Reimplemented from AudioWriter.

◆ begin() [2/2]

virtual bool begin ( int  input_channels = 2,
int  input_sample_rate = 44100,
int  input_bits_per_sample = 16 
)
inlinevirtual

Opens the encoder

Parameters
input_channels
input_sample_rate
input_bits_per_sample
Returns
int 0 => ok; error with negative number

◆ setAfterburner()

virtual void setAfterburner ( bool  afterburner)
inlinevirtual

This parameter controls the use of the afterburner feature. The afterburner is a type of analysis by synthesis algorithm which increases the audio quality but also the required processing power. It is recommended to always activate this if additional memory consumption and processing power consumption is not a problem. If increased MHz and memory consumption are an issue then the MHz and memory cost of this optional module need to be evaluated against the improvement in audio quality on a case by case basis.

  • 0: Disable afterburner (default).
  • 1: Enable afterburner.

◆ setAudioObjectType()

virtual void setAudioObjectType ( int  aot)
inlinevirtual

Audio object type. See ::AUDIO_OBJECT_TYPE in FDK_audio.h.

  • 2: MPEG-4 AAC Low Complexity.
  • 5: MPEG-4 AAC Low Complexity with Spectral Band Replication (HE-AAC).
  • 29: MPEG-4 AAC Low Complexity with Spectral Band Replication and Parametric Stereo (HE-AAC v2). This configuration can be used only with stereo input audio data.
  • 23: MPEG-4 AAC Low-Delay.
  • 39: MPEG-4 AAC Enhanced Low-Delay. Since there is no ::AUDIO_OBJECT_TYPE for ELD in combination with SBR defined, enable SBR explicitely by ::AACENC_SBR_MODE parameter. The ELD v2 212 configuration can be configured by ::AACENC_CHANNELMODE parameter.
  • 129: MPEG-2 AAC Low Complexity.
  • 132: MPEG-2 AAC Low Complexity with Spectral Band Replication (HE-AAC).

Please note that the virtual MPEG-2 AOT's basically disables non-existing Perceptual Noise Substitution tool in AAC encoder and controls the MPEG_ID flag in adts header. The virtual MPEG-2 AOT doesn't prohibit specific transport formats.

◆ setBitrate()

virtual void setBitrate ( int  bitrate)
inlinevirtual

Total encoder bitrate. This parameter is
mandatory and interacts with ::AACENC_BITRATEMODE.

  • CBR: Bitrate in bits/second.
  • VBR: Variable bitrate. Bitrate argument will be ignored. See suppBitrates for details.

◆ setOutputBufferSize()

virtual void setOutputBufferSize ( int  outbuf_size)
inlinevirtual

Set the Output Buffer Size object.

Parameters
outbuf_size

◆ setSpectralBandReplication()

virtual void setSpectralBandReplication ( int  eld_sbr)
inlinevirtual

Configure SBR independently of the chosen Audio Object Type ::AUDIO_OBJECT_TYPE. This parameter is for ELD audio object type only.

  • -1: Use ELD SBR auto configurator (default).
  • 0: Disable Spectral Band Replication.
  • 1: Enable Spectral Band Replication.

◆ setVariableBitrateMode()

virtual void setVariableBitrateMode ( int  vbr)
inlinevirtual

Bitrate mode. Configuration can be different kind of bitrate configurations:

  • 0: Constant bitrate, use bitrate according to ::AACENC_BITRATE. (default) Within none LD/ELD ::AUDIO_OBJECT_TYPE, the CBR mode makes use of full allowed bitreservoir. In contrast, at Low-Delay ::AUDIO_OBJECT_TYPE the bitreservoir is kept very small.
  • 1: Variable bitrate mode, very low bitrate.
  • 2: Variable bitrate mode, low bitrate.
  • 3: Variable bitrate mode, medium bitrate.
  • 4: Variable bitrate mode, high bitrate.
  • 5: Variable bitrate mode, very high bitrate.

The documentation for this class was generated from the following file: