PDA

View Full Version : Sound using carbon


NYGhost
2002.12.06, 07:23 PM
Hello all, I've been looking for some sample code on sounds for carbon OS X without any luck, any advise would be appreciated.

Thank you all.

w_reade
2002.12.06, 07:58 PM
I found the old Sound Manager functions easiest to deal with - you should be able to find something using them somewhere in the Source Code section (where I learned from), or you could download the source to MAFFia (my uDG entry), which I know has it. It's 3.8 MB, mostly graphics I'm afraid, but sound.c should have most of what you need.

http://www.btinternet.com/~julianreade/maffcode.dmg.sit

NYGhost
2002.12.08, 05:29 PM
:) Thanks w_reade I have some sounds working!!
I'm working on 3D game using Open GL, I wanted to have more control ever the sound, but for now your suggestion will do just fine.

Once I got something ready to show I'll post it here.

I wish Apple had an easier way to deal with sounds on 3D.

w_reade
2002.12.08, 09:19 PM
My pleasure, glad to help.

Oh yeah - If you're using OpenGL, how about OpenAL for the sound? I've never used it myself but I hear it has a similar interface to OpenGL, and may offer the control you're afterÖ it might be just what you're looking for.

Josh
2002.12.08, 10:58 PM
I have some code that shows how to pan using Sound Manager.

NYGhost
2002.12.09, 11:56 AM
I'll take a look at OpenAL

Jabber is it possible to take a look at code or a demo?

Thanks again..

Josh
2002.12.09, 01:50 PM
#define kFullLeft -kFullVolume
#define kFullRight kFullVolume

OSStatus PanSpeakers(SndChannelPtr theChannel, short panPos)
{
short theVolumeLeft, theVolumeRight;
OSStatus err;
SndCommand theCmd;

theVolumeRight = kFullVolume + panPos;
theVolumeLeft = kFullVolume - panPos;

theCmd.param1 = 0;
theCmd.param2 = (long)((long)theVolumeRight << 16L | theVolumeLeft);
theCmd.cmd = volumeCmd;

err = SndDoImmediate(theChannel, &theCmd);
return err;
}
Should work with Mac OS 9 and X. panPos should be anywhere between -128 to 128. -128 being full left speaker, 0 begin center and 128 being full right speaker.

NYGhost
2002.12.09, 02:30 PM
Thanks Jabber !

NYGhost
2002.12.11, 01:37 AM
:shock: I really wanted to use OpenAL, but My project is carbon CFM and OpenAL is a framework.
I looked at the sample code CallMachOFramework from Apple, but it only works with frameworks in the System/Library/frameworks not on Library/frameworks.

Should I change all my code to work with Mach-0:???:

Any suggestions?