/* Tempo Change (tchange) by Warren Porter for use in the Semware Editor * No warrenty is implied. This is experimental code and user takes all * risks. * * Before using this macro, play (or start to play) your NWC2 selection * and note the duration of it. You will be prompted for this time as * well as for the duration you want. * * Usage * 1. Be sure all Tempo marks and MPC tempo changes are only on one staff. * 2. Select the entire staff and cut it to the clipboard. * 3. Start TSE (The Semware Editor). * 4. If TSE is not configured to start this macro automatically, copy the contents of the system clipboard into your edit space and start this macro. * 5. Answer the prompts one at a time. To enter zero minutes or zero seconds, just press "Enter". Otherwise, press "Enter" after typing the requested time. * 6. Unless automatically configured, select the entire edit space and copy it to the system clipboard. * 7. Paste the clipboard back into the staff you cut in step 2. Shut down TSE if necessary. */ proc Main() integer curr_line = 2 integer last_line integer org_min = 0, org_sec = 0, new_min = 0, new_sec = 0 integer old_tempo, new_tempo string old_tempo_str[10] = "", new_tempo_str[10] = "" // PasteFromWinClip() For use in a TSE shortcut while in NWC2 AskNumeric("Old tempo minutes: ", old_tempo_str) org_min = val(old_tempo_str) old_tempo_str = "" AskNumeric("Old tempo seconds: ", old_tempo_str) org_sec = val(old_tempo_str) AskNumeric("New tempo minutes: ", new_tempo_str) new_min = val(new_tempo_str) new_tempo_str = "" AskNumeric("New tempo seconds: ", new_tempo_str) new_sec = val(new_tempo_str) org_sec = org_min * 60 + org_sec new_sec = new_min * 60 + new_sec Message("Existing tempos will be multiplied by ",org_sec, " / ", new_sec) last_line = NumLines() - 1 while last_line > curr_line GotoLine(curr_line) //Place cursor at beginning of "curr_line" GotoColumn(1) if lFind("^\|Tempo.*\|Tempo:","xc") lFind("[0-9]#","xc") old_tempo_str = GetFoundText() old_tempo = Val(old_tempo_str) new_tempo = old_tempo * org_sec / new_sec new_tempo_str = Str(new_tempo) lReplace(old_tempo_str,new_tempo_str,"cn1") endif if lFind("MPC|Controller:tempo","c") if lFind("Pt0:","c") lFind("{[0-9]#},{[0-9]#}","xc") old_tempo_str = GetFoundText(2) // Warn("Found 0: ", old_tempo_str, " on line ", curr_line) old_tempo = Val(old_tempo_str) new_tempo = old_tempo * org_sec / new_sec new_tempo_str = Str(new_tempo) lReplace(old_tempo_str,new_tempo_str,"cn1") endif if lFind("Pt1:","c") lFind("{[0-9]#},{[0-9]#}","xc") old_tempo_str = GetFoundText(2) // Warn("Found 1: ", old_tempo_str, " on line ", curr_line) old_tempo = Val(old_tempo_str) new_tempo = old_tempo * org_sec / new_sec new_tempo_str = Str(new_tempo) lReplace(old_tempo_str,new_tempo_str,"cn1") endif if lFind("Pt2:","c") lFind("{[0-9]#},{[0-9]#}","xc") old_tempo_str = GetFoundText(2) // Warn("Found 2: ", old_tempo_str, " on line ", curr_line) old_tempo = Val(old_tempo_str) new_tempo = old_tempo * org_sec / new_sec new_tempo_str = Str(new_tempo) lReplace(old_tempo_str,new_tempo_str,"cn1") endif if lFind("Pt3:","c") lFind("{[0-9]#},{[0-9]#}","xc") old_tempo_str = GetFoundText(2) // Warn("Found 3: ", old_tempo_str, " on line ", curr_line) old_tempo = Val(old_tempo_str) new_tempo = old_tempo * org_sec / new_sec new_tempo_str = Str(new_tempo) lReplace(old_tempo_str,new_tempo_str,"cn1") endif if lFind("Pt4:","c") lFind("{[0-9]#},{[0-9]#}","xc") old_tempo_str = GetFoundText(2) // Warn("Found 4: ", old_tempo_str, " on line ", curr_line) old_tempo = Val(old_tempo_str) new_tempo = old_tempo * org_sec / new_sec new_tempo_str = Str(new_tempo) lReplace(old_tempo_str,new_tempo_str,"cn1") endif endif curr_line = curr_line + 1 endwhile /* BegFile() These 8 lines used in a TSE shortcut BegLine() MarkColumn() EndFile() GoToColumn(255) MarkColumn() CopyToWinClip() AbandonEditor() */ end