Loading...
Searching...
No Matches
AudioReaderSource.h
Go to the documentation of this file.
// Copyright (c) 2008-2019 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#ifndef OPENSHOT_AUDIOREADERSOURCE_H
#define OPENSHOT_AUDIOREADERSOURCE_H
#include "ReaderBase.h"
#include "Qt/VideoCacheThread.h"
#include <AppConfig.h>
#include <juce_audio_basics/juce_audio_basics.h>
namespace openshot
{
class Frame;
class AudioReaderSource : public juce::PositionableAudioSource
{
private:
int stream_position;
int frame_position;
int speed;
ReaderBase *reader;
std::shared_ptr<Frame> frame;
int64_t sample_position;
openshot::VideoCacheThread *videoCache;
public:
AudioReaderSource(ReaderBase *audio_reader, int64_t starting_frame_number);
~AudioReaderSource();
void getNextAudioBlock (const juce::AudioSourceChannelInfo& info);
void prepareToPlay(int, double);
void releaseResources();
void setNextReadPosition (juce::int64 newPosition) { stream_position = newPosition; };
juce::int64 getNextReadPosition() const { return stream_position; };
juce::int64 getTotalLength() const;
bool isLooping() const { return false; };
void setLooping (bool shouldLoop) { };
std::shared_ptr<Frame> getFrame() const { return frame; }
void setSpeed(int new_speed) { speed = new_speed; }
int getSpeed() const { return speed; }
void setVideoCache(openshot::VideoCacheThread *newCache) { videoCache = newCache; }
void Reader(ReaderBase *audio_reader) { reader = audio_reader; }
ReaderBase* Reader() const { return reader; }
void Seek(int64_t new_position) { frame_position = new_position; sample_position=0; }
};
}
#endif
ReaderBase.h
Header file for ReaderBase class.
VideoCacheThread.h
Source file for VideoCacheThread class.
openshot::AudioReaderSource
This class is used to expose any ReaderBase derived class as an AudioSource in JUCE.
Definition AudioReaderSource.h:32
openshot::AudioReaderSource::Seek
void Seek(int64_t new_position)
Seek to a specific frame.
Definition AudioReaderSource.h:97
openshot::AudioReaderSource::getSpeed
int getSpeed() const
Get Speed (The speed and direction to playback a reader (1=normal, 2=fast, 3=faster,...
Definition AudioReaderSource.h:86
openshot::AudioReaderSource::releaseResources
void releaseResources()
Release all resources.
Definition AudioReaderSource.cpp:99
openshot::AudioReaderSource::Reader
void Reader(ReaderBase *audio_reader)
Set Reader.
Definition AudioReaderSource.h:92
openshot::AudioReaderSource::getNextReadPosition
juce::int64 getNextReadPosition() const
Get the next read position of this source.
Definition AudioReaderSource.h:68
openshot::AudioReaderSource::setLooping
void setLooping(bool shouldLoop)
This method is ignored (we do not support looping audio playback)
Definition AudioReaderSource.h:78
openshot::AudioReaderSource::getTotalLength
juce::int64 getTotalLength() const
Get the total length (in samples) of this audio source.
Definition AudioReaderSource.cpp:102
openshot::AudioReaderSource::setSpeed
void setSpeed(int new_speed)
Set Speed (The speed and direction to playback a reader (1=normal, 2=fast, 3=faster,...
Definition AudioReaderSource.h:84
openshot::AudioReaderSource::prepareToPlay
void prepareToPlay(int, double)
Prepare to play this audio source.
Definition AudioReaderSource.cpp:96
openshot::AudioReaderSource::Reader
ReaderBase * Reader() const
Get Reader.
Definition AudioReaderSource.h:94
openshot::AudioReaderSource::getNextAudioBlock
void getNextAudioBlock(const juce::AudioSourceChannelInfo &info)
Get the next block of audio samples.
Definition AudioReaderSource.cpp:33
openshot::AudioReaderSource::getFrame
std::shared_ptr< Frame > getFrame() const
Return the current frame object.
Definition AudioReaderSource.h:81
openshot::AudioReaderSource::~AudioReaderSource
~AudioReaderSource()
Destructor.
Definition AudioReaderSource.cpp:28
openshot::AudioReaderSource::setVideoCache
void setVideoCache(openshot::VideoCacheThread *newCache)
Set playback video cache thread (for pre-roll reference)
Definition AudioReaderSource.h:89
openshot::AudioReaderSource::setNextReadPosition
void setNextReadPosition(juce::int64 newPosition)
Set the next read position of this source.
Definition AudioReaderSource.h:65
openshot::AudioReaderSource::isLooping
bool isLooping() const
Looping is not support in OpenShot audio playback (this is always false)
Definition AudioReaderSource.h:74
openshot::ReaderBase
This abstract class is the base class, used by all readers in libopenshot.
Definition ReaderBase.h:76
openshot::VideoCacheThread
The video cache class.
Definition VideoCacheThread.h:30
openshot
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29