[ardour-dev] time ruler patch

nick mainsbridge beatroot at optushome.com.au
Mon Mar 1 06:14:20 PST 2004


this patch changes the minsec and smpte rulers a bit.. the smpte ruler
is now based on frames and subframes at low zoom ratios (probably a bit
wonky at NTSC frame rate).. both rulers now extend before the left edge
to avoid numbers jumping in out of nowhere.
minsec calculation should be a bit faster.
no big deal, really.
-- 
nick mainsbridge <beatroot at optushome.com.au>
-------------- next part --------------
--- ../../../Desktop/ardour-0.9beta11.2/gtk_ardour/editor_rulers.cc	Sun Feb 29 15:25:32 2004
+++ gtk_ardour/editor_rulers.cc	Tue Mar  2 00:59:34 2004
@@ -782,54 +721,98 @@
 	jack_nframes_t fr;
 	jack_nframes_t mark_interval;
 	jack_nframes_t pos;
+	jack_nframes_t spacer;
 	SMPTE_Time smpte;
 	gchar buf[16];
 	gint nmarks;
 	gint n;
+	gint mark_modulo = 5;
+	bool show_bits = false;
+	bool show_seconds = false;
+	bool show_minutes = false;
+	bool show_hours = false;
 
 	if (session == 0) {
 		return 0;
 	}
 
 	fr = session->frame_rate();
