Video display and composing engine for JUCE
Loading...
Searching...
No Matches
AudioClip Class Reference

The AudioClip plays back an audio file inside the video engine. More...

#include <foleys_AudioClip.h>

+ Inheritance diagram for AudioClip:

Public Member Functions

 AudioClip (VideoEngine &videoEngine)
 
juce::String getClipType () const override
 Used to identify the clip type to the user.
 
juce::String getDescription () const override
 returns a string describing the clip.
 
juce::URL getMediaFile () const override
 returns the original media file to restore
 
void setMediaFile (const juce::URL &media)
 
void setAudioFormatReader (juce::AudioFormatReader *reader, int samplesToBuffer=48000)
 
VideoFramegetFrame (double pts) override
 Returns the frame for a certain timecode.
 
bool isFrameAvailable (double pts) const override
 Checks, if a frame is available.
 
void render (juce::Graphics &view, juce::Rectangle< float > area, double pts, float rotation=0.0f, float zoom=100.0f, juce::Point< float > translation=juce::Point< float >(), float alpha=1.0f) override
 This is the virtual render() method for OpenGL rendering.
 
Size getVideoSize () const override
 returns the pixel size of the media as a tuple.
 
double getCurrentTimeInSeconds () const override
 Return the clip's read position in seconds.
 
void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override
 
void releaseResources () override
 
void getNextAudioBlock (const juce::AudioSourceChannelInfo &) override
 
void setNextReadPosition (juce::int64 samples) override
 
juce::int64 getNextReadPosition () const override
 
juce::int64 getTotalLength () const override
 
bool isLooping () const override
 
void setLooping (bool shouldLoop) override
 
juce::Image getStillImage (double seconds, Size size) override
 This returns a still frame on the selected position.
 
double getLengthInSeconds () const override
 Returns the length of the clip in seconds.
 
bool hasVideo () const override
 Returns true, if this clip will produce visual frames.
 
bool hasAudio () const override
 Returns true, if this clip will produce audio.
 
std::shared_ptr< AVClipcreateCopy (StreamTypes types) override
 This returns a copy of the clip.
 
double getSampleRate () const override
 This is the samplerate supplied from prepareToPlay and the sample rate this clip will produce audio and use as clock source.
 
- Public Member Functions inherited from AVClip
 AVClip (VideoEngine &videoEngine)
 
virtual ~AVClip ()=default
 
void renderFrame (juce::Graphics &g, juce::Rectangle< float > area, VideoFrame &frame, float rotation, float zoom, juce::Point< float > translation, float alpha)
 Renders a frame on the OpenGLView.
 
void setAspectType (Aspect type)
 
virtual double getFrameDurationInSeconds () const
 Returns the duration of a frame in seconds.
 
virtual bool waitForSamplesReady (int samples, int timeout=1000)
 When rendering non realtime (bounce), use this to wait for background threads to read ahead.
 
virtual bool waitForFrameReady (double pts, int timeout=1000)
 When rendering non realtime (bounce), use this to wait for background threads to read ahead.
 
const ParameterMapgetVideoParameters ()
 
const ParameterMapgetAudioParameters ()
 
virtual juce::TimeSliceClient * getBackgroundJob ()
 
VideoEnginegetVideoEngine () const
 
- Public Member Functions inherited from TimeCodeAware
 TimeCodeAware ()=default
 
virtual ~TimeCodeAware ()=default
 
void addTimecodeListener (Listener *listener)
 Register a TimecodeListener to be notified, when the visual frame changes.
 
void removeTimecodeListener (Listener *listener)
 Unregister a TimecodeListener.
 

Additional Inherited Members

- Static Public Member Functions inherited from AVClip
static void addDefaultAudioParameters (AVClip &clip)
 
static void addDefaultVideoParameters (AVClip &clip)
 
- Protected Member Functions inherited from AVClip
void addAudioParameter (std::unique_ptr< ProcessorParameter > parameter)
 
void addVideoParameter (std::unique_ptr< ProcessorParameter > parameter)
 
- Protected Member Functions inherited from TimeCodeAware
void sendTimecode (int64_t count, double seconds, juce::NotificationType nt)
 Subclasses can call this to notify displays, that the time code has changed, e.g.
 

