All Classes Namespaces Functions Variables Enumerations Enumerator Modules Pages
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ModulatorSamplerSound Class Reference
Inheritance diagram for ModulatorSamplerSound:
SafeChangeBroadcaster RestorableObject

Public Types

enum  Property

Public Member Functions

 ModulatorSamplerSound (StreamingSamplerSound *sound, int index_)
Range< int > getPropertyRange (Property p) const
String getPropertyAsString (Property p) const
var getProperty (Property p) const
void setProperty (Property p, int newValue, NotificationType notifyEditor=sendNotification)
void toggleBoolProperty (ModulatorSamplerSound::Property p, NotificationType notifyEditor=sendNotification)
ValueTree exportAsValueTree () const override
void restoreFromValueTree (const ValueTree &v) override
void setUndoManager (UndoManager *newUndoManager)
void startPropertyChange (Property p, int newValue)
void endPropertyChange (Property p, int startValue, int endValue)
void setPropertyWithUndo (Property p, var newValue)
void openFileHandle ()
void closeFileHandle ()
int getId () const
float getPropertyVolume () const noexcept
double getPropertyPitch () const noexcept
double getSampleRate () const noexcept
int getRootNote () const noexcept
void setMappingData (MappingData newData)
void calculateNormalizedPeak (bool forceScan=false)
float getNormalizedPeak () const
bool isNormalizedEnabled () const noexcept
float getBalance (bool getRightChannelGain) const
- Public Member Functions inherited from SafeChangeBroadcaster
void sendSynchronousChangeMessage ()
void addChangeListener (SafeChangeListener *listener)
void removeChangeListener (SafeChangeListener *listener)
void removeAllChangeListeners ()
void sendChangeMessage (const String &=String())
void sendAllocationFreeChangeMessage ()

Static Public Member Functions

static String getPropertyName (Property p)

Detailed Description

A ModulatorSamplerSound is a wrapper around a StreamingSamplerSound that allows modulation of parameters.

It also contains methods that extend the properties of a StreamingSamplerSound.

Member Enumeration Documentation

enum Property

The extended properties of the ModulatorSamplerSound


a unique ID which corresponds to the number in the sound array


the complete filename of the audio file


the root note


the highest mapped key


the lowest mapped key


the lowest mapped velocity


the highest mapped velocity


the group index for round robin / random group start behaviour


the gain in decibels. It is converted to a gain value internally


enables normalization of the sample data


the pitch factor in cents (+- 100). This is for fine tuning, for anything else, use RootNote.


the start sample


the end sample,


the amount of samples that the sample start can be modulated.


the loop start in samples. This is independent from the sample start / end, but it checks the bounds.


the loop end in samples. This is independent from the sample start / end, but it checks the bounds.


the loop crossfade at the end of the loop (using a precalculated buffer)


true if the sample should be looped


the length of the velocity crossfade (0 if there is no crossfade). If the crossfade starts at the bottom, it will have negative values.


the length of the velocity crossfade (0 if there is no crossfade). If the crossfade starts at the bottom, it will have negative values.


this property allows to set the state of samples between 'Normal', 'Disabled' and 'Purged'

Constructor & Destructor Documentation

