Midi: added MidiDefaultVelocity to be used for test notes etc.

This commit is contained in:
Tobias Doerffel
2014-03-08 13:22:51 +01:00
parent b01f093e37
commit 56ee27ed9b
6 changed files with 10 additions and 9 deletions

View File

@@ -127,6 +127,7 @@ const int MidiChannelCount = 16;
const int MidiControllerCount = 128;
const int MidiProgramCount = 128;
const int MidiMaxVelocity = 127;
const int MidiDefaultVelocity = MidiMaxVelocity / 2;
const int MidiMaxControllerValue = 127;
const int MidiMaxNote = 127;

View File

@@ -50,7 +50,7 @@ public:
return m_pressedKeys[key];
}
void handleKeyPress( int key, int midiVelocity = MidiMaxVelocity );
void handleKeyPress( int key, int midiVelocity = MidiDefaultVelocity );
void handleKeyRelease( int key );
InstrumentTrack* instrumentTrack() const

View File

@@ -1103,7 +1103,7 @@ void sfxrInstrumentView::previewSound()
sfxrInstrument* s = castModel<sfxrInstrument>();
InstrumentTrack* it = s->instrumentTrack();
it->silenceAllNotes();
it->processInEvent( MidiEvent( MidiNoteOn, 0, it->baseNoteModel()->value(), MidiMaxVelocity ) );
it->processInEvent( MidiEvent( MidiNoteOn, 0, it->baseNoteModel()->value(), MidiDefaultVelocity ) );
}

View File

@@ -452,7 +452,7 @@ void PianoView::mousePressEvent( QMouseEvent * _me )
( ( KEY_ORDER[key_num % KeysPerOctave] ==
Piano::WhiteKey ) ?
PW_WHITE_KEY_HEIGHT : PW_BLACK_KEY_HEIGHT ) *
(float) MidiMaxVelocity );
(float) MidiDefaultVelocity );
if( y_diff < 0 )
{
velocity = 0;
@@ -462,7 +462,7 @@ void PianoView::mousePressEvent( QMouseEvent * _me )
Piano::WhiteKey ) ?
PW_WHITE_KEY_HEIGHT : PW_BLACK_KEY_HEIGHT ) )
{
velocity = MidiMaxVelocity;
velocity = MidiDefaultVelocity;
}
// set note on
m_piano->midiEventProcessor()->processInEvent( MidiEvent( MidiNoteOn, 0, key_num, velocity ) );
@@ -550,7 +550,7 @@ void PianoView::mouseMoveEvent( QMouseEvent * _me )
int velocity = (int)( (float) y_diff /
( ( KEY_ORDER[key_num % KeysPerOctave] == Piano::WhiteKey ) ?
PW_WHITE_KEY_HEIGHT : PW_BLACK_KEY_HEIGHT ) *
(float) MidiMaxVelocity );
(float) MidiDefaultVelocity );
// maybe the user moved the mouse-cursor above or under the
// piano-widget while holding left button so check that and
// correct volume if necessary
@@ -562,7 +562,7 @@ void PianoView::mouseMoveEvent( QMouseEvent * _me )
( ( KEY_ORDER[key_num % KeysPerOctave] == Piano::WhiteKey ) ?
PW_WHITE_KEY_HEIGHT : PW_BLACK_KEY_HEIGHT ) )
{
velocity = MidiMaxVelocity;
velocity = MidiDefaultVelocity;
}
// is the calculated key different from current key? (could be the

View File

@@ -1808,7 +1808,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
m_lastKey = key_num;
//if( ! m_recording && ! engine::getSong()->isPlaying() )
{
int v = ( (float) x ) / ( (float) WHITE_KEY_WIDTH ) * MidiMaxVelocity;
int v = ( (float) x ) / ( (float) WHITE_KEY_WIDTH ) * MidiDefaultVelocity;
m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( key_num, v );
}
}
@@ -2129,7 +2129,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
&& _me->buttons() & Qt::LeftButton )
{
// clicked on a key, play the note
testPlayKey( key_num, ( (float) x ) / ( (float) WHITE_KEY_WIDTH ) * MidiMaxVelocity, 0 );
testPlayKey( key_num, ( (float) x ) / ( (float) WHITE_KEY_WIDTH ) * MidiDefaultVelocity, 0 );
update();
return;
}

View File

@@ -1062,7 +1062,7 @@ void InstrumentTrackView::toggleInstrumentWindow( bool _on )
void InstrumentTrackView::activityIndicatorPressed()
{
model()->processInEvent( MidiEvent( MidiNoteOn, 0, DefaultKey, MidiMaxVelocity ) );
model()->processInEvent( MidiEvent( MidiNoteOn, 0, DefaultKey, MidiDefaultVelocity ) );
}