fix bug that plays the first beat twice when counting
1 files changed, 11 insertions(+), 7 deletions(-)

M zmusic.el
M zmusic.el +11 -7
@@ 689,9 689,11 @@ After it is played, highlight the beat a
   (interactive)
   (setq *zmusic//repeat-current-beat-count* 1)
   (zmusic//play-next-beat)
-  (run-with-timer (/ 60.0 *zmusic//bpm*)
-                  nil
-                  #'zmusic//move-to-next-beat))
+  (zmusic//stop-timer)
+  (setq *zmusic//beat-timer*
+        (run-with-timer (* 0.99 (/ 60.0 *zmusic//bpm*))
+                        nil
+                        #'zmusic//move-to-next-beat)))
 
 (defun zmusic//move-to-next-beat ()
   "Move to the next beat, but do not play it."

          
@@ 778,18 780,20 @@ 1.  This function converts from a note p
                                            (gethash semitones *zmusic//rendered-notes-files*))))))
 
 (defun zmusic//start-timer ()
-  "Start stepping forward."
+  "Start playing the music."
   (interactive)
+  (setq *zmusic//repeat-current-beat-count* 1)
   (when *zmusic//beat-timer*
     (cancel-timer *zmusic//beat-timer*))
   (setq *zmusic//beat-timer*
-        (run-with-timer (/ 60.0 *zmusic//bpm*)
+        (run-with-timer 0
                         (/ 60.0 *zmusic//bpm*)
-                        #'zmusic/count-beat)))
+                        #'zmusic//play-next-beat)))
 
 (defun zmusic//stop-timer ()
   "Stop stepping forward."
-  (cancel-timer *zmusic//beat-timer*)
+  (when *zmusic//beat-timer*
+    (cancel-timer *zmusic//beat-timer*))
   (setq *zmusic//beat-timer* nil))
 
 (defun zmusic/toggle-play ()