Detailed Description

The AudioClip plays back an audio file inside the video engine.

It wraps around a JUCE AudioFormatReaderSource.

When you created a shared_ptr of an AudioClip, call manageLifeTime() on the VideoEngine, that will add it to the auto release pool and register possible background jobs with the TimeSliceThreads.

Constructor & Destructor Documentation

◆ AudioClip()

Member Function Documentation

◆ getClipType()

juce::String getClipType ( ) const
overridevirtual

Used to identify the clip type to the user.

Implements AVClip.

◆ getDescription()

juce::String getDescription ( ) const
overridevirtual

returns a string describing the clip.

This could be the filename of the original media file

Implements AVClip.

◆ getMediaFile()

juce::URL getMediaFile ( ) const
overridevirtual

returns the original media file to restore

Reimplemented from AVClip.

Referenced by AudioClip::createCopy().

◆ setMediaFile()

void setMediaFile ( const juce::URL &  media)

◆ setAudioFormatReader()

void setAudioFormatReader ( juce::AudioFormatReader *  reader,
int  samplesToBuffer = 48000 
)

◆ getFrame()

VideoFrame & getFrame ( double  pts)
overridevirtual

Returns the frame for a certain timecode.

Implements AVClip.

◆ isFrameAvailable()

bool isFrameAvailable ( double  pts) const
overridevirtual

Checks, if a frame is available.

Implements AVClip.

◆ render()

void render ( juce::Graphics &  g,
juce::Rectangle< float >  area,
double  pts,
float  rotation = 0.0f,
float  zoom = 100.0f,
juce::Point< float >  translation = juce::Point< float >(),
float  alpha = 1.0f 
)
overridevirtual

This is the virtual render() method for OpenGL rendering.

Implements AVClip.

◆ getVideoSize()

Size getVideoSize ( ) const
overridevirtual

returns the pixel size of the media as a tuple.

In some video files this can change at any frame.

Implements AVClip.

◆ getCurrentTimeInSeconds()

double getCurrentTimeInSeconds ( ) const
overridevirtual

Return the clip's read position in seconds.

Implements TimeCodeAware.

◆ prepareToPlay()

void prepareToPlay ( int  samplesPerBlockExpected,
double  sampleRate 
)
override

◆ releaseResources()

void releaseResources ( )
override

◆ getNextAudioBlock()

void getNextAudioBlock ( const juce::AudioSourceChannelInfo &  info)
override

◆ setNextReadPosition()

void setNextReadPosition ( juce::int64  samples)
override

◆ getNextReadPosition()

juce::int64 getNextReadPosition ( ) const
override

◆ getTotalLength()

juce::int64 getTotalLength ( ) const
override

◆ isLooping()

bool isLooping ( ) const
override

◆ setLooping()

void setLooping ( bool  shouldLoop)
override

◆ getStillImage()

juce::Image getStillImage ( double  seconds,
Size  size 
)
overridevirtual

This returns a still frame on the selected position.

Don't use this method for streaming a video, because it will be slow

Implements AVClip.

◆ getLengthInSeconds()

double getLengthInSeconds ( ) const
overridevirtual

Returns the length of the clip in seconds.

Implements AVClip.

◆ hasVideo()

bool hasVideo ( ) const
overridevirtual

Returns true, if this clip will produce visual frames.

Implements AVClip.

◆ hasAudio()

bool hasAudio ( ) const
overridevirtual

Returns true, if this clip will produce audio.

Implements AVClip.

◆ createCopy()

std::shared_ptr< AVClip > createCopy ( StreamTypes  types)
overridevirtual

This returns a copy of the clip.

Note that this will not work properly if the clip is not properly registered in the engine, because the copy will automatically be registered with the engine as well.

Implements AVClip.

References AudioClip::getMediaFile(), and AVClip::getVideoEngine().

◆ getSampleRate()

double getSampleRate ( ) const
overridevirtual

This is the samplerate supplied from prepareToPlay and the sample rate this clip will produce audio and use as clock source.

Implements AVClip.


The documentation for this class was generated from the following files: