mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 08:36:32 +01:00
lower zoom step slightly, speed up autoscrolling when snapping to sub-beats (esp 32), make grid lines disappear when on coarse zoom, put grid lines in the idle thread (called from the idle thread.. interesting..), make current_bbt_points coarser so the bbt_ruler and grid lines can use it instead of making their own list, clean up bbt ruler.
git-svn-id: svn://localhost/ardour2/trunk@905 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
cb17e3cc81
commit
e513d106d7
9 changed files with 176 additions and 159 deletions
|
|
@ -966,7 +966,6 @@ Editor::canvas_horizontally_scrolled ()
|
||||||
{
|
{
|
||||||
|
|
||||||
Glib::signal_idle().connect (mem_fun(*this, &Editor::lazy_canvas_horizontally_scrolled));
|
Glib::signal_idle().connect (mem_fun(*this, &Editor::lazy_canvas_horizontally_scrolled));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
@ -996,7 +995,7 @@ Editor::deferred_reposition_and_zoom (jack_nframes_t frame, double nfpu)
|
||||||
|
|
||||||
set_frames_per_unit (nfpu);
|
set_frames_per_unit (nfpu);
|
||||||
reposition_x_origin (frame);
|
reposition_x_origin (frame);
|
||||||
|
tempo_map_changed (Change (0));
|
||||||
repos_zoom_queued = false;
|
repos_zoom_queued = false;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
||||||
|
|
@ -684,6 +684,7 @@ class Editor : public PublicEditor
|
||||||
void tie_vertical_scrolling ();
|
void tie_vertical_scrolling ();
|
||||||
void canvas_horizontally_scrolled ();
|
void canvas_horizontally_scrolled ();
|
||||||
bool lazy_canvas_horizontally_scrolled ();
|
bool lazy_canvas_horizontally_scrolled ();
|
||||||
|
|
||||||
void reposition_and_zoom (jack_nframes_t sample, double fpu);
|
void reposition_and_zoom (jack_nframes_t sample, double fpu);
|
||||||
gint deferred_reposition_and_zoom (jack_nframes_t sample, double fpu);
|
gint deferred_reposition_and_zoom (jack_nframes_t sample, double fpu);
|
||||||
void end_location_changed (ARDOUR::Location*);
|
void end_location_changed (ARDOUR::Location*);
|
||||||
|
|
@ -1185,8 +1186,6 @@ class Editor : public PublicEditor
|
||||||
bool _follow_playhead;
|
bool _follow_playhead;
|
||||||
bool _show_waveforms_recording;
|
bool _show_waveforms_recording;
|
||||||
|
|
||||||
void add_bbt_marks (ARDOUR::TempoMap::BBTPointList&);
|
|
||||||
|
|
||||||
ARDOUR::TempoMap::BBTPointList *current_bbt_points;
|
ARDOUR::TempoMap::BBTPointList *current_bbt_points;
|
||||||
|
|
||||||
typedef vector<ArdourCanvas::SimpleLine*> TimeLineList;
|
typedef vector<ArdourCanvas::SimpleLine*> TimeLineList;
|
||||||
|
|
@ -1196,8 +1195,7 @@ class Editor : public PublicEditor
|
||||||
ArdourCanvas::Group* time_line_group;
|
ArdourCanvas::Group* time_line_group;
|
||||||
ArdourCanvas::SimpleLine* get_time_line ();
|
ArdourCanvas::SimpleLine* get_time_line ();
|
||||||
void hide_measures ();
|
void hide_measures ();
|
||||||
void draw_measures ();
|
bool draw_measures ();
|
||||||
void draw_time_bars ();
|
|
||||||
|
|
||||||
void new_tempo_section ();
|
void new_tempo_section ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1110,9 +1110,9 @@ Editor::temporal_zoom_step (bool coarser)
|
||||||
nfpu = frames_per_unit;
|
nfpu = frames_per_unit;
|
||||||
|
|
||||||
if (coarser) {
|
if (coarser) {
|
||||||
nfpu *= 2.0;
|
nfpu *= 1.61803399;
|
||||||
} else {
|
} else {
|
||||||
nfpu = max(1.0,(nfpu/2.0));
|
nfpu = max(1.0,(nfpu/1.61803399));
|
||||||
}
|
}
|
||||||
|
|
||||||
temporal_zoom (nfpu);
|
temporal_zoom (nfpu);
|
||||||
|
|
@ -1251,22 +1251,22 @@ Editor::temporal_zoom_to_frame (bool coarser, jack_nframes_t frame)
|
||||||
{
|
{
|
||||||
if (!session) return;
|
if (!session) return;
|
||||||
|
|
||||||
jack_nframes_t range_before = frame - leftmost_frame;
|
double range_before = frame - leftmost_frame;
|
||||||
double new_fpu;
|
double new_fpu;
|
||||||
|
|
||||||
new_fpu = frames_per_unit;
|
new_fpu = frames_per_unit;
|
||||||
|
|
||||||
if (coarser) {
|
if (coarser) {
|
||||||
new_fpu *= 2.0;
|
new_fpu *= 1.61803399;
|
||||||
range_before *= 2;
|
range_before *= 1.61803399;
|
||||||
} else {
|
} else {
|
||||||
new_fpu = max(1.0,(new_fpu/2.0));
|
new_fpu = max(1.0,(new_fpu/1.61803399));
|
||||||
range_before /= 2;
|
range_before /= 1.61803399;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_fpu == frames_per_unit) return;
|
if (new_fpu == frames_per_unit) return;
|
||||||
|
|
||||||
jack_nframes_t new_leftmost = frame - range_before;
|
jack_nframes_t new_leftmost = frame - (jack_nframes_t)range_before;
|
||||||
|
|
||||||
if (new_leftmost > frame) new_leftmost = 0;
|
if (new_leftmost > frame) new_leftmost = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1034,114 +1034,87 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble upper
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TempoMap::BBTPointList::iterator i;
|
TempoMap::BBTPointList::iterator i;
|
||||||
TempoMap::BBTPointList *zoomed_bbt_points;
|
|
||||||
uint32_t beats = 0;
|
uint32_t beats = 0;
|
||||||
uint32_t bars = 0;
|
uint32_t bars = 0;
|
||||||
uint32_t tick = 0;
|
|
||||||
uint32_t skip;
|
|
||||||
uint32_t t;
|
|
||||||
uint32_t zoomed_beats = 0;
|
|
||||||
uint32_t zoomed_bars = 0;
|
|
||||||
uint32_t desirable_marks;
|
uint32_t desirable_marks;
|
||||||
uint32_t magic_accent_number = 1;
|
uint32_t magic_accent_number = 1;
|
||||||
gint nmarks;
|
gint nmarks;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
gint n;
|
gint n;
|
||||||
jack_nframes_t pos;
|
jack_nframes_t pos;
|
||||||
jack_nframes_t frame_one_beats_worth;
|
bool bar_helper_on = true;
|
||||||
jack_nframes_t frame_skip;
|
|
||||||
double frame_skip_error;
|
|
||||||
double accumulated_error;
|
|
||||||
bool bar_helper_on = true;
|
|
||||||
|
|
||||||
|
|
||||||
BBT_Time previous_beat;
|
|
||||||
BBT_Time next_beat;
|
BBT_Time next_beat;
|
||||||
jack_nframes_t next_beat_pos;
|
jack_nframes_t next_beat_pos;
|
||||||
jack_nframes_t ilower = (jack_nframes_t) floor (lower);
|
jack_nframes_t ilower = (jack_nframes_t) floor (lower);
|
||||||
jack_nframes_t iupper = (jack_nframes_t) floor (upper);
|
|
||||||
|
|
||||||
if ((desirable_marks = maxchars / 6) == 0) {
|
if ((desirable_marks = maxchars / 7) == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* align the tick marks to whatever we're snapping to... */
|
/* align the tick marks to whatever we're snapping to... */
|
||||||
|
|
||||||
if (snap_type == SnapToAThirdBeat) {
|
switch (snap_type) {
|
||||||
|
case SnapToAThirdBeat:
|
||||||
bbt_beat_subdivision = 3;
|
bbt_beat_subdivision = 3;
|
||||||
} else if (snap_type == SnapToAQuarterBeat) {
|
break;
|
||||||
|
case SnapToAQuarterBeat:
|
||||||
bbt_beat_subdivision = 4;
|
bbt_beat_subdivision = 4;
|
||||||
} else if (snap_type == SnapToAEighthBeat) {
|
break;
|
||||||
|
case SnapToAEighthBeat:
|
||||||
bbt_beat_subdivision = 8;
|
bbt_beat_subdivision = 8;
|
||||||
magic_accent_number = 2;
|
magic_accent_number = 2;
|
||||||
} else if (snap_type == SnapToASixteenthBeat) {
|
break;
|
||||||
|
case SnapToASixteenthBeat:
|
||||||
bbt_beat_subdivision = 16;
|
bbt_beat_subdivision = 16;
|
||||||
magic_accent_number = 4;
|
magic_accent_number = 4;
|
||||||
} else if (snap_type == SnapToAThirtysecondBeat) {
|
break;
|
||||||
|
case SnapToAThirtysecondBeat:
|
||||||
bbt_beat_subdivision = 32;
|
bbt_beat_subdivision = 32;
|
||||||
magic_accent_number = 8;
|
magic_accent_number = 8;
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
bbt_beat_subdivision = 4;
|
bbt_beat_subdivision = 4;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* First find what a beat's distance is, so we can start plotting stuff before the beginning of the ruler */
|
if (current_bbt_points == 0 || current_bbt_points->empty()) {
|
||||||
|
|
||||||
session->bbt_time(ilower,previous_beat);
|
|
||||||
previous_beat.ticks = 0;
|
|
||||||
next_beat = previous_beat;
|
|
||||||
|
|
||||||
if (session->tempo_map().meter_at(ilower).beats_per_bar() < (next_beat.beats + 1)) {
|
|
||||||
next_beat.bars += 1;
|
|
||||||
next_beat.beats = 1;
|
|
||||||
} else {
|
|
||||||
next_beat.beats += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame_one_beats_worth = session->tempo_map().frame_time(next_beat) - session->tempo_map().frame_time(previous_beat);
|
|
||||||
|
|
||||||
|
|
||||||
zoomed_bbt_points = session->tempo_map().get_points((ilower >= frame_one_beats_worth) ? ilower - frame_one_beats_worth : 0, iupper);
|
|
||||||
|
|
||||||
if (current_bbt_points == 0 || zoomed_bbt_points == 0 || zoomed_bbt_points->empty()) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = current_bbt_points->begin(); i != current_bbt_points->end(); i++) {
|
i = current_bbt_points->end();
|
||||||
if ((*i).type == TempoMap::Beat) {
|
i--;
|
||||||
beats++;
|
bars = (*i).bar - (*current_bbt_points->begin()).bar;
|
||||||
} else if ((*i).type == TempoMap::Bar) {
|
beats = current_bbt_points->size() - bars;
|
||||||
bars++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*Only show the bar helper if there aren't many bars on the screen */
|
/*Only show the bar helper if there aren't many bars on the screen */
|
||||||
if (bars > 1) {
|
if (bars > 2) {
|
||||||
bar_helper_on = false;
|
bar_helper_on = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = zoomed_bbt_points->begin(); i != zoomed_bbt_points->end(); i++) {
|
|
||||||
if ((*i).type == TempoMap::Beat) {
|
|
||||||
zoomed_beats++;
|
|
||||||
} else if ((*i).type == TempoMap::Bar) {
|
|
||||||
zoomed_bars++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (desirable_marks > (beats / 4)) {
|
if (desirable_marks > (beats / 4)) {
|
||||||
|
|
||||||
/* we're in beat land...*/
|
/* we're in beat land...*/
|
||||||
|
|
||||||
|
uint32_t tick = 0;
|
||||||
|
uint32_t skip;
|
||||||
|
uint32_t t;
|
||||||
|
jack_nframes_t frame_skip;
|
||||||
|
double frame_skip_error;
|
||||||
|
double accumulated_error;
|
||||||
double position_of_helper;
|
double position_of_helper;
|
||||||
bool i_am_accented = false;
|
bool i_am_accented = false;
|
||||||
bool we_need_ticks = false;
|
bool we_need_ticks = false;
|
||||||
|
|
||||||
position_of_helper = ilower + (30 * Editor::get_current_zoom ());
|
position_of_helper = ilower + (30 * Editor::get_current_zoom ());
|
||||||
|
|
||||||
if (desirable_marks >= (beats * 2)) {
|
if (desirable_marks >= (beats / 2)) {
|
||||||
nmarks = (zoomed_beats * bbt_beat_subdivision) + 1;
|
nmarks = ((beats + 4) * bbt_beat_subdivision) + 1;
|
||||||
we_need_ticks = true;
|
we_need_ticks = true;
|
||||||
} else {
|
} else {
|
||||||
nmarks = zoomed_beats + 1;
|
nmarks = beats + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
|
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
|
||||||
|
|
@ -1150,17 +1123,14 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble upper
|
||||||
(*marks)[0].position = ilower;
|
(*marks)[0].position = ilower;
|
||||||
(*marks)[0].style = GtkCustomRulerMarkMicro;
|
(*marks)[0].style = GtkCustomRulerMarkMicro;
|
||||||
|
|
||||||
for (n = 1, i = zoomed_bbt_points->begin(); i != zoomed_bbt_points->end() && n < nmarks; ++i) {
|
for (n = 1, i = current_bbt_points->begin(); n < nmarks && i != current_bbt_points->end(); i++) {
|
||||||
|
|
||||||
if ((*i).frame <= ilower && (bar_helper_on)) {
|
if ((*i).frame < ilower && (bar_helper_on)) {
|
||||||
|
|
||||||
snprintf (buf, sizeof(buf), "<%" PRIu32 "|%" PRIu32, (*i).bar, (*i).beat);
|
snprintf (buf, sizeof(buf), "<%" PRIu32 "|%" PRIu32, (*i).bar, (*i).beat);
|
||||||
(*marks)[0].label = g_strdup (buf);
|
(*marks)[0].label = g_strdup (buf);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
if ((*i).type == TempoMap::Bar) {
|
if ((*i).type == TempoMap::Bar) {
|
||||||
tick = 0;
|
|
||||||
(((*i).frame < position_of_helper) && bar_helper_on) ?
|
(((*i).frame < position_of_helper) && bar_helper_on) ?
|
||||||
snprintf (buf, sizeof(buf), " ") : snprintf (buf, sizeof(buf), "%" PRIu32, (*i).bar);
|
snprintf (buf, sizeof(buf), " ") : snprintf (buf, sizeof(buf), "%" PRIu32, (*i).bar);
|
||||||
(*marks)[n].label = g_strdup (buf);
|
(*marks)[n].label = g_strdup (buf);
|
||||||
|
|
@ -1169,7 +1139,6 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble upper
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
} else if (((*i).type == TempoMap::Beat) && ((*i).beat > 1)) {
|
} else if (((*i).type == TempoMap::Beat) && ((*i).beat > 1)) {
|
||||||
tick = 0;
|
|
||||||
((((*i).frame < position_of_helper) && bar_helper_on) || !we_need_ticks) ?
|
((((*i).frame < position_of_helper) && bar_helper_on) || !we_need_ticks) ?
|
||||||
snprintf (buf, sizeof(buf), " ") : snprintf (buf, sizeof(buf), "%" PRIu32, (*i).beat);
|
snprintf (buf, sizeof(buf), " ") : snprintf (buf, sizeof(buf), "%" PRIu32, (*i).beat);
|
||||||
if (((*i).beat % 2 == 1) || we_need_ticks) {
|
if (((*i).beat % 2 == 1) || we_need_ticks) {
|
||||||
|
|
@ -1183,33 +1152,36 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble upper
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/* Find the next beat */
|
|
||||||
|
|
||||||
session->bbt_time((*i).frame, next_beat);
|
|
||||||
|
|
||||||
if (session->tempo_map().meter_at((*i).frame).beats_per_bar() > (next_beat.beats + 1)) {
|
|
||||||
next_beat.beats += 1;
|
|
||||||
} else {
|
|
||||||
next_beat.bars += 1;
|
|
||||||
next_beat.beats = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
next_beat_pos = session->tempo_map().frame_time(next_beat);
|
|
||||||
|
|
||||||
/* Add the tick marks */
|
/* Add the tick marks */
|
||||||
|
|
||||||
if (we_need_ticks) {
|
if (we_need_ticks) {
|
||||||
|
|
||||||
frame_skip = (jack_nframes_t) floor ((session->frame_rate() * 60) / (bbt_beat_subdivision * (*i).tempo->beats_per_minute()));
|
/* Find the next beat */
|
||||||
frame_skip_error = ((session->frame_rate() * 60.0f) / (bbt_beat_subdivision * (*i).tempo->beats_per_minute())) - frame_skip;
|
|
||||||
|
next_beat.beats = (*i).beat;
|
||||||
|
next_beat.bars = (*i).bar;
|
||||||
|
|
||||||
|
if ((*i).meter->beats_per_bar() > (next_beat.beats + 1)) {
|
||||||
|
next_beat.beats += 1;
|
||||||
|
} else {
|
||||||
|
next_beat.bars += 1;
|
||||||
|
next_beat.beats = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
next_beat_pos = session->tempo_map().frame_time(next_beat);
|
||||||
|
|
||||||
|
frame_skip = (jack_nframes_t) floor (frame_skip_error = (session->frame_rate() * 60) / (bbt_beat_subdivision * (*i).tempo->beats_per_minute()));
|
||||||
|
frame_skip_error -= frame_skip;
|
||||||
skip = (uint32_t) (Meter::ticks_per_beat / bbt_beat_subdivision);
|
skip = (uint32_t) (Meter::ticks_per_beat / bbt_beat_subdivision);
|
||||||
|
|
||||||
pos = (*i).frame + frame_skip;
|
pos = (*i).frame + frame_skip;
|
||||||
accumulated_error = frame_skip_error;
|
accumulated_error = frame_skip_error;
|
||||||
|
|
||||||
tick += skip;
|
tick = skip;
|
||||||
|
|
||||||
for (t = 0; tick < Meter::ticks_per_beat && pos <= next_beat_pos ; pos += frame_skip, tick += skip, ++t) {
|
for (t = 0; (tick < Meter::ticks_per_beat) && (n < nmarks) && (pos < next_beat_pos) ; pos += frame_skip, tick += skip, ++t) {
|
||||||
|
|
||||||
if (t % magic_accent_number == (magic_accent_number - 1)) {
|
if (t % magic_accent_number == (magic_accent_number - 1)) {
|
||||||
i_am_accented = true;
|
i_am_accented = true;
|
||||||
|
|
@ -1246,23 +1218,22 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble upper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete zoomed_bbt_points;
|
|
||||||
return n; //return the actual number of marks made, since we might have skipped some fro fractional time signatures
|
return n; //return the actual number of marks made, since we might have skipped some fro fractional time signatures
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* we're in bar land */
|
/* we're in bar land */
|
||||||
|
|
||||||
if (desirable_marks < (uint32_t) (zoomed_bars / 256)) {
|
if (desirable_marks < (uint32_t) (bars / 256)) {
|
||||||
nmarks = 1;
|
nmarks = 1;
|
||||||
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
|
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
|
||||||
snprintf (buf, sizeof(buf), "too many bars... (currently %" PRIu32 ")", zoomed_bars );
|
snprintf (buf, sizeof(buf), "too many bars... (currently %" PRIu32 ")", bars );
|
||||||
(*marks)[0].style = GtkCustomRulerMarkMajor;
|
(*marks)[0].style = GtkCustomRulerMarkMajor;
|
||||||
(*marks)[0].label = g_strdup (buf);
|
(*marks)[0].label = g_strdup (buf);
|
||||||
(*marks)[0].position = ilower;
|
(*marks)[0].position = ilower;
|
||||||
} else if (desirable_marks < (uint32_t) (nmarks = (gint) (zoomed_bars / 64))) {
|
} else if (desirable_marks < (uint32_t) (nmarks = (gint) (bars / 64))) {
|
||||||
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
|
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
|
||||||
for (n = 0, i = zoomed_bbt_points->begin(); i != zoomed_bbt_points->end() && n < nmarks; i++) {
|
for (n = 0, i = current_bbt_points->begin(); i != current_bbt_points->end() && n < nmarks; i++) {
|
||||||
if ((*i).type == TempoMap::Bar) {
|
if ((*i).type == TempoMap::Bar) {
|
||||||
if ((*i).bar % 64 == 1) {
|
if ((*i).bar % 64 == 1) {
|
||||||
if ((*i).bar % 256 == 1) {
|
if ((*i).bar % 256 == 1) {
|
||||||
|
|
@ -1282,9 +1253,9 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble upper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (desirable_marks < (uint32_t) (nmarks = (gint)(zoomed_bars / 16))) {
|
} else if (desirable_marks < (uint32_t) (nmarks = (gint)(bars / 16))) {
|
||||||
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
|
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
|
||||||
for (n = 0, i = zoomed_bbt_points->begin(); i != zoomed_bbt_points->end() && n < nmarks; i++) {
|
for (n = 0, i = current_bbt_points->begin(); i != current_bbt_points->end() && n < nmarks; i++) {
|
||||||
if ((*i).type == TempoMap::Bar) {
|
if ((*i).type == TempoMap::Bar) {
|
||||||
if ((*i).bar % 16 == 1) {
|
if ((*i).bar % 16 == 1) {
|
||||||
if ((*i).bar % 64 == 1) {
|
if ((*i).bar % 64 == 1) {
|
||||||
|
|
@ -1304,9 +1275,9 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble upper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (desirable_marks < (uint32_t) (nmarks = (gint)(zoomed_bars / 4))){
|
} else if (desirable_marks < (uint32_t) (nmarks = (gint)(bars / 4))){
|
||||||
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
|
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
|
||||||
for (n = 0, i = zoomed_bbt_points->begin(); i != zoomed_bbt_points->end() && n < nmarks; ++i) {
|
for (n = 0, i = current_bbt_points->begin(); i != current_bbt_points->end() && n < nmarks; ++i) {
|
||||||
if ((*i).type == TempoMap::Bar) {
|
if ((*i).type == TempoMap::Bar) {
|
||||||
if ((*i).bar % 4 == 1) {
|
if ((*i).bar % 4 == 1) {
|
||||||
if ((*i).bar % 16 == 1) {
|
if ((*i).bar % 16 == 1) {
|
||||||
|
|
@ -1327,9 +1298,9 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble upper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nmarks = zoomed_bars;
|
nmarks = bars;
|
||||||
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
|
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
|
||||||
for (n = 0, i = zoomed_bbt_points->begin(); i != zoomed_bbt_points->end() && n < nmarks; i++) {
|
for (n = 0, i = current_bbt_points->begin(); i != current_bbt_points->end() && n < nmarks; i++) {
|
||||||
if ((*i).type == TempoMap::Bar) {
|
if ((*i).type == TempoMap::Bar) {
|
||||||
if ((*i).bar % 4 == 1) {
|
if ((*i).bar % 4 == 1) {
|
||||||
snprintf (buf, sizeof(buf), "%" PRIu32, (*i).bar);
|
snprintf (buf, sizeof(buf), "%" PRIu32, (*i).bar);
|
||||||
|
|
@ -1348,7 +1319,6 @@ Editor::metric_get_bbt (GtkCustomRulerMark **marks, gdouble lower, gdouble upper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete zoomed_bbt_points;
|
|
||||||
return nmarks;
|
return nmarks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,14 +96,47 @@ void
|
||||||
Editor::tempo_map_changed (Change ignored)
|
Editor::tempo_map_changed (Change ignored)
|
||||||
{
|
{
|
||||||
ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::tempo_map_changed), ignored));
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::tempo_map_changed), ignored));
|
||||||
|
|
||||||
|
BBT_Time previous_beat, next_beat; // the beats previous to the leftmost frame and after the rightmost frame
|
||||||
|
|
||||||
|
session->bbt_time(leftmost_frame, previous_beat);
|
||||||
|
|
||||||
|
previous_beat.ticks = 0;
|
||||||
|
if (previous_beat.beats > 1) {
|
||||||
|
previous_beat.beats -= 1;
|
||||||
|
} else if (previous_beat.bars > 1) {
|
||||||
|
previous_beat.bars--;
|
||||||
|
previous_beat.beats += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
session->bbt_time(leftmost_frame + current_page_frames(), next_beat);
|
||||||
|
|
||||||
|
if (session->tempo_map().meter_at(leftmost_frame + current_page_frames()).beats_per_bar () > next_beat.beats + 1) {
|
||||||
|
next_beat.beats += 1;
|
||||||
|
next_beat.ticks = 0;
|
||||||
|
} else {
|
||||||
|
next_beat.bars += 1;
|
||||||
|
next_beat.beats = 1;
|
||||||
|
next_beat.ticks = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (current_bbt_points) {
|
if (current_bbt_points) {
|
||||||
delete current_bbt_points;
|
delete current_bbt_points;
|
||||||
current_bbt_points = 0;
|
current_bbt_points = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session) {
|
if (session) {
|
||||||
current_bbt_points = session->tempo_map().get_points (leftmost_frame, leftmost_frame + current_page_frames());
|
current_bbt_points = session->tempo_map().get_points (session->tempo_map().frame_time (previous_beat), session->tempo_map().frame_time (next_beat));
|
||||||
|
|
||||||
|
/*
|
||||||
|
TempoMap::BBTPointList::iterator i;
|
||||||
|
cerr << "******************" << endl << "current bbt points dump: " << endl;
|
||||||
|
for (i = current_bbt_points->begin(); i != current_bbt_points->end(); i++) {
|
||||||
|
cerr << (*i).bar << " : " << (*i).beat << endl;
|
||||||
|
}
|
||||||
|
cerr << "******************" << endl;
|
||||||
|
*/
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
current_bbt_points = 0;
|
current_bbt_points = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -114,10 +147,11 @@ Editor::tempo_map_changed (Change ignored)
|
||||||
void
|
void
|
||||||
Editor::redisplay_tempo ()
|
Editor::redisplay_tempo ()
|
||||||
{
|
{
|
||||||
|
|
||||||
hide_measures ();
|
hide_measures ();
|
||||||
|
|
||||||
if (session && current_bbt_points) {
|
if (session && current_bbt_points) {
|
||||||
draw_measures ();
|
Glib::signal_idle().connect (mem_fun (*this, &Editor::draw_measures));
|
||||||
update_tempo_based_rulers ();
|
update_tempo_based_rulers ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,22 +183,21 @@ Editor::get_time_line ()
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
Editor::draw_measures ()
|
Editor::draw_measures ()
|
||||||
{
|
{
|
||||||
if (session == 0 || _show_measures == false) {
|
if (session == 0 || _show_measures == false) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TempoMap::BBTPointList::iterator i = current_bbt_points->begin();
|
TempoMap::BBTPointList::iterator i;
|
||||||
TempoMap::BBTPoint& p = (*i);
|
|
||||||
ArdourCanvas::SimpleLine *line;
|
ArdourCanvas::SimpleLine *line;
|
||||||
gdouble xpos, last_xpos;
|
gdouble xpos, last_xpos;
|
||||||
uint32_t cnt;
|
uint32_t cnt;
|
||||||
uint32_t color;
|
uint32_t color;
|
||||||
|
|
||||||
if (current_bbt_points == 0 || current_bbt_points->empty()) {
|
if (current_bbt_points == 0 || current_bbt_points->empty()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
|
|
@ -176,7 +209,7 @@ Editor::draw_measures ()
|
||||||
gdouble beat_spacing = 0;
|
gdouble beat_spacing = 0;
|
||||||
|
|
||||||
for (i = current_bbt_points->begin(); i != current_bbt_points->end() && beat_spacing == 0; ++i) {
|
for (i = current_bbt_points->begin(); i != current_bbt_points->end() && beat_spacing == 0; ++i) {
|
||||||
TempoMap::BBTPoint& p = (*i);
|
TempoMap::BBTPoint& p = (*i);
|
||||||
|
|
||||||
switch (p.type) {
|
switch (p.type) {
|
||||||
case TempoMap::Bar:
|
case TempoMap::Bar:
|
||||||
|
|
@ -191,13 +224,20 @@ Editor::draw_measures ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (beat_spacing < 12.0) {
|
||||||
|
/*
|
||||||
|
if the lines are too close together,
|
||||||
|
they become useless
|
||||||
|
*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
double x1, x2, y1, y2;
|
double x1, x2, y1, y2;
|
||||||
track_canvas.get_scroll_region (x1, y1, x2, y2);
|
track_canvas.get_scroll_region (x1, y1, x2, y2);
|
||||||
//y2 = 1000000000.0f;
|
|
||||||
|
|
||||||
for (i = current_bbt_points->begin(); i != current_bbt_points->end(); ++i) {
|
for (i = current_bbt_points->begin(); i != current_bbt_points->end(); ++i) {
|
||||||
|
|
||||||
p = (*i);
|
TempoMap::BBTPoint& p = (*i);
|
||||||
|
|
||||||
switch (p.type) {
|
switch (p.type) {
|
||||||
case TempoMap::Bar:
|
case TempoMap::Bar:
|
||||||
|
|
@ -239,6 +279,7 @@ Editor::draw_measures ()
|
||||||
|
|
||||||
cursor_group->raise_to_top();
|
cursor_group->raise_to_top();
|
||||||
time_line_group->lower_to_bottom();
|
time_line_group->lower_to_bottom();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -118,21 +118,6 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
|
||||||
|
|
||||||
hide_button.add (*(manage (new Image (get_xpm("small_x.xpm")))));
|
hide_button.add (*(manage (new Image (get_xpm("small_x.xpm")))));
|
||||||
|
|
||||||
/* XXX is this incomplete? i don't think its very useful atm
|
|
||||||
|
|
||||||
solo_button->signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false);
|
|
||||||
mute_button->signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false);
|
|
||||||
playlist_button.signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false);
|
|
||||||
automation_button.signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false);
|
|
||||||
size_button.signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false);
|
|
||||||
visual_button.signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false);
|
|
||||||
hide_button.signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false);
|
|
||||||
*/
|
|
||||||
|
|
||||||
solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
|
|
||||||
solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
|
|
||||||
mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
|
|
||||||
mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
|
|
||||||
edit_group_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::edit_click), false);
|
edit_group_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::edit_click), false);
|
||||||
playlist_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::playlist_click));
|
playlist_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::playlist_click));
|
||||||
automation_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::automation_click));
|
automation_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::automation_click));
|
||||||
|
|
@ -200,6 +185,7 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
|
||||||
_route->name_changed.connect (mem_fun(*this, &RouteTimeAxisView::route_name_changed));
|
_route->name_changed.connect (mem_fun(*this, &RouteTimeAxisView::route_name_changed));
|
||||||
_route->solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
|
_route->solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
|
||||||
|
|
||||||
|
|
||||||
if (is_track()) {
|
if (is_track()) {
|
||||||
|
|
||||||
track()->FreezeChange.connect (mem_fun(*this, &RouteTimeAxisView::map_frozen));
|
track()->FreezeChange.connect (mem_fun(*this, &RouteTimeAxisView::map_frozen));
|
||||||
|
|
@ -218,6 +204,7 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
|
||||||
|
|
||||||
editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
|
editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
|
||||||
ColorChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler));
|
ColorChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RouteTimeAxisView::~RouteTimeAxisView ()
|
RouteTimeAxisView::~RouteTimeAxisView ()
|
||||||
|
|
@ -608,19 +595,19 @@ RouteTimeAxisView::set_height (TrackHeight h)
|
||||||
show_name_entry ();
|
show_name_entry ();
|
||||||
hide_name_label ();
|
hide_name_label ();
|
||||||
|
|
||||||
mute_button->show_all();
|
mute_button->show();
|
||||||
solo_button->show_all();
|
solo_button->show();
|
||||||
if (rec_enable_button)
|
if (rec_enable_button)
|
||||||
rec_enable_button->show_all();
|
rec_enable_button->show();
|
||||||
|
|
||||||
edit_group_button.show_all();
|
edit_group_button.show();
|
||||||
hide_button.show_all();
|
hide_button.show();
|
||||||
visual_button.show_all();
|
visual_button.show();
|
||||||
size_button.show_all();
|
size_button.show();
|
||||||
automation_button.show_all();
|
automation_button.show();
|
||||||
|
|
||||||
if (is_track() && track()->mode() == ARDOUR::Normal) {
|
if (is_track() && track()->mode() == ARDOUR::Normal) {
|
||||||
playlist_button.show_all();
|
playlist_button.show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -628,10 +615,10 @@ RouteTimeAxisView::set_height (TrackHeight h)
|
||||||
show_name_entry ();
|
show_name_entry ();
|
||||||
hide_name_label ();
|
hide_name_label ();
|
||||||
|
|
||||||
mute_button->show_all();
|
mute_button->show();
|
||||||
solo_button->show_all();
|
solo_button->show();
|
||||||
if (rec_enable_button)
|
if (rec_enable_button)
|
||||||
rec_enable_button->show_all();
|
rec_enable_button->show();
|
||||||
|
|
||||||
edit_group_button.hide ();
|
edit_group_button.hide ();
|
||||||
hide_button.hide ();
|
hide_button.hide ();
|
||||||
|
|
@ -1196,13 +1183,6 @@ RouteTimeAxisView::color_handler (ColorID id, uint32_t val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
RouteTimeAxisView::select_me (GdkEventButton* ev)
|
|
||||||
{
|
|
||||||
editor.get_selection().add (this);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
RouteTimeAxisView::show_all_automation ()
|
RouteTimeAxisView::show_all_automation ()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -214,8 +214,7 @@ protected:
|
||||||
void map_frozen ();
|
void map_frozen ();
|
||||||
|
|
||||||
void color_handler (ColorID, uint32_t);
|
void color_handler (ColorID, uint32_t);
|
||||||
bool select_me (GdkEventButton*);
|
|
||||||
|
|
||||||
void region_view_added (RegionView*);
|
void region_view_added (RegionView*);
|
||||||
void add_ghost_to_redirect (RegionView*, AutomationTimeAxisView*);
|
void add_ghost_to_redirect (RegionView*, AutomationTimeAxisView*);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,10 +84,10 @@ RouteUI::RouteUI (boost::shared_ptr<ARDOUR::Route> rt, ARDOUR::Session& sess, co
|
||||||
|
|
||||||
update_rec_display ();
|
update_rec_display ();
|
||||||
}
|
}
|
||||||
|
|
||||||
mute_button->unset_flags (Gtk::CAN_FOCUS);
|
mute_button->unset_flags (Gtk::CAN_FOCUS);
|
||||||
solo_button->unset_flags (Gtk::CAN_FOCUS);
|
solo_button->unset_flags (Gtk::CAN_FOCUS);
|
||||||
|
|
||||||
/* map the current state */
|
/* map the current state */
|
||||||
|
|
||||||
map_frozen ();
|
map_frozen ();
|
||||||
|
|
|
||||||
|
|
@ -919,6 +919,33 @@ jack_nframes_t
|
||||||
|
|
||||||
TempoMap::round_to_beat_subdivision (jack_nframes_t fr, int sub_num)
|
TempoMap::round_to_beat_subdivision (jack_nframes_t fr, int sub_num)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
BBT_Time the_beat;
|
||||||
|
uint32_t ticks_one_half_subdivisions_worth;
|
||||||
|
uint32_t ticks_one_subdivisions_worth;
|
||||||
|
|
||||||
|
bbt_time(fr, the_beat);
|
||||||
|
|
||||||
|
ticks_one_subdivisions_worth = (uint32_t)Meter::ticks_per_beat / sub_num;
|
||||||
|
ticks_one_half_subdivisions_worth = ticks_one_subdivisions_worth / 2;
|
||||||
|
|
||||||
|
if (the_beat.ticks % ticks_one_subdivisions_worth > ticks_one_half_subdivisions_worth) {
|
||||||
|
uint32_t difference = ticks_one_subdivisions_worth - (the_beat.ticks % ticks_one_subdivisions_worth);
|
||||||
|
if (the_beat.ticks + difference >= (uint32_t)Meter::ticks_per_beat) {
|
||||||
|
the_beat.beats++;
|
||||||
|
the_beat.ticks += difference;
|
||||||
|
the_beat.ticks -= (uint32_t)Meter::ticks_per_beat;
|
||||||
|
} else {
|
||||||
|
the_beat.ticks += difference;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
the_beat.ticks -= the_beat.ticks % ticks_one_subdivisions_worth;
|
||||||
|
}
|
||||||
|
|
||||||
|
return frame_time (the_beat);
|
||||||
|
|
||||||
|
/* XXX just keeping this for reference
|
||||||
|
|
||||||
TempoMap::BBTPointList::iterator i;
|
TempoMap::BBTPointList::iterator i;
|
||||||
TempoMap::BBTPointList *more_zoomed_bbt_points;
|
TempoMap::BBTPointList *more_zoomed_bbt_points;
|
||||||
jack_nframes_t frame_one_beats_worth;
|
jack_nframes_t frame_one_beats_worth;
|
||||||
|
|
@ -970,6 +997,9 @@ TempoMap::round_to_beat_subdivision (jack_nframes_t fr, int sub_num)
|
||||||
|
|
||||||
delete more_zoomed_bbt_points;
|
delete more_zoomed_bbt_points;
|
||||||
return fr ;
|
return fr ;
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jack_nframes_t
|
jack_nframes_t
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue