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
