[ardour-dev] rulerland - 24 fps patch

nick mainsbridge beatroot at optushome.com.au
Wed May 26 12:37:20 PDT 2004


hi,
  i finally noticed that the SMPTE ruler doesn't show 24 fps and 44.1
kHz very well at all zooms, so here's a patch to correct that, along
with the removal of my dumb test that carefully checked to see if 24 was
an integer.
  The hours and minutes values are now always shown in the minsec ruler.

-- 
nick mainsbridge <beatroot at optushome.com.au>
-------------- next part --------------
--- ../../ardour/gtk_ardour/editor_rulers.cc	Wed Apr  7 13:49:31 2004
+++ gtk_ardour/editor_rulers.cc	Thu May 27 05:17:18 2004
@@ -829,24 +829,20 @@
         }
 	range = upper - lower;
 
-	if (range < session->frames_per_smpte_frame()) { 
-		if ((int)session->smpte_frames_per_second == session->smpte_frames_per_second) {
+	if (range < session->frames_per_smpte_frame()) {
+		if ((session->smpte_frames_per_second == 24) && (fr == 44100)) {
+			mark_interval = fr / 36; // one and a half frames.. no nice integers @ 44100 :(
+		} else if ((int)session->smpte_frames_per_second == session->smpte_frames_per_second) {
 			mark_interval = (fr / (2 * (int)session->smpte_frames_per_second));
 		} else {
 			mark_interval = (jack_nframes_t)(fr / (2 * session->smpte_frames_per_second));
 		}
 		mark_modulo = 10;
 		show_bits = true;
-	} else if (range <= (fr / 10)) { /* 0-0.1 second */
-		if ((int)session->smpte_frames_per_second == session->smpte_frames_per_second) {
-			mark_interval = fr / (int)session->smpte_frames_per_second;/* show single frames */
-		} else {
-			mark_interval = (jack_nframes_t)(fr / session->smpte_frames_per_second);/* show single frames */
-		}
-		mark_modulo = 1;
-		show_frames = true;
 	} else if (range <= (fr / 4)) { /* 0-0.250 second */
-		if ((int)session->smpte_frames_per_second == session->smpte_frames_per_second) {
+		if ((session->smpte_frames_per_second == 24) && (fr == 44100)) {
+			 mark_interval = (2 * fr) / (int)session->smpte_frames_per_second;/* show two frames */
+		} else if ((int)session->smpte_frames_per_second == session->smpte_frames_per_second) {
                         mark_interval = fr / (int)session->smpte_frames_per_second;/* show single frames */
                 } else {
                         mark_interval = (jack_nframes_t)(fr / session->smpte_frames_per_second);/* show single frames */
@@ -854,24 +850,25 @@
 		mark_modulo = 1;
 		show_frames = true;
 	} else if (range <= fr) { /* 0-1 second */
-		if ((int)session->smpte_frames_per_second == session->smpte_frames_per_second) {
+		if ((session->smpte_frames_per_second == 24) && (fr == 44100)) {
+                        mark_interval = (2 * fr) / (int)session->smpte_frames_per_second;/* show two frames */
+		} else	if ((int)session->smpte_frames_per_second == session->smpte_frames_per_second) {
                         mark_interval = fr / (int)session->smpte_frames_per_second;/* show single frames */
                 } else {
                         mark_interval = (jack_nframes_t)(fr / session->smpte_frames_per_second);/* show single frames */
                 }
+		if (session->smpte_frames_per_second == 24) {
+			mark_modulo = 4;
+		}
 		show_frames = true;
 	} else if (range <= 2 * fr) { /* 1-2 seconds */
 		mark_modulo = (gint)(session->smpte_frames_per_second / 2);
 		if (session->smpte_frames_per_second == 24) {
-			if ((int)session->smpte_frames_per_second == session->smpte_frames_per_second) {
-	                         mark_interval = 4 * (fr / (int)session->smpte_frames_per_second);/* show single frames */
-	                 } else {
-                        	mark_interval = (jack_nframes_t)(4 * fr / session->smpte_frames_per_second);/* show 4 frames */
-                	}
+			mark_interval = (4 * fr) / (int)session->smpte_frames_per_second;/* show single frames */
 		} else {
 			if ((int)session->smpte_frames_per_second == session->smpte_frames_per_second) {
                                   mark_interval = 5 * (fr / (int)session->smpte_frames_per_second);/* show single frames */
-                         } else {
+                        } else {
                                 mark_interval = (jack_nframes_t)(5 * fr / session->smpte_frames_per_second);/* show 5 frames */
                         }
 		}
@@ -879,18 +876,14 @@
 	} else if (range <= 8 * fr) { /* 2-5 seconds */
 		mark_modulo = (gint)session->smpte_frames_per_second;
                 if (session->smpte_frames_per_second == 24) {
-			 if ((int)session->smpte_frames_per_second == session->smpte_frames_per_second) {
-                                  mark_interval = 4 * (fr / (int)session->smpte_frames_per_second);/* show single frames */
-                         } else {
-                                mark_interval = (jack_nframes_t)(4 * fr / session->smpte_frames_per_second);/* show 4 frames */
-                        }
+			mark_interval = (4 * fr) / (int)session->smpte_frames_per_second;/* show four frames */
                 } else {
-			 if ((int)session->smpte_frames_per_second == session->smpte_frames_per_second) {
-                                   mark_interval = 5 * (fr / (int)session->smpte_frames_per_second);/* show single frames */
-                         } else {
-                                mark_interval = (jack_nframes_t)(5 * fr / session->smpte_frames_per_second);/* show 5 frames */
-                        }
-                }
+			if ((int)session->smpte_frames_per_second == session->smpte_frames_per_second) {
+				mark_interval = 5 * (fr / (int)session->smpte_frames_per_second);/* show five frames */
+			} else {
+				mark_interval = (jack_nframes_t)(5 * fr / session->smpte_frames_per_second);/* show 5 frames */
+			}
+		}
 		show_frames = true;
 	} else if (range <= 16 * fr) { /* 8-16 seconds */
 		mark_interval =   fr; /* show seconds */
@@ -1422,7 +1415,6 @@
 static void
 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,
@@ -1561,13 +1553,12 @@
 		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);
-                        	}
+				if (secs == 0) {
+					(*marks)[n].style = GtkCustomRulerMarkMajor;
+				} else {
+					(*marks)[n].style = GtkCustomRulerMarkMinor;
+				}
+				snprintf (buf, sizeof(buf), "%02ld:%02ld:%02ld.%03ld", hrs, mins, secs, millisecs);
                 	} else {
                         	snprintf (buf, sizeof(buf), " ");
 	                        (*marks)[n].style = GtkCustomRulerMarkMicro;
@@ -1581,11 +1572,10 @@
                         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);
                                 }
+				snprintf (buf, sizeof(buf), "%02ld:%02ld:%02ld.%03ld", hrs, mins, secs, millisecs);
                         } else {
                                 snprintf (buf, sizeof(buf), " ");
                                 (*marks)[n].style = GtkCustomRulerMarkMicro;
@@ -1612,11 +1602,10 @@
 			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);
 				}
+				snprintf (buf, sizeof(buf), "%02ld:%02ld:%02ld.%03ld", hrs, mins, secs, millisecs);
 			} else {
 				snprintf (buf, sizeof(buf), " ");
 				(*marks)[n].style = GtkCustomRulerMarkMicro;


More information about the Ardour-Dev mailing list