All Classes Namespaces Functions Variables Enumerations Enumerator Modules Pages
Public Member Functions | List of all members
SampleLoader Class Reference

Inherits NewSampleThreadPool::Job.

Public Member Functions

 SampleLoader (SampleThreadPool *pool_)
void setBufferSize (int newBufferSize)
bool assertBufferSize (int minimumBufferSize)
JobStatus runJob () override
bool advanceReadIndex (double uptime)
void startNote (StreamingSamplerSound const *s, int sampleStartModValue)
const StreamingSamplerSoundgetLoadedSound () const
void reset ()
double getDiskUsage () noexcept

Detailed Description

This is a utility class that handles buffered sample streaming in a background thread.

It is derived from ThreadPoolJob, so whenever you want it to read new samples, add an instance of this to a ThreadPool (but don't delete it!) and it will do what it is supposed to do.

Constructor & Destructor Documentation

SampleLoader ( SampleThreadPool *  pool_)

Creates a new SampleLoader.

Normally you don't need to call this manually, as a StreamingSamplerVoice automatically creates a instance as member.

Member Function Documentation

bool advanceReadIndex ( double  uptime)

Advances the read index and returns false if the streaming thread is blocked.

bool assertBufferSize ( int  minimumBufferSize)

This checks the buffer size and increases it if it is too low.

This is used to make sure that the buffer size is at least 3x bigger than the current block size to avoid switching the buffers within one processBlock.

'true' if the buffer needed resizing (because it was either too big or to small).
double getDiskUsage ( )

Calculates and returns the disk usage.

It measures the time the background thread needed for the loading operation and divides it with the duration since the last call to requestNewData().

const StreamingSamplerSound* getLoadedSound ( ) const

Returns the loaded sound.

void reset ( )

Resets the loader (unloads the sound).

SampleThreadPoolJob::JobStatus runJob ( )

This fills the currently inactive buffer with samples from the SamplerSound.

The write buffer will be locked for the time of the read operation. Also it measures the time for getDiskUsage();

void setBufferSize ( int  newBufferSize)

Sets the buffer size in samples.

void startNote ( StreamingSamplerSound const *  s,
int  sampleStartModValue 

Call this whenever a sound was started.

This will set the read pointer to the preload buffer of the StreamingSamplerSound and start the background reading.

©2017 HISE. This documentation is autogenerated from the HISE source code using Doxygen.