36#define OCTAVE_OFFSET 3
37#define OCTAVE_DEFAULT 0
38#define KEYS_PER_OCTAVE 12
40#define MIDI_MIDDLE_C 60
41#define MIDI_FACTOR 127
43#define VELOCITY_MIN 0.0f
44#define VELOCITY_MAX 1.0f
47#define LEAD_LAG_MIN -1.0f
48#define LEAD_LAG_MAX 1.0f
51#define MIDI_DEFAULT_OFFSET 36
106 enum Key {
C=
KEY_MIN,
Cs,
D,
Ef,
E,
F,
Fs,
G,
Af,
A,
Bf,
B };
124 Note( std::shared_ptr<Instrument> pInstrument,
int nPosition = 0,
float fVelocity = 0.8,
float fPan = 0.0,
int nLength = -1,
float fPitch = 0.0 );
131 Note(
Note* pOther, std::shared_ptr<Instrument> pInstrument =
nullptr );
148 static Note*
load_from(
XMLNode* node, std::shared_ptr<InstrumentList> instruments,
bool bSilent =
false );
154 void map_instrument( std::shared_ptr<InstrumentList> instruments );
192 this->
setPan( -1.f + 2.f * fVal );
198 return 0.5f * ( 1.f +
m_fPan );
323 std::shared_ptr<ADSR>
get_adsr()
const;
330 bool match( std::shared_ptr<Instrument> instrument,
Key key,
Octave octave )
const;
334 bool match(
const std::shared_ptr<Note> pNote )
const;
385 QString
toQString(
const QString& sPrefix =
"",
bool bShort =
true )
const override;
390 return pow( 1.0594630943593, fPitch );
395 return (
Octave)(nPitch / 12);
397 return (
Octave)((nPitch-11) / 12);
404 return 12 * (int)octave + (
int)key;
422 std::shared_ptr<Sample>
getSample(
int nComponentID,
int nSelectedLayer = -1 );
667 const double fLimit = 0.001;
724 return match( pNote->__instrument, pNote->__key, pNote->__octave );
#define MIDI_DEFAULT_OFFSET
A note plays an associated instrument with a velocity left and right pan.
int get_position() const
__position accessor
int __humanize_delay
frequency [0;1]
static int octaveKeyToPitch(Octave octave, Key key)
float m_fUsedTickSize
TransportPosition::m_fTickSize used to calculate m_nNoteStart.
static Key pitchToKey(int nPitch)
void set_length(int value)
__length setter
std::shared_ptr< SelectedLayerInfo > get_layer_selected(int CompoID)
float getPanWithRangeFrom0To1() const
get pan of the note, scaling and translating the range from [-1;1] to [0;1]
float get_lpfb_r() const
__lpfb_r accessor
void swing()
Add swing contribution to __humanize_delay.
bool isPartiallyRendered() const
int __pattern_idx
index of the pattern holding this note for undo actions
float get_bpfb_r() const
__bpfb_r accessor
std::shared_ptr< Instrument > __instrument
the instrument to be played by this note
void set_lead_lag(float value)
__lead_lag setter
float get_resonance() const
__resonance accessor
static QString KeyToQString(Key key)
float m_fPan
pan of the note, [-1;1] from
float __lpfb_l
left low pass filter buffer
void set_humanize_delay(int value)
__humanize_delay setter
void set_key_octave(const QString &str)
parse str and set __key and __octave
int __position
note position in
static Octave pitchToOctave(int nPitch)
void map_instrument(std::shared_ptr< InstrumentList > instruments)
find the corresponding instrument and point to it, or an empty instrument
static Note * load_from(XMLNode *node, std::shared_ptr< InstrumentList > instruments, bool bSilent=false)
load a note from an XMLNode
bool filter_sustain() const
Filter output is sustaining note.
float __resonance
filter resonant
Octave get_octave()
__octave accessor
void set_probability(float value)
int get_humanize_delay() const
__humanize_delay accessor
float __lead_lag
lead or lag offset of the note
int get_specific_compo_id() const
__specific_compo_id accessor
void set_position(int value)
__position setter
std::shared_ptr< Instrument > get_instrument()
__instrument accessor
float get_bpfb_l() const
__bpfb_l accessor
int get_midi_msg() const
__midi_msg accessor
float get_total_pitch() const
bool __just_recorded
used in record+delete
float get_lead_lag() const
__lead_lag accessor
float getUsedTickSize() const
void save_to(XMLNode *node)
float get_pitch() const
__pitch accessor
void humanize()
Add random contributions to __pitch, __humanize_delay, and __velocity.
void compute_lr_values(float *val_l, float *val_r)
compute left and right output based on filters
void set_just_recorded(bool value)
__just_recorded setter
int __length
left to right, as requested by Sampler PanLaws
std::shared_ptr< Sample > getSample(int nComponentID, int nSelectedLayer=-1)
Returns the sample associated with the note for a specific InstrumentComponent nComponentID.
int get_length() const
__length accessor
float get_notekey_pitch() const
note key pitch accessor
void set_instrument_id(int value)
__instrument_id setter
float __pitch
the frequency of the note
float __velocity
ticks inside the pattern
int get_midi_key() const
return scaled key for midi output, !!! DO NOT CHECK IF INSTRUMENT IS SET !!!
bool has_instrument() const
return true if __instrument is set
int get_pattern_idx() const
__pattern_idx accessor
float __probability
note probability
QString key_to_string()
return a string representation of key-octave
bool get_just_recorded() const
__just_recorded accessor
float get_velocity() const
__velocity accessor
void setPanWithRangeFrom0To1(float fVal)
set pan of the note, assuming the input range in [0;1]
bool get_note_off() const
__note_off accessor
void computeNoteStart()
Calculates the m_nNoteStart in frames corresponding to the __position in ticks and storing the used t...
void set_pattern_idx(int value)
__pattern_idx setter
void setPan(float val)
set pan of the note.
float __lpfb_r
right low pass filter buffer
void set_specific_compo_id(int value)
__specific_compo_id setter
void set_velocity(float value)
__velocity setter
static double pitchToFrequency(double fPitch)
Convert a logarithmic pitch-space value in semitones to a frequency-domain value.
QString toQString(const QString &sPrefix="", bool bShort=true) const override
Formatted string version for debugging purposes.
float __cut_off
filter cutoff [0;1]
std::shared_ptr< ADSR > get_adsr() const
get the ADSR of the note
std::map< int, std::shared_ptr< SelectedLayerInfo > > __layers_selected
long long getNoteStart() const
std::shared_ptr< ADSR > __adsr
attack decay sustain release
void set_note_off(bool value)
__note_off setter
float get_cut_off() const
__cut_off accessor
bool __note_off
note type on|off
long long m_nNoteStart
from __key an __octave
Key get_key()
__key accessor
float __bpfb_l
left band pass filter buffer
void set_midi_info(Key key, Octave octave, int msg)
set __key, __octave and __midi_msg only if within acceptable range
Key __key
the key, [0;11]==[C;B]
float get_probability() const
Octave __octave
the octave [-3;3]
float get_lpfb_l() const
__lpfb_l accessor
Note(std::shared_ptr< Instrument > pInstrument, int nPosition=0, float fVelocity=0.8, float fPan=0.0, int nLength=-1, float fPitch=0.0)
constructor
float getPan() const
get pan of the note.
int get_midi_velocity() const
midi velocity accessor
float __bpfb_r
right band pass filter buffer
int get_instrument_id() const
__instrument_id accessor
int __instrument_id
the id of the instrument played by this note
int __specific_compo_id
play a specific component, -1 if playing all
void set_pitch(float value)
__pitch setter
bool match(std::shared_ptr< Instrument > instrument, Key key, Octave octave) const
return true if instrument, key and octave matches with internal
std::map< int, std::shared_ptr< SelectedLayerInfo > > get_layers_selected() const
static const char * __key_str[]
used to build QString
XMLNode is a subclass of QDomNode with read and write values methods.
Auxiliary variables storing the rendering state of a H2Core::Note within the H2Core::Sampler.
int nSelectedLayer
Selected layer during rendering in the H2Core::Sampler.
float fSamplePosition
Stores the frame till which the H2Core::Sample of the selected H2Core::InstrumentLayer using nSelecte...
int nNoteLength
Frame / fSamplePosition at which rendering of the current note is considered done.