12 #ifndef SAMPLEHUFFMAN_H
13 #define SAMPLEHUFFMAN_H
15 #include "mozzi_pgmspace.h"
60 SampleHuffman(uint8_t
const * SOUNDDATA, int16_t
const * HUFFMAN_DATA, uint32_t
const SOUNDDATA_BITS):sounddata(SOUNDDATA),huffman(HUFFMAN_DATA),sounddata_bits(SOUNDDATA_BITS)
73 if(datapos >= sounddata_bits){
82 int16_t dif = decode();
116 uint8_t
const * sounddata;
117 int16_t
const * huffman;
118 uint32_t
const sounddata_bits;
128 const uint8_t b = datapos&7;
130 if(!b) bt = FLASH_OR_RAM_READ<const uint8_t>(sounddata+((uint32_t)datapos>>3));
132 return ((uint8_t)bt>>(7-b))&1;
140 int16_t
const * huffcode = huffman;
143 const int16_t offs = FLASH_OR_RAM_READ<const int16_t>(huffcode);
144 huffcode += offs?offs+1:2;
148 while(FLASH_OR_RAM_READ<const int16_t>(huffcode++));
149 return FLASH_OR_RAM_READ<const int16_t>(huffcode);
A sample player for samples encoded with Huffman compression.
void setLoopingOn()
Turns looping on, with the whole sample length as the loop range.
void setLoopingOff()
Turns looping off.
void start()
Sets the playhead to the beginning of the sample.
SampleHuffman(uint8_t const *SOUNDDATA, int16_t const *HUFFMAN_DATA, uint32_t const SOUNDDATA_BITS)
Constructor.
int16_t next()
Update and return the next audio sample.