[comp.sys.mac.misc] controlling digitizer from Lisp

spector@brillig.cs.umd.edu (Lee Spector) (11/02/90)

I've just built a "Cedar Sound Digitizer" which is supposed to be fully
compatible with Farallon's "Mac Recorder" sound digitizer, and I'd like
to send it simple commands from Macintosh Allegro Common Lisp. Basically I'd 
like to tell it to start sampling, to stop sampling, and to save the captured 
sample to a file.  I know that there is a package called "MacRecorder 
Hacker's Toolkit" which allows such commands to be sent - but the code is all 
in C and assembly. I suppose I could go the foreign-function-interface route, 
but I'm not sure how and I'd rather not. So I'm looking for access to 
the digitizer from within Lisp.  If anyone has digitizer-related MACL code, 
or any other hints that might be useful, I'd really appreciate hearing from 
you.

 Thanks!  -Lee (spector@cs.umd.edu)

mikec@allspice.lcs.mit.edu (Mike Ciholas) (11/02/90)

In article <...> spector@brillig.cs.umd.edu (Lee Spector) writes:
>I've just built a "Cedar Sound Digitizer" which is supposed to be fully
>compatible with Farallon's "Mac Recorder" sound digitizer, and I'd like
>to send it simple commands from Macintosh Allegro Common Lisp. Basically I'd 
>like to tell it to start sampling, to stop sampling, and to save the captured 
>sample to a file.  [...stuff deleted...]       So I'm looking for access to 
>the  digitizer from within Lisp.  If anyone has digitizer-related MACL code, 
>or any other hints that might be useful, I'd really appreciate hearing from 
>you.
> Thanks!  -Lee (spector@cs.umd.edu)

There is, in fact nothing the software can do to talk to the sound
digitizer.  The digitizer just runs wide open and the software can
decide to listen to it or not.  Capturing sound samples is merely
listening to the serial port.

I suspect what you want is the following functions:

(setup-digitizer-port port)
	[port = which serial port]
	[returns T if port setup okay]

(get-one-sample)
	[returns the value of one sample]

(get-block-sample length)
	[returns an array length samples long of continuous sound]

C or assembly code will be required in all functions to talk directly
with the serial controller chip.  This may, or has, changed with
system 7 which has a sound input manager, presumably callable as any
other toolbox call (thus ACL will support it eventually).  Be aware
that when getting block samples, the computer will be completely
locked up since it doesn't allow interrupts during this period.  With
only 45 microseconds between samples, it is not reasonable to get each
sample, do some processing on it, then get the next, etc.

Hope this helps.

(PS: email me at mikec@lcs.mit.edu if you want info on how to get a
CEDAR Sound Digitizer (CSD).  It is an inexpensive, high-quality sound
digitizer for the mac that is compatible with the MacRecorder but
offers improved quality and an auto-level control.)

Mike Ciholas

mikec@lcs.mit.edu