From 3e4a645292565b73e66de00f6c58fadbc7d01d51 Mon Sep 17 00:00:00 2001 From: Marcus Huntemann Date: Mon, 5 Oct 2026 18:44:57 +0200 Subject: [PATCH] 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 --- .gitattributes | 9 ++ .gitignore | 7 ++ README_Shakuhachi.txt | 127 ++++++++++++++++++++++++++++ ShakuhachiKinko.plg | 167 +++++++++++++++++++++++++++++++++++++ ShakuhachiKinkoReverse.plg | 151 +++++++++++++++++++++++++++++++++ 5 files changed, 461 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 README_Shakuhachi.txt create mode 100644 ShakuhachiKinko.plg create mode 100644 ShakuhachiKinkoReverse.plg diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..ff93eab --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +*.plg linguist-language=ManuScript + +# Sibelius temp files +*.sib~ +*.tmp + +# OS files +.DS_Store +Thumbs.db diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5f1f1a1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +# Sibelius temp files +*.sib~ +*.tmp + +# OS files +.DS_Store +Thumbs.db diff --git a/README_Shakuhachi.txt b/README_Shakuhachi.txt new file mode 100644 index 0000000..c979862 --- /dev/null +++ b/README_Shakuhachi.txt @@ -0,0 +1,127 @@ +Shakuhachi Kinko Notation Plugin for Sibelius + +INSTALLATION: +1. Copy ShakuhachiKinko.plg and ShakuhachiKinkoReverse.plg to Sibelius plugins folder: + Windows: C:\Users\[username]\AppData\Roaming\Avid\Sibelius\Plugins + macOS: ~/Library/Application Support/Avid/Sibelius/Plugins +2. Restart Sibelius or run Plug-ins > Rescan Plug-ins + +USAGE: +Forward (staff notation to Kinko): +1. Select measures containing notes +2. Run Plug-ins > Text > Add Shakuhachi Kinko Notation +3. Choose shakuhachi length (default 1.8 shaku) +4. Choose position (above or below staff) +5. Click OK + +Bidirectional editing workflow: +1. Create staff notation, run forward plugin to add Kinko text +2. Edit Kinko text directly in score (double-click text, type new characters) +3. Select edited measures, run reverse plugin to update staff notes +4. Optionally run forward plugin again to verify all Kinko text synced + +Reverse (Kinko to staff notation): +1. Edit Kinko text characters directly in score (double-click, edit) +2. Select measures containing edited Kinko text +3. Run Plug-ins > Notes and Rests > Update Notes from Kinko +4. Choose shakuhachi length (must match original) +5. Click OK + +SUPPORTED LENGTHS: +1.3 shaku (G) - 1.4 (F#) - 1.5 (F) - 1.6 (E) - 1.8 (D) - 1.9 (C#) - 2.0 (C) - 2.1 (B) - 2.3 (Bb) - 2.4 (A) + +KINKO NOTATION: +Basic notes: ロ (ro), ツ (tsu), レ (re), チ (chi), リ (ri), ウ (u) +Meri notation (pitch lowering): + - 中 prefix (chu meri): lowers by ~half step + Example: 中ロ (chu ro) = D# for 1.8 shaku + - 大 prefix (dai meri): lowers by ~whole step + Example: 大ロ (dai ro) = E for 1.8 shaku + +Extended symbols: + - ウ₃ (san no u): alternative fingering for B, same pitch as ウ + - カ (kari): raises pitch, rarely used in traditional scores + - Ornaments (ori, suri, atari, keshi): phrase-ending techniques, add manually + +Valid range: D4-D6 (three octaves) +Chords: notation added to top note only +System fonts render katakana/kanji automatically +Workflow: on-demand sync via plugin execution (not live/automatic) + +ADDING SUBSCRIPTS: +To add Unicode subscript 3 for san no u: +- Windows: Type u followed by Alt+2083 +- macOS: Character Viewer > search "subscript 3" +- Or copy/paste: ₃ (Unicode U+2083) + +The reverse plugin normalizes subscripts (strips them) before pitch lookup, so ウ₃ and ウ produce the same pitch. + +MANUAL EDITS: +You can freely edit Kinko text in the score: +- Double-click any Kinko character to edit +- Type new characters (ロツレチリウ, 中, 大, etc.) +- Add subscripts or custom symbols +- Run reverse plugin to update staff notes from your edits +- Run forward plugin again to sync any remaining notation + +TROUBLESHOOTING: +- "No notes in shakuhachi range found": All selected notes are outside D4-D6 range +- Japanese characters not displaying: Install system Japanese font support + Windows: MS Mincho, MS Gothic, or Yu Mincho + macOS: Hiragino Kaku Gothic (included by default) + Linux: Install fonts-noto-cjk or equivalent +- Tied notes showing duplicate notation: Enable "Update existing notation" checkbox +- Octave ambiguity in reverse: Duplicate characters (ロツレチリウ appear in multiple octaves) + default to first octave; manually adjust pitch if needed + +FUTURE ENHANCEMENT - Custom Calligraphy Symbols: +If you have calligraphy images and want authentic visual appearance: + +1. Prepare calligraphy images: + - Create SVG or PNG files for each symbol: ro.svg, tsu.svg, chu_ro.svg, dai_ro.svg, u_san.svg, etc. + - Ensure consistent size and baseline alignment + +2. Install as Sibelius symbols: + - Edit > Symbols > New Symbol + - Import each image + - Name with prefix: kinko_ro, kinko_tsu, kinko_chu_ro, kinko_u_san, etc. + +3. Modify forward plugin (line ~129): + Replace: text = bar.AddText(position, kinkoChar, "Technique"); + With: text = bar.AddSymbol(position, GetSymbolName(kinkoChar)); + + Add symbol name mapping function: + GetSymbolName "(kinkoChar) { + if (kinkoChar = "ロ") { return "kinko_ro"; } + if (kinkoChar = "中ロ") { return "kinko_chu_ro"; } + if (kinkoChar = "大ロ") { return "kinko_dai_ro"; } + if (kinkoChar = "ツ") { return "kinko_tsu"; } + // ... etc for all characters + }" + +4. Modify reverse plugin: + - Change iteration from Text objects to SymbolItem objects + - Reverse lookup: symbol name -> Kinko character -> pitch + - Add fallback check: if symbol not installed, warn user + +5. Add fallback logic: + Before AddSymbol, check: if (Sibelius.SymbolExists(symbolName)) + Fall back to Unicode text with user warning if symbol missing + +Reference implementation: +https://github.com/chrisrauh/shakuhachi-ro +SVG-based rendering with similar modifier/note separation architecture + +This architecture allows incremental adoption: start with Unicode text immediately, +upgrade to calligraphy when ready without rewriting plugin logic. + +PLUGIN REQUIREMENTS: +- Sibelius Ultimate (version 7+) with ManuScript support +- Not compatible with Sibelius First or Student editions + +LICENSE: +This plugin is provided as-is for shakuhachi notation purposes. +No warranty expressed or implied. + +VERSION: +1.0 - Initial release with bidirectional Unicode text notation diff --git a/ShakuhachiKinko.plg b/ShakuhachiKinko.plg new file mode 100644 index 0000000..e431cd0 --- /dev/null +++ b/ShakuhachiKinko.plg @@ -0,0 +1,167 @@ +{ + 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; + }" +} diff --git a/ShakuhachiKinkoReverse.plg b/ShakuhachiKinkoReverse.plg new file mode 100644 index 0000000..7ada52f --- /dev/null +++ b/ShakuhachiKinkoReverse.plg @@ -0,0 +1,151 @@ +{ + 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; + }" +}