Jump to content

API Sound.LoadWav: Difference between revisions

From Flowcode Help
JonnyW (talk | contribs)
No edit summary
m Text replacement - "width="90%" style="background-color:#D8C9D8; color:#4B008D;"" to "width="90%" class="mtx-class-macrohead""
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{| class="mtx-class-macrotable wikitable"
 
|-
<sidebar>API contents</sidebar>
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
Loads a wave file into memory, providing the values needed to play it
| width="90%" class="mtx-class-macrohead" | '''LoadWav'''
 
|-
<div style="width:25%; float:right" class="toc">
| colspan="2" | Loads a wave file into memory, providing the values needed to play it&nbsp;
====Class hierarchy====
|-
[[API Sound|Sound]]
|-
:[[API Sound|LoadWav]]
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
</div>
| width="90%" | Filename
__TOC__
|-
 
| colspan="2" | The formatted file to load into memory&nbsp;
==Parameters==
|-
[[Variable Types|STRING]] ''Filename''
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE[]
:The formatted file to load into memory
| width="90%" | Buffer
 
|-
[[Variable Types|BYTE[]]] ''Buffer''
| colspan="2" | A buffer to write the wave data to&nbsp;
:A buffer to write the wave data to
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
[[Variable Types|UINT]] ''SampleFormat''
| width="90%" | SampleFormat
:Variable to receive the format of the samples
|-
:''This parameter is returned back to the caller''
| colspan="2" | Variable to receive the format of the samples&nbsp;
 
|-
[[Variable Types|ULONG]] ''Elements''
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
:Variable to receive the number of sample elements to play
| width="90%" | Elements
:''This parameter is returned back to the caller''
|-
 
| colspan="2" | Variable to receive the number of sample elements to play&nbsp;
[[Variable Types|FLOAT]] ''SampleRate''
|-
:Variable to receive the wave source sample rate
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
:''This parameter is returned back to the caller''
| width="90%" | SampleRate
 
|-
 
| colspan="2" | Variable to receive the wave source sample rate&nbsp;
==Return value==
|-
[[Variable Types|BOOL]]
| 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''
Returns true if the operation is a success, else false
|}




Line 51: Line 51:
* Declare a variable 'result' of type BOOL
* Declare a variable 'result' of type BOOL
* Add to a calculation icon: <pre class="brush:[cpp]">result = ::Sound.LoadWav("filename", _arraybuffer, return_sampleformat, return_elements, return_samplerate)</pre>
* Add to a calculation icon: <pre class="brush:[cpp]">result = ::Sound.LoadWav("filename", _arraybuffer, return_sampleformat, return_elements, return_samplerate)</pre>
''<span style="color:red;">No additional examples</span>''

Latest revision as of 13:17, 13 July 2026

LoadWav
Loads a wave file into memory, providing the values needed to play it 
- STRING Filename
The formatted file to load into memory 
- BYTE[] Buffer
A buffer to write the wave data to 
- UINT SampleFormat
Variable to receive the format of the samples 
- ULONG Elements
Variable to receive the number of sample elements to play 
- FLOAT SampleRate
Variable to receive the wave source sample rate 
- BOOL Return


Detailed description

This loads WAV files given a Filename to the data. The Filename may point to a resource file. The data in the file should be in a RIFF format, see WAV file for a more detailed description of a WAV file.


On exit from the routine, the Buffer, SampleFormat, Elements and SampleRate are all updated to contain data read from the file. These are all written with zero values (Buffer is not altered) if the call fails.


If Buffer is not large enough for the wave data it is resized in the call to an appropriate size.


Examples

Calling in a calculation

  • Declare a variable 'result' of type BOOL
  • Add to a calculation icon:
    result = ::Sound.LoadWav("filename", _arraybuffer, return_sampleformat, return_elements, return_samplerate)