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

Enumerator
ID 

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

FileName 

the complete filename of the audio file

RootNote 

the root note

KeyHigh 

the highest mapped key

KeyLow 

the lowest mapped key

VeloLow 

the lowest mapped velocity

VeloHigh 

the highest mapped velocity

RRGroup 

the group index for round robin / random group start behaviour

Volume 

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

Normalized 

enables normalization of the sample data

Pitch 

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

SampleStart 

the start sample

SampleEnd 

the end sample,

SampleStartMod 

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

LoopStart 

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

LoopEnd 

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

LoopXFade 

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

LoopEnabled 

true if the sample should be looped

LowerVelocityXFade 

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

UpperVelocityXFade 

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

SampleState 

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.

Parameters
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
overridevirtual

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
inline

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)
static

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
noexcept

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
noexcept

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
inlinenoexcept

returns the root note.

double getSampleRate ( ) const
inlinenoexcept

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

bool isNormalizedEnabled ( ) const
inlinenoexcept

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)
overridevirtual

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)
inline

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.