[Pychord-commits] r70 - trunk/pychord2

danilo at garage.maemo.org danilo at garage.maemo.org
Tue Mar 25 19:31:18 EET 2008


Author: danilo
Date: 2008-03-25 19:31:17 +0200 (Tue, 25 Mar 2008)
New Revision: 70

Removed:
   trunk/pychord2/chords.py
Modified:
   trunk/pychord2/chordlist.py
   trunk/pychord2/window_show.py
Log:
- ToneChange Heuristic working

Modified: trunk/pychord2/chordlist.py
===================================================================
--- trunk/pychord2/chordlist.py	2008-03-25 16:50:10 UTC (rev 69)
+++ trunk/pychord2/chordlist.py	2008-03-25 17:31:17 UTC (rev 70)
@@ -1,5 +1,6 @@
 from pgui import list
 from pgui.locale import *
+import re
 
 
 class chordlist (list):
@@ -49,4 +50,43 @@
         self.setBackground(background)
         
         self.move(pos)
-        self.autoScroll(speed)
\ No newline at end of file
+        self.autoScroll(speed)
+        
+    def changeTone(self, semiTons ):
+        for obj in self.objects:
+           if self.isChordLine(obj.text):
+               obj.modify(self.retChordsToneChanged(obj.text,semiTons))
+         
+        self.father.repaint()
+        
+        
+    def retChordsToneChanged(self, chords, semiTons):
+        toneUp = True
+        
+        chordlist = ['H', 'G#', 'G', 'F#', 'F', 'E', 'D#', 'D', 'C#', 'C', 'B', 'A#', 'A']
+    
+        if semiTons < 0:
+            toneUp = False
+            semiTons = -1 * semiTons
+        
+        semiTons = semiTons % 12
+        
+        if not toneUp:
+            semiTons = (12 - semiTons)%13
+        for i in range (semiTons):
+            for i in chordlist:
+                chords = chords.replace(i,chordlist[(chordlist.index(i) - 1 )%13])
+            chords = chords.replace('H',"A")
+            
+        return chords
+
+    def isChordLine(self, line):
+        denied = "a,c,d,e,f,g,h,i,j,l,n,o,p,q,r,s,t,u,v,x,z,H,I,J,L,N,O,P,Q,R,S,T,U,V,X,Z"
+        half_permited = "A,B,C,D,E,F,G"
+        
+        # If line contains any of denied chars, return false
+        R = re.compile("([" + denied + "])")
+        if R.search(line) != None:
+            return False
+        
+        return True
\ No newline at end of file

Deleted: trunk/pychord2/chords.py
===================================================================
--- trunk/pychord2/chords.py	2008-03-25 16:50:10 UTC (rev 69)
+++ trunk/pychord2/chords.py	2008-03-25 17:31:17 UTC (rev 70)
@@ -1,19 +0,0 @@
-def changeTone(chords, semiTons,toneUp = True):
-    chordlist = ['H', 'G#', 'G', 'F#', 'F', 'E', 'D#', 'D', 'C#', 'C', 'B', 'A#', 'A']
-
-    semiTons = semiTons % 12
-    if not toneUp:
-        semiTons = (12 - semiTons)%13
-    for i in range (semiTons):
-        for i in chordlist:
-            chords = chords.replace(i,chordlist[(chordlist.index(i) - 1 )%13])
-        chords = chords.replace('H',"A")
-        
-    return chords
-
-song = "A A# B C C# D D# E F F# G G#"
-print changeTone(song, 1, False)
-
-
-
-re.compile("([a,b,c,d,e,f,g,h,i,j,l,n,o,p,q,r,s,t,u,v,x,z,H,I,J,L,N,O,P,Q,R,S,T,U,V,X,Z]|Dam)")
\ No newline at end of file

Modified: trunk/pychord2/window_show.py
===================================================================
--- trunk/pychord2/window_show.py	2008-03-25 16:50:10 UTC (rev 69)
+++ trunk/pychord2/window_show.py	2008-03-25 17:31:17 UTC (rev 70)
@@ -2,6 +2,7 @@
 from pgui import window
 
 from pgui import Ibutton
+from pgui import Tbutton
 from pgui import label
 
 from chordlist import chordlist 
@@ -59,6 +60,16 @@
         self.addElement(btRR)
         
         
+        btToneUp = Tbutton(self, [730,140],"T+", height=50, width = 50)
+        btToneUp.registerClickSlot(lst.changeTone, 1)
+        self.addElement(btToneUp)
+        
+        
+        btToneDown = Tbutton(self, [730,210],"T-", height=50, width = 50)
+        btToneDown.registerClickSlot(lst.changeTone, -1)
+        self.addElement(btToneDown)
+        
+        
         pygame.event.clear()
         
         self.backlight_count = 0



More information about the Pychord-commits mailing list