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
This commit is contained in:
David Robillard 2007-07-28 09:01:19 +00:00
parent 6e167cb1a8
commit 633d9131af
8 changed files with 34 additions and 16 deletions

View file

@ -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);
}
}

View file

@ -54,6 +54,7 @@ using namespace Editing;
MidiStreamView::MidiStreamView (MidiTimeAxisView& tv)
: StreamView (tv)
, _range(ContentsRange)
, _lowest_note(60)
, _highest_note(60)
{

View file

@ -54,6 +54,8 @@ public:
bool destroy_region (boost::shared_ptr<Region>);
void set_note_mode (NoteMode m) { _note_mode = m; }
protected:
/* playlist "callbacks" */
@ -68,6 +70,8 @@ private:
void dump () const;
bool region_changed (Change, boost::shared_ptr<Region>);
NoteMode _note_mode;
};
} /* namespace ARDOUR */

View file

@ -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 ();

View file

@ -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; }

View file

@ -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);
}

View file

@ -150,11 +150,13 @@ 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);
if (mr) {
mr->read_at (dst, start, dur, chan_n, _note_mode);
_read_data_count += mr->read_data_count();
}
}
return dur;
}

View file

@ -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" */
}