OpenShot Library | libopenshot  0.3.0
AudioReaderSource.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2008-2019 OpenShot Studios, LLC
10 //
11 // SPDX-License-Identifier: LGPL-3.0-or-later
12 
13 #ifndef OPENSHOT_AUDIOREADERSOURCE_H
14 #define OPENSHOT_AUDIOREADERSOURCE_H
15 
16 #include "ReaderBase.h"
17 #include "Qt/VideoCacheThread.h"
18 
19 #include <AppConfig.h>
20 #include <juce_audio_basics/juce_audio_basics.h>
21 
23 namespace openshot
24 {
25  class Frame;
31  class AudioReaderSource : public juce::PositionableAudioSource
32  {
33  private:
34  int stream_position;
35  int frame_position;
36  int speed;
37 
38  ReaderBase *reader;
39  std::shared_ptr<Frame> frame;
40  int64_t sample_position;
41  openshot::VideoCacheThread *videoCache;
42 
43  public:
44 
48  AudioReaderSource(ReaderBase *audio_reader, int64_t starting_frame_number);
49 
52 
55  void getNextAudioBlock (const juce::AudioSourceChannelInfo& info);
56 
58  void prepareToPlay(int, double);
59 
61  void releaseResources();
62 
65  void setNextReadPosition (juce::int64 newPosition) { stream_position = newPosition; };
66 
68  juce::int64 getNextReadPosition() const { return stream_position; };
69 
72 
74  bool isLooping() const { return false; };
75 
78  void setLooping (bool shouldLoop) { };
79 
81  std::shared_ptr<Frame> getFrame() const { return frame; }
82 
84  void setSpeed(int new_speed) { speed = new_speed; }
86  int getSpeed() const { return speed; }
87 
89  void setVideoCache(openshot::VideoCacheThread *newCache) { videoCache = newCache; }
90 
92  void Reader(ReaderBase *audio_reader) { reader = audio_reader; }
94  ReaderBase* Reader() const { return reader; }
95 
97  void Seek(int64_t new_position) { frame_position = new_position; sample_position=0; }
98 
99  };
100 
101 }
102 
103 #endif
void setNextReadPosition(juce::int64 newPosition)
Set the next read position of this source.
Source file for VideoCacheThread class.
The video cache class.
void setLooping(bool shouldLoop)
This method is ignored (we do not support looping audio playback)
Header file for ReaderBase class.
int getSpeed() const
Get Speed (The speed and direction to playback a reader (1=normal, 2=fast, 3=faster, -1=rewind, etc...)
ReaderBase * Reader() const
Get Reader.
juce::int64 getTotalLength() const
Get the total length (in samples) of this audio source.
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:75
void releaseResources()
Release all resources.
std::shared_ptr< Frame > getFrame() const
Return the current frame object.
void getNextAudioBlock(const juce::AudioSourceChannelInfo &info)
Get the next block of audio samples.
void Seek(int64_t new_position)
Seek to a specific frame.
void Reader(ReaderBase *audio_reader)
Set Reader.
bool isLooping() const
Looping is not support in OpenShot audio playback (this is always false)
#define int64
Definition: Clip.h:17
void setVideoCache(openshot::VideoCacheThread *newCache)
Set playback video cache thread (for pre-roll reference)
This class is used to expose any ReaderBase derived class as an AudioSource in JUCE.
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
void prepareToPlay(int, double)
Prepare to play this audio source.
AudioReaderSource(ReaderBase *audio_reader, int64_t starting_frame_number)
The cache thread (for pre-roll checking)
juce::int64 getNextReadPosition() const
Get the next read position of this source.
void setSpeed(int new_speed)
Set Speed (The speed and direction to playback a reader (1=normal, 2=fast, 3=faster, -1=rewind, etc...)