REM Play a DigiSound sample
REM By R.A.Waddilove
REM FAST BASIC

POKE $484,2				:\keyclick off
TXTSIZE 13
TXTRECT 0,0,SCREENWIDTH, SCREENHEIGHT : CLS

dummy%=ALERT("[3][Digital sounds created| with Digisound from  |    Alpha Systems][ Wow! ]",1)
dummy%=ALERT("[3][Sounds played with portions|of software copyright Alpha|    Systems (c) 1987][ Understood ]",1)

RESERVE pgm%,1500 :REM space for program code
RESERVE sample%,20000 :REM space for sample

BLOAD "basplay.exe",pgm%
pgm% = pgm% + 28			:\skip header

REPEAT
	sample$ = FNselect_file	:\get sample filename
	BLOAD sample$,sample%	:\load sample data into buffer
	file% = OPENIN sample$	:\get sample length
	size% = EXT#file% - 648	:\ size of sample file - 648 (envelope data)
	CLOSE#file%
	pgm%!6 = sample%		:\set start of sample data
	pgm%!10 = size%		:\set sample length
	REM Speed:  5k=7  8k=6  10k=5  16k=4  20k=3  25k=2  32k=1  40k=0
	speed% = 3 + ALERT("[3][select replay speed][ 16k | 10k | 8k ]",2)
	pgm%!14 = speed%		:\set sample speed
	PRINT TAB(11,1);"Pump up the volume!"
	FOR i%=1 TO 5
		CALL pgm%			:\play sample
	NEXT
UNTIL ALERT("[3][Another one?][ Yes | No ]",1) = 2
END

DEF FNselect_file
LOCAL file$,name$
file$=PATH$ + "*.SND"
name$ = ""
button% = 0
FSELECT file$,name$,button%
IF button%=0 OR name$="" THEN END
WHILE RIGHT$(file$,1)<>"\"
	file$=LEFT$(file$,LEN(file$)-1)
WEND
CLS
= file$ + name$
