Open Source sound engine - c++

When I started using SoundEngine (from CrashLanding and TouchFighter), I had read about a few people recommending not to use it, for it was, according to them, not stable enough. Still it was the only solution I knew of to play sounds with pitch and position control without learning C++ and OpenAL, so I ignored the warnings and went on with it.
But now I'm starting to worry. The 2.2 SDK introduced AVFoundation. Using both SoundEngine from CrashLanding (for sounds) and AVAudioPlayer (for music), I found out SoundEngine behaves strangely when the only existing AVAudioPlayer is released (all sounds stop until a new AVAudioPlayer is initiated). Around the same time as the 2.2 SDK came out, the CrashLanding sample code was mysteriously removed from the ADC site. I'm worried there are more bad surprises to come.
My question is, is anyone aware of an Open Source alternative to SoundEngine? Maybe even a C++ library that uses OpenAL?

Look at this library, but i don't know is this what you need.

The Kowalski project provides a data driven and portable sound engine that currently runs on iOS, OS X and Windows. The engine is released under the zlib license and provides positional audio, pitch control etc.

ObjectAL for iPhone
Clone it. Use it. Love it. Enjoy the freedom.

Why not just use AVFoundation? It's pretty simple to handle and nicely flexible - apart from if you need exact timing (says the Apple documentation - but I've been testing it fairly extensively and yet to find any significant practical issues) I don't see any reason for not leveraging it.

AVFoundation lacks sound placement. This makes me sad.

I’ve written a simple sound engine around OpenAL. There are no position controls (I didn’t need them), but they would be trivial to add if you find the rest to your liking. And there is also some experimental sound code in the Cocos2D engine. It has both pitch and position controls and looks quite usable.

Related

Why should cocos2d-iphone users avoid using the #2x file extension?

Cocos2d-iphone uses the -hd extension for Retina images (and other assets). The cocos2d Retina guide speaks only vaguely of "some incompatibilities" regarding #2x:
Apple uses the ”#2x” suffix, but cocos2d doesn't use that extension
because of some incompatibilities. Instead, cocos2d has its own
suffix: ”-hd”.
WARNING: It is NOT recommend to use the ”#2x” suffix. Apple treats
those images in a special way which might cause bugs in your cocos2d
application.
Great. I feel well informed.
Through a 2-year old bug report regarding #2x I got the link to a forum thread that supposedly explains the issues with #2x. However, it does not. The only hints I found in there is that there are iOS (4.0/4.1) bugs regarding #2x which I suppose are no longer relevant. It's possible that I might have missed some crucial aspect (there was some talk about caching or repeat loading issues) - the thread is very long after all.
I'd like to know what specific issues might a cocos2d developer encounter if (s)he is using the #2x suffix for images instead of -hd?
Please give concrete examples of things that might go or actually will be wrong.
This seems to be the main reason from this link: http://www.cocos2d-iphone.org/forum/topic/12026
Specifically this post by riq:
I don't know if initWithContentsOfFile was fixed, but in 4.0 it was broken and it wasn't working with #2x, ~iphone extensions.
imageNamed caches all the loaded files so it consumes much more memory than initWithContentsOfFile
Also the #2x extension does something (I don't know exactly what) but it doesn't work OK with cocos2d.
Another good point: Back when the iPhone 4 was just released with the retina display, I am sure some users of Cocos2D were using an older version of it so when the user was using the retina display on a version of Cocos2D that didn't support it, things were twice as large as they should've been. Again this is now fixed to most unless you are using a VERY early version of Cocos2D.
Overview, so it seems that the main issue was with initWithContentsOfFile from iOS 4 but they have fixed this since because I use that exact API with Cocos2D 2.0-rc2 in my app and I do not have any issues whatsoever. I use all Apple specified extensions for images and everything works jolly good! :)
It seems as if this has a historic background.
What makes using -hd graphics still worthwhile is that loading them doesn't rely on Apple functionality but is rather done in framework code. So -hd can be loaded for iPads in iPhone Simulator mode and make use of the higher resolution pictures in 2x mode.
Other than that I couldn't find any more reasons to not use #2x when I was looking into this a week ago.
In case you want all the details it is probably best to drop riq an email.

Simple C++ Sound API

My commercial embedded C++ Linux project requires playing wav files and tones at individual volume levels concurrently. A few examples of the sounds:
• “Click” sounds each time user presses screen played at a user-specified volume
• Warning sounds played at max-volume
• Warning tones requested by other applications at app-specified volume level (0-100%)
• Future support for MP3 player and/or video playback (with sound) at user-specified volume. All other sounds should continue while song/video is playing.
We're using Qt as our UI framework which has QtMultimedia and Phonon support. However, I heard the former has spotty sound support on Linux and the latter is an older version and may be deprecated in an upcoming Qt release.
I've done some research and here are a few APIs I've come across:
KDE Phonon
SFML
PortAudio
SDL_Mixer
OpenAL Soft
FMOD (though I'd prefer to avoid license fees)
ALSA (perhaps a bit too low-level...)
Other considerations:
Cross-platform isn't required but preferred. We'd like to limit dependencies as much as possible. There is no need for advanced features like 3D audio or special effects in the foreseeable future. My team doesn't have much audio experience so ease-of-use is important.
Are any of these overkill for my application? Which seems like the best fit?
Update:
It turns out we were already dependent on SDL for other reasons so we decided on SDL_Mixer. For other Embedded applications, however, I'd take a long at the PortAudio/libsndfile combo as well due to their minimal dependencies.
libao is simple, cross-platform, Xiphy goodness.
There's documentation too!
Usage is outlined here - simple usage goes like this:
Initialize (ao_initialize())
Call ao_open_live() or ao_open_file()
Play sound using ao_play()
Close device/file using ao_close() and then ao_shutdown() to clean up.
Go for PortAudio. For just plain audio without unneeded overhead such as complex streaming pipelines, or 3D, it is the best lib out there. In addition you have really nice cross-platform support. It is used by several professional audio programs and has really high quality.
i have used SDL_Mixer time and time again, lovely library, it should serve well for your needs, the license is flexible and its heavily documented. i have also experimented with SFML, while more modern and fairly documented, i find it a bit bulky and cumbersome to work with even tho both libraries are very similar. imo SDL_Mixer is the best.
however you might also want to check out this one i found a few weeks ago http://www.mpg123.de/, i haven't delved too much into it, but it is very lightweight and again the license is flexible.
There is a sound library called STK that would meet most of your requirements:
https://ccrma.stanford.edu/software/stk/faq.html
Don't forget about:
FFmpeg: is a complete, cross-platform solution to record, convert and stream audio and video.
GStreamer: is a library for constructing graphs of media-handling components. The applications it supports range from simple Ogg/Vorbis playback, audio/video streaming to complex audio (mixing) and video (non-linear editing) processing.

Three.js ported to native code?

I've been playing with WebGL quite a bit lately and I really dig Three.js. It's really lightweight and just serves as something that makes wrangling most of the GL calls a bit easier, and provides a quick way of creating basic primatives like a sphere.
Now, in native land, it seems that all the frameworks want to be so much more than that. Things like Oolong, UDK, Unity, Cocos, etc. I did a bit of googling, and the closest thing I could find was iSGL3D but I'm not thoroughly convinced it is the right answer.
Is there something more similar to Three.js that is written in native C, C++ or Objective-C that I can't find?
Here is a port of three to C++: https://github.com/jdduke/three_cpp
Core - 75% complete (TODO: Morph targets, shadows, plugin support)
Extras - 5-10% complete (TODO: Pretty much everything)
Examples - 25% complete (TODO: Examples involving morph targets an)
You're asking for a strict graphics engine only, in the same direction as OpenGL (in comparison to DirectX which again wants to be so much more than that). I'd advise Ogre3D for iPhone as the philosophy behind Ogre3d is to be a strict graphics engine.
The other one that comes to mind is recently perused MoSync mobile sdk which offers excellent OpenGL support across a wide range of platforms (albeit limited; to maintain portability).
If you're more interested in loading shaders and having the graphics engine manage the rest, I'd pick Ogre3D for iPhone.
You can always take the initiative (if you have the time of course) to write your own or start off from the ones mentioned here!
Or you can use a JavaScript engine (JSAPI for example) in a C++ editor and then move three.js on top of that. This is great as you'll only update the JSAPI and Three.js without breaking functionalities and your C++/JSThree engine will stay up to date with minimal maintenance.
Just some ideas of course!
Although I would also prefer to see a port of three.js for iOS, recently stumbled up on iSGL3d (http://isgl3d.com/).
This project serves a simple, encapsuled way to build an manipulate an opengl scene graph by code. Otherwise than some creative coding frameworks like cinder, iSGL3d comes in pure Objective C.
Works well for me yet.
You could also give Ejecta a go. They just added WebGL/three.js support.
https://github.com/phoboslab/Ejecta/tree/next
Three_cpp is good, but has stopped updating since 3 years ago. It does not support VS version below 2012.
Ogre is another good choice, which is much similar to the logic of Threejs:)
And the official site provides a very detailed tutorial, making it easy to use!
After some more searching I found a stripped down version of SIO2 called GFX that looks promising.
If you're looking for strictly ease-of-use, I'd highly recommend Panda3D. It's cross-platform (Windows, Unix, Mac), really easy to use, has extensive documentation, and a nice community around it.

Sound output through M-Audio ProFire 610

I got an assignment at work to create a system which will be able to direct sound to different output channels of our sound card. We are using M-Audio ProFire 610, which has 8 channel output and connects through FireWire. We are also using a Mac Mini as our host server and I'm gonna be working in Xcode.
This is the diagram of what I am building:
diagram http://img121.imageshack.us/img121/7865/diagramy.png
At first I thought that Java will be enough for this project, however later on I discovered that Java is not able to push sound to other than default output channels of the sound card so I decided to switch to C++. The problem is that I am a web developer and I don't have any experience in this language whatsoever - that is why I am looking for help from more experienced developers.
I found a Core Audio Primer for ios4 but not sure how much of it I can use for my project. I find it a bit confusing, too.
What steps should I take to complete this assignment? What frameworks should I use? Any code examples? I am looking for any help, hints, tips - well anything that will help me complete this project.
If you're just looking for audio pass-through, you might want to look at something that's already been built, like Jack which creates a software audio device that looks and works just like a real one (you can set it as default output for your app) and then allows you to route each channel anywhere you want (including to other applications).
If you want/need to make your own, definitely go with C++, for which there are many many tutorials (I learned from cplusplus.com). CoreAudio is the low-level C/C++ interface as Justin mentioned, but it's really hard to learn and use. A much simpler API is provided by PortAudio, for which I've worked a bit on the Mac implementation. Look at the tutorials there, make something similar for default input and output, and then to do the channel mapping use PaMacCore_SetupChannelMap, which is described here. You'll need to call it twice, once for the input stream and once for the output stream. Join the mailing list for PortAudio if you need more advice! Good luck!
the primary APIs are at CoreAudio/AudioHardware.h
most of the samples/supporting code provided by apple is in C++. however, the APIs are totally C (don't know if that helps you or not).
you'll want to access the Hardware Abstraction Layer (aka HAL), more details in this doc:
http://developer.apple.com/documentation/MusicAudio/Conceptual/CoreAudioOverview/CoreAudioOverview.pdf
for (a rather significant amount of) additional samples/usage, see $DEVELOPER_DIR/Extras/CoreAudio/

Playing Sound in C++

I need to play sound in C++.
It should be compatible across all platforms.
Thanks,
goerdy
Try OpenAL, FMOD or SDL_mixer. The choice is wide.
std::cout << "\a\a\a\a\a\a\a\a";
)))
My suggestion is to go with OpenAl (3D cross platform Audio API)
It's fairly easy to learn and meant to have a similar flow of programming as OpenGl. It's free and has different extensions to take advantage of sound cards. OpenAl has a library akin to OpenGl's Utility Toolkit (GLUT) that's called freealut. It makes things even simpler.
This might be a good place to get started:
http://www.devmaster.net/articles/openal/
Some of the functions in that code are deprecated but reading the documentation, you'll be able to update it.
The devmaster tutorial also teaches you how to load ogg vorbis (royalty free) files into memory and play them. You'll need to download and build libvorbis and libogg to do that but there's good documentation and, in case you're using Visual Studio, already made solutions.
The fact that Creative Labs (largest sound card manufacturer) is a major contributor to the project is a great point in it's favor. Hardware will not be ignored.
Last thing, remember to download the OpenAl SDK and link to the proper libraries and include directories. There's always a lot of people asking for specific files stored inside it.
"Compatible to all platforms" is a bit of a tall order. After all, "all platforms" includes the controller in your car, the regulator in a nuclear plant, and the router in your network.
If you mean "all desktop platforms", you may have a bit more luck. While it is impossible to produce sound in 100% standards C++, there are libraries that are available. However, I don't think that even these will get you "all platforms". Are you willing to settle for "most common platforms"?