Audio overlap loop: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
m (Automated syntax highlighting fixup (second round - minor fixes))
Line 1: Line 1:
[[Category:Temporal media]]
{{draft task}}
{{draft task}}
'''Audio Overlap Loop''' is a program that produces an "echo chamber" effect by playing an audio file several times in an overlapping loop. A repetition level determines the number of times that the file is looped. For the purpose of this task, write a program that takes a parameter for the number of repetitions and plays the file ''loop.wav'' in an overlapping loop according to the number of repetitions.
'''Audio Overlap Loop''' is a program that produces an "echo chamber" effect by playing an audio file several times in an overlapping loop. A repetition level determines the number of times that the file is looped. For the purpose of this task, write a program that takes a parameter for the number of repetitions and plays the file ''loop.wav'' in an overlapping loop according to the number of repetitions.
Line 7: Line 8:
{{libheader| Winapi.Windows}}
{{libheader| Winapi.Windows}}
{{libheader| Winapi.MMSystem}}
{{libheader| Winapi.MMSystem}}
<syntaxhighlight lang=Delphi>
<syntaxhighlight lang="delphi">
program Audio_Overlap_Loop;
program Audio_Overlap_Loop;


Line 130: Line 131:
=={{header|Go}}==
=={{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.
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.
<syntaxhighlight lang=go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 191: Line 192:


=={{header|JavaScript}}/{{header|HTML}}==
=={{header|JavaScript}}/{{header|HTML}}==
<syntaxhighlight lang=JavaScript><script>
<syntaxhighlight lang="javascript"><script>
var j = prompt("Enter the sound manipulation level you want", "");
var j = prompt("Enter the sound manipulation level you want", "");
for(i=0; i<j; i++) {
for(i=0; i<j; i++) {
Line 201: Line 202:
=={{header|Julia}}==
=={{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.
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.
<syntaxhighlight lang=julia>const soundfile = "loop.wav"
<syntaxhighlight lang="julia">const soundfile = "loop.wav"


if length(ARGS) < 1
if length(ARGS) < 1
Line 219: Line 220:
{{trans|Go}}
{{trans|Go}}
As in Go version, we use Sox "play" command.
As in Go version, we use Sox "play" command.
<syntaxhighlight lang=Nim>import osproc, strutils
<syntaxhighlight lang="nim">import osproc, strutils


proc getValue[T: int | float](msg: string; minval, maxval: T): T =
proc getValue[T: int | float](msg: string; minval, maxval: T): T =
Line 252: Line 253:


=={{header|Phix}}==
=={{header|Phix}}==
<!--<syntaxhighlight lang=Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\AudioOverlapLoop.exw
-- demo\rosetta\AudioOverlapLoop.exw
Line 286: Line 287:
Either of these may be desirable in different circumstances, so both are left as an example.
Either of these may be desirable in different circumstances, so both are left as an example.


<syntaxhighlight lang=Tcl>package require Tk
<syntaxhighlight lang="tcl">package require Tk
package require snack
package require snack


Line 392: Line 393:
{{trans|Go}}
{{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.
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=ecmascript>/* audio_overlap_loop.wren */
<syntaxhighlight lang="ecmascript">/* audio_overlap_loop.wren */


class C {
class C {
Line 432: Line 433:
<br>
<br>
We now embed this in the following C program, compile and run it.
We now embed this in the following C program, compile and run it.
<syntaxhighlight lang=c>#include <stdio.h>
<syntaxhighlight lang="c">#include <stdio.h>
#include <stdio_ext.h>
#include <stdio_ext.h>
#include <stdlib.h>
#include <stdlib.h>
Line 525: Line 526:
return 0;
return 0;
}</syntaxhighlight>
}</syntaxhighlight>



{{omit from|Bc}}
{{omit from|Bc}}
Line 530: Line 532:
{{omit from|GUISS}}
{{omit from|GUISS}}
{{omit from|Lotus 123 Macro Scripting}}
{{omit from|Lotus 123 Macro Scripting}}

[[Category:Temporal media]]