# -*- coding: ISO-8859-1 -*- """ capellaScript -- Copyright (c) 2009 Bernd Jungmann-bearbeitet von Burkhard Mikolai >>> Bunte Noten Fingersatz I.Lage Die Partitur wird in Bunte Noten nach den Regeln von www.bunte-noten.de umgewandelt.|| Wenn genau eine Note markiert ist, kann für sie Färbung und Bezifferung manuell eingestellt werden.|| Der normale Notenkopf wird von einem Einfachtext mit entsprechend gefärbtem Notenkopf und einem weiteren Einfachtext mit einer Zahl überlagert. <<< Erste Version Bernd Jungmann, 6.4.2009: """ # Korrekterweise werden Gitarrennoten mit Oktavierung nach unten notiert, # ähnlich wie die Tenor-Stimme. # Vielfach wird dies jedoch weggelassen und die Oktavierung trotzdem erwartet. # Dieses Verhalten können Sie erreichen, indem Sie OktavierenOhneSchluessel = True # aktivieren. OktavierenOhneSchluessel = False #OktavierenOhneSchluessel = True #------------------------------------------------------------------- ColorNames = ["schwarz","braun", "blau", "rot", "grün", "gelb"] ColorValues = [(0,0,0), (153,51,0), (0,0,255), (255,0,0), (0,155,30), (255,200,50)] TextColorsVoll = [(0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0)] TextColorsOffen = [(0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0), (0,0,0)]#Farbe für Zahl in hohlen Notenköpfen def addColorHead(noteObj, head, color, number): duration = noteObj.duration() # Viertelkopf: 229 capella3Code = "å" TextColors = TextColorsVoll x32offset = 0 if number > 9: x32offset = -0.3 # ??? fontHeight = 5# Schriftgröße viertelnote - orginal4 if duration >= Rational(1,1): capella3Code = "ã" x32offset = 0.3# verschieben der Zahl horizontal - orginal 0.3 fontHeight = 5# Schriftgröße hohle Notenköpfe - orginal3 TextColors = TextColorsOffen elif duration >= Rational(1,2): capella3Code = "ä" x32offset = 0.05 fontHeight = 5# Schriftgröße hohle Notenköpfe - orginal3 TextColors = TextColorsOffen r,g,b = ColorValues[color] rgb = 256*((256*b)+g)+r y32 = 0 capFont = {"face":"capella3", "pitchAndFamily":2, "charSet":2, "height":18.14,"color":rgb}#Notenkopf leicht vergrößert - height original 18 drawObj = {"type":"text", "vertAlign":1, "x":0.03, "y":y32,"content":capella3Code, "tag":"035401-1", "font":capFont} noteObj.addDrawObj(drawObj) if number > 0: y32 = 0.95# verschieben der Zahl vertikal x32 = -0.9 + x32offset# verschieben der Zahl horizontal -nach links r,g,b = TextColors[color] rgb = 256*((256*b)+g)+r arialFont = {"face":"Arial", "height":fontHeight, "weight":700, "color":rgb} drawObjN = {"type":"text", "vertAlign":1, "x":x32, "y":y32,"content":str(number), "tag":"035401-1", "font":arialFont} noteObj.addDrawObj(drawObjN) def getBuntCode(pitch): if OktavierenOhneSchluessel: pitch -= 12 if pitch >= 64: color = 5 fret = pitch - 64 elif pitch >= 59: color = 4 fret = pitch - 59 elif pitch >= 55: color = 3 fret = pitch - 55 elif pitch >= 50: color = 2 fret = pitch - 50 elif pitch >= 45: color = 1 fret = pitch - 45 else: color = 0 fret = pitch - 40 return color, fret def addColorHeadQuery(noteObj, head, color, number): # number 0 (nicht angezeigt), 1, 2, .. # color = Index in ColorNames comboCol = ComboBox(ColorNames, width=8, value = color) labelCol = Label("Farbe des Notenkopfes") hboxCol = HBox([comboCol, labelCol], padding = 4) editNum = Edit(str(number), width = 8, min=0,max=12) labelNum = Label("Zahl (0 = keine Zahl)") hboxNum = HBox([editNum, labelNum], padding = 4) box = VBox([hboxCol, hboxNum], padding=8) dlg = Dialog("Bitte Farbe und Zahl festlegen", box) if dlg.run(): chosenColor = comboCol.value() chosenNum = int(editNum.value()) # ggfls. alte bunte Note löschen nDrawO = noteObj.nDrawObjs() for i in range(nDrawO): thisDO = noteObj.drawObj(nDrawO-i-1) if thisDO.has_key("tag") and thisDO["tag"] == "35401-1": noteObj.deleteDrawObj(nDrawO-i-1) addColorHead(noteObj, head, chosenColor, chosenNum) def main(): if activeScore(): (sy1, st1, vo1, ob1),(sy2, st2, vo2, ob2) = curSelection() if sy1 == sy2 and st1 == st2 and vo1 == vo2: if ob1 == ob2: activeScore().registerUndo("bunte Noten") for noteObj in activeScore().noteObjs(): if noteObj.isChord(): if noteObj.nHeads() > 1: continue nDrawO = noteObj.nDrawObjs() for i in range(nDrawO): thisDO = noteObj.drawObj(nDrawO-i-1) if thisDO.has_key("tag") and thisDO["tag"] == "35401-1": noteObj.deleteDrawObj(nDrawO-i-1) for head in noteObj.heads(): color, fret = getBuntCode(head.chromaticPitch()) addColorHead(noteObj, head, color, fret) elif ob1+1 == ob2: activeScore().registerUndo("bunte Note ändern") voice = activeScore().system(sy1).staff(st1).voice(vo1) if ob1 < voice.nNoteObjs(): noteObj = voice.noteObj(ob1) if noteObj.isChord(): if noteObj.nHeads() > 1: messageBox("bunte-noten","Mehrere Köpfe am Hals nicht unterstützt") return for head in noteObj.heads(): color, fret = getBuntCode(head.chromaticPitch()) addColorHeadQuery(noteObj, head, color, fret) main()