You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
73 lines
1.8 KiB
C++
73 lines
1.8 KiB
C++
#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__
|
|
|
|
#include <iomanip>
|
|
#include "juce.h"
|
|
|
|
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
|
|
AudioBufferSource(int samples, int channels);
|
|
|
|
/// 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
|
|
void setNextReadPosition (int newPosition);
|
|
|
|
/// Get the next read position of this source
|
|
int getNextReadPosition() const;
|
|
|
|
/// Get the total length (in samples) of this audio source
|
|
int getTotalLength() const;
|
|
|
|
/// 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);
|
|
|
|
/// Add audio samples to a specific channel
|
|
void AddAudio(int destChannel, int destStartSample, const float* source, int numSamples, float gainToApplyToSource);
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|