Skip to content

Class daisy::WavWriter

template <size_t transfer_size>

ClassList > daisy > WavWriter

More...

  • #include <WavWriter.h>

Classes

Type Name
struct Config

Public Types

Type Name
enum BufferState
enum Result

Public Functions

Type Name
uint32_t GetLengthSamps ()
float GetLengthSeconds ()
void Init (const Config & cfg)
bool IsRecording () const
void OpenFile (const char * name)
void Sample (const float * in)
void SaveFile ()
WavWriter ()
void Write ()
~WavWriter ()

Detailed Description

Audio Recording Module

Record audio into a working buffer that is gradually written to a WAV file on an SD Card.

Recordings are made with floating point input, and will be converted to the specified bits per sample internally

For now only 16-bit and 32-bit (signed int) formats are supported f32 and s24 formats will be added next

The transfer size determines the amount of internal memory used, and can have an effect on the performance of the streaming behavior of the WavWriter. Memory use can be calculated as: (2 * transfer_size) bytes Performance optimal with sizes: 16384, 32768

To use: * Create a WavWriter<size> object (e.g. WavWriter<32768> writer) * Configure the settings as desired by creating a WavWriter<32768>::Config struct and setting the settings. * Initialize the object with the configuration struct. * Open a new file for writing with: writer.OpenFile("FileName.wav") * Write to it within your audio callback using: writer.Sample(value) * Fill the Wav File on the SD Card with data from your main loop by running: writer.Write() * When finished with the recording finalize, and close the file with: writer.SaveFile();

Public Types Documentation

enum BufferState

enum daisy::WavWriter::BufferState {
    IDLE,
    FLUSH0,
    FLUSH1
};

State of the internal Writing mechanism. When the buffer is a certain amount full one section will write its contents while the other is still being written to. This is performed circularly so that audio will be uninterrupted during writing.


enum Result

enum daisy::WavWriter::Result {
    OK,
    ERROR
};

Return values for write related functions


Public Functions Documentation

function GetLengthSamps

inline uint32_t daisy::WavWriter::GetLengthSamps () 

Returns the current length in samples of the recording.


function GetLengthSeconds

inline float daisy::WavWriter::GetLengthSeconds () 

Returns the current length of the recording in seconds.


function Init

inline void daisy::WavWriter::Init (
    const  Config & cfg
) 

Initializes the WavFile header, and prepares the object for recording.


function IsRecording

inline bool daisy::WavWriter::IsRecording () const

Returns whether recording is currently active or not.


function OpenFile

inline void daisy::WavWriter::OpenFile (
    const  char * name
) 

Opens a file for writing. Writes the initial WAV Header, and gets ready for stream-based recording.


function Sample

inline void daisy::WavWriter::Sample (
    const  float * in
) 

Records the current sample into the working buffer, queues writes to media when necessary.

Parameters:

  • in should be a pointer to an array of samples

function SaveFile

inline void daisy::WavWriter::SaveFile () 

Finalizes the writing of the WAV file. This overwrites the WAV Header with the correct final size, and closes the fptr.


function WavWriter

inline daisy::WavWriter::WavWriter () 

function Write

inline void daisy::WavWriter::Write () 

Check buffer state and write


function ~WavWriter

inline daisy::WavWriter::~WavWriter () 


The documentation for this class was generated from the following file external-docs/libDaisy/src/util/WavWriter.h