+
+	if (lower > (spacer = (jack_nframes_t)(128 * Editor::get_current_zoom ()))) {
+                lower = lower - spacer;
+        } else {
+                upper = upper + spacer - lower;
+                lower = 0;
+        }
 	range = upper - lower;
 
 	if (range < session->frames_per_smpte_frame()) { 
-		mark_interval = session->frames_per_smpte_frame(); /* show SMPTE frames */
+		mark_interval = (jack_nframes_t)(fr / (2 * session->smpte_frames_per_second));
+		mark_modulo = 10;
+		show_bits = true;
 	} else if (range <= (jack_nframes_t) floor(fr * 0.1)) { /* 0-0.1 second */
-		mark_interval = (jack_nframes_t) (fr * 0.025); /* show 1/40 seconds */
-	} else if (range <= fr/2) { /* 0-0.5 second */
-		mark_interval = (jack_nframes_t) (fr * 0.05);  /* show 1/20 seconds */
+		mark_interval = (jack_nframes_t)(fr / session->smpte_frames_per_second);/* show single frames */
+		mark_modulo = 1;
+	} else if (range <= fr/4) { /* 0-0.250 second */
+		mark_interval = (jack_nframes_t)(fr / session->smpte_frames_per_second);/* show single frames */
+		mark_modulo = 1;
 	} else if (range <= fr) { /* 0-1 second */
-		mark_interval = (jack_nframes_t) (fr * 0.1);  /* show 1/10 seconds */
+		mark_interval = (jack_nframes_t)(fr / session->smpte_frames_per_second);/* show single frames */
 	} else if (range <= 2 * fr) { /* 1-2 seconds */
-		mark_interval = (jack_nframes_t) floor (fr * 0.5); /* show 1/2 seconds */
+		mark_modulo = (gint)(session->smpte_frames_per_second / 2);
+		if (session->smpte_frames_per_second == 24) {
+			mark_interval = (jack_nframes_t)(4 * fr / session->smpte_frames_per_second); /* show 4 frames */
+		} else {
+			mark_interval = (jack_nframes_t)(5 *  fr / session->smpte_frames_per_second);  /* show 5 frames */
+		}
 	} else if (range <= 8 * fr) { /* 2-5 seconds */
-		mark_interval =  2 * fr; /* show 2 seconds */
+		mark_modulo = (gint)session->smpte_frames_per_second;
+                if (session->smpte_frames_per_second == 24) {
+                        mark_interval = (jack_nframes_t)(4 * fr / session->smpte_frames_per_second); /* show 4 frames */
+                } else {
+                        mark_interval = (jack_nframes_t)(5 *  fr / session->smpte_frames_per_second);  /* show 5 frames */
+                }
 	} else if (range <= 16 * fr) { /* 8-16 seconds */
-		mark_interval =  4 * fr; /* show 4 seconds */
+		mark_interval =   fr; /* show seconds */
+		show_seconds = true;
 	} else if (range <= 30 * fr) { /* 10-30 seconds */
-		mark_interval = 10 * fr; /* show 10 seconds */
+		mark_interval =  fr; /* show 2 seconds */
+		show_seconds = true;
 	} else if (range <= 60 * fr) { /* 30-60 seconds */
-		mark_interval = 15 * fr; /* show 15 seconds */
+		mark_interval = 5 * fr; /* show 5 seconds */
+		show_seconds = true;
+		mark_modulo = 3;
 	} else if (range <= 2 * 60 * fr) { /* 1-2 minutes */
+		mark_interval = 5 * fr; /* show 5 seconds */
+		show_seconds = true;
+		mark_modulo = 3;
+	} else if (range <= 4 * 60 * fr) { /* 4 minutes */
+		mark_interval = 10 * fr; /* show 10 seconds */
+		show_seconds = true;
+		mark_modulo = 30;
+	} else if (range <= 10 * 60 * fr) { /* 10 minutes */
 		mark_interval = 30 * fr; /* show 30 seconds */
-	} else if (range <= 10 * 60 * fr) { /* 2-10 minutes */
-		mark_interval = 60 * fr; /* show 1 minutes */
-	} else if (range <= 15 * 60 * fr) { /* 10-15 minutes */
-		mark_interval = 2 * 60 * fr; /* show 2 minutes */
+		show_seconds = true;
+		mark_modulo = 60;
 	} else if (range <= 30 * 60 * fr) { /* 10-30 minutes */
-		mark_interval = 5 * 60 * fr; /* show 5 minutes */
+		mark_interval =  60 * fr; /* show 1 minute */
+		show_minutes = true;
 	} else if (range <= 60 * 60 * fr) { /* 30 minutes - 1hr */
-		mark_interval = 10 * 60 * fr; /* show 10 minutes */
+		mark_interval = 2 * 60 * fr; /* show 2 minutes */
+		show_minutes = true;
+		 mark_modulo = 10;
 	} else if (range <= 4 * 60 * 60 * fr) { /* 1 - 4 hrs*/
-		mark_interval = 30 * 60 * fr; /* show 30 minutes */
+		mark_interval = 5 * 60 * fr; /* show 10 minutes */
+		show_minutes = true;
+		mark_modulo = 30;
 	} else if (range <= 8 * 60 * 60 * fr) { /* 4 - 8 hrs*/
-		mark_interval = 60 * 60 * fr; /* show hrs */
-	} else if (range <= 16 * 60 * 60 * fr) { /* 8-16 hrs*/
-		mark_interval = (jack_nframes_t) floor (1.5 * 60 * 60 * fr); /* show 1 1/2hrs XXX don't like this */
+		mark_interval = 20 * 60 * fr; /* show 20 minutes */
+		show_minutes = true;
+		 mark_modulo = 60;
 	} else if (range <= 16 * 60 * 60 * fr) { /* 16-24 hrs*/
-		mark_interval = 2 * 60 * 60 * fr; /* show 2 hrs */
+		mark_interval =  60 * 60 * fr; /* show 60 minutes */
+		show_hours = true;
+                mark_modulo = 2;
 	} else {
 
 		/* not possible if jack_nframes_t is a 32 bit quantity */
@@ -842,16 +825,109 @@
 	pos = ((lower + (mark_interval/2))/mark_interval) * mark_interval;
 	pos += session->smpte_offset(0);
 
-	for (n = 0; n < nmarks; pos += mark_interval, ++n) {
-		session->smpte_time (pos, smpte);
-		if (smpte.negative) {
-			snprintf (buf, sizeof(buf), "-%02ld:%02ld:%02ld:%02ld", smpte.hours, smpte.minutes, smpte.seconds, smpte.frames);
-		} else {
-			snprintf (buf, sizeof(buf), "%02ld:%02ld:%02ld:%02ld", smpte.hours, smpte.minutes, smpte.seconds, smpte.frames);
+	if (show_bits) {
+		for (n = 0; n < nmarks; pos += mark_interval, ++n) {
+                        session->smpte_time_subframes (pos, smpte);
+                        if ((smpte.subframes % mark_modulo) == 0) {
+                                if (smpte.subframes == 0) {
+                                        (*marks)[n].style = GtkCustomRulerMarkMajor;
+                                        if (smpte.negative) {
+                                                snprintf (buf, sizeof(buf), "-%02ld:%02ld:%02ld:%02ld", smpte.hours, smpte.minutes, smpte.seconds, smpte.frames);
+                                        } else {
+                                                snprintf (buf, sizeof(buf), "%02ld:%02ld:%02ld:%02ld", smpte.hours, smpte.minutes, smpte.seconds, smpte.frames);
+                                        }
+                                } else {
+                                        (*marks)[n].style = GtkCustomRulerMarkMinor;
+                                        snprintf (buf, sizeof(buf), ".%02ld", smpte.subframes);
+                                }
+                        } else {
+                                snprintf (buf, sizeof(buf)," ");
+                                (*marks)[n].style = GtkCustomRulerMarkMicro;
+                                                                                                                   
+                        }
+                        (*marks)[n].label = g_strdup (buf);
+                        (*marks)[n].position = pos;
+                }
+	} else if (show_seconds) {
+		for (n = 0; n < nmarks; pos += mark_interval, ++n) {
+			session->smpte_time (pos, smpte);
+                        if ((smpte.seconds % mark_modulo) == 0) {
+				if (smpte.seconds == 0) {
+					(*marks)[n].style = GtkCustomRulerMarkMajor;
+				} else {
+					(*marks)[n].style = GtkCustomRulerMarkMinor;
+				}
+				if (smpte.negative) {
+                                        snprintf (buf, sizeof(buf), "-%02ld:%02ld:%02ld:%02ld", smpte.hours, smpte.minutes, smpte.seconds, smpte.frames);
+                                } else {
+                                        snprintf (buf, sizeof(buf), "%02ld:%02ld:%02ld:%02ld", smpte.hours, smpte.minutes, smpte.seconds, smpte.frames);
+                                }
+                        } else {
+                                snprintf (buf, sizeof(buf)," ");
+                                (*marks)[n].style = GtkCustomRulerMarkMicro;
+                                                                                                                   
+                        }
+                        (*marks)[n].label = g_strdup (buf);
+                        (*marks)[n].position = pos;
+                }
+	} else if (show_minutes) {
+		 for (n = 0; n < nmarks; pos += mark_interval, ++n) {
+			session->smpte_time (pos, smpte);
+                        if ((smpte.minutes % mark_modulo) == 0) {
+				if (smpte.minutes == 0) {
+                                	(*marks)[n].style = GtkCustomRulerMarkMajor;
+                        	} else {
+					(*marks)[n].style = GtkCustomRulerMarkMinor;
+				}
+				if (smpte.negative) {
+                                        snprintf (buf, sizeof(buf), "-%02ld:%02ld:%02ld:%02ld", smpte.hours, smpte.minutes, smpte.seconds, smpte.frames);
+                                } else {
+                                        snprintf (buf, sizeof(buf), "%02ld:%02ld:%02ld:%02ld", smpte.hours, smpte.minutes, smpte.seconds, smpte.frames);
+                                }
+			} else {
+                                snprintf (buf, sizeof(buf)," ");
+                                (*marks)[n].style = GtkCustomRulerMarkMicro;
+                                                                                                                   
+                        }
+                        (*marks)[n].label = g_strdup (buf);
+                        (*marks)[n].position = pos;
+                }
+	} else if (show_hours) {
+                 for (n = 0; n < nmarks; pos += mark_interval, ++n) {
+			session->smpte_time (pos, smpte);
+                        if ((smpte.hours % mark_modulo) == 0) {
+                                (*marks)[n].style = GtkCustomRulerMarkMajor;
+                                snprintf (buf, sizeof(buf), "%02ld:%02ld:%02ld:%02ld", smpte.hours, smpte.minutes, smpte.seconds, smpte.frames);
+                        } else {
+                                snprintf (buf, sizeof(buf)," ");
+                                (*marks)[n].style = GtkCustomRulerMarkMicro;
+                                                                                                                   
+                        }
+                        (*marks)[n].label = g_strdup (buf);
+                        (*marks)[n].position = pos;
+                }
+	} else {
+		for (n = 0; n < nmarks; pos += mark_interval, ++n) {
+			session->smpte_time (pos, smpte);
+			if ((smpte.frames % mark_modulo) == 0) {
+				if ((smpte.frames == 0) || (session->smpte_drop_frames && (smpte.frames == 2))) {
+					(*marks)[n].style = GtkCustomRulerMarkMajor;
+				} else {
+					(*marks)[n].style = GtkCustomRulerMarkMinor;
+				}
+				if (smpte.negative) {
+					snprintf (buf, sizeof(buf), "-%02ld:%02ld:%02ld:%02ld", smpte.hours, smpte.minutes, smpte.seconds, smpte.frames);
+				} else {
+					snprintf (buf, sizeof(buf), "%02ld:%02ld:%02ld:%02ld", smpte.hours, smpte.minutes, smpte.seconds, smpte.frames);
+				}
+			} else {
+				snprintf (buf, sizeof(buf)," ");
+				(*marks)[n].style = GtkCustomRulerMarkMicro;
+			
+			}
+			(*marks)[n].label = g_strdup (buf);
+			(*marks)[n].position = pos;
 		}
-		(*marks)[n].label = g_strdup (buf);
-		(*marks)[n].position = pos;
-		(*marks)[n].style = GtkCustomRulerMarkMajor;
 	}
 
 	return nmarks;
@@ -1147,26 +1223,31 @@
 }
 
 static void
-sample_to_clock_parts (guint32 sample,
-		       guint32 sample_rate, 
-		       float smpte_fps,
-		       guint32 *hrs_p,
-		       guint32 *mins_p,
-		       float *secs_p)
+sample_to_clock_parts ( jack_nframes_t sample,
+			jack_nframes_t sample_rate, 
+//			float smpte_fps,
+			long *hrs_p,
+			long *mins_p,
+			long *secs_p,
+			long *millisecs_p)
 
 {
 	jack_nframes_t left;
-	guint32 hrs;
-	guint32 mins;
-	float secs;
+	long hrs;
+	long mins;
+	long secs;
+	long millisecs;
 	
 	left = sample;
-	hrs = (int) floor (left / (sample_rate * 60.0f * 60.0f));
-	left -= (jack_nframes_t) floor (hrs * sample_rate * 60.0f * 60.0f);
-	mins = (int) floor (left / (sample_rate * 60.0f));
-	left -= (jack_nframes_t) floor (mins * sample_rate * 60.0f);
-	secs = left / (float) sample_rate;
+	hrs = left / (sample_rate * 60 * 60);
+	left -= hrs * sample_rate * 60 * 60;
+	mins = left / (sample_rate * 60);
+	left -= mins * sample_rate * 60;
+	secs = left / sample_rate;
+	left -= secs * sample_rate;
+	millisecs = left * 1000 / sample_rate;
 
+	*millisecs_p = millisecs;
 	*secs_p = secs;
 	*mins_p = mins;
 	*hrs_p = hrs;
@@ -1181,76 +1262,172 @@
 	jack_nframes_t fr;
 	jack_nframes_t mark_interval;
 	jack_nframes_t pos;
-	guint32 hrs, mins;
-	float secs;
+	jack_nframes_t spacer;
+	long hrs, mins, secs, millisecs;
 	gchar buf[16];
 	gint nmarks;
 	gint n;
+	gint mark_modulo = 100;
+	bool show_seconds = false;
+	bool show_minutes = false;
+	bool show_hours = false;
 
 	if (session == 0) {
 		return 0;
 	}
 
 	fr = session->frame_rate();
+
+	/* to prevent 'flashing' */
+	if (lower > (spacer = (jack_nframes_t)(128 * Editor::get_current_zoom ()))) {
+		lower = lower - spacer;
+	} else {
+		upper = upper + spacer;
+		lower = 0;
+	}
 	range = upper - lower;
 
-	if (range < (jack_nframes_t) floor (fr * 0.01)) {
+	if (range < (jack_nframes_t) floor (fr * 0.02)) {
 		mark_interval = (jack_nframes_t) (fr * 0.01); /* show 1/100 seconds */
+		mark_modulo = 10;
 	} else if (range <= (jack_nframes_t) floor(fr * 0.1)) { /* 0-0.1 second */
-		mark_interval = (jack_nframes_t) (fr * 0.025); /* show 1/40 seconds */
+		mark_interval = (jack_nframes_t) (fr * 0.02); /* show 1/50 seconds */
+		mark_modulo = 20;
 	} else if (range <= fr/2) { /* 0-0.5 second */
 		mark_interval = (jack_nframes_t) (fr * 0.05);  /* show 1/20 seconds */
+		mark_modulo = 100;
 	} else if (range <= fr) { /* 0-1 second */
 		mark_interval = (jack_nframes_t) (fr * 0.1);  /* show 1/10 seconds */
+		mark_modulo = 200;
 	} else if (range <= 2 * fr) { /* 1-2 seconds */
-		mark_interval = (jack_nframes_t) floor (fr * 0.5); /* show 1/2 seconds */
+		mark_interval = (jack_nframes_t) floor (fr * 0.1); /* show 1/2 seconds */
+		mark_modulo = 500;
 	} else if (range <= 8 * fr) { /* 2-5 seconds */
-		mark_interval =  2 * fr; /* show 2 seconds */
+		mark_interval =  (jack_nframes_t) floor (fr * 0.2); /* show 2 seconds */
+		mark_modulo = 1000;
 	} else if (range <= 16 * fr) { /* 8-16 seconds */
-		mark_interval =  4 * fr; /* show 4 seconds */
+		mark_interval =  1 * fr; /* show 1 seconds */
+		show_seconds = true;
+		mark_modulo = 5;
 	} else if (range <= 30 * fr) { /* 10-30 seconds */
-		mark_interval = 10 * fr; /* show 10 seconds */
+		mark_interval = 1 * fr; /* show 10 seconds */
+		show_seconds = true;
+                mark_modulo = 5;
 	} else if (range <= 60 * fr) { /* 30-60 seconds */
-		mark_interval = 15 * fr; /* show 15 seconds */
-	} else if (range <= 2 * 60 * fr) { /* 1-2 minutes */
-		mark_interval = 30 * fr; /* show 30 seconds */
-	} else if (range <= 10 * 60 * fr) { /* 2-10 minutes */
-		mark_interval = 60 * fr; /* show 1 minutes */
-	} else if (range <= 15 * 60 * fr) { /* 10-15 minutes */
-		mark_interval = 2 * 60 * fr; /* show 2 minutes */
-	} else if (range <= 30 * 60 * fr) { /* 10-30 minutes */
-		mark_interval = 5 * 60 * fr; /* show 5 minutes */
-	} else if (range <= 60 * 60 * fr) { /* 30 minutes - 1hr */
-		mark_interval = 10 * 60 * fr; /* show 10 minutes */
-	} else if (range <= 4 * 60 * 60 * fr) { /* 1 - 4 hrs*/
-		mark_interval = 30 * 60 * fr; /* show 30 minutes */
-	} else if (range <= 8 * 60 * 60 * fr) { /* 4 - 8 hrs*/
-		mark_interval = 60 * 60 * fr; /* show hrs */
-	} else if (range <= 16 * 60 * 60 * fr) { /* 8-16 hrs*/
-		mark_interval = (jack_nframes_t) floor (1.5 * 60 * 60 * fr); /* show 1 1/2hrs XXX don't like this */
-	} else if (range <= 16 * 60 * 60 * fr) { /* 16-24 hrs*/
-		mark_interval = 2 * 60 * 60 * fr; /* show 2 hrs */
-	} else {
-
-		/* not possible if jack_nframes_t is a 32 bit quantity */
-
-		mark_interval = 4 * 60 * 60 * fr; /* show 4 hrs */
-	}
+                mark_interval = 5 * fr; /* show 5 seconds */
+                show_seconds = true;
+                mark_modulo = 3;
+        } else if (range <= 2 * 60 * fr) { /* 1-2 minutes */
+                mark_interval = 5 * fr; /* show 5 seconds */
+                show_seconds = true;
+                mark_modulo = 3;
+        } else if (range <= 4 * 60 * fr) { /* 4 minutes */
+                mark_interval = 10 * fr; /* show 10 seconds */
+                show_seconds = true;
+                mark_modulo = 30;
+        } else if (range <= 10 * 60 * fr) { /* 10 minutes */
+                mark_interval = 30 * fr; /* show 30 seconds */
+                show_seconds = true;
+                mark_modulo = 60;
+        } else if (range <= 30 * 60 * fr) { /* 10-30 minutes */
+                mark_interval =  60 * fr; /* show 1 minute */
+                show_minutes = true;
+		mark_modulo = 5;
+        } else if (range <= 60 * 60 * fr) { /* 30 minutes - 1hr */
+                mark_interval = 2 * 60 * fr; /* show 2 minutes */
+                show_minutes = true;
+                mark_modulo = 10;
+        } else if (range <= 4 * 60 * 60 * fr) { /* 1 - 4 hrs*/
+                mark_interval = 5 * 60 * fr; /* show 10 minutes */
+                show_minutes = true;
+                mark_modulo = 30;
+        } else if (range <= 8 * 60 * 60 * fr) { /* 4 - 8 hrs*/
+                mark_interval = 20 * 60 * fr; /* show 20 minutes */
+                show_minutes = true;
+                mark_modulo = 60;
+        } else if (range <= 16 * 60 * 60 * fr) { /* 16-24 hrs*/
+                mark_interval =  60 * 60 * fr; /* show 60 minutes */
+                show_hours = true;
+		mark_modulo = 2;
+        } else {
+                                                                                                                   
+                /* not possible if jack_nframes_t is a 32 bit quantity */
+                                                                                                                   
+                mark_interval = 4 * 60 * 60 * fr; /* show 4 hrs */
+        }
 
 	nmarks = 1 + (range / mark_interval);
 	*marks = (GtkCustomRulerMark *) g_malloc (sizeof(GtkCustomRulerMark) * nmarks);
 	pos = ((lower + (mark_interval/2))/mark_interval) * mark_interval;
 	
-	for (n = 0; n < nmarks; pos += mark_interval, ++n) {
-		sample_to_clock_parts (pos, fr, session->smpte_frames_per_second, &hrs, &mins, &secs);
-		snprintf (buf, sizeof(buf), "%02d:%02d:%.3f", hrs, mins, secs);
-		(*marks)[n].label = g_strdup (buf);
-		(*marks)[n].position = pos;
-		(*marks)[n].style = GtkCustomRulerMarkMajor;
+	if (show_seconds) {
+		for (n = 0; n < nmarks; pos += mark_interval, ++n) {
+                	sample_to_clock_parts (pos, fr, &hrs, &mins, &secs, &millisecs);
+              	  	if (secs % mark_modulo == 0) {
+                	        if (secs == 0) {
+                        	        (*marks)[n].style = GtkCustomRulerMarkMajor;
+                                	snprintf (buf, sizeof(buf), "%02ld:%02ld:%02ld.%03ld", hrs, mins, secs, millisecs);
+           	             } else {
+                	                (*marks)[n].style = GtkCustomRulerMarkMinor;
+                        	        snprintf (buf, sizeof(buf), ":%02ld.%03ld", secs, millisecs);
+                        	}
+                	} else {
+                        	snprintf (buf, sizeof(buf), " ");
+	                        (*marks)[n].style = GtkCustomRulerMarkMicro;
+        	        }
+                	(*marks)[n].label = g_strdup (buf);
+              		(*marks)[n].position = pos;
+		}
+        } else if (show_minutes) {
+		for (n = 0; n < nmarks; pos += mark_interval, ++n) {
+                        sample_to_clock_parts (pos, fr, &hrs, &mins, &secs, &millisecs);
+                        if (mins % mark_modulo == 0) {
+                                if (mins == 0) {
+                                        (*marks)[n].style = GtkCustomRulerMarkMajor;
+                                        snprintf (buf, sizeof(buf), "%02ld:%02ld:%02ld.%03ld", hrs, mins, secs, millisecs);
+                                } else {
+                                        (*marks)[n].style = GtkCustomRulerMarkMinor;
+                                        snprintf (buf, sizeof(buf), ":%02ld:%02ld.%03ld", mins, secs, millisecs);
+                                }
+                        } else {
+                                snprintf (buf, sizeof(buf), " ");
+                                (*marks)[n].style = GtkCustomRulerMarkMicro;
+                        }
+                        (*marks)[n].label = g_strdup (buf);
+                        (*marks)[n].position = pos;
+                }
+        } else if (show_hours) {
+		 for (n = 0; n < nmarks; pos += mark_interval, ++n) {
+                        sample_to_clock_parts (pos, fr, &hrs, &mins, &secs, &millisecs);
+                        if (hrs % mark_modulo == 0) {
+                                (*marks)[n].style = GtkCustomRulerMarkMajor;
+                                snprintf (buf, sizeof(buf), "%02ld:%02ld:%02ld.%03ld", hrs, mins, secs, millisecs);
+                        } else {
+                                snprintf (buf, sizeof(buf), " ");
+                                (*marks)[n].style = GtkCustomRulerMarkMicro;
+                        }
+                        (*marks)[n].label = g_strdup (buf);
+                        (*marks)[n].position = pos;
+                }
+        } else {
+		for (n = 0; n < nmarks; pos += mark_interval, ++n) {
+			sample_to_clock_parts (pos, fr, &hrs, &mins, &secs, &millisecs);
+			if (millisecs % mark_modulo == 0) {
+				if (millisecs == 0) {
+					(*marks)[n].style = GtkCustomRulerMarkMajor;
+					snprintf (buf, sizeof(buf), "%02ld:%02ld:%02ld.%03ld", hrs, mins, secs, millisecs);
+				} else {
+					(*marks)[n].style = GtkCustomRulerMarkMinor;
+					snprintf (buf, sizeof(buf), ".%03ld", millisecs);
+				}
+			} else {
+				snprintf (buf, sizeof(buf), " ");
+				(*marks)[n].style = GtkCustomRulerMarkMicro;
+			}
+			(*marks)[n].label = g_strdup (buf);
+			(*marks)[n].position = pos;
+		}
 	}
 
 	return nmarks;
 }
-
-
-


More information about the Ardour-Dev mailing list