196748Smarkm#!/bin/sh
296748Smarkm
396748Smarkm#
496748Smarkm# Copyright (c) 2002  The FreeBSD Project
596748Smarkm# All rights reserved.
696748Smarkm#
796748Smarkm# Redistribution and use in source and binary forms, with or without
896748Smarkm# modification, are permitted provided that the following conditions
996748Smarkm# are met:
1096748Smarkm# 1. Redistributions of source code must retain the above copyright
1196748Smarkm#    notice, this list of conditions and the following disclaimer.
1296748Smarkm# 2. Redistributions in binary form must reproduce the above copyright
1396748Smarkm#    notice, this list of conditions and the following disclaimer in the
1496748Smarkm#    documentation and/or other materials provided with the distribution.
1596748Smarkm#
1696748Smarkm# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1796748Smarkm# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1896748Smarkm# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1996748Smarkm# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2096748Smarkm# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2196748Smarkm# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2296748Smarkm# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2396748Smarkm# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2496748Smarkm# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2596748Smarkm# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2696748Smarkm# SUCH DAMAGE.
2796748Smarkm#
2896748Smarkm
2996748Smarkm#
3096748Smarkm# Inspired on spkrtest.pl, rewritten from scratch to remove perl dependency
3196748Smarkm# $VER: spkrtest 0.3 (9.5.2002) Riccardo "VIC" Torrini <riccardo@torrini.org>
3296748Smarkm# $FreeBSD$
3396748Smarkm#
3496748Smarkm
3596748SmarkmcleanExit() {
3696748Smarkm	rm -f ${choices}
3796748Smarkm	exit ${1:-0}
3896748Smarkm}
3996748Smarkm
4096748Smarkmtrap 'cleanExit 1' 1 2 3 5 15	# HUP, INT, QUIT, TRAP, TERM
4196748Smarkm
4296748Smarkmchoices=${TMP:-/tmp}/_spkrtest_choices.$$
4396748Smarkmspeaker=/dev/speaker
4496748Smarkm
4596748Smarkmtest -w ${speaker}
4696748Smarkmif [ $? -ne 0 ]
4796748Smarkmthen
4896748Smarkm	echo "You have no write access to $speaker or the speaker device is"
4996748Smarkm	echo "not enabled in kernel. Cannot play any melody! See spkr(4)."
5096748Smarkm	sleep 2
5196748Smarkm	cleanExit 1
5296748Smarkmfi
5396748Smarkm
5496748Smarkm/usr/bin/dialog --title "Speaker test" --checklist \
5596748Smarkm	"Please select the melodies you wish to play (space for select)" \
56217364Snwhitehorn	0 0 0 \
5796748Smarkm	reveille "Reveille" OFF \
5896748Smarkm	contact "Contact theme from Close Encounters" OFF \
5996748Smarkm	dance "Lord of the Dance (aka Simple Gifts)" OFF \
6096748Smarkm	loony "Loony Toons theme" OFF \
6196748Smarkm	sinister "Standard villain's entrance music" OFF \
6296748Smarkm	rightstuff "A trope from 'The Right Stuff' score by Bill Conti" OFF \
6396748Smarkm	toccata "Opening bars of Bach's Toccata and Fugue in D Minor" OFF \
6496748Smarkm	startrek "Opening bars of the theme from Star Trek Classic" OFF \
6596748Smarkm		2> ${choices} || cleanExit 0
6696748Smarkm
6796748Smarkmecho ""
6896748Smarkmtunes="`cat ${choices} | tr -d '\"'`"
6996748Smarkmfor tune in ${tunes:-DEFAULT}
7096748Smarkmdo
7196748Smarkm	case ${tune:-NULL} in
7296748Smarkm	DEFAULT)
7396748Smarkm		title="(default melody)"
7496748Smarkm		music="ec"
7596748Smarkm		;;
7696748Smarkm	reveille)
7796748Smarkm		title="Reveille"
7896748Smarkm		music="t255l8c.f.afc~c.f.afc~c.f.afc.f.a..f.~c.f.afc~c.f.afc~c.f.afc~c.f.."
7996748Smarkm		;;
8096748Smarkm	contact)
8196748Smarkm		title="Contact theme from Close Encounters"
8296748Smarkm		music="<cd<a#~<a#>f"
8396748Smarkm		;;
8496748Smarkm	dance)
8596748Smarkm		title="Lord of the Dance (aka Simple Gifts)"
8696748Smarkm		music="t240<cfcfgagaa#b#>dc<a#a.~fg.gaa#.agagegc.~cfcfgagaa#b#>dc<a#a.~fg.gga.agfgfgf."
8796748Smarkm		;;
8896748Smarkm	loony)
8996748Smarkm		title="Loony Toons theme"
9096748Smarkm		music="t255cf8f8edc<a>~cf8f8edd#e~ce8cdce8cd.<a>c8c8c#def8af8"
9196748Smarkm		;;
9296748Smarkm	sinister)
9396748Smarkm		title="standard villain's entrance music"
9496748Smarkm		music="mst200o2ola.l8bc.~a.~>l2d#"
9596748Smarkm		;;
9696748Smarkm	rightstuff)
9796748Smarkm		title="a trope from 'The Right Stuff' score by Bill Conti"
9896748Smarkm		music="olcega.a8f>cd2bgc.c8dee2"
9996748Smarkm		;;
10096748Smarkm	toccata)
10196748Smarkm		title="opening bars of Bach's Toccata and Fugue in D Minor"
10296748Smarkm		music="msl16oldcd4mll8pcb-agf+4.g4p4<msl16dcd4mll8pa.a+f+4p16g4"
10396748Smarkm		;;
10496748Smarkm	startrek)
10596748Smarkm		title="opening bars of the theme from Star Trek Classic"
10696748Smarkm		music="l2b.f+.p16a.c+.p l4mn<b.>e8a2mspg+e8c+f+8b2"
10796748Smarkm		;;
10896748Smarkm	esac
10996748Smarkm	echo "Title: ${title}"
11096748Smarkm	echo ${music} > ${speaker}
11196748Smarkm	sleep 1
11296748Smarkmdone
11396748SmarkmcleanExit 0
114