Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
StreamingSamplerSound Class Reference

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

Inherits SynthesiserSound.

Classes

struct  LoadingError
 An object of this class will be thrown if the loading of the sound fails. More...
 

Public Types

enum  SampleStates { Normal = 0, Disabled, Purged }
 

Public Member Functions

bool appliesToChannel (int) noexcept override
 Always returns true ( can be implemented if used, but I don't need it)
 
bool appliesToNote (int midiNoteNumber) noexcept override
 Checks if the note is mapped to the supplied note number. More...
 
float calculatePeakValue ()
 Scans the file for the max level. More...
 
void decreaseVoiceCount () const
 decreases the voice counter. More...
 
size_t getActualPreloadSize () const
 Returns the size of the preload buffer in bytes. More...
 
int64 getLengthInSamples () const noexcept
 Returns the length of the loaded audio file in samples. More...
 
int getLoopCrossfade () const noexcept
 Returns the length of the crossfade. More...
 
int getLoopEnd () const noexcept
 Returns the loop end. More...
 
int getLoopLength () const noexcept
 Returns the loop length. More...
 
int getLoopStart () const noexcept
 Returns the loop start. More...
 
const hlac::HiseSampleBuffer & getPreloadBuffer () const
 Returns read only access to the preload buffer. More...
 
int getSampleEnd () const noexcept
 Returns the sample end index. More...
 
int getSampleLength () const noexcept
 Returns the length of the sample. More...
 
double getSampleRate () const noexcept
 Returns the sampleRate of the sample (not the current playback samplerate). More...
 
int getSampleStart () const noexcept
 Returns the sample start index. More...
 
int getSampleStartModulation () const noexcept
 Returns the amount of samples that can be skipped at voice start. More...
 
bool hasEnoughSamplesForBlock (int maxSampleIndexInFile) const
 Checks if the file is mapped and has enough samples. More...
 
void increaseVoiceCount () const
 increases the voice counter. More...
 
bool isLoopEnabled () const noexcept
 Checks if the looping is enabled. More...
 
void loadEntireSample ()
 Tell the sound to load everything into memory. More...
 
void setBasicMappingData (const StreamingHelpers::BasicMappingData &data)
 Sets the basic MIDI mapping data (key-range, velocity-range and root note) from the given data object. More...
 
void setLoopCrossfade (int newCrossfadeLength)
 This sets the crossfade length. More...
 
void setLoopEnabled (bool shouldBeEnabled)
 Enables the loop. More...
 
void setLoopEnd (int newLoopEnd)
 Sets the end point of the looping section. More...
 
void setLoopStart (int newLoopStart)
 Sets the start of the loop section. More...
 
void setPreloadSize (int newPreloadSizeInSamples, bool forceReload=false)
 Set the preload size. More...
 
void setReversed (bool shouldBeReversed)
 Loads the entire sample into the preload buffer and reverses it. More...
 
void setSampleEnd (int sampleEnd)
 Sets the sample end. More...
 
void setSampleStart (int sampleStart)
 Sets the sample start. More...
 
void setSampleStartModulation (int maxSampleStartDelta)
 Sets the sample start modulation. More...
 
 StreamingSamplerSound (const String &fileNameToLoad, StreamingSamplerSoundPool *pool)
 Creates a new StreamingSamplerSound. More...
 
 StreamingSamplerSound (MonolithInfoToUse *info, int channelIndex, int sampleIndex)
 Creates a new StreamingSamplerSound from a monolithic file. More...
 
void wakeSound () const
 Gets the sound into active memory. More...
 

Static Public Member Functions

static double getPitchFactor (int noteNumberToPitch, int rootNoteForPitchFactor) noexcept
 Returns the pitch factor for the note number. More...
 

Detailed Description

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

This class is not directly used in HISE, but wrapped into a ModulatorSamplerSound which provides extra functionality. However, if you roll your own sampler class and just need to reuse the streaming facilities, you can tinker around with this class.

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,
StreamingSamplerSoundPool *  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 appliesToNote ( int  midiNoteNumber)
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  rootNoteForPitchFactor 
)
staticnoexcept

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 ( void  ) 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 setBasicMappingData ( const StreamingHelpers::BasicMappingData data)

Sets the basic MIDI mapping data (key-range, velocity-range and root note) from the given data object.

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.