Scale MIDI track vertical range to match widgest range of notes in child regions.

Fiddled with canvas theme a bit to make tempo more visible and probably annoy pure audio MIDI/tempo haters.
Fix track-specific-color display on mixer strips for MIDI tracks.


git-svn-id: svn://localhost/ardour2/trunk@2112 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2007-07-05 07:02:24 +00:00
parent 0c3944f7dd
commit cfe29a14ee
8 changed files with 86 additions and 24 deletions

View File

@ -3,12 +3,12 @@
<Canvas>
<Option name="waveform" value="000000cc"/>
<Option name="clipped waveform" value="ff0000e5"/>
<Option name="region base" value="bfbfc1aa"/>
<Option name="selected region base" value="b591a8ff"/>
<Option name="audio track base" value="c6d3d868"/>
<Option name="audio bus base" value="dbd1ea68"/>
<Option name="midi track base" value="ff8f8f3d"/>
<Option name="midi bus base" value="ff0000ee"/>
<Option name="region base" value="bfbfc172"/>
<Option name="selected region base" value="b591a8d0"/>
<Option name="audio track base" value="b6c3cb88"/>
<Option name="audio bus base" value="cbc1de78"/>
<Option name="midi track base" value="ffd0d850"/>
<Option name="midi bus base" value="ffceea40"/>
<Option name="time-stretch-fill" value="e2b5b596"/>
<Option name="time-stretch-outline" value="63636396"/>
<Option name="automation line" value="44bc59ff"/>
@ -60,8 +60,8 @@
<Option name="EnteredMarker" value="dd6363ff"/>
<Option name="MeterMarker" value="f2425bff"/>
<Option name="TempoMarker" value="f2425bff"/>
<Option name="MeasureLineBeat" value="72727266"/>
<Option name="MeasureLineBar" value="8c8c988c"/>
<Option name="MeasureLineBeat" value="82828276"/>
<Option name="MeasureLineBar" value="9c9ca89c"/>
<Option name="GhostTrackBase" value="44007c7f"/>
<Option name="GhostTrackWave" value="02fd004c"/>
<Option name="GhostTrackWaveClip" value="ff000000"/>

View File

