|
hydrogen 1.1.1
|
Waveform based sampler. More...
#include <Sampler.h>
Public Types | |
| enum | PAN_LAW_TYPES { RATIO_STRAIGHT_POLYGONAL = 0 , RATIO_CONST_POWER , RATIO_CONST_SUM , LINEAR_STRAIGHT_POLYGONAL , LINEAR_CONST_POWER , LINEAR_CONST_SUM , POLAR_STRAIGHT_POLYGONAL , POLAR_CONST_POWER , POLAR_CONST_SUM , QUADRATIC_STRAIGHT_POLYGONAL , QUADRATIC_CONST_POWER , QUADRATIC_CONST_SUM , LINEAR_CONST_K_NORM , RATIO_CONST_K_NORM , POLAR_CONST_K_NORM , QUADRATIC_CONST_K_NORM } |
| PAN LAWS The following pan law functions return pan_L (==L, which is the gain for Left channel). More... | |
Public Member Functions | |
| Sampler () | |
| Constructor of the Sampler. More... | |
| ~Sampler () | |
| void | process (uint32_t nFrames, Song *pSong) |
| void | noteOn (Note *pNote) |
| Start playing a note. More... | |
| void | noteOff (Note *pNote) |
| Stop playing a note. More... | |
| void | midiKeyboardNoteOff (int key) |
| void | stopPlayingNotes (Instrument *pInstr=nullptr) |
| int | getPlayingNotesNumber () |
| void | preview_sample (std::shared_ptr< Sample > pSample, int length) |
| Preview, uses only the first layer. More... | |
| void | preview_instrument (Instrument *pInstr) |
| void | setPlayingNotelength (Instrument *pInstrument, unsigned long ticks, unsigned long noteOnTick) |
| bool | isInstrumentPlaying (Instrument *pInstr) |
| void | setInterpolateMode (Interpolation::InterpolateMode mode) |
| Instrument * | getPreviewInstrument () const |
| Instrument * | getPlaybackTrackInstrument () const |
| Interpolation::InterpolateMode | getInterpolateMode () |
| void | reinitializePlaybackTrack () |
| Loading of the playback track. More... | |
Public Member Functions inherited from Object | |
| ~Object () | |
| destructor More... | |
| Object (const Object &obj) | |
| copy constructor More... | |
| Object (const char *class_name) | |
| constructor More... | |
| const char * | class_name () const |
| return the class name More... | |
| virtual QString | toQString (const QString &sPrefix, bool bShort=true) const |
| Formatted string version for debugging purposes. More... | |
| void | Print (bool bShort=true) const |
| Prints content of toQString() via DEBUGLOG. More... | |
Static Public Member Functions | |
| static float | ratioStraightPolygonalPanLaw (float fPan) |
| static float | ratioConstPowerPanLaw (float fPan) |
| static float | ratioConstSumPanLaw (float fPan) |
| static float | linearStraightPolygonalPanLaw (float fPan) |
| static float | linearConstPowerPanLaw (float fPan) |
| static float | linearConstSumPanLaw (float fPan) |
| static float | polarStraightPolygonalPanLaw (float fPan) |
| static float | polarConstPowerPanLaw (float fPan) |
| static float | polarConstSumPanLaw (float fPan) |
| static float | quadraticStraightPolygonalPanLaw (float fPan) |
| static float | quadraticConstPowerPanLaw (float fPan) |
| static float | quadraticConstSumPanLaw (float fPan) |
| static float | linearConstKNormPanLaw (float fPan, float k) |
| static float | polarConstKNormPanLaw (float fPan, float k) |
| static float | ratioConstKNormPanLaw (float fPan, float k) |
| static float | quadraticConstKNormPanLaw (float fPan, float k) |
| static float | getRatioPan (float fPan_L, float fPan_R) |
| This necessary function returns the single pan parameter in [-1,1] from the L,R gains as it was input from the GUI (up to scale and translation, which is arbitrary) More... | |
Static Public Member Functions inherited from Object | |
| static void | set_count (bool flag) |
| enable/disable class instances counting More... | |
| static bool | count_active () |
| return true if class instances counting is enabled More... | |
| static unsigned | objects_count () |
| return the number of objects More... | |
| static void | write_objects_map_to (std::ostream &out) |
| output the full objects map to a given ostream More... | |
| static void | write_objects_map_to_cerr () |
| output objects map to stderr More... | |
| static int | bootstrap (Logger *logger, bool count=false) |
| must be called before any Object instantiation ! More... | |
| static Logger * | logger () |
| return the logger instance More... | |
Data Fields | |
| float * | m_pMainOut_L |
| sampler main out (left channel) More... | |
| float * | m_pMainOut_R |
| sampler main out (right channel) More... | |
Static Public Attributes | |
| static const float | K_NORM_DEFAULT = 1.33333333333333 |
| default k for pan law with such that L^k + R^k = const must be initialised in Sampler.cpp More... | |
Static Public Attributes inherited from Object | |
| static QString | sPrintIndention = " " |
| String used to format the debugging string output of some core classes. More... | |
Private Member Functions | |
| float | panLaw (float fPan, Song *pSong) |
| function to direct the computation to the selected pan law function More... | |
| bool | processPlaybackTrack (int nBufferSize) |
| bool | isAnyInstrumentSoloed () const |
| bool | renderNote (Note *pNote, unsigned nBufferSize, Song *pSong) |
| Render a note Return false: the note is not ended Return true: the note is ended. More... | |
| bool | renderNoteNoResample (std::shared_ptr< Sample > pSample, Note *pNote, SelectedLayerInfo *pSelectedLayerInfo, InstrumentComponent *pCompo, DrumkitComponent *pDrumCompo, int nBufferSize, int nInitialSilence, float cost_L, float cost_R, float cost_track_L, float cost_track_R, Song *pSong) |
| bool | renderNoteResample (std::shared_ptr< Sample > pSample, Note *pNote, SelectedLayerInfo *pSelectedLayerInfo, InstrumentComponent *pCompo, DrumkitComponent *pDrumCompo, int nBufferSize, int nInitialSilence, float cost_L, float cost_R, float cost_track_L, float cost_track_R, float fLayerPitch, Song *pSong) |
Private Attributes | |
| std::vector< Note * > | m_playingNotesQueue |
| std::vector< Note * > | m_queuedNoteOffs |
| Instrument * | m_pPlaybackTrackInstrument |
| Instrument used for the playback track feature. More... | |
| Instrument * | m_pPreviewInstrument |
| Instrument used for the preview feature. More... | |
| int | m_nMaxLayers |
| Maximum number of layers to be used in the Instrument editor. More... | |
| int | m_nPlayBackSamplePosition |
| Interpolation::InterpolateMode | m_interpolateMode |
Additional Inherited Members | |
Static Protected Attributes inherited from Object | |
| static Logger * | __logger = nullptr |
| logger instance pointer More... | |
Waveform based sampler.
| enum PAN_LAW_TYPES |
PAN LAWS The following pan law functions return pan_L (==L, which is the gain for Left channel).
They assume a fPan argument domain in [-1;1], and this always happens
For the right channel use: R(p) == pan_R(p) = pan_L(-p) == L(-p)
The prefix of the function name tells the interpretation of the fPan argument:
"ratio" parameter: fPan = R/L - 1 if panned to the left, fPan = 1 - L/R if panned to the right.
"linear" parameter (arithmetic mean with linear weights): fPan = ( R - L ) / ( R + L ).
"polar" parameter (polar coordinate in LR plane): fPan = 4 / pi * arctan( R/L ) - 1 if L != 0, fPan = 1 if L == 0.
"quadratic" parameter (arithmetic mean with squared weights): fPan = ( R^2 - L^2 ) / ( R^2 + L^2 ).
Note: using a different fPan interpretation makes the output signal more central or more lateral. From more central to more lateral:
After the prefix, the name describes the Image of the pan law in the LR plane. (remember that each pan law is a parametrized curve in LR plane. E.g.: "ConstantSum": it's properly used in an anechoic room, where there are no reflections. Ensures uniform volumes in MONO export, has -6.02 dB center compensation. "ConstantPower": probably makes uniform volumes in a common room, has -3.01 dB center compensation. "ConstantKNorm": L^k + R^k = const generalises constant sum (k = 1) and constant power (k = 2) "StraightPolygonal": one gain is constant while the other varies. It's ideal as BALANCE law of DUAL-channel track, has 0 dB center compensation.
| Sampler | ( | ) |
Constructor of the Sampler.
It is called by AudioEngine::AudioEngine() and stored in AudioEngine::__sampler.
| ~Sampler | ( | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
This necessary function returns the single pan parameter in [-1,1] from the L,R gains as it was input from the GUI (up to scale and translation, which is arbitrary)
|
private |
| bool isInstrumentPlaying | ( | Instrument * | pInstr | ) |
|
static |
|
static |
|
static |
|
static |
| void midiKeyboardNoteOff | ( | int | key | ) |
| void noteOff | ( | Note * | pNote | ) |
Stop playing a note.
This old note_off function is only used by right click on mixer channel strip play button all other note_off stuff will handle in midi_keyboard_note_off() and note_on()
| void noteOn | ( | Note * | pNote | ) |
Start playing a note.
|
inlineprivate |
function to direct the computation to the selected pan law function
|
static |
|
static |
|
static |
|
static |
| void preview_instrument | ( | Instrument * | pInstr | ) |
| void preview_sample | ( | std::shared_ptr< Sample > | pSample, |
| int | length | ||
| ) |
Preview, uses only the first layer.
| void process | ( | uint32_t | nFrames, |
| Song * | pSong | ||
| ) |
|
private |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| void reinitializePlaybackTrack | ( | ) |
Loading of the playback track.
The playback track is added to #__playback_instrument as a new InstrumentLayer containing the loaded Sample. If Song::__playback_track_filename is empty, the layer will be loaded with a nullptr instead.
Render a note Return false: the note is not ended Return true: the note is ended.
|
private |
|
private |
|
inline |
| void setPlayingNotelength | ( | Instrument * | pInstrument, |
| unsigned long | ticks, | ||
| unsigned long | noteOnTick | ||
| ) |
| void stopPlayingNotes | ( | Instrument * | pInstr = nullptr | ) |
|
static |
default k for pan law with such that L^k + R^k = const must be initialised in Sampler.cpp
set default k for pan law with -4.5dB center compensation, given L^k + R^k = const it is the mean compromise between constant sum and constant power
|
private |
|
private |
Maximum number of layers to be used in the Instrument editor.
It will be inferred from InstrumentComponent::m_nMaxLayers, which itself is inferred from Preferences::m_nMaxLayers. Default value assigned in Preferences::Preferences(): 16.
|
private |
|
private |
| float* m_pMainOut_L |
sampler main out (left channel)
| float* m_pMainOut_R |
sampler main out (right channel)
|
private |
Instrument used for the playback track feature.
|
private |
Instrument used for the preview feature.
|
private |