Where to start with Sound?
I'm developing a 2D game in C, and would like some sound. I've decided to use quicktime (It is my first game) but have no idea how to implement this. I will prepare .aiff sound files (Backround ditty, laser, blow up, etc etc) but how do I use these? 
Thanks

Thanks

~ Bring a Pen ~
This is rather a question of how to start with movies. It is almost the same code except that the audio doesn't need a window/view to be show in.
I don't think QuickTime is the best choice for instant sound effects. It is best used for background music and similar things.
I don't think QuickTime is the best choice for instant sound effects. It is best used for background music and similar things.
OK, how do I start with movies? I've looked everwhere, but I can't find any tutorials. Oh, and should I make my audio into .mov?
~ Bring a Pen ~
No, you don't need .mov, it works nicely with mp3, AIFF etc.
I thought I should post some sample code, but that code was a bit old, it uses OpenMovieFile which is outdated. So I can post something that works, but I think both you and I want newer code.
I thought I should post some sample code, but that code was a bit old, it uses OpenMovieFile which is outdated. So I can post something that works, but I think both you and I want newer code.
Hmm, might you be using Cocoa?
If you are/can, you might look into QTMovie docs - should be fairly easy to work with.
If you are/can, you might look into QTMovie docs - should be fairly easy to work with.
He said C, which to me means using QuickTime's stand-alone APIs. And there are updated calls, but I havn't figured out how to use them yet.
Ah, so the QT API is for C then eh? That's good, but my game's still silent.

~ Bring a Pen ~
The general consensus is that QuickTime is evil. People usually use OpenAL for sound.
My web site - Games, music, Python stuff
Ingemar Wrote:He said C, which to me means using QuickTime's stand-alone APIs. And there are updated calls, but I havn't figured out how to use them yet.
Hmm, I was under the impression that you could access the Cocoa API with C, or just dip into Objective-C.
Ignore my post then.

This code works (which doesn't mean I want to do exactly this way):
Does anyone has working (and reasonably simple) code for doing this with FSRefs?
Code:
/* C translation from Pascal source file: MovieHack.p */
// Super simple movie player for playing sounds (like mp3)
// Plays a file named "Sample.mp3" in the same folder as the binary.
#include <QuickTime/Movies.h>
Movie theMovie;
OSErr err;
FSSpec fileSpec;
short resRefNum;
SInt16 actualResId;
Rect theMovieBox;
WindowPtr w;
int main()
{
err = EnterMovies();
actualResId = DoTheRightThing;
// The following lines need replacing by FSRef-based calls
err = FSMakeFSSpec(0, 0, "\pSample.mp3", &fileSpec);
if ( err != noErr )
printf("FSMakeFSSpec %d\n", err);
err = OpenMovieFile(&fileSpec, &resRefNum, 0);
if ( err != noErr )
printf("OpenMovieFile %d\n", err);
err = NewMovieFromFile(&theMovie, resRefNum, &actualResId, 0L, newMovieActive, 0L);
if ( err != noErr )
printf("NewMovieFromFile %d\n", err);
// Try playing it
StartMovie(theMovie);
while ( ! IsMovieDone(theMovie) )
MoviesTask(0L,0);
DisposeMovie(theMovie);
ExitMovies();
}
Does anyone has working (and reasonably simple) code for doing this with FSRefs?
Well, that code doesn't work on my mac.
Thanks anyway.
So, according to diordna, QT is evil. I should use OpenAL. I've two questions:
• I read somewhere that OpenAL will only work on the customers mac if they've installed OpenAL. This could be a problem.
• Is there a new(ish) tutorial/guide on OpenAL for mac?
Could someone please answer my questions, or post some sample code.
Thanks

So, according to diordna, QT is evil. I should use OpenAL. I've two questions:
• I read somewhere that OpenAL will only work on the customers mac if they've installed OpenAL. This could be a problem.
• Is there a new(ish) tutorial/guide on OpenAL for mac?
Could someone please answer my questions, or post some sample code.
Thanks
~ Bring a Pen ~
FSSpec? WindowPtr? 
I don't think we should be recommending to new users that they use deprecated technologies. While the QuickTime C API might not be entirely deprecated yet, it's rapidly moving in that direction. Unfortunately, modern technologies like OpenAL and CoreAudio are somewhat more daunting...
mikey, I have some reasonably simple OpenAL code that I'll post here when I get home. Also, OpenAL is installed as part of the OS as of Mac OS X 10.3 (someone correct me if it's 10.4, but I was pretty sure it was 10.3), so you shouldn't need to worry about that.

I don't think we should be recommending to new users that they use deprecated technologies. While the QuickTime C API might not be entirely deprecated yet, it's rapidly moving in that direction. Unfortunately, modern technologies like OpenAL and CoreAudio are somewhat more daunting...
mikey, I have some reasonably simple OpenAL code that I'll post here when I get home. Also, OpenAL is installed as part of the OS as of Mac OS X 10.3 (someone correct me if it's 10.4, but I was pretty sure it was 10.3), so you shouldn't need to worry about that.
Thanks everyone, I'll post my game when it's finished!
PS. I'm looking forward to ThemsAllTook's OpenAL Code.
PS. I'm looking forward to ThemsAllTook's OpenAL Code.
~ Bring a Pen ~
ThemsAllTook Wrote:FSSpec? WindowPtr?I feared that kind of replies. That is exactly why I initially didn't post the code at all, but I hoped someone would be helpful and patch it up with the new calls (which I tried but didn't have time to get to work). Did you at all notice that I clearly stated, three times, that the FSSpec should be replaced by FSRef-based calls? (And the WindowPtr is not used at all.)
I don't think we should be recommending to new users that they use deprecated technologies.
Ingemar Wrote:Did you at all notice that I clearly stated, three times, that the FSSpec should be replaced by FSRef-based calls? (And the WindowPtr is not used at all.)
Sure, but even FSRef is still part of Carbon, which Apple has clearly stated is not and will not be supported on 64-bit architectures. To call Carbon's future even "uncertain" would be incredibly optimistic. The QuickTime C API is in the same boat. Apple's been recommending that all new development be done with Cocoa APIs for many years now, and they're finally starting to take steps to enforce that. In order to stay relevant to the Mac scene, iDevGames needs to be up to date on Apple's technological best practices, which really don't include anything Carbon anymore.