Giter VIP home page Giter VIP logo

hill_audio_tools's Introduction

hill_audio_tools

hill_audio_tools will be a set of tools to simplify controlling audio files in juce.

Getting Started

Installing

Download or clone the repository into your Juce user modules folder. You can define the path for user modules in the Projucer under "Projucer - Global Paths... - User Modules".

Create a project

Create a new project in Projucer and start with an Audio Application. Add the hill_audio_tools module to your project (go to modules, click the add button and juce "Add a module - Global user modules path - hill_audio_tools"). If you can't see the module, click Re-scan path. Create your Xcode (or whatever software you use) project.

Add an audio file to the Projucer

Back in the projucer add an audio file to your project. Do this by clicking on "File Explorer", then drag and drop your audio file into the folder Source. Once you click save, the file is available as a binary source file in your project.

Play a file

In Xcode got to your MainComponent.cpp file and find the Constructor.

We now will initialize the AudioFilesPlayer singleton instance, load an audio file and play and loop it. We will create a fade-in over 5 seconds from 0 gain to 0.8 gain.

 auto background_music = AudioFilesPlayer::getInstance()->loadFile(BinaryData::test_wav, BinaryData::test:test_wavSize, false, "background_music");
    
    background_music->setGain(0);
    background_music->play();
    background_music->setGain(0.8,5);
    background_music->setLoop(true);

Prepare to play and pass an audio buffer

In MainComponent.cpp find the method prepareToPlay(...) and call the process method in your AudioFilesPlayer.

void MainComponent::prepareToPlay (int samplesPerBlockExpected, double sampleRate)
{
    AudioFilesPlayer::getInstance()->prepareToPlay(samplesPerBlockExpected, sampleRate);
}

Then go to the method getNextAudioBlock(...) and pass the audio buffer.

void MainComponent::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
{
    auto buffer = *bufferToFill.buffer;
    buffer.clear();
    AudioFilesPlayer::getInstance()->process(buffer);
  
}

Control the file where ever you need

Now you can get the music file where ever you need it.

    auto background_music = AudioFilesPlayer::getInstance()->getFile("background_music");
    background_music->stop();

Authors

  • David Hill - Initial work - davemod

License

This project is licensed under the MIT License - see the LICENSE.md file for details

hill_audio_tools's People

Contributors

davemod 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.