[mythtv] [PATCH] AB-Repeat for mythmusic

Leo Weppelman leo at wau.mis.ah.nl
Sat May 22 16:38:36 EDT 2004


This patch implements the AB-Repeat function that exists on many dvd/cd
players (like on my revoy). It allows the repeat of a section of a 'song'
marked by the press of the AB-button. For the patch I used the 'B' button.

For those who wonder why someone likes to have parts of a song played over
and over again: I use it on my guitar play-along CD's to practice only
a few measures.

Leo.

-------------- next part --------------
Binary files mythmusic.org/libmythmusic.so and mythmusic/libmythmusic.so differ
diff -ru mythmusic.org/main.cpp mythmusic/main.cpp
--- mythmusic.org/main.cpp	Sun Mar 21 07:22:42 2004
+++ mythmusic/main.cpp	Thu May 20 23:49:39 2004
@@ -383,6 +383,7 @@
     REG_KEY("Music", "THMBUP", "Increase rating", "9");
     REG_KEY("Music", "THMBDOWN", "Decrease rating", "7");
     REG_KEY("Music", "REFRESH", "Refresh music tree", "8");
+    REG_KEY("Music", "ABREPEAT", "AB-repeat", "B");
 
     REG_MEDIA_HANDLER("MythMusic Media Handler", "", "", handleMedia, MEDIATYPE_AUDIO | MEDIATYPE_MIXED);
 }
diff -ru mythmusic.org/playbackbox.cpp mythmusic/playbackbox.cpp
--- mythmusic.org/playbackbox.cpp	Tue Apr 27 11:50:22 2004
+++ mythmusic/playbackbox.cpp	Fri May 21 22:15:35 2004
@@ -43,6 +43,7 @@
     outputBufferSize = 256;
     currentTime = 0;
     maxTime = 0;
+    ab_pos_a = ab_pos_b = -1;
     setContext(0);
     visual_mode_timer = new QTimer(this);
     visualizer_status = 0;
@@ -269,6 +270,8 @@
             else
                 stop();
         }
+	else if (action == "ABREPEAT")
+	    toggleABRepeat();
         else if (action == "THMBUP")
             increaseRating();
         else if (action == "THMBDOWN")
@@ -850,6 +853,33 @@
     seek(nextTime);
 }
 
+void PlaybackBox::toggleABRepeat()
+{
+    if (ab_pos_a == -1)
+    {
+	    ab_pos_a = currentTime;
+	    ab_pos_b = -1;
+    }
+    else
+    {
+	    if (ab_pos_b == -1)
+	    {
+	    	int tmp = currentTime;
+
+	    	if (tmp > ab_pos_a) {
+		    ab_pos_b = tmp;
+		    seek(ab_pos_a);
+	    	}
+	    	else
+		    ab_pos_a = ab_pos_b = -1;
+	    }
+    	    else {
+		    ab_pos_a = currentTime;
+	    	    ab_pos_b = -1;
+	    }
+    }
+}
+
 void PlaybackBox::seek(int pos)
 {
     if (output && output->running()) 
@@ -1162,6 +1192,11 @@
                     current_visualization_text->refresh();
                 }
             }
+	    if (ab_pos_b != -1) { // AB-repeat active
+		    if (ab_pos_b < currentTime) {
+		    	seek(ab_pos_a);
+		    }
+	    }
 
             break;
         }
diff -ru mythmusic.org/playbackbox.h mythmusic/playbackbox.h
--- mythmusic.org/playbackbox.h	Thu May 20 20:05:58 2004
+++ mythmusic/playbackbox.h	Thu May 20 21:14:04 2004
@@ -69,6 +69,7 @@
     void showVolume(bool on_or_off);
     void wipeTrackInfo();
     void toggleFullBlankVisualizer();
+    void toggleABRepeat();
     
   signals:
   
@@ -103,6 +104,7 @@
     bool listAsShuffled;
     int outputBufferSize;
     int currentTime, maxTime;
+    int ab_pos_a, ab_pos_b;
 
     Metadata *curMeta;
 


More information about the mythtv-dev mailing list