Open In App

Audiere Library

Last Updated : 09 Oct, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

Audiere is a high-level Audio API developed by Chad Austin and Matthew Campbell. It was released on 6 August 2001. It supports direct sound in Windows as well as in Linux. It can play sounds in formats like WAV, MP3, as well as any formats. It can be used in many languages like C, C++, Java, etc.

Installing Audiere:

  • For Linux/Windows: For setting up the environment you can download the Audiere package from this website.
  • For MinGW: Build all the dependencies for Audiere, including libogg, libvorbis from xiph.org, libspeex, libdumb and FLAC from the below command:
    ./configure --prefix=/mingw && make && make install
    

Setting the Environment:

  1. Download Audiere for windows.
  2. Extract the downloaded file.
  3. Create a New Folder.
  4. Place audiere.dll and some music files lets say .mp3 files in it.
  5. Open DevCPP and Start a Console Project in the directory.
  6. Open the main.CPP file of the project.
  7. Go to Project Options and in Directories state the include path of the audiere.h file and in parameters add to the linker path <strong\lib\audiere.lib.

Header File:

#include <audiere.h>

Below are some of the function used in this library:

  1. play(): It is used to play the audio file.
  2. stop(): It is used to stop the audio file.
  3. isPlaying(): It is used to check if any file is playing or not.
  4. reset(): It is used to reset the audio file while playing any audio file.
  5. setVolume(float volume): It is used to set the volume of the audio file.
  6. setRepeat(bool repeat): It is used to set the count of repeat any audio file is played.
  7. setPan(float pan): It controls the speakers balance. -0.1 gives sound output only through the left Channel (or Speaker) and +0.1 gives the output through right channel (Speaker) only.
  8. isSeekable(): It tells us if your music file supports the setting of the position of your sound.setPosition method can be used to set to the desired position. Current position can always be known by calling the getPosition function
  9. getLength(): It gives the length of your music file
  10. setPitchShift(float shift): It controls the tone. Value varies between 0.5 and 2.0, 1.0 is the default value. Volume range is between 0.0 to 1.0
  11. getPitchShift(): It is used to get the tone value.

Below is the implementation of playing music using functions in audiere.h library:




// C++ program to play music using
// audiere file function
#include "audiere.h"
#include <stdio>
#include <string>
  
// Using Audiere File
using namespace audiere;
using namespace std;
  
// Driver Code
int main(void)
{
    // Name of the file
    string name = "file1.mp3";
  
    // Create Object to open device
    AudioDevicePtr device(OpenDevice());
  
    // Create Object to open the music file
    OutputStreamPtr sound(OpenSound(device,
                                    name.c_str(),
                                    false));
  
    // Play music using play() function
    sound->play();
  
    // Repeat music using setRepeat() function
    sound->setRepeat(true);
  
    // Change volume using setVolume() function
    sound->setVolume(2.0f);
  
    getchar();
    return 0;
}




Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads