sl161022@silver.bacs.indiana.edu (01/25/89)
"There is no need for anyone to have a computer in their home."
-- Ken Olsen, president of
Digital, 1977
I program the Mac in assembly language, and appear to be the only person
in all of Bloomington to do so. Thus, I have no recourse but to seek
experienced programmers elsewhere.
I've heard that the Inside Mac Volume V description of the Sound Manager
is badly written and self-contradictory. After immersing myself in it
these past few days, I have no trouble believing this. ALL I WANT TO DO
is play a particular type 2 'snd ' resource, which is a digitally-sampled
sound. No fancy pitch changes. No frills. Just play the damn thing as
recorded!
The 'snd ' is loaded into memory. It's not going anywhere. I'm willing
to allocate my own section of memory for the SndChannel record. I know
where that is too. My program has already been loaded into a nice cozy
spot in the system heap, and I've redirected a trap to call my routine
first, which calls the original trap and then returns to play the sound.
I.e., whenever this particular trap gets called, my 'snd ' is to be played.
The above routine is working just fine as it is. Right now, it merely
does a _SysBeep whenever this trap is activated. But how in hell do
you get the Sound Manager to play the sound? Any guidance on this
question would be dearly appreciated.
As a side question: I want this sound to be played whenever the user
hits a key, but ONLY when TextEdit is active. When the user is in the
Finder or anywhere else where keystrokes do not produce characters on
the screen, I do NOT want my sound to be played. The way I'm doing this
now is by redirecting the trap _TEKey. I haven't tested it in many
different applications yet, but this seems to work as I want it too.
Can anyone else think of a different, perhaps better, way? (Just for
more options to consider.)
Be seeing you...
__________________________________________________________________
"May the forces of evil become confused on the way to your house."
-- George Carlin
Sincerely,
Phaedrus
(aka Colin Klipsch)
sl161022@silver.bacs.indiana.edu
Indiana University at Bloomingtonbob@accuvax.nwu.edu (Bob Hablutzel) (01/26/89)
> I program the Mac in assembly language, and appear to be the only person > in all of Bloomington to do so. Thus, I have no recourse but to seek > experienced programmers elsewhere. It's always nice to hear from another assembler language nut. (But, _no_, I will not discuss how nice assembler language is. Headaches like that I don't need again :-)) > I've heard that the Inside Mac Volume V description of the Sound Manager > is badly written and self-contradictory. Apple admits that the old Sound Manager chapter is "ambiguous, inaccurate, and often contradics itself". They have put out a new sound manager chapter (in Word format) which is designed to clear things up. I think it was posted to Comp.Binaries.Mac a while back, if not I can post it. > ALL I WANT TO DO > is play a particular type 2 'snd ' resource, which is a digitally-sampled > sound. No fancy pitch changes. No frills. Just play the damn thing as > recorded! One of the first things the new document does is give the sample code for playing a simple 'snd ' resource. They give it in Pascal: myChan := NIL; sndHandle := GetNamedResource( 'snd ', 'myBeep' ); myErr := SndPlay( myChan, sndHandle, FALSE ); In assembler, this would be: subq.l #4,sp move.l #'snd ',-(sp) pea myBeep _GetNamedResource move.l (sp)+,D0 beq NoGood tst.w ResErr bne NoGood subq.l #2,sp clr.l -(sp) move.l D0,-(sp) sf.b -(sp) _SndPlay tst.w (sp)+ bne NoGood > As a side question: I want this sound to be played whenever the user > hits a key, but ONLY when TextEdit is active. When the user is in the > Finder or anywhere else where keystrokes do not produce characters on > the screen, I do NOT want my sound to be played. The way I'm doing this > now is by redirecting the trap _TEKey. I haven't tested it in many > different applications yet, but this seems to work as I want it too. This sounds like a good way to go about things. You get the additional advantage that you are ensured that the heap is in a consistant state, since TEKey can't be called when the heap isn't. (Neither can SndPlay, I think, but IM V isn't here). > Be seeing you... Later > Phaedrus > (aka Colin Klipsch) > sl161022@silver.bacs.indiana.edu > Indiana University at Bloomington Bob Hablutzel Wildwood Software BOB@NUACC.ACNS.NWU.EDU