/*
Copyright (C) 2008 Paul Davis
- Author: Dave Robillard
+ Author: David Robillard
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
+#include <ctype.h>
#include <cstdio>
#include "ardour/types.h"
#include "ardour/event_type_map.h"
+#include "ardour/parameter_types.h"
+#include "ardour/uri_map.h"
#include "evoral/Parameter.hpp"
#include "evoral/midi_events.h"
#include "evoral/MIDIParameters.hpp"
namespace ARDOUR {
-EventTypeMap EventTypeMap::event_type_map;
+EventTypeMap* EventTypeMap::event_type_map;
+
+EventTypeMap&
+EventTypeMap::instance()
+{
+ if (!EventTypeMap::event_type_map) {
+ EventTypeMap::event_type_map = new EventTypeMap(URIMap::instance());
+
+ // Initialize parameter metadata
+ EventTypeMap::event_type_map->new_parameter(NullAutomation);
+ EventTypeMap::event_type_map->new_parameter(GainAutomation);
+ EventTypeMap::event_type_map->new_parameter(PanAzimuthAutomation);
+ EventTypeMap::event_type_map->new_parameter(PanElevationAutomation);
+ EventTypeMap::event_type_map->new_parameter(PanWidthAutomation);
+ EventTypeMap::event_type_map->new_parameter(PluginAutomation);
+ EventTypeMap::event_type_map->new_parameter(PluginPropertyAutomation);
+ EventTypeMap::event_type_map->new_parameter(SoloAutomation);
+ EventTypeMap::event_type_map->new_parameter(MuteAutomation);
+ EventTypeMap::event_type_map->new_parameter(MidiCCAutomation);
+ EventTypeMap::event_type_map->new_parameter(MidiPgmChangeAutomation);
+ EventTypeMap::event_type_map->new_parameter(MidiPitchBenderAutomation);
+ EventTypeMap::event_type_map->new_parameter(MidiChannelPressureAutomation);
+ EventTypeMap::event_type_map->new_parameter(FadeInAutomation);
+ EventTypeMap::event_type_map->new_parameter(FadeOutAutomation);
+ EventTypeMap::event_type_map->new_parameter(EnvelopeAutomation);
+ EventTypeMap::event_type_map->new_parameter(MidiCCAutomation);
+ }
+ return *EventTypeMap::event_type_map;
+}
bool
EventTypeMap::type_is_midi(uint32_t type) const
{
- return (type >= MidiCCAutomation) && (type <= MidiChannelPressureAutomation);
+ return ARDOUR::parameter_is_midi((AutomationType)type);
}
bool
EventTypeMap::is_midi_parameter(const Evoral::Parameter& param)
{
- return type_is_midi(param.type());
+ return type_is_midi(param.type());
}
uint8_t
EventTypeMap::parameter_midi_type(const Evoral::Parameter& param) const
{
- switch (param.type()) {
- case MidiCCAutomation: return MIDI_CMD_CONTROL; break;
- case MidiPgmChangeAutomation: return MIDI_CMD_PGM_CHANGE; break;
- case MidiChannelPressureAutomation: return MIDI_CMD_CHANNEL_PRESSURE; break;
- case MidiPitchBenderAutomation: return MIDI_CMD_BENDER; break;
- case MidiSystemExclusiveAutomation: return MIDI_CMD_COMMON_SYSEX; break;
- default: return 0;
- }
+ return ARDOUR::parameter_midi_type((AutomationType)param.type());
}
uint32_t
EventTypeMap::midi_event_type(uint8_t status) const
{
- switch (status & 0xF0) {
- case MIDI_CMD_CONTROL: return MidiCCAutomation; break;
- case MIDI_CMD_PGM_CHANGE: return MidiPgmChangeAutomation; break;
- case MIDI_CMD_CHANNEL_PRESSURE: return MidiChannelPressureAutomation; break;
- case MIDI_CMD_BENDER: return MidiPitchBenderAutomation; break;
- case MIDI_CMD_COMMON_SYSEX: return MidiSystemExclusiveAutomation; break;
- default: return 0;
- }
+ return (uint32_t)ARDOUR::midi_parameter_type(status);
}
bool
&& param.type() <= MidiChannelPressureAutomation);
}
-Evoral::ControlList::InterpolationStyle
+Evoral::ControlList::InterpolationStyle
EventTypeMap::interpolation_of(const Evoral::Parameter& param)
{
switch (param.type()) {
case MIDI_CTL_OMNI_OFF:
case MIDI_CTL_OMNI_ON:
case MIDI_CTL_MONO:
- case MIDI_CTL_POLY:
- return Evoral::ControlList::Discrete;
- break;
- default: return Evoral::ControlList::Linear; break;
+ case MIDI_CTL_POLY:
+ return Evoral::ControlList::Discrete; break;
+ default:
+ return Evoral::ControlList::Linear; break;
}
- break;
- case MidiPgmChangeAutomation: return Evoral::ControlList::Discrete; break;
- case MidiChannelPressureAutomation: return Evoral::ControlList::Linear; break;
- case MidiPitchBenderAutomation: return Evoral::ControlList::Linear; break;
+ break;
+ case MidiPgmChangeAutomation: return Evoral::ControlList::Discrete; break;
+ case MidiChannelPressureAutomation: return Evoral::ControlList::Linear; break;
+ case MidiPitchBenderAutomation: return Evoral::ControlList::Linear; break;
default: assert(false);
}
return Evoral::ControlList::Linear; // Not reached, suppress warnings
double min = 0.0f;
double max = 1.0f;
double normal = 0.0f;
+
switch((AutomationType)type) {
case NullAutomation:
case GainAutomation:
max = 2.0f;
normal = 1.0f;
break;
- case PanAutomation:
- normal = 0.5f;
+ case PanAzimuthAutomation:
+ normal = 0.5f; // there really is no normal but this works for stereo, sort of
+ break;
+ case PanWidthAutomation:
+ min = -1.0;
+ max = 1.0;
+ normal = 0.0f;
+ break;
+ case PanElevationAutomation:
+ case PanFrontBackAutomation:
+ case PanLFEAutomation:
+ break;
+ case RecEnableAutomation:
+ /* default 0.0 - 1.0 is fine */
break;
case PluginAutomation:
- case SoloAutomation:
- case MuteAutomation:
case FadeInAutomation:
case FadeOutAutomation:
case EnvelopeAutomation:
max = 2.0f;
normal = 1.0f;
break;
+ case SoloAutomation:
+ case MuteAutomation:
+ max = 1.0f;
+ normal = 0.0f;
+ break;
case MidiCCAutomation:
case MidiPgmChangeAutomation:
case MidiChannelPressureAutomation:
Evoral::MIDI::bender_range(min, max, normal); break;
case MidiSystemExclusiveAutomation:
return p;
+ case PluginPropertyAutomation:
+ return p;
}
-
- p.set_range(type, min, max, normal);
+
+ p.set_range(type, min, max, normal, false);
return p;
}
p_type = FadeOutAutomation;
} else if (str == "envelope") {
p_type = EnvelopeAutomation;
- } else if (str == "pan") {
- p_type = PanAutomation;
- } else if (str.length() > 4 && str.substr(0, 4) == "pan-") {
- p_type = PanAutomation;
- p_id = atoi(str.c_str()+4);
+ } else if (str == "pan-azimuth") {
+ p_type = PanAzimuthAutomation;
+ } else if (str == "pan-width") {
+ p_type = PanWidthAutomation;
+ } else if (str == "pan-elevation") {
+ p_type = PanElevationAutomation;
+ } else if (str == "pan-frontback") {
+ p_type = PanFrontBackAutomation;
+ } else if (str == "pan-lfe") {
+ p_type = PanLFEAutomation;
} else if (str.length() > 10 && str.substr(0, 10) == "parameter-") {
p_type = PluginAutomation;
p_id = atoi(str.c_str()+10);
+ } else if (str.length() > 9 && str.substr(0, 9) == "property-") {
+ p_type = PluginPropertyAutomation;
+ const char* name = str.c_str() + 9;
+ if (isdigit(str.c_str()[0])) {
+ p_id = atoi(name);
+ } else {
+ p_id = _uri_map.uri_to_id(name);
+ }
} else if (str.length() > 7 && str.substr(0, 7) == "midicc-") {
p_type = MidiCCAutomation;
uint32_t channel = 0;
assert(channel < 16);
p_id = 0;
p_channel = channel;
- } else if (str.length() > 24 && str.substr(0, 24) == "midi-channel-pressure-") {
+ } else if (str.length() > 22 && str.substr(0, 22) == "midi-channel-pressure-") {
p_type = MidiChannelPressureAutomation;
uint32_t channel = 0;
sscanf(str.c_str(), "midi-channel-pressure-%d", &channel);
} else {
PBD::warning << "Unknown Parameter '" << str << "'" << endmsg;
}
-
+
return new_parameter(p_type, p_channel, p_id);
}
if (t == GainAutomation) {
return "gain";
- } else if (t == PanAutomation) {
- return string_compose("pan-%1", param.id());
+ } else if (t == PanAzimuthAutomation) {
+ return "pan-azimuth";
+ } else if (t == PanElevationAutomation) {
+ return "pan-elevation";
+ } else if (t == PanWidthAutomation) {
+ return "pan-width";
+ } else if (t == PanFrontBackAutomation) {
+ return "pan-frontback";
+ } else if (t == PanLFEAutomation) {
+ return "pan-lfe";
} else if (t == SoloAutomation) {
return "solo";
} else if (t == MuteAutomation) {
return "envelope";
} else if (t == PluginAutomation) {
return string_compose("parameter-%1", param.id());
+ } else if (t == PluginPropertyAutomation) {
+ const char* uri = _uri_map.id_to_uri(param.id());
+ if (uri) {
+ return string_compose("property-%1", uri);
+ } else {
+ return string_compose("property-%1", param.id());
+ }
} else if (t == MidiCCAutomation) {
return string_compose("midicc-%1-%2", int(param.channel()), param.id());
} else if (t == MidiPgmChangeAutomation) {