Jump to content

API Sound.LoadWav: Difference between revisions

From Flowcode Help
m Text replacement - "width="10%" align="center" style="background-color:#D8C9D8;" align="center"" to "width="10%" align="center" class="mtx-class-macrohead""
m Text replacement - "width="90%" style="background-color:#D8C9D8; color:#4B008D;"" to "width="90%" class="mtx-class-macrohead""
 
Line 2: Line 2:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''LoadWav'''
| width="90%" class="mtx-class-macrohead" | '''LoadWav'''
|-
|-
| colspan="2" | Loads a wave file into memory, providing the values needed to play it 
| colspan="2" | Loads a wave file into memory, providing the values needed to play it 

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)