Adafruit WaveHC Arduino Library
Public Member Functions | Public Attributes | List of all members
WaveHC Class Reference

Wave file player. More...

#include <WaveHC.h>

Public Member Functions

 WaveHC (void)
 
uint8_t create (FatReader &f)
 
uint32_t getSize (void)
 Return the size of the WAV file. More...
 
uint8_t isPaused (void)
 Returns true if the player is paused else false. More...
 
void pause (void)
 
void play (void)
 
int16_t readWaveData (uint8_t *buff, uint16_t len)
 Not for use in applications. Must be public so SD read ISR can access it. Insures SD sectors are aligned with buffers. More...
 
void resume (void)
 
void seek (uint32_t pos)
 
void setSampleRate (uint32_t samplerate)
 
void stop (void)
 

Public Attributes

uint8_t Channels
 
uint32_t dwSamplesPerSec
 
uint8_t BitsPerSample
 
uint32_t remainingBytesInChunk
 
volatile uint8_t isplaying
 
uint32_t errors
 
uint8_t volume
 
FatReaderfd
 

Detailed Description

Wave file player.

Play wave files from FAT16 and FAT32 file systems on SD and SDHC flash memory cards.

Constructor & Destructor Documentation

◆ WaveHC()

WaveHC::WaveHC ( void  )

create an instance of WaveHC.

Member Function Documentation

◆ create()

uint8_t WaveHC::create ( FatReader f)

Read a wave file's metadata and initialize member variables.

Parameters
[in]fA open FatReader instance for the wave file.
Returns
The value one, true, is returned for success and the value zero, false, is returned for failure. Reasons for failure include I/O error, an invalid wave file or a wave file with features that WaveHC does not support.

◆ getSize()

uint32_t WaveHC::getSize ( void  )
inline

Return the size of the WAV file.

Returns
the size of the WAV file

◆ isPaused()

uint8_t WaveHC::isPaused ( void  )

Returns true if the player is paused else false.

Returns
true if paused, false otherwise

◆ pause()

void WaveHC::pause ( void  )

Pause the player.

◆ play()

void WaveHC::play ( void  )

Play a wave file.

WaveHC::create() must be called before a file can be played.

Check the member variable WaveHC::isplaying to monitor the status of the player.

◆ readWaveData()

int16_t WaveHC::readWaveData ( uint8_t *  buff,
uint16_t  len 
)

Not for use in applications. Must be public so SD read ISR can access it. Insures SD sectors are aligned with buffers.

Read wave data.

Parameters
buffpointer to the buffer where the data should be placed
lenthe number of bytes to read.
Returns
the number of bytes that were actually read.

◆ resume()

void WaveHC::resume ( void  )

Resume a paused player.

◆ seek()

void WaveHC::seek ( uint32_t  pos)

Reposition a wave file.

Parameters
[in]posseek will attempt to position the file near pos. pos is the byte number from the beginning of file.

◆ setSampleRate()

void WaveHC::setSampleRate ( uint32_t  samplerate)

Set the player's sample rate.

Parameters
[in]samplerateThe new sample rate in samples per second. No checks are done on the input parameter.

◆ stop()

void WaveHC::stop ( void  )

Stop the player.

Member Data Documentation

◆ Channels

uint8_t WaveHC::Channels

Wave file number of channels. Mono = 1, Stereo = 2

◆ dwSamplesPerSec

uint32_t WaveHC::dwSamplesPerSec

Wave file sample rate. Must be not greater than 44100/sec.

◆ BitsPerSample

uint8_t WaveHC::BitsPerSample

Wave file bits per sample. Must be 8 or 16.

◆ remainingBytesInChunk

uint32_t WaveHC::remainingBytesInChunk

Remaining bytes to be played in Wave file data chunk.

◆ isplaying

volatile uint8_t WaveHC::isplaying

Has the value true if a wave file is playing else false.

◆ errors

uint32_t WaveHC::errors

Number of times data was not available from the SD in the DAC ISR

◆ volume

uint8_t WaveHC::volume

Software volume control. Reduce volume by 6 dB per step. See DAC ISR.

◆ fd

FatReader* WaveHC::fd

FatReader instance for current wave file.


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