Difference between revisions of "API Sound.SetRate"

From Flowcode Help
Jump to navigationJump to search
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
+
|-
<sidebar>API contents</sidebar>
+
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
Sets the current sample rate for the sound - this will stop the playing sound
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetRate'''
 
+
|-
<div style="width:25%; float:right" class="toc">
+
| colspan="2" | Sets the current sample rate for the sound - this will stop the playing sound&nbsp;
====Class hierarchy====
+
|-
[[API Sound|Sound]]
+
|-
:[[API Sound|SetRate]]
+
| width="10%" align="center" | [[File:Fc9-h32-icon.png]] - HANDLE
</div>
+
| width="90%" | Sounds
__TOC__
+
|-
 
+
| colspan="2" | The handle of the sound object to modify&nbsp;
==Parameters==
+
|-
[[Variable Types|HANDLE]] ''Sounds''
+
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
:The handle of the sound object to modify
+
| width="90%" | Rate
 
+
|-
[[Variable Types|ULONG]] ''Rate''
+
| colspan="2" | The sample rate to set&nbsp;
:The sample rate to set
+
|-
 
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - NONE
 
+
| width="90%" style="border-top: 2px solid #000;" | ''Return''
==Return value==
+
|}
''This call does not return a value''
 
  
  
 
==Detailed description==
 
==Detailed description==
The base sample is specified in creation through [[API Sound.Create|Sound.Create]]. This call does not alter that rate, but specifies a scale factor for the samples played. Subsequent sounds played through this handle will have their wave-forms transformed using this scale factor as a step. Linear interpolation is used to smooth the waveform.
+
The base sample is specified in creation through [[API Sound.Create|Sound.Create]]. This call stops the current playing sound and resets that rate. Subsequent sounds played through this handle will play at the given rate.
 
 
  
The conversion factor is calculated as (Original_Rate / ''Rate''), meaning a ''Rate'' of zero is illegal and will cause the call to fail.
 
  
 +
If the sound handle is currently playing samples, these will be cleared meaning noticeable glitches may occur. To avoid this, use the ''RateMul'' parameter in [[API Sound.Queue|Sound.Queue]] or [[API Sound.QueueEx|Sound.QueueEx]] to perform software conversion per wave, which will not glitch.
  
  
Line 34: Line 32:
 
===Calling in a calculation===
 
===Calling in a calculation===
 
* Add to a calculation icon: <pre class="brush:[cpp]">::Sound.SetRate(sounds, rate)</pre>
 
* Add to a calculation icon: <pre class="brush:[cpp]">::Sound.SetRate(sounds, rate)</pre>
 
''<span style="color:red;">No additional examples</span>''
 

Latest revision as of 11:55, 16 January 2023

Fc9-comp-macro.png SetRate
Sets the current sample rate for the sound - this will stop the playing sound 
Fc9-h32-icon.png - HANDLE Sounds
The handle of the sound object to modify 
Fc9-u32-icon.png - ULONG Rate
The sample rate to set 
Fc9-void-icon.png - NONE Return


Detailed description

The base sample is specified in creation through Sound.Create. This call stops the current playing sound and resets that rate. Subsequent sounds played through this handle will play at the given rate.


If the sound handle is currently playing samples, these will be cleared meaning noticeable glitches may occur. To avoid this, use the RateMul parameter in Sound.Queue or Sound.QueueEx to perform software conversion per wave, which will not glitch.


Examples

Calling in a calculation

  • Add to a calculation icon:
    ::Sound.SetRate(sounds, rate)