[comp.sys.mac.programmer] Simple sound manager question

leipold@eplrx7.uucp (Walt Leipold) (02/13/91)

I use the following procedure to play some short 'snd ' resources:

    static void playNamedSoundResource(char *s)
    /* 's' is a Pascal-format string (with leading length byte) */
    {
        Handle h;
        OSErr e;
    
        h = GetNamedResource('snd ',s);
        if (h != NULL) {
            e = SndPlay(NULL,h,false);
            ReleaseResource(h);
            }
    }

This works fine for type 1 'snd ' resources, but plays the (recommended)
type 2 resources (the kind that HyperCard likes) at the wrong sampling rate
(too fast).  Also, I've noticed that ResEdit (at least the 1.2 vintage)
plays these sounds too fast.  Does anybody know a simple way to get these
type 2's to play correctly, or am I gonna have to get intimate with the
Sound Manager chapter?

Thanks!

-----------------------------------------------------------------------------
Global warming: Everybody's doing something about                Walt Leipold
the weather, but nobody's talking about it.        (leipolw%esvax@dupont.com)
-----------------------------------------------------------------------------
--
The UUCP Mailer

vrm@blackwater.cerc.wvu.wvnet.edu (Vasile R. Montan) (04/10/91)

I am attempting to figure out how the Sound Manager works, and
want to start by simply playing a single asynchronous sound.
I have a resource file containing the Harpsichord sound from
HyperCard, and the following code:

program SndTest;
  uses
    Sound;
  var
    Harpsichord: Handle;
    result : OSErr;
begin
  Harpsichord := GetResource('snd ', 190);
  Result := SndPlay(nil, Harpsichord, FALSE);
end.

Result end up being 0, indicating that nothing went wrong, but there
is no sound to be heard.  What's wrong?

--Kurisuto
un020070@vaxa.wvnet.edu