# -*- coding: ISO-8859-1 -*- """ capellaScript -- Copyright (c) 2010 Peter Becker >>> ChorAlong Lautstärke für eine einzelne Stimmen hervorheben|| Achtung: In der Partitur muss für jede Stimme ein Klang ausgewählt sein ! Steht unter Klang "wie .. " wird diese Stimme nicht zur Auswahl angegeben !|| Bei Problemen bitte eine Mail an peter_becker@freenet.de <<< Choir Along (bring out a voice)

Heigthening the volume of single voices.

Beware: In the score for every voice a sound has to be selected ! If it says 'as ..' under Sound, this voice is not given as an option !

if one wishes to save an actual situation, than the script therefore produces the file '[FILE NAME].CAL'.

In case of problems plese mail to to peter_becker@freenet.de

ChorAlong (eine Stimme hervorheben)

Lautstärke für eine einzelne Stimmen hervorheben.

Achtung: In der Partitur muss für jede Stimme ein Klang ausgewählt sein ! Steht unter Klang 'wie .. ' wird diese Stimme nicht zur Auswahl angegeben !

Wenn man einen aktuellen Zustand sichern will, erzeugt das Skript dazu die Datei '[DATEINAME].CAL'.

Bei Problemen bitte eine Mail an peter_becker@freenet.de

Choir Along (een stem laten uitkomen)

Volume voor afzonderlijke stemmen verhogen.

Let op: In de partituur moet voor elke stem een klank geselecteerd zijn ! Staat onder klank 'als (of hoe) .. ', dan wordt deze stem niet ter keuze voorgelegd !

Kiest men voor vastlegen van een actuele situatie, dan maakt het script daartoe het bestand '[BESTANDSNAAM].CAL' aan.

Bij problemen graag een mail naar peter_becker@freenet.de

