Component: WAV Library File (Audio Output)

From Flowcode Help
Jump to navigationJump to search
Author Matrix TSL
Version 1.0
Category Audio Output


WAV Library File component

Allows WAV files to be played or recorded using a file component to provide the data. Complete with buffer to allow for uninterrupted playback when performing other tasks. Playback compatible with analogue outputs such as DAC or PWM. Recording compatible with analogue inputs such as a Microphone.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_WAV_Player_FAT.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_WAV_Player_FAT.fcfx

Detailed description

No detailed description exists yet for this component

Examples

No additional examples






Macro reference

EndOfFile

Fc9-comp-macro.png EndOfFile
A simple check to see if we are at the end of the file. Returns 0 if we and not yet at the end fo the file. Returns 1 if we are at the end of the file. 
Fc9-bool-icon.png - BOOL Return


GetBitsPerSample

Fc9-comp-macro.png GetBitsPerSample
Returns the number of bits per sample during playback. 
Fc9-u8-icon.png - BYTE Return


GetNextSample

Fc9-comp-macro.png GetNextSample
Retreives the value for the next sample and auto increments the file pointer. Ideally this function should be called as part of a timer interrupt at the sample rate. The value returned should be passed onto a means of analogue output e.g. a DAC or PWM. 
Fc9-u16-icon.png - UINT Return


GetNumChannels

Fc9-comp-macro.png GetNumChannels
Returns the number of audio channels stored in the WAV file during playback. 
Fc9-u8-icon.png - BYTE Return


ProcessBuffer

Fc9-comp-macro.png ProcessBuffer
When Playing a WAV File - Fills the local data buffer from the SD card. When Recording a WAV File - Writes the local data buffer to the SD card. Must be called often enough to maintain playback or recording. Returns 0 for buffer OK 1 for buffer overrun 
Fc9-u8-icon.png - BYTE Return


PutNextSample

Fc9-comp-macro.png PutNextSample
Writes the value for the next sample and auto increments the file pointer. Ideally this function should be called as part of a timer interrupt at the sample rate. The value written should be collected using an analogue input such as a Mic. 
Fc9-u16-icon.png - UINT Sample
 
Fc9-void-icon.png - VOID Return


StartPlayback

Fc9-comp-macro.png StartPlayback
Start playing a WAV file from the SD card. Use the GetNextSample and EndOfFile macros to read out the contents of the file. Use the ProcessBuffer macro to maintain the local buffer. Returns 1 if file found and opened, else returns 0. 
Fc9-string-icon.png - STRING Filename
WAV Filename e.g. "Test.wav" 
Fc9-u8-icon.png - BYTE Return


StartRecording

Fc9-comp-macro.png StartRecording
Start recording a WAV file to the SD card. Use the WritetNextSample macro to write the contents of the file. Use the ProcessBuffer macro to maintain the local buffer. Returns 1 if file created and opened, else returns 0. 
Fc9-string-icon.png - STRING Filename
WAV Filename e.g. "Test.wav" 
Fc9-u8-icon.png - BYTE BitsPerSample
Number of bits per sample - 8 or 16 
Fc9-u32-icon.png - ULONG SampleRate
Sample Rate in Hz e.g. 8000 for 8KHz 
Fc9-u8-icon.png - BYTE Return


StopRecording

Fc9-comp-macro.png StopRecording
 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png LinkTo
 
Fc9-type-21-icon.png Buffer Size
The number of RAM bytes to allocate to the WAV buffer. The buffer must be big enough to store enough WAV audio samples to maintain playback or recording when doing other program tasks or performing SD card read/write operations. 
Fc9-type-16-icon.png Memory Type