[comp.sources.wanted] Mac sound programs

brian@brazil.psych.purdue.edu (Brian Berndt) (06/05/90)

We are using this sample program as a subroutine in a larger program that plays 
files produced by a program called MacRecorder sampled at 7 kHz.  When played 
back with MacRecorder, these files sound fine.  However, when played back 
through PLAY SOUND.BAS (either alone or as a subroutine), they sound poor even 
when I adjust the rate parameters. 

	This sample program PLAY SOUND.BAS contains the following lines:

POKE WORD P&+2, 0		: ' RATE OF PLAY (INTEGER)
POKE WORD P&+4, 32768		: ' RATE OF PLAY (FRACTIONAL)

	By trial and error, we have found the following:
values for the fractional parameter affect the sound quality, namely values 
near 20849, give distorted sounds with clicks at the beginning and end of 
the sounds.  Values near 22500, give much better sound quality with much less 
noticeable clicks.  However, the improvement caused by using these values
varies.  It is greater in PLAY SOUND.BAS when it is a free-standing program
than when it is a subroutine and the improvement varies for Mac SE and Mac II.

	Is there an exactly correct value(s) that would be right in all
circumstances?  What would be a statement of the rule for determining 
these values?

*********** Sample sound program from ZBasic ***************************

	              PLAY SOUND.BAS
'
' This is a program that plays most of the MAC
' Start-up Sound files. Just run the program and
' select a valid start-up sound or cancel to exit

' NOTE: There are some example sounds in the SOUND folder
' where this program came from.
'
DO
  F$=FILES$(1,"FSSD",,V%)   	: ' OPEN A SOUND TYPE FILE
  IF F$="" THEN END         	: ' CANCELED FILES$
  TEXT 0,12 : CLS           	: ' SET TEXT SIZE AND CLEAR SCREEN
  OPEN "I",1,F$,1,V%        	: ' OPEN A SOUND TYPE FILE?
  L&=LOF(1)                 	: ' GET THE LENGTH OF FILE
  IF L&=0  THEN STOP        	: ' IF NO LENGTH THEN STOP
  P&=FN NEWPTR(L&+6)        	: ' ROOM FOR SOUND RECORD
  IF P&=0 THEN STOP         	: ' COULD NOT GET THE MEMORY
  READ FILE #1,P&+6,L&      	: ' READ INTO MEMORY
  CLOSE 1                   	: ' CLOSE THE FILE
  PRINT "File Name: ";F$    	: ' SHOW FILE NAME
  PRINT "Length:";L&;"bytes"
  POKE WORD P&,0            	: ' FREE FORM SYNTH
  POKE WORD P&+2,0      	: ' RATE OF PLAY (INTEGER)
  POKE WORD P&+4,32768  	: ' RATE OF PLAY (FRACTIONAL)
  A&=VARPTR(A$)             	: ' GET A PARAMETER BLOCK
  POKE LONG A&+12,0         	: ' NO COMPLETION ROUTINE
  POKE WORD A&+24,-4        	: ' SOUND DRIVER REF-NUMBER
  POKE LONG A&+32,P&        	: ' POINTER TO SOUND RECORD
  POKE LONG A&+36,L&        	: ' LENGTH  OF SOUND RECORD

  X=FN WRITE(A&)            	: ' PLAY THE SOUND (remove for async)
  X=FN DISPOSPTR(P&)        	: ' DISPOSE OF SOUND MEMORY (remove for asyn)

UNTIL Forever               	: ' ALL DONE....
STOP

  'MACHLG A$, &A403         	: ' delete remarks for AsynchronousSound
  'DO                       	: ' Asynchronous is background sound.
  '  PRINT ".";
  'UNTIL PEEK WORD (A&+16)=0