# How can I solve these errors when using SimpleAudioEngine?

I want to use SimpleAudioEngine for the music in a cocos2d game I'm working on. When I import SimpleAudioEngine.h in my game layer I get syntax errors in CVPixelBuffer.h and CMFormatDescription.h.

I've created a new clean cocos2d application and imported SimpleAudioEngine and it worked just fine, thus the error is in the code of my application.

What do you think causes the errors with SimpleAudioEngine? How can I fix this?

EDIT:

Looks like the problem is with size_t width when creating CVPixelBuffer.

In this code:

CV_EXPORT CVReturn CVPixelBufferCreate(CFAllocatorRef allocator,
size_t width,
size_t height,
OSType pixelFormatType,
CFDictionaryRef pixelBufferAttributes,
CVPixelBufferRef *pixelBufferOut) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0);


It raises error for size_t width and saying:

/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVPixelBuffer.h:183: error: expected ';', ',' or ')' before numeric constant

• It's going to be extremely difficult / impossible to help you without some explanation of what the errors are. – user1430 Oct 5 '11 at 15:39
• If I'm not mistaken you have to add some frameworks to your project if you are using SimpleAudioEngine. I can't remember what exactly those frameworks were but it's possible that new project you are creating has those frameworks by default (maybe because of some template). – Ali1S232 Oct 5 '11 at 18:56
• @Gajet If you're using the cocos2d project templates everything is in place to use SimpleAudioEngine. – bummzack Oct 6 '11 at 6:29

I don't understand why you're using CVPixelBufferCreate here?

In my cocos2d projects I use the SimpleAudioEngine like this:

// play effect
[[SimpleAudioEngine sharedEngine] playEffect:@"MySoundEffect.caf"];

// play background music
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"MySoundLoop.mp3"];


Here's the API docs if you need to know about further methods.

• @oded It seems like I misunderstood your question, sorry. So disregard what I wrote above :). Still it seems odd that you get an error in CVPixelBufferCreate, because CoreVideo is usually not part of a cocos2d project. Did you add that framework yourself? – bummzack Oct 6 '11 at 6:41