iDevGames Forums
Sound using carbon - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Sound using carbon (/thread-7464.html)



Sound using carbon - NYGhost - Dec 6, 2002 05: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.


Sound using carbon - w_reade - Dec 6, 2002 05: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


Sound using carbon - NYGhost - Dec 8, 2002 03:29 PM

Smile 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.


Sound using carbon - w_reade - Dec 8, 2002 07: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.


Sound using carbon - Josh - Dec 8, 2002 08:58 PM

I have some code that shows how to pan using Sound Manager.


Sound using carbon - NYGhost - Dec 9, 2002 09:56 AM

I'll take a look at OpenAL

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

Thanks again..


Sound using carbon - Josh - Dec 9, 2002 11:50 AM

Code:
#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.


Sound using carbon - NYGhost - Dec 9, 2002 12:30 PM

Thanks Jabber !


Sound using carbon - NYGhost - Dec 10, 2002 11:37 PM

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-0Huh

Any suggestions?