arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SBCEncoder Class Reference

Encoder for SBC - Depends on https://github.com/pschatzmann/arduino-libsbc. Inspired by sbcenc.c. More...

#include <CodecSBC.h>

Inheritance diagram for SBCEncoder:
AudioEncoder AudioWriter AudioInfoSupport

Public Member Functions

 SBCEncoder (int subbands=8, int blocks=16, int bitpool=32, int allocation_method=SBC_AM_LOUDNESS)
 
AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 
bool begin ()
 Restarts the processing.
 
virtual bool begin (AudioInfo info)
 
int bytesCompressed ()
 
int bytesUncompressed ()
 
virtual void end ()
 Ends the processing.
 
virtual uint32_t frameDurationUs ()
 Optional rtsp function: provide the frame duration in microseconds.
 
virtual const charmime ()
 Provides the mime type of the encoded result.
 
 operator bool ()
 
virtual uint16_t samplesPerFrame ()
 Optional rtsp function: provide samples per the frame.
 
void setAllocationMethod (int allocation_method)
 Defines the allocation method: Use SBC_AM_LOUDNESS, SBC_AM_SNR.
 
void setAudioInfo (AudioInfo from) override
 Defines the sample rate, number of channels and bits per sample.
 
void setBitpool (int bitpool)
 Defines the bitpool (2-86?)
 
void setBlocks (int blocks)
 Defines the number of blocks: valid values (4,8,12,16)
 
virtual void setOutput (Print &out_stream)
 Default output assignment (encoders may override to store Print reference)
 
void setSubbands (int subbands)
 Defines the subbands: Use 4 or 8.
 
virtual size_t write (const uint8_t *data, size_t len)
 

Protected Member Functions

int codeSize ()
 Provides the uncompressed length (of the PCM data) in bytes.
 
int frameLength ()
 Provides the compressed length in bytes (after encoding)
 
void processByte (uint8_t byte)
 
bool setup ()
 Determines audio information and calls sbc_init;.
 
void writeBlocking (Print *out, uint8_t *data, size_t len)
 

Protected Attributes

int allocation_method
 
int bitpool = 32
 
int blocks = 4
 
Vector< uint8_tbuffer {0}
 
int buffer_pos = 0
 
int current_codesize = 0
 
AudioInfo info
 
bool is_active = false
 
bool is_first = true
 
Printp_print = nullptr
 
Vector< uint8_tresult_buffer {0}
 
sbc_t sbc
 
int subbands = 4
 

Detailed Description

Encoder for SBC - Depends on https://github.com/pschatzmann/arduino-libsbc. Inspired by sbcenc.c.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ SBCEncoder()

SBCEncoder ( int  subbands = 8,
int  blocks = 16,
int  bitpool = 32,
int  allocation_method = SBC_AM_LOUDNESS 
)
inline

Member Function Documentation

◆ audioInfo()

AudioInfo audioInfo ( )
inlineoverridevirtualinherited

provides the actual input AudioInfo

Implements AudioInfoSupport.

Reimplemented in CodecNOP, BinaryContainerEncoder, and MP3ParserEncoder.

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ begin() [1/2]

bool begin ( )
inlinevirtual

Restarts the processing.

Implements AudioWriter.

◆ begin() [2/2]

virtual bool begin ( AudioInfo  info)
inlinevirtualinherited

◆ bytesCompressed()

int bytesCompressed ( )
inline

◆ bytesUncompressed()

int bytesUncompressed ( )
inline

◆ codeSize()

int codeSize ( )
inlineprotected

Provides the uncompressed length (of the PCM data) in bytes.

◆ end()

virtual void end ( )
inlinevirtual

Ends the processing.

Implements AudioWriter.

◆ frameDurationUs()

virtual uint32_t frameDurationUs ( )
inlinevirtualinherited

Optional rtsp function: provide the frame duration in microseconds.

Reimplemented in ADPCMEncoder, OpusOggEncoder, MP3ParserEncoder, and MetaDataFilterEncoder.

◆ frameLength()

int frameLength ( )
inlineprotected

Provides the compressed length in bytes (after encoding)

◆ mime()

virtual const char * mime ( )
inlinevirtual

Provides the mime type of the encoded result.

Implements AudioEncoder.

◆ operator bool()

operator bool ( )
inlinevirtual

Implements AudioWriter.

◆ processByte()

void processByte ( uint8_t  byte)
inlineprotected

◆ samplesPerFrame()

virtual uint16_t samplesPerFrame ( )
inlinevirtualinherited

Optional rtsp function: provide samples per the frame.

Reimplemented in MP3ParserEncoder, and MetaDataFilterEncoder.

◆ setAllocationMethod()

void setAllocationMethod ( int  allocation_method)
inline

Defines the allocation method: Use SBC_AM_LOUDNESS, SBC_AM_SNR.

◆ setAudioInfo()

void setAudioInfo ( AudioInfo  from)
inlineoverridevirtualinherited

◆ setBitpool()

void setBitpool ( int  bitpool)
inline

Defines the bitpool (2-86?)

◆ setBlocks()

void setBlocks ( int  blocks)
inline

Defines the number of blocks: valid values (4,8,12,16)

◆ setOutput()

virtual void setOutput ( Print out_stream)
inlinevirtual

Default output assignment (encoders may override to store Print reference)

Reimplemented from AudioEncoder.

◆ setSubbands()

void setSubbands ( int  subbands)
inline

Defines the subbands: Use 4 or 8.

◆ setup()

bool setup ( )
inlineprotected

Determines audio information and calls sbc_init;.

◆ write()

virtual size_t write ( const uint8_t data,
size_t  len 
)
inlinevirtual

Implements AudioWriter.

◆ writeBlocking()

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

Member Data Documentation

◆ allocation_method

int allocation_method
protected

◆ bitpool

int bitpool = 32
protected

◆ blocks

int blocks = 4
protected

◆ buffer

Vector<uint8_t> buffer {0}
protected

◆ buffer_pos

int buffer_pos = 0
protected

◆ current_codesize

int current_codesize = 0
protected

◆ info

AudioInfo info
protectedinherited

◆ is_active

bool is_active = false
protected

◆ is_first

bool is_first = true
protected

◆ p_print

Print* p_print = nullptr
protected

◆ result_buffer

Vector<uint8_t> result_buffer {0}
protected

◆ sbc

sbc_t sbc
protected

◆ subbands

int subbands = 4
protected

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