revert to a 0..2 scale for MIDI velocity control, so that we can increase MIDI note velocities as well as deccrease them (note: this will make the use of MIDI CC #7 a bit more complex)
git-svn-id: svn://localhost/ardour2/branches/3.0@13483 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
40a7b0f0b3
commit
3f35528f18
|
@ -263,7 +263,7 @@ GainMeterBase::setup_gain_adjustment ()
|
|||
} else {
|
||||
_data_type = DataType::MIDI;
|
||||
gain_adjustment.set_lower (0.0);
|
||||
gain_adjustment.set_upper (1.0);
|
||||
gain_adjustment.set_upper (2.0);
|
||||
gain_adjustment.set_step_increment (1.0/128.0);
|
||||
gain_adjustment.set_page_increment (10.0/128.0);
|
||||
gain_slider->set_default_value (1.0);
|
||||
|
@ -412,8 +412,7 @@ GainMeterBase::gain_activated ()
|
|||
f = min (f, 6.0f);
|
||||
_amp->set_gain (dB_to_coefficient(f), this);
|
||||
} else {
|
||||
f = min (fabs (f), 127.0f);
|
||||
f = Amp::midi_velocity_factor_to_gain_coefficient (f/127.0f);
|
||||
f = min (fabs (f), 2.0f);
|
||||
_amp->set_gain (f, this);
|
||||
}
|
||||
|
||||
|
@ -438,7 +437,7 @@ GainMeterBase::show_gain ()
|
|||
}
|
||||
break;
|
||||
case DataType::MIDI:
|
||||
snprintf (buf, sizeof (buf), "%.0f", v * 127.0f);
|
||||
snprintf (buf, sizeof (buf), "%.1f", v);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -455,7 +454,7 @@ GainMeterBase::gain_adjusted ()
|
|||
if (_data_type == DataType::AUDIO) {
|
||||
value = slider_position_to_gain_with_max (gain_adjustment.get_value(), Config->get_max_gain());
|
||||
} else {
|
||||
value = Amp::midi_velocity_factor_to_gain_coefficient (gain_adjustment.get_value());
|
||||
value = gain_adjustment.get_value();
|
||||
}
|
||||
|
||||
if (!ignore_toggle) {
|
||||
|
@ -479,7 +478,7 @@ GainMeterBase::effective_gain_display ()
|
|||
value = gain_to_slider_position_with_max (_amp->gain(), Config->get_max_gain());
|
||||
break;
|
||||
case DataType::MIDI:
|
||||
value = Amp::gain_coefficient_to_midi_velocity_factor (_amp->gain ());
|
||||
value = _amp->gain ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,12 +117,11 @@ Amp::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/,
|
|||
for (BufferSet::midi_iterator i = bufs.midi_begin(); i != bufs.midi_end(); ++i) {
|
||||
|
||||
MidiBuffer& mb (*i);
|
||||
const float midi_velocity_factor = gain_coefficient_to_midi_velocity_factor (_current_gain);
|
||||
|
||||
for (MidiBuffer::iterator m = mb.begin(); m != mb.end(); ++m) {
|
||||
Evoral::MIDIEvent<MidiBuffer::TimeType> ev = *m;
|
||||
if (ev.is_note_on()) {
|
||||
ev.scale_velocity (midi_velocity_factor);
|
||||
ev.scale_velocity (_current_gain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +176,7 @@ Amp::apply_gain (BufferSet& bufs, framecnt_t nframes, gain_t initial, gain_t tar
|
|||
|
||||
if (ev.is_note_on()) {
|
||||
const gain_t scale = delta * (ev.time()/(double) nframes);
|
||||
ev.scale_velocity (gain_coefficient_to_midi_velocity_factor (initial+scale));
|
||||
ev.scale_velocity (initial+scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -335,12 +334,11 @@ Amp::apply_simple_gain (BufferSet& bufs, framecnt_t nframes, gain_t target)
|
|||
|
||||
for (BufferSet::midi_iterator i = bufs.midi_begin(); i != bufs.midi_end(); ++i) {
|
||||
MidiBuffer& mb (*i);
|
||||
const float midi_velocity_factor = gain_coefficient_to_midi_velocity_factor (target);
|
||||
|
||||
for (MidiBuffer::iterator m = mb.begin(); m != mb.end(); ++m) {
|
||||
Evoral::MIDIEvent<MidiBuffer::TimeType> ev = *m;
|
||||
if (ev.is_note_on()) {
|
||||
ev.scale_velocity (midi_velocity_factor);
|
||||
ev.scale_velocity (target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,14 +105,6 @@ public:
|
|||
|
||||
static const float max_gain_coefficient;
|
||||
|
||||
inline static float gain_coefficient_to_midi_velocity_factor (gain_t v) {
|
||||
return (v/max_gain_coefficient);
|
||||
}
|
||||
|
||||
inline static gain_t midi_velocity_factor_to_gain_coefficient (float v) {
|
||||
return v * max_gain_coefficient;
|
||||
}
|
||||
|
||||
private:
|
||||
bool _denormal_protection;
|
||||
bool _apply_gain;
|
||||
|
|
Loading…
Reference in New Issue