ModulatorSamplerSound ( StreamingSamplerSound sound,
int  index_ 

Creates a ModulatorSamplerSound. You only have to supply the index and the fileName, the rest is supposed to be restored with restoreFromValueTree().

Member Function Documentation

void calculateNormalizedPeak ( bool  forceScan = false)

Calculates the gain value that must be applied to normalize the volume of the sample ( 1.0 / peakValue ).

It should save calculated value along with the other properties, but if a new sound is added, it will call StreamingSamplerSound::getPeakValue(), which scans the whole file.

forceScanif true, then it will scan the file and calculate the peak value.
void closeFileHandle ( )

Opens the file handle for all samples of this sound.

void endPropertyChange ( Property  p,
int  startValue,
int  endValue 

Call this whenever you finish a series of property modifications.

It will group all actions since startPropertyChange and saves it to the UndoManager list with a description "CHANGING PROPERTY FROM X TO Y"

ValueTree exportAsValueTree ( ) const

Exports all properties (excluding the ID) as value tree.

Implements RestorableObject.

float getBalance ( bool  getRightChannelGain) const

Returns the calculated (equal power) pan value for either the left or the right channel.

int getId ( ) const

Returns the id.

Can also be achieved by getProperty(ID), but this is more convenient.

float getNormalizedPeak ( ) const

Returns the gain value that must be applied to normalize the volume of the sample ( 1.0 / peakValue ).

var getProperty ( Property  p) const

Returns the property as var object.

Use this method if you want to have access to the actual data. Internal methods of ModulatorSamplerSound access the member variables directly for more speed.

String getPropertyAsString ( Property  p) const

Returns a string version of the Property.

This is used for displaying a nicer value than the raw data value (eg. note names, or milliseconds). Do not use the return value for further processing, use getProperty() instead.

String getPropertyName ( Property  p)

Returns the name of the Property.

This is used to display the name in the user interface and for the tag name within the XML samplemap, so you must return a valid tag name here.

double getPropertyPitch ( ) const

Returns the pitch value of the sound.

Unlike getProperty(Pitch), it returns the pitch factor (from 0.5 to 2.0)

Range< int > getPropertyRange ( Property  p) const

Returns the min and max values for the Property.

This method is non-static because you can change the range dynamically eg. depending on other properties.

It returns the following ranges:

  • MIDI Upper limits: Low limits - 127
  • MIDI Lower limits: 0 -> Upper Limit
  • RRGroups: 0 -> number of RR groups
  • Volume: -100dB -> +18dB
  • Pitch: -100ct -> +100ct
  • Sample Start: 0 -> sample end or loop start or sample end - sample start mod
  • Sample End: sample start + sampleStartMod -> file end
  • Sample Start Mod: 0 -> sample length
  • Loop enabled: 0 -> 1
  • Loop Start: (SampleStart + Crossfade) -> (LoopEnd - Crossfade)
  • Loop End: (LoopStart + Crossfade) -> SampleEnd
  • Loop Xfade: 0 -> (LoopStart - SampleStart) or LoopLength
float getPropertyVolume ( ) const

Returns the gain value of the sound.

Unlike getProperty(Volume), it returns a value from 0.0 to 1.0, so use this for internal stuff

int getRootNote ( ) const

returns the root note.

double getSampleRate ( ) const

returns the sample rate of the sound (!= the sample rate of the current audio settings)

bool isNormalizedEnabled ( ) const

Checks if the normalization gain should be applied to the sample.

void openFileHandle ( )

Closes the file handle for all samples of this sound.

void restoreFromValueTree ( const ValueTree &  v)

restores all properties (excluding filename and ID) from the value tree.

Implements RestorableObject.

void setMappingData ( MappingData  newData)

This sets the MIDI related properties without undo / range checks.

void setProperty ( Property  p,
int  newValue,
NotificationType  notifyEditor = sendNotification 

Change a property. It also sends a change message to all registered listeners.

Calling this method directly can't be undone. If you want undo behaviour, call setPropertyWithUndo() instead.

void setPropertyWithUndo ( Property  p,
var  newValue 

Call this method whenever you want to change a property with undo.

If you didn't supply an UndoManager, it will simply call setProperty().

void setUndoManager ( UndoManager *  newUndoManager)

set the UndoManager that is used to save calls to setPropertyWithUndo().

void startPropertyChange ( Property  p,
int  newValue 

Call this whenever you want to start a new series of property modifications.

void toggleBoolProperty ( ModulatorSamplerSound::Property  p,
NotificationType  notifyEditor = sendNotification 

Toggles the boolean properties.

Currently supported Properties:

  • Normalized
  • LoopEnabled

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