2626
2727namespace lsp
2828{
29+ namespace meta
30+ {
31+ static constexpr float midi_velocity_min = 0 .0f ;
32+ static constexpr float midi_velocity_max = 127 .0f ;
33+ static constexpr float midi_velocity_err = 0 .01f ;
34+ static constexpr float midi_velocity_rng = midi_velocity_max - midi_velocity_min;
35+
36+ const meta::port_t midi_velocity_template =
37+ INT_CONTROL_ALL (" " , " MIDI velocity" , " MIDI vel" , meta::U_NONE, midi_velocity_min, midi_velocity_max, 0 .0f , 1 .0f );
38+ } /* namespace meta */
39+
2940 namespace plugui
3041 {
3142 namespace sampler_midi
3243 {
33- static constexpr float midi_velocity_min = 0 .0f ;
34- static constexpr float midi_velocity_max = 127 .0f ;
35- static constexpr float midi_velocity_err = 0 .01f ;
36- static constexpr float midi_velocity_rng = midi_velocity_max - midi_velocity_min;
37-
38- const meta::port_t midi_velocity_template =
39- {
40- " " ,
41- " MIDI velocity" ,
42- NULL ,
43- meta::U_NONE,
44- meta::R_CONTROL,
45- meta::F_INT | meta::F_LOWER | meta::F_UPPER | meta::F_STEP,
46- midi_velocity_min, midi_velocity_max, 0 .0f , 0 .05f ,
47- NULL , NULL , NULL
48- };
49-
5044 MidiVelocityPort::MidiVelocityPort ()
5145 {
5246 }
@@ -73,7 +67,7 @@ namespace lsp
7367 if (!tmp.append_utf8 (cptr))
7468 return STATUS_NO_MEM;
7569
76- return ProxyPort::init (tmp.get_utf8 (), port, &midi_velocity_template);
70+ return ProxyPort::init (tmp.get_utf8 (), port, &meta:: midi_velocity_template);
7771 }
7872
7973 float MidiVelocityPort::from_value (float value)
@@ -82,7 +76,7 @@ namespace lsp
8276 if (meta == NULL )
8377 return value;
8478
85- const float range = midi_velocity_rng / (meta->max - meta->min );
79+ const float range = meta:: midi_velocity_rng / (meta->max - meta->min );
8680 return (value - meta->min ) * range;
8781 }
8882
@@ -92,8 +86,8 @@ namespace lsp
9286 if (meta == NULL )
9387 return value;
9488
95- const float range = (meta->max - meta->min + midi_velocity_err) / midi_velocity_rng;
96- value = meta->min + (value - midi_velocity_min) * range;
89+ const float range = (meta->max - meta->min + meta:: midi_velocity_err) / meta:: midi_velocity_rng;
90+ value = meta->min + (value - meta:: midi_velocity_min) * range;
9791 return lsp_limit (value, meta->min , meta->max );
9892 }
9993
0 commit comments