Audio alarm: Difference between revisions
m
syntax highlighting fixup automation
(→{{header|Phix}}: replaced with gui version) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 4:
=={{header|AutoHotkey}}==
Uses Run for maximum compatibility
<
FileSelectFile, File, 3, %A_ScriptDir%, File to be played, MP3 Files (*.mp3)
Sleep Seconds*1000
RunWait % file</
=={{header|AWK}}==
<
# syntax: GAWK -f AUDIOALARM.AWK
BEGIN {
Line 32:
exit(0)
}
</syntaxhighlight>
=={{header|Batch File}}==
<
@echo off
Line 52:
timeout /t %time% /nobreak >nul
start "" "%alarm%.mp3"
</syntaxhighlight>
{{out}}
<pre>
Line 62:
{{libheader| Bass}}
'''Bass''' is a third part library, free for non-commercial use, can be found here [https://www.un4seen.com]. Require a '''bass.dll''' in the same folder of executable.
<
program AudioAlarm;
Line 159:
BASS_StreamFree(Music);
BASS_Free();
end.</
{{out}}
<pre>Enter name of .mp3 file to play (without extension) :
Line 177:
=={{header|EchoLisp}}==
<
(lib 'timer)
(lib 'audio)
Line 200:
Time to wake-up ;; + ... 🎼 🎶🎵🎶🎵
</syntaxhighlight>
=={{header|FreeBASIC}}==
<
Dim As String song
Input "Delay in seconds: ", sec
Line 215:
Exec(exename, song)
Sleep</
=={{header|Go}}==
As Go does not have any audio support in its standard library, this invokes the SoX utility's 'play' command to play the required .mp3 file.
<
import (
Line 263:
log.Fatal(err)
}
}</
=={{header|Java}}==
<
import java.io.File;
import java.util.Scanner;
Line 304:
System.exit(0); // To stop the JavaFX thread.
}
}</
=={{header|JavaScript}}/{{header|HTML}}==
<
<script>
var a=prompt("Enter a number of seconds", "");
var b=prompt("Enter the name of an MP3 file you have installed in the directory (without extension)", "");
document.write("<meta http-equiv='refresh' content='"+a+";url="+b+".mp3'>")
</script></
=={{header|Julia}}==
Works when the computer will play an MP3 file with the "play" command.
<
(secs = tryparse(Int, readline())) == nothing && (secs = 10)
Line 327:
sleep(secs)
run(`play "$soundfile"`)
</syntaxhighlight>
=={{header|Kotlin}}==
For this to work on Ubuntu, 'glib' and 'libav-tools' need to be installed on your system.
<
import javafx.application.Application
Line 379:
val fileName = readLine()!! + ".mp3"
AudioAlarm.create(seconds, fileName)
}</
Sample input:
Line 391:
If not already running, this will add an extra delay...
It will error if the mp3 file does not exist in the specified path.
<
prompt "Delay in seconds"; sec$
Line 404:
run "C:\Program Files\Windows Media Player\wmplayer.exe " +chr$(34) +f$ +chr$(34)
end</
=={{header|Lua}}==
Line 410:
luasdl2 and luafilesystem libraries required.
<
mixer = require "SDL.mixer"
lfs = require "lfs"
Line 425:
print("Press Enter to quit")
io.read()
</syntaxhighlight>
=={{header|Nim}}==
{{Trans|Go}}
<
var delay: int
Line 460:
stdout.eraseScreen()
if execShellCmd("play $#.mp3" % filename) != 0:
echo "Error while playing mp3 file."</
=={{header|OCaml}}==
requires mpg123 to be installed.
<
| 0 -> ()
| n -> Sys.command "sleep 1"; wait (n - 1);;
Line 477:
wait time;;
Sys.command ("mpg123 " ^ fileName);;
</syntaxhighlight>
=={{header|Phix}}==
<!--<
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\AudioAlarm.exw
Line 584:
<span style="color: #7060A8;">IupMainLoop</span><span style="color: #0000FF;">()</span>
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span>
<!--</
=={{header|Pure Data}}==
Line 703:
{{works with|Python|3.4.1}}
<
import os
Line 710:
time.sleep(float(seconds))
os.startfile(sound + ".mp3")</
=={{header|Racket}}==
Racket does not currently have native mp3 support so this example uses system to call an external application.
<
(display "Time to wait in seconds: ")
(define time (string->number (read-line)))
Line 723:
(when (file-exists? (string->path (string-append file-name ".mp3")))
(sleep time)
(system* "/usr/bin/mpg123" (string-append file-name ".mp3")))</
=={{header|REXX}}==
===using SLEEP===
<
say '──────── Please enter a number of seconds to wait:'
Line 739:
call sleep waitTime
MP3FILE'.MP3'
/*stick a fork in it, we're done.*/</
'''output''' when using the input of: <tt> xxx </tt>
===using spin===
<
say '──────── Please enter a number of seconds to wait:'
Line 757:
MP3FILE'.MP3'
/*stick a fork in it, we're done.*/</
=={{header|Ring}}==
<
# Project : AudioAlarm
Line 771:
sleep(sec)
system("C:\Ring\wmplayer.exe C:\Ring\calmosoft\" + f)
</syntaxhighlight>
Output:
Line 779:
requires mpg123 to be installed.
<
seconds = gets.chomp.to_i
puts "Enter a MP3 file to be played"
Line 785:
sleep(seconds)
pid = fork{ exec 'mpg123','-q', mp3filepath }
</syntaxhighlight>
=={{header|Tcl}}==
{{libheader|Snack}}
<
fconfigure stdout -buffering none
Line 805:
snd destroy
puts "all done"
exit</
=={{header|Wren}}==
Line 812:
Currently, DOME can only playback .wav and .ogg files so we use the former here.
<
import "graphics" for Canvas, Color
import "audio" for AudioEngine
Line 851:
}
var Game = AudioAlarm.new()</
=={{header|XPL0}}==
Works on Raspberry Pi.
<
char FN(80), Ext;
[Text(0, "Number of seconds to wait? ");
Line 872:
DelayUs(Time * 1_000_000);
PlaySoundFile(FN);
]</
=={{header|Yabasic}}==
<
input "What file to play: " song$
wait sec
Line 881:
system("explorer " + song$)
exit 0</
=={{header|zkl}}==
There is no built in sound support so this example is coded for my Linux box.
A change: rather than seconds to wait, a time is used.
<
file:=ask("File to play: ") + ".mp3";
Line 899:
//Atomic.sleep(time);
//System.cmd("mplayer "+file);
</syntaxhighlight>
{{out}}
<pre>
|