Giter VIP home page Giter VIP logo

acousticslib's Introduction

AcousticsLib

This project provides a simple and cross-platform audio library for modern C++11.

Overview

Dependencies

Using this library requires the GaussianLib

Building this library requires the OpenAL SDK, and optionally the Ogg-Vorbis libraries

Supported Platforms

 Platform  OpenAL  XAudio2
Windows Vista/ 7/ 8/ 10 ✔️  :heavy_check_mark:
Mac OS X  :heavy_check_mark: N/A 
Linux  :heavy_check_mark: N/A 

Supported File Formats

Format  File Extensions  Read Support  Write Support
Waveform Audio File Format  WAV ✔️  :heavy_check_mark:
Audio Interchange File Format AIFF, AIFC  :heavy_check_mark: ✖️ 
Ogg-Vorbis OGG  :heavy_check_mark: ✖️ 

Audio Engines

  • OpenAL (in progress)

Getting Started

Play a sound with less code as possible:

#include <Ac/AcLib.h>

int main()
{
    // Load default audio system module
    auto audioSystem = Ac::AudioSystem::Load();

    // Play sound with 100% volume
    audioSystem->Play("mySound.wav");

    // Wait for user input
    int i = 0;
    std::cin >> i;

    return 0;
}

Play a sound by choosing a module:

#include <Ac/AcLib.h>
#include <iostream>
#include <thread>
#include <chrono>

int main()
{
    // If an audio system is not available, dynamically catch the
    // exception an load another audio system, e.g. when "XAudio2"
    // is not available due to a missing DirectX version on a Windows platform.
    for (auto module : Ac::AudioSystem::FindModules())
    {
        try
        {
            // Load audio system from shared library
            auto audioSystem = Ac::AudioSystem::Load(module);

            std::cout
                << "Audio System: \" << audioSystem->GetName() << "\""
                << ", Version: " << audioSystem->GetVersion() <<
            std::endl;

            if (auto sound = audioSystem->LoadSound("mySound.wav"))
            {
                sound->SetVolume(0.5f); // set volume to 50%
                sound->SetPitch(1.5f);  // play with 1.5x frequency (or speed)
                sound->Play();          // play sound

                while (sound->IsPlaying())
                {
                    // Wait while sound is playing and show current seek position (in seconds)
                    std::cout << "Playing: " << sound->GetSeek() << std::end;

                    // Wait a moment
                    std::this_thread::sleep_for(std::chrono::milliseconds(100));
                }
            }

            // Break out from loop, we only need one single audio system
            break;
        }
        catch (const std::exception& e)
        {
            std::cerr << e.what() << std::endl;
        }
    }
    return 0;
}

acousticslib's People

Contributors

lukasbanana avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.