using namespace sigc;
using namespace ARDOUR;
+using namespace PBD;
using namespace Gtk;
using namespace Editing;
hide_verbose_canvas_cursor();
stop_canvas_autoscroll();
- jack_nframes_t where = leftmost_frame + pixel_to_frame (x);
+ nframes_t where = leftmost_frame + pixel_to_frame (x);
switch (ev->button) {
case 1:
if (session == 0 || !ruler_pressed_button) {
return FALSE;
}
-
+
double wcx=0,wcy=0;
double cx=0,cy=0;
track_canvas.c2w (x, y, wcx, wcy);
track_canvas.w2c (wcx, wcy, cx, cy);
- jack_nframes_t where = leftmost_frame + pixel_to_frame (x);
+ nframes_t where = leftmost_frame + pixel_to_frame (x);
- /// ripped from maybe_autoscroll
- jack_nframes_t one_page = (jack_nframes_t) rint (canvas_width * frames_per_unit);
- jack_nframes_t rightmost_frame = leftmost_frame + one_page;
- jack_nframes_t frame = pixel_to_frame (cx);
+ /// ripped from maybe_autoscroll, and adapted to work here
+ nframes_t one_page = (nframes_t) rint (canvas_width * frames_per_unit);
+ nframes_t rightmost_frame = leftmost_frame + one_page;
if (autoscroll_timeout_tag < 0) {
- if (frame > rightmost_frame) {
+ if (where > rightmost_frame) {
if (rightmost_frame < max_frames) {
start_canvas_autoscroll (1);
}
- } else if (frame < leftmost_frame) {
+ } else if (where <= leftmost_frame) {
if (leftmost_frame > 0) {
start_canvas_autoscroll (-1);
}
}
} else {
- if (frame >= leftmost_frame && frame < rightmost_frame) {
+ if (where >= leftmost_frame && where < rightmost_frame) {
stop_canvas_autoscroll ();
}
}
void
-Editor::popup_ruler_menu (jack_nframes_t where, ItemType t)
+Editor::popup_ruler_menu (nframes_t where, ItemType t)
{
using namespace Menu_Helpers;
an uint32_t (or larger) to a float ... what to do ?
*/
- jack_nframes_t page = (jack_nframes_t) floor (canvas_width * frames_per_unit);
- jack_nframes_t rightmost_frame = leftmost_frame + page;
+ nframes_t page = (nframes_t) floor (canvas_width * frames_per_unit);
+ nframes_t rightmost_frame = leftmost_frame + page;
if (ruler_shown[ruler_metric_smpte]) {
gtk_custom_ruler_set_range (GTK_CUSTOM_RULER(_smpte_ruler), leftmost_frame, rightmost_frame,
void
Editor::update_fixed_rulers ()
{
- jack_nframes_t rightmost_frame;
+ nframes_t rightmost_frame;
if (session == 0) {
return;
an uint32_t (or larger) to a float ... what to do ?
*/
- jack_nframes_t page = (jack_nframes_t) floor (canvas_width * frames_per_unit);
+ nframes_t page = (nframes_t) floor (canvas_width * frames_per_unit);
ruler_metrics[ruler_metric_smpte].units_per_pixel = frames_per_unit;
ruler_metrics[ruler_metric_frames].units_per_pixel = frames_per_unit;
an uint32_t (or larger) to a float ... what to do ?
*/
- jack_nframes_t page = (jack_nframes_t) floor (canvas_width * frames_per_unit);
+ nframes_t page = (nframes_t) floor (canvas_width * frames_per_unit);
ruler_metrics[ruler_metric_bbt].units_per_pixel = frames_per_unit;
if (ruler_shown[ruler_metric_bbt]) {
gint
Editor::metric_get_smpte (GtkCustomRulerMark **marks, gdouble lower, gdouble upper, gint maxchars)
{
- jack_nframes_t range;
- jack_nframes_t pos;
- jack_nframes_t spacer;
- jack_nframes_t fr;
- SMPTE_Time smpte;
+ nframes_t range;
+ nframes_t pos;
+ nframes_t spacer;
+ nframes_t fr;
+ SMPTE::Time smpte;
gchar buf[16];
gint nmarks = 0;
gint n;
fr = session->frame_rate();
- if (lower > (spacer = (jack_nframes_t)(128 * Editor::get_current_zoom ()))) {
+ if (lower > (spacer = (nframes_t)(128 * Editor::get_current_zoom ()))) {
lower = lower - spacer;
} else {
- upper = upper + spacer - lower;
lower = 0;
}
- range = (jack_nframes_t) floor (upper - lower);
+ upper = upper + spacer;
+ range = (nframes_t) floor (upper - lower);
if (range < (2 * session->frames_per_smpte_frame())) { /* 0 - 2 frames */
show_bits = true;
} else if (range <= (fr / 4)) { /* 2 frames - 0.250 second */
show_frames = true;
mark_modulo = 1;
- nmarks = 1 + (range / (jack_nframes_t)session->frames_per_smpte_frame());
+ nmarks = 1 + (range / (nframes_t)session->frames_per_smpte_frame());
} else if (range <= (fr / 2)) { /* 0.25-0.5 second */
show_frames = true;
mark_modulo = 2;
- nmarks = 1 + (range / (jack_nframes_t)session->frames_per_smpte_frame());
+ nmarks = 1 + (range / (nframes_t)session->frames_per_smpte_frame());
} else if (range <= fr) { /* 0.5-1 second */
show_frames = true;
mark_modulo = 5;
- nmarks = 1 + (range / (jack_nframes_t)session->frames_per_smpte_frame());
+ nmarks = 1 + (range / (nframes_t)session->frames_per_smpte_frame());
} else if (range <= 2 * fr) { /* 1-2 seconds */
show_frames = true;
mark_modulo = 10;
- nmarks = 1 + (range / (jack_nframes_t)session->frames_per_smpte_frame());
+ nmarks = 1 + (range / (nframes_t)session->frames_per_smpte_frame());
} else if (range <= 8 * fr) { /* 2-8 seconds */
show_seconds = true;
mark_modulo = 1;
nmarks = 1 + 24;
} else {
- /* not possible if jack_nframes_t is a 32 bit quantity */
+ /* not possible if nframes_t is a 32 bit quantity */
show_hours = true;
mark_modulo = 4;
nmarks = 1 + 24;
}
- pos = (jack_nframes_t) floor (lower);
+ pos = (nframes_t) floor (lower);
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
(*marks)[n].position = pos;
// Increment subframes by one
- session->smpte_increment_subframes( smpte );
+ SMPTE::increment_subframes( smpte );
}
} else if (show_seconds) {
// Find smpte time of this sample (pos)
session->sample_to_smpte(pos, smpte, true /* use_offset */, false /* use_subframes */ );
// Go to next whole second down
- session->smpte_seconds_floor( smpte );
+ SMPTE::seconds_floor( smpte );
for (n = 0; n < nmarks; n++) {
session->smpte_to_sample(smpte, pos, true /* use_offset */, false /* use_subframes */ );
}
(*marks)[n].label = g_strdup (buf);
- session->smpte_increment_seconds( smpte );
+ SMPTE::increment_seconds( smpte );
}
} else if (show_minutes) {
// Find smpte time of this sample (pos)
session->sample_to_smpte(pos, smpte, true /* use_offset */, false /* use_subframes */ );
// Go to next whole minute down
- session->smpte_minutes_floor( smpte );
+ SMPTE::minutes_floor( smpte );
for (n = 0; n < nmarks; n++) {
session->smpte_to_sample(smpte, pos, true /* use_offset */, false /* use_subframes */ );
}
(*marks)[n].label = g_strdup (buf);
(*marks)[n].position = pos;
- session->smpte_increment_minutes( smpte );
+ SMPTE::increment_minutes( smpte );
}
} else if (show_hours) {
// Find smpte time of this sample (pos)
session->sample_to_smpte(pos, smpte, true /* use_offset */, false /* use_subframes */ );
// Go to next whole hour down
- session->smpte_hours_floor( smpte );
+ SMPTE::hours_floor( smpte );
for (n = 0; n < nmarks; n++) {
session->smpte_to_sample(smpte, pos, true /* use_offset */, false /* use_subframes */ );
(*marks)[n].label = g_strdup (buf);
(*marks)[n].position = pos;
- session->smpte_increment_hours( smpte );
+ SMPTE::increment_hours( smpte );
}
} else { // show_frames
// Find smpte time of this sample (pos)
session->sample_to_smpte(pos, smpte, true /* use_offset */, false /* use_subframes */ );
// Go to next whole frame down
- session->smpte_frames_floor( smpte );
+ SMPTE::frames_floor( smpte );
for (n = 0; n < nmarks; n++) {
session->smpte_to_sample(smpte, pos, true /* use_offset */, false /* use_subframes */ );
}
(*marks)[n].label = g_strdup (buf);
- session->smpte_increment( smpte );
+ SMPTE::increment( smpte );
}
}
return 0;
}
- TempoMap::BBTPointList::iterator i;
- TempoMap::BBTPointList *zoomed_bbt_points;
+ TempoMap::BBTPointList::iterator i;
+
uint32_t beats = 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 magic_accent_number = 1;
gint nmarks;
char buf[64];
gint n;
- jack_nframes_t pos;
- jack_nframes_t frame_one_beats_worth;
- jack_nframes_t frame_skip;
- double frame_skip_error;
- double accumulated_error;
- bool bar_helper_on = true;
-
+ nframes_t pos;
+ bool bar_helper_on = true;
- BBT_Time previous_beat;
BBT_Time next_beat;
- jack_nframes_t next_beat_pos;
- jack_nframes_t ilower = (jack_nframes_t) floor (lower);
- jack_nframes_t iupper = (jack_nframes_t) floor (upper);
+ nframes_t next_beat_pos;
+ nframes_t ilower = (nframes_t) floor (lower);
- if ((desirable_marks = maxchars / 6) == 0) {
+ if ((desirable_marks = maxchars / 7) == 0) {
return 0;
}
/* align the tick marks to whatever we're snapping to... */
-
- if (snap_type == SnapToAThirdBeat) {
+
+ switch (snap_type) {
+ case SnapToAThirdBeat:
bbt_beat_subdivision = 3;
- } else if (snap_type == SnapToAQuarterBeat) {
+ break;
+ case SnapToAQuarterBeat:
bbt_beat_subdivision = 4;
- } else if (snap_type == SnapToAEighthBeat) {
+ break;
+ case SnapToAEighthBeat:
bbt_beat_subdivision = 8;
magic_accent_number = 2;
- } else if (snap_type == SnapToASixteenthBeat) {
+ break;
+ case SnapToASixteenthBeat:
bbt_beat_subdivision = 16;
magic_accent_number = 4;
- } else if (snap_type == SnapToAThirtysecondBeat) {
+ break;
+ case SnapToAThirtysecondBeat:
bbt_beat_subdivision = 32;
magic_accent_number = 8;
- } else {
+ break;
+ default:
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 */
-
- 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()) {
+ if (current_bbt_points == 0 || current_bbt_points->empty()) {
return 0;
}
- for (i = current_bbt_points->begin(); i != current_bbt_points->end(); i++) {
- if ((*i).type == TempoMap::Beat) {
- beats++;
- } else if ((*i).type == TempoMap::Bar) {
- bars++;
- }
- }
+ i = current_bbt_points->end();
+ i--;
+ bars = (*i).bar - (*current_bbt_points->begin()).bar;
+ beats = current_bbt_points->size() - bars;
+
/*Only show the bar helper if there aren't many bars on the screen */
- if (bars > 1) {
+ if (bars > 2) {
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)) {
/* we're in beat land...*/
+ uint32_t tick = 0;
+ uint32_t skip;
+ uint32_t t;
+ nframes_t frame_skip;
+ double frame_skip_error;
+ double accumulated_error;
double position_of_helper;
bool i_am_accented = false;
bool we_need_ticks = false;
position_of_helper = ilower + (30 * Editor::get_current_zoom ());
- if (desirable_marks >= (beats * 2)) {
- nmarks = (zoomed_beats * bbt_beat_subdivision) + 1;
+ if (desirable_marks >= (beats)) {
+ nmarks = ((beats + 1) * bbt_beat_subdivision) + 1;
we_need_ticks = true;
} else {
- nmarks = zoomed_beats + 1;
+ nmarks = beats + 1;
}
*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
(*marks)[0].position = ilower;
(*marks)[0].style = GtkCustomRulerMarkMicro;
- for (n = 1, i = zoomed_bbt_points->begin(); i != zoomed_bbt_points->end() && n < nmarks; ++i) {
-
- if ((*i).frame <= ilower && (bar_helper_on)) {
-
+ for (n = 1, i = current_bbt_points->begin(); n < nmarks && i != current_bbt_points->end(); i++) {
+
+ if ((*i).frame < ilower && (bar_helper_on)) {
snprintf (buf, sizeof(buf), "<%" PRIu32 "|%" PRIu32, (*i).bar, (*i).beat);
(*marks)[0].label = g_strdup (buf);
} else {
-
if ((*i).type == TempoMap::Bar) {
- tick = 0;
(((*i).frame < position_of_helper) && bar_helper_on) ?
snprintf (buf, sizeof(buf), " ") : snprintf (buf, sizeof(buf), "%" PRIu32, (*i).bar);
(*marks)[n].label = g_strdup (buf);
n++;
} else if (((*i).type == TempoMap::Beat) && ((*i).beat > 1)) {
- tick = 0;
((((*i).frame < position_of_helper) && bar_helper_on) || !we_need_ticks) ?
snprintf (buf, sizeof(buf), " ") : snprintf (buf, sizeof(buf), "%" PRIu32, (*i).beat);
if (((*i).beat % 2 == 1) || we_need_ticks) {
}
}
- /* 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 */
- if (we_need_ticks) {
+ if (we_need_ticks && (*i).type != TempoMap::Bar) {
+
+ /* Find the next beat */
+
+ 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 ((session->frame_rate() * 60) / (bbt_beat_subdivision * (*i).tempo->beats_per_minute()));
- frame_skip_error = ((session->frame_rate() * 60.0f) / (bbt_beat_subdivision * (*i).tempo->beats_per_minute())) - frame_skip;
+ frame_skip = (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);
pos = (*i).frame + frame_skip;
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)) {
i_am_accented = true;
(*marks)[n].label = g_strdup (buf);
- /* Error compensation for float to jack_nframes_t*/
+ /* Error compensation for float to nframes_t*/
accumulated_error += frame_skip_error;
if (accumulated_error > 1) {
pos += 1;
}
}
}
- delete zoomed_bbt_points;
return n; //return the actual number of marks made, since we might have skipped some fro fractional time signatures
} else {
/* we're in bar land */
- if (desirable_marks < (uint32_t) (zoomed_bars / 256)) {
+ if (desirable_marks < (uint32_t) (bars / 256)) {
nmarks = 1;
*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].label = g_strdup (buf);
(*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);
- 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).bar % 64 == 1) {
if ((*i).bar % 256 == 1) {
}
}
}
- } 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);
- 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).bar % 16 == 1) {
if ((*i).bar % 64 == 1) {
}
}
}
- } 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);
- 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).bar % 4 == 1) {
if ((*i).bar % 16 == 1) {
}
}
} else {
- nmarks = zoomed_bars;
+ nmarks = bars;
*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).bar % 4 == 1) {
snprintf (buf, sizeof(buf), "%" PRIu32, (*i).bar);
}
}
}
- delete zoomed_bbt_points;
return nmarks;
}
}
gint
Editor::metric_get_frames (GtkCustomRulerMark **marks, gdouble lower, gdouble upper, gint maxchars)
{
- jack_nframes_t mark_interval;
- jack_nframes_t pos;
- jack_nframes_t ilower = (jack_nframes_t) floor (lower);
- jack_nframes_t iupper = (jack_nframes_t) floor (upper);
+ nframes_t mark_interval;
+ nframes_t pos;
+ nframes_t ilower = (nframes_t) floor (lower);
+ nframes_t iupper = (nframes_t) floor (upper);
gchar buf[16];
gint nmarks;
gint n;
}
static void
-sample_to_clock_parts ( jack_nframes_t sample,
- jack_nframes_t sample_rate,
+sample_to_clock_parts ( nframes_t sample,
+ nframes_t sample_rate,
long *hrs_p,
long *mins_p,
long *secs_p,
long *millisecs_p)
{
- jack_nframes_t left;
+ nframes_t left;
long hrs;
long mins;
long secs;
gint
Editor::metric_get_minsec (GtkCustomRulerMark **marks, gdouble lower, gdouble upper, gint maxchars)
{
- jack_nframes_t range;
- jack_nframes_t fr;
- jack_nframes_t mark_interval;
- jack_nframes_t pos;
- jack_nframes_t spacer;
+ nframes_t range;
+ nframes_t fr;
+ nframes_t mark_interval;
+ nframes_t pos;
+ nframes_t spacer;
long hrs, mins, secs, millisecs;
gchar buf[16];
gint nmarks;
bool show_seconds = false;
bool show_minutes = false;
bool show_hours = false;
- jack_nframes_t ilower = (jack_nframes_t) floor (lower);
- jack_nframes_t iupper = (jack_nframes_t) floor (upper);
+ nframes_t ilower = (nframes_t) floor (lower);
+ nframes_t iupper = (nframes_t) floor (upper);
if (session == 0) {
return 0;
fr = session->frame_rate();
/* to prevent 'flashing' */
- if (lower > (spacer = (jack_nframes_t)(128 * Editor::get_current_zoom ()))) {
+ if (lower > (spacer = (nframes_t)(128 * Editor::get_current_zoom ()))) {
lower = lower - spacer;
} else {
- upper = upper + spacer;
lower = 0;
}
+ upper = upper + spacer;
range = iupper - ilower;
if (range < (fr / 50)) {
mark_modulo = 2;
} else {
- /* not possible if jack_nframes_t is a 32 bit quantity */
+ /* not possible if nframes_t is a 32 bit quantity */
mark_interval = 4 * 60 * 60 * fr; /* show 4 hrs */
}