-
Notifications
You must be signed in to change notification settings - Fork 0
/
sib2hum_0.05.plg
1445 lines (1217 loc) · 90.5 KB
/
sib2hum_0.05.plg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
Initialize "(){ AddToPluginsMenu('Convert Sibelius Score to Humdrum','Run');
// The following enables the latest behavior for the ManuScript interpreter.
// If you intend your plugin to run on previous versions of Sibelius where that functionality
// didn't exist, you will likely have to revisit the following:
if (Sibelius.ProgramVersion > 20200600) {
SetInterpreterOption(TreatSingleCharacterAsString);
SetInterpreterOption(SupportHalfSemitonePitchValues);
} }"
Run "() {
// Convert Sibelius Score to Humdrum Kern Format
// Version 0.05
// Written by: Hubert Léveillé Gauvin
// Date: January - February 2022
// NOTE: TUPLETS ARE NOT SUPPORTED AT THE MOMENT
// GRACE NOTES ARE NOT SUPPORTED AT THE MOMENT (they are ignored by NoteRestAtBarPosVoice)
clefDictionary = CreateClefDictionary();
instrumentDictionary = CreateInstrumentDictionary();
keySignatureDictionary = CreateKeySignatureDictionary();
specialBarlineDictionary = CreateSpecialBarlineDictionary();
durationDictionary = CreateDurationDictionary();
pitchDictionary = CreatePitchDictionary();
thisScore = Sibelius.ActiveScore;
sysStaff = thisScore.SystemStaff;
barlines = thisScore.Barlines;
// Create blank text file
fname = '';
fname = Sibelius.GetDocumentsFolder();
fname = fname & 'sib2humtest.krn';
Sibelius.CreateTextFile(fname);
// Get info from File > Score Info, reformat for Humdrum and append to file
AppendScoreInfoToFile(fname);
// Add Exclusive interpretations
/* Assume for the moment that everything **kern */
humExclusiveInterpretationsLine = '';
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
if (currentStaff = 1)
{
humExclusiveInterpretationsLine = humExclusiveInterpretationsLine & '\*\*kern'; // if last staff, dont add tab at the end
} else {
humExclusiveInterpretationsLine = humExclusiveInterpretationsLine & '\*\*kern' & '\t';
}
currentStaff = currentStaff-1;
}
// Add Exclusive interpretations to krn file
Sibelius.AppendLineToFile(fname,humExclusiveInterpretationsLine);
// Get name of instruments
humInstrumentLine = '';
humInstrumentNameFirstSystemLine = '';
humInstrumentNameSubSytemLine = '';
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
/* In a perfect world, we would print parts in reverse order because Humdrum scores are printed lowest
part first going towards highest, but Sib numbering is from highest to lowest. Doesn't have a functional impact, but this is how C.Sapp does it so...*/
if (currentStaff = 1)
{
humInstrumentLine = humInstrumentLine & ConvertInstrumentCode(s.InitialStyleId,instrumentDictionary); // if last staff, dont add tab at the end
humInstrumentNameFirstSystemLine = humInstrumentNameFirstSystemLine & '*I' & Chr(34) & s.FullInstrumentName ;
humInstrumentNameSubSytemLine = humInstrumentNameSubSytemLine & '*I\'' & s.ShortInstrumentName ;
} else {
humInstrumentLine = humInstrumentLine & ConvertInstrumentCode(s.InitialStyleId,instrumentDictionary) & '\t';
humInstrumentNameFirstSystemLine = humInstrumentNameFirstSystemLine & '*I' & Chr(34) & s.FullInstrumentName & '\t';
humInstrumentNameSubSytemLine = humInstrumentNameSubSytemLine & '*I\'' & s.ShortInstrumentName & '\t';
}
currentStaff = currentStaff-1;
}
//Add Humdrum Instrument Line to krn file
Sibelius.AppendLineToFile(fname,humInstrumentLine);
Sibelius.AppendLineToFile(fname,humInstrumentNameFirstSystemLine);
Sibelius.AppendLineToFile(fname,humInstrumentNameSubSytemLine);
// Convert Inital clef name
humInitialClefLine = '';
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
if (currentStaff = 1)
{
humInitialClefLine = humInitialClefLine & ConvertClef(s.InitialClefStyleId,clefDictionary); // if last staff, don't add tab at the end
} else {
humInitialClefLine = humInitialClefLine & ConvertClef(s.InitialClefStyleId,clefDictionary) & '\t';
}
currentStaff = currentStaff-1;
}
//Add Humdrum Clef Line to krn file
Sibelius.AppendLineToFile(fname,humInitialClefLine);
// Convert Initial Key Signature
initialKeySignature = thisScore.SystemStaff.InitialKeySignature.Sharps;
currentKeySignature = initialKeySignature;
humInitialKeySignatureLine = '';
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
if (currentStaff = 1) // if last staff, don't add tab at the end
{
if (ConvertClef(s.InitialClefStyleId,clefDictionary) = '*clefX') // if clef is percussion, no key sig
{
humInitialKeySignatureLine = humInitialKeySignatureLine & '*';
} else {
humInitialKeySignatureLine = humInitialKeySignatureLine & ConvertKeySignature(initialKeySignature,keySignatureDictionary);
}
} else {
if (ConvertClef(s.InitialClefStyleId,clefDictionary) = '*clefX' ) // if clef is percussion, no key sig
{
humInitialKeySignatureLine = humInitialKeySignatureLine & '*' & '\t';
} else {
humInitialKeySignatureLine = humInitialKeySignatureLine & ConvertKeySignature(initialKeySignature,keySignatureDictionary) & '\t';
}
}
currentStaff = currentStaff-1;
}
//Add Humdrum Initial Key Signature Line to krn file
Sibelius.AppendLineToFile(fname,humInitialKeySignatureLine);
// Convert Initial Time Signature
initialTimeSignature = thisScore.SystemStaff.CurrentTimeSignature(1);
currentTimeSignature = initialTimeSignature;
humInitialTimeSignatureLine = '';
initialTimeSignatureArray = ConvertTimeSignature(initialTimeSignature.Numerator,initialTimeSignature.Denominator,initialTimeSignature.Text);
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
if (currentStaff = 1)
{
humInitialTimeSignatureLine = humInitialTimeSignatureLine & initialTimeSignatureArray[0] ; // if last staff, don't add tab at the end
} else {
humInitialTimeSignatureLine = humInitialTimeSignatureLine & initialTimeSignatureArray[0] & '\t';
}
currentStaff = currentStaff-1;
}
//Add Humdrum Initial Time Signature Line to krn file
Sibelius.AppendLineToFile(fname,humInitialTimeSignatureLine);
//Check if meter info exists (e.g. common-time), and if so add to krn file
if (initialTimeSignatureArray[1] != '')
{
humInitialMeterLine = '';
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
if (currentStaff = 1)
{
humInitialMeterLine = humInitialMeterLine & initialTimeSignatureArray[1] ; // if last staff, don't add tab at the end
} else {
humInitialMeterLine = humInitialMeterLine & initialTimeSignatureArray[1] & '\t';
}
currentStaff = currentStaff-1;
}
//Add Humdrum Initial Meter Line to krn file
Sibelius.AppendLineToFile(fname,humInitialMeterLine);
}
// Create a humline with the barline before First Measure
// According to C.Sapp, 'Labeling the first bar is necessary if you need to extract it by measure number with a tool such as myank.'
nextExternalBarNumber = sysStaff.NthBar(1).ExternalBarNumberString;
x = 1;
sblCount = 1;
startsWithRepeat = false;
// this is not elegant, but basically see if there's a start repeat in bar 1
for each SpecialBarline sbl in sysStaff.NthBar(1)
{
if (sblCount = 1)
{
if (sbl.BarlineInternalType = SpecialBarlineStartRepeat)
{
startsWithRepeat = true;
startRepeat = sbl.BarlineInternalType;
}
}
}
if (nextExternalBarNumber = '')
{
if (startsWithRepeat = false)
{
thisMeasureBarline = '=-';
} else {
thisMeasureBarline = '=' & '1' & ConvertSpecialBarlineCode(startRepeat,specialBarlineDictionary);
}
} else {
if (startsWithRepeat = false)
{
thisMeasureBarline = '=' & nextExternalBarNumber;
} else {
thisMeasureBarline = '=' & nextExternalBarNumber & ConvertSpecialBarlineCode(startRepeat,specialBarlineDictionary);
}
}
humBarlineLine = '';
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
if (currentStaff = 1)
{
humBarlineLine = humBarlineLine & thisMeasureBarline ; // if last staff, don't add tab at the end
} else {
humBarlineLine = humBarlineLine & thisMeasureBarline & '\t';
}
currentStaff = currentStaff-1;
}
//Add Humdrum Barline Line to krn file
Sibelius.AppendLineToFile(fname,humBarlineLine);
addNewKeySignature = false;
addNewTimeSignature = false;
wholeBarRestTrackerArray = ResetWholeBarRestTracker();
for each Bar b in sysStaff
{
currentInternalBarNumber = b.BarNumber;
if (b.BarNumber < sysStaff.BarCount) // As long as not on the last bar
{
nextInternalBarNumber = currentInternalBarNumber+1;
nextExternalBarNumber = sysStaff.NthBar(nextInternalBarNumber).ExternalBarNumberString;
}
noteRestPositionArray = CreateSparseArray();
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
//get a list of all the unique NoteRest position for this bar, regardless of the staff
// NOTE: THIS DOESN'T WORK FOR TUPLETS
for each BarObject in s.NthBar(currentInternalBarNumber)
{
if (BarObject.Type = 'BarRest')
{
if (BarObject.RestType = '0') // if RestType = WholeBarRest
{
wholeBarRestTrackerArray[currentStaff] = true ; // set the tracker for this staff to true
if (utils.IsInArray(noteRestPositionArray,0) = false) //add if 0 not already in array
{
noteRestPositionArray.Push(0); // Create an 'event' at position 0
}
}
} else {
if (BarObject.Type = 'NoteRest')
{
if (utils.IsInArray(noteRestPositionArray,BarObject.Position) = false) //add if not already in array
{
noteRestPositionArray.Push(BarObject.Position);
}
}
}
}
currentStaff=currentStaff-1;
}
// test if the time sig for this element is different than current.
if( currentTimeSignature.Text != sysStaff.CurrentTimeSignature(currentInternalBarNumber).Text)
{ currentTimeSignature = thisScore.SystemStaff.CurrentTimeSignature(currentInternalBarNumber);
addNewTimeSignature = true;
humNewTimeSignatureLine = '';
currentTimeSignatureArray = ConvertTimeSignature(currentTimeSignature.Numerator,currentTimeSignature.Denominator,currentTimeSignature.Text);
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
if (currentStaff = 1)
{
humNewTimeSignatureLine = humNewTimeSignatureLine & currentTimeSignatureArray[0] ; // if last staff, don't add tab at the end
} else {
humNewTimeSignatureLine = humNewTimeSignatureLine & currentTimeSignatureArray[0] & '\t';
}
currentStaff = currentStaff-1;
}
//Add Humdrum New Time Signature Line to krn file
Sibelius.AppendLineToFile(fname,humNewTimeSignatureLine);
//Check if meter info exists (e.g. common-time), and if so add to krn file
if (currentTimeSignatureArray[1] != '')
{
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
if (currentStaff = 1)
{
humNewMeterLine = humNewMeterLine & currentTimeSignatureArray[1] ; // if last staff, don't add tab at the end
} else {
humNewMeterLine = humNewMeterLine & currentTimeSignatureArray[1] & '\t';
}
currentStaff = currentStaff-1;
}
//Add Humdrum Initial Meter Line to krn file
Sibelius.AppendLineToFile(fname,humNewMeterLine);
}
}
// sort the array
noteRestPositionArray = utils.SortArrayNumeric(noteRestPositionArray,false);
// create one humLine per Rhythmic Position in noteRestPositionArray
line = '1';
for each e in noteRestPositionArray
{
humLine = '';
// test if the key sig for this element is different than current.
// NOTE: This method assumes that all staves have same key signature, which might not always be true...
if( currentKeySignature != b.GetKeySignatureAt(e).Sharps)
{ currentKeySignature = b.GetKeySignatureAt(e).Sharps;
addNewKeySignature = true;
}
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
if (wholeBarRestTrackerArray[currentStaff] = true) // if this measure is wholebarrest
{
kernToken = 'rr' ; // this is legal but not supported by Verovio reader. See this for how to do it properly https://doc.verovio.humdrum.org/humdrum/getting_started/#extended-rhythm-representation
wholeBarRestTrackerArray[currentStaff] = false ;
} else {
result = NoteRestAtBarPosVoice(s.NthBar(currentInternalBarNumber),e,1); // always voice 1 for now. Add loop here eventually
kernToken = '' ;
if (result != null)
{
humDuration = ConvertDuration(result.Duration,durationDictionary);
if (result.NoteCount = 0) // is NoteRest is rest
{
kernToken = humDuration & 'r'; //
} else {// if NoteRest is note or chord
for each n in result // for each note of chord
{
kernToken = kernToken & humDuration & ConvertPitch(n.DiatonicPitch,pitchDictionary,n.Accidental,n.IsAccidentalVisible) & ' ';
}
kernToken = utils.TrimBlanks(kernToken) ; // Remove that last space that was added in the loop above
}
} else { // if there is no event at that position in that bar, null token is needed
kernToken = '.';
}
}
if (currentStaff = 1)
{
humLine = humLine & kernToken ; // if last staff, don't add tab at the end
} else {
humLine = humLine & kernToken & '\t';
}
currentStaff = currentStaff-1;
}
// if addNewKeySignature is true, add a new key signature before adding Humdrum Line
// !!! IMPORTANT : NOTE HERE CHANGE INITIAL InitialClefStyleId WITH CURRENT CLEF STYLE ID WHEN THAT BIT IS FIXED
if (addNewKeySignature = true)
{
humNewKeySignatureLine = '';
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
if (currentStaff = 1) // if last staff, don't add tab at the end
{
if (ConvertClef(s.InitialClefStyleId,clefDictionary) = '*clefX') // if clef is percussion, no key sig
{
humNewKeySignatureLine = humNewKeySignatureLine & '*';
} else {
humNewKeySignatureLine = humNewKeySignatureLine & ConvertKeySignature(currentKeySignature,keySignatureDictionary);
}
} else {
if (ConvertClef(s.InitialClefStyleId,clefDictionary) = '*clefX' ) // if clef is percussion, no key sig
{
humNewKeySignatureLine = humNewKeySignatureLine & '*' & '\t';
} else {
humNewKeySignatureLine = humNewKeySignatureLine & ConvertKeySignature(currentKeySignature,keySignatureDictionary) & '\t';
}
}
currentStaff = currentStaff-1;
}
//Add New Key Signature Line to krn file
Sibelius.AppendLineToFile(fname,humNewKeySignatureLine);
addNewKeySignature = false ; // set back flag to false
}
//Add Humdrum Line to krn file
Sibelius.AppendLineToFile(fname,humLine);
line = line+1;
}
/* This bit is a train wreck, because of the different way in which Sib and Humdrum handles barlines.
The complicated bit is the end-repeat-start-repeat combinaision.
I need to look at special barlines always for the current and next barline
*/
specialBarline = false;
thisMeasureBarline = '';
x=1;
for each SpecialBarline sbl in b
{
specialBarline = true;
if (b.BarNumber = sysStaff.BarCount)
{
thisMeasureBarline = '=' & ConvertSpecialBarlineCode(sbl.BarlineInternalType,specialBarlineDictionary); // if final barline, no bar number
} else {
if (startsWithRepeat = true)
{
startsWithRepeat = false;
specialBarline = false;
} else {
thisMeasureBarline = '=' & nextExternalBarNumber & ConvertSpecialBarlineCode(sbl.BarlineInternalType,specialBarlineDictionary) & CreateTokenIfBarStartsWithStartRepeat(nextInternalBarNumber);
thisMeasureBarline = utils.Replace(thisMeasureBarline,'!!','!',false); // when there is end repeat followed by start repeat, this removes the superfluous !
if (CreateTokenIfBarStartsWithStartRepeat(nextInternalBarNumber) != '')
{
startsWithRepeat = true;
} else {
startsWithRepeat = false;
}
}
}
x=x+1;
}
if (specialBarline = false)
{
if (b.BarNumber = sysStaff.BarCount)
{
thisMeasureBarline = '=' ; //in the rare case where last measure does not have a special barline, make sure to not add a bar number
} else {
thisMeasureBarline = '=' & nextExternalBarNumber & CreateTokenIfBarStartsWithStartRepeat(nextInternalBarNumber) ;
thisMeasureBarline = utils.Replace(thisMeasureBarline,'!!','!',false);
if (CreateTokenIfBarStartsWithStartRepeat(nextInternalBarNumber) != '')
{
startsWithRepeat = true;
} else {
startsWithRepeat = false;
}
}
}
// Create a humline with the barline at the end of this measure
humBarlineLine = '';
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
if (currentStaff = 1)
{
humBarlineLine = humBarlineLine & thisMeasureBarline ; // if last staff, don't add tab at the end
} else {
humBarlineLine = humBarlineLine & thisMeasureBarline & '\t';
}
currentStaff = currentStaff-1;
}
//Add Humdrum Barline Line to krn file
Sibelius.AppendLineToFile(fname,humBarlineLine);
}
// create one Humdrum spine-path terminator Line
humSpinePathTerminatorLine = '';
currentStaff = thisScore.StaffCount;
while (currentStaff>0)
{
s = thisScore.NthStaff(currentStaff);
if (currentStaff = 1) // if last staff
{
humSpinePathTerminatorLine = humSpinePathTerminatorLine & '*-' ; // if last staff, don't add tab at the end
} else {
humSpinePathTerminatorLine = humSpinePathTerminatorLine & '*-' & '\t';
}
currentStaff = currentStaff-1;
}
//Add Humdrum spine-path terminator Line to krn file
Sibelius.AppendLineToFile(fname,humSpinePathTerminatorLine);
//Add final line that doesn't end with new line car
Sibelius.AppendTextFile(fname,'!! Converted from Sibelius with sib2hum plugin');
//Message Box at the end to know it's done is nice
Sibelius.MessageBox('Done! The file is available here; ' & fname);
}"
ConvertInstrumentCode "(InitialStyleId,instrumentDictionary) {
/* Instruments that are not currently mapped to a Humdrum equivalent will become **I?? for the moment */
if (instrumentDictionary[InitialStyleId] = '')
{
return '*I??';
} else {
return instrumentDictionary[InitialStyleId];
}}"
ConvertClef "(clefStyle,clefDictionary) {
/* Convert Sib clefs to Humdrum format using the dictionary createde with CreateClefDictionary() ;
I'm ignoring all TAB clefs for the moment; they will become *clef?? */
if (clefDictionary[clefStyle] = '')
{
return '*clef??';
} else {
return clefDictionary[clefStyle];
}
}"
CreateInstrumentDictionary "() {
instrumentDictionary = CreateDictionary(
'instrument.brass.cornet.a','*Icornt',
'instrument.brass.cornet.bflat','*Icornt',
'instrument.brass.cornet.soprano.eflat','*Icornt',
'instrument.brass.flugelhorn','*Iflugh',
'instrument.brass.horn.a.nokeysig','*Icor',
'instrument.brass.horn.alto.aflat.nokeysig','*Icor',
'instrument.brass.horn.alto.eflat','*Icor',
'instrument.brass.horn.alto.f','*Icor',
'instrument.brass.horn.b.nokeysig','*Icor',
'instrument.brass.horn.basso.a.nokeysig','*Icor',
'instrument.brass.horn.basso.bflat.nokeysig','*Icor',
'instrument.brass.horn.basso.c.nokeysig','*Icor',
'instrument.brass.horn.bflat.nokeysig','*Icor',
'instrument.brass.horn.c.nokeysig','*Icor',
'instrument.brass.horn.d.nokeysig','*Icor',
'instrument.brass.horn.dflat.nokeysig','*Icor',
'instrument.brass.horn.e.nokeysig','*Icor',
'instrument.brass.horn.eflat','*Icor',
'instrument.brass.horn.eflat.nokeysig','*Icor',
'instrument.brass.horn.f','*Icor',
'instrument.brass.horn.f.bassclef','*Icor',
'instrument.brass.horn.f.nokeysig','*Icor',
'instrument.brass.horn.fsharp.nokeysig','*Icor',
'instrument.brass.horn.g.nokeysig','*Icor',
'instrument.brass.horn.tenor','*Icor',
'instrument.brass.trombone','*Itromt',
'instrument.brass.trombone.bassclef.trebleclef','*Itromt',
'instrument.brass.trombone.tenor','*Itromt',
'instrument.brass.trombone.trebleclef','*Itromt',
'instrument.brass.trumpet.a','*Itromp',
'instrument.brass.trumpet.b.nokeysig','*Itromp',
'instrument.brass.trumpet.bflat','*Itromp',
'instrument.brass.trumpet.bflat.nokeysig','*Itromp',
'instrument.brass.trumpet.c','*Itromp',
'instrument.brass.trumpet.d','*Itromp',
'instrument.brass.trumpet.dflat','*Itromp',
'instrument.brass.trumpet.e.nokeysig','*Itromp',
'instrument.brass.trumpet.eflat','*Itromp',
'instrument.brass.trumpet.f','*Itromp',
'instrument.brass.trumpet.g.nokeysig','*Itromp',
'instrument.brass.tuba','*Ituba',
'instrument.brass.tuba.f','*Ituba',
'instrument.brass.tuba.tenor','*Ituba',
'instrument.brass.tuba.tenor.bassclef','*Ituba',
'instrument.brass.tuba.wagner.bflat','*Ituba',
'instrument.brass.tuba.wagner.f','*Ituba',
'instrument.fretted.banjo.5lines','*Ibanjo',
'instrument.fretted.banjo.aDADE.tab','*Ibanjo',
'instrument.fretted.banjo.aEADE.tab','*Ibanjo',
'instrument.fretted.banjo.gCGBD.tab','*Ibanjo',
'instrument.fretted.banjo.gCGCD.tab','*Ibanjo',
'instrument.fretted.banjo.gDFAD.tab','*Ibanjo',
'instrument.fretted.banjo.gDGBD.tab','*Ibanjo',
'instrument.fretted.banjo.gDGCD.tab','*Ibanjo',
'instrument.fretted.banjo.tenor.5lines','*Ibanjo',
'instrument.fretted.banjo.tenor.tab','*Ibanjo',
'instrument.fretted.guitar.resonator.5lines','*Iguitr',
'instrument.fretted.guitar.resonator.a6.tab','*Iguitr',
'instrument.fretted.guitar.resonator.b11.tab','*Iguitr',
'instrument.fretted.guitar.resonator.c#m.tab','*Iguitr',
'instrument.fretted.guitar.resonator.c6-a7.tab','*Iguitr',
'instrument.fretted.guitar.resonator.c6-highg.tab','*Iguitr',
'instrument.fretted.guitar.resonator.c6.tab','*Iguitr',
'instrument.fretted.guitar.resonator.cm7.tab','*Iguitr',
'instrument.fretted.guitar.resonator.e13-hawaiian.tab','*Iguitr',
'instrument.fretted.guitar.resonator.e13-western.tab','*Iguitr',
'instrument.fretted.guitar.resonator.open.A.tab','*Iguitr',
'instrument.fretted.guitar.resonator.open.G.tab','*Iguitr',
'instrument.fretted.dulcimer','*Idulc',
'instrument.fretted.dulcimer.5lines','*Idulc',
'instrument.fretted.dulcimer.daa.tab','*Idulc',
'instrument.fretted.dulcimer.dad.tab','*Idulc',
'instrument.fretted.guitar.12-string.5lines','*Iguitr',
'instrument.fretted.guitar.12-string.dadgad.tab','*Iguitr',
'instrument.fretted.guitar.12-string.double-d.tab','*Iguitr',
'instrument.fretted.guitar.12-string.dropped-d.tab','*Iguitr',
'instrument.fretted.guitar.12-string.open-d.tab','*Iguitr',
'instrument.fretted.guitar.12-string.open-e.tab','*Iguitr',
'instrument.fretted.guitar.12-string.open-g.tab','*Iguitr',
'instrument.fretted.guitar.12-string.tab','*Iguitr',
'instrument.fretted.guitar.12-string.tab.rhythms','*Iguitr',
'instrument.fretted.guitar.acoustic.5lines','*Iguitr',
'instrument.fretted.guitar.acoustic.dadgad.tab','*Iguitr',
'instrument.fretted.guitar.acoustic.double-d.tab','*Iguitr',
'instrument.fretted.guitar.acoustic.dropped-d.tab','*Iguitr',
'instrument.fretted.guitar.acoustic.modal-d.tab','*Iguitr',
'instrument.fretted.guitar.acoustic.nashville.tab','*Iguitr',
'instrument.fretted.guitar.acoustic.open-a.tab','*Iguitr',
'instrument.fretted.guitar.acoustic.open-c.tab','*Iguitr',
'instrument.fretted.guitar.acoustic.open-d.tab','*Iguitr',
'instrument.fretted.guitar.acoustic.open-dm.tab','*Iguitr',
'instrument.fretted.guitar.acoustic.open-e.tab','*Iguitr',
'instrument.fretted.guitar.acoustic.open-g.tab','*Iguitr',
'instrument.fretted.guitar.acoustic.tab','*Iguitr',
'instrument.fretted.guitar.acoustic.tab.rhythms','*Iguitr',
'instrument.fretted.guitar.bass.4-string.5lines','*Ibguit',
'instrument.fretted.guitar.bass.4-string.tab','*Ibguit',
'instrument.fretted.guitar.bass.5-string.5lines','*Ibguit',
'instrument.fretted.guitar.bass.5-string.tab','*Ibguit',
'instrument.fretted.guitar.bass.5lines','*Ibguit',
'instrument.fretted.guitar.bass.6-string.5lines','*Ibguit',
'instrument.fretted.guitar.bass.6-string.tab','*Ibguit',
'instrument.fretted.guitar.bass.electric.5-string.5lines','*Ibguit',
'instrument.fretted.guitar.bass.electric.5-string.tab','*Ibguit',
'instrument.fretted.guitar.bass.electric.5lines','*Ibguit',
'instrument.fretted.guitar.bass.electric.6-string.5lines','*Ibguit',
'instrument.fretted.guitar.bass.electric.6-string.tab','*Ibguit',
'instrument.fretted.guitar.bass.electric.fretless.5-string.5lines','*Ibguit',
'instrument.fretted.guitar.bass.electric.fretless.5-string.tab','*Ibguit',
'instrument.fretted.guitar.bass.electric.fretless.5lines','*Ibguit',
'instrument.fretted.guitar.bass.electric.fretless.6-string.5lines','*Ibguit',
'instrument.fretted.guitar.bass.electric.fretless.6-string.tab','*Ibguit',
'instrument.fretted.guitar.bass.electric.fretless.tab','*Ibguit',
'instrument.fretted.guitar.bass.electric.tab','*Ibguit',
'instrument.fretted.guitar.bass.fretless.5-string.5lines','*Ibguit',
'instrument.fretted.guitar.bass.fretless.5-string.tab','*Ibguit',
'instrument.fretted.guitar.bass.fretless.5lines','*Ibguit',
'instrument.fretted.guitar.bass.fretless.6-string.5lines','*Ibguit',
'instrument.fretted.guitar.bass.fretless.6-string.tab','*Ibguit',
'instrument.fretted.guitar.bass.fretless.tab','*Ibguit',
'instrument.fretted.guitar.bass.semi-acoustic.5lines','*Ibguit',
'instrument.fretted.guitar.bass.semi-acoustic.tab','*Ibguit',
'instrument.fretted.guitar.bass.tab','*Ibguit',
'instrument.fretted.guitar.bass.tab.rhythms','*Ibguit',
'instrument.fretted.guitar.classical.5lines','*Iguitr',
'instrument.fretted.guitar.classical.dadgad.tab','*Iguitr',
'instrument.fretted.guitar.classical.double-d.tab','*Iguitr',
'instrument.fretted.guitar.classical.dropped-d.tab','*Iguitr',
'instrument.fretted.guitar.classical.open-d.tab','*Iguitr',
'instrument.fretted.guitar.classical.open-e.tab','*Iguitr',
'instrument.fretted.guitar.classical.open-g.tab','*Iguitr',
'instrument.fretted.guitar.classical.tab','*Iguitr',
'instrument.fretted.guitar.classical.tab.rhythms','*Iguitr',
'instrument.fretted.guitar.electric.5lines','*Ieguit',
'instrument.fretted.guitar.electric.7-string.low-a.tab','*Ieguit',
'instrument.fretted.guitar.electric.7-string.tab','*Ieguit',
'instrument.fretted.guitar.electric.dadgad.tab','*Ieguit',
'instrument.fretted.guitar.electric.double-d.tab','*Ieguit',
'instrument.fretted.guitar.electric.dropped-d.tab','*Ieguit',
'instrument.fretted.guitar.electric.open-d.tab','*Ieguit',
'instrument.fretted.guitar.electric.open-e.tab','*Ieguit',
'instrument.fretted.guitar.electric.open-g.tab','*Ieguit',
'instrument.fretted.guitar.electric.tab','*Ieguit',
'instrument.fretted.guitar.electric.tab.rhythms','*Ieguit',
'instrument.fretted.guitar.semi-acoustic.5lines','*Iguitr',
'instrument.fretted.guitar.semi-acoustic.dadgad.tab','*Iguitr',
'instrument.fretted.guitar.semi-acoustic.double-d.tab','*Iguitr',
'instrument.fretted.guitar.semi-acoustic.dropped-d.tab','*Iguitr',
'instrument.fretted.guitar.semi-acoustic.open-d.tab','*Iguitr',
'instrument.fretted.guitar.semi-acoustic.open-e.tab','*Iguitr',
'instrument.fretted.guitar.semi-acoustic.open-g.tab','*Iguitr',
'instrument.fretted.guitar.semi-acoustic.tab','*Iguitr',
'instrument.fretted.guitar.semi-acoustic.tab.rhythms','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.10-string.tab','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.5lines','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.6-string.tab','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.6-string.tab.alternative','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.6-string.tab.bflat.mauna.loa','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.6-string.tab.c.mauna.loa','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.6-string.tab.cgdgbd.wahine','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.6-string.tab.cgdgbe.wahine','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.6-string.tab.dgdfbd.wahine','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.6-string.tab.g.mauna.loa','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.6-string.tab.g.taro.patch','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.6-string.tab.gcdgbe.wahine','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.8-string.tab','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.8-string.tab.alternative','*Iguitr',
'instrument.fretted.guitar.steel.hawaiian.tab','*Iguitr',
'instrument.fretted.guitar.steel.pedal.5lines','*Iguitr',
'instrument.fretted.guitar.steel.pedal.tab','*Iguitr',
'instrument.fretted.guitarra.5lines','*Iguitr',
'instrument.fretted.guitarra.coimbra.tab','*Iguitr',
'instrument.fretted.guitarra.lisboa.tab','*Iguitr',
'instrument.fretted.guitarra.portuguesa.tab','*Iguitr',
'instrument.fretted.lute.5lines','*Iliuto',
'instrument.fretted.lute.bass-d.french.english.5lines','*Iliuto',
'instrument.fretted.lute.bass-d.french.english.tab','*Iliuto',
'instrument.fretted.lute.bass-d.italian.tab','*Iliuto',
'instrument.fretted.lute.bass-d.spanish.tab','*Iliuto',
'instrument.fretted.lute.italian.tab','*Iliuto',
'instrument.fretted.lute.spanish.tab','*Iliuto',
'instrument.fretted.lute.tab','*Iliuto',
'instrument.fretted.lute.tenor-a.french.english.tab','*Iliuto',
'instrument.fretted.lute.tenor-a.italian.tab','*Iliuto',
'instrument.fretted.lute.tenor-a.spanish.tab','*Iliuto',
'instrument.fretted.lute.treble-d.french.english.5lines','*Iliuto',
'instrument.fretted.lute.treble-d.french.english.tab','*Iliuto',
'instrument.fretted.lute.treble-d.italian.tab','*Iliuto',
'instrument.fretted.lute.treble-d.spanish.tab','*Iliuto',
'instrument.fretted.mandolin.5lines','*Imando',
'instrument.fretted.mandolin.tab','*Imando',
'instrument.fretted.oud.5lines','*Ioud', // 2022-01-30: New instrument code proposed by C.Sapp to replace old Iud
'instrument.fretted.oud.tab','*Ioud', // 2022-01-30: New instrument code proposed by C.Sapp to replace old Iud
'instrument.fretted.sitar.5lines','*Isitar',
'instrument.fretted.sitar.ravi-shankkar.tab','*Isitar',
'instrument.fretted.sitar.vilayat-khan.tab','*Isitar',
'instrument.fretted.tambura.female','*Itambu',
'instrument.fretted.tambura.male','*Itambu',
'instrument.fretted.ukulele.5lines','*Iukule',
'instrument.fretted.ukulele.tab','*Iukule',
'instrument.fretted.zither','*Izithr',
'instrument.keyboard.accordion','*Iaccor',
'instrument.keyboard.celesta','*Iclest',
'instrument.keyboard.clavichord','*Iclavi',
'instrument.keyboard.keyboards','*Icemba',
'instrument.keyboard.organ.manuals','*Iorgan',
'instrument.keyboard.organ.manuals.solo','*Iorgan',
'instrument.keyboard.organ.pedals','*Iorgan',
'instrument.keyboard.organ.pedals.solo','*Iorgan',
'instrument.keyboard.piano','*Ipiano',
'instrument.keyboard.synthesizer','*Isynth',
'instrument.pitchedpercussion.bells.chimes','*Ichime',
'instrument.pitchedpercussion.bells.chimes.nokeysig','*Ichime',
'instrument.pitchedpercussion.bells.orchestral','*Icampn',
'instrument.pitchedpercussion.bells.tubular','*Icampn',
'instrument.pitchedpercussion.cimbalom','*Idulc',
'instrument.pitchedpercussion.drums.steel','*Isteel',
'instrument.pitchedpercussion.drums.steel.bassclef','*Isteel',
'instrument.pitchedpercussion.glockenspiel','*Iglock',
'instrument.pitchedpercussion.glockenspiel.alto','*Iglock',
'instrument.pitchedpercussion.glockenspiel.soprano','*Iglock',
'instrument.pitchedpercussion.harp','*Iarpa',
'instrument.pitchedpercussion.harp.lever','*Iarpa',
'instrument.pitchedpercussion.timpani','*Itimpa',
'instrument.pitchedpercussion.timpani.nokeysig','*Itimpa',
'instrument.pitchedpercussion.vibraphone','*Ivibra',
'instrument.pitchedpercussion.xylophone','*Ixylo',
'instrument.pitchedpercussion.xylophone.alto','*Ixylo',
'instrument.pitchedpercussion.xylophone.bass','*Ixylo',
'instrument.pitchedpercussion.xylophone.soprano','*Ixylo',
'instrument.singers.alto','*Ialto',
'instrument.singers.alto.solo','*Ialto',
'instrument.singers.baritone','*Ibarit',
'instrument.singers.baritone.solo','*Ibarit',
'instrument.singers.bass','*Ibass',
'instrument.singers.bass.solo','*Ibass',
'instrument.singers.contralto','*Icalto',
'instrument.singers.counter-tenor','*Ictenor',
'instrument.singers.mezzo-soprano','*Imezzo',
'instrument.singers.soprano','*Isoprn',
'instrument.singers.soprano.solo','*Isoprn',
'instrument.singers.tenor','*Itenor',
'instrument.singers.tenor.solo','*Itenor',
'instrument.singers.voice.male','*Imale',
'instrument.strings.contrabass','*Icbass',
'instrument.strings.contrabass.bass','*Icbass',
'instrument.strings.contrabass.double-bass','*Icbass',
'instrument.strings.contrabass.solo','*Icbass',
'instrument.strings.contrabass.string','*Icbass',
'instrument.strings.contrabass.upright','*Icbass',
'instrument.strings.viola','*Iviola',
'instrument.strings.viola.solo','*Iviola',
'instrument.strings.violin.1','*Ivioln',
'instrument.strings.violin.2','*Ivioln',
'instrument.strings.violin.I','*Ivioln',
'instrument.strings.violin.ii','*Ivioln',
'instrument.strings.violin.solo','*Ivioln',
'instrument.strings.violoncello','*Icello',
'instrument.strings.violoncello.solo','*Icello',
'instrument.unpitched.drums.cymbal','*Ipiatt',
'instrument.unpitched.drums.table','*Itabla',
'instrument.unpitched.drums.tom-toms','*Itom',
'instrument.unpitched.drums.tom-toms.4lines','*Itom',
'instrument.unpitched.gong.large.1line','*Igong',
'instrument.unpitched.gong.medium.1line','*Igong',
'instrument.unpitched.tambourine','*Itambn',
'instrument.unpitched.triangle','*Itrngl',
'instrument.wind.bassoon','*Ifagot',
'instrument.wind.bassoon.quart','*Ifag_c',
'instrument.wind.clarinet.a','*Iclars',
'instrument.wind.clarinet.aflat','*Iclars',
'instrument.wind.clarinet.alto.eflat','*Iclara',
'instrument.wind.clarinet.alto.eflat.bassclef','*Iclara',
'instrument.wind.clarinet.bass.bflat','*Iclarb',
'instrument.wind.clarinet.bass.bflat.8vb-score','*Iclarb',
'instrument.wind.clarinet.bass.bflat.bassclef','*Iclarb',
'instrument.wind.clarinet.bflat','*Iclars',
'instrument.wind.clarinet.c','*Iclars',
'instrument.wind.clarinet.d','*Iclars',
'instrument.wind.clarinet.eflat','*Iclars',
'instrument.wind.clarinet.g','*Iclars',
'instrument.wind.coranglais','*Icangl',
'instrument.wind.englishhorn','*Icangl',
'instrument.wind.flute','*Iflt',
'instrument.wind.flute.alto','*Iflt_a',
'instrument.wind.flute.bansuri','*Ibansu',
'instrument.wind.flute.bass','*Iflt_b',
'instrument.wind.flute.eflat','*Iflt',
'instrument.wind.flute.g','*Iflt',
'instrument.wind.harmonica','*Iarmon',
'instrument.wind.oboe','*Ioboe',
'instrument.wind.oboe.baritone','*Ioboe',
'instrument.wind.oboe.bass','*Ioboe',
'instrument.wind.oboe.damore','*IoboeD',
'instrument.wind.ocarina','*Iocari',
'instrument.wind.piccolo','*Ipicco',
'instrument.wind.piccolo.dflat','*Ipicco',
'instrument.wind.recorder.alto','*Ifltda',
'instrument.wind.recorder.bass','*Ifltdb',
'instrument.wind.recorder.sopranino','*Ifltdn',
'instrument.wind.recorder.soprano','*Ifltds',
'instrument.wind.recorder.tenor','*Ifltdt',
'instrument.wind.saxophone.alto','*Ifltda',
'instrument.wind.saxophone.baritone','*IsaxR',
'instrument.wind.saxophone.baritone.8vb-score','*IsaxR',
'instrument.wind.saxophone.baritone.bassclef','*IsaxR',
'instrument.wind.saxophone.bass','*IsaxB',
'instrument.wind.saxophone.bass.15mb-score','*IsaxB',
'instrument.wind.saxophone.bass.bassclef','*IsaxB',
'instrument.wind.saxophone.contrabass','*IsaxC',
'instrument.wind.saxophone.contrabass.15mb-score','*IsaxC',
'instrument.wind.saxophone.contrabass.bassclef','*IsaxC',
'instrument.wind.saxophone.sopranino','*IsaxN',
'instrument.wind.saxophone.soprano','*IsaxS',
'instrument.wind.saxophone.tenor','*IsaxT',
'instrument.wind.saxophone.tenor.8vb-score','*IsaxT',
'instrument.wind.saxophone.tenor.bassclef','*IsaxT',
'instrument.wind.shakuhachi','*Ishaku');
return instrumentDictionary;}"
CreateClefDictionary "() {
clefDictionary = CreateDictionary(
'clef.alto','*clefC3',
'clef.baritone.c','*clefC5',
'clef.baritone.f','*clefF3',
'clef.bass','*clefF4',
'clef.bass.down.8','*clefFv4',
'clef.bass.up.15','*clefF^^4',
'clef.bass.up.8','*clefF^4',
'clef.percussion','*clefX',
'clef.percussion_2','*clefX',
'clef.soprano','*clefC1',
'clef.soprano.mezzo','*clefC2',
'clef.tenor','*clefC4',
'clef.tenor.down.8','*clefCv4',
'clef.treble','*clefG2',
'clef.treble.down.8','*clefGv2',
'clef.treble.down.8.bracketed','*clefGv2',
'clef.treble.down.8.old','*clefGv2',
'clef.treble.up.15','*clefG^15',
'clef.treble.up.8','*clefG^8',
'clef.violin.french','*clefG1',
'clef.sub-bass.f','*clefF5');
return clefDictionary;}"
AppendScoreInfoToFile "(fname) {
thisScore = Sibelius.ActiveScore;
if (thisScore.Composer != '')
{
humComposer = '!!!COM: ' & thisScore.Composer;
Sibelius.AppendLineToFile(fname,humComposer);
}
if (thisScore.ComposerDates != '')
{
humComposerDates = '!!!CDT: ' & thisScore.ComposerDates;
Sibelius.AppendLineToFile(fname,humComposerDates);
}
if (thisScore.Lyricist != '')
{
humLyricist = '!!!LYR: ' & thisScore.Lyricist;
Sibelius.AppendLineToFile(fname,humLyricist);
}
if (thisScore.Arranger != '')
{
humArranger = '!!!LAR: ' & thisScore.Arranger;
Sibelius.AppendLineToFile(fname,humArranger);
}
//Here I chose to use MPN-artist for Artist