13
0

* first prototype implementation of playing back MIDI notes when selected

git-svn-id: svn://localhost/ardour2/branches/3.0@4348 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier 2008-12-25 23:08:57 +00:00
parent c3636a8c61
commit be75d43bd0
6 changed files with 47 additions and 11 deletions

View File

@ -3248,11 +3248,6 @@ Editor::midi_panic_button_pressed ()
}
}
void Editor::midi_sound_notes_toggled ()
{
cerr << "toggle sound notes" << endl;
}
void
Editor::setup_midi_toolbar ()
{
@ -3317,8 +3312,6 @@ Editor::setup_midi_toolbar ()
midi_sound_notes.set_relief(Gtk::RELIEF_NONE);
ARDOUR_UI::instance()->tooltips().set_tip (midi_sound_notes, _("Sound Notes"));
midi_sound_notes.unset_flags (CAN_FOCUS);
midi_sound_notes.signal_toggled().connect (mem_fun(*this,
&Editor::midi_sound_notes_toggled));
/* Panic */

View File

@ -1754,7 +1754,7 @@ public:
GroupedButtons *midi_tool_button_set;
void midi_edit_mode_toggled (Editing::MidiEditMode m);
void midi_panic_button_pressed ();
void midi_sound_notes_toggled();
bool is_midi_sound_notes_active () const { return midi_sound_notes.get_active(); }
bool ignore_midi_edit_mode_toggle;

View File

@ -887,6 +887,36 @@ MidiRegionView::extend_active_notes()
}
}
void
MidiRegionView::play_midi_note(boost::shared_ptr<Evoral::Note> note)
{
if (!trackview.editor.is_midi_sound_notes_active()) {
cerr << "not_active " << endl;
return;
}
RouteUI* route_ui = dynamic_cast<RouteUI*> (&trackview);
assert(route_ui);
route_ui->midi_track()->write_immediate_event(note->on_event().size(), note->on_event().buffer());
Glib::Thread::create(bind(mem_fun(this, &MidiRegionView::play_midi_note_off), note), false);
}
void
MidiRegionView::play_midi_note_off(boost::shared_ptr<Evoral::Note> note)
{
RouteUI* route_ui = dynamic_cast<RouteUI*> (&trackview);
assert(route_ui);
Glib::usleep(
(note->off_event().time() - note->on_event().time()) *
(1000000 / route_ui->session().nominal_frame_rate())
);
route_ui->midi_track()->write_immediate_event(note->off_event().size(), note->off_event().buffer());
}
/** Add a MIDI note to the view (with length).
*
@ -1181,6 +1211,7 @@ MidiRegionView::note_selected(ArdourCanvas::CanvasNoteEvent* ev, bool add)
}
_selection.insert(ev);
play_midi_note(ev->note());
if ( ! ev->selected()) {
ev->selected(true);

View File

@ -261,7 +261,15 @@ class MidiRegionView : public RegionView
void reset_width_dependent_items (double pixel_width);
private:
/** play back the given MIDI note immediately
*/
void play_midi_note(boost::shared_ptr<Evoral::Note> note);
/** play back the NoteOff-Event of the given note (used by
* @ref play_midi_note() ) after waiting the duration of the MIDI Note
*/
void play_midi_note_off(boost::shared_ptr<Evoral::Note> note);
void clear_events();
void switch_source(boost::shared_ptr<ARDOUR::Source> src);

View File

@ -160,6 +160,10 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway
* (defined in editing_syms.h)
*/
virtual Editing::MidiEditMode current_midi_edit_mode () const = 0;
/** @return Sound edited notes in MIDI regions while editing
*/
virtual bool is_midi_sound_notes_active () const = 0;
/** Possibly start the audition of a region. If \ref r is 0, or not an AudioRegion
* any current audition is cancelled. If we are currently auditioning \ref r,

View File

@ -726,11 +726,11 @@ MidiTrack::midi_panic()
bool
MidiTrack::write_immediate_event(size_t size, const uint8_t* buf)
{
/*printf("Write immediate event: ");
printf("Write immediate event: ");
for (size_t i=0; i < size; ++i) {
printf("%X ", buf[i]);
}
printf("\n");*/
printf("\n");
const uint32_t type = EventTypeMap::instance().midi_event_type(buf[0]);
return (_immediate_events.write(0, type, size, buf) == size);
}