|
arduino-audio-tools
|
Forward error correction using Reed-Solomon: write is encoding and readBytes does the decoding. More...
#include <ReedSolomonFEC.h>


Public Member Functions | |
| ReedSolomonFEC (Print &print) | |
| ReedSolomonFEC (Stream &stream) | |
| int | available () override |
| Number of decoded bytes which can be read without blocking. | |
| int | availableForWrite () override |
| Number of bytes which can be written until the next block is encoded. | |
| bool | begin () override |
| virtual void | end () |
| size_t | failedBlocks () |
| Number of blocks which could not be corrected. | |
| virtual void | flush () override |
| operator bool () | |
| size_t | readBytes (uint8_t *data, size_t len) override |
| void | setWriteBufferSize (int size) |
| size_t | write (const uint8_t *data, size_t len) override |
| virtual size_t | write (uint8_t ch) override |
Protected Member Functions | |
| bool | decodeBlock () |
| void | refillReadBuffer () |
| Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read() | |
| bool | writeBlock () |
Protected Attributes | |
| int | _timeout = 10 |
| uint8_t | decoded [bytecount] |
| int | decoded_len = 0 |
| int | decoded_pos = 0 |
| size_t | failed_blocks = 0 |
| const int | max_write_retries = 1000 |
| Print * | p_print = nullptr |
| Stream * | p_stream = nullptr |
| uint8_t | raw [bytecount] |
| int | raw_len = 0 |
| RS::ReedSolomon< bytecount, additional_bytes > | rs |
| uint8_t | rx_encoded [bytecount+additional_bytes] |
| int | rx_len = 0 |
| RingBuffer< uint8_t > | tmp_in {0} |
| RingBuffer< uint8_t > | tmp_out {0} |
| uint8_t | tx_encoded [bytecount+additional_bytes] |
| int | write_buffer_size = MAX_SINGLE_CHARS |
Forward error correction using Reed-Solomon: write is encoding and readBytes does the decoding.
The written data is split into blocks of bytecount bytes and each block is written with additional_bytes parity bytes. Data is only sent in complete blocks: the bytes of a trailing incomplete block (less than bytecount bytes) are never written. The reader collects the encoded blocks from the stream and corrects up to additional_bytes / 2 wrong bytes per block. If a block can not be corrected, the uncorrected data bytes are provided and failedBlocks() is incremented. There are no sync markers: if bytes get lost on the link, the block boundaries are wrong until begin() is called on both sides to restart at a block boundary.
|
inline |
|
inline |
Number of decoded bytes which can be read without blocking.
Reimplemented from BaseStream.
Number of bytes which can be written until the next block is encoded.
Reimplemented from BaseStream.
Resets the encoding and decoding state: can be used to resynchronize the block boundaries (e.g. after lost bytes)
Reimplemented from BaseStream.
Decodes the received block if it is complete: returns false if more data is needed
|
inlinevirtualinherited |
Reimplemented in FaustStream< DSP >, AudioMP34DT05, I2SCodecStream, MozziStream, PureDataStream, SPDIFOutput, VS1053Stream, WM8960Stream, AdaptiveResamplingStream, AudioLoRa, ESPNowStream, BufferedTaskStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, USBAudioDeviceBase, USBAudioHostBase, GoertzelStream, Equalizer3BandsT< T >, I2SStream, AudioStreamWrapper, TimerCallbackAudioStream, FormatConverterStream, FileLoopT< FileType >, FileLoopT< File >, EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >, EncodedAudioStream, AudioKitStream, MiniAudioStream, PortAudioStream, StdioStream, A2DPStream, BLESerialClientArduinoBLE, BLESerialClientESP32, BLESerialServerArduinoBLE, BLESerialServerESP32, HLSStreamT< URLStream >, HttpRequest, ICYStreamT< T >, URLStream, URLStreamESP32, NRF24Stream, SPIAudioSlave, SPIRegAudioSlave, AutomaticGainControlStream, VolumeStream, AnalogAudioStream, AudioEffectStreamT< T >, AudioEffectStream, Equalizer3BandsPerChannelT< T >, ReformatBaseStream, AdapterAudioOutputToAudioStream, MemoryStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, InputMixer< T, SumT >, InputMerge< T >, CallbackStream, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, ChannelFormatConverterStream, NumberFormatConverterStream, CatStream, QueueStream< T >, QueueStream< uint8_t >, DynamicMemoryStream, Pipeline, Pipeline::ModifyingStreamAdapter, SupportedRatesStream, AudioFFTBase, AbstractURLStream, and BLESerialStream.
Number of blocks which could not be corrected.
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in PureDataStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, ReformatBaseStream, AudioStreamWrapper, ResampleStream, EncodedAudioStream, BLESerialClientBase, URLStream, BufferedTaskStream, AutomaticGainControlStream, MeasuringStream, QualityAnalysisStream, VolumeStream, AudioEffectStreamT< T >, AudioEffectStream, Equalizer3BandsT< T >, Equalizer3BandsPerChannelT< T >, I2SStream, TimedStream, MemoryStream, RingBufferStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, BufferedStream, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, QueueStream< T >, QueueStream< uint8_t >, FadeStream, Pipeline::ModifyingStreamAdapter, SupportedRatesStream, and EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >.
|
inlineinherited |
Implements BaseStream.
|
inlineprotectedinherited |
Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
|
inlineinherited |
Implements BaseStream.
Reimplemented in MemoryStream, AudioStreamWrapper, BufferedTaskStream, RingBufferStream, BufferedStream, and URLStream.
Writes the complete encoded block: a partial block would break the block boundaries of the receiver
|
protectedinherited |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protectedinherited |