History: 03.08.2010 - Erste Ausgabe 4-stimmig, 4 Notenzeilen System 14.08.2010 - Anzahl Stimmen und Zeilen beliebig 24.08.2010 - Balance und Original sichern und wiederherstellen 27.08.2010 - Sicherung dateiabhängig machen 30.08.2010 - Wording im Menu angepasst 19.05.2012 - unterschiedliche Instrumente für laut und leise 04.07.2012 - Zusatz: voreingestellte Instrumente beibehalten 16.10.2012 - 2.1.1 PB vor hervorheben auf Originalzustand zurücksetzen 24.10.2012 - 2.1.2 PB Fagott hinzugefügt 26.12.2018 - 2.1.3 PB Oboe hinzugefügt 04.01.2018 - 2.1.4 PB Menü überarbeitet 21.01.2019 - 2.1.5 WW Internationalisierung (en-de-nl); Dialog stabilisiert ; Nummerierung der Stimmen cnt+1 (gemäß capella) 06.01.2020 - 2.1.6 PB Klarinette hinzugefügt 06.01.2020 - 2.1.7 PB Englischhorn hinzugefügt """ english = { 'grandpiano' :'Grand piano', 'choirA' :'Choir Aahs', 'voiceO' :'Voice Oohs', 'soprano' :'Soprano', 'alto' :'Alto', 'tenor' :'Tenor', 'bass' :'Bass', 'violin' :'Violin', 'viola' :'Viola', 'cello' :'Cello', 'contrabass' :'Contrabass', 'flute' :'Flute', 'bassoon' :'Bassoon', 'oboe' :'Oboe', 'clarinet' :'Clarinet', 'englishhorn' :'Englishhorn', 'savePreset' :'Retain presetting', 'wrongInstVolume' :'Wrong setting - Volume', 'permitRangeVol' :' Permitted range : 0 to 127 ', 'wrongInstBalance' :'Wrong setting - Balance', 'permitRangeBal' :' Permitted range : -64 to 63 ', 'fileNoValidSaving' :'There is no valid safeguarding for this file.', 'savingNotStaffLayout' :'The extant file safeguarding does not agree with the staff lay-out of the actual file.', 'bringOutVoice' :'Bring out a voice', 'saveSituation' :'Safeguard actual situation', 'restoreSavedSituation' :'Restore safeguarded situation', 'bringOut' :' is brought out.', 'VolBalEqual' :'All voices equally loud. Balance in the middle.', 'VolBal' :' Volume Balance ', 'text1' :'BEWARE :', 'text2' :'The voice designation comes from the field \n\'Description\' of the staff lay-out.', 'text3' :'More voices in a staff are numbered consecutively,', 'text4' :'but only, when they are also visible in the staff lay-out.', 'text5' :'For every voice an own sound has to be defined.', 'text6' :'If it says under Sound \'as .. \' , this voice will not be \ndisplayed with the voice selection !', 'text7' :'Balance and display with separate regulation of more ', 'text8' :'voices per staff are not supported before Capella 7.', 'loud' :'LOUD ', 'soft' :'SOFT ', 'volume' :'Volume', 'balance' :'Balance', 'basicSettings' :'Basic settings', 'selFunction' :'Select function', 'voiceStaffLayout' :'Select voice from Staff Lay-out', 'settingsLoud' :'Settings - Loud', 'settingsSoft' :'Settings - Soft', 'header' :'Choir Along (bring out a voice) Version : ', } german = { 'grandpiano' :'Konzertflügel', 'choirA' :'Chor a singend', 'voiceO' :'Stimme o singend', 'soprano' :'Sopran', 'alto' :'Alt', 'tenor' :'Tenor', 'bass' :'Bass', 'violin' :'Violine', 'viola' :'Bratsche', 'cello' :'Cello', 'contrabass' :'Kontrabass', 'flute' :'Flöte', 'bassoon' :'Fagott', 'oboe' :'Oboe', 'clarinet' :'Klarinette', 'englishhorn' :'Englischhorn', 'savePreset' :'Voreinstellung beibehalten', 'wrongInstVolume' :'falsche Voreinstellung - Lautstärke', 'permitRangeVol' :' erlaubte Bandbreite 0 bis 127 ', 'wrongInstBalance' :'falsche Voreinstellung - Balance', 'permitRangeBal' :' erlaubte Bandbreite -64 bis 63 ', 'fileNoValidSaving' :'Es existiert keine gültige Sicherung für diese Datei.', 'savingNotStaffLayout' :'Die vorhandene Dateisicherung entspricht nicht dem Mustersystem \nder aktuellen Datei.', 'bringOutVoice' :'Stimme hervorheben', 'saveSituation' :'aktuellen Zustand sichern', 'restoreSavedSituation' :'gesicherten Zustand wiederherstellen', 'bringOut' :' hervorheben', 'VolBalEqual' :'Alle Stimmen gleich (Laut). Balance auf Mitte.', 'VolBal' :' Lautstärke Balance ', 'text1' :'ACHTUNG : ', 'text2' :'Die Stimmbezeichnung wird aus dem Feld \n\'Beschreibung\' des Mustersystems übernommen.', 'text3' :'Mehrere Stimmen in einer Zeile werden durchnummeriert,', 'text4' :'aber nur, wenn sie im Mustersystem als eigene Stimme \nsichtbar sind.', 'text5' :'Für jede Stimme muss ein eigener Klang definiert werden.', 'text6' :'Steht unter Klang \'wie .. \' wird diese Stimme bei der\nAuswahl nicht angezeigt !', 'text7' :'Balance und Anzeige mit getrennter Reglung mehrerer ', 'text8' :'Stimmen pro Zeile ist erst ab Capella V7 unterstützt. ', 'loud' :'LAUT ', 'soft' :'LEISE ', 'volume' :'Lautstärke', 'balance' :'Balance', 'basicSettings' :'Grundeinstellungen', 'selFunction' :'Funktion auswählen', 'voiceStaffLayout' :'Stimme aus Mustersystem auswählen', 'settingsLoud' :'Einstellungen - Laut', 'settingsSoft' :'Einstellungen - Leise', 'header' :'ChorAlong (eine Stimme hervorheben) Version : ', 'version' :' Version : ' } dutch = { 'grandpiano' :'Concertvleugel', 'choirA' :'Koor a zingend', 'voiceO' :'Stem o zingend', 'soprano' :'Sopraan', 'alto' :'Alt', 'tenor' :'Tenor', 'bass' :'Bas', 'violin' :'Viool', 'viola' :'Altviool', 'cello' :'Cello', 'contrabass' :'Contrabas', 'flute' :'Fluit', 'bassoon' :'Fagot', 'oboe' :'Hobo', 'clarinet' :'Klarinet', 'englishhorn' :'Engelse hoorn', 'savePreset' :'Vóórinstelling behouden', 'wrongInstVolume' :'Onjuiste instelling - Volume', 'permitRangeVol' :' Toegestane waarden van 0 tot en met 127 ', 'wrongInstBalance' :'Onjuiste instelling - Balans', 'permitRangeBal' :' Toegestane waarden van -64 tot en met 63 ', 'fileNoValidSaving' :'Er bestaat geen geldige veiligstelling voor dit bestand.', 'savingNotStaffLayout' :'De aanwezige veiligstelling van dit bestand komt niet overeen \nmet het partituursjabloon van het actuele bestand.', 'bringOutVoice' :'Stem laten uitkomen', 'saveSituation' :'Actuele situatie veiligstellen', 'restoreSavedSituation' :'Veiliggestelde situatie herstellen', 'bringOut' :' laten uitkomen', 'VolBalEqual' :'Alle stemmen even luid. Balans in het midden.', 'VolBal' :' Volume Balans ', 'text1' :'LET OP : ', 'text2' :'De stemaanduidingen zijn afkomstig uit het veld \n\'Beschrijving\' van het partituursjabloon. ', 'text3' :'Meerdere stemmen in één notenbalk worden', 'text4' :'doorgenummerd,echter, alleen wanneer ze ook in het \npartituursjabloon zichtbaar zijn. ', 'text5' :'Voor elke stem moet een eigen klank worden ', 'text6' :'gedefiniëerd. Staat onder Klank \'als (of hoe) .. \', dan \nwordt deze stem niet getoond bij de stemselectie !', 'text7' :'Balans en weergave met gescheiden regeling van ', 'text8' :'meerdere stemmen per notenbalk worden pas \nvanaf Capella 7 ondersteund.', 'loud' :'HARD ', 'soft' :'ZACHT ', 'volume' :'Volume', 'balance' :'Balans', 'basicSettings' :'Basisinstellingen', 'selFunction' :'Functie selecteren', 'voiceStaffLayout' :'Stem uit partituursjabloon selecteren', 'settingsLoud' :'Instellingen - Hard', 'settingsSoft' :'Instellingen - Zacht', 'header' :'Choir Along (een stem laten uitkomen) Versie : ' } try: setStringTable( ("en", english), ("de", german), ("nl", dutch)) except: def tr(s): return german[s] #--------------------------------------------------------- import xml.dom, tempfile import tkFont import Tkinter from caplib.capDOM import * from xml.dom.minidom import * from re import * from string import * import shelve version = '2.1.7' instrumente = dict( i1 = dict(name = tr('grandpiano'), midi='0', gen='hammer.piano.grandpiano' ), i2 = dict(name = tr('choirA'), midi='52', gen='voice.a' ), i3 = dict(name = tr('voiceO'), midi='53', gen='voice.o' ), i4 = dict(name = tr('soprano'), midi='52', gen='voice.soprano:soprano' ), i5 = dict(name = tr('alto'), midi='52', gen='voice.alto:alto' ), i6 = dict(name = tr('tenor'), midi='52', gen='voice.tenor:tenor' ), i7 = dict(name = tr('bass'), midi='52', gen='voice.bass:bass' ), i8 = dict(name = tr('violin'), midi='40', gen='bow.string.violin:soprano' ), i9 = dict(name = tr('viola'), midi='41', gen='bow.string.viola:alto' ), i10 = dict(name = tr('cello'), midi='42', gen='bow.string.cello:tenor' ), i11 = dict(name = tr('contrabass'), midi='43', gen='bow.string.contrabass:bass' ), i12 = dict(name = tr('flute'), midi='73', gen='wind.wood.flutes.flute:soprano' ), i13 = dict(name = tr('bassoon'), midi='70', gen='wind.wood.doublereed.bassoon:bass' ), i14 = dict(name = tr('oboe'), midi='68', gen='wind.wood.doublereed.oboe:soprano' ), i15 = dict(name = tr('clarinet'), midi='71', gen='wind.wood.singlereed.clarinet:alto' ), i16 = dict(name = tr('englishhorn'), midi='69', gen='wind.wood.englishhorn' ), i17 = dict(name = tr('savePreset'), midi='999', gen='none.none:none' ) ) #instlaut_midi = instrumente['i1']['midi'] #so wird das Dictionary abgefragt def changeDoc(score): global select,laut,leise,blaut,bleise,fun,anzahlStimmen,volume,balance,instrument,sample,genSound,options,opt,ilaut,ileise, genDevice #messageBox('vorz',str(select) + '\n' + str(laut) + '\n' + str(leise)) bandbreite = 'NOK' while bandbreite == 'NOK' : if pqDialog(score): instlaut_name = instrumente['i'+ str(ilaut+1)]['name'] instlaut_midi = instrumente['i'+ str(ilaut+1)]['midi'] instlaut_gen = instrumente['i'+ str(ilaut+1)]['gen'] instleise_name = instrumente['i'+ str(ileise+1)]['name'] instleise_midi = instrumente['i'+ str(ileise+1)]['midi'] instleise_gen = instrumente['i'+ str(ileise+1)]['gen'] if fun == 0: # Stimme hervorheben wiederherstellen(score) if int(laut) < 0 or int(laut) > 127 or int(leise) < 0 or int(leise) > 127: messageBox(tr('wrongInstVolume'),tr('permitRangeVol')) bandbreite = 'NOK' elif int(blaut) < -64 or int(blaut) > 63 or int(bleise) < -64 or int(bleise) > 63: messageBox(tr('wrongInstBalance'),tr('permitRangeBal')) bandbreite = 'NOK' else: bandbreite = 'OK' if select == anzahlStimmen: # alles laut layout = score.getElementsByTagName('layout')[0] staves = layout.getElementsByTagName('staves')[0] for sLs in staves.getElementsByTagName('staffLayout'): for snd in sLs.getElementsByTagName('sound'): snd.setAttribute('volume',str(laut)) snd.setAttribute('panorama','0') if instlaut_name <> tr('savePreset'): snd.setAttribute('instr',instlaut_midi) snd.setAttribute('sample',instlaut_name) snd.setAttribute('genericSound',instlaut_gen) else: cnt = 0 layout = score.getElementsByTagName('layout')[0] staves = layout.getElementsByTagName('staves')[0] for sLs in staves.getElementsByTagName('staffLayout'): for snd in sLs.getElementsByTagName('sound'): if cnt == select: snd.setAttribute('volume',str(laut)) snd.setAttribute('panorama',str(blaut)) if instlaut_name <> tr('savePreset'): snd.setAttribute('instr',instlaut_midi) snd.setAttribute('sample',instlaut_name) snd.setAttribute('genericSound',instlaut_gen) cnt = cnt + 1 else: snd.setAttribute('volume',str(leise)) snd.setAttribute('panorama',str(bleise)) if instleise_name <> tr('savePreset'): snd.setAttribute('instr',instleise_midi) snd.setAttribute('sample',instleise_name) snd.setAttribute('genericSound',instleise_gen) cnt = cnt + 1 elif fun == 1: # Zustand sichern volume = [] balance = [] instrument = [] sample = [] genSound = [] genDevice = [] layout = score.getElementsByTagName('layout')[0] staves = layout.getElementsByTagName('staves')[0] for sLs in staves.getElementsByTagName('staffLayout'): for snd in sLs.getElementsByTagName('sound'): vol = latin1_e(snd.getAttribute('volume')) if snd.hasAttribute('panorama'): pan = latin1_e(snd.getAttribute('panorama')) else: pan = '0' if snd.hasAttribute('instr'): ins = latin1_e(snd.getAttribute('instr')) else: ins = instlaut_midi if snd.hasAttribute('sample'): smp = latin1_e(snd.getAttribute('sample')) else: smp = instlaut_name if snd.hasAttribute('device'): dev = latin1_e(snd.getAttribute('device')) else: dev = '' if snd.hasAttribute('genericSound'): snd = latin1_e(snd.getAttribute('genericSound')) else: snd = instlaut_gen volume.append(vol) balance.append(pan) instrument.append(ins) sample.append(smp) genSound.append(snd) genDevice.append(dev) saveStandart(score,volume,balance,instrument,sample,genSound,genDevice) else: # Zustand wiederherstellen bandbreite = 'OK' wiederherstellen(score) else: bandbreite = 'OK' # entspricht Abbruch def wiederherstellen(score): volorg = [] balorg = [] layout = score.getElementsByTagName('layout')[0] staves = layout.getElementsByTagName('staves')[0] for sLs in staves.getElementsByTagName('staffLayout'): for snd in sLs.getElementsByTagName('sound'): vol = latin1_e(snd.getAttribute('volume')) if snd.hasAttribute('panorama'): pan = latin1_e(snd.getAttribute('panorama')) else: pan = '0' volorg.append(vol) balorg.append(pan) cnt = 0 status = restoreStandart(score) if status == 'NOK': messageBox('RESTORE STATUS1',tr('fileNoValidSaving')) return if len(volorg) <> len(volume): messageBox('RESTORE STATUS2',tr('savingNotStaffLayout')) return layout = score.getElementsByTagName('layout')[0] staves = layout.getElementsByTagName('staves')[0] for sLs in staves.getElementsByTagName('staffLayout'): for snd in sLs.getElementsByTagName('sound'): vol = volume bal = balance ins = instrument smp = sample gsd = genSound dev = genDevice snd.setAttribute('volume',str(vol[cnt])) snd.setAttribute('panorama',str(bal[cnt])) snd.setAttribute('instrument',str(ins[cnt])) snd.setAttribute('sample',str(smp[cnt])) snd.setAttribute('genericSound',str(gsd[cnt])) snd.setAttribute('device',str(dev[cnt])) cnt = cnt + 1 return def restoreStandart(score): global volume, balance, instrument, sample, genSound, genDevice path = upper(activeScore().pathName()) if path.endswith('CAPX') == 1: path=path.rstrip('CAPX') else: path=path.rstrip('CAP') StandartSave = shelve.open(path + 'CAL') if StandartSave.has_key('V'): volume = StandartSave['V'] balance = StandartSave['B'] instrument = StandartSave['I'] sample = StandartSave['S'] genSound = StandartSave['G'] genDevice = StandartSave['D'] status = 'OK' else: status = 'NOK' StandartSave.close() return status def saveStandart(score,volume,balance,instrument,sample,genSound, genDevice): path = upper(activeScore().pathName()) if path.endswith('CAPX') == 1: path=path.rstrip('CAPX') else: path=path.rstrip('CAP') StandartSave = shelve.open(path + 'CAL') daten = {'V':volume,'B':balance,'I':instrument,'S':sample,'G':genSound,'D':genDevice} #messageBox('DAT',str(daten)) StandartSave.update(daten) StandartSave.close() def pqDialog(score): global select,laut,leise,fun,anzahlStimmen,blaut,bleise,volume,options,opt,ilaut,ileise lt = '100' ls = '50' bls = '-64' blt = '63' fn = '0' iLt = '0' iLs = '0' options = ScriptOptions() opt = options.get() instrum = [] stimmen = [] instrumCnt = len(instrumente) cnt = 0 while cnt <> instrumCnt: iName = instrumente['i'+ str(cnt+1)]['name'] instrum.append(iName) cnt = cnt + 1 radioILt = Radio(instrum, value=int(opt.get('iLt',0))) vBoxILt = VBox([radioILt],text='Instrument') radioILs = Radio(instrum, value=int(opt.get('iLs',0))) vBoxILs = VBox([radioILs],text='Instrument') funktion = [tr('bringOutVoice'),tr('saveSituation'),tr('restoreSavedSituation')] layout = score.getElementsByTagName('layout')[0] staves = layout.getElementsByTagName('staves')[0] for sLs in staves.getElementsByTagName('staffLayout'): desc = sLs.getAttribute('description') cnt = 0 for snd in sLs.getElementsByTagName('sound'): element = latin1_e(desc + '-' + str(cnt+1) + tr('bringOut')) ## WW 'cnt+1' war 'cnt' stimmen.append(element) cnt = cnt + 1 stimmen.append(tr('VolBalEqual')) anzahlStimmen = len(stimmen)-1 radioF = Radio(funktion, value=int(opt.get('fn', 0))) lablTitel = Label(tr('VolBal')) lablLeer = Label(' ') lablText1 = Label(tr('text1'),width=40) ## (WW) vBoxLbl stabilisiert (u.a.m. 'width=40 und mehr 'lab1Leer'-Zeilen) lablText2 = Label(tr('text2'),width=40) lablText3 = Label(tr('text3'),width=40) lablText4 = Label(tr('text4'),width=40) lablText5 = Label(tr('text5'),width=40) lablText6 = Label(tr('text6'),width=40) lablText7 = Label(tr('text7'),width=40) lablText8 = Label(tr('text8'),width=40) lablText9 = Label(tr('text9'),width=40) lablLaut = Label(tr('loud'),width=6) editLaut = Edit (opt.get('lt',str(lt)),width=4) editBLaut = Edit (opt.get('blt',str(blt)),width=4) lablLeise = Label(tr('soft'),width=6) editLeise = Edit (opt.get('ls',str(ls)),width=4) editBLeise = Edit (opt.get('bls',str(bls)),width=4) radioS = Radio(stimmen, value=int(opt.get('sel', 0))) vBoxVolLs = HBox([editLeise,lablLeer],text=tr('volume')) vBoxVolLt = HBox([editLaut,lablLeer],text=tr('volume')) vBoxBalLs = HBox([editBLeise,lablLeer],text=tr('balance')) vBoxBalLt = HBox([editBLaut,lablLeer],text=tr('balance')) hBoxEstLs = HBox([vBoxVolLs,vBoxBalLs],text=tr('basicSettings')) hBoxEstLt = HBox([vBoxVolLt,vBoxBalLt],text=tr('basicSettings')) vBoxLbl = VBox([lablLeer,lablText1,lablLeer,lablText2,lablLeer,lablText3,lablText4, lablLeer,lablText5,lablText6,lablLeer,lablText7,lablText8]) vBoxF = VBox([radioF,lablLeer,vBoxLbl],text=tr('selFunction')) vBoxS = VBox([radioS],text=tr('voiceStaffLayout')) vBoxLaut = VBox([vBoxILt,hBoxEstLt],text=tr('settingsLoud')) vBoxLeise = VBox([vBoxILs,hBoxEstLs],text=tr('settingsSoft')) hBoxT = HBox([vBoxF,vBoxS,vBoxLaut,vBoxLeise]) box = VBox([hBoxT]) dlg = Dialog(tr('header') + str(version), box) if dlg.run(): select = radioS.value() fun = radioF.value() laut = editLaut.value() leise = editLeise.value() bleise = editBLeise.value() blaut = editBLaut.value() ilaut = radioILt.value() ileise = radioILs.value() opt.update(dict(sel=select, lt=laut, ls=leise, blt=blaut, bls=bleise, iLt = ilaut, iLs = ileise)) options.set(opt) return True else: return False def latin1_e(u): return u.encode('Latin-1') #return u.encode() # Hauptprogramm: from caplib.capDOM import ScoreChange import tempfile class ScoreChange(ScoreChange): def changeScore(self, score): changeDoc(score) if activeScore(): global tempInput, tempOutput activeScore().registerUndo("ChorAlong") tempInput = tempfile.mktemp('.capx') tempOutput = tempfile.mktemp('.capx') activeScore().write(tempInput) ScoreChange(tempInput, tempOutput) activeScore().read(tempOutput) os.remove(tempInput) os.remove(tempOutput)