Files
sibelius-shakuhachi-kinko/ShakuhachiKinkoReverse.plg
T
Marcus Huntemann 3e4a645292 feat: sibelius shakuhachi kinko notation plugins
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
2026-10-05 18:44:57 +02:00

152 lines
4.2 KiB
Plaintext

{
Initialize "() {
// Set plugin metadata
PluginName = "Update Notes from Kinko";
Category = "Notes and Rests";
MenuText = "Update Notes from Kinko";
// Initialize length-to-semitone offset mapping (same as forward plugin)
LengthSemitoneOffset = CreateDictionary(
"1.3", 5,
"1.4", 4,
"1.5", 3,
"1.6", 2,
"1.8", 0,
"1.9", -1,
"2.0", -2,
"2.1", -3,
"2.3", -4,
"2.4", -5
);
// Initialize Kinko notation mapping (same as forward plugin)
KinkoMapping = CreateDictionary(
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, "ロ"
);
// Build reverse mapping: Kinko character -> baseline MIDI pitch
// Iterate in ascending order so later duplicates overwrite (prefer first octave)
ReverseKinkoMapping = CreateDictionary();
for i = 62 to 86 {
kinkoChar = KinkoMapping[i];
if (kinkoChar != null) {
ReverseKinkoMapping[kinkoChar] = i;
}
}
// Create configuration dialog
ConfigDialog = CreateDialog("Update Notes from Kinko", 350, 180);
ConfigDialog.AddDropDown("Length", "1.3;1.4;1.5;1.6;1.8;1.9;2.0;2.1;2.3;2.4", 4);
ConfigDialog.AddCheckBox("CreateMissing", "Create notes if missing at position", true);
}"
ShowDialog "(configDialog) {
return configDialog.Show();
}"
StripSubscripts "(text) {
// Remove Unicode subscripts (U+2080-U+2089)
// ManuScript string handling: iterate and rebuild without subscripts
result = "";
for i = 0 to Length(text) - 1 {
ch = CharAt(text, i);
code = Asc(ch);
// Check if character is subscript 0-9 (Unicode 8304-8313 or 8320-8329)
// Skip subscripts, keep everything else
if (code < 8304 or (code > 8313 and code < 8320) or code > 8329) {
result = result & ch;
}
}
return result;
}"
Run "() {
score = Sibelius.ActiveScore;
if (score = null) {
Sibelius.MessageBox("No score is open");
return false;
}
if (score.Selection.Length = 0) {
Sibelius.MessageBox("Please select measures containing Kinko text");
return false;
}
// Show dialog
if (not ShowDialog(ConfigDialog)) {
return false;
}
// Read dialog values
lengthIndex = ConfigDialog.GetValue("Length");
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];
createMissing = ConfigDialog.GetValue("CreateMissing");
// Process selection
notesUpdated = 0;
for each obj in score.Selection {
// Filter to Text objects with Technique style
if (obj.Type = "Text" and obj.StyleId = "text.staff.technique") {
// Get Kinko character text
kinkoChar = obj.Text;
// Normalize: strip whitespace and subscripts
kinkoChar = Trim(kinkoChar);
kinkoChar = StripSubscripts(kinkoChar);
// Look up baseline pitch
baselinePitch = ReverseKinkoMapping[kinkoChar];
if (baselinePitch = null) {
continue; // Skip unknown characters
}
// Apply transposition
targetPitch = baselinePitch + semitoneOffset;
// Get parent bar and position
bar = obj.ParentBar;
position = obj.Position;
// Search for NoteRest at same position
foundNote = false;
for each barObj in bar {
if (barObj.Type = "NoteRest" and barObj.Position = position and barObj.NoteCount > 0) {
// Update top note pitch
barObj[barObj.NoteCount - 1].Pitch = targetPitch;
notesUpdated = notesUpdated + 1;
foundNote = true;
break;
}
}
// Create new note if not found and user allowed it
if (not foundNote and createMissing) {
// Add quarter note (duration 256 = quarter note in Sibelius units)
noterest = bar.AddNoteRest(position, targetPitch, 256);
notesUpdated = notesUpdated + 1;
}
}
}
// Report results
if (notesUpdated = 0) {
Sibelius.MessageBox("No Kinko notation found in selection");
} else {
Sibelius.MessageBox("Updated " & notesUpdated & " notes from Kinko notation");
}
return true;
}"
}