, _last_event_y (0)
, pre_enter_cursor (0)
, pre_press_cursor (0)
+ , _note_player (0)
{
_note_group->raise_to_top();
PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys));
- /* Look up MIDNAM details from our MidiTimeAxisView */
- MidiTimeAxisView& mtv = dynamic_cast<MidiTimeAxisView&> (tv);
- midi_patch_settings_changed (mtv.midi_patch_model (), mtv.midi_patch_custom_device_node ());
-
Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&MidiRegionView::parameter_changed, this, _1), gui_context());
connect_to_diskstream ();
, _last_event_y (0)
, pre_enter_cursor (0)
, pre_press_cursor (0)
+ , _note_player (0)
{
_note_group->raise_to_top();
PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys));
- /* Look up MIDNAM details from our MidiTimeAxisView */
- MidiTimeAxisView& mtv = dynamic_cast<MidiTimeAxisView&> (tv);
- midi_patch_settings_changed (mtv.midi_patch_model (), mtv.midi_patch_custom_device_node ());
-
connect_to_diskstream ();
SelectionCleared.connect (_selection_cleared_connection, invalidator (*this), boost::bind (&MidiRegionView::selection_cleared, this, _1), gui_context ());
, _last_event_y (0)
, pre_enter_cursor (0)
, pre_press_cursor (0)
+ , _note_player (0)
{
Gdk::Color c;
int r,g,b,a;
, _last_event_y (0)
, pre_enter_cursor (0)
, pre_press_cursor (0)
+ , _note_player (0)
{
Gdk::Color c;
int r,g,b,a;
midi_view()->signal_channel_mode_changed().connect(
sigc::mem_fun(this, &MidiRegionView::midi_channel_mode_changed));
- midi_view()->signal_midi_patch_settings_changed().connect(
- sigc::mem_fun(this, &MidiRegionView::midi_patch_settings_changed));
+ RouteUI* route_ui = dynamic_cast<RouteUI*> (&trackview);
+ if (route_ui) {
+ route_ui->route()->instrument_info().Changed.connect (_instrument_changed_connection, invalidator (*this),
+ boost::bind (&MidiRegionView::instrument_settings_changed, this), gui_context());
+ }
trackview.editor().SnapChanged.connect(snap_changed_connection, invalidator(*this),
boost::bind (&MidiRegionView::snap_changed, this),
bool
MidiRegionView::canvas_event(GdkEvent* ev)
{
+ bool r;
+
switch (ev->type) {
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
return button_press (&ev->button);
case GDK_BUTTON_RELEASE:
- return button_release (&ev->button);
+ r = button_release (&ev->button);
+ delete _note_player;
+ _note_player = 0;
+ return r;
case GDK_ENTER_NOTIFY:
return enter_notify (&ev->crossing);
continue;
}
- MIDI::Name::PatchPrimaryKey patch_key ((*i)->bank_msb (), (*i)->bank_lsb (), (*i)->program ());
+ // MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
+ //string patch_name = mtv->get_patch_name ((*i)->bank(), (*i)->program(), channel);
- boost::shared_ptr<MIDI::Name::Patch> patch =
- MIDI::Name::MidiPatchManager::instance().find_patch(
- _model_name, _custom_device_mode, channel, patch_key);
-
- if (patch != 0) {
- add_canvas_patch_change (*i, patch->name(), active_channel);
- } else {
- char buf[16];
- /* program and bank numbers are zero-based: convert to one-based: MIDI_BP_ZERO */
- snprintf (buf, 16, "%d %d", (*i)->program() + MIDI_BP_ZERO , (*i)->bank() + MIDI_BP_ZERO);
- add_canvas_patch_change (*i, buf, active_channel);
- }
+ // add_canvas_patch_change (*i, patch_name, active_channel);
}
}
return;
}
- NotePlayer* np = new NotePlayer (route_ui->midi_track());
+ NotePlayer* np = new NotePlayer (route_ui->midi_track ());
np->add (note);
np->play ();
+
+ /* NotePlayer deletes itself */
}
void
-MidiRegionView::play_midi_chord (vector<boost::shared_ptr<NoteType> > notes)
+MidiRegionView::start_playing_midi_note(boost::shared_ptr<NoteType> note)
{
if (_no_sound_notes || !Config->get_sound_midi_notes()) {
return;
return;
}
- NotePlayer* np = new NotePlayer (route_ui->midi_track());
+ delete _note_player;
+ _note_player = new NotePlayer (route_ui->midi_track ());
+ _note_player->add (note);
+ _note_player->on ();
+}
+
+void
+MidiRegionView::start_playing_midi_chord (vector<boost::shared_ptr<NoteType> > notes)
+{
+ if (_no_sound_notes || !Config->get_sound_midi_notes()) {
+ return;
+ }
+
+ RouteUI* route_ui = dynamic_cast<RouteUI*> (&trackview);
+
+ if (!route_ui || !route_ui->midi_track()) {
+ return;
+ }
+
+ delete _note_player;
+ _note_player = new NotePlayer (route_ui->midi_track());
for (vector<boost::shared_ptr<NoteType> >::iterator n = notes.begin(); n != notes.end(); ++n) {
- np->add (*n);
+ _note_player->add (*n);
}
- np->play ();
+ _note_player->on ();
}
}
if (i != _model->patch_changes().end()) {
- key.msb = (*i)->bank_msb ();
- key.lsb = (*i)->bank_lsb ();
+ key.bank_number = (*i)->bank();
key.program_number = (*i)->program ();
} else {
- key.msb = key.lsb = key.program_number = 0;
+ key.bank_number = key.program_number = 0;
}
assert (key.is_sane());
c->change_program (pc.patch (), new_patch.program_number);
}
- int const new_bank = (new_patch.msb << 7) | new_patch.lsb;
+ int const new_bank = new_patch.bank_number;
if (pc.patch()->bank() != new_bank) {
c->change_bank (pc.patch (), new_bank);
}
if (patch.patch()->program() < 127) {
MIDI::Name::PatchPrimaryKey key;
get_patch_key_at (patch.patch()->time(), patch.patch()->channel(), key);
- if (key.lsb > 0) {
- key.lsb--;
+ if (key.bank_number > 0) {
+ key.bank_number--;
change_patch_change (patch, key);
- } else {
- if (key.msb > 0) {
- key.lsb = 127;
- key.msb--;
- change_patch_change (patch, key);
- }
}
}
}
if (patch.patch()->program() > 0) {
MIDI::Name::PatchPrimaryKey key;
get_patch_key_at (patch.patch()->time(), patch.patch()->channel(), key);
- if (key.lsb < 127) {
- key.lsb++;
+ if (key.bank_number < 127) {
+ key.bank_number++;
change_patch_change (patch, key);
- } else {
- if (key.msb < 127) {
- key.lsb = 0;
- key.msb++;
- change_patch_change (patch, key);
- }
}
}
}
if (_selection.insert (ev).second) {
ev->set_selected (true);
- play_midi_note ((ev)->note());
+ start_playing_midi_note ((ev)->note());
}
if (add_mrv_selection) {
shifted.push_back (moved_note);
}
- play_midi_chord (shifted);
+ start_playing_midi_chord (shifted);
} else if (!to_play.empty()) {
boost::shared_ptr<NoteType> moved_note (new NoteType (*to_play.front()));
moved_note->set_note (moved_note->note() + cumulative_dy);
- play_midi_note (moved_note);
+ start_playing_midi_note (moved_note);
}
}
}
}
void
-MidiRegionView::midi_patch_settings_changed(std::string model, std::string custom_device_mode)
+MidiRegionView::instrument_settings_changed ()
{
- _model_name = model;
- _custom_device_mode = custom_device_mode;
redisplay_model();
}
/* Clear our selection in sympathy; but don't signal the fact */
clear_selection (false);
}
+
+void
+MidiRegionView::note_button_release ()
+{
+ delete _note_player;
+ _note_player = 0;
+}