13
0

* MidiModel::const_iterator::operator++: added AUTOMATION type

* automatable.cc/parameter.cc: Added friendly names for the new Midi parameter types
* fixed a failed assertion problem (note on channel != note off channel), but have no idea how :)
* changed lots of whitespace :|


git-svn-id: svn://localhost/ardour2/branches/3.0@3309 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier 2008-05-03 06:37:22 +00:00
parent fb1fbf71af
commit b0d49651a7
9 changed files with 320 additions and 337 deletions

View File

@ -238,7 +238,7 @@ class AutomationList : public PBD::StatefulDestructible
Glib::Mutex& lock() const { return _lock; }
LookupCache& lookup_cache() const { return _lookup_cache; }
SearchCache& search_cache() const { return _search_cache; }
/** Called by locked entry point and various private
* locations where we already hold the lock.
*

View File

@ -226,6 +226,9 @@ private:
WriteNotes _write_notes[16];
bool _writing;
bool _edited;
typedef std::vector< boost::shared_ptr<const ARDOUR::AutomationList> > AutomationLists;
AutomationLists _dirty_automations;
const const_iterator _end_iter;

View File

@ -198,14 +198,21 @@ Automatable::describe_parameter (Parameter param)
{
/* derived classes like PluginInsert should override this */
if (param == Parameter(GainAutomation))
if (param == Parameter(GainAutomation)) {
return _("Fader");
else if (param.type() == PanAutomation)
} else if (param.type() == PanAutomation) {
return (string_compose(_("Pan %1"), param.id()));
else if (param.type() == MidiCCAutomation)
return string_compose("CC %1", param.id());
else
} else if (param.type() == MidiCCAutomation) {
return string_compose("CC %1 [%2]", param.id(), int(param.channel()) + 1);
} else if (param.type() == MidiPgmChangeAutomation) {
return string_compose("Program [%1]", int(param.channel()) + 1);
} else if (param.type() == MidiPitchBenderAutomation) {
return string_compose("Bender [%1]", int(param.channel()) + 1);
} else if (param.type() == MidiChannelAftertouchAutomation) {
return string_compose("Aftertouch [%1]", int(param.channel()) + 1);
} else {
return param.to_string();
}
}
void
@ -455,7 +462,11 @@ Automatable::transport_stopped (nframes_t now)
boost::shared_ptr<AutomationControl>
Automatable::control_factory(boost::shared_ptr<AutomationList> list)
{
if (list->parameter().type() == MidiCCAutomation) {
if (
list->parameter().type() == MidiCCAutomation ||
list->parameter().type() == MidiPgmChangeAutomation ||
list->parameter().type() == MidiChannelAftertouchAutomation
) {
// FIXME: this will die horribly if this is not a MidiTrack
return boost::shared_ptr<AutomationControl>(new MidiTrack::MidiControl((MidiTrack*)this, list));
} else {

View File

@ -1436,6 +1436,10 @@ AutomationList::get_state ()
XMLNode&
AutomationList::state (bool full)
{
cerr << "getting ";
if(full)
cerr << "full ";
cerr << "state for AutomationList " << _parameter.to_string() << " list size: " << size() << endl;
XMLNode* root = new XMLNode (X_("AutomationList"));
char buf[64];
LocaleGuard lg (X_("POSIX"));

File diff suppressed because it is too large Load Diff

View File

@ -724,11 +724,35 @@ MidiTrack::write_immediate_event(size_t size, const Byte* buf)
void
MidiTrack::MidiControl::set_value(float val)
{
assert(val >= 0);
assert(val <= 127.0);
assert(val >= _list->parameter().min());
assert(val <= _list->parameter().max());
if ( ! _list->automation_playback()) {
Byte ev[3] = { MIDI_CMD_CONTROL, _list->parameter().id(), (int)val };
Byte ev[3] = { _list->parameter().channel(), int(val), 0.0 };
switch(AutomationType type = _list->parameter().type()) {
case MidiCCAutomation:
ev[0] += MIDI_CMD_CONTROL;
ev[1] = _list->parameter().id();
ev[2] = int(val);
break;
case MidiPgmChangeAutomation:
ev[0] += MIDI_CMD_PGM_CHANGE;
break;
case MidiChannelAftertouchAutomation:
ev[0] += MIDI_CMD_CHANNEL_PRESSURE;
break;
case MidiPitchBenderAutomation:
ev[0] += MIDI_CMD_BENDER;
ev[1] = 0x7F & int(val);
ev[2] = 0x7F & (int(val) >> 7);
break;
default:
assert(false);
}
_route->write_immediate_event(3, ev);
}

View File

@ -40,6 +40,7 @@ Note::Note(uint8_t chan, double t, double d, uint8_t n, uint8_t v)
assert(duration() == d);
assert(note() == n);
assert(velocity() == v);
assert(_on_event.channel() == _off_event.channel());
}
@ -64,6 +65,8 @@ Note::Note(const Note& copy)
assert(note() == copy.note());
assert(velocity() == copy.velocity());
assert(duration() == copy.duration());
assert(_on_event.channel() == _off_event.channel());
assert(channel() == copy.channel());
}
@ -86,7 +89,9 @@ Note::operator=(const Note& copy)
assert(note() == copy.note());
assert(velocity() == copy.velocity());
assert(duration() == copy.duration());
assert(_on_event.channel() == _off_event.channel());
assert(channel() == copy.channel());
return *this;
}

View File

@ -87,13 +87,13 @@ Parameter::to_string() const
} else if (_type == PluginAutomation) {
return string_compose("parameter-%1", _id);
} else if (_type == MidiCCAutomation) {
return string_compose("midicc-%1-%2", _channel, _id);
return string_compose("midicc-%1-%2", int(_channel), _id);
} else if (_type == MidiPgmChangeAutomation) {
return string_compose("midi_pgm_change-%1", _channel);
return string_compose("midi-pgm-change-%1", int(_channel));
} else if (_type == MidiPitchBenderAutomation) {
return string_compose("midi_pitch_bender-%1", _channel);
return string_compose("midi-pitch-bender-%1", int(_channel));
} else if (_type == MidiChannelAftertouchAutomation) {
return string_compose("midi_channel_aftertouch-%1", _channel);
return string_compose("midi-channel-aftertouch-%1", int(_channel));
} else {
PBD::warning << "Uninitialized Parameter to_string() called." << endmsg;
return "";

View File

@ -451,8 +451,7 @@ SMFSource::write_unlocked (MidiRingBuffer& src, nframes_t cnt)
void
SMFSource::append_event_unlocked(EventTimeUnit unit, const MIDI::Event& ev)
{
printf("%s - append chan = %u, time = %lf, size = %u, data = ", _path.c_str(),
(unsigned)ev.channel(), ev.time(), ev.size());
//printf("%s - append chan = %u, time = %lf, size = %u, data = ", _path.c_str(), (unsigned)ev.channel(), ev.time(), ev.size());
for (size_t i=0; i < ev.size(); ++i) {
printf("%X ", ev.buffer()[i]);
}