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

Inherits SynthesiserSound.

Classes

struct  LoadingError
 

Public Member Functions

 StreamingSamplerSound (const String &fileNameToLoad, ModulatorSamplerSoundPool *pool)
 
 StreamingSamplerSound (MonolithInfoToUse *info, int channelIndex, int sampleIndex)
 
bool appliesToNote (int) noexceptoverride
 
bool appliesToChannel (int) noexceptoverride
 
double getPitchFactor (int noteNumberToPitch, int rootNote) const noexcept
 
void setSampleStart (int sampleStart)
 
void setSampleEnd (int sampleEnd)
 
int getSampleStart () const noexcept
 
int getSampleEnd () const noexcept
 
int getSampleLength () const noexcept
 
void setSampleStartModulation (int maxSampleStartDelta)
 
int getSampleStartModulation () const noexcept
 
void setLoopEnabled (bool shouldBeEnabled)
 
bool isLoopEnabled () const noexcept
 
void setLoopStart (int newLoopStart)
 
void setLoopEnd (int newLoopEnd)
 
int getLoopStart () const noexcept
 
int getLoopEnd () const noexcept
 
int getLoopLength () const noexcept
 
void setLoopCrossfade (int newCrossfadeLength)
 
int getLoopCrossfade () const noexcept
 
void setReversed (bool shouldBeReversed)
 
void setPreloadSize (int newPreloadSizeInSamples, bool forceReload=false)
 
size_t getActualPreloadSize () const
 
void loadEntireSample ()
 
void increaseVoiceCount () const
 
void decreaseVoiceCount () const
 
double getSampleRate () const noexcept
 
int64 getLengthInSamples () const noexcept
 
void wakeSound () const
 
bool hasEnoughSamplesForBlock (int maxSampleIndexInFile) const
 
const hlac::HiseSampleBuffer & getPreloadBuffer () const
 
float calculatePeakValue ()
 

Detailed Description

A SamplerSound which provides buffered disk streaming using memory mapped file access and a preloaded sample start.

Member Enumeration Documentation

Enumerator
Normal 

the default state for existing samples

Disabled 

if samples are not found on the disk, they are disabled

Purged 

you can purge samples (unload them from memory)

Constructor & Destructor Documentation

StreamingSamplerSound ( const String &  fileNameToLoad,
ModulatorSamplerSoundPool pool 
)

Creates a new StreamingSamplerSound.

Parameters
fileToLoada stereo wave file that is read as memory mapped file.
midiNotesthe note map
midiNoteForNormalPitchthe root note
StreamingSamplerSound ( MonolithInfoToUse *  info,
int  channelIndex,
int  sampleIndex 
)

Creates a new StreamingSamplerSound from a monolithic file.

Member Function Documentation

bool appliesToChannel ( int  )
inlineoverridenoexcept

Always returns true ( can be implemented if used, but I don't need it)

bool appliesToNote ( int  )
inlineoverridenoexcept

Checks if the note is mapped to the supplied note number.

float calculatePeakValue ( )

Scans the file for the max level.

void decreaseVoiceCount ( ) const

decreases the voice counter. The file handle will be kept open until no voice is played.

size_t getActualPreloadSize ( ) const

Returns the size of the preload buffer in bytes. You can use this method to check how much memory the sound uses. It also includes the memory used for the crossfade buffer.

int64 getLengthInSamples ( ) const
inlinenoexcept

Returns the length of the loaded audio file in samples.

int getLoopCrossfade ( ) const
inlinenoexcept

Returns the length of the crossfade.

int getLoopEnd ( ) const
inlinenoexcept

Returns the loop end.

int getLoopLength ( ) const
inlinenoexcept

Returns the loop length.

int getLoopStart ( ) const
inlinenoexcept

Returns the loop start.

double getPitchFactor ( int  noteNumberToPitch,
int  rootNote 
) const
inlinenoexcept

Returns the pitch factor for the note number.

const hlac::HiseSampleBuffer& getPreloadBuffer ( ) const
inline

Returns read only access to the preload buffer.

This is used by the SampleLoader class to fetch the samples from the preloaded buffer until the disk streaming thread fills the other buffer.

int getSampleEnd ( ) const
inlinenoexcept

Returns the sample end index.

int getSampleLength ( ) const
inlinenoexcept

Returns the length of the sample.

double getSampleRate ( ) const
inlinenoexcept

Returns the sampleRate of the sample (not the current playback samplerate).

int getSampleStart ( ) const
inlinenoexcept

Returns the sample start index.

int getSampleStartModulation ( ) const
inlinenoexcept

Returns the amount of samples that can be skipped at voice start.

Changing this value means that the preload buffer will be increased to this amount of samples + the preload size.

bool hasEnoughSamplesForBlock ( int  maxSampleIndexInFile) const

Checks if the file is mapped and has enough samples.

Call this before you call fillSampleBuffer() to check if the audio file has enough samples.

void increaseVoiceCount ( ) const

increases the voice counter.

bool isLoopEnabled ( ) const
inlinenoexcept

Checks if the looping is enabled.

void loadEntireSample ( )

Tell the sound to load everything into memory.

It will also close the file handle.

void setLoopCrossfade ( int  newCrossfadeLength)

This sets the crossfade length.

void setLoopEnabled ( bool  shouldBeEnabled)

Enables the loop. If the loop points are beyond the loaded sample area, they will be truncated.

void setLoopEnd ( int  newLoopEnd)

Sets the end point of the looping section.

If crossfading is enabled, it will reload the crossfade area.

void setLoopStart ( int  newLoopStart)

Sets the start of the loop section.

If crossfading is enabled, it will reload the crossfade area.

void setPreloadSize ( int  newPreloadSizeInSamples,
bool  forceReload = false 
)

Set the preload size.

If the preload size is not changed, it will do nothing, but you can force it to reload it with 'forceReload'. You can also tell the sound to load everything into memory by calling loadEntireSample().

void setReversed ( bool  shouldBeReversed)

Loads the entire sample into the preload buffer and reverses it.

void setSampleEnd ( int  sampleEnd)

Sets the sample end. This can be used to truncate a sample.

void setSampleStart ( int  sampleStart)

Sets the sample start. This reloads the PreloadBuffer, so make sure you don't call it in the audio thread.

If the sample start is the same, it will do nothing.

void setSampleStartModulation ( int  maxSampleStartDelta)

Sets the sample start modulation. The preload buffer will be enhanced by this amount in order to ensure immediate playback.

void wakeSound ( ) const

Gets the sound into active memory.

This is a wrapper around MemoryMappedAudioFormatReader::touchSample(), and I didn't check if it is necessary.

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