* improved the way, MIDI-events are internally sent and handled

* fixed names of various member methods of notePlayHandle class
* full MIDI velocity when pressing key on test piano
* send volume changes of a notePlayHandle as MidiKeyPressure events
* send pitch changes of instrument track as MidiPitchBend events
* added detection for running MIDI notes
* correct calculation of MIDI key - makes remotePlugins respect base note settings



git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1562 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-09-06 22:04:03 +00:00
parent 61bdf0e089
commit 884b9ca671
11 changed files with 263 additions and 114 deletions

View File

@@ -70,6 +70,8 @@ public:
void processAudioBuffer( sampleFrame * _buf, const fpp_t _frames,
notePlayHandle * _n );
midiEvent applyMasterKey( const midiEvent & _me );
virtual void processInEvent( const midiEvent & _me,
const midiTime & _time );
virtual void processOutEvent( const midiEvent & _me,
@@ -100,9 +102,9 @@ public:
// name-stuff
virtual void setName( const QString & _new_name );
// translate key of given notePlayHandle to absolute key (i.e.
// add global master-pitch and base-note in piano)
int masterKey( notePlayHandle * _n ) const;
// translate given key of a note-event to absolute key (i.e.
// add global master-pitch and base-note of this instrument track)
int masterKey( int _midi_key ) const;
// translate pitch to midi-pitch [0,16383]
inline int midiPitch( void ) const
@@ -181,6 +183,7 @@ protected:
protected slots:
void updateBaseNote( void );
void updatePitch( void );
private:
@@ -188,6 +191,7 @@ private:
midiPort m_midiPort;
notePlayHandle * m_notes[NumKeys];
int m_runningMidiNotes[NumKeys];
intModel m_baseNoteModel;

View File

@@ -81,6 +81,7 @@ enum MidiMetaEvents
const int MidiChannelCount = 16;
const int MidiControllerCount = 128;
const int MidiMaxVelocity = 127;
struct midiEvent
@@ -105,6 +106,14 @@ struct midiEvent
m_data.m_sysExDataLen = _data_len;
}
midiEvent( const midiEvent & _copy ) :
m_type( _copy.m_type ),
m_channel( _copy.m_channel ),
m_data( _copy.m_data ),
m_sysExData( _copy.m_sysExData )
{
}
inline Uint16 key( void ) const
{
return( m_data.m_param[0] );
@@ -125,6 +134,12 @@ struct midiEvent
return( m_data.m_param[1] );
}
inline volume getVolume( void ) const
{
return( velocity() * 100 / MidiMaxVelocity );
}
MidiEventTypes m_type; // MIDI event type
Sint8 m_channel; // MIDI channel
union

View File

@@ -94,7 +94,7 @@ public:
void setLength( const midiTime & _length );
void setPos( const midiTime & _pos );
void setKey( const int _key );
void setVolume( const volume _volume = DefaultVolume );
virtual void setVolume( const volume _volume = DefaultVolume );
void setPanning( const panning _panning = DefaultPanning );
void quantizeLength( const int _q_grid );
void quantizePos( const int _q_grid );

View File

@@ -52,9 +52,12 @@ public:
const f_cnt_t _offset,
const f_cnt_t _frames, const note & _n,
notePlayHandle * _parent = NULL,
const bool _arp_note = FALSE );
const bool _part_of_arp = false );
virtual ~notePlayHandle();
virtual void setVolume( const volume _volume = DefaultVolume );
int getMidiVelocity( void ) const;
const float & frequency( void ) const
{
@@ -85,7 +88,7 @@ public:
if( m_released == TRUE )
{
f_cnt_t todo = engine::getMixer()->framesPerPeriod();
if( arpBaseNote() == TRUE )
if( isArpeggioBaseNote() )
{
rftd = rfd + 2 *
engine::getMixer()->framesPerPeriod();
@@ -118,7 +121,7 @@ public:
}
}
if( arpBaseNote() == TRUE && m_subNotes.size() == 0 )
if( isArpeggioBaseNote() && m_subNotes.size() == 0 )
{
rfd = rftd;
}
@@ -184,29 +187,29 @@ public:
// returns whether note is a base-note, e.g. is not part of an arpeggio
// or a chord
inline bool baseNote( void ) const
inline bool isBaseNote( void ) const
{
return( m_baseNote );
}
// returns whether note is part of an arpeggio
inline bool arpNote( void ) const
inline bool isPartOfArpeggio( void ) const
{
return( m_arpNote );
return( m_partOfArpeggio );
}
inline void setArpNote( const bool _on )
inline void setPartOfArpeggio( const bool _on )
{
m_arpNote = _on;
m_partOfArpeggio = _on;
}
// returns whether note is base-note for arpeggio
inline bool arpBaseNote( void ) const
inline bool isArpeggioBaseNote( void ) const
{
return( baseNote() && arpNote() );
return( isBaseNote() && ( m_partOfArpeggio ||
m_instrumentTrack->arpeggiatorEnabled() ) );
}
inline bool muted( void ) const
inline bool isMuted( void ) const
{
return( m_muted );
}
@@ -214,7 +217,7 @@ public:
void mute( void );
// returns index of note-play-handle in vector of note-play-handles
// belonging to this channel
// belonging to this instrument-track - used by arpeggiator
int index( void ) const;
// note-play-handles belonging to given channel, if _all_ph = TRUE,
@@ -255,7 +258,7 @@ public:
}
void processMidiTime( const midiTime & _time );
void resize( const bpm_t _new_bpm );
void resize( const bpm_t _new_tempo );
#if LMMS_SINGERBOT_SUPPORT
int patternIndex( void )
@@ -310,7 +313,7 @@ private:
volatile bool m_released; // indicates whether note is released
bool m_baseNote; // indicates whether note is a
// base-note (i.e. no sub-note)
bool m_arpNote; // indicates whether note is part of
bool m_partOfArpeggio; // indicates whether note is part of
// an arpeggio (either base-note or
// sub-note)
bool m_muted; // indicates whether note is muted
@@ -320,8 +323,8 @@ private:
#endif
// tempo reaction
bpm_t m_orig_bpm; // original bpm
f_cnt_t m_orig_frames; // original m_frames
bpm_t m_origTempo; // original tempo
f_cnt_t m_origFrames; // original m_frames
float m_frequency;
float m_unpitchedFrequency;