I figured out how to use audiere with Windows....(this is my solution, but you might find this useful as a starting point if you want to use this and you need to do something similar)...
I get a whole bunch of warning messages about to do with having virtual functions but not having a virtual destructor...don't know how to get rid of these, but it still works.
1) download binaries for 1.9.4 package for windows
2) from this package, you only need 3 files...audiere.h, audiere.dll and audiere.lib which are in different directories.
3) rename audiere.lib to audiere.a
4) copy audiere.dll to the same directory where your executable will run from so it can be found at runtime.
5) copy audiere.a to linker directory and add it to the file list in the project.
6) copy audiere.h to your source directory where all your other *.h files are.
7) in the *.h file of your source code, add #include "audiere.h" (note not <angle brackets>)
also in the *.h file, add the following as global variables (I don't use namespaces so I specify the fully qualified name)
audiere::AudioDevicePtr device;
audiere::OutputStreamPtr sound;
9) In your *.cpp file, in the constructor, add the following:
device = audiere::OpenDevice();
10) Add a timer so you can monitor the when the sound clip finishes playing. For me, it fires 4 times a second. When the clip is finished, the timer is stopped. Here is my code:
void MyClass::OnTimerEvent( wxTimerEvent& event )
{
bool restartTimer = true;
bool isItPlaying;
timer.Stop();
isItPlaying = sound -> isPlaying();
// check status of audio clip
if (isItPlaying == false)
timer.Start(250);
else {
// re-enable any controls you disabled while audio clip was playing
} // end else
} // end OnTimerEvent
11) In your code where you actually want to kick off (load and play) the sound clip - add something like this:
(note you need char_str method to pull it out of a wxString object)
fileName.sprintf(wxT("c:\\testsound.mp3"));
sound = audiere::OpenSound(device, fileName.char_str(), true);
sound -> play();
timer.Start(250);
12) Suppose you already have the clip loaded and want to play it again without reloading it. In that case, just repeat the last two lines from step 11 (sound -> play(); and timer.Start(250);)
In a nutshell that should get you started.
using audiere with windows to play mp3 clips Topic is solved
-
- Knows some wx things
- Posts: 30
- Joined: Sun May 04, 2008 6:41 pm
-
- Moderator
- Posts: 19163
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Re: using audiere with windows to play mp3 clips
Thanks, i was looking for an audio library that can be used in a commercial application without buying a licence. I never heard of this one before, maybe because it hasn't seen an update for so many years.
From the header file:I get a whole bunch of warning messages about to do with having virtual functions but not having a virtual destructor...don't know how to get rid of these, but it still works.
Code: Select all
* Note: When compiling this header in gcc, you may want to use the
* -Wno-non-virtual-dtor flag to get rid of those annoying "class has
* virtual functions but no virtual destructor" warnings.
Use the source, Luke!