Audio frequency generator: Difference between revisions
m
syntax highlighting fixup automation
No edit summary |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 30:
=={{header|Action!}}==
<
volu,dist,freq,key=764
Line 83:
sndrst() mar=2 graphics(0)
return</
=={{header|Axe}}==
{{untested|Axe}}
<
Disp "FREQ:",i
10→F
Line 99:
Output(5,0,F▶Dec)
Freq(F,10000)
End</
=={{header|Go}}==
Line 105:
The duration of the monotone is set in advance (to a small number of seconds) and the application ends when it finishes playing. Consequently, a method to silence it is not required.
<
import (
Line 173:
err := cmd.Run()
check(err)
}</
=={{header|Julia}}==
Uses the PortAudio library.
<
if Sys.iswindows()
Line 291:
@async(inputtask(chan))
playtone(ostr)
</syntaxhighlight>
=={{header|Locomotive Basic}}==
<
20 if sq(2)<128 then sound 2,62500/f,100
30 a$=inkey$
Line 303:
70 locate 1,1:print f"Hz "
80 print:print " Use h and l to adjust frequency;":print " q to quit."
90 goto 20</
=={{header|Nim}}==
{{trans|Go}}
As in the Go version, we use the Sox "play" command to emulate the audio frequency generator. This version is a faithful translation of the Go version, even if the way things are done is pretty different.
<
type Waveform {.pure.} = enum
Line 337:
let args = ["-n", "synth", $dur, $kind, $freq, "vol", $vol, "dB"]
echo execProcess("play", args = args, options = {poStdErrToStdOut, poUsePath})</
=={{header|Perl}}==
<
use feature 'say';
use feature 'state';
Line 374:
return $freq;
}
}</
=={{header|Phix}}==
<!--<
<span style="color: #000080;font-style:italic;">-- demo/rosetta/Audio_frequency_generator.exw</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 439:
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</
=={{header|Pure Data}}==
Line 641:
=={{header|Ring}}==
<
# Project : Audio frequency generator
Line 804:
ok
return
</syntaxhighlight>
Output:
Line 812:
SuperCollider is a sound programming language, so the task is predictably easy.
<
// the server application detects audio hardware.
Server.default.boot;
Line 844:
// sound stops on exit
Server.default.quit;
</syntaxhighlight>
=={{header|Tcl}}==
{{libheader|Snack}}
This does not work on Windows due the use of the external <tt>stty</tt> program.
<
set baseFrequency 261.63
Line 911:
# Stop the sound playing
$sound stop
exit</
=={{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.
<
class C {
Line 958:
var args = ["-n", "-V1", "synth", durS, kindS, freqS, "vol", volS, "dB"].join(" ")
C.play(args)</
<br>
We now embed this in the following C program, compile and run it.
<
#include <stdio_ext.h>
#include <stdlib.h>
Line 1,053:
free(script);
return 0;
}</
=={{header|ZX Spectrum Basic}}==
Line 1,065:
There is no volume control on the Spectrum.
<
20 REM We do not check for boundary errors in this simple demo
30 LET n=1
Line 1,073:
70 PRINT AT 0,0;n," "
80 BEEP 0.1,n: REM beep for 0.1 second at n semitones relative to middle C
90 GO TO 40</
|