2011-10-11 08:44:27 -05:00
|
|
|
#ifndef OPENSHOT_AUDIOBUFFERSOURCE_H
|
|
|
|
|
#define OPENSHOT_AUDIOBUFFERSOURCE_H
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \file
|
|
|
|
|
* \brief Header file for AudioBufferSource class
|
|
|
|
|
* \author Copyright (c) 2011 Jonathan Thomas
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/// Do not include the juce unittest headers, because it collides with unittest++
|
|
|
|
|
#define __JUCE_UNITTEST_JUCEHEADER__
|
|
|
|
|
|
2013-06-09 01:08:23 -05:00
|
|
|
#ifndef _NDEBUG
|
|
|
|
|
// Define NO debug for JUCE on mac os
|
|
|
|
|
#define _NDEBUG
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-10-11 08:44:27 -05:00
|
|
|
#include <iomanip>
|
2012-06-16 02:12:48 -05:00
|
|
|
#include "JuceLibraryCode/JuceHeader.h"
|
2011-10-11 08:44:27 -05:00
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
namespace openshot
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief This class is used to expose an AudioSampleBuffer as an AudioSource in juce.
|
|
|
|
|
*
|
|
|
|
|
* The juce library cannot play audio directly from an AudioSampleBuffer, so this class exposes
|
|
|
|
|
* an AudioSampleBuffer as a AudioSource, so that juce can play the audio.
|
|
|
|
|
*/
|
|
|
|
|
class AudioBufferSource : public PositionableAudioSource
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
int position;
|
|
|
|
|
int start;
|
|
|
|
|
bool repeat;
|
|
|
|
|
AudioSampleBuffer *buffer;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
/// Default constructor
|
2012-08-05 15:17:37 -05:00
|
|
|
AudioBufferSource(AudioSampleBuffer *audio_buffer);
|
2011-10-11 08:44:27 -05:00
|
|
|
|
|
|
|
|
/// Destructor
|
|
|
|
|
~AudioBufferSource();
|
|
|
|
|
|
|
|
|
|
/// Get the next block of audio samples
|
|
|
|
|
void getNextAudioBlock (const AudioSourceChannelInfo& info);
|
|
|
|
|
|
|
|
|
|
/// Prepare to play this audio source
|
|
|
|
|
void prepareToPlay(int, double);
|
|
|
|
|
|
|
|
|
|
/// Release all resources
|
|
|
|
|
void releaseResources();
|
|
|
|
|
|
|
|
|
|
/// Set the next read position of this source
|
2012-06-16 02:12:48 -05:00
|
|
|
void setNextReadPosition (long long newPosition);
|
2011-10-11 08:44:27 -05:00
|
|
|
|
|
|
|
|
/// Get the next read position of this source
|
2012-06-16 02:12:48 -05:00
|
|
|
long long getNextReadPosition() const;
|
2011-10-11 08:44:27 -05:00
|
|
|
|
|
|
|
|
/// Get the total length (in samples) of this audio source
|
2012-06-16 02:12:48 -05:00
|
|
|
long long getTotalLength() const;
|
2011-10-11 08:44:27 -05:00
|
|
|
|
|
|
|
|
/// Determines if this audio source should repeat when it reaches the end
|
|
|
|
|
bool isLooping() const;
|
|
|
|
|
|
|
|
|
|
/// Set if this audio source should repeat when it reaches the end
|
|
|
|
|
void setLooping (bool shouldLoop);
|
2012-08-05 15:17:37 -05:00
|
|
|
|
|
|
|
|
/// Update the internal buffer used by this source
|
|
|
|
|
void setBuffer (AudioSampleBuffer *audio_buffer);
|
2011-10-11 08:44:27 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|