[comp.sys.mac.programmer] Problem with Sound Manager

west@turing.toronto.edu (Tom West) (12/07/90)

  I have a problem with the Sound Manager.  I can make it do ordinal notes 
without any problem.  However, when I try and make it play a frequency, it 
play nothing. 

	The following code plays nothing:

/* Play Middle A (440Hz) for 1 second */
    SoundChannelPtr channel = NIL;
    SndCommand cmd;

    cmd.cmd = noteCmd;
    cmd.param1 = 2000;
    cmd.param2 = 0xFF000000 + (440 * 256);

    (void) SndNewChannel (&channel, noteSynth, 0, (SndCallBackProcPtr) NULL);
    (void) SndDoCommand (channel, &cmd, false);
    (void) SndDisposeChannel (channel, false);

	But the following commands plays a note:

/* Play Middle C for 1 second) */
    SoundChannelPtr channel = NIL;
    SndCommand cmd;

    cmd.cmd = noteCmd;
    cmd.param1 = 2000;
    cmd.param2 = 0xFF000000 + 60;

    (void) SndNewChannel (&channel, noteSynth, 0, (SndCallBackProcPtr) NULL);
    (void) SndDoCommand (channel, &cmd, false);
    (void) SndDisposeChannel (channel, false);

Any advice or help would be greatly appreciated. Thanks in advance.

					Tom West
				    west@turing.toronto.edu
				    tomwest@gpu.utcs.utoronto.ca
				    west@hsa.on.ca

ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) (12/07/90)

Contrary to the documentation for the 6.0.7 Sound Manager, it does
*not* support frequencies specified as some number of Hertz, only
as discrete semitone note numbers.

I personally found this out with freqCmd, you've found it applies
to noteCmd as well.

My workaround was to use rateCmd to modify the pitch of the playing
note--this does support arbitrary fractional values, as documented.
It's a real kludge, I know, and I suspect it wouldn't work all that
well with a note that's already started playing. Myself, I was messing
around with notes of indefinite duration, so I could set the amplitude to
zero before changing the pitch, and then make it audible at the right
pitch.

The guy who wrote that Inside Mac chapter told me the reason for
the omission was to avoid compatibility problems with some software.
Hard to believe, but there you go...

Lawrence D'Oliveiro                       fone: +64-71-562-889
Computer Services Dept                     fax: +64-71-384-066
University of Waikato            electric mail: ldo@waikato.ac.nz
Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
>>insert worthless, irrelevant, space-consuming saying here<<