Difference between revisions of "Component: WAV Library File (Audio Output)"
From Flowcode Help
Jump to navigationJump to searchLine 16: | Line 16: | ||
==Component Source Code== | ==Component Source Code== | ||
+ | |||
+ | Please click here to download the component source project: [https://www.flowcode.co.uk/wikicopy/componentsource/FC_Comp_Source_WAV_Player_FAT.fcfx FC_Comp_Source_WAV_Player_FAT.fcfx] | ||
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_WAV_Player_FAT.fcfx FC_Comp_Source_WAV_Player_FAT.fcfx] | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_WAV_Player_FAT.fcfx FC_Comp_Source_WAV_Player_FAT.fcfx] | ||
==Detailed description== | ==Detailed description== | ||
+ | |||
+ | |||
Line 28: | Line 32: | ||
==Examples== | ==Examples== | ||
+ | |||
+ | |||
Line 36: | Line 42: | ||
==Macro reference== | ==Macro reference== | ||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''StartPlayback''' | ||
+ | |- | ||
+ | | colspan="2" | 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. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" | Filename | ||
+ | |- | ||
+ | | colspan="2" | WAV Filename e.g. "Test.wav" | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''EndOfFile''' | ||
+ | |- | ||
+ | | colspan="2" | 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. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ProcessBuffer''' | ||
+ | |- | ||
+ | | colspan="2" | 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 | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''StopRecording''' | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''PutNextSample''' | ||
+ | |- | ||
+ | | colspan="2" | 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. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Sample | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetNumChannels''' | ||
+ | |- | ||
+ | | colspan="2" | Returns the number of audio channels stored in the WAV file during playback. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''StartRecording''' | ||
+ | |- | ||
+ | | colspan="2" | 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. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" | Filename | ||
+ | |- | ||
+ | | colspan="2" | WAV Filename e.g. "Test.wav" | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | BitsPerSample | ||
+ | |- | ||
+ | | colspan="2" | Number of bits per sample - 8 or 16 | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG | ||
+ | | width="90%" | SampleRate | ||
+ | |- | ||
+ | | colspan="2" | Sample Rate in Hz e.g. 8000 for 8KHz | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetBitsPerSample''' | ||
+ | |- | ||
+ | | colspan="2" | Returns the number of bits per sample during playback. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetNextSample''' | ||
+ | |- | ||
+ | | colspan="2" | 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. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==Property reference== | ||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties''' | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
+ | | width="90%" | LinkTo | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-21-icon.png]] | ||
+ | | width="90%" | Buffer Size | ||
+ | |- | ||
+ | | colspan="2" | 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. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
+ | | width="90%" | Memory Type | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |}==Macro reference== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
Revision as of 15:25, 20 January 2023
Author | Matrix TSL |
Version | 1.0 |
Category | Audio Output |
Contents
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 | |
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. | |
- BOOL | Return |
StopRecording | |
- VOID | Return |
GetNumChannels | |
Returns the number of audio channels stored in the WAV file during playback. | |
- BYTE | Return |
GetBitsPerSample | |
Returns the number of bits per sample during playback. | |
- BYTE | Return |
Property reference
==Macro reference==
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. | |
- BOOL | Return |
StopRecording | |
- VOID | Return |
GetNumChannels | |
Returns the number of audio channels stored in the WAV file during playback. | |
- BYTE | Return |
GetBitsPerSample | |
Returns the number of bits per sample during playback. | |
- BYTE | Return |
Property reference
==Macro reference==
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. | |
- BOOL | Return |
StopRecording | |
- VOID | Return |
GetNumChannels | |
Returns the number of audio channels stored in the WAV file during playback. | |
- BYTE | Return |
GetBitsPerSample | |
Returns the number of bits per sample during playback. | |
- BYTE | Return |