diff options
author | David Robillard <d@drobilla.net> | 2007-07-28 09:01:19 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-07-28 09:01:19 +0000 |
commit | 633d9131af0a04bed812ce75e9f1da07fe7dfcd4 (patch) | |
tree | 989f907ffa7a8c4829160946e49f503c4e3a903c | |
parent | 6e167cb1a835cb0b44990cc4c2b2a47db9dd2b9e (diff) |
Use 'show contents' note range by default (fix uninitialized value).
Obey note mode on playback (note offs are not sent in Percussive mode).
Vary note colour/opacity with velocity (needs theization/tweaking, but hey, it's something).
git-svn-id: svn://localhost/ardour2/trunk@2184 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 14 | ||||
-rw-r--r-- | gtk2_ardour/midi_streamview.cc | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_playlist.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_region.h | 9 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_source.h | 1 | ||||
-rw-r--r-- | libs/ardour/midi_diskstream.cc | 1 | ||||
-rw-r--r-- | libs/ardour/midi_playlist.cc | 8 | ||||
-rw-r--r-- | libs/ardour/midi_region.cc | 12 |
8 files changed, 34 insertions, 16 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 0c2efec35a..77c297f422 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -410,6 +410,10 @@ MidiRegionView::add_note (const MidiModel::Note& note) const uint8_t note_range = view->highest_note() - view->lowest_note() + 1; const double footer_height = name_highlight->property_y2() - name_highlight->property_y1(); const double pixel_range = (trackview.height - footer_height - 5.0) / (double)note_range; + const uint8_t fill_alpha = 0x20 + (uint8_t)(note.velocity() * 1.5); + const uint32_t fill = RGBA_TO_UINT(0xE0 + note.velocity()/127.0 * 0x10, 0xE0, 0xE0, fill_alpha); + const uint8_t outline_alpha = 0x80 + (uint8_t)(note.velocity()); + const uint32_t outline = RGBA_TO_UINT(0xE0 + note.velocity()/127.0 * 0x10, 0xE0, 0xE0, outline_alpha); if (mtv->note_mode() == Sustained) { const double y1 = trackview.height - (pixel_range * (note.note() - view->lowest_note() + 1)) @@ -418,11 +422,11 @@ MidiRegionView::add_note (const MidiModel::Note& note) ArdourCanvas::SimpleRect * ev_rect = new Gnome::Canvas::SimpleRect(*group); ev_rect->property_x1() = trackview.editor.frame_to_pixel((nframes_t)note.time()); ev_rect->property_y1() = y1; - ev_rect->property_x2() = trackview.editor.frame_to_pixel((nframes_t)(note.time() + note.duration())); + ev_rect->property_x2() = trackview.editor.frame_to_pixel((nframes_t)(note.end_time())); ev_rect->property_y2() = y1 + ceil(pixel_range); - ev_rect->property_fill_color_rgba() = 0xFFFFFF66; - ev_rect->property_outline_color_rgba() = 0xFFFFFFAA; + ev_rect->property_fill_color_rgba() = fill; + ev_rect->property_outline_color_rgba() = outline; ev_rect->property_outline_what() = (guint32) 0xF; // all edges ev_rect->show(); @@ -436,8 +440,8 @@ MidiRegionView::add_note (const MidiModel::Note& note) Diamond* ev_diamond = new Diamond(*group, std::min(pixel_range, 5.0)); ev_diamond->move(x, y); ev_diamond->show(); - ev_diamond->property_outline_color_rgba() = 0xFFFFFFDD; - ev_diamond->property_fill_color_rgba() = 0xFFFFFF66; + ev_diamond->property_fill_color_rgba() = fill; + ev_diamond->property_outline_color_rgba() = outline; _events.push_back(ev_diamond); } } diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc index e602c3a880..7d3c05a876 100644 --- a/gtk2_ardour/midi_streamview.cc +++ b/gtk2_ardour/midi_streamview.cc @@ -54,6 +54,7 @@ using namespace Editing; MidiStreamView::MidiStreamView (MidiTimeAxisView& tv) : StreamView (tv) + , _range(ContentsRange) , _lowest_note(60) , _highest_note(60) { diff --git a/libs/ardour/ardour/midi_playlist.h b/libs/ardour/ardour/midi_playlist.h index 3162debbd5..5838f5addd 100644 --- a/libs/ardour/ardour/midi_playlist.h +++ b/libs/ardour/ardour/midi_playlist.h @@ -53,6 +53,8 @@ public: UndoAction get_memento() const; bool destroy_region (boost::shared_ptr<Region>); + + void set_note_mode (NoteMode m) { _note_mode = m; } protected: @@ -68,6 +70,8 @@ private: void dump () const; bool region_changed (Change, boost::shared_ptr<Region>); + + NoteMode _note_mode; }; } /* namespace ARDOUR */ diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h index 83487e456a..ade839ab3e 100644 --- a/libs/ardour/ardour/midi_region.h +++ b/libs/ardour/ardour/midi_region.h @@ -53,12 +53,14 @@ class MidiRegion : public Region nframes_t read_at (MidiRingBuffer& dst, nframes_t position, nframes_t dur, - uint32_t chan_n = 0) const; + uint32_t chan_n = 0, + NoteMode mode = Sustained) const; nframes_t master_read_at (MidiRingBuffer& dst, nframes_t position, nframes_t dur, - uint32_t chan_n=0) const; + uint32_t chan_n = 0, + NoteMode mode = Sustained) const; XMLNode& state (bool); int set_state (const XMLNode&); @@ -82,7 +84,8 @@ class MidiRegion : public Region nframes_t _read_at (const SourceList&, MidiRingBuffer& dst, nframes_t position, nframes_t dur, - uint32_t chan_n = 0) const; + uint32_t chan_n = 0, + NoteMode mode = Sustained) const; void recompute_at_start (); void recompute_at_end (); diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h index 5393f07157..9917a0cb42 100644 --- a/libs/ardour/ardour/midi_source.h +++ b/libs/ardour/ardour/midi_source.h @@ -74,6 +74,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); } virtual bool model_loaded() const { return _model_loaded; } MidiModel* model() { return _model; } diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index c5711a8295..74acae522a 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -312,6 +312,7 @@ void MidiDiskstream::set_note_mode (NoteMode m) { _note_mode = m; + midi_playlist()->set_note_mode(m); if (_write_source && _write_source->model()) _write_source->model()->set_note_mode(m); } diff --git a/libs/ardour/midi_playlist.cc b/libs/ardour/midi_playlist.cc index 0aa3779034..27410462d1 100644 --- a/libs/ardour/midi_playlist.cc +++ b/libs/ardour/midi_playlist.cc @@ -150,10 +150,12 @@ MidiPlaylist::read (MidiRingBuffer& dst, nframes_t start, sort(regs.begin(), regs.end(), layer_cmp); for (vector<boost::shared_ptr<Region> >::iterator i = regs.begin(); i != regs.end(); ++i) { - // FIXME: ensure time is monotonic here + // FIXME: ensure time is monotonic here? boost::shared_ptr<MidiRegion> mr = boost::dynamic_pointer_cast<MidiRegion>(*i); - mr->read_at (dst, start, dur, chan_n); - _read_data_count += mr->read_data_count(); + if (mr) { + mr->read_at (dst, start, dur, chan_n, _note_mode); + _read_data_count += mr->read_data_count(); + } } return dur; diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index 860d0ec672..1ef52c743d 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -110,19 +110,19 @@ MidiRegion::~MidiRegion () } nframes_t -MidiRegion::read_at (MidiRingBuffer& out, nframes_t position, nframes_t dur, uint32_t chan_n) const +MidiRegion::read_at (MidiRingBuffer& out, nframes_t position, nframes_t dur, uint32_t chan_n, NoteMode mode) const { - return _read_at (_sources, out, position, dur, chan_n); + return _read_at (_sources, out, position, dur, chan_n, mode); } nframes_t -MidiRegion::master_read_at (MidiRingBuffer& out, nframes_t position, nframes_t dur, uint32_t chan_n) const +MidiRegion::master_read_at (MidiRingBuffer& out, nframes_t position, nframes_t dur, uint32_t chan_n, NoteMode mode) const { - return _read_at (_master_sources, out, position, dur, chan_n); + return _read_at (_master_sources, out, position, dur, chan_n, mode); } nframes_t -MidiRegion::_read_at (const SourceList& srcs, MidiRingBuffer& dst, nframes_t position, nframes_t dur, uint32_t chan_n) const +MidiRegion::_read_at (const SourceList& srcs, MidiRingBuffer& dst, nframes_t position, nframes_t dur, uint32_t chan_n, NoteMode mode) const { // cerr << _name << "._read_at(" << position << ") - " << _position << endl; @@ -162,6 +162,8 @@ MidiRegion::_read_at (const SourceList& srcs, MidiRingBuffer& dst, nframes_t pos _read_data_count = 0; boost::shared_ptr<MidiSource> src = midi_source(chan_n); + src->set_note_mode(mode); + if (src->read (dst, _start + internal_offset, to_read, _position) != to_read) { return 0; /* "read nothing" */ } |