Help needed porting some Sound Manager code

Member
Posts: 257
Joined: 2004.06
Post: #1
Yes. You read correctly. Sound Manager code. From the System 7 days. Wacko

So I've been given the unsavory task of bringing a Mac Classic application into the world of UBs and what not. I've managed to get about 90% of it working but the last bit I'm stuck on is trying to find modern equivalents of freqCmd and freqDurationCmd, which was used to play notes:

http://developer.apple.com/documentation...RKER-9-271

Apple's documentation points to using the rateMultiplierCmd as a replacement but that so far has not worked. My guess is that the Sound Manager API is now finally broken.

So I've been trying to find ways to replicate this functionality. My initial thought is to just stick in OpenAL and load the sound sample into a source and change the pitch when I play it back. However, the original code used MIDI notes so I'd have to figure out the pitch frequencies. My next thought was to use QuickTime but I can't tell if the API supports loading a sound sample and using it to play back notes. However, I'm probably just not looking at the documentation hard enough.

So, does anyone have any other suggestions or insight? I have to support 10.3.9 so I'm not sure if CoreAudio is available that far back.

The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
Malarkey Wrote:I have to support 10.3.9 so I'm not sure if CoreAudio is available that far back.

It is. I'm pretty sure CoreAudio has been available from the beginning.
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #3
Malarkey Wrote:Yes. You read correctly. Sound Manager code. From the System 7 days. Wacko

So I've been given the unsavory task of bringing a Mac Classic application into the world of UBs and what not. I've managed to get about 90% of it working but the last bit I'm stuck on is trying to find modern equivalents of freqCmd and freqDurationCmd, which was used to play notes:

http://developer.apple.com/documentation...RKER-9-271

Apple's documentation points to using the rateMultiplierCmd as a replacement but that so far has not worked. My guess is that the Sound Manager API is now finally broken.
At least it is not totally defunct. It isn't just some stupid endian error, so you need to swap the bytes in some constants? Apple have introduced some errors of that kind when moving to Intel. The ones I have ran into, I have been able to work around.

I was digging into audio about a week ago, and decided to keep my old, fully working SM code for now, and after that find a cross-platform solution. Core Audio is out; Apple provide few, if any, helpful demos, it has a reputation of being complicated to use (I havn't used it enough to judge that myself), and it would just lock me into another API that will change or go away any time. OpenAL, maybe.

I ask, what was wrong with Sound Manager? Why did it need replacing? Couldn't it just have been extended? Apple keeps doing this, forcing us to rewrite because they don't want to revise old APIs but instead make totally new ones. They do that over and over again, often with new APIs that are a lot more complicated than the old ones. It seems to me that Apple's user friendly culture does not carry over to the engineers.
Quote this message in a reply
Moderator
Posts: 3,573
Joined: 2003.06
Post: #4
Ingemar Wrote:I ask, what was wrong with Sound Manager? Why did it need replacing? Couldn't it just have been extended? Apple keeps doing this, forcing us to rewrite because they don't want to revise old APIs but instead make totally new ones. They do that over and over again, often with new APIs that are a lot more complicated than the old ones. It seems to me that Apple's user friendly culture does not carry over to the engineers.

I have to partially agree with this. I say "partially" because I didn't really think Sound Manager was all that great to begin with. What didn't make sense though is that they decided to make Core Audio, which is much worse in terms of being able to comprehend it IMHO, and like you said, the sample code is often poor if you can find any. The audio API engineers have had a tendency of over-complicating things since the start of OS X. Replacing Sound Manager wasn't a step forward for us.

Another API they unnecessarily threw in the garbage was Game Sprockets. I think that was a *huge* mistake. We struggled for a few years just trying to figure out the new windowing scheme in OS X, and many of us still to this day don't have joystick support -- that's like what, eight years later? Yeah, I'd call that a failure.
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #5
I'll have to pick up this thread again.

As I said, my own Sounds Manager code seems to work just fine, but I can't expect that to last. Even if SM is still around in 10.6, I would not be surprised if it is broken, has got some fresh and fatal bugs. So I'd like to move to something better.

Core Audio scares me. I havn't found any decent demos. I know how to record sounds (I took Apple's demo, simplified it to 1/3 of the size with no loss...) but not how to play.

What do you think about OpenAL? Or would I be better off with a third party library (like FMOD)? The perfect solution would be a static linked, free, cross-platform library, but I know that that is asking for a lot. Is there some package that I have missed?

Here is a pretty nice list of audio libs (a few years old though):

http://lists.wxwidgets.org/pipermail/wx-...83510.html

I am interested in both sound effects and music. QuickTime is pretty good for music. I have had some problems with crashing PPC code. but PPC is getting less and less important, so QuickTime seems OK for music, at least for the time being. But sound effects?
Quote this message in a reply
Moderator
Posts: 3,573
Joined: 2003.06
Post: #6
I don't know if you've already seen it, but Brian Greenstone made his book available for free. You can download it here. Chapter 10 has some good information on how to use Quicktime for music playback. Also has some Sound Manager code too, but more importantly there is some OpenAL stuff at the end of the chapter. It's written for slightly older OS X, but I imagine it's plenty up to date enough that it should get you on the right track.

An alternative to Quicktime for music playback would be to use Audio Queues. Audio Queues only works on the latest OS though, so it's not ideal.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Sound manager? Leroy 5 3,184 Sep 8, 2007 02:04 PM
Last Post: OneSadCookie