honor LV2 units:midiNote: display Note name instead of integer
This commit is contained in:
parent
d92feec3f3
commit
0029ee40b6
@ -490,6 +490,32 @@ GenericPluginUI::integer_printer (char buf[32], Adjustment &adj, ControlUI* cui)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
GenericPluginUI::midinote_printer (char buf[32], Adjustment &adj, ControlUI* cui)
|
||||
{
|
||||
float const v = adj.get_value ();
|
||||
|
||||
if (cui->scale_points) {
|
||||
Plugin::ScalePoints::const_iterator i = cui->scale_points->begin ();
|
||||
while (i != cui->scale_points->end() && i->second != v) {
|
||||
++i;
|
||||
}
|
||||
|
||||
if (i != cui->scale_points->end ()) {
|
||||
snprintf (buf, 32, "%s", i->first.c_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (v >= 0 && v <= 127) {
|
||||
int mn = rint(v);
|
||||
const char notename[12][3] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
|
||||
snprintf (buf, 32, "%s %d", notename[mn%12], (mn/12)-2);
|
||||
} else {
|
||||
snprintf (buf, 32, "%.0f", v);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
GenericPluginUI::print_parameter (char *buf, uint32_t len, uint32_t param)
|
||||
{
|
||||
@ -610,7 +636,12 @@ GenericPluginUI::build_control_ui (guint32 port_index, boost::shared_ptr<Automat
|
||||
if (desc.integer_step) {
|
||||
control_ui->clickbox = new ClickBox (adj, "PluginUIClickBox");
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (*control_ui->clickbox, "g9999999", 2, 2);
|
||||
control_ui->clickbox->set_printer (sigc::bind (sigc::mem_fun (*this, &GenericPluginUI::integer_printer), control_ui));
|
||||
if (desc.midinote) {
|
||||
printf("MIDI NOTE\n");
|
||||
control_ui->clickbox->set_printer (sigc::bind (sigc::mem_fun (*this, &GenericPluginUI::midinote_printer), control_ui));
|
||||
} else {
|
||||
control_ui->clickbox->set_printer (sigc::bind (sigc::mem_fun (*this, &GenericPluginUI::integer_printer), control_ui));
|
||||
}
|
||||
} else {
|
||||
//sigc::slot<void,char*,uint32_t> pslot = sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::print_parameter), (uint32_t) port_index);
|
||||
|
||||
|
@ -277,6 +277,7 @@ class GenericPluginUI : public PlugUIBase, public Gtk::VBox
|
||||
/* XXX: remove */
|
||||
void print_parameter (char *buf, uint32_t len, uint32_t param);
|
||||
bool integer_printer (char* buf, Gtk::Adjustment &, ControlUI *);
|
||||
bool midinote_printer(char* buf, Gtk::Adjustment &, ControlUI *);
|
||||
};
|
||||
|
||||
class PluginUIWindow : public ArdourWindow
|
||||
|
@ -116,6 +116,7 @@ class Plugin : public PBD::StatefulDestructible, public Latent
|
||||
bool min_unbound;
|
||||
bool max_unbound;
|
||||
bool enumeration;
|
||||
bool midinote;
|
||||
};
|
||||
|
||||
XMLNode& get_state ();
|
||||
|
@ -143,6 +143,8 @@ public:
|
||||
LilvNode* ui_GtkUI;
|
||||
LilvNode* ui_external;
|
||||
LilvNode* ui_externalkx;
|
||||
LilvNode* units_unit;
|
||||
LilvNode* units_midiNote;
|
||||
|
||||
private:
|
||||
bool _bundle_checked;
|
||||
@ -1328,8 +1330,10 @@ LV2Plugin::get_parameter_descriptor(uint32_t which, ParameterDescriptor& desc) c
|
||||
{
|
||||
const LilvPort* port = lilv_plugin_get_port_by_index(_impl->plugin, which);
|
||||
|
||||
LilvNodes* portunits;
|
||||
LilvNode *def, *min, *max;
|
||||
lilv_port_get_range(_impl->plugin, port, &def, &min, &max);
|
||||
portunits = lilv_port_get_value(_impl->plugin, port, _world.units_unit);
|
||||
|
||||
desc.integer_step = lilv_port_has_property(_impl->plugin, port, _world.lv2_integer);
|
||||
desc.toggled = lilv_port_has_property(_impl->plugin, port, _world.lv2_toggled);
|
||||
@ -1338,6 +1342,8 @@ LV2Plugin::get_parameter_descriptor(uint32_t which, ParameterDescriptor& desc) c
|
||||
desc.label = lilv_node_as_string(lilv_port_get_name(_impl->plugin, port));
|
||||
desc.lower = min ? lilv_node_as_float(min) : 0.0f;
|
||||
desc.upper = max ? lilv_node_as_float(max) : 1.0f;
|
||||
desc.midinote = lilv_nodes_contains(portunits, _world.units_midiNote);
|
||||
|
||||
if (desc.sr_dependent) {
|
||||
desc.lower *= _session.frame_rate ();
|
||||
desc.upper *= _session.frame_rate ();
|
||||
@ -1362,6 +1368,7 @@ LV2Plugin::get_parameter_descriptor(uint32_t which, ParameterDescriptor& desc) c
|
||||
lilv_node_free(def);
|
||||
lilv_node_free(min);
|
||||
lilv_node_free(max);
|
||||
lilv_nodes_free(portunits);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1965,10 +1972,14 @@ LV2World::LV2World()
|
||||
ui_GtkUI = lilv_new_uri(world, LV2_UI__GtkUI);
|
||||
ui_external = lilv_new_uri(world, "http://lv2plug.in/ns/extensions/ui#external");
|
||||
ui_externalkx = lilv_new_uri(world, "http://kxstudio.sf.net/ns/lv2ext/external-ui#Widget");
|
||||
units_unit = lilv_new_uri(world, "http://lv2plug.in/ns/extensions/units#unit");
|
||||
units_midiNote = lilv_new_uri(world, "http://lv2plug.in/ns/extensions/units#midiNote");
|
||||
}
|
||||
|
||||
LV2World::~LV2World()
|
||||
{
|
||||
lilv_node_free(units_midiNote);
|
||||
lilv_node_free(units_unit);
|
||||
lilv_node_free(ui_externalkx);
|
||||
lilv_node_free(ui_external);
|
||||
lilv_node_free(ui_GtkUI);
|
||||
|
Loading…
Reference in New Issue
Block a user