Normalize volume 100% to MIDI velocity 63
Furthermore moved midiVelocity() to Note and removed global volumeToMidi() helper method. Closes #280.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <cstdlib>
|
||||
#include "Midi.h"
|
||||
#include "panning_constants.h"
|
||||
#include "volume.h"
|
||||
|
||||
class MidiEvent
|
||||
{
|
||||
@@ -141,7 +142,7 @@ public:
|
||||
|
||||
volume_t volume() const
|
||||
{
|
||||
return (volume_t)( velocity() * 100 / MidiMaxVelocity );
|
||||
return (volume_t)( velocity() * MaxVolume / MidiMaxVelocity );
|
||||
}
|
||||
|
||||
const void* sourcePort() const
|
||||
|
||||
@@ -68,11 +68,6 @@ public:
|
||||
virtual void setVolume( volume_t volume );
|
||||
virtual void setPanning( panning_t panning );
|
||||
|
||||
int midiVelocity() const
|
||||
{
|
||||
return volumeToMidi( getVolume() );
|
||||
}
|
||||
|
||||
int midiKey() const;
|
||||
int midiChannel() const
|
||||
{
|
||||
|
||||
@@ -176,6 +176,11 @@ public:
|
||||
return m_volume;
|
||||
}
|
||||
|
||||
int midiVelocity() const
|
||||
{
|
||||
return qMin( MidiMaxVelocity, getVolume() * MidiMaxVelocity / MaxVolume );
|
||||
}
|
||||
|
||||
inline panning_t getPanning() const
|
||||
{
|
||||
return m_panning;
|
||||
|
||||
@@ -40,10 +40,4 @@ typedef struct
|
||||
float vol[2];
|
||||
} stereoVolumeVector;
|
||||
|
||||
|
||||
inline int volumeToMidi( volume_t vol )
|
||||
{
|
||||
return qMin( MidiMaxVelocity, vol * MidiMaxVelocity / DefaultVolume );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1862,7 +1862,7 @@ void pianoRoll::testPlayNote( note * n )
|
||||
//if( ! n->isPlaying() && ! m_recording && ! engine::getSong()->isPlaying() )
|
||||
{
|
||||
n->setIsPlaying( true );
|
||||
m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( n->key(), volumeToMidi( n->getVolume() ) );
|
||||
m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( n->key(), n->midiVelocity() );
|
||||
|
||||
MidiEvent event( MidiMetaEvent, 0, n->key(), panningToMidi( n->getPanning() ) );
|
||||
|
||||
@@ -2223,7 +2223,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
|
||||
if( m_noteEditMode == NoteEditVolume )
|
||||
{
|
||||
n->setVolume( vol );
|
||||
m_pattern->instrumentTrack()->processInEvent( MidiEvent( MidiKeyPressure, 0, n->key(), volumeToMidi( vol ) ) );
|
||||
m_pattern->instrumentTrack()->processInEvent( MidiEvent( MidiKeyPressure, 0, n->key(), n->midiVelocity() ) );
|
||||
}
|
||||
else if( m_noteEditMode == NoteEditPanning )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user