I have been trying to play a sound in the iphone, but I have not been able. Should’t this work? I don’t get any error message…
//in testApp.cpp - testApp::setup
Hey, ofSoundPlayer isn’t ported yet I’m afraid. Until it is, you can use Zach G’s openAL wrapper which is very similar in functionality
or if you’re feeling adventurous with Objective C you can have a look at the AVAudioPlayer class in the iPhone SDK
However, I have been trying to include it, but all I can get are the following errors
“ofxALSoundPlayer::ofxALSoundPlayer()”, referenced from:
“ofxALSoundPlayer::~ofxALSoundPlayer()”, referenced from:
ld: symbol(s) not found
collect2: ld returned 1 exit status
I’m sure that I am missing something basic argh!
not sure what’s going on there.
it looks like you’re missing files though.
were you sure you #include the file in testApp.mm?
and did you change testApp.cpp and main.cpp to mm files?
also did you include the soundEngine files with your project? (in the ofxAlSoundPlayer folder)
also you need to add the openAL.framework to your project…
that should do it
I can’t understand, I cannot make it work. I must be missing something obvious
Can somebody share with me a very simple xcodeproj with ofxALSoundPlayer included to see the differences with it?
I have changed file’s extensions, included, imported, everywhere it should go, added the openAL framework… it’s too strange
quickly, I think you are missing “ofxALSoundPlayer.cpp” from the project. you likely have the .h file, but not the .cpp file, so the code is compiling Ok, but failing on link (ld). Check to make sure that you have the addon src code included, in addition to the includes.
Well, I couldn’t. The Cpp file is also included in the addons folder of xcode. I have tried all ways, in folders, outside of them…
Isn’t there any “include ofxALSoundPlayer for dummies” around? I think my applications will have to be mute xD
I’ve tried to import the addon in a project made from scratch and i’ve the same problem, it says that could not find the addon, but i tried to import it from one of the examples provided in the OF for iphone package and it works great for me.
Someone know why it works with one of the examples provided and not for projects made by yourself??
If you’re using XCode you’ll need to make sure that both the h and cpp files are included in the project. I haven’t touched the iPhone stuff so I don’t know if you also need to muck around with the path settings, but I wouldn’t imagine so. Like Zach says, check that the file structure in your app matches that of the addon example, i.e. that all the same files are being included.
Also, if need be I suppose you could just drop it in the src folder of your application, but you shouldn’t have to do that.
there isnt any complicated path stuff…
it’s just 4 files you need to include
(the ofxAlSoundPlayer files and the soundEngine files)
the only other thing you need to do is go down to libs/core/core frameworks/ and right click. Select ‘add existing framework’ and pick OpenAL.framework
i talk about it on the wiki.
Yes, I did it that way, several times, always starting from sample iPhone projects downloaded from here and I’ve not been able to make it work
Maybe is something in my preferences… I’ll keep looking
I finally compiled the project without errors, and i’ve converted an .mp3 file to .caf format like is indicated in the addon files but i can’t hear anything.
Someone knows what happens if compile and runs correctly??
this is all pretty weird sounding. ill make an example file up soon and post it. hopefully that’ll clear some stuff up
Great! Thanks Zach
If anybody can also point me to a tutorial / example files related to this, it would be really helpful
I got it working. Some quick notes to whoever could have problems with this:
1.- DON’T download OpenAl from creativelabs.com. It already comes with OS X. Look for it at /System/Library/Frameworks/. More info: http://forums.macrumors.com/showthread.php?p=6280337
2.- To convert any audio file to something that the iPhone can play, this will do the trick. In terminal:
afconvert -f caff -d LEI16@44100 -c 1 in.wav out.caf
3.- Basic code that worked for me
ahh yeah that will do it haha.
when you do objective-c stuff for a while you get used to importing frameworks and forget that most people arent too aware of the included frameworks…
ill add a mention of that to the comprehensive guide
//— note this was miss-posted elsewhere
thanks for the excellent ofxALSoundPlayer class - it worked perfectly out the box!
( I hooked it up for this little dj app I made: http://vimeo.com/4353898 )
One thing I couldn’t find in it though a setPosition function - as in set the playback position within the track - ie setPosition(0.5) ( jump to half way through ).
Is that something that is missing from the SoundEngine class hence ofxALSoundPlayer?
I have not played around with the openAL thing yet, but I am using the remoteIO with pretty good success…
should get you rolling down the right path. I can currently get 2 stereo channels with mixing and low pass filters going without any problems. Once I get up past that, I run into speed issues (probably due to the fact that I am using floats instead of fixed point math), but that is a problem for a smarter person than me.
I will try to get my engine releasable soon.
theo- yeah thats exactly it. I havent gotten around to really digging into soundEngine yet. it seems pretty complicated.
I did add a function to import sounds from arrays, so I’m starting to understand what’s going on in soundEngine, but thats as far as I’ve gotten. I definitely want to add position information soon though
For those of you that have it working, can you post a caf file that you know works? I followed the guide, added the framework, renamed the cpp to mm, etc. The console shows the sound engine being initialized but I can’t hear anything. No errors are thrown either when I try playing the file.
I’m trying to get this to work as part of a class, but even without that I hear nothing.
This is the code:
I’ve tried putting in an incorrect file name just to make sure that it’s finding the file prooperly, and that definitely throws errors. Any ideas? I’ve tried a few caf files (converting aifs from terminal) but no luck thus far.