Audio overlap loop: Difference between revisions

Added FreeBASIC
m (→‎{{header|Wren}}: Changed to Wren S/H)
(Added FreeBASIC)
 
(One intermediate revision by one other user not shown)
Line 129:
Enter decay between repetitions (0.01 to 0.99) :
0.2</pre>
 
=={{header|FreeBASIC}}==
{{libheader| FMOD}}
[https://www.fmod.com/core Library FMOD]
<syntaxhighlight lang="vbnet">#Include "fmod.bi"
 
Sub PlaySound (nombrearchivo As String, repeticiones As Integer, retardo As Integer, decaimiento As Single)
Dim As Single volumen = 1.0
Dim As Integer canal, sonido
' Initialize FMOD
FSOUND_Init(44100, 32, 0)
For i As Integer = 1 To repeticiones
' Cargar el archivo de sonido
sonido = FSOUND_Sample_Load(FSOUND_FREE, nombrearchivo, FSOUND_NORMAL, 0, 0)
If sonido = 0 Then
Print "Error: Failed to load the sample!"
FSOUND_Close
Exit Sub 'END
End If
' Play the sound at the current volume
canal = FSOUND_PlaySound(FSOUND_FREE, sonido)
FSOUND_SetVolume(canal, volumen * 255) ' FMOD uses a volume range of 0 to 255
' Wait for the specified delay
Sleep retardo
' Apply the decay
volumen *= decaimiento
' Release the sound
FSOUND_Sample_Free(sonido)
Next i
' Close FMOD
FSOUND_Close
End Sub
 
Dim As Integer repeticiones, retardo
Dim As Single decaimiento
 
' Get the parameters from the user
Input "Enter the number of repeticiones: ", repeticiones
Input "Enter the retardo between repeticiones (in milliseconds): ", retardo
Input "Enter the decaimiento factor (between 0 and 1): ", decaimiento
 
' Play the sound
PlaySound("loop.wav", repeticiones, retardo, decaimiento)</syntaxhighlight>
 
=={{header|Go}}==
As Go does not have any audio support in its standard library, this invokes the SoX utility's 'play' command with the appropriate parameters to achieve the 'echo chamber' effect.
Line 393 ⟶ 443:
{{trans|Go}}
The ability to call external processes such as ''SoX'' is expected to be added to Wren-cli in the next release. In the meantime, we embed the following Wren script in a C host to complete this task.
<syntaxhighlight lang="wren">/* audio_overlap_loopAudio_overlap_loop.wren */
 
class C {
Line 509 ⟶ 559:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "audio_overlap_loopAudio_overlap_loop.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
2,127

edits