@ -32,6 +32,7 @@
#include "streamview.h"
#include "midi_region_view.h"
#include "midi_streamview.h"
#include "midi_time_axis.h"
#include "simplerect.h"
#include "simpleline.h"
@ -158,7 +159,7 @@ void
MidiRegionView::set_y_position_and_height (double y, double h)
{
RegionView::set_y_position_and_height(y, h - 1);
display_events();
if (name_text) {
@ -223,10 +224,17 @@ MidiRegionView::add_event (const MidiEvent& ev)
}
printf("\n\n");*/
double y1 = trackview.height / 2.0;
MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
MidiStreamView* const view = mtv->midi_view();
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;
if ((ev.buffer[0] & 0xF0) == MIDI_CMD_NOTE_ON) {
const Byte& note = ev.buffer[1];
y1 = trackview.height - ((trackview.height / 127.0) * note);
const double y1 = trackview.height - (pixel_range * (note - view->lowest_note() + 1))
- footer_height - 3.0;
ArdourCanvas::SimpleRect * ev_rect = new Gnome::Canvas::SimpleRect(
*(ArdourCanvas::Group*)get_canvas_group());
@ -235,7 +243,7 @@ MidiRegionView::add_event (const MidiEvent& ev)
ev_rect->property_y1() = y1;
ev_rect->property_x2() = trackview.editor.frame_to_pixel (
_region->length());
ev_rect->property_y2() = y1 + ceil(trackview.height / 127.0);
ev_rect->property_y2() = y1 + ceil(pixel_range);
ev_rect->property_outline_color_rgba() = 0xFFFFFFAA;
/* outline all but right edge */
ev_rect->property_outline_what() = (guint32) (0x1 & 0x4 & 0x8);

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2001, 2006 Paul Davis
Copyright (C) 2001-2007 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -29,6 +29,7 @@
#include <ardour/midi_source.h>
#include <ardour/midi_diskstream.h>
#include <ardour/midi_track.h>
#include <ardour/midi_events.h>
#include <ardour/smf_source.h>
#include <ardour/region_factory.h>
@ -53,6 +54,8 @@ using namespace Editing;
MidiStreamView::MidiStreamView (MidiTimeAxisView& tv)
: StreamView (tv)
, _lowest_note(0)
, _highest_note(127)
{
if (tv.is_track())
stream_base_color = ARDOUR_UI::config()->canvasvar_MidiTrackBase.get();
@ -89,6 +92,8 @@ MidiStreamView::add_region_view_internal (boost::shared_ptr<Region> r, bool wait
/* great. we already have a MidiRegionView for this Region. use it again. */
(*i)->set_valid (true);
display_region(dynamic_cast<MidiRegionView*>(*i), false);
return NULL;
}
}
@ -107,11 +112,11 @@ MidiStreamView::add_region_view_internal (boost::shared_ptr<Region> r, bool wait
// FIXME
//region_view->set_waveform_visible(_trackview.editor.show_waveforms());
/* display events */
region_view->begin_write();
for (size_t i=0; i < region->midi_source(0)->model()->n_events(); ++i)
region_view->add_event(region->midi_source(0)->model()->event_at(i));
region_view->end_write();
/* display events and find note range */
display_region(region_view, false);
/* always display at least 1 octave range */
_highest_note = max(_highest_note, static_cast<uint8_t>(_lowest_note + 11));
/* catch regionview going away */
region->GoingAway.connect (bind (mem_fun (*this, &MidiStreamView::remove_region_view), region));
@ -121,7 +126,35 @@ MidiStreamView::add_region_view_internal (boost::shared_ptr<Region> r, bool wait
return region_view;
}
// FIXME: code duplication with AudioStreamVIew
void
MidiStreamView::display_region(MidiRegionView* region_view, bool redisplay_events)
{
if ( ! region_view)
return;
if (redisplay_events)
region_view->begin_write();
boost::shared_ptr<MidiSource> source(region_view->midi_region()->midi_source(0));
for (size_t i=0; i < source->model()->n_events(); ++i) {
const MidiEvent& ev = source->model()->event_at(i);
// Look at all note on events to find our note range
if ((ev.buffer[0] & 0xF0) == MIDI_CMD_NOTE_ON) {
_lowest_note = min(_lowest_note, ev.buffer[1]);
_highest_note = max(_highest_note, ev.buffer[1]);
}
if (redisplay_events)
region_view->add_event(ev);
}
if (redisplay_events)
region_view->end_write();
}
// FIXME: code duplication with AudioStreamView
void
MidiStreamView::redisplay_diskstream ()
{
@ -130,11 +163,14 @@ MidiStreamView::redisplay_diskstream ()
for (i = region_views.begin(); i != region_views.end(); ++i) {
(*i)->set_valid (false);
}
_lowest_note = 60; // middle C
_highest_note = _lowest_note + 11;
if (_trackview.is_midi_track()) {
_trackview.get_diskstream()->playlist()->foreach_region (static_cast<StreamView*>(this), &StreamView::add_region_view);
}
for (i = region_views.begin(); i != region_views.end(); ) {
tmp = i;
tmp++;
@ -142,7 +178,9 @@ MidiStreamView::redisplay_diskstream ()
if (!(*i)->is_valid()) {
delete *i;
region_views.erase (i);
}
} else {
(*i)->set_y_position_and_height(0, height); // apply note range
}
i = tmp;
}

View File

@ -58,16 +58,23 @@ class MidiStreamView : public StreamView
void get_selectables (jack_nframes_t start, jack_nframes_t end, list<Selectable* >&);
void get_inverted_selectables (Selection&, list<Selectable* >& results);
uint8_t lowest_note() const { return _lowest_note; }
uint8_t highest_note() const { return _highest_note; }
private:
void setup_rec_box ();
void rec_data_range_ready (boost::shared_ptr<ARDOUR::MidiBuffer> data, jack_nframes_t start, jack_nframes_t dur, boost::weak_ptr<ARDOUR::Source> src);
void update_rec_regions (boost::shared_ptr<ARDOUR::MidiBuffer> data, jack_nframes_t start, jack_nframes_t dur);
RegionView* add_region_view_internal (boost::shared_ptr<ARDOUR::Region>, bool wait_for_waves);
void display_region(MidiRegionView* region_view, bool redisplay_events);
void redisplay_diskstream ();
void color_handler ();
uint8_t _lowest_note;
uint8_t _highest_note;
};
#endif /* __ardour_midi_streamview_h__ */

View File

@ -128,6 +128,12 @@ MidiTimeAxisView::~MidiTimeAxisView ()
{
}
MidiStreamView*
MidiTimeAxisView::midi_view()
{
return dynamic_cast<MidiStreamView*>(_view);
}
guint32
MidiTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
{

View File

@ -49,6 +49,7 @@ namespace ARDOUR {
}
class PublicEditor;
class MidiStreamView;
class MidiTimeAxisView : public RouteTimeAxisView
{
@ -56,6 +57,8 @@ class MidiTimeAxisView : public RouteTimeAxisView
MidiTimeAxisView (PublicEditor&, ARDOUR::Session&, boost::shared_ptr<ARDOUR::Route>, ArdourCanvas::Canvas& canvas);
virtual ~MidiTimeAxisView ();
MidiStreamView* midi_view();
/* overridden from parent to store display state */
guint32 show_at (double y, int& nth, Gtk::VBox *parent);
void hide ();

View File

@ -669,7 +669,7 @@ MixerStrip::add_bundle_to_output_menu (ARDOUR::Bundle* c)
void
MixerStrip::update_diskstream_display ()
{
if (is_audio_track()) {
if (is_track()) {
map_frozen ();

View File

@ -91,7 +91,7 @@ TimeAxisViewItem::TimeAxisViewItem(const string & it_name, ArdourCanvas::Group&
layout->set_font_description (*NAME_FONT);
Gtkmm2ext::get_ink_pixel_size (layout, width, height);
NAME_Y_OFFSET = height + 6;
NAME_Y_OFFSET = height + 5;
NAME_HIGHLIGHT_SIZE = height + 6;
NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 2;
@ -683,7 +683,7 @@ TimeAxisViewItem::compute_colors(Gdk::Color& base_color)
r = base_color.get_red()/256 ;
g = base_color.get_green()/256 ;
b = base_color.get_blue()/256 ;
fill_color = RGBA_TO_UINT(r,g,b,255) ;
fill_color = RGBA_TO_UINT(r,g,b,160) ;
/* for minor colors:
if the overall saturation is strong, make the minor colors light.