Audio frequency generator: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
Thundergnat (talk | contribs) m (Automated syntax highlighting fixup (second round - minor fixes)) |
||
Line 1: | Line 1: | ||
⚫ | |||
[[Category:Sciences]] |
|||
[[Category:Sound]] |
|||
⚫ | |||
{{draft task}} |
{{draft task}} |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
An audio [[wp:Signal_generator|frequency generator]] produces a continual audible monotone at a set frequency and level of volume. |
An audio [[wp:Signal_generator|frequency generator]] produces a continual audible monotone at a set frequency and level of volume. |
||
There are controls to adjust the frequency and the volume up and down as desired. |
There are controls to adjust the frequency and the volume up and down as desired. |
||
Line 30: | Line 28: | ||
=={{header|Action!}}== |
=={{header|Action!}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="action!">byte |
||
volu,dist,freq,key=764 |
volu,dist,freq,key=764 |
||
Line 86: | Line 84: | ||
=={{header|Axe}}== |
=={{header|Axe}}== |
||
{{untested|Axe}} |
{{untested|Axe}} |
||
<syntaxhighlight lang=axe>ClrHome |
<syntaxhighlight lang="axe">ClrHome |
||
Disp "FREQ:",i |
Disp "FREQ:",i |
||
10→F |
10→F |
||
Line 105: | Line 103: | ||
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. |
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. |
||
<syntaxhighlight lang=go>package main |
<syntaxhighlight lang="go">package main |
||
import ( |
import ( |
||
Line 178: | Line 176: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
Uses the PortAudio library. |
Uses the PortAudio library. |
||
<syntaxhighlight lang=julia>using PortAudio |
<syntaxhighlight lang="julia">using PortAudio |
||
if Sys.iswindows() |
if Sys.iswindows() |
||
Line 295: | Line 293: | ||
=={{header|Locomotive Basic}}== |
=={{header|Locomotive Basic}}== |
||
<syntaxhighlight lang=locobasic>10 mode 1:input "Enter initial frequency in Hz";f:cls |
<syntaxhighlight lang="locobasic">10 mode 1:input "Enter initial frequency in Hz";f:cls |
||
20 if sq(2)<128 then sound 2,62500/f,100 |
20 if sq(2)<128 then sound 2,62500/f,100 |
||
30 a$=inkey$ |
30 a$=inkey$ |
||
Line 308: | Line 306: | ||
{{trans|Go}} |
{{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. |
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. |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="nim">import osproc, strutils |
||
type Waveform {.pure.} = enum |
type Waveform {.pure.} = enum |
||
Line 340: | Line 338: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
<syntaxhighlight lang=perl>use strict 'vars'; |
<syntaxhighlight lang="perl">use strict 'vars'; |
||
use feature 'say'; |
use feature 'say'; |
||
use feature 'state'; |
use feature 'state'; |
||
Line 377: | Line 375: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
<!--<syntaxhighlight lang= |
<!--<syntaxhighlight lang="phix">(notonline)--> |
||
<span style="color: #000080;font-style:italic;">-- demo/rosetta/Audio_frequency_generator.exw</span> |
<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> |
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> |
||
Line 641: | Line 639: | ||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
<syntaxhighlight lang=ring> |
<syntaxhighlight lang="ring"> |
||
# Project : Audio frequency generator |
# Project : Audio frequency generator |
||
Line 812: | Line 810: | ||
SuperCollider is a sound programming language, so the task is predictably easy. |
SuperCollider is a sound programming language, so the task is predictably easy. |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="supercollider"> |
||
// the server application detects audio hardware. |
// the server application detects audio hardware. |
||
Server.default.boot; |
Server.default.boot; |
||
Line 849: | Line 847: | ||
{{libheader|Snack}} |
{{libheader|Snack}} |
||
This does not work on Windows due the use of the external <tt>stty</tt> program. |
This does not work on Windows due the use of the external <tt>stty</tt> program. |
||
<syntaxhighlight lang=tcl>package require sound |
<syntaxhighlight lang="tcl">package require sound |
||
set baseFrequency 261.63 |
set baseFrequency 261.63 |
||
Line 916: | Line 914: | ||
{{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_frequency_generator.wren */ |
<syntaxhighlight lang="ecmascript">/* audio_frequency_generator.wren */ |
||
class C { |
class C { |
||
Line 961: | Line 959: | ||
<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 1,065: | Line 1,063: | ||
There is no volume control on the Spectrum. |
There is no volume control on the Spectrum. |
||
<syntaxhighlight lang=zxbasic>10 REM The crappest signal generator in the world |
<syntaxhighlight lang="zxbasic">10 REM The crappest signal generator in the world |
||
20 REM We do not check for boundary errors in this simple demo |
20 REM We do not check for boundary errors in this simple demo |
||
30 LET n=1 |
30 LET n=1 |
||
Line 1,074: | Line 1,072: | ||
80 BEEP 0.1,n: REM beep for 0.1 second at n semitones relative to middle C |
80 BEEP 0.1,n: REM beep for 0.1 second at n semitones relative to middle C |
||
90 GO TO 40</syntaxhighlight> |
90 GO TO 40</syntaxhighlight> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ |