Looking for a simple audio playback library for C++ [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I'm working on a simple audio player, which is going quite well, using Qt and everything. But I'm in need of a solid but simple Audio library. I don't need anything fancy such as 3D sound and what do I know what else these things got nowadays. I'm just looking for something simple and efficient.
A list of features I'm looking for:
Audio playback from files
.ogg, .mp3 and .flac should be supported at the very least.
Should be able to pause playback.
I am planning to use it in C++
See. Nothing huge or anything, but at the same time I am having a hard time finding something suitable. The platform I'm targeting is Windows 7.
Anyone out there that knows something that I might be looking for?

The best possible choice in my opinion is the BASS audio library, which is not open source, but free for non-commercial use.
It is used by the AIMP2 audio player, which you can use to check the sound quality, natively supports a lot of formats including MP3 and OGG, and uses plugins to support even more, including FLAC.

How about libavcodec ? Its LGPL. I'm not sure about ogg >_<

I have used BASS before from a Windows C++ program, and it is very simple to use - link the DLL and call a couple of methods to specify the file to play back.
It certainly handles MP3 playback from a file as that's what I was doing.
I wish I could verify OGG and Flac, but alas I'm behind a firewall that has the site blocked.

Miles is a good and commonly used audio library.

Came across a good answer to my own question via an answer of another. FFmpeg is almost exactly what I'm looking for. Thanks all.

I suggest Openframeworks or use of the rtAudio library - that openframeworks is using - directly. Oh, and on the side: rtAudio has pretty much no license restrictions. ;-)
Correct me, if I'm wrong.

DirectShow is actually pretty easy to use, flexible, and comes with Windows. There are a million examples, and it can be as easy or as sophisticated as you need it to be. When I throw together something that needs to play MP3s, I use it. Note that you are targeting Windows 7, so you could consider using Media Foundation instead.

I use a C++ encapsulation of FFMPEG : FOBS
Easy to use and C++ :)
EDIT:
Fobs is no longer maintained. However you can use it as a starting point to make your own C++ encapsulation of FFMPEG.

Related

