diff options
author | David Robillard <d@drobilla.net> | 2009-02-15 19:44:27 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-02-15 19:44:27 +0000 |
commit | 166395c96b8a85d90b9785e629c739494494130f (patch) | |
tree | ad688f25e8298519f63829e926a09d8739fbf5b0 | |
parent | ecaf107ed3dd2bb3443a92fc3dd9cf566d3439e3 (diff) |
Fix genererally retarded and broken note range / diskstream display / etc. related things (correctly display region contents on initial session load).
git-svn-id: svn://localhost/ardour2/branches/3.0@4583 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/audio_streamview.cc | 22 | ||||
-rw-r--r-- | gtk2_ardour/canvas-hit.h | 3 | ||||
-rw-r--r-- | gtk2_ardour/canvas-note-event.h | 10 | ||||
-rw-r--r-- | gtk2_ardour/canvas-note.h | 7 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 47 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.h | 3 | ||||
-rw-r--r-- | gtk2_ardour/midi_streamview.cc | 134 | ||||
-rw-r--r-- | gtk2_ardour/midi_streamview.h | 3 | ||||
-rw-r--r-- | gtk2_ardour/midi_util.h | 6 | ||||
-rw-r--r-- | gtk2_ardour/streamview.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_region.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_source.h | 17 | ||||
-rw-r--r-- | libs/ardour/audiofilesource.cc | 2 | ||||
-rw-r--r-- | libs/ardour/midi_source.cc | 13 | ||||
-rw-r--r-- | libs/ardour/smf_source.cc | 13 | ||||
-rw-r--r-- | libs/evoral/evoral/SMF.hpp | 2 |
16 files changed, 151 insertions, 135 deletions
diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc index 85812b43d6..4ea7269f40 100644 --- a/gtk2_ardour/audio_streamview.cc +++ b/gtk2_ardour/audio_streamview.cc @@ -137,15 +137,16 @@ AudioStreamView::add_region_view_internal (boost::shared_ptr<Region> r, bool wai case Normal: if (recording) { region_view = new AudioRegionView (canvas_group, _trackview, region, - _samples_per_unit, region_color, recording, TimeAxisViewItem::Visibility(TimeAxisViewItem::ShowFrame | TimeAxisViewItem::HideFrameRight)); + _samples_per_unit, region_color, recording, TimeAxisViewItem::Visibility( + TimeAxisViewItem::ShowFrame | TimeAxisViewItem::HideFrameRight)); } else { region_view = new AudioRegionView (canvas_group, _trackview, region, - _samples_per_unit, region_color); + _samples_per_unit, region_color); } break; case Destructive: region_view = new TapeAudioRegionView (canvas_group, _trackview, region, - _samples_per_unit, region_color); + _samples_per_unit, region_color); break; default: fatal << string_compose (_("programming error: %1"), "illegal track mode in ::add_region_view_internal") << endmsg; @@ -379,16 +380,19 @@ AudioStreamView::redisplay_diskstream () } if (_trackview.is_audio_track()) { - _trackview.get_diskstream()->playlist()->foreach_region (static_cast<StreamView*>(this), &StreamView::add_region_view); + _trackview.get_diskstream()->playlist()->foreach_region( + static_cast<StreamView*>(this), + &StreamView::add_region_view); - boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist>(_trackview.get_diskstream()->playlist()); + boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist>( + _trackview.get_diskstream()->playlist()); if (apl) apl->foreach_crossfade (this, &AudioStreamView::add_crossfade); } RegionViewList copy; - /* Place regions */ + // Build a list of region views sorted by layer, and remove invalids for (i = region_views.begin(); i != region_views.end(); ) { tmp = i; tmp++; @@ -402,9 +406,6 @@ AudioStreamView::redisplay_diskstream () (*i)->enable_display(true); } - /* Sort regionviews by layer so that when we call region_layered () - the canvas layering works out (in non-stacked mode). */ - if (copy.size() == 0) { copy.push_front((*i)); i = tmp; @@ -447,8 +448,7 @@ AudioStreamView::redisplay_diskstream () xi = tmpx; } - /* now fix layering */ - + // Fix canvas layering by raising each in the sorted list order for (RegionViewList::iterator i = copy.begin(); i != copy.end(); ++i) { region_layered (*i); } diff --git a/gtk2_ardour/canvas-hit.h b/gtk2_ardour/canvas-hit.h index c4578b3530..a467952966 100644 --- a/gtk2_ardour/canvas-hit.h +++ b/gtk2_ardour/canvas-hit.h @@ -41,6 +41,9 @@ public: { } + void show() { Diamond::show(); } + void hide() { Diamond::hide(); } + double x1() { double x1, y1, x2, y2; get_bounds(x1,y1,x2,y2); return x1; } double y1() { double x1, y1, x2, y2; get_bounds(x1,y1,x2,y2); return y1; } double x2() { double x1, y1, x2, y2; get_bounds(x1,y1,x2,y2); return x2; } diff --git a/gtk2_ardour/canvas-note-event.h b/gtk2_ardour/canvas-note-event.h index 1f22a5b797..060e4d9fa9 100644 --- a/gtk2_ardour/canvas-note-event.h +++ b/gtk2_ardour/canvas-note-event.h @@ -59,6 +59,8 @@ public: virtual ~CanvasNoteEvent(); + virtual void show() = 0; + virtual void hide() = 0; virtual bool on_event(GdkEvent* ev); bool selected() const { return _selected; } @@ -71,10 +73,10 @@ public: void show_velocity(); void hide_velocity(); - /** - * This slot is called, when a new channel is selected for the single event - * */ + /** Channel changed for this specific event */ void on_channel_change(uint8_t channel); + + /** Channel selection changed */ void on_channel_selection_change(uint16_t selection); void show_channel_selector(); @@ -111,7 +113,7 @@ public: return UINT_INTERPOLATE(color, 0x000000ff, 0.5); } - /// dividing the hue circle in 16 parts, hand adjusted for equal look, courtesy Thorsten Wilms + /// hue circle divided into 16 equal-looking parts, courtesy Thorsten Wilms static const uint32_t midi_channel_colors[16]; protected: diff --git a/gtk2_ardour/canvas-note.h b/gtk2_ardour/canvas-note.h index 0f5d428ef1..46f4bbee35 100644 --- a/gtk2_ardour/canvas-note.h +++ b/gtk2_ardour/canvas-note.h @@ -41,6 +41,9 @@ public: void set_outline_color(uint32_t c) { property_outline_color_rgba() = c; hide(); show(); } void set_fill_color(uint32_t c) { property_fill_color_rgba() = c; hide(); show(); } + void show() { SimpleRect::show(); } + void hide() { SimpleRect::hide(); } + bool on_event(GdkEvent* ev); enum NoteEnd { @@ -58,16 +61,12 @@ public: MidiRegionView& region, Group& group, const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>()) - : SimpleRect(group), CanvasNoteEvent(region, this, note), _note_state(None) { } protected: NoteState _note_state; - -private: - }; } // namespace Gnome diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 8d688fa082..f8ea8a3e2e 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -482,7 +482,6 @@ void MidiRegionView::display_model(boost::shared_ptr<MidiModel> model) { _model = model; - if (_enable_display) { redisplay_model(); } @@ -549,8 +548,9 @@ void MidiRegionView::redisplay_model() { // Don't redisplay the model if we're currently recording and displaying that - if (_active_notes) + if (_active_notes) { return; + } if (_model) { clear_events(); @@ -754,7 +754,8 @@ MidiRegionView::apply_note_range (uint8_t min, uint8_t max, bool force) Item* item = dynamic_cast<Item*>(event); assert(item); if (event && event->note()) { - if (event->note()->note() < _current_range_min || event->note()->note() > _current_range_max) { + if (event->note()->note() < _current_range_min + || event->note()->note() > _current_range_max) { if (canvas_item_visible(item)) { item->hide(); } @@ -787,7 +788,6 @@ MidiRegionView::apply_note_range (uint8_t min, uint8_t max, bool force) } } } - } } @@ -917,6 +917,16 @@ MidiRegionView::play_midi_note_off(boost::shared_ptr<NoteType> note) return false; } +bool +MidiRegionView::note_in_visible_range(const boost::shared_ptr<NoteType> note) const +{ + const nframes64_t note_start_frames = beats_to_frames(note->time()); + bool outside = (note_start_frames - _region->start() >= _region->length()) + || (note_start_frames < _region->start()) + || (note->note() < midi_stream_view()->lowest_note()) + || (note->note() > midi_stream_view()->highest_note()); + return !outside; +} /** Add a MIDI note to the view (with length). * @@ -933,14 +943,6 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note) const nframes64_t note_start_frames = beats_to_frames(note->time()); const nframes64_t note_end_frames = beats_to_frames(note->end_time()); - // dont display notes beyond the region bounds - if (note_start_frames - _region->start() >= _region->length() || - note_start_frames < _region->start() || - note->note() < midi_stream_view()->lowest_note() || - note->note() > midi_stream_view()->highest_note() ) { - return; - } - ArdourCanvas::Group* const group = (ArdourCanvas::Group*)get_canvas_group(); CanvasNoteEvent* event = 0; @@ -955,14 +957,14 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note) CanvasNote* ev_rect = new CanvasNote(*this, *group, note); ev_rect->property_x1() = x; ev_rect->property_y1() = y1; - if (note->length() > 0) + if (note->length() > 0) { ev_rect->property_x2() = note_endpixel; - else + } else { ev_rect->property_x2() = trackview.editor().frame_to_pixel(_region->length()); + } ev_rect->property_y2() = y1 + floor(midi_stream_view()->note_height()); if (note->length() == 0) { - if (_active_notes) { assert(note->note() < 128); // If this note is already active there's a stuck note, @@ -985,12 +987,9 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note) ev_rect->property_outline_what() = (guint32) 0xF; } - ev_rect->show(); - _events.push_back(ev_rect); event = ev_rect; MidiGhostRegion* gr; - for (std::vector<GhostRegion*>::iterator g = ghosts.begin(); g != ghosts.end(); ++g) { if ((gr = dynamic_cast<MidiGhostRegion*>(*g)) != 0) { gr->add_note(ev_rect); @@ -1003,8 +1002,6 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note) CanvasHit* ev_diamond = new CanvasHit(*this, *group, diamond_size, note); ev_diamond->move(x, y); - ev_diamond->show(); - _events.push_back(ev_diamond); event = ev_diamond; } else { event = 0; @@ -1015,6 +1012,12 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note) note_selected(event, true); } event->on_channel_selection_change(_last_channel_selection); + _events.push_back(event); + if (note_in_visible_range(note)) { + event->show(); + } else { + event->hide(); + } } } @@ -1348,7 +1351,7 @@ MidiRegionView::note_dropped(CanvasNoteEvent* ev, double dt, uint8_t dnote) uint8_t new_pitch = original_pitch + dnote - highest_note_difference; // keep notes in standard midi range - clamp_0_to_127(new_pitch); + clamp_to_0_127(new_pitch); // keep original pitch if note is dragged outside valid midi range if ((original_pitch != 0 && new_pitch == 0) @@ -1556,7 +1559,7 @@ MidiRegionView::change_note_velocity(CanvasNoteEvent* event, int8_t velocity, bo if (relative) { uint8_t new_velocity = copy->velocity() + velocity; - clamp_0_to_127(new_velocity); + clamp_to_0_127(new_velocity); copy->set_velocity(new_velocity); } else { copy->set_velocity(velocity); diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 5c00175cbf..d6a7695997 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -177,6 +177,9 @@ class MidiRegionView : public RegionView void move_selection(double dx, double dy); void note_dropped(ArdourCanvas::CanvasNoteEvent* ev, double d_frames, uint8_t d_note); + /** Return true iff the note is within the currently visible range */ + bool note_in_visible_range(const boost::shared_ptr<NoteType> note) const; + /** Get the region position in pixels relative to session. */ double get_position_pixels(); diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc index 0d2abb04fd..178919a32c 100644 --- a/gtk2_ardour/midi_streamview.cc +++ b/gtk2_ardour/midi_streamview.cc @@ -24,28 +24,29 @@ #include <gtkmm2ext/gtk_ui.h> +#include <ardour/midi_diskstream.h> #include <ardour/midi_playlist.h> #include <ardour/midi_region.h> #include <ardour/midi_source.h> -#include <ardour/midi_diskstream.h> #include <ardour/midi_track.h> -#include <ardour/smf_source.h> #include <ardour/region_factory.h> +#include <ardour/smf_source.h> -#include "midi_streamview.h" -#include "region_view.h" +#include "ardour_ui.h" +#include "canvas-simplerect.h" +#include "gui_thread.h" +#include "lineset.h" #include "midi_region_view.h" +#include "midi_streamview.h" #include "midi_time_axis.h" -#include "canvas-simplerect.h" -#include "region_selection.h" -#include "selection.h" +#include "midi_util.h" #include "public_editor.h" -#include "ardour_ui.h" +#include "region_selection.h" +#include "region_view.h" #include "rgb_macros.h" -#include "gui_thread.h" -#include "utils.h" +#include "selection.h" #include "simplerect.h" -#include "lineset.h" +#include "utils.h" using namespace std; using namespace ARDOUR; @@ -62,10 +63,11 @@ MidiStreamView::MidiStreamView (MidiTimeAxisView& tv) , _data_note_min(60) , _data_note_max(71) { - if (tv.is_track()) + if (tv.is_track()) { stream_base_color = ARDOUR_UI::config()->canvasvar_MidiTrackBase.get(); - else + } else { stream_base_color = ARDOUR_UI::config()->canvasvar_MidiBusBase.get(); + } use_rec_regions = tv.editor().show_waveforms_recording (); @@ -82,7 +84,10 @@ MidiStreamView::MidiStreamView (MidiTimeAxisView& tv) _note_lines->property_x2() = trackview().editor().frame_to_pixel (max_frames); _note_lines->property_y2() = 0; - _note_lines->signal_event().connect (bind (mem_fun (_trackview.editor(), &PublicEditor::canvas_stream_view_event), _note_lines, &_trackview)); + _note_lines->signal_event().connect(bind( + mem_fun(_trackview.editor(), &PublicEditor::canvas_stream_view_event), + _note_lines, &_trackview)); + _note_lines->lower_to_bottom(); ColorsChanged.connect(mem_fun(*this, &MidiStreamView::draw_note_lines)); @@ -90,7 +95,8 @@ MidiStreamView::MidiStreamView (MidiTimeAxisView& tv) note_range_adjustment.set_page_size(_highest_note - _lowest_note); note_range_adjustment.set_value(_lowest_note); - note_range_adjustment.signal_value_changed().connect (mem_fun (*this, &MidiStreamView::note_range_adjustment_changed)); + note_range_adjustment.signal_value_changed().connect( + mem_fun(*this, &MidiStreamView::note_range_adjustment_changed)); } MidiStreamView::~MidiStreamView () @@ -101,10 +107,8 @@ static void veto_note_range(uint8_t& min, uint8_t& max) { /* Legal notes, thanks */ - if (max > 127) - max = 127; - if (min > 127) - min = 127; + clamp_to_0_127(min); + clamp_to_0_127(max); /* Always display at least one octave in [0, 127] */ if (max == 127) { @@ -172,7 +176,7 @@ MidiStreamView::display_region(MidiRegionView* region_view, bool load_model) { if ( ! region_view) return; - + region_view->enable_display(true); boost::shared_ptr<MidiSource> source(region_view->midi_region()->midi_source(0)); @@ -186,6 +190,7 @@ MidiStreamView::display_region(MidiRegionView* region_view, bool load_model) source->model()->highest_note()); // Display region contents + region_view->set_height(height); region_view->display_model(source->model()); } @@ -197,6 +202,18 @@ MidiStreamView::display_diskstream (boost::shared_ptr<Diskstream> ds) NoteRangeChanged(); } +void +MidiStreamView::update_contents_metrics(boost::shared_ptr<Region> r) +{ + boost::shared_ptr<MidiRegion> mr = boost::dynamic_pointer_cast<MidiRegion>(r); + if (mr) { + mr->midi_source(0)->load_model(); + _range_dirty = update_data_note_range( + mr->model()->lowest_note(), + mr->model()->highest_note()); + } +} + bool MidiStreamView::update_data_note_range(uint8_t min, uint8_t max) { @@ -212,29 +229,22 @@ MidiStreamView::update_data_note_range(uint8_t min, uint8_t max) return dirty; } -// FIXME: code duplication with AudioStreamView void MidiStreamView::redisplay_diskstream () { - list<RegionView *>::iterator i, tmp; + if (!_trackview.is_midi_track()) { + return; + } + + list<RegionView*>::iterator i, tmp; + // Load models if necessary, and find note range of all our contents _range_dirty = false; _data_note_min = 127; _data_note_max = 0; - - for (i = region_views.begin(); i != region_views.end(); ++i) { - (*i)->set_valid (false); - (*i)->enable_display (false); - - // Load model if it isn't already, to get note range - MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*i); - if (mrv) { - mrv->midi_region()->midi_source(0)->load_model(); - _range_dirty = update_data_note_range( - mrv->midi_region()->model()->lowest_note(), - mrv->midi_region()->model()->highest_note()); - } - } + _trackview.get_diskstream()->playlist()->foreach_region( + static_cast<StreamView*>(this), + &StreamView::update_contents_metrics); // No notes, use default range if (!_range_dirty) { @@ -242,28 +252,25 @@ MidiStreamView::redisplay_diskstream () _data_note_max = 71; } - bool range_changed = false; - // Extend visible range to show newly recorded data, if necessary - if (_data_note_min < _lowest_note) { - _lowest_note = _data_note_min; - range_changed = true; - } - if (_data_note_max > _highest_note) { - _highest_note = _data_note_max; - range_changed = true; - } + _lowest_note = std::min(_lowest_note, _data_note_min); + _highest_note = std::max(_highest_note, _data_note_max); veto_note_range(_lowest_note, _highest_note); - if (_trackview.is_midi_track()) { - _trackview.get_diskstream()->playlist()->foreach_region ( - static_cast<StreamView*>(this), &StreamView::add_region_view); + // Flag region views as invalid and disable drawing + for (i = region_views.begin(); i != region_views.end(); ++i) { + (*i)->set_valid(false); + (*i)->enable_display(false); } + // Add and display region views, and flag existing ones as valid + _trackview.get_diskstream()->playlist()->foreach_region( + static_cast<StreamView*>(this), + &StreamView::add_region_view); + + // Build a list of region views sorted by layer, and remove invalids RegionViewList copy; - - /* Place regions */ for (i = region_views.begin(); i != region_views.end(); ) { tmp = i; tmp++; @@ -273,14 +280,8 @@ MidiStreamView::redisplay_diskstream () region_views.erase (i); i = tmp; continue; - } else { - (*i)->enable_display(true); - (*i)->set_height(height); // apply note range } - /* Sort regionviews by layer so that when we call region_layered () - the canvas layering works out (in non-stacked mode). */ - if (copy.size() == 0) { copy.push_front((*i)); i = tmp; @@ -311,14 +312,13 @@ MidiStreamView::redisplay_diskstream () i = tmp; } - /* Fix canvas layering */ + // Fix canvas layering by raising each in the sorted list order for (RegionViewList::iterator j = copy.begin(); j != copy.end(); ++j) { region_layered (*j); } - /* Update note range and re-draw note lines if necessary */ - apply_note_range(_lowest_note, _highest_note); - NoteRangeChanged(); + // Update note range (not to regions which are already good) and draw note lines + apply_note_range(_lowest_note, _highest_note, false); } @@ -378,11 +378,11 @@ MidiStreamView::set_note_range(VisibleNoteRange r) _highest_note = _data_note_max; } - apply_note_range(_lowest_note, _highest_note); + apply_note_range(_lowest_note, _highest_note, true); } void -MidiStreamView::apply_note_range(uint8_t lowest, uint8_t highest) +MidiStreamView::apply_note_range(uint8_t lowest, uint8_t highest, bool to_region_views) { _highest_note = highest; _lowest_note = lowest; @@ -390,8 +390,10 @@ MidiStreamView::apply_note_range(uint8_t lowest, uint8_t highest) note_range_adjustment.set_value(_lowest_note); draw_note_lines(); - for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) { - ((MidiRegionView*)(*i))->apply_note_range(lowest, highest); + if (to_region_views) { + for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) { + ((MidiRegionView*)(*i))->apply_note_range(lowest, highest); + } } NoteRangeChanged(); @@ -716,6 +718,6 @@ MidiStreamView::note_range_adjustment_changed() _lowest_note = lowest; _highest_note = highest; - apply_note_range(lowest, highest); + apply_note_range(lowest, highest, true); } diff --git a/gtk2_ardour/midi_streamview.h b/gtk2_ardour/midi_streamview.h index c06af28cd4..2f8e63ab9d 100644 --- a/gtk2_ardour/midi_streamview.h +++ b/gtk2_ardour/midi_streamview.h @@ -121,8 +121,9 @@ class MidiStreamView : public StreamView void update_contents_height (); void draw_note_lines(); - void apply_note_range(uint8_t lowest, uint8_t highest); + void apply_note_range(uint8_t lowest, uint8_t highest, bool to_region_views); bool update_data_note_range(uint8_t min, uint8_t max); + void update_contents_metrics(boost::shared_ptr<ARDOUR::Region> r); void color_handler (); diff --git a/gtk2_ardour/midi_util.h b/gtk2_ardour/midi_util.h index 5b2a7702d8..0dedbc14ce 100644 --- a/gtk2_ardour/midi_util.h +++ b/gtk2_ardour/midi_util.h @@ -20,11 +20,11 @@ #ifndef __gtk_ardour_midi_util_h__ #define __gtk_ardour_midi_util_h__ -inline static void clamp_0_to_127(uint8_t &val) +inline static void clamp_to_0_127(uint8_t &val) { - if( (127 < val) && (val < 192) ) { + if ((127 < val) && (val < 192)) { val = 127; - } else if( (192 <= val) && (val < 255) ) { + } else if ((192 <= val) && (val < 255)) { val = 0; } } diff --git a/gtk2_ardour/streamview.h b/gtk2_ardour/streamview.h index 68498f30eb..932e919cee 100644 --- a/gtk2_ardour/streamview.h +++ b/gtk2_ardour/streamview.h @@ -93,6 +93,7 @@ public: void get_selectables (nframes_t start, nframes_t end, list<Selectable* >&); void get_inverted_selectables (Selection&, list<Selectable* >& results); + virtual void update_contents_metrics(boost::shared_ptr<ARDOUR::Region> r) {} void add_region_view (boost::shared_ptr<ARDOUR::Region>); void region_layered (RegionView*); virtual void update_contents_height (); diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h index 356e418fc1..00c71ab6ee 100644 --- a/libs/ardour/ardour/midi_region.h +++ b/libs/ardour/ardour/midi_region.h @@ -27,10 +27,11 @@ #include <pbd/undo.h> #include <ardour/ardour.h> -#include <ardour/region.h> #include <ardour/gain.h> #include <ardour/logcurve.h> +#include <ardour/midi_model.h> #include <ardour/midi_source.h> +#include <ardour/region.h> class XMLNode; diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h index f5c660d9cb..9e01881186 100644 --- a/libs/ardour/ardour/midi_source.h +++ b/libs/ardour/ardour/midi_source.h @@ -21,24 +21,21 @@ #define __ardour_midi_source_h__ #include <string> - #include <time.h> - -#include <glibmm/thread.h> - #include <sigc++/signal.h> - -#include <ardour/source.h> -#include <ardour/ardour.h> -#include <ardour/buffer.h> -#include <ardour/midi_model.h> +#include <glibmm/thread.h> #include <pbd/stateful.h> #include <pbd/xml++.h> +#include <evoral/Sequence.hpp> +#include <ardour/ardour.h> +#include <ardour/buffer.h> +#include <ardour/source.h> using std::string; namespace ARDOUR { +class MidiModel; template<typename T> class MidiRingBuffer; /** Source for MIDI data */ @@ -93,7 +90,7 @@ class MidiSource : public Source virtual void load_model(bool lock=true, bool force_reload=false) = 0; virtual void destroy_model() = 0; - void set_note_mode(NoteMode mode) { if (_model) _model->set_note_mode(mode); } + void set_note_mode(NoteMode mode); boost::shared_ptr<MidiModel> model() { return _model; } void set_model(boost::shared_ptr<MidiModel> m) { _model = m; } diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index 0064fd0b8e..9ac63c21fb 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -403,7 +403,7 @@ AudioFileSource::move_to_trash (const ustring& trash_dir_name) if (::rename (_path.c_str(), newpath.c_str()) != 0) { PBD::error << string_compose ( - _("cannot rename midi file source from %1 to %2 (%3)"), + _("cannot rename audio file source from %1 to %2 (%3)"), _path, newpath, strerror (errno)) << endmsg; return -1; } diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc index e5b1d813c5..70abb99e56 100644 --- a/libs/ardour/midi_source.cc +++ b/libs/ardour/midi_source.cc @@ -33,6 +33,7 @@ #include <pbd/basename.h> #include <ardour/audioengine.h> +#include <ardour/midi_model.h> #include <ardour/midi_ring_buffer.h> #include <ardour/midi_source.h> #include <ardour/session.h> @@ -51,9 +52,7 @@ sigc::signal<void,MidiSource *> MidiSource::MidiSourceCreated; MidiSource::MidiSource (Session& s, string name) : Source (s, name, DataType::MIDI) , _timeline_position(0) - , _model(new MidiModel(this)) , _writing (false) - , _model_iter(*_model.get(), 0.0) , _last_read_end(0) { _read_data_count = 0; @@ -63,9 +62,7 @@ MidiSource::MidiSource (Session& s, string name) MidiSource::MidiSource (Session& s, const XMLNode& node) : Source (s, node) , _timeline_position(0) - , _model(new MidiModel(this)) , _writing (false) - , _model_iter(*_model.get(), 0.0) , _last_read_end(0) { _read_data_count = 0; @@ -237,3 +234,11 @@ MidiSource::session_saved() } } +void +MidiSource::set_note_mode(NoteMode mode) +{ + if (_model) { + _model->set_note_mode(mode); + } +} + diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index 7072cc8634..bcf4aecae0 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -35,12 +35,13 @@ #include <evoral/SMFReader.hpp> #include <evoral/Control.hpp> -#include <ardour/smf_source.h> -#include <ardour/session.h> -#include <ardour/midi_ring_buffer.h> -#include <ardour/tempo.h> #include <ardour/audioengine.h> #include <ardour/event_type_map.h> +#include <ardour/midi_model.h> +#include <ardour/midi_ring_buffer.h> +#include <ardour/session.h> +#include <ardour/smf_source.h> +#include <ardour/tempo.h> #include "i18n.h" @@ -167,7 +168,7 @@ SMFSource::read_unlocked (MidiRingBuffer<nframes_t>& dst, nframes_t start, nfram _last_read_end = start + dur; - while (!Evoral::SMF::eof()) { + while (true) { ret = read_event(&ev_delta_t, &ev_size, &ev_buffer); if (ret == -1) { // EOF break; @@ -623,7 +624,7 @@ SMFSource::load_model(bool lock, bool force_reload) Glib::Mutex::Lock lm (_lock); } - if (_model && !force_reload && !_model->empty()) { + if (_model && !force_reload) { return; } diff --git a/libs/evoral/evoral/SMF.hpp b/libs/evoral/evoral/SMF.hpp index 73d56e5eaa..0be2a4b8a7 100644 --- a/libs/evoral/evoral/SMF.hpp +++ b/libs/evoral/evoral/SMF.hpp @@ -57,7 +57,6 @@ public: uint16_t num_tracks() const; uint16_t ppqn() const; bool is_empty() const { return _empty; } - bool eof() const { assert(false); return true; } void begin_write(); void append_event_delta(uint32_t delta_t, uint32_t size, const uint8_t* buf); @@ -69,7 +68,6 @@ private: std::string _path; smf_t* _smf; smf_track_t* _smf_track; - bool _empty; ///< true iff file contains(non-empty) events }; |