From 0fea67a10813084148c2803c45d6919a135840e0 Mon Sep 17 00:00:00 2001
From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Sat, 6 Jan 2007 19:15:29 +0100
Subject: [PATCH] text diffs  on textized midi files.

---
 buildscripts/output-distance.py | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/buildscripts/output-distance.py b/buildscripts/output-distance.py
index 5aa5dfcb6e..48318d882e 100644
--- a/buildscripts/output-distance.py
+++ b/buildscripts/output-distance.py
@@ -7,9 +7,7 @@ import math
 ## so we can call directly as buildscripts/output-distance.py
 me_path = os.path.abspath (os.path.split (sys.argv[0])[0])
 sys.path.insert (0, me_path + '/../python/')
-
-
-import safeeval
+sys.path.insert (0, me_path + '/../python/out/')
 
 
 X_AXIS = 0
@@ -523,19 +521,26 @@ class ProfileFileLink (FileCompareLink):
         return dist
 
     
-class MidiFileLink (FileCompareLink):
-    def get_content (self, f):
-        s = FileCompareLink.get_content (self, f)
-        s = re.sub ('LilyPond [0-9.]+', '', s)
-        return s
-    
-    def get_cell (self, oldnew):
+class MidiFileLink (TextFileCompareLink):
+    def get_content (self, oldnew):
+        import midi
+        
+        data = FileCompareLink.get_content (self, oldnew)
+        midi = midi.parse (data)
+        tracks = midi[1]
+
         str = ''
-        if oldnew == 1 and self.distance () > 0:
-            str = 'changed' 
+        j = 0
+        for t in tracks:
+            str += 'track %d' % j
+            j += 1
+
+            for e in t:
+                str += '  ev %s\n' % `e`
         return str
     
 
+
 class SignatureFileLink (FileLink):
     def __init__ (self, f1, f2 ):
         FileLink.__init__ (self, f1, f2)
-- 
2.39.5