C/C++ Sound OS API [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a question about sound.
I have used sound libraries like OpenAL in my projects before.
What I need, is insight as to what underling OS APIs these libraries use.
Even if each library provides an easy way to manipulate the input file
according to format, the very basic "raw byte-to-byte, send to the driver"
function has to exist.
I mean, surely there has to be a default api (one for windows, another for Linux)
that these libraries use. I don't suppose they use directly each sound
card's drivers, so the OS has to somehow do the magic. Am I correct?
Now, I know DirectX supports sound (Although I have never used it), but
DirectX isn't installed by default on windows, so I suppose it doesn't count,
and I have no idea what happens on Linux, and I would like to know about both.
I know it's probably impractical not to use a dedicated library, and I don't
really intend not to, but I'm curious about this subject.
So please indulge me.
So, for basic graphics it's OpenGL and DirectX... But what about sound?
Thank you in advance.
Each major platform has a number of API's that allow you to work with sound, On Windows and Mac there are Native Sound Api's that are used by default by the OS as well as well as others that are either Non-Standard or deprecated.
Have A look at he diagram HERE, it has a useful breakdown of many of the major sound API's across major platforms.
In addition to each platform having native sound API's there are also many cross platform API's that encapsulate the way that each native API works in order to allow you to write portable audio software.
For example there is: PortAudio which is a well know C language API
there is also RtAudio which is a C++ API for sound, but it is somewhat of an older C++ style in my opinion(Does not take advantage of post C++11 features).
I am currently working on my own more modern C++11 audio API which can be found HERE. At the moment my API is a thin wrapper around PortAudio that allows you to work with audio in a more modern C++ way.
Keep in mind, the library that you choose will also depend on what kind of audio work you intend to do. All of the libraries I have listed above deal with real-time audio processing and do not deal with audio files. If working with audio files is what you are trying to do you could use libsndfile which is a popular open source sound file manipulation API.
From the context of your question it sound like you have been dealing with sound primarily in a Game Dev related context. It's worth mentioning that working with sound at the level that most of the libraries I have suggested thus far will be at a much lower level than simply calling one function to play a sound file.
Trying to answer the question of how OpenAl interacts with the OS is an answer best left to reading the OpenAL documentation.
I would also suggest looking into basic digital audio theory as well as digital signal processing. There are many resources available for free online on either subject.
EDIT:
In regards to how audio API's work... The average audio api works off of several layers of abstraction between the programmer and the sound card. Typically the programmer is given a buffer of audio data stored as an array of values. The programmer will have requested a specific set of parameters that the system will use for playback (sampling rate, buffer size, number of channels). The programmer will do their work with the audio data and hand the output buffer over to the api which in turn will eventually hand the buffers data over to a device driver written specifically for the installed sound card. The driver for that sound card will have been implemented based off of an interface specified by the platform that the driver is targeting. That is why when you install a new sound card on a machine you may be required to install drivers for it, by installing the drivers you are giving the OS level api a means of communicating with the device.
(There is a lot more that goes on than is possible to easily explain, and i'm sure i have missed a few steps in the process. But I hope that should be a good enough explanation to get started)

Graphics for C++ cross-platform music making software [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
EDITED, see below
I need an library to display graphics of music notation on a music making software. It will be Sibelius-like: Basically the user creates the sheet music and the app sends midi output.
I'm not looking for an library to display music notation, as for various reasons i must implement it myself. Also, the library i'm looking for must be cross-platform (should run at least on Windows and Linux).
The graphics will be vector-based or drawn with functions like "line(point1, point2);"
(Before continuing let me state that i'm new to C++ and most of my experience is with interpreted languages - PureData and Processing, mostly)
Now to the question:
I've found Cinder. You think Cinder is sutiable for the task? If no, you might skip 2 and 3.
I don't have experience with OpenGL. I couldn't actually figure out if Cinder uses OpenGL exclusively or if it uses it only on demand. My doubt here is, when using OpenGL libraries my application will only be able to run on computers with dedicated graphics cards?
Cinder doesn't have the hability to create GUIs like Qt or GTK+. Is it possible to integrade Cinder in another window, created by Qt/GTK+/SDL/etc ? I want something like Sibelius, where you have normal GUI (buttons, menus, etc) integrated in the notation graphics window.
If Cinder is not a good option, what might you recommend for that specific application needs? OpenCV? SDL? SFML?
EDIT:
I see this was marked as off-topic. Sorry, i'm new here. I've seen some posts asking for this kind of recomendation so i thought it was okay. Well, i will try to be objective and straight-forward
Question:
I need to draw music notation graphics, but i don't want to deal with low-level stuff (like Cinder, SDL, SFML, Ati-Grain). So, what are the other technologies available? That is, what are the other options?
What you are describing is a LOT of work and something impossible for someone with limited programming experience such as yourself. C++ is neither an easy language nor a language that forgives.. it's not just about learning the syntax (as is the case with processing or similar languages with automatic garbage collection) - it's also about managing memory and other resources, invariants, etc - leaving aside the complexities of linkage, compilation, etc: in turn this prerequisites that you have a thorough understanding of how computers work at a lower level.
Anyway, I'll try to answer your questions:
You could do this with cinder - this would probably mean having to re-invent the wheel - but you can do. I wouldn't say, however, that cinder is really suitable for such a task. This is meant for accelerated 2D/3D computer graphics. What you want is some more generic GUI library (maybe QT?). Regarding midi-support, you'll probably have to rely on some other library for this anyway.
Most computers these days do support openGL. Again you don't really need openGL for what you want to do.
Yes you can do this in theory - but it won't be easy and it's not really necessary for what you want to do.
OpenCV definitely NOT. This is for image processing - i.e. raster graphics - you need vector graphics. Let aside that OpenCV's Highgui is really slow on certain things so you'd have to use some other library for rendering anyway. I have no experience with the other libraries. My suggestion would be to either use some interpreted language such as python, luaAV or maybe SuperCollider (which does have built-in midi support by the way) which is far easier than C++, or to search for some open-source music-notation alternative (if there any) -> you can always build something of your own upon an existent code-base - reinventing the wheel is not necessary...

C++ cross-platform framework for mobile app development [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Improve this question
I'm planning on developing mobile application for both iOS and Android and I want to use C++ for the development.
Which cross-platform framework is available for building mobile application using the C++ language.
I'm sure a lot of people have this question as well, so read this if you'd really like to know the answer. Marmalade is probably the BEST solution. Code once, deploy to mobile devices, desktops, even some TV's. Many popular games have been created with Marmalade.
Extensive games like:
Lara Croft and the Guardian of Light
Call of Duty: World at War Zombies
But also simple games like:
draw something.
Doodle Jump
They've added a free package. You can create your game for free and if you want to get rid of the ad splash screen, it's $150,- per year for mobile devices or $500,- per year for other devices as well.
A big advantage is the native speed. It doesn't matter what people claim about other languages like javascript or java (and unfortunately Qt, which of course isn't a language but you know what I mean) running as fast as C or C++. It's simply not true. For simple applications this is of course not important, but when you're looking at (simple) games, this is crucial.
At the moment version 7.3 is available, but this version has a problem with the ARM emulator. I would download 7.0.
Whether you choose Marmalade or not, make sure you read the documentation. You don't want to end up missing some functionality and switch to another option when you're almost finished.
I've looked into portable code between Android and iOS before and I don't think it's possible.
To release apps into the Android market it needs to be in Java, and anything with a GUI on iOS needs to use Objective-C.
You might be able to have partial portable C++ layer, but in reality it's probably quicker to write the same app twice in Java and Obj-C than it would be to write it once in C++ as a portable solution.
Qt or Wx-Widgets might have some support, but I have not looked into mobile platforms for these, and I suspect the reality is that Apple, Microsoft and Oracle want you to be tied into their technologies these days and have no incentive to make things portable.
C# and Java provide a complete framework that allows code to be written much quicker using well documented classes and libraries, especially when dealing with user interfaces.
C++ on the other hand relies on many open source projects that take a lot of effort to get functioning on multiple platforms, and much time is spent dealing with subtle platform problems.
My suggestion was simply that it might be easier to pick a language better suited to the platform you are dealing with, as C++ tends to be lower level than other languages, the syntax can seem verbose and many hours can be wasted trying to make things work that you would expect to just work, and unfortunately documentation for many open source projects is poor.
Maybe this can be considered to be an opinion, but then the shift from C++ to C# or Java commercially might also indicate that I'm not the only one believing this.
You can take a look on openFrameworks, maybe it fits on your needs:
http://openframeworks.cc/about/
There ARE solutions for C++ cross-platform development for Android and iPhone, despite what other answers say here.
The best is probably Marmalade, but it's expensive, so only useful for commercially viable apps: https://www.madewithmarmalade.com/
Then there's MoSync, which you can use for free. Unfortunately they went bankrupt last year, so there's no ongoing support. Still, might be worth a look depending on your needs. http://www.mosync.com
OpenFrameworks is one I hadn't seen, so thanks Rodrigo for that answer: http://openframeworks.cc/
There is no cross platform solution using C++, unless you're interested in making games. There are a few options available if you don't mind using another programming language. Take a look at Titanium SDK (Javascript), Xamarin (C#) or the multitude of HTML5/CSS/Javascript frameworks (Phonegap comes to mind).
Look for the DragonFire SDK it allows you to write apps and games in c/c++. Not cross-platform and never used it but looks good. It uses Visual Studio and has its own simulator for iOS development.

Open source libraries for sound effects in games [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
does aybody know about an open source sound library in C++ or some other popular language that can be used in open source games for recreating sounds and especifically in car racing games to recreate engine sound?
Thanks
A long time ago, there was OpenAL and was moderately successful on Linux.
It's fairly easy, modelled around the OpenGL library principles.
While you got a few answers regarding how to output sound I believe that wasn't your question.
If I got your question correctly I think "Sound Synthesis" is what you are looking for.
All you need is a bunch of generators (e.g. Sine, Sawtooth, Noise)
and filters (low,high,band); And combine these.
Next step would be adding LFOs (Low-Frequency-Oscillators) to modulate parameters of the generators and filters.
I'm aware that this is not the full answer you looked for, but sound synthesis is a science in itself and the above keywords should get you started on the right track.
As for realtime synthesis of SFX for games. Simple answer:
Don't do it!
It's a waste of resources and - unless you have very strict size limits - the size of the samples used for SFX won't kill you.
For our current game the average sample has a(n on disk) size of around 7KB.
(We use 16KHz, mono, ADPCM wavs most of the time.)
I've only trivially poked around with it, but SDL is a very popular, cross-platform, C++ game dev library. It includes support for graphics, sound, input.
I also recall that it's very modular. That is, it's less of a framework and more of a library than some other solutions. Give it a look.
Is there a specific reason you need open source, or is "source available" good enough? A popular one is fmod http://www.fmod.org
It is free for non-commercial products, and also offers sourcecode under a license. It is very popular and isused in many well known games.
The irrKlang sound engine is very popular amoung independent developers. It is free for non-commercial use and still very cheap, if you want to start earning some money with your game.
It supports all major plattforms (Windows, Linux, Mac) and has APIs for C++ and .Net languages.
I know it's an old question, but I think SFML needs to be represented here. SFML is available in C++, C, .Net (C#, VB.Net, C++/CLI, etc), Python, D, and Ruby, and is designed to be small and fast.
Features specific to audio:
Uses hardware acceleration whenever possible
Can load and save standard sound formats : ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64
Can load all audio resources directly from files in memory
3D sound spacialization
Easy interface for capturing audio
Manages memory efficiently, so that you don't have to worry about resources lifetime or storage
Supports streaming for big files ; you can even write your custom streaming class for any source (network, ...)
Supports multi-channels formats (mono, stereo, 4.0, 5.1, 6.1, 7.1)
For the specific question of recreating engine sounds, usually games take a single looping sound and adjust the pitch. An open source game that does this very well is VDrift.
SDL is Good Option for Graphics/Sound
QT frame work has also good support for sound and graphics
PortAudio is also good option

Is there any 'out-of-the-box' 2D/3D plotting library for C++? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I looked at the different options for plotting functions (or other types of graphs) in an interactive window. I mostly use wxWidgets but I'd be open to any other "interfaces".
Looking at what is available, here is what I've found:
wxPlot: Not updated since 2006. But it would be a good candidate if it was...
wxMathPlot: Very new, not mature, few features (still active?)
libgraph: Outdated, not rebust, 2D only and outputs images only.
koolplot: Too basic, no control over the created window.
EasyBMP: Very basic, only images output.
plotutils: Command line only.
plplot: C and C++ API are barely maintained. It is in fact on this that wxPlot is based. Could be a could candidate also if C and C++ interface we're updated.
Any comments? Ideas?
Thanks!
Even though this thread is old but gold. QCustomPlot is very recommendable as well to complement this list.
MathGL have many plot types, C/Fortran interface and basic data analysis
I'm all about ROOT for these needs. Pretty heavy if you don't need all the analysis support, though.
You have Qwt which is mature. There is a 3D version lurking somewhere. However, I have never been satisfied with the aesthetic result.
It may be worth waiting for Qt3D to come out to write something better yourself easily.
I programmatically provide required input files to GNUPlot executable and invoke it using system() function. It is suitable to my situation since I only want to visualize my data during research. But if you want the plotting functionality integrated into your executable file, maybe this is not for you :)
u can use DISLIN
it is quite neat!
Might wxChart be an option? I have not used it myself however and it looks like it hasnt been updated for a while.
Just an idea: Use Python as embeddable scripting language to plot your graphs. Python has a plethora of plotting libraries.
I found the game library Allegro easy to use back in the day. Might be worth a look.
We use an ancient version of ComponentOne Chart.
AntiGrain Geometry (AGG). http://www.antigrain.com/. Its an opensource 2D vector graphics library. Its a standalone library with no additional dependencies. Has good documentation. Python plotting library matplotlib uses AGG as one of backends.
Have a look at wxArt2d it is a complete framework for 2d editing and plotting. See the screenshots for more examples.
Some interesting features:
Reading and writing SVG and CVG
Several views of the same document
Changes are updated when idle
Optimized drawing of 2d objects
Hey! I'm the developer of wxMathPlot! The project is active: I just took a long time to get a new release, because the code needed a partial rewriting to introduce new features. Take a look to the new 0.1.0 release: it is a great improvement from old versions. Anyway, it doesn't provide 3D (even if I always thinking about it...).
OpenGL. It WILL be hard and possibly rewriting the wheel, though.
Keep in mind that OpenGL is a general 3D library, and not a specific plot library, but you can implement plotting based on it.