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 ()
 Optioinal rtsp function: provide the frame duration in microseconds.
 
virtual const char * mime ()
 Provides the mime type of the encoded result.
 
 operator bool ()
 
virtual uint16_t samplesPerFrame ()
 Optioinal 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_t > buffer {0}
 
int buffer_pos = 0
 
int current_codesize = 0
 
AudioInfo info
 
bool is_active = false
 
bool is_first = true
 
Printp_print = nullptr
 
Vector< uint8_t > result_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

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

Reimplemented in AACEncoderFDK.

◆ end()

virtual void end ( )
inlinevirtual

Ends the processing.

Implements AudioWriter.

◆ frameDurationUs()

virtual uint32_t frameDurationUs ( )
inlinevirtualinherited

Optioinal rtsp function: provide the frame duration in microseconds.

Reimplemented in ADPCMEncoder, OpusOggEncoder, MP3ParserEncoder, and MetaDataFilterEncoder.

◆ mime()

virtual const char * mime ( )
inlinevirtual

Provides the mime type of the encoded result.

Implements AudioEncoder.

◆ operator bool()

operator bool ( )
inlinevirtual

Implements AudioWriter.

◆ samplesPerFrame()

virtual uint16_t samplesPerFrame ( )
inlinevirtualinherited

Optioinal rtsp function: provide samples per the frame.

Reimplemented in MP3ParserEncoder, and MetaDataFilterEncoder.

◆ setAudioInfo()

void setAudioInfo ( AudioInfo  from)
inlineoverridevirtualinherited

Defines the sample rate, number of channels and bits per sample.

Implements AudioWriter.

Reimplemented in MP3EncoderLAME, EncoderBasic, CodecChain, FLACEncoder, OpusAudioEncoder, WAVEncoder, CodecNOP, G7xxEncoder, BinaryContainerEncoder, OggContainerEncoder, OSCContainerEncoder, and MetaDataFilterEncoder.

◆ setOutput()

virtual void setOutput ( Print out_stream)
inlinevirtual

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

Reimplemented from AudioEncoder.

◆ write()

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

Implements AudioWriter.


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