Audio overlap loop: Difference between revisions

m
syntax highlighting fixup automation
m (syntax highlighting fixup automation)
Line 7:
{{libheader| Winapi.Windows}}
{{libheader| Winapi.MMSystem}}
<langsyntaxhighlight lang=Delphi>
program Audio_Overlap_Loop;
 
Line 120:
vol := vol * (1 - decay);
end;
end.</langsyntaxhighlight>
{{out}}
<pre>Enter number of repetitions (1 to 20) :
Line 130:
=={{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.
<langsyntaxhighlight lang=go>package main
 
import (
Line 188:
err := cmd.Run()
check(err)
}</langsyntaxhighlight>
 
=={{header|JavaScript}}/{{header|HTML}}==
<langsyntaxhighlight lang=JavaScript><script>
var j = prompt("Enter the sound manipulation level you want", "");
for(i=0; i<j; i++) {
document.write("<bgsound src='loop.wav'>")
}
</script></langsyntaxhighlight>
 
 
=={{header|Julia}}==
Uses Julia's ability to run iterations of a 4 loop in separate threads to play a file 4 times, with each play 0.1 seconds out of sync with the previous play. Requires available threads on the CPU at Julia startup.
<langsyntaxhighlight lang=julia>const soundfile = "loop.wav"
 
if length(ARGS) < 1
Line 214:
end
end
</syntaxhighlight>
</lang>
 
=={{header|Nim}}==
{{trans|Go}}
As in Go version, we use Sox "play" command.
<langsyntaxhighlight lang=Nim>import osproc, strutils
 
proc getValue[T: int | float](msg: string; minval, maxval: T): T =
Line 249:
args.add $(i * delay)
args.add $decay2
echo execProcess("play", args = args, options = {poStdErrToStdOut, poUsePath})</langsyntaxhighlight>
 
=={{header|Phix}}==
<!--<langsyntaxhighlight lang=Phix>(phixonline)-->
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\AudioOverlapLoop.exw
Line 268:
<span style="color: #0000FF;">?</span><span style="color: #008000;">"done"</span>
<span style="color: #0000FF;">{}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">wait_key</span><span style="color: #0000FF;">()</span>
<!--</langsyntaxhighlight>-->
The distributed version also has a loop/wait for all channels to finish playing
before terminating the program, or you could just use sleep() or as above wait_key().
Line 286:
Either of these may be desirable in different circumstances, so both are left as an example.
 
<langsyntaxhighlight lang=Tcl>package require Tk
package require snack
 
Line 387:
 
make_gui
</syntaxhighlight>
</lang>
 
=={{header|Wren}}==
{{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.
<langsyntaxhighlight lang=ecmascript>/* audio_overlap_loop.wren */
 
class C {
Line 429:
args.add(decayS)
}
C.play(args.join(" "))</langsyntaxhighlight>
<br>
We now embed this in the following C program, compile and run it.
<langsyntaxhighlight lang=c>#include <stdio.h>
#include <stdio_ext.h>
#include <stdlib.h>
Line 524:
free(script);
return 0;
}</langsyntaxhighlight>
 
{{omit from|Bc}}
10,327

edits