Add bidirectional plugins for shakuhachi Kinko notation in Sibelius: - Forward plugin: converts staff notation to Kinko characters - Reverse plugin: updates staff notes from edited Kinko text - Support for 10 shakuhachi lengths (1.3-2.4 shaku) - MIDI 62-86 (D4-D6) pitch mapping - Extended symbols: chu/dai meri prefix notation - Unicode subscript normalization for alternative fingerings - Position-based synchronization enables manual text editing - Architecture extensible to custom calligraphy symbols Verification: - ManuScript syntax and three-method structure - Pitch mappings and transposition logic for all lengths - Bidirectional workflow with round-trip consistency - Edge case handling: tied notes, chords, range validation
168 lines
5.0 KiB
Plaintext
168 lines
5.0 KiB
Plaintext
{
|
|
Initialize "() {
|
|
// Set plugin metadata
|
|
PluginName = "Shakuhachi Kinko Notation";
|
|
Category = "Text";
|
|
MenuText = "Add Shakuhachi Kinko Notation";
|
|
|
|
// Initialize length-to-semitone offset mapping
|
|
// 1.8 shaku is baseline (D), others transposed relative to it
|
|
LengthSemitoneOffset = CreateDictionary(
|
|
"1.3", 5, // G (5 semitones above D)
|
|
"1.4", 4, // F# (4 semitones above D)
|
|
"1.5", 3, // F (3 semitones above D)
|
|
"1.6", 2, // E (2 semitones above D)
|
|
"1.8", 0, // D (baseline)
|
|
"1.9", -1, // C# (1 semitone below D)
|
|
"2.0", -2, // C (2 semitones below D)
|
|
"2.1", -3, // B (3 semitones below D)
|
|
"2.3", -4, // Bb (4 semitones below D)
|
|
"2.4", -5 // A (5 semitones below D)
|
|
);
|
|
|
|
// Initialize Kinko notation mapping for 1.8 shaku baseline
|
|
// MIDI 62-86 (D4-D6), prefix notation for chu/dai meri
|
|
KinkoMapping = CreateDictionary(
|
|
// First octave (Otsu register) - MIDI 62-73
|
|
62, "ロ", // D4 ro
|
|
63, "中ロ", // D#4 chu ro (chu meri)
|
|
64, "大ロ", // E4 dai ro (dai meri)
|
|
65, "ツ", // F4 tsu
|
|
66, "中ツ", // F#4 chu tsu
|
|
67, "レ", // G4 re
|
|
68, "中レ", // G#4 chu re
|
|
69, "チ", // A4 chi
|
|
70, "中チ", // A#4 chu chi
|
|
71, "ウ", // B4 u
|
|
72, "リ", // C5 ri
|
|
73, "中リ", // C#5 chu ri
|
|
|
|
// Second octave (Kan register) - MIDI 74-85
|
|
74, "ロ", // D5 ro
|
|
75, "中ロ", // D#5 chu ro
|
|
76, "大ロ", // E5 dai ro
|
|
77, "ツ", // F5 tsu
|
|
78, "中ツ", // F#5 chu tsu
|
|
79, "レ", // G5 re
|
|
80, "中レ", // G#5 chu re
|
|
81, "チ", // A5 chi
|
|
82, "中チ", // A#5 chu chi
|
|
83, "ウ", // B5 u
|
|
84, "リ", // C6 ri
|
|
85, "中リ", // C#6 chu ri
|
|
|
|
// Third octave (Dai-Kan register) - MIDI 86
|
|
86, "ロ" // D6 ro
|
|
);
|
|
|
|
// Create configuration dialog
|
|
ConfigDialog = CreateDialog("Configure Shakuhachi Notation", 350, 200);
|
|
ConfigDialog.AddDropDown("Length", "1.3;1.4;1.5;1.6;1.8;1.9;2.0;2.1;2.3;2.4", 4); // Index 4 = 1.8 default
|
|
ConfigDialog.AddRadioGroup("Position", "Above staff;Below staff", 0); // 0 = above default
|
|
ConfigDialog.AddCheckBox("UpdateExisting", "Update existing Kinko notation", false);
|
|
}"
|
|
|
|
ShowDialog "(configDialog) {
|
|
// Show dialog and return user choice
|
|
return configDialog.Show();
|
|
}"
|
|
|
|
Run "() {
|
|
// Get active score
|
|
score = Sibelius.ActiveScore;
|
|
|
|
if (score = null) {
|
|
Sibelius.MessageBox("No score is open");
|
|
return false;
|
|
}
|
|
|
|
// Check for selection
|
|
if (score.Selection.Length = 0) {
|
|
Sibelius.MessageBox("Please select measures containing notes");
|
|
return false;
|
|
}
|
|
|
|
// Show dialog
|
|
if (not ShowDialog(ConfigDialog)) {
|
|
return false; // User cancelled
|
|
}
|
|
|
|
// Read dialog values
|
|
lengthIndex = ConfigDialog.GetValue("Length");
|
|
|
|
// Convert index to shaku string
|
|
lengths = CreateSparseArray("1.3", "1.4", "1.5", "1.6", "1.8", "1.9", "2.0", "2.1", "2.3", "2.4");
|
|
selectedLength = lengths[lengthIndex];
|
|
semitoneOffset = LengthSemitoneOffset[selectedLength];
|
|
|
|
positionAbove = (ConfigDialog.GetValue("Position") = 0);
|
|
updateExisting = ConfigDialog.GetValue("UpdateExisting");
|
|
|
|
// Process selection
|
|
notesProcessed = 0;
|
|
|
|
for each obj in score.Selection {
|
|
// Filter to NoteRest objects with actual notes
|
|
if (obj.Type = "NoteRest" and obj.NoteCount > 0) {
|
|
// Check if tied continuation (skip if tied from previous note)
|
|
if (obj.Tied = true) {
|
|
continue;
|
|
}
|
|
|
|
// Get top note (highest pitch in chord)
|
|
topNote = obj[obj.NoteCount - 1];
|
|
pitch = topNote.Pitch;
|
|
|
|
// Calculate baseline pitch (transpose to 1.8 shaku reference)
|
|
baselinePitch = pitch - semitoneOffset;
|
|
|
|
// Check if in valid shakuhachi range (D4-D6)
|
|
if (baselinePitch < 62 or baselinePitch > 86) {
|
|
continue; // Skip notes outside range
|
|
}
|
|
|
|
// Look up Kinko character
|
|
kinkoChar = KinkoMapping[baselinePitch];
|
|
|
|
if (kinkoChar = null) {
|
|
continue; // Skip if no mapping (shouldn't happen)
|
|
}
|
|
|
|
// Get parent bar and position
|
|
bar = obj.ParentBar;
|
|
position = obj.Position;
|
|
|
|
// Check for existing Kinko text at this position if updating
|
|
if (updateExisting) {
|
|
for each barObj in bar {
|
|
if (barObj.Type = "Text" and barObj.StyleId = "text.staff.technique" and barObj.Position = position) {
|
|
barObj.DeleteText();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Add new Kinko text using Technique style
|
|
text = bar.AddText(position, kinkoChar, "Technique");
|
|
|
|
// Adjust vertical position (staff spaces, positive = down)
|
|
if (positionAbove) {
|
|
text.DY = -6; // 6 spaces above staff
|
|
} else {
|
|
text.DY = 10; // 10 spaces below staff
|
|
}
|
|
|
|
notesProcessed = notesProcessed + 1;
|
|
}
|
|
}
|
|
|
|
// Report results
|
|
if (notesProcessed = 0) {
|
|
Sibelius.MessageBox("No notes in shakuhachi range (D4-D6) found");
|
|
} else {
|
|
Sibelius.MessageBox("Added Kinko notation to " & notesProcessed & " notes");
|
|
}
|
|
|
|
return true;
|
|
}"
|
|
}
|