Jump to content

API Sound.Create: Difference between revisions

From Flowcode Help
Admin (talk | contribs)
XML import of API auto-gen
m Text replacement - "width="90%" style="background-color:#D8C9D8; color:#4B008D;"" to "width="90%" class="mtx-class-macrohead""
 
(16 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<sidebar>API contents</sidebar>
{| class="mtx-class-macrotable wikitable"
Creates a sound object that data can be played through
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''Create'''
|-
| colspan="2" | Creates a sound object that data can be played through&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" | SampleRate
|-
| colspan="2" | The number of samples per second&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | SampleBits
|-
| colspan="2" | The number of bits per sample - either 8 or 16&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
| width="90%" | Stereo
|-
| colspan="2" | True to treat each pair of samples as a stereo sample&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-h32-icon.png]] - HANDLE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




===Parameters===
==Detailed description==
''[[Variable types|ULONG]] SampleRate''
Sounds can only be played directly through the [[API Sound.Play|Sound.Play]] call or through a handle to a sound channel. Sounds played through a handle can be [[API Sound.Queue|queued]] and played in sequence, allowing multiple sounds to be played seamlessly.
:The number of samples per second
:''The default value for this parameter is: '''''44100'''


''[[Variable types|BYTE]] SampleBits''
:The number of bits per sample - either 8 or 16
:''The default value for this parameter is: '''''8'''


''[[Variable types|BOOL]] Stereo''
Sounds can be queued on an event, [[Event Sound.Complete|Sound.Complete]], which is a notification that any sound played through this mechanism has finished.
:True to treat each pair of samples as a stereo sample
:''The default value for this parameter is: '''''0'''


===Return value===
[[Variable types|HANDLE]]


No additional information
The parameters used here will define the basics of the sound and are used to define the underlying system. Any sounds played have their values adjusted by Flowcode to conform to these values - a sound played which has a native sample rate and details matching the parameters of this call will in general be more efficient and clearer than a sound where the sample rate has to be adjusted to fit.


===Detailed description===
''No additional information''


===Examples===
==Examples==
====Calling in a calculation====
===Calling in a calculation===
* Declare a variable 'result' of type HANDLE
* Declare a variable 'result' of type HANDLE
* Add to a calculation icon: <pre class="brush:[C]">result = ::Sound.Create(samplerate, samplebits, false)</pre>
* Add to a calculation icon: <pre class="brush:[cpp]">result = ::Sound.Create(samplerate, samplebits, false)</pre>

Latest revision as of 13:17, 13 July 2026

Create
Creates a sound object that data can be played through 
- ULONG SampleRate
The number of samples per second 
- BYTE SampleBits
The number of bits per sample - either 8 or 16 
- BOOL Stereo
True to treat each pair of samples as a stereo sample 
- HANDLE Return


Detailed description

Sounds can only be played directly through the Sound.Play call or through a handle to a sound channel. Sounds played through a handle can be queued and played in sequence, allowing multiple sounds to be played seamlessly.


Sounds can be queued on an event, Sound.Complete, which is a notification that any sound played through this mechanism has finished.


The parameters used here will define the basics of the sound and are used to define the underlying system. Any sounds played have their values adjusted by Flowcode to conform to these values - a sound played which has a native sample rate and details matching the parameters of this call will in general be more efficient and clearer than a sound where the sample rate has to be adjusted to fit.


Examples

Calling in a calculation

  • Declare a variable 'result' of type HANDLE
  • Add to a calculation icon:
    result = ::Sound.Create(samplerate, samplebits, false)