From b47d0fb8a051004a6bda633d5559ae272622ceab Mon Sep 17 00:00:00 2001 From: hmmbug Date: Fri, 29 May 2026 19:41:32 +0100 Subject: [PATCH 1/3] Yamaha SY77 & TG77 initial version (cherry picked from commit 974afc4c0c75ccf5fe8939ff24422f246d468d91) --- adaptations/Yamaha_SY77.py | 280 +++++++++++ adaptations/Yamaha_TG77.py | 171 +++++++ adaptations/testData/Yamaha_SY77/bank.syx | Bin 0 -> 42299 bytes adaptations/testData/Yamaha_TG77/Preset1.syx | Bin 0 -> 35148 bytes .../Yamaha_TG77/Preset1_01_SP_Cosmo__.syx | Bin 0 -> 587 bytes adaptations/yamaha/Yamaha_SY_TG_common.py | 475 ++++++++++++++++++ adaptations/yamaha/__init__.py | 0 7 files changed, 926 insertions(+) create mode 100644 adaptations/Yamaha_SY77.py create mode 100644 adaptations/Yamaha_TG77.py create mode 100644 adaptations/testData/Yamaha_SY77/bank.syx create mode 100644 adaptations/testData/Yamaha_TG77/Preset1.syx create mode 100644 adaptations/testData/Yamaha_TG77/Preset1_01_SP_Cosmo__.syx create mode 100644 adaptations/yamaha/Yamaha_SY_TG_common.py create mode 100644 adaptations/yamaha/__init__.py diff --git a/adaptations/Yamaha_SY77.py b/adaptations/Yamaha_SY77.py new file mode 100644 index 00000000..33599f03 --- /dev/null +++ b/adaptations/Yamaha_SY77.py @@ -0,0 +1,280 @@ +""" +# Yamaha SY77 adaptation. + +Adaptation created by github.com/hmmbug. + +- Requires synth to be in program change "direct" mode (Utility -> MIDI -> + Program Change = direct) +- Requires "Bulk Protect" set to "off" (Utility -> MIDI -> Channel Set -> Bulk + Protect = Off) +- The SY77/TG77 has different settings for MIDI Channel and SysEx Device ID. + +## Testing Notes: +- Tested on an SY77 (ROM version 1.5). + +## Mapping SysEx Banks to Interface Banks +The SY77/TG77 maps voices (patches) to 3 main banks: + +- Internal (editable), 64 voice slots +- Preset 1 (read-only), 64 voice slots +- Preset 2 (read-only), 64 voice slots + +On the front panels, each of these 64-slot banks are split into 4 banks (A-D) +of 16 voices, so banks A-D represent voices 1-16, 17-32, 33-48, 49-64. In MIDI +these numbers are zero-indexed instead (0-63 voices). + +This adaptation largely ignores the 16 slot A-D banks and represents banks as +64 slots. The `friendlyProgramName(patchNo)` function references voices in the +same way as on the synth screen, eg "IN-A01" for Internal, Bank A, voice 1. + +## References: +- SY77 & TG77 MIDI Data Format Manuals: + https://usa.yamaha.com/files/download/other_assets/1/317121/SY77E2.PDF + https://usa.yamaha.com/files/download/other_assets/0/316980/TG77E2.PDF +""" + +from enum import IntEnum +import logging +import sys +from types import ModuleType +from typing import List + +import testing + +logging.basicConfig(level=logging.DEBUG) + +from yamaha.Yamaha_SY_TG_common import ( + YamahaSYTGBase, + bytes2str, + SYSEX_START, + YAMAHA_ID, + OFFSET_DEVICE_ID, + OFFSET_CHECKSUM, + SYSEX_END, +) + +this_module = sys.modules[__name__] + + +HELP_STRING = \ +"""SY77/TG77 Systems Settings: +- Set 'Program Change' mode to 'direct' (Utility -> MIDI -> Program Change) +- Set 'Bulk Protect' to 'off' (Utility -> MIDI -> Channel Set -> Bulk Protect) +- Set 'SysEx Device ID' appropriately. If in doubt, set it the same as the + MIDI channel or 'omni'. (Utility -> MIDI -> Channel Set -> Device ID) + +Only Voices are supported, no Multi, sequencer or other capabilities. +""" + +class MemoryType(IntEnum): + INTERNAL = 0x00 + PRESET1 = 0x02 + PRESET2 = 0x03 + EDIT = 0x7F + +BANKS = [ + { "bank": 0, "name": "Internal", "size": 64, "type": "Voice", "isROM": False, }, + { "bank": 1, "name": "Preset 1", "size": 64, "type": "Voice", "isROM": True, }, + { "bank": 2, "name": "Preset 2", "size": 64, "type": "Voice", "isROM": True, }, +] + + +class YamahaSY77(YamahaSYTGBase): + + def convertPatchesToBankDump(self, patches: List[List[int]]) -> List[int]: + # SY77, TG77 patch -> bank conversion + device_id = (self.detected_device_id if self.detected_device_id else 0) & 0x0f + bank = [] + for idx, patch in enumerate(patches): + buf = patch.copy() + buf[OFFSET_DEVICE_ID] = device_id + buf[self.offset_memory_type] = MemoryType.INTERNAL + buf[self.offset_memory_number] = idx + buf[OFFSET_CHECKSUM] = self._calculateChecksum(buf) + bank += buf + return bank + + def createCustomProgramChange(self, channel: int, patchNo: int) -> List[int]: + memtype, memnum = self._mapPatchNumToSynthMemory(patchNo) + if memtype == MemoryType.INTERNAL: bank_pc = 122 + elif memtype == MemoryType.PRESET1: bank_pc = 121 + elif memtype == MemoryType.PRESET2: bank_pc = 117 + else: + raise ValueError(f"Invalid memory type ({memtype}).") + rtn = [ + 0xc0 | (channel & 0x0f), bank_pc, # 'direct mode' program change for bank selection (manual ref 2.1.3) + 0xc0 | (channel & 0x0f), memnum # select the voice in the bank, based on patchNo MOD 64 + ] + logging.debug(f"createCustomProgramChange({channel},{patchNo}) -> {bytes2str(rtn)}") + return rtn + + def friendlyProgramName(self, patchNo: int) -> str: + # SY77: IN-A01 (internal, bank A, slot 1), P1-B03 (Preset 1, bank B, slot 3) + # same format as displayed on synth screen + memtype, memnum = self._mapPatchNumToSynthMemory(patchNo) + memname = ["IN", None, "P1", "P2"][memtype] + bankchar = "ABCD"[memnum // 16] + bankslot = memnum % 16 + 1 + rtn = f"{memname}-{bankchar}{bankslot:02d}" + logging.debug(f"friendlyProgramName: MemType/Num: {memtype}/{memnum} -> rtn:{rtn}") + return rtn + + def bankSlotToPatchNo(self, memory_type: int, memory_number: int) -> int: + self._memoryTypeNumberChecks(memory_type, memory_number) + if memory_type == self.memory_types["EDIT"]: rtn = -1 + elif memory_type == self.memory_types["INTERNAL"]: rtn = memory_number + elif memory_type == self.memory_types["PRESET1"]: rtn = memory_number + 64 + elif memory_type == self.memory_types["PRESET2"]: rtn = memory_number + 128 + else: + raise ValueError("Invalid memory type/number combination") + return rtn + + def _mapPatchNumToSynthMemory(self, patchno: int) -> tuple[int, int]: + "Maps Knobcraft flat patch numbers to synth memory types and banks" + rtn = None + if patchno <= 63: rtn = (int(self.memory_types["INTERNAL"]), patchno) + elif patchno <= 127: rtn = (int(self.memory_types["PRESET1"]), patchno - 64) + elif patchno <= 191: rtn = (int(self.memory_types["PRESET2"]), patchno - 128) + if rtn is None: + raise ValueError(f"Invalid patchno ({patchno})") + return rtn + + def install(self, module: ModuleType): + super().install(module) + setattr(module, 'convertPatchesToBankDump', self.convertPatchesToBankDump) + setattr(module, 'createCustomProgramChange', self.createCustomProgramChange) + setattr(module, 'friendlyProgramName', self.friendlyProgramName) + setattr(module, 'bankSlotToPatchNo', self.bankSlotToPatchNo) + + +synth = YamahaSY77( + synth_name="Yamaha SY77", + synth_id=0x7a, + + # voice + first_preset_name="GrandPiano", + msg_id_voice_dump="LM 8101VC", + voice_default_name="INIT VOICE", + voice_name_length=10, # 10 characters in the voice name + offset_voice_name=33, # location of voice name + + # banks + memory_types=MemoryType, + banks=BANKS, + + # data offsets in voice bulk dumps + offset_memory_type=30, # location of memory type (eg. INT, Preset) + offset_memory_number=31, # location of memory number (eg. patch num.) + offset_req_memory_type=28, # location of memory type in request + offset_req_memory_number=29, # location of memory num. in request + + help_string=HELP_STRING, +) +synth.install(this_module) + +# # ##### TEST FUNCTIONS + +# Unimplemented tests: +# - layers: not applicable +# - legacy_loader: no idea.. it's legacy so I guess it's deprecated... +# - *_via_mock_device: mock device not implemented + +def make_test_data(): + def programs(data: testing.TestData): + return [ + testing.ProgramTestData( + message=data.all_messages[0], + number=0, + name="GrandPiano", + friendly_number="IN-A01", + rename_name="New Patch" + ), + testing.ProgramTestData( + message=data.all_messages[6], + number=6, + name="Triton ", + friendly_number="IN-A07", + rename_name="New Patch" + ), + testing.ProgramTestData( + message=data.all_messages[7], + number=7, + name="FrenchHorn", + friendly_number="IN-A08", + rename_name="New Patch" + ), + ] + + def edit_buffers(data: testing.TestData): + edit_buffer = synth.convertToEditBuffer(0, data.all_messages[16]) + return [ + testing.ProgramTestData( + message=edit_buffer, name="Dyna Grand", number=0, rename_name="0123456789") + ] + + def banks(test_data: testing.TestData): + yield test_data.all_messages[0] + + return testing.TestData( + sysex="testData/Yamaha_SY77/bank.syx", + program_generator=programs, + edit_buffer_generator=edit_buffers, + bank_generator=banks, + program_dump_request=[ + # Preset 1, Voice 1 dump request + SYSEX_START, YAMAHA_ID, 0x20, synth.synth_id, 0x4c, 0x4d, 0x20, 0x20, + 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, SYSEX_END + ], + device_detect_call=[ + SYSEX_START, YAMAHA_ID, 0x20, synth.synth_id, 0x4c, 0x4d, 0x20, 0x20, + 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, SYSEX_END + ], + device_detect_reply=( + [ + # Preset 1 Voice 1 dump + 0xF0, 0x43, 0x00, 0x7A, 0x04, 0x43, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, + 0x08, 0x47, 0x72, 0x61, 0x6E, 0x64, 0x50, 0x69, 0x61, 0x6E, 0x6F, 0x01, 0x00, 0x38, 0x64, 0x03, + 0x10, 0x01, 0x01, 0x00, 0x64, 0x64, 0x08, 0x10, 0x10, 0x08, 0x06, 0x64, 0x17, 0x12, 0x05, 0x0A, + 0x10, 0x64, 0x1F, 0x0D, 0x05, 0x0B, 0x01, 0x01, 0x02, 0x00, 0x01, 0x15, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x7F, + 0x00, 0x00, 0x7F, 0x00, 0x40, 0x00, 0x7F, 0x01, 0x7F, 0x20, 0x06, 0x7F, 0x00, 0x40, 0x00, 0x7F, + 0x01, 0x7F, 0x20, 0x06, 0x3F, 0x18, 0x3F, 0x11, 0x22, 0x3F, 0x3F, 0x3A, 0x3A, 0x00, 0x00, 0x00, + 0x03, 0x3F, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x3F, 0x00, 0x00, 0x0E, 0x01, 0x00, + 0x00, 0x43, 0x00, 0x2A, 0x54, 0x7F, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x03, + 0x00, 0x3E, 0x1A, 0x3F, 0x0F, 0x1B, 0x3F, 0x3F, 0x3A, 0x3A, 0x00, 0x00, 0x00, 0x03, 0x3F, 0x00, + 0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0x12, 0x3F, 0x00, 0x0C, 0x0E, 0x01, 0x00, 0x00, 0x38, 0x00, + 0x2A, 0x54, 0x7F, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x3D, 0x18, + 0x17, 0x11, 0x1D, 0x3F, 0x3F, 0x39, 0x37, 0x00, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x01, 0x00, 0x06, + 0x00, 0x00, 0x01, 0x04, 0x3F, 0x01, 0x00, 0x0E, 0x01, 0x00, 0x00, 0x70, 0x00, 0x53, 0x5B, 0x60, + 0x00, 0x01, 0x00, 0x01, 0x00, 0x7B, 0x00, 0x7B, 0x01, 0x01, 0x00, 0x3F, 0x1F, 0x3F, 0x12, 0x22, + 0x3F, 0x3F, 0x38, 0x38, 0x00, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x13, 0x3F, 0x00, 0x02, 0x0E, 0x01, 0x12, 0x11, 0x56, 0x4B, 0x4C, 0x4D, 0x58, 0x01, 0x00, 0x00, + 0x79, 0x00, 0x7A, 0x00, 0x7C, 0x00, 0x06, 0x00, 0x3E, 0x12, 0x3F, 0x0F, 0x1B, 0x3F, 0x3F, 0x3A, + 0x3A, 0x00, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x10, 0x3F, 0x00, + 0x0A, 0x0E, 0x01, 0x15, 0x12, 0x4E, 0x00, 0x2A, 0x57, 0x58, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, + 0x01, 0x03, 0x00, 0x01, 0x00, 0x2A, 0x17, 0x13, 0x11, 0x21, 0x3F, 0x3F, 0x39, 0x37, 0x00, 0x00, + 0x00, 0x03, 0x34, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, 0x01, 0x14, 0x3F, 0x01, 0x0A, 0x0E, 0x01, + 0x30, 0x00, 0x6F, 0x29, 0x4A, 0x5A, 0x5B, 0x00, 0x01, 0x00, 0x71, 0x00, 0x6B, 0x00, 0x01, 0x00, + 0x01, 0x00, 0x21, 0x3F, 0x3F, 0x3F, 0x3F, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x41, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x02, 0x28, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x2A, 0x54, + 0x7F, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x7F, 0x00, 0x3F, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x40, 0x40, 0x22, 0x22, 0x22, 0x22, 0x22, 0x04, 0x00, 0x4B, 0x4C, 0x4D, 0x01, 0x00, + 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x40, 0x03, + 0x3E, 0x3F, 0x3F, 0x3F, 0x40, 0x40, 0x40, 0x40, 0x40, 0x01, 0x00, 0x00, 0x36, 0x13, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x01, 0x00, 0x48, 0x54, 0x7F, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, + 0x00, 0x01, 0x64, 0x00, 0x3F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x07, 0x00, 0x48, 0x54, 0x7F, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x06, + 0x00, 0x00, 0x3F, 0x0C, 0x0D, 0x0C, 0x1D, 0x3F, 0x3A, 0x02, 0x4B, 0x4C, 0x50, 0x51, 0x01, 0x00, + 0x01, 0x09, 0x01, 0x08, 0x00, 0x7F, 0x06, 0x00, 0x00, 0x08, 0xF7, + ], 0 + ), + expected_patch_count=64, + friendly_bank_name=(0, "Internal"), + ) diff --git a/adaptations/Yamaha_TG77.py b/adaptations/Yamaha_TG77.py new file mode 100644 index 00000000..2dfee13a --- /dev/null +++ b/adaptations/Yamaha_TG77.py @@ -0,0 +1,171 @@ +""" +# Yamaha SY77 adaptation. + +Adaptation created by github.com/hmmbug. + +- Requires synth to be in program change "direct" mode (Utility -> MIDI -> Program Change = direct) +- Requires "Bulk Protect" set to "off" (Utility -> MIDI -> Channel Set -> Bulk Protect = Off) +- The SY77/TG77 has different settings for MIDI Channel and SysEx Device ID. +""" + +from enum import IntEnum +import logging +import sys +from types import ModuleType +from typing import List + +import testing + +logging.basicConfig(level=logging.DEBUG) + +from yamaha.Yamaha_SY_TG_common import ( + SYSEX_START, + YAMAHA_ID, + SYSEX_END, +) +from Yamaha_SY77 import ( + YamahaSY77, + MemoryType, + HELP_STRING, + BANKS, +) + +this_module = sys.modules[__name__] + +class YamahaTG77(YamahaSY77): + # No changes in the subclass, but it'll be easier on the eye in logs + # having the correct synth name when the class is referenced! + pass + + +synth = YamahaTG77( + synth_name="Yamaha TG77", + synth_id=0x7a, + + # voice + first_preset_name="SP|Cosmo ", + msg_id_voice_dump="LM 8101VC", + voice_default_name="INIT VOICE", + voice_name_length=10, + offset_voice_name=33, + + # banks + memory_types=MemoryType, + banks=BANKS, + + # data offsets in voice bulk dumps + offset_memory_type=30, # location of memory type (eg. INT, Preset) + offset_memory_number=31, # location of memory number (eg. patch num.) + offset_req_memory_type=28, # location of memory type in request + offset_req_memory_number=29, # location of memory num. in request + + help_string=HELP_STRING, +) +synth.install(this_module) + +# # ##### TEST FUNCTIONS + +# Unimplemented tests: +# - layers: not applicable +# - legacy_loader: no idea.. it's legacy so I guess it's deprecated... +# - *_via_mock_device: mock device not implemented + +def make_test_data(): + def programs(data: testing.TestData): + return [ + testing.ProgramTestData( + message=data.all_messages[0], + number=64, + name="SP|Cosmo ", + friendly_number="P1-A01", + rename_name="New Patch" + ), + testing.ProgramTestData( + message=data.all_messages[6], + number=70, + name="SP:Darkpad", + friendly_number="P1-A07", + rename_name="New Patch" + ), + testing.ProgramTestData( + message=data.all_messages[10], + number=74, + name="SP|Annapad", + friendly_number="P1-A11", + rename_name="New Patch" + ), + ] + + def edit_buffers(data: testing.TestData): + edit_buffer = synth.convertToEditBuffer(0, data.all_messages[16]) + return [ + testing.ProgramTestData( + message=edit_buffer, name="BR:Plucky ", number=0, rename_name="0123456789") + ] + + def banks(test_data: testing.TestData): + yield test_data.all_messages[0] + + return testing.TestData( + sysex="testData/Yamaha_TG77/Preset1.syx", + program_generator=programs, + edit_buffer_generator=edit_buffers, + bank_generator=banks, + program_dump_request=[ + # Preset 1, Voice 1 dump request + SYSEX_START, YAMAHA_ID, 0x20, synth.synth_id, 0x4c, 0x4d, 0x20, 0x20, + 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, SYSEX_END + ], + device_detect_call=[ + SYSEX_START, YAMAHA_ID, 0x20, synth.synth_id, 0x4c, 0x4d, 0x20, 0x20, + 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, SYSEX_END + ], + device_detect_reply=( + [ + # Preset 1 bank, voice 1 + 0xF0, 0x43, 0x00, 0x7A, 0x04, 0x43, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, + 0x08, 0x53, 0x50, 0x7C, 0x43, 0x6F, 0x73, 0x6D, 0x6F, 0x20, 0x20, 0x01, 0x01, 0x64, 0x64, 0x05, + 0x64, 0x2A, 0x00, 0x03, 0x64, 0x64, 0x08, 0x64, 0x00, 0x00, 0x01, 0x20, 0x64, 0x18, 0x0A, 0x29, + 0x0A, 0x20, 0x64, 0x4B, 0x3F, 0x3E, 0x01, 0x00, 0x02, 0x00, 0x79, 0x11, 0x0C, 0x00, 0x0D, 0x00, + 0x0D, 0x00, 0x01, 0x43, 0x0A, 0x00, 0x02, 0x00, 0x0E, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x7F, + 0x00, 0x00, 0x7F, 0x00, 0x40, 0x00, 0x7F, 0x01, 0x7F, 0x44, 0x06, 0x7F, 0x00, 0x58, 0x00, 0x7F, + 0x01, 0x7F, 0x40, 0x06, 0x3F, 0x3F, 0x3F, 0x3F, 0x0A, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x00, 0x00, + 0x03, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x3F, 0x00, 0x01, 0x06, 0x01, 0x00, + 0x14, 0x69, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, 0x00, 0x00, 0x78, 0x00, 0x68, 0x00, 0x01, + 0x00, 0x1E, 0x3F, 0x3F, 0x3F, 0x1B, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x00, 0x00, 0x03, 0x3F, 0x00, + 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x04, 0x38, 0x03, 0x0C, 0x0F, 0x01, 0x00, 0x00, 0x7F, 0x24, + 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x6D, 0x00, 0x00, 0x00, 0x3F, 0x3F, + 0x3F, 0x3F, 0x0A, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x12, 0x3F, 0x00, 0x0B, 0x0E, 0x01, 0x00, 0x00, 0x69, 0x24, 0x37, 0x4C, 0x60, + 0x01, 0x00, 0x01, 0x00, 0x00, 0x78, 0x00, 0x71, 0x00, 0x01, 0x00, 0x1E, 0x3F, 0x3F, 0x3F, 0x1B, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, + 0x14, 0x38, 0x03, 0x0C, 0x03, 0x01, 0x00, 0x07, 0x7F, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, + 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x0A, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x3F, 0x00, + 0x0A, 0x02, 0x01, 0x00, 0x07, 0x69, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, 0x00, 0x00, 0x78, + 0x00, 0x71, 0x00, 0x01, 0x00, 0x1E, 0x3F, 0x3F, 0x3F, 0x1B, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x00, + 0x00, 0x03, 0x3F, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x14, 0x38, 0x03, 0x0C, 0x07, 0x01, + 0x00, 0x14, 0x7F, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x29, 0x3F, 0x3F, 0x3F, 0x3F, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x42, + 0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x01, 0x64, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x24, 0x37, 0x4C, + 0x60, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x64, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x24, 0x37, 0x4C, 0x60, 0x00, 0x62, + 0x00, 0x6C, 0x00, 0x76, 0x01, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, 0x1D, 0x00, 0x3C, 0x40, 0x03, + 0x3F, 0x3F, 0x3F, 0x3F, 0x40, 0x40, 0x40, 0x40, 0x40, 0x01, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x5E, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x00, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, + 0x00, 0x01, 0x6A, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x00, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x16, 0x3F, 0x3F, 0x00, 0x18, 0x3F, 0x3F, 0x00, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, + 0x01, 0x00, 0x00, 0x7A, 0x00, 0x73, 0x02, 0x01, 0x00, 0x09, 0xF7, 0x2E, 0xF0, 0x86, 0x66, 0xF7 + ], 0 + ), + expected_patch_count=64, + friendly_bank_name=(0, "Internal"), + ) diff --git a/adaptations/testData/Yamaha_SY77/bank.syx b/adaptations/testData/Yamaha_SY77/bank.syx new file mode 100644 index 0000000000000000000000000000000000000000..153ebaee17c770fe54e3f81f1b02e0ebcc17023a GIT binary patch literal 42299 zcmeHw>t7T{({}gFo>)!`EJp>Fg9<2e5ahHli>Sd;RWe`f zZSVN^UTyE}YPIOQIjxoNXL7kr%I|JZW^?{vbFxuuN9oS^r4Igd%Sx41NtJcEkP5$e zJzm?e=PfT2!s8qMC-J34E485}9+b5*FVw8{d9A0afOWg4nh3lY1J-J_r@O7+^OhD2 zX01|6>4c{R^ILWQ$(A7gpg!O>yg{!WWGpTk;DjQ@9iDPpbbH&wTet5#Mhl1P5A_jf z*4kraXaeh;r?M@&v;9jo@d&{3a`7?I-O)A_kTD0)G=TG-2Jp1n9l!bA69E0HUdt5# z^t=)anqS9%DfjU1jM+b=mh}tS^;@SrQ5qhkP>^7EA70fE@R7xx@UddQ_Ku zvv{@Itgu}B%42^7c+=5J^3!W-ZtC}zom;o>eTDWKbVil&bNYY(r@koZ%=#Y0Xy?;A+h2c3{rn zraudF-e3mRCu7cZ5VKO9pN|>9amVrB+D)s3kQF1a@4|jG8*Dl_JR?@zo@O|Z+^3yBL%g(~JTytJu+sr5W zMUJ@+&b1h?l4S^HjKXeB$tH%(fhz20$>D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toJ36_} zqcQ)4PgWf{;y7B_$*cIFK!>*{m!qxe*;D+z>WByaGWp~cGRwaN)+zlHe?XC|_~rh0 z<|*3;&=0U(a@mCHU7n9+|AWmq2>0L9UI*J-I?|pwMWl|#@EW)$77uRP+b(E#+;?wd zES*UGqB|H3qD_U8iJ1ZF}a-#X{;&vpj*-;o7)8O~giW*+>!h ztmsq{N&sf9yEV!!889v+KyG4g5nvF6RSC8d0{E)?BM(+Uh7Xf#s01zyz`FJp1I&~n zY7Fei0cLDDGS;;Pp6Kzq1T#F{&=}NtI^CWIEqKJ$eYM1`335E|3meCdkpXZy41&Nv zDmfYsi_qVZ#EcEyN6FBP(vysiPrz)1*_>U@6+x&mmM)A?E|go=iCV6T$_<>PF^(`9 z1M2gc4CVP>CPN;|(i;_Z5)&cT^&aQh#p7K}2{qC5wa4lr9zXIE#PvmWC1v6crkoW$ iKnaIGj;oTGXBR*J!|h=%ml6^aZ4aG&OnZO+@BaayfW&bC literal 0 HcmV?d00001 diff --git a/adaptations/testData/Yamaha_TG77/Preset1.syx b/adaptations/testData/Yamaha_TG77/Preset1.syx new file mode 100644 index 0000000000000000000000000000000000000000..cf72678ff1a0d47fe7deeec4272dcd0faac0b53c GIT binary patch literal 35148 zcmeHw>01+7(|4Wjq!U6C0wnB90+Cg=0I~(T5m8*2(E*py84cQwGAbzIg5ym7<>%Y; z_5D?KchVgoct6W^zwdRu9c4R}>gqbRpE@W1u|eNL8+W#|*~OXZnFkvbxHO9H-2J|B z`0?FgHmj6vhwU-aZ98fcsjS@*8;xb{+vb`gjZT{5l)y`E#PC}Z{}t(FqB2=jR^@9( znI7>EmSN(G@fVXw$A7t+O;U!U^nQNfPD$at^p#%YTOYu>{lFS-9a_}mO#mr-!1(zc z&@kL7%q=E0CIR5b{NX&zX<*hBMSPg?)^jkoniSIj{KJ?dc)(iBqfE5L7jAPko#wj{ z-Nk=p%dLrI6yw#W#lTsE^qk((XAEjOQ7;uOy@DKnTo=q3e2QQAIt#D*v(6w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nBGnMx+XB=t12AZ3>kU@e-GD)?^8E00IgG38!hmRU8zlrLuUlfM%6ySx73#@AnP|H^Q}e!5tsF zjBQuLimj8LZmcsBW?_y;#Khb$@`lA~lYuJvX&E^uSqo|vGM6qPZ(3xE;eV5BJm61q zCvLikVw;mZkKKSFOMKZHC|&wrr=_vT#4R52OjBuK2S List[int] + createCustomProgramChange(self, channel: int, patchNo: int) -> List[int] + +Methods to override: + friendlyProgramName(self, patchNo: int) -> str + bankSlotToPatchNo(self, memory_type:int, memory_number: int) -> int + _mapPatchNumToSynthMemory(self, patchno: int) -> tuple[int, int] + +Data structures to define: + - a MemoryType(IntEnum) class representing the INTERNAL/PRESET banks. + This varies for each synth (example below) + - a 'banks' dictionary. See the Knobcraft Adaption Programming Guide or + the SY77 adaptation for examples. + +Device detection may require overrides to other methods such as +`createDeviceDetectMessage()` and/or `channelIfValidDeviceResponse`. + + +## BULK DATA DUMP OVERVIEW + +This series of synths have a (mostly) common SysEx format. Each message header +is of the format (hex): + + HEADER: + f0 4d + where: + f0: start of sysex + 4d: manufacturer id for Yamaha + device id: the MIDI device id for SysEx messages. This is not the + same as MIDI channel. + synth id: a marker for (I guess) a hardware series or protocol + version. For example 0x7a is used for SY55/77/85/99. It's unnamed + in most of the MIDI Data Format manuals, but the SY55 manual + refers to it as a "format number". + +Next is a 10 character string in 3 parts: + + SUBHEADER (msg_id) + xxxxyyyyzz + where: + xxxx is always 2 upper case characters plus spaces, usually "LM " + ("LM" + 2x spaces) + Referred to as a "Classification Number" in some manuals. + yyyy is a 4 digit decimal number + Referred to as a "Data Format Name" in some manuals, but seemingly + unrelated to the above "format number" + zz is a 2 digit code for the data type (eg. voice, multi etc) + + Examples: + SY22/SY35: "PK 2203AE" + TG33: "LM 0012VE" + SY55/TG55: "LM 8103VC" + SY77/TG77: "LM 8101VC" + SY85/TG500: "LM 0065VC" + SY99: "LM 8101VC" and "LM 0040VC" + +Some synths also then have a 16 byte value, mostly null padding, sometimes with +memory type (Internal, Preset etc) and memory slot. + +A message tail comprises: + + TAIL + checksum: a 1 byte checksum value based on a simple algorithm + Only used for dump records, not for dump requests + f0: end of SysEx + + +## DEVICE DETECTION OVERVIEW + +Mostly this can be accomplished with the SUBHEADER value in conjunction with +the name of PRESET sound. For example, the message formats of the SY77 and +TG77 are identical but the PRESET sounds differ. + +There are some exceptions to this. The SY85 has no (read-only) PRESET banks +while the rack version of it (the TG500) does have PRESET banks. +""" + +import hashlib +import logging +from types import ModuleType +from typing import List + +import knobkraft.sysex + +logging.basicConfig(level=logging.DEBUG) + +# SysEx constants +SYSEX_START = 0xf0 +SYSEX_END = 0xf7 +YAMAHA_ID = 0x43 +OFFSET_DEVICE_ID = 2 # offsets into SysEx msgs +OFFSET_CHECKSUM = -2 # penultimate byte +OFFSET_SIZE_BYTE1 = 4 +OFFSET_SIZE_BYTE2 = OFFSET_SIZE_BYTE1 + 1 +MESSAGE_TYPE_LENGTH = 10 +OFFSET_MESSAGE_TYPE = 6 +OFFSET_MESSAGE_TYPE_END = OFFSET_MESSAGE_TYPE + MESSAGE_TYPE_LENGTH + +# Example MemoryType enum: +# +# class MemoryType(IntEnum): +# INTERNAL = 0xF0 +# PRESET1 = 0xF2 +# PRESET2 = 0xF3 +# EDIT = 0xFF + +class YamahaSYTGBase: + + def __init__( + self, + synth_name:str, + synth_id:int, + first_preset_name:str, # Verbatim preset name. Used for device detection. + + # voice dump parameters + msg_id_voice_dump:str, # Used for device detection. + voice_default_name:str, + voice_name_length:int, + offset_voice_name:int, + + # memory banks + memory_types, # TODO: typing for subclass of IntEnum?? + banks:List[dict], + + # offsets in sysex messages + # these are the offsets in a bulk dump to where the memory_type + # (INTERNAL, PRESET1 etc) and voice slot is specified + offset_memory_type:int, + offset_memory_number:int, + + # ...and the same but for a bulk dump request. The request messages + # are slightly different because there's no byte count field in + # requests + offset_req_memory_type:int, + offset_req_memory_number:int, + + # misc + help_string:str="", + needs_channel_specific_detection:bool=True, + ) -> None: + self.synth_name = synth_name + self.synth_id = synth_id + self.first_preset_name = first_preset_name + + # voice + self.msg_id_voice_dump = msg_id_voice_dump + self.voice_default_name = voice_default_name + self.voice_name_length = voice_name_length + self.offset_voice_name = offset_voice_name + + # banks + self.memory_types = memory_types + if banks is None: + raise ValueError("'banks' is undefined.") + self.banks = banks + + self.offset_memory_type = offset_memory_type + self.offset_memory_number = offset_memory_number + self.offset_req_memory_type = offset_req_memory_type + self.offset_req_memory_number = offset_req_memory_number + + # misc + self.help_string = help_string + self.needs_channel_specific_detection = needs_channel_specific_detection + + # not user-configurable beyond her + self.detected_device_id = None + + def name(self) -> str: + return self.synth_name + + def setupHelp(self) -> str: + return self.help_string + + + # ##### DEVICE DETECTION CAPACBILITIES + + def createDeviceDetectMessage(self, channel: int) -> List[int]: + device_id = 0x20 | (channel & 0x0f) + # Request PRESET1, voice 1 by default. Override this method if something different is needed. + bank_name = 'PRESET1' if 'PRESET1' in self.memory_types.__members__ else 'PRESET' + msg = str2bytes(self.msg_id_voice_dump) + [0x00]*14 + [int(self.memory_types[bank_name]), 0] + buf = self._makeMessage(device_id, msg, add_checksum=False) + logging.debug(f"createDeviceDetectMessage({channel}: {bytes2str(buf[:32])} ... {bytes2str(buf[-2:])}") + return buf + + def channelIfValidDeviceResponse(self, buf: List[int]) -> int: + if len(buf) < 32: + return False # filter out irrelevant messages like active sensing + if self._validateVoiceMessage(buf): + if self.nameFromDump(buf).strip() == self.first_preset_name.strip(): # ignore whitespace + rtn = buf[OFFSET_DEVICE_ID] + self.detected_device_id = rtn + else: + rtn = -1 + else: + rtn = -1 + return rtn + + def needsChannelSpecificDetection(self) -> bool: + return self.needs_channel_specific_detection + + + # ##### PROGRAM DUMP CAPABILITY + + def createProgramDumpRequest(self, channel: int, patchNo: int) -> List[int]: + device_id = 0x20 | (channel & 0x0f) + memory_type, memory_number = self._mapPatchNumToSynthMemory(patchNo) + msg = [*str2bytes(self.msg_id_voice_dump), *[0]*14, int(memory_type), memory_number] + # print(f"DEBUG ch:{channel} pN:{patchNo}", msg) + buf = self._makeMessage(device_id, msg, add_checksum=False) + logging.debug(f"createProgramDumpRequest({channel}, {patchNo}): {bytes2str(buf[:32])}") + return buf + + def isSingleProgramDump(self, buf: List[int]) -> bool: + if self._validateVoiceMessage(buf): + msg_size = self._getMessageSize(buf) + rtn = msg_size == len(buf) + logging.debug(f"isSingleProgramDump: msgSize:{msg_size} totalSize:{len(buf)} -> {rtn}") + else: + rtn = False + logging.debug(f"isSingleProgramDump: invalid msg: {buf}") + return rtn + + def convertToProgramDump(self, channel: int, message: List[int], patchNo: int) -> List[int]: + buf = message.copy() + buf[OFFSET_DEVICE_ID] = channel & 0x0f + buf[self.offset_memory_type], buf[self.offset_memory_number] = self._mapPatchNumToSynthMemory(patchNo) + buf[OFFSET_CHECKSUM] = self._calculateChecksum(buf) + logging.debug(f"convertToProgramDump({channel}, msg): " + f"MemType/Num:{message[self.offset_memory_type]:02x}{message[self.offset_memory_number]:02x}" + f"->{buf[self.offset_memory_type]:02x}{buf[self.offset_memory_number]:02x}") + return buf + + + # ##### EDIT BUFFER CAPABILITIES + + def convertToEditBuffer(self, channel: int, msg: List[int]) -> List[int]: + buf = msg.copy() + buf[OFFSET_DEVICE_ID] = channel & 0x0f + buf[self.offset_memory_type] = self.memory_types.EDIT + buf[self.offset_memory_number] = 0 + buf[OFFSET_CHECKSUM] = self._calculateChecksum(buf) + logging.debug(f"convertToEditBuffer({channel}, msg): " + f"MemType/Num:{msg[self.offset_memory_type]:02x}{msg[self.offset_memory_number]:02x}" + f"->{buf[self.offset_memory_type]:02x}{buf[self.offset_memory_number]:02x}") + return buf + + def createEditBufferRequest(self, channel: int) -> List[int]: + device_id = 0x20 | (channel & 0x0f) + msg = [*str2bytes(self.msg_id_voice_dump), *[0]*14, int(self.memory_types['EDIT']), 0] + buf = self._makeMessage(device_id, msg, add_checksum=False) + logging.debug(f"createEditBufferRequest({channel}: {bytes2str(buf[:32])} ... {bytes2str(buf[-2:])}") + return buf + + def isEditBufferDump(self, buf: List[int]) -> bool: + rtn = self._validateVoiceMessage(buf) and (buf[self.offset_memory_type] == self.memory_types['EDIT']) + logging.debug(f"isEditBufferDump: MemType:{buf[self.offset_memory_type]:02x} " + f"{buf[self.offset_memory_type] == self.memory_types['EDIT']} -> {rtn}") + return rtn + + + # ##### BANK CAPABILITIES + + def bankDescriptors(self) -> List[dict]: + return self.banks + + def isPartOfBankDump(self, first_message: List[int]) -> bool: + return self._getMessageSize(first_message) < len(first_message) + + def friendlyProgramName(self, patchNo: int) -> str: + rtn ="OVERRIDE friendlyProgramName()" + return rtn + + def friendlyBankName(self, bank_number: int) -> str: + rtn = self.banks[bank_number]["name"] + logging.debug(f"friendlyBankName(bank_number) -> {rtn}") + return rtn + + + # ##### SYSEX MESSAGE HELPERS + + def _makeMessage(self, device_id: int, msg: List[int], add_checksum: bool=True) -> List[int]: + buf = [SYSEX_START, YAMAHA_ID, device_id, self.synth_id] + msg + if add_checksum: + buf += [0, SYSEX_END] + buf[OFFSET_CHECKSUM] = self._calculateChecksum(buf) + else: + buf += [SYSEX_END] + logging.debug(f"make_message({device_id}, msg={msg}, add_checksum={add_checksum}): {bytes2str(buf)}") + return buf + + def _calculateChecksum(self, data: List[int]) -> int: + """ + Checksum the SysEx array. This excludes the first 6 bytes (f0 43 0n, 7a + 2 byte data length). + Returns the checksum byte to be inserted at OFFSET_CHECKSUM. + """ + data_sum = sum(data[6:-2]) & 0x7f # sum & mask to 7 bit values + checksum = (0x80 - data_sum) & 0x7f # subtract from 128 (0x80), mask again for 7-bit value + return checksum + + def _validateMessage(self, buf: List[int]) -> bool: + if len(buf) < 32: + return False + csum = self._calculateChecksum(buf) + rtn = ( + buf[0] == SYSEX_START and + buf[1] == YAMAHA_ID and + buf[3] == self.synth_id and + buf[OFFSET_CHECKSUM] == csum and + buf[-1] == SYSEX_END + ) + logging.debug(f"validate_message: {bytes2str(buf[:32])} ... {bytes2str(buf[-2:])}" + f" chk:{buf[-2]:02x} ?? ver:{csum:02x} --> {rtn}") + return rtn + + def _validateVoiceMessage(self, buf: List[int]) -> bool: + rtn = self._validateMessage(buf) and self._getMessageType(buf) == str2bytes(self.msg_id_voice_dump) + logging.debug(f"validate_voice_message: rtn:{rtn}") + return rtn + + def _getMemoryType(self, buf: List[int]) -> int: + return self.memory_types(buf[self.offset_memory_type]) + + def _getMemoryNumber(self, buf: List[int]) -> int: + return buf[self.offset_memory_number] + + def _getMessageType(self, buf: List[int]) -> List[int]: + return buf[OFFSET_MESSAGE_TYPE:OFFSET_MESSAGE_TYPE_END] + + def __nameFromDump(self, buf: List[int]) -> str: + return "".join( + chr(c) for c in buf[self.offset_voice_name:self.offset_voice_name+self.voice_name_length] + ) + + def nameFromDump(self, buf: List[int]) -> str: + rtn = self.__nameFromDump(buf) + logging.debug(f"nameFromDump: rtn:{rtn}") + return rtn + + def numberFromDump(self, buf: List[int]) -> int: + rtn = self.bankSlotToPatchNo(buf[self.offset_memory_type], buf[self.offset_memory_number]) + logging.debug(f"numberFromDump: MemType/Num: {buf[self.offset_memory_type]}/{buf[self.offset_memory_number]} -> rtn:{rtn} -> rtn:{rtn}") + return rtn + + def _getPayloadSize(self, buf: List[int]) -> int: + "Returns payload size - the size field" + if len(buf) > OFFSET_SIZE_BYTE2: + return (buf[OFFSET_SIZE_BYTE1] << 7) + buf[OFFSET_SIZE_BYTE2] + else: + return 0 + + def _getMessageSize(self, buf: List[int]) -> int: + """ + Returns message size (inc. headers/tail): + - header (4 bytes) + - payload size field: 2 bytes + - payload (variable) + - tail (2 bytes: checksum and End of SysEx byte) + For a single voice a simple `len(buf)` would work fine, but for banks of voices + we need to use the size supplied in the message. + """ + return 4 + 2 + self._getPayloadSize(buf) + 2 + + def extractPatchesFromBank(self, bank: List[int]) -> List[List[int]]: + patches = [ + p for p in knobkraft.sysex.splitSysexMessage(bank) + if self._validateVoiceMessage(p) + ] + logging.debug(f"extractPatchesFromBank(): {len(patches)} patches extracted") + return patches + + def _mapPatchNumToSynthMemory(self, patchno: int) -> tuple[int, int]: + "Maps Knobcraft flat patch numbers to synth memory types and banks" + raise NotImplementedError + + def bankSlotToPatchNo(self, memory_type:int, memory_number: int) -> int: + return -1 # Override in child class + + def _memoryTypeNumberChecks(self, memory_type:int, memory_number: int): + if memory_type not in self.memory_types: + raise Exception(f"Invalid format (memory_type) for SY77/TG77 dump request given: {format}") + if not (0 <= memory_number <= 63): + raise Exception(f"Invalid format (memory_number) for SY77/TG77 dump request given: {format} (out of range)") + + def isDefaultName(self, patchName: int) -> bool: + rtn = patchName == self.voice_default_name + logging.debug(f"isDefaultName({patchName}) -> {rtn}") + return rtn + + def renamePatch(self, message, new_name) -> List[int]: + if not self._validateVoiceMessage(message): + raise ValueError("Not a Voice Dump") + + # truncate / space pad new_name + fmt_name = [0x20] * self.voice_name_length + for i, c in enumerate(new_name[:self.voice_name_length]): + fmt_name[i] = ord(c) + + # build new message + rtn = message.copy() + for i in range(0, self.voice_name_length): + rtn[self.offset_voice_name + i] = fmt_name[i] + rtn[OFFSET_CHECKSUM] = self._calculateChecksum(rtn) + logging.debug(f"renamePatch({new_name}): {self.__nameFromDump(rtn)}") + return rtn + + + # ##### KNOBCRAFT FUNCTIONS + + def blankedOut(self, buf: List[int]) -> List[int]: + buf[OFFSET_DEVICE_ID] = 0 + buf[self.offset_memory_type] = 0 + buf[self.offset_memory_number] = 0 + buf[OFFSET_CHECKSUM] = 0 + buf[self.offset_voice_name:self.offset_voice_name+self.voice_name_length] = [0] * self.voice_name_length + return buf + + def calculateFingerprint(self, buf: List[int]) -> str: + rtn = buf.copy() + rtn = self.blankedOut(rtn) + return hashlib.md5(bytearray(rtn)).hexdigest() + + # ##### CLASS OPERATIONS METHODS + + def install(self, module: ModuleType) -> None: + # This is required because the original KnobKraft modules are not objects, but rather a module namespace with + # methods declared. Expose our objects methods in the top level module namespace so the C++ code finds it + # TODO Make this a loop + for m in [ + 'name', + 'setupHelp', + # ##### DEVICE DETECTION CAPACBILITIES + 'createDeviceDetectMessage', + 'channelIfValidDeviceResponse', + 'needsChannelSpecificDetection', + # ##### PROGRAM DUMP CAPABILITY + 'createProgramDumpRequest', + 'isSingleProgramDump', + 'convertToProgramDump', + # ##### EDIT BUFFER CAPABILITIES + 'convertToEditBuffer', + 'createEditBufferRequest', + 'isEditBufferDump', + # ##### BANK CAPABILITIES + 'bankDescriptors', + 'isPartOfBankDump', + 'friendlyBankName', + # ##### SYSEX MESSAGE HELPERS + 'nameFromDump', + 'numberFromDump', + 'extractPatchesFromBank', + 'bankSlotToPatchNo', + 'isDefaultName', + 'renamePatch', + # ##### KNOBCRAFT FUNCTIONS + 'blankedOut', + 'calculateFingerprint', + ]: + setattr(module, m, getattr(self, m)) + +def str2bytes(s: str) -> List[int]: + return [ord(x) for x in s] + +def bytes2str(b: List[int], delimiter: str=' ') -> str: + return delimiter.join(f"{x:02x}" for x in b) diff --git a/adaptations/yamaha/__init__.py b/adaptations/yamaha/__init__.py new file mode 100644 index 00000000..e69de29b From eb789d8ba98762b353f87ed4c666672519b5a4f5 Mon Sep 17 00:00:00 2001 From: Christof Date: Tue, 17 Nov 2026 22:58:57 +0100 Subject: [PATCH 2/3] Add Giovanni Candiago's Yamaha SY77/TG77 voice adaptation (cherry picked from commit 86e256520e03ad30038186f837b50e2993a21898) --- README.md | 1 + adaptations/CMakeLists.txt | 3 +- adaptations/Yamaha_SY77-TG77.py | 397 ++++++++++++++++++ .../Yamaha_SY77-TG77/TG77_test_voices.syx | Bin 0 -> 53666 bytes adaptations/test_Yamaha_SY77_TG77.py | 43 ++ data/supported-synths.json | 11 +- docs/data/supported-synths.yml | 6 + docs/supported-synths.md | 1 + 8 files changed, 460 insertions(+), 2 deletions(-) create mode 100644 adaptations/Yamaha_SY77-TG77.py create mode 100644 adaptations/testData/Yamaha_SY77-TG77/TG77_test_voices.syx create mode 100644 adaptations/test_Yamaha_SY77_TG77.py diff --git a/README.md b/README.md index 35c97b7d..b94cf51a 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ This table is generated from `docs/data/supported-synths.yml` by `scripts/genera | Yamaha | FS1R | alpha | adaptation | 2.10.2 | Thanks to @markusschlosser for testing! | | Yamaha | reface DX | works | adaptation | 2.10.2 | | | Yamaha | reface CP | beta | adaptation | 2.10.2 | Thanks to @milnak! | +| Yamaha | SY77 / TG77 (voices) | beta | adaptation | After 2.10.2 | Contributed and tested on TG77 by Giovanni Candiago. SY77 hardware testing pending. | | Yamaha | TX7 | works | adaptation | 2.10.2 | Thanks to Gerome S! | | Yamaha | TX81Z | works | adaptation | 2.10.2 | Contributed by @summersetter! | | Yamaha | Yamaha YC61/YC73/YC88 | works | adaptation | 2.10.2 | Thanks to @milnak! | diff --git a/adaptations/CMakeLists.txt b/adaptations/CMakeLists.txt index f2a473a9..b037472e 100644 --- a/adaptations/CMakeLists.txt +++ b/adaptations/CMakeLists.txt @@ -35,7 +35,7 @@ set(adaptation_files "Sequential_Fourm.py" "Sequential Pro 3.py" "Sequential Prophet 5 Rev4.py" "Sequential Prophet 6.py" "Sequential Prophet X.py" "Sequential_Take_5.py" "Sequential_Trigon6.py" "Studiologic Sledge.py" "Waldorf Blofeld.py" "Waldorf_Kyra.py" "Waldorf_MicroWave.py" "Waldorf_M.py" "Waldorf_Pulse.py" - "YamahaDX7.py" "YamahaDX7II.py" "Yamaha_TX7.py" "Yamaha_FS1R.py" "YamahaRefaceDX.py" "YamahaRefaceCP.py" "Yamaha_TX81Z.py" "Yamaha-YC-Series.py" + "YamahaDX7.py" "YamahaDX7II.py" "Yamaha_TX7.py" "Yamaha_FS1R.py" "YamahaRefaceDX.py" "YamahaRefaceCP.py" "Yamaha_TX81Z.py" "Yamaha-YC-Series.py" "Yamaha_SY77-TG77.py" "Zoom_MS.py" ) @@ -60,6 +60,7 @@ set(adaptation_files_test_shipped "test_Sequential_Fourm.py" "test_Sequential_Pro_3.py" "test_YamahaRefaceDX.py" + "test_Yamaha_SY77_TG77.py" ) set(adaptation_files_test_only diff --git a/adaptations/Yamaha_SY77-TG77.py b/adaptations/Yamaha_SY77-TG77.py new file mode 100644 index 00000000..8169b589 --- /dev/null +++ b/adaptations/Yamaha_SY77-TG77.py @@ -0,0 +1,397 @@ +# Yamaha SY77/TG77 voice adaptation contributed by Giovanni Candiago. +# Based on the KnobKraft Yamaha reface DX adaptation. +# Live MIDI workflows were tested on a TG77. +import hashlib + +# English: Model ID and specific headers for the SY/TG77 series +# Italiano: Model ID e intestazioni specifiche per la serie SY/TG77 +TG77_MODEL_ID = 0x7A +TG77_LM_HEADER = [0x4C, 0x4D, 0x20, 0x20, 0x38, 0x31, 0x30, 0x31] # ASCII "LM 8101" + +# English: Mapping of TG77 Voice Types from index 32 (byte 33, F0 included) +# Italiano: Mappatura dei tipi di voce TG77 dall'indice 32 (byte 33, F0 incluso) +TG77_VOICE_TYPES = { + 0x00: "1AFM mono", + 0x01: "2AFM mono", + 0x02: "4AFM mono", + 0x03: "1AFM", + 0x04: "2AFM", + 0x05: "1AWM", + 0x06: "2AWM", + 0x07: "4AWM", + 0x08: "1AFM+1AWM", + 0x09: "2AFM+2AWM", + 0x0A: "Drum set" +} + +# English: Header of a VOICE bulk dump, indices 6-15: ASCII "LM 8101VC". +# English: Other bulk dumps (Multi MU, Pan PN, Micro tuning MT, System SY, Additional multi "8104MU", Program change +# English: table "8104PC") share the same layout but have a different header: they must NOT be taken for voices. +# Italiano: Intestazione di un bulk dump VOICE, indici 6-15: ASCII "LM 8101VC". +# Italiano: Gli altri bulk dump (Multi MU, Pan PN, Micro tuning MT, System SY, Multi aggiuntivo "8104MU", Tabella +# Italiano: program change "8104PC") hanno la stessa struttura ma un'intestazione diversa: NON vanno scambiati per voci. +TG77_VOICE_DUMP_ID = TG77_LM_HEADER + [0x56, 0x43] # "LM 8101" + "VC" +TG77_SYSTEM_DUMP_ID = TG77_LM_HEADER + [0x53, 0x59] # "LM 8101" + "SY" (reply to the device detect) + +# English: Voice types that can ONLY be stored in bank D (slots 0x30-0x3F, voices 49-64). +# English: 0x02=4AFM mono, 0x07=4AWM, 0x09=2AFM+2AWM (the three "large" voice types, confirmed by the user) +# English: and 0x0A=Drum set (MIDI DATA FORMAT, voice bulk dump table: Memory# $30-$3F). +# English: In the edit buffer any voice type can be loaded. +# Italiano: Tipi voce salvabili SOLO nel banco D (slot 0x30-0x3F, voci 49-64). +# Italiano: 0x02=4AFM mono, 0x07=4AWM, 0x09=2AFM+2AWM (le tre voci "grandi", confermato dall'utente) +# Italiano: e 0x0A=Drum set (MIDI DATA FORMAT, tabella voice bulk dump: Memory# $30-$3F). +# Italiano: Nell'edit buffer si puo caricare qualsiasi tipo di voce. +TG77_DBANK_ONLY_TYPES = {0x02, 0x07, 0x09, 0x0A} + +# English: Bank D starts at slot 0x30 (voice 49). Larger voices are restricted to these slots. +# Italiano: Il banco D inizia allo slot 0x30 (voce 49). Le voci grandi possono essere salvate solo qui. +TG77_BANK_D_START = 0x30 + + +# --------------------------------------------------------------------------- +# Internal helpers (prefix _ = not called by KnobKraft directly) +# --------------------------------------------------------------------------- + +def _slotToLabel(slot): + # English: Convert raw slot 0x00-0x3F to TG77 display label e.g. 0x00->"A01", 0x2F->"C16" + # English: Single 64-voice internal memory divided in sub-banks: + # English: A = 0x00-0x0F voices 01-16 + # English: B = 0x10-0x1F voices 17-32 + # English: C = 0x20-0x2F voices 33-48 + # English: D = 0x30-0x3F voices 49-64 + # Italiano: Converte slot grezzo 0x00-0x3F in etichetta display TG77 es. 0x00->"A01" + bank_letter = "ABCD"[slot >> 4] # nibble alto 0-3 -> A B C D + position = (slot & 0x0F) + 1 # nibble basso 0-15 -> 1-16 + return f"{bank_letter}{position:02d}" + +def _isBulkDump(message, dump_id, minimum_size): + return ( + len(message) >= minimum_size + and message[0] == 0xF0 + and message[1] == 0x43 + and 0 <= message[2] <= 0x0F + and message[3] == TG77_MODEL_ID + and message[-1] == 0xF7 + and list(message[6:16]) == dump_id + and (message[4] << 7) + message[5] == len(message) - 8 + and all(0 <= byte < 0x80 for byte in message[1:-1]) + and message[-2] == calculateChecksum(message[6:-2]) + ) + + +def _isVoiceDump(message): + # English: True only for a TG77/SY77 VOICE bulk dump: F0 43 0n 7A, byte count, "LM 8101VC". + # English: Memory type (index 30) is checked by the callers: 0x7F edit buffer, 0x00 internal memory. + # Italiano: Vero solo per un bulk dump VOICE TG77/SY77: F0 43 0n 7A, byte count, "LM 8101VC". + # Italiano: Il tipo memoria (indice 30) lo controllano i chiamanti: 0x7F edit buffer, 0x00 memoria interna. + return _isBulkDump(message, TG77_VOICE_DUMP_ID, 45) + + +# The system dump reports the voice receive channel for the responding SysEx device number. +_voice_receive_channels = {} + + +def _deviceNibble(channel): + # English: KnobKraft channel is 0-based (0..15) = Device number 1..16 = low nibble of the Device ID byte. + # English: Anything invalid falls back to device number 1 (nibble 0). + # Italiano: Il canale di KnobKraft e 0-based (0..15) = Device number 1..16 = nibble basso del byte Device ID. + # Italiano: Un valore non valido torna al device number 1 (nibble 0). + if channel is not None and 0 <= channel <= 15: + return channel & 0x0F + return 0 + + +# --------------------------------------------------------------------------- +# KnobKraft required functions +# --------------------------------------------------------------------------- + +def name(): + return "Yamaha SY77-TG77" + +def setupHelp(): + return ( + "Voice support was tested on the TG77. SY77 hardware and writes to internal memory still need testing. " + "For Program change send mode on the TG77, set Program change mode to Normal. " + "Run detection again after changing the Voice Receive Channel. " + "To write to internal memory, turn off Bulk Protect on the synth. " + "4AFM mono, 4AWM, 2AFM+2AWM and Drum Set voices require a slot from D01 to D16." + ) + + +def createDeviceDetectMessage(channel): + return [0xF0, 0x43, 0x20 | _deviceNibble(channel), TG77_MODEL_ID] + TG77_SYSTEM_DUMP_ID + [0] * 16 + [0xF7] + + +def needsChannelSpecificDetection(): + return True + + +def generalMessageDelay(): + # English: Pause in ms between the messages of ONE call (edit buffer request: EDIT mode + dump request + + # English: VOICE mode). Tested on the TG77: the biggest voice type (4AFM, 1564 bytes, about 0.66 s to be + # English: transmitted) needs at least 600 ms; with 400 ms the instrument stays in the edit window. + # English: 800 = tested value + margin. Calls that return a single message (program dump request, + # English: program dump, edit buffer send) are not affected, so the 64 voices download is not slower. + # Italiano: Pausa in ms tra i messaggi di UNA chiamata (richiesta edit buffer: modo EDIT + dump request + + # Italiano: modo VOICE). Provato sul TG77: la voce piu grande (4AFM, 1564 byte, circa 0,66 s di trasmissione) + # Italiano: richiede almeno 600 ms; con 400 ms lo strumento resta nella finestra edit. + # Italiano: 800 = valore provato + margine. Le chiamate con un solo messaggio (richiesta program dump, + # Italiano: program dump, invio edit buffer) non sono toccate, quindi il download delle 64 voci non rallenta. + return 800 + +def channelIfValidDeviceResponse(message): + # English: The reply to the identity request is the System bulk dump "LM 8101SY". + # English: Device ID byte (index 2) is 0x0n with n = Device number - 1, so the channel is its low nibble. + # English: Returns a 0-based channel; KnobKraft adds 1 internally. + # Italiano: La risposta alla identity request e il bulk dump System "LM 8101SY". + # Italiano: Il byte Device ID (indice 2) e 0x0n con n = Device number - 1, quindi il canale e il suo nibble basso. + # Italiano: Restituisce un canale 0-based; KnobKraft aggiunge 1 internamente. + if not _isBulkDump(message, TG77_SYSTEM_DUMP_ID, 83): + return -1 + device_number = message[2] + voice_channel = message[80] + # 16 means omni. Fall back to the detected device number in that case. + _voice_receive_channels[device_number] = voice_channel if voice_channel < 16 else device_number + return device_number + + +def createCustomProgramChange(channel, patchNo): + # English: KnobKraft "Program change" send mode: recalls a voice already in the TG77 internal memory. + # English: Program change 0-63 = voices 1-64 (TG77 "Program change mode" must be Normal). It goes on the + # English: voice receive channel read at detect (VRCH), NOT on the device number channel; if unknown or omni, + # English: the detected channel is used. + # Italiano: Modo di invio "Program change" di KnobKraft: richiama una voce gia presente nella memoria interna del TG77. + # Italiano: Program change 0-63 = voci 1-64 (il "Program change mode" del TG77 deve essere Normal). Va sul canale di + # Italiano: ricezione voci letto al rilevamento (VRCH), NON sul canale del device number; se sconosciuto o omni + # Italiano: si usa il canale rilevato. + device_number = _deviceNibble(channel) + midi_channel = _voice_receive_channels.get(device_number, device_number) + return [0xC0 | midi_channel, patchNo & 0x3F] + +def numberOfBanks(): + # English: One logical bank = the single 64-voice internal memory + # Italiano: Un banco logico = la memoria interna unica a 64 voci + return 1 + +def numberOfPatchesPerBank(): + return 64 + +def friendlyBankName(bank): + # English: Only one bank (numberOfBanks() == 1): the internal memory, shown as A01-D16 in friendlyProgramName() + # Italiano: Un solo banco (numberOfBanks() == 1): la memoria interna, mostrata come A01-D16 in friendlyProgramName() + return "Internal" + +def numberFromDump(message): + # English: Memory number (index 31) of an internal memory dump. Bit 6 is ignored by the TG77 on reception. + # English: -1 for anything that is not a program dump (e.g. the edit buffer has no memory number). + # Italiano: Numero di memoria (indice 31) di un dump di memoria interna. Il bit 6 e ignorato dal TG77 in ricezione. + # Italiano: -1 per tutto cio che non e un program dump (es. l'edit buffer non ha numero di memoria). + if isSingleProgramDump(message): + return message[31] & 0x3F + return -1 + +def friendlyProgramName(programNo): + if programNo == 0x7F: + return "Edit voice" + slot = programNo & 0x3F + label = _slotToLabel(slot) + return f"{programNo + 1:02d}-{label}" + +def friendlyEditBufferName(): + return "Edit voice" + +def isDefaultName(patch_name): + clean_name = patch_name.strip() + return clean_name == "Init Voice" or clean_name == "" + +def nameFromDump(message): + # English: 10 ASCII name bytes at indices 33-42 (bytes 34-43 counting from F0) + # Italiano: 10 byte ASCII nome agli indici 33-42 (byte 34-43 contando da F0) + if len(message) >= 43: + name_bytes = message[33:43] + return "".join([chr(x) if 32 <= x <= 126 else " " for x in name_bytes]).strip() + return "New Patch" + +def renamePatch(message, new_name): + data = list(message) + if len(data) > 44: + for i in range(10): + character = new_name[i] if i < len(new_name) else " " + data[33 + i] = ord(character) if " " <= character <= "~" else ord(" ") + data[-2] = calculateChecksum(data[6:-2]) + return data + +def calculateChecksum(data_block): + # English: Yamaha checksum: (128 - (sum_of_bytes & 0x7F)) & 0x7F + # English: Sum covers index 6 up to (not including) the checksum byte + # Italiano: Checksum Yamaha: (128 - (somma_byte & 0x7F)) & 0x7F + # Doc ref section 5 + s = sum(data_block) & 0x7F + return (128 - s) & 0x7F + +def createEditBufferRequest(channel): + # English: "Enter Edit Mode" command + request current Edit Buffer voice + # Italiano: Comando "Entra in modalita Edit" + richiesta voce Edit Buffer corrente + nibble = _deviceNibble(channel) + id_edit = 0x10 | nibble + id_dump = 0x20 | nibble + enter_edit_mode = [0xF0, 0x43, id_edit, 0x34, 0x0D, 0x00, 0x00, 0x05, 0x00, 0x7F, 0xF7] + request_dump = [0xF0, 0x43, id_dump, 0x7A, + 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0xF7] + enter_voice_mode = [0xF0, 0x43, id_edit, 0x34, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xF7] + return enter_edit_mode + request_dump + enter_voice_mode + +def isEditBufferDump(message): + # English: Voice dump ("VC") with memory type 0x7F at index 30 and memory number 0x00 at index 31 + # Italiano: Dump voice ("VC") con tipo memoria 0x7F all'indice 30 e numero memoria 0x00 all'indice 31 + if _isVoiceDump(message): + return message[30] == 0x7F and message[31] == 0x00 + return False + +def isSingleProgramDump(message): + # English: Voice dump ("VC") of the internal memory: memory type 0x00 at index 30, slot 0x00-0x3F at index 31 + # English: Mutually exclusive with isEditBufferDump (which has 0x7F at index 30) + # English: Other bulk dumps (Multi, Pan, Micro tuning, System, PC table) are rejected by the "VC" check. + # Italiano: Dump voice ("VC") della memoria interna: tipo memoria 0x00 all'indice 30, slot 0x00-0x3F all'indice 31 + # Italiano: Mutuamente esclusivo con isEditBufferDump (che ha 0x7F all'indice 30) + # Italiano: Gli altri bulk dump (Multi, Pan, Micro tuning, System, tabella PC) sono scartati dal controllo "VC". + # Doc ref section 6.a: bytes 31-32 = "00 01" for slot 2 + # English: ALSO accepted: the TG77 front panel sends a single voice with memory type 0x7F and the memory + # English: number it was recalled from (e.g. 0x2E = C15). With number 0x00 it stays an edit buffer dump. + # Italiano: ACCETTATO ANCHE: il pannello del TG77 invia una voce singola con tipo memoria 0x7F e il numero + # Italiano: della memoria da cui e stata richiamata (es. 0x2E = C15). Con numero 0x00 resta un dump edit buffer. + if _isVoiceDump(message): + return message[30] == 0x00 or (message[30] == 0x7F and message[31] != 0x00) + return False + +def isOwnSysex(message): + # English: Any TG77 SysEx: F0 + Yamaha 0x43 + TG77 model 0x7A at index 3 + # Italiano: Qualsiasi SysEx TG77: F0 + Yamaha 0x43 + modello TG77 0x7A all'indice 3 + return len(message) > 5 and message[1] == 0x43 and message[3] == 0x7A + +def createProgramDumpRequest(channel, patch_no): + # English: Bulk dump request = Device ID 0x2n, n = Device number - 1 (0x20 for device number 1) + # Italiano: Richiesta bulk dump = Device ID 0x2n, n = Device number - 1 (0x20 per device number 1) + req = [0xF0, 0x43, 0x20 | _deviceNibble(channel), 0x7A, + 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + patch_no & 0x3F, + 0xF7] + return req + +def convertToEditBuffer(channel, data): + # English: Set memory type 0x7F (edit buffer) and number 0x00 at indices 30-31; recalc checksum + # Italiano: Imposta tipo memoria 0x7F (edit buffer) e numero 0x00 agli indici 30-31; ricalc checksum + new_data = list(data) + if len(new_data) > 35: + new_data[30] = 0x7F + new_data[31] = 0x00 + new_data[2] = 0x00 | _deviceNibble(channel) + new_data[-2] = calculateChecksum(new_data[6:-2]) + return new_data + +def convertToProgramDump(channel, data, patch_no): + if not _isVoiceDump(data) or not 0 <= patch_no < 64: + print("Yamaha SY77-TG77: expected a voice dump and an internal slot from A01 to D16.") + return [] + + voice_type = data[32] + if voice_type in TG77_DBANK_ONLY_TYPES and patch_no < TG77_BANK_D_START: + print(f"Yamaha SY77-TG77: {TG77_VOICE_TYPES[voice_type]} cannot be stored at " + f"{_slotToLabel(patch_no)}. Choose a slot from D01 to D16.") + return [] + + new_data = list(data) + new_data[30] = 0x00 + new_data[31] = patch_no + new_data[2] = _deviceNibble(channel) + new_data[-2] = calculateChecksum(new_data[6:-2]) + return new_data + + +def calculateFingerprint(message): + # English: MD5 of the sound parameters only: voice type (index 32) + everything from index 43 (EFMODE, + # English: first effect parameter) up to the checksum. Skipped on purpose: device ID (2), byte count (4-5), + # English: header, memory type/number (30-31), name (33-42) and checksum, so renaming a voice or storing + # English: it in another memory does not change the fingerprint. + # Italiano: MD5 dei soli parametri del suono: tipo voce (indice 32) + tutto dall'indice 43 (EFMODE, + # Italiano: primo parametro effetti) fino al checksum. Esclusi di proposito: device ID (2), byte count (4-5), + # Italiano: intestazione, tipo/numero memoria (30-31), nome (33-42) e checksum, cosi rinominare una voce o + # Italiano: salvarla in un'altra memoria non cambia il fingerprint. + if len(message) > 44: + return hashlib.md5(bytearray(list(message[32:33]) + list(message[43:-2]))).hexdigest() + return "empty" + +def changeChannelInMessage(new_channel, message): + # English: Update Device ID at index 2: keep upper nibble (0x0n data / 0x1n parameter / 0x2n request), + # English: set the lower nibble to the 0-based channel (Device number - 1) + # Italiano: Aggiorna Device ID all'indice 2: mantieni nibble alto (0x0n dati / 0x1n parametro / 0x2n richiesta), + # Italiano: imposta il nibble basso al canale 0-based (Device number - 1) + new_msg = list(message) + if len(new_msg) > 2: + new_msg[2] = (new_msg[2] & 0xF0) | _deviceNibble(new_channel) + return new_msg + +def isPartOfSingleProgramDump(message): + # English: A TG77 voice dump is one single MIDI message, so it is the same test as isSingleProgramDump + # Italiano: Un dump voice TG77 e un solo messaggio MIDI, quindi il test e lo stesso di isSingleProgramDump + return isSingleProgramDump(message) + +def make_test_data(): + # English: Feeds the generic KnobKraft adaptation test suite. The file testData/Yamaha_SY77-TG77/TG77_test_voices.syx + # English: holds 75 single-voice dumps (memory type 0x00): messages 0-63 = the 64 internal voices (number = index), + # English: messages 64-74 = the same voice in all 11 voice modes (TG77_11_VOICE_MODE, stored D01-D11 = numbers 48-58). + # English: Samples: one voice per type from the 64 + the two PD:PUFF AT voices that differ only in EFMODE (2 vs 1) + # English: + all 11 modes (1AFM/2AFM/4AFM mono, 1AFM/2AFM, 1AWM/2AWM/4AWM, 1AFM+1AWM, 2AFM+2AWM, Drum set). + # Italiano: Alimenta la suite di test generica delle adaptation KnobKraft. Il file testData/Yamaha_SY77-TG77/TG77_test_voices.syx + # Italiano: contiene 75 dump di voce singola (tipo memoria 0x00): messaggi 0-63 = le 64 voci interne (numero = indice), + # Italiano: messaggi 64-74 = la stessa voce in tutti gli 11 modi (TG77_11_VOICE_MODE, salvate D01-D11 = numeri 48-58). + # Italiano: Campioni: una voce per tipo dalle 64 + le due voci PD:PUFF AT che differiscono solo per EFMODE (2 contro 1) + # Italiano: + tutti gli 11 modi (1AFM/2AFM/4AFM mono, 1AFM/2AFM, 1AWM/2AWM/4AWM, 1AFM+1AWM, 2AFM+2AWM, Drum set). + import testing + + # (index in file, expected memory number, expected name, description for the comment) + samples = [ + (12, 12, "PD:GB AGE", "1AFM"), + (2, 2, "PD:WARM", "2AFM"), + (6, 6, "WN:PICCOLO", "1AWM"), + (4, 4, "PD:CHRSTRG", "2AWM"), + (0, 0, "PD:PUFF AT", "1AFM+1AWM, EFMODE 2"), + (19, 19, "PD:PUFF AT", "1AFM+1AWM, EFMODE 1"), + (48, 48, "PD:OPET", "2AFM+2AWM"), + (64, 48, "1AFM mono", "1AFM mono"), + (65, 49, "2AFM mono", "2AFM mono"), + (66, 50, "4AFM mono", "4AFM mono (1564 bytes)"), + (67, 51, "1AFM poly", "1AFM"), + (68, 52, "2AFM poly", "2AFM"), + (69, 53, "1AWM poly", "1AWM"), + (70, 54, "2AWM poly", "2AWM"), + (71, 55, "4AWM poly", "4AWM"), + (72, 56, "1AFM&1AWM", "1AFM+1AWM"), + (73, 57, "2AFM&2AWM", "2AFM+2AWM"), + (74, 58, "Drum Set", "Drum set"), + ] + + def programs(test_data): + for index, number, name, _description in samples: + yield testing.ProgramTestData(message=test_data.all_messages[index], name=name, + friendly_number=f"{number + 1:02d}-{_slotToLabel(number)}", + rename_name="NEW NAME", number=number, target_no=number) + + def edit_buffers(test_data): + # English: No original edit buffer file: built from the program dumps with convertToEditBuffer (type 0x7F, number 0) + # Italiano: Nessun file originale dell'edit buffer: ricavato dai program dump con convertToEditBuffer (tipo 0x7F, numero 0) + for index, number, name, _description in samples: + yield testing.ProgramTestData(message=convertToEditBuffer(0, test_data.all_messages[index]), + name=name, rename_name="NEW NAME", target_no=number) + + return testing.TestData(sysex="testData/Yamaha_SY77-TG77/TG77_test_voices.syx", + expected_patch_count=75, program_generator=programs, + edit_buffer_generator=edit_buffers) + + +# English: End of Yamaha SY77-TG77 Adaptation +# Italiano: Fine dell'Adattamento per Yamaha SY77-TG77 diff --git a/adaptations/testData/Yamaha_SY77-TG77/TG77_test_voices.syx b/adaptations/testData/Yamaha_SY77-TG77/TG77_test_voices.syx new file mode 100644 index 0000000000000000000000000000000000000000..d7f92d0608a6156368b601f3ddd7a2b8ed76e60c GIT binary patch literal 53666 zcmeHw`9l=f@^78)nVy|(1`rn*HrWJW6j?;NM?k>^2%rY&9Fn!*#8th2&}c>rz=2+^o^9ltHSZzxu9_!>0t{H)P^dg&eA=$^)zV zVaB%YH2$}3A`|}ukgQIdR1)9#nkEk_3cunX{5O~GNSw1*?Uj-TY~r^u+oZH2pd2|8 zV0uR{@WhJ^Fekcz8Nl?-$o#<({Yvlg^HwPu2k=>@B0z>JXw0B`;iv*IqUZD+Z#N6D zD9y<{(@d2AZe(HSi2g(G0R91(M|;xAGxnUlf_IY_WSSYXp{QG9epAIfvAi-i<*Y9| zj%iTYXa6pQVh_OyOoi-vj{B>HA;>{i-ghm2+`C@f@u< zF@8PVbsXGUiuVb6^-$T}MBU_kC%0&1;m(oIa`mIY5Xmjz4c^?1$LMN*M|*y8#_)en zAL!ROu>G(9X)a1Cxv{&vx4E;vu|KECbyY`)G9J3*UOcVbbRl&Pzw5y7Kq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xfCrtBYKn5R%pwoPpnx*;fw@UL#vqm<>M1x>B&QUVQT1B-} zdp3#peRA~V=`+U(l`A7&rY{#)_$G!F#fL1qaBvaAtgVo!@>~}Ow}~jNCb6l0b7yaR zV|(B5`kN^CnwmQ$r)ruhHH2f=^;y|S)Jv-=?r$QZy!=yKLaqTZt*Kk21o9F)WGZ&3tyCd@(~YJ@kZ<@Fg@iu zRxB{ut7goCU1~OJ?(D*}C=|WaG!0v*iZLi-E@uLw2zF$ld_-5!809G}VBP~|(#pEY zjbT<;mT*qDMh?3HF%G%>RVt(fU+R0*=q9JWfsjzq6w2UY0QFH#P3#yu1yNetyt{XE zy`;=>7v~<3dBaVVVF)ZjD_QCmMClwySKp0!G{|2GypPT2QnJm2Lc>y$5@uyN`C3>F!><7*QtWhLA;R`E+fIS8082!<8qb*D|+vW?83kX z%jn(}V3rInmx{u4mc1*eS;fCJ=D`|f63lgbS2$#Y@GoONAEDXbyV8sOv4T0c6{IhM zc~D~x>|H^tQBV=yyRy#1$AVD-g~p69m#X6&R1FGCfLy*11aCr%d}cDH5XQMBlRY*z zW-^B1SSIfSd;Q*(D;Zw!FnZ0t+Vmz&XAw-dHqNkO?DI)6OFyQQ0weICF-I#prFXC> zNxaXn#|;S&z_!wF@1PM9Ai^)u^d`}k%%5!G*d8M#GIh0CNS9PG{LV5`w3`HA}`nEaH=a->7%_|RXP0KZ~1pW?}KnP<{T?B z3yI4gpQ}~&RzLjR@BR6Ch-v-_hy1wN>B-UBv2wJSWMk~S=%2qDx~xjgXFL1o)7#m9 z_f%gx&QzG literal 0 HcmV?d00001 diff --git a/adaptations/test_Yamaha_SY77_TG77.py b/adaptations/test_Yamaha_SY77_TG77.py new file mode 100644 index 00000000..dd329209 --- /dev/null +++ b/adaptations/test_Yamaha_SY77_TG77.py @@ -0,0 +1,43 @@ +import importlib +from pathlib import Path + +import knobkraft + + +yamaha = importlib.import_module("Yamaha_SY77-TG77") +FIXTURE = Path(__file__).parent / "testData" / "Yamaha_SY77-TG77" / "TG77_test_voices.syx" + + +def test_detection_requests_only_system_data(): + assert yamaha.needsChannelSpecificDetection() + for device_number in range(16): + assert yamaha.createDeviceDetectMessage(device_number) == [ + 0xF0, 0x43, 0x20 | device_number, 0x7A, + *b"LM 8101SY", *([0] * 16), 0xF7, + ] + + +def test_system_dump_sets_voice_receive_channel(monkeypatch): + monkeypatch.setattr(yamaha, "_voice_receive_channels", {}) + system_data = [*b"LM 8101SY", *([0] * 80)] + system_data[80 - 6] = 8 + reply = [0xF0, 0x43, 0x0F, 0x7A, 0, 90, *system_data, (-sum(system_data)) & 0x7F, 0xF7] + + assert yamaha.channelIfValidDeviceResponse(reply) == 15 + assert yamaha.createCustomProgramChange(15, 21) == [0xC8, 21] + assert yamaha.createCustomProgramChange(3, 21) == [0xC3, 21] + + reply[80] = 4 + assert yamaha.channelIfValidDeviceResponse(reply) == -1 + assert yamaha.createCustomProgramChange(15, 21) == [0xC8, 21] + + +def test_large_voices_require_an_explicit_bank_d_slot(): + voices = knobkraft.load_sysex(str(FIXTURE)) + for index in (66, 71, 73, 74): + voice = voices[index] + assert yamaha.convertToProgramDump(5, voice, 47) == [] + converted = yamaha.convertToProgramDump(5, voice, 48) + assert yamaha.numberFromDump(converted) == 48 + assert converted[2] == 5 + assert yamaha.calculateFingerprint(voice) == yamaha.calculateFingerprint(converted) diff --git a/data/supported-synths.json b/data/supported-synths.json index 3177bc2b..92b16525 100644 --- a/data/supported-synths.json +++ b/data/supported-synths.json @@ -1,7 +1,7 @@ { "source_revision": "76b39b7c767129eaeb01534008547e8a320b0886", "release_checked": "2.10.2", - "count": 92, + "count": 93, "synths": [ { "manufacturer": "Access", @@ -795,6 +795,15 @@ "kudos": "Thanks to @milnak!", "availability": "2.10.2" }, + { + "manufacturer": "Yamaha", + "synth": "SY77 / TG77 (voices)", + "status": "beta", + "statusLabel": "Beta", + "type": "adaptation", + "kudos": "Contributed and tested on TG77 by Giovanni Candiago. SY77 hardware testing pending.", + "availability": "After 2.10.2" + }, { "manufacturer": "Yamaha", "synth": "TX7", diff --git a/docs/data/supported-synths.yml b/docs/data/supported-synths.yml index 345c380b..8a6e7685 100644 --- a/docs/data/supported-synths.yml +++ b/docs/data/supported-synths.yml @@ -531,6 +531,12 @@ synths: type: adaptation kudos: Thanks to @milnak! availability: 2.10.2 +- manufacturer: Yamaha + synth: SY77 / TG77 (voices) + status: beta + type: adaptation + kudos: Contributed and tested on TG77 by Giovanni Candiago. SY77 hardware testing pending. + availability: After 2.10.2 - manufacturer: Yamaha synth: TX7 status: works diff --git a/docs/supported-synths.md b/docs/supported-synths.md index 2a2555e3..257e9a02 100644 --- a/docs/supported-synths.md +++ b/docs/supported-synths.md @@ -287,6 +287,7 @@ Use the searchable model filter, or choose a manufa | FS1R | alpha | adaptation | 2.10.2 | Thanks to @markusschlosser for testing! | | reface DX | works | adaptation | 2.10.2 | | | reface CP | beta | adaptation | 2.10.2 | Thanks to @milnak! | +| SY77 / TG77 (voices) | beta | adaptation | After 2.10.2 | Contributed and tested on TG77 by Giovanni Candiago. SY77 hardware testing pending. | | TX7 | works | adaptation | 2.10.2 | Thanks to Gerome S! | | TX81Z | works | adaptation | 2.10.2 | Contributed by @summersetter! | | Yamaha YC61/YC73/YC88 | works | adaptation | 2.10.2 | Thanks to @milnak! | From 87a5e996d8b6facbe04808fc22d0eb32c8927b9e Mon Sep 17 00:00:00 2001 From: Christof Date: Tue, 17 Nov 2026 23:27:10 +0100 Subject: [PATCH 3/3] Integrate the Yamaha SY77 and TG77 voice adaptations --- README.md | 3 +- The-Orm/CMakeLists.txt | 6 + The-Orm/setup.iss | 4 + adaptations/CMakeLists.txt | 4 +- adaptations/Yamaha_SY77-TG77.py | 397 ------------------ adaptations/Yamaha_SY77.py | 284 +------------ adaptations/Yamaha_TG77.py | 184 +-------- adaptations/test_Yamaha_SY77_TG77.py | 201 +++++++-- adaptations/yamaha/Yamaha77Voice.py | 297 ++++++++++++++ adaptations/yamaha/Yamaha_SY_TG_common.py | 475 ---------------------- data/supported-synths.json | 15 +- docs/data/supported-synths.yml | 10 +- docs/supported-synths.md | 3 +- docs/yamaha-sy77-tg77.md | 28 ++ 14 files changed, 567 insertions(+), 1344 deletions(-) delete mode 100644 adaptations/Yamaha_SY77-TG77.py create mode 100644 adaptations/yamaha/Yamaha77Voice.py delete mode 100644 adaptations/yamaha/Yamaha_SY_TG_common.py create mode 100644 docs/yamaha-sy77-tg77.md diff --git a/README.md b/README.md index b94cf51a..d57a123f 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,8 @@ This table is generated from `docs/data/supported-synths.yml` by `scripts/genera | Yamaha | FS1R | alpha | adaptation | 2.10.2 | Thanks to @markusschlosser for testing! | | Yamaha | reface DX | works | adaptation | 2.10.2 | | | Yamaha | reface CP | beta | adaptation | 2.10.2 | Thanks to @milnak! | -| Yamaha | SY77 / TG77 (voices) | beta | adaptation | After 2.10.2 | Contributed and tested on TG77 by Giovanni Candiago. SY77 hardware testing pending. | +| Yamaha | SY77 (voices) | beta | adaptation | After 2.10.2 | Contributed by @hmmbug and Giovanni Candiago. Original SY77 hardware testing by @hmmbug. | +| Yamaha | TG77 (voices) | beta | adaptation | After 2.10.2 | Contributed by @hmmbug and Giovanni Candiago. Original TG77 hardware testing by Giovanni Candiago. | | Yamaha | TX7 | works | adaptation | 2.10.2 | Thanks to Gerome S! | | Yamaha | TX81Z | works | adaptation | 2.10.2 | Contributed by @summersetter! | | Yamaha | Yamaha YC61/YC73/YC88 | works | adaptation | 2.10.2 | Thanks to @milnak! | diff --git a/The-Orm/CMakeLists.txt b/The-Orm/CMakeLists.txt index eabfbf3a..022db981 100644 --- a/The-Orm/CMakeLists.txt +++ b/The-Orm/CMakeLists.txt @@ -277,6 +277,12 @@ add_custom_command(TARGET KnobKraftOrm POST_BUILD -DNO_PYCACHE_DEST_DIR=$/korg -P ${CMAKE_SOURCE_DIR}/cmake/copy_without_pycache.cmake ) +add_custom_command(TARGET KnobKraftOrm POST_BUILD + COMMAND ${CMAKE_COMMAND} + -DNO_PYCACHE_SOURCE_DIR=${CMAKE_SOURCE_DIR}/adaptations/yamaha + -DNO_PYCACHE_DEST_DIR=$/yamaha + -P ${CMAKE_SOURCE_DIR}/cmake/copy_without_pycache.cmake + ) add_custom_command(TARGET KnobKraftOrm POST_BUILD COMMAND ${CMAKE_COMMAND} -DNO_PYCACHE_SOURCE_DIR=${CMAKE_SOURCE_DIR}/adaptations/knobkraft diff --git a/The-Orm/setup.iss b/The-Orm/setup.iss index c8e0e75a..a8f84794 100644 --- a/The-Orm/setup.iss +++ b/The-Orm/setup.iss @@ -50,6 +50,7 @@ Source: "${CMAKE_CURRENT_BINARY_DIR}\RelWithDebInfo\WinSparkle.dll"; DestDir: "{ Source: "${CMAKE_SOURCE_DIR}\adaptations\sequential\*.*"; DestDir: "{app}\sequential";Flags: ignoreversion Source: "${CMAKE_SOURCE_DIR}\adaptations\roland\*.*"; DestDir: "{app}\roland";Flags: ignoreversion Source: "${CMAKE_SOURCE_DIR}\adaptations\korg\*.*"; DestDir: "{app}\korg";Flags: ignoreversion +Source: "${CMAKE_SOURCE_DIR}\adaptations\yamaha\*.py"; DestDir: "{app}\yamaha";Flags: ignoreversion Source: "${CMAKE_SOURCE_DIR}\adaptations\knobkraft\*.*"; DestDir: "{app}\knobkraft";Flags: ignoreversion Source: "${CMAKE_SOURCE_DIR}\adaptations\testing\*.*"; DestDir: "{app}\testing";Flags: ignoreversion #include "adaptations.iss" @@ -66,6 +67,9 @@ Type: dirifempty; Name: "{app}\roland" Type: files; Name: "{app}\korg\__pycache__\*.pyc" Type: dirifempty; Name: "{app}\korg\__pycache__" Type: dirifempty; Name: "{app}\korg" +Type: files; Name: "{app}\yamaha\__pycache__\*.pyc" +Type: dirifempty; Name: "{app}\yamaha\__pycache__" +Type: dirifempty; Name: "{app}\yamaha" Type: files; Name: "{app}\knobkraft\__pycache__\*.pyc" Type: dirifempty; Name: "{app}\knobkraft\__pycache__" Type: dirifempty; Name: "{app}\knobkraft" diff --git a/adaptations/CMakeLists.txt b/adaptations/CMakeLists.txt index b037472e..b464f7d0 100644 --- a/adaptations/CMakeLists.txt +++ b/adaptations/CMakeLists.txt @@ -35,7 +35,7 @@ set(adaptation_files "Sequential_Fourm.py" "Sequential Pro 3.py" "Sequential Prophet 5 Rev4.py" "Sequential Prophet 6.py" "Sequential Prophet X.py" "Sequential_Take_5.py" "Sequential_Trigon6.py" "Studiologic Sledge.py" "Waldorf Blofeld.py" "Waldorf_Kyra.py" "Waldorf_MicroWave.py" "Waldorf_M.py" "Waldorf_Pulse.py" - "YamahaDX7.py" "YamahaDX7II.py" "Yamaha_TX7.py" "Yamaha_FS1R.py" "YamahaRefaceDX.py" "YamahaRefaceCP.py" "Yamaha_TX81Z.py" "Yamaha-YC-Series.py" "Yamaha_SY77-TG77.py" + "YamahaDX7.py" "YamahaDX7II.py" "Yamaha_TX7.py" "Yamaha_FS1R.py" "YamahaRefaceDX.py" "YamahaRefaceCP.py" "Yamaha_TX81Z.py" "Yamaha-YC-Series.py" "Yamaha_SY77.py" "Yamaha_TG77.py" "Zoom_MS.py" ) @@ -72,6 +72,7 @@ set(adaptation_files_test_only set(adaptation_support_files "roland/__init__.py" "roland/GenericRoland.py" "sequential/__init__.py" "sequential/GenericSequential.py" + "yamaha/__init__.py" "yamaha/Yamaha77Voice.py" "knobkraft/__init__.py" "knobkraft/adaptation_module.py" "knobkraft/sysex.py" "knobkraft/test_helper.py" "korg/__init__.py" "korg/GenericKorg.py" "testing/__init__.py" "testing/test_data.py" @@ -130,6 +131,7 @@ if(UNIX AND NOT APPLE) # Define additional install files - in our case, all adaptation files and the python modules install(DIRECTORY sequential/ DESTINATION bin/sequential PATTERN "__pycache__" EXCLUDE) install(DIRECTORY roland/ DESTINATION bin/roland PATTERN "__pycache__" EXCLUDE) + install(DIRECTORY yamaha/ DESTINATION bin/yamaha PATTERN "__pycache__" EXCLUDE) install(DIRECTORY korg/ DESTINATION bin/korg PATTERN "__pycache__" EXCLUDE) install(DIRECTORY knobkraft/ DESTINATION bin/knobkraft PATTERN "__pycache__" EXCLUDE) install(DIRECTORY testing/ DESTINATION bin/testing PATTERN "__pycache__" EXCLUDE) diff --git a/adaptations/Yamaha_SY77-TG77.py b/adaptations/Yamaha_SY77-TG77.py deleted file mode 100644 index 8169b589..00000000 --- a/adaptations/Yamaha_SY77-TG77.py +++ /dev/null @@ -1,397 +0,0 @@ -# Yamaha SY77/TG77 voice adaptation contributed by Giovanni Candiago. -# Based on the KnobKraft Yamaha reface DX adaptation. -# Live MIDI workflows were tested on a TG77. -import hashlib - -# English: Model ID and specific headers for the SY/TG77 series -# Italiano: Model ID e intestazioni specifiche per la serie SY/TG77 -TG77_MODEL_ID = 0x7A -TG77_LM_HEADER = [0x4C, 0x4D, 0x20, 0x20, 0x38, 0x31, 0x30, 0x31] # ASCII "LM 8101" - -# English: Mapping of TG77 Voice Types from index 32 (byte 33, F0 included) -# Italiano: Mappatura dei tipi di voce TG77 dall'indice 32 (byte 33, F0 incluso) -TG77_VOICE_TYPES = { - 0x00: "1AFM mono", - 0x01: "2AFM mono", - 0x02: "4AFM mono", - 0x03: "1AFM", - 0x04: "2AFM", - 0x05: "1AWM", - 0x06: "2AWM", - 0x07: "4AWM", - 0x08: "1AFM+1AWM", - 0x09: "2AFM+2AWM", - 0x0A: "Drum set" -} - -# English: Header of a VOICE bulk dump, indices 6-15: ASCII "LM 8101VC". -# English: Other bulk dumps (Multi MU, Pan PN, Micro tuning MT, System SY, Additional multi "8104MU", Program change -# English: table "8104PC") share the same layout but have a different header: they must NOT be taken for voices. -# Italiano: Intestazione di un bulk dump VOICE, indici 6-15: ASCII "LM 8101VC". -# Italiano: Gli altri bulk dump (Multi MU, Pan PN, Micro tuning MT, System SY, Multi aggiuntivo "8104MU", Tabella -# Italiano: program change "8104PC") hanno la stessa struttura ma un'intestazione diversa: NON vanno scambiati per voci. -TG77_VOICE_DUMP_ID = TG77_LM_HEADER + [0x56, 0x43] # "LM 8101" + "VC" -TG77_SYSTEM_DUMP_ID = TG77_LM_HEADER + [0x53, 0x59] # "LM 8101" + "SY" (reply to the device detect) - -# English: Voice types that can ONLY be stored in bank D (slots 0x30-0x3F, voices 49-64). -# English: 0x02=4AFM mono, 0x07=4AWM, 0x09=2AFM+2AWM (the three "large" voice types, confirmed by the user) -# English: and 0x0A=Drum set (MIDI DATA FORMAT, voice bulk dump table: Memory# $30-$3F). -# English: In the edit buffer any voice type can be loaded. -# Italiano: Tipi voce salvabili SOLO nel banco D (slot 0x30-0x3F, voci 49-64). -# Italiano: 0x02=4AFM mono, 0x07=4AWM, 0x09=2AFM+2AWM (le tre voci "grandi", confermato dall'utente) -# Italiano: e 0x0A=Drum set (MIDI DATA FORMAT, tabella voice bulk dump: Memory# $30-$3F). -# Italiano: Nell'edit buffer si puo caricare qualsiasi tipo di voce. -TG77_DBANK_ONLY_TYPES = {0x02, 0x07, 0x09, 0x0A} - -# English: Bank D starts at slot 0x30 (voice 49). Larger voices are restricted to these slots. -# Italiano: Il banco D inizia allo slot 0x30 (voce 49). Le voci grandi possono essere salvate solo qui. -TG77_BANK_D_START = 0x30 - - -# --------------------------------------------------------------------------- -# Internal helpers (prefix _ = not called by KnobKraft directly) -# --------------------------------------------------------------------------- - -def _slotToLabel(slot): - # English: Convert raw slot 0x00-0x3F to TG77 display label e.g. 0x00->"A01", 0x2F->"C16" - # English: Single 64-voice internal memory divided in sub-banks: - # English: A = 0x00-0x0F voices 01-16 - # English: B = 0x10-0x1F voices 17-32 - # English: C = 0x20-0x2F voices 33-48 - # English: D = 0x30-0x3F voices 49-64 - # Italiano: Converte slot grezzo 0x00-0x3F in etichetta display TG77 es. 0x00->"A01" - bank_letter = "ABCD"[slot >> 4] # nibble alto 0-3 -> A B C D - position = (slot & 0x0F) + 1 # nibble basso 0-15 -> 1-16 - return f"{bank_letter}{position:02d}" - -def _isBulkDump(message, dump_id, minimum_size): - return ( - len(message) >= minimum_size - and message[0] == 0xF0 - and message[1] == 0x43 - and 0 <= message[2] <= 0x0F - and message[3] == TG77_MODEL_ID - and message[-1] == 0xF7 - and list(message[6:16]) == dump_id - and (message[4] << 7) + message[5] == len(message) - 8 - and all(0 <= byte < 0x80 for byte in message[1:-1]) - and message[-2] == calculateChecksum(message[6:-2]) - ) - - -def _isVoiceDump(message): - # English: True only for a TG77/SY77 VOICE bulk dump: F0 43 0n 7A, byte count, "LM 8101VC". - # English: Memory type (index 30) is checked by the callers: 0x7F edit buffer, 0x00 internal memory. - # Italiano: Vero solo per un bulk dump VOICE TG77/SY77: F0 43 0n 7A, byte count, "LM 8101VC". - # Italiano: Il tipo memoria (indice 30) lo controllano i chiamanti: 0x7F edit buffer, 0x00 memoria interna. - return _isBulkDump(message, TG77_VOICE_DUMP_ID, 45) - - -# The system dump reports the voice receive channel for the responding SysEx device number. -_voice_receive_channels = {} - - -def _deviceNibble(channel): - # English: KnobKraft channel is 0-based (0..15) = Device number 1..16 = low nibble of the Device ID byte. - # English: Anything invalid falls back to device number 1 (nibble 0). - # Italiano: Il canale di KnobKraft e 0-based (0..15) = Device number 1..16 = nibble basso del byte Device ID. - # Italiano: Un valore non valido torna al device number 1 (nibble 0). - if channel is not None and 0 <= channel <= 15: - return channel & 0x0F - return 0 - - -# --------------------------------------------------------------------------- -# KnobKraft required functions -# --------------------------------------------------------------------------- - -def name(): - return "Yamaha SY77-TG77" - -def setupHelp(): - return ( - "Voice support was tested on the TG77. SY77 hardware and writes to internal memory still need testing. " - "For Program change send mode on the TG77, set Program change mode to Normal. " - "Run detection again after changing the Voice Receive Channel. " - "To write to internal memory, turn off Bulk Protect on the synth. " - "4AFM mono, 4AWM, 2AFM+2AWM and Drum Set voices require a slot from D01 to D16." - ) - - -def createDeviceDetectMessage(channel): - return [0xF0, 0x43, 0x20 | _deviceNibble(channel), TG77_MODEL_ID] + TG77_SYSTEM_DUMP_ID + [0] * 16 + [0xF7] - - -def needsChannelSpecificDetection(): - return True - - -def generalMessageDelay(): - # English: Pause in ms between the messages of ONE call (edit buffer request: EDIT mode + dump request + - # English: VOICE mode). Tested on the TG77: the biggest voice type (4AFM, 1564 bytes, about 0.66 s to be - # English: transmitted) needs at least 600 ms; with 400 ms the instrument stays in the edit window. - # English: 800 = tested value + margin. Calls that return a single message (program dump request, - # English: program dump, edit buffer send) are not affected, so the 64 voices download is not slower. - # Italiano: Pausa in ms tra i messaggi di UNA chiamata (richiesta edit buffer: modo EDIT + dump request + - # Italiano: modo VOICE). Provato sul TG77: la voce piu grande (4AFM, 1564 byte, circa 0,66 s di trasmissione) - # Italiano: richiede almeno 600 ms; con 400 ms lo strumento resta nella finestra edit. - # Italiano: 800 = valore provato + margine. Le chiamate con un solo messaggio (richiesta program dump, - # Italiano: program dump, invio edit buffer) non sono toccate, quindi il download delle 64 voci non rallenta. - return 800 - -def channelIfValidDeviceResponse(message): - # English: The reply to the identity request is the System bulk dump "LM 8101SY". - # English: Device ID byte (index 2) is 0x0n with n = Device number - 1, so the channel is its low nibble. - # English: Returns a 0-based channel; KnobKraft adds 1 internally. - # Italiano: La risposta alla identity request e il bulk dump System "LM 8101SY". - # Italiano: Il byte Device ID (indice 2) e 0x0n con n = Device number - 1, quindi il canale e il suo nibble basso. - # Italiano: Restituisce un canale 0-based; KnobKraft aggiunge 1 internamente. - if not _isBulkDump(message, TG77_SYSTEM_DUMP_ID, 83): - return -1 - device_number = message[2] - voice_channel = message[80] - # 16 means omni. Fall back to the detected device number in that case. - _voice_receive_channels[device_number] = voice_channel if voice_channel < 16 else device_number - return device_number - - -def createCustomProgramChange(channel, patchNo): - # English: KnobKraft "Program change" send mode: recalls a voice already in the TG77 internal memory. - # English: Program change 0-63 = voices 1-64 (TG77 "Program change mode" must be Normal). It goes on the - # English: voice receive channel read at detect (VRCH), NOT on the device number channel; if unknown or omni, - # English: the detected channel is used. - # Italiano: Modo di invio "Program change" di KnobKraft: richiama una voce gia presente nella memoria interna del TG77. - # Italiano: Program change 0-63 = voci 1-64 (il "Program change mode" del TG77 deve essere Normal). Va sul canale di - # Italiano: ricezione voci letto al rilevamento (VRCH), NON sul canale del device number; se sconosciuto o omni - # Italiano: si usa il canale rilevato. - device_number = _deviceNibble(channel) - midi_channel = _voice_receive_channels.get(device_number, device_number) - return [0xC0 | midi_channel, patchNo & 0x3F] - -def numberOfBanks(): - # English: One logical bank = the single 64-voice internal memory - # Italiano: Un banco logico = la memoria interna unica a 64 voci - return 1 - -def numberOfPatchesPerBank(): - return 64 - -def friendlyBankName(bank): - # English: Only one bank (numberOfBanks() == 1): the internal memory, shown as A01-D16 in friendlyProgramName() - # Italiano: Un solo banco (numberOfBanks() == 1): la memoria interna, mostrata come A01-D16 in friendlyProgramName() - return "Internal" - -def numberFromDump(message): - # English: Memory number (index 31) of an internal memory dump. Bit 6 is ignored by the TG77 on reception. - # English: -1 for anything that is not a program dump (e.g. the edit buffer has no memory number). - # Italiano: Numero di memoria (indice 31) di un dump di memoria interna. Il bit 6 e ignorato dal TG77 in ricezione. - # Italiano: -1 per tutto cio che non e un program dump (es. l'edit buffer non ha numero di memoria). - if isSingleProgramDump(message): - return message[31] & 0x3F - return -1 - -def friendlyProgramName(programNo): - if programNo == 0x7F: - return "Edit voice" - slot = programNo & 0x3F - label = _slotToLabel(slot) - return f"{programNo + 1:02d}-{label}" - -def friendlyEditBufferName(): - return "Edit voice" - -def isDefaultName(patch_name): - clean_name = patch_name.strip() - return clean_name == "Init Voice" or clean_name == "" - -def nameFromDump(message): - # English: 10 ASCII name bytes at indices 33-42 (bytes 34-43 counting from F0) - # Italiano: 10 byte ASCII nome agli indici 33-42 (byte 34-43 contando da F0) - if len(message) >= 43: - name_bytes = message[33:43] - return "".join([chr(x) if 32 <= x <= 126 else " " for x in name_bytes]).strip() - return "New Patch" - -def renamePatch(message, new_name): - data = list(message) - if len(data) > 44: - for i in range(10): - character = new_name[i] if i < len(new_name) else " " - data[33 + i] = ord(character) if " " <= character <= "~" else ord(" ") - data[-2] = calculateChecksum(data[6:-2]) - return data - -def calculateChecksum(data_block): - # English: Yamaha checksum: (128 - (sum_of_bytes & 0x7F)) & 0x7F - # English: Sum covers index 6 up to (not including) the checksum byte - # Italiano: Checksum Yamaha: (128 - (somma_byte & 0x7F)) & 0x7F - # Doc ref section 5 - s = sum(data_block) & 0x7F - return (128 - s) & 0x7F - -def createEditBufferRequest(channel): - # English: "Enter Edit Mode" command + request current Edit Buffer voice - # Italiano: Comando "Entra in modalita Edit" + richiesta voce Edit Buffer corrente - nibble = _deviceNibble(channel) - id_edit = 0x10 | nibble - id_dump = 0x20 | nibble - enter_edit_mode = [0xF0, 0x43, id_edit, 0x34, 0x0D, 0x00, 0x00, 0x05, 0x00, 0x7F, 0xF7] - request_dump = [0xF0, 0x43, id_dump, 0x7A, - 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0xF7] - enter_voice_mode = [0xF0, 0x43, id_edit, 0x34, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xF7] - return enter_edit_mode + request_dump + enter_voice_mode - -def isEditBufferDump(message): - # English: Voice dump ("VC") with memory type 0x7F at index 30 and memory number 0x00 at index 31 - # Italiano: Dump voice ("VC") con tipo memoria 0x7F all'indice 30 e numero memoria 0x00 all'indice 31 - if _isVoiceDump(message): - return message[30] == 0x7F and message[31] == 0x00 - return False - -def isSingleProgramDump(message): - # English: Voice dump ("VC") of the internal memory: memory type 0x00 at index 30, slot 0x00-0x3F at index 31 - # English: Mutually exclusive with isEditBufferDump (which has 0x7F at index 30) - # English: Other bulk dumps (Multi, Pan, Micro tuning, System, PC table) are rejected by the "VC" check. - # Italiano: Dump voice ("VC") della memoria interna: tipo memoria 0x00 all'indice 30, slot 0x00-0x3F all'indice 31 - # Italiano: Mutuamente esclusivo con isEditBufferDump (che ha 0x7F all'indice 30) - # Italiano: Gli altri bulk dump (Multi, Pan, Micro tuning, System, tabella PC) sono scartati dal controllo "VC". - # Doc ref section 6.a: bytes 31-32 = "00 01" for slot 2 - # English: ALSO accepted: the TG77 front panel sends a single voice with memory type 0x7F and the memory - # English: number it was recalled from (e.g. 0x2E = C15). With number 0x00 it stays an edit buffer dump. - # Italiano: ACCETTATO ANCHE: il pannello del TG77 invia una voce singola con tipo memoria 0x7F e il numero - # Italiano: della memoria da cui e stata richiamata (es. 0x2E = C15). Con numero 0x00 resta un dump edit buffer. - if _isVoiceDump(message): - return message[30] == 0x00 or (message[30] == 0x7F and message[31] != 0x00) - return False - -def isOwnSysex(message): - # English: Any TG77 SysEx: F0 + Yamaha 0x43 + TG77 model 0x7A at index 3 - # Italiano: Qualsiasi SysEx TG77: F0 + Yamaha 0x43 + modello TG77 0x7A all'indice 3 - return len(message) > 5 and message[1] == 0x43 and message[3] == 0x7A - -def createProgramDumpRequest(channel, patch_no): - # English: Bulk dump request = Device ID 0x2n, n = Device number - 1 (0x20 for device number 1) - # Italiano: Richiesta bulk dump = Device ID 0x2n, n = Device number - 1 (0x20 per device number 1) - req = [0xF0, 0x43, 0x20 | _deviceNibble(channel), 0x7A, - 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - patch_no & 0x3F, - 0xF7] - return req - -def convertToEditBuffer(channel, data): - # English: Set memory type 0x7F (edit buffer) and number 0x00 at indices 30-31; recalc checksum - # Italiano: Imposta tipo memoria 0x7F (edit buffer) e numero 0x00 agli indici 30-31; ricalc checksum - new_data = list(data) - if len(new_data) > 35: - new_data[30] = 0x7F - new_data[31] = 0x00 - new_data[2] = 0x00 | _deviceNibble(channel) - new_data[-2] = calculateChecksum(new_data[6:-2]) - return new_data - -def convertToProgramDump(channel, data, patch_no): - if not _isVoiceDump(data) or not 0 <= patch_no < 64: - print("Yamaha SY77-TG77: expected a voice dump and an internal slot from A01 to D16.") - return [] - - voice_type = data[32] - if voice_type in TG77_DBANK_ONLY_TYPES and patch_no < TG77_BANK_D_START: - print(f"Yamaha SY77-TG77: {TG77_VOICE_TYPES[voice_type]} cannot be stored at " - f"{_slotToLabel(patch_no)}. Choose a slot from D01 to D16.") - return [] - - new_data = list(data) - new_data[30] = 0x00 - new_data[31] = patch_no - new_data[2] = _deviceNibble(channel) - new_data[-2] = calculateChecksum(new_data[6:-2]) - return new_data - - -def calculateFingerprint(message): - # English: MD5 of the sound parameters only: voice type (index 32) + everything from index 43 (EFMODE, - # English: first effect parameter) up to the checksum. Skipped on purpose: device ID (2), byte count (4-5), - # English: header, memory type/number (30-31), name (33-42) and checksum, so renaming a voice or storing - # English: it in another memory does not change the fingerprint. - # Italiano: MD5 dei soli parametri del suono: tipo voce (indice 32) + tutto dall'indice 43 (EFMODE, - # Italiano: primo parametro effetti) fino al checksum. Esclusi di proposito: device ID (2), byte count (4-5), - # Italiano: intestazione, tipo/numero memoria (30-31), nome (33-42) e checksum, cosi rinominare una voce o - # Italiano: salvarla in un'altra memoria non cambia il fingerprint. - if len(message) > 44: - return hashlib.md5(bytearray(list(message[32:33]) + list(message[43:-2]))).hexdigest() - return "empty" - -def changeChannelInMessage(new_channel, message): - # English: Update Device ID at index 2: keep upper nibble (0x0n data / 0x1n parameter / 0x2n request), - # English: set the lower nibble to the 0-based channel (Device number - 1) - # Italiano: Aggiorna Device ID all'indice 2: mantieni nibble alto (0x0n dati / 0x1n parametro / 0x2n richiesta), - # Italiano: imposta il nibble basso al canale 0-based (Device number - 1) - new_msg = list(message) - if len(new_msg) > 2: - new_msg[2] = (new_msg[2] & 0xF0) | _deviceNibble(new_channel) - return new_msg - -def isPartOfSingleProgramDump(message): - # English: A TG77 voice dump is one single MIDI message, so it is the same test as isSingleProgramDump - # Italiano: Un dump voice TG77 e un solo messaggio MIDI, quindi il test e lo stesso di isSingleProgramDump - return isSingleProgramDump(message) - -def make_test_data(): - # English: Feeds the generic KnobKraft adaptation test suite. The file testData/Yamaha_SY77-TG77/TG77_test_voices.syx - # English: holds 75 single-voice dumps (memory type 0x00): messages 0-63 = the 64 internal voices (number = index), - # English: messages 64-74 = the same voice in all 11 voice modes (TG77_11_VOICE_MODE, stored D01-D11 = numbers 48-58). - # English: Samples: one voice per type from the 64 + the two PD:PUFF AT voices that differ only in EFMODE (2 vs 1) - # English: + all 11 modes (1AFM/2AFM/4AFM mono, 1AFM/2AFM, 1AWM/2AWM/4AWM, 1AFM+1AWM, 2AFM+2AWM, Drum set). - # Italiano: Alimenta la suite di test generica delle adaptation KnobKraft. Il file testData/Yamaha_SY77-TG77/TG77_test_voices.syx - # Italiano: contiene 75 dump di voce singola (tipo memoria 0x00): messaggi 0-63 = le 64 voci interne (numero = indice), - # Italiano: messaggi 64-74 = la stessa voce in tutti gli 11 modi (TG77_11_VOICE_MODE, salvate D01-D11 = numeri 48-58). - # Italiano: Campioni: una voce per tipo dalle 64 + le due voci PD:PUFF AT che differiscono solo per EFMODE (2 contro 1) - # Italiano: + tutti gli 11 modi (1AFM/2AFM/4AFM mono, 1AFM/2AFM, 1AWM/2AWM/4AWM, 1AFM+1AWM, 2AFM+2AWM, Drum set). - import testing - - # (index in file, expected memory number, expected name, description for the comment) - samples = [ - (12, 12, "PD:GB AGE", "1AFM"), - (2, 2, "PD:WARM", "2AFM"), - (6, 6, "WN:PICCOLO", "1AWM"), - (4, 4, "PD:CHRSTRG", "2AWM"), - (0, 0, "PD:PUFF AT", "1AFM+1AWM, EFMODE 2"), - (19, 19, "PD:PUFF AT", "1AFM+1AWM, EFMODE 1"), - (48, 48, "PD:OPET", "2AFM+2AWM"), - (64, 48, "1AFM mono", "1AFM mono"), - (65, 49, "2AFM mono", "2AFM mono"), - (66, 50, "4AFM mono", "4AFM mono (1564 bytes)"), - (67, 51, "1AFM poly", "1AFM"), - (68, 52, "2AFM poly", "2AFM"), - (69, 53, "1AWM poly", "1AWM"), - (70, 54, "2AWM poly", "2AWM"), - (71, 55, "4AWM poly", "4AWM"), - (72, 56, "1AFM&1AWM", "1AFM+1AWM"), - (73, 57, "2AFM&2AWM", "2AFM+2AWM"), - (74, 58, "Drum Set", "Drum set"), - ] - - def programs(test_data): - for index, number, name, _description in samples: - yield testing.ProgramTestData(message=test_data.all_messages[index], name=name, - friendly_number=f"{number + 1:02d}-{_slotToLabel(number)}", - rename_name="NEW NAME", number=number, target_no=number) - - def edit_buffers(test_data): - # English: No original edit buffer file: built from the program dumps with convertToEditBuffer (type 0x7F, number 0) - # Italiano: Nessun file originale dell'edit buffer: ricavato dai program dump con convertToEditBuffer (tipo 0x7F, numero 0) - for index, number, name, _description in samples: - yield testing.ProgramTestData(message=convertToEditBuffer(0, test_data.all_messages[index]), - name=name, rename_name="NEW NAME", target_no=number) - - return testing.TestData(sysex="testData/Yamaha_SY77-TG77/TG77_test_voices.syx", - expected_patch_count=75, program_generator=programs, - edit_buffer_generator=edit_buffers) - - -# English: End of Yamaha SY77-TG77 Adaptation -# Italiano: Fine dell'Adattamento per Yamaha SY77-TG77 diff --git a/adaptations/Yamaha_SY77.py b/adaptations/Yamaha_SY77.py index 33599f03..17e528bb 100644 --- a/adaptations/Yamaha_SY77.py +++ b/adaptations/Yamaha_SY77.py @@ -1,280 +1,14 @@ -""" -# Yamaha SY77 adaptation. +"""Yamaha SY77 voices. Initial adaptation and ROM 1.5 hardware testing by hmmbug.""" -Adaptation created by github.com/hmmbug. +from yamaha.Yamaha77Voice import Yamaha77Voice, voice_test_data -- Requires synth to be in program change "direct" mode (Utility -> MIDI -> - Program Change = direct) -- Requires "Bulk Protect" set to "off" (Utility -> MIDI -> Channel Set -> Bulk - Protect = Off) -- The SY77/TG77 has different settings for MIDI Channel and SysEx Device ID. +Yamaha77Voice("SY77", "GrandPiano").install(globals()) -## Testing Notes: -- Tested on an SY77 (ROM version 1.5). - -## Mapping SysEx Banks to Interface Banks -The SY77/TG77 maps voices (patches) to 3 main banks: - -- Internal (editable), 64 voice slots -- Preset 1 (read-only), 64 voice slots -- Preset 2 (read-only), 64 voice slots - -On the front panels, each of these 64-slot banks are split into 4 banks (A-D) -of 16 voices, so banks A-D represent voices 1-16, 17-32, 33-48, 49-64. In MIDI -these numbers are zero-indexed instead (0-63 voices). - -This adaptation largely ignores the 16 slot A-D banks and represents banks as -64 slots. The `friendlyProgramName(patchNo)` function references voices in the -same way as on the synth screen, eg "IN-A01" for Internal, Bank A, voice 1. - -## References: -- SY77 & TG77 MIDI Data Format Manuals: - https://usa.yamaha.com/files/download/other_assets/1/317121/SY77E2.PDF - https://usa.yamaha.com/files/download/other_assets/0/316980/TG77E2.PDF -""" - -from enum import IntEnum -import logging -import sys -from types import ModuleType -from typing import List - -import testing - -logging.basicConfig(level=logging.DEBUG) - -from yamaha.Yamaha_SY_TG_common import ( - YamahaSYTGBase, - bytes2str, - SYSEX_START, - YAMAHA_ID, - OFFSET_DEVICE_ID, - OFFSET_CHECKSUM, - SYSEX_END, -) - -this_module = sys.modules[__name__] - - -HELP_STRING = \ -"""SY77/TG77 Systems Settings: -- Set 'Program Change' mode to 'direct' (Utility -> MIDI -> Program Change) -- Set 'Bulk Protect' to 'off' (Utility -> MIDI -> Channel Set -> Bulk Protect) -- Set 'SysEx Device ID' appropriately. If in doubt, set it the same as the - MIDI channel or 'omni'. (Utility -> MIDI -> Channel Set -> Device ID) - -Only Voices are supported, no Multi, sequencer or other capabilities. -""" - -class MemoryType(IntEnum): - INTERNAL = 0x00 - PRESET1 = 0x02 - PRESET2 = 0x03 - EDIT = 0x7F - -BANKS = [ - { "bank": 0, "name": "Internal", "size": 64, "type": "Voice", "isROM": False, }, - { "bank": 1, "name": "Preset 1", "size": 64, "type": "Voice", "isROM": True, }, - { "bank": 2, "name": "Preset 2", "size": 64, "type": "Voice", "isROM": True, }, -] - - -class YamahaSY77(YamahaSYTGBase): - - def convertPatchesToBankDump(self, patches: List[List[int]]) -> List[int]: - # SY77, TG77 patch -> bank conversion - device_id = (self.detected_device_id if self.detected_device_id else 0) & 0x0f - bank = [] - for idx, patch in enumerate(patches): - buf = patch.copy() - buf[OFFSET_DEVICE_ID] = device_id - buf[self.offset_memory_type] = MemoryType.INTERNAL - buf[self.offset_memory_number] = idx - buf[OFFSET_CHECKSUM] = self._calculateChecksum(buf) - bank += buf - return bank - - def createCustomProgramChange(self, channel: int, patchNo: int) -> List[int]: - memtype, memnum = self._mapPatchNumToSynthMemory(patchNo) - if memtype == MemoryType.INTERNAL: bank_pc = 122 - elif memtype == MemoryType.PRESET1: bank_pc = 121 - elif memtype == MemoryType.PRESET2: bank_pc = 117 - else: - raise ValueError(f"Invalid memory type ({memtype}).") - rtn = [ - 0xc0 | (channel & 0x0f), bank_pc, # 'direct mode' program change for bank selection (manual ref 2.1.3) - 0xc0 | (channel & 0x0f), memnum # select the voice in the bank, based on patchNo MOD 64 - ] - logging.debug(f"createCustomProgramChange({channel},{patchNo}) -> {bytes2str(rtn)}") - return rtn - - def friendlyProgramName(self, patchNo: int) -> str: - # SY77: IN-A01 (internal, bank A, slot 1), P1-B03 (Preset 1, bank B, slot 3) - # same format as displayed on synth screen - memtype, memnum = self._mapPatchNumToSynthMemory(patchNo) - memname = ["IN", None, "P1", "P2"][memtype] - bankchar = "ABCD"[memnum // 16] - bankslot = memnum % 16 + 1 - rtn = f"{memname}-{bankchar}{bankslot:02d}" - logging.debug(f"friendlyProgramName: MemType/Num: {memtype}/{memnum} -> rtn:{rtn}") - return rtn - - def bankSlotToPatchNo(self, memory_type: int, memory_number: int) -> int: - self._memoryTypeNumberChecks(memory_type, memory_number) - if memory_type == self.memory_types["EDIT"]: rtn = -1 - elif memory_type == self.memory_types["INTERNAL"]: rtn = memory_number - elif memory_type == self.memory_types["PRESET1"]: rtn = memory_number + 64 - elif memory_type == self.memory_types["PRESET2"]: rtn = memory_number + 128 - else: - raise ValueError("Invalid memory type/number combination") - return rtn - - def _mapPatchNumToSynthMemory(self, patchno: int) -> tuple[int, int]: - "Maps Knobcraft flat patch numbers to synth memory types and banks" - rtn = None - if patchno <= 63: rtn = (int(self.memory_types["INTERNAL"]), patchno) - elif patchno <= 127: rtn = (int(self.memory_types["PRESET1"]), patchno - 64) - elif patchno <= 191: rtn = (int(self.memory_types["PRESET2"]), patchno - 128) - if rtn is None: - raise ValueError(f"Invalid patchno ({patchno})") - return rtn - - def install(self, module: ModuleType): - super().install(module) - setattr(module, 'convertPatchesToBankDump', self.convertPatchesToBankDump) - setattr(module, 'createCustomProgramChange', self.createCustomProgramChange) - setattr(module, 'friendlyProgramName', self.friendlyProgramName) - setattr(module, 'bankSlotToPatchNo', self.bankSlotToPatchNo) - - -synth = YamahaSY77( - synth_name="Yamaha SY77", - synth_id=0x7a, - - # voice - first_preset_name="GrandPiano", - msg_id_voice_dump="LM 8101VC", - voice_default_name="INIT VOICE", - voice_name_length=10, # 10 characters in the voice name - offset_voice_name=33, # location of voice name - - # banks - memory_types=MemoryType, - banks=BANKS, - - # data offsets in voice bulk dumps - offset_memory_type=30, # location of memory type (eg. INT, Preset) - offset_memory_number=31, # location of memory number (eg. patch num.) - offset_req_memory_type=28, # location of memory type in request - offset_req_memory_number=29, # location of memory num. in request - - help_string=HELP_STRING, -) -synth.install(this_module) - -# # ##### TEST FUNCTIONS - -# Unimplemented tests: -# - layers: not applicable -# - legacy_loader: no idea.. it's legacy so I guess it's deprecated... -# - *_via_mock_device: mock device not implemented def make_test_data(): - def programs(data: testing.TestData): - return [ - testing.ProgramTestData( - message=data.all_messages[0], - number=0, - name="GrandPiano", - friendly_number="IN-A01", - rename_name="New Patch" - ), - testing.ProgramTestData( - message=data.all_messages[6], - number=6, - name="Triton ", - friendly_number="IN-A07", - rename_name="New Patch" - ), - testing.ProgramTestData( - message=data.all_messages[7], - number=7, - name="FrenchHorn", - friendly_number="IN-A08", - rename_name="New Patch" - ), - ] - - def edit_buffers(data: testing.TestData): - edit_buffer = synth.convertToEditBuffer(0, data.all_messages[16]) - return [ - testing.ProgramTestData( - message=edit_buffer, name="Dyna Grand", number=0, rename_name="0123456789") - ] - - def banks(test_data: testing.TestData): - yield test_data.all_messages[0] - - return testing.TestData( - sysex="testData/Yamaha_SY77/bank.syx", - program_generator=programs, - edit_buffer_generator=edit_buffers, - bank_generator=banks, - program_dump_request=[ - # Preset 1, Voice 1 dump request - SYSEX_START, YAMAHA_ID, 0x20, synth.synth_id, 0x4c, 0x4d, 0x20, 0x20, - 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, SYSEX_END - ], - device_detect_call=[ - SYSEX_START, YAMAHA_ID, 0x20, synth.synth_id, 0x4c, 0x4d, 0x20, 0x20, - 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, SYSEX_END - ], - device_detect_reply=( - [ - # Preset 1 Voice 1 dump - 0xF0, 0x43, 0x00, 0x7A, 0x04, 0x43, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, - 0x08, 0x47, 0x72, 0x61, 0x6E, 0x64, 0x50, 0x69, 0x61, 0x6E, 0x6F, 0x01, 0x00, 0x38, 0x64, 0x03, - 0x10, 0x01, 0x01, 0x00, 0x64, 0x64, 0x08, 0x10, 0x10, 0x08, 0x06, 0x64, 0x17, 0x12, 0x05, 0x0A, - 0x10, 0x64, 0x1F, 0x0D, 0x05, 0x0B, 0x01, 0x01, 0x02, 0x00, 0x01, 0x15, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x7F, - 0x00, 0x00, 0x7F, 0x00, 0x40, 0x00, 0x7F, 0x01, 0x7F, 0x20, 0x06, 0x7F, 0x00, 0x40, 0x00, 0x7F, - 0x01, 0x7F, 0x20, 0x06, 0x3F, 0x18, 0x3F, 0x11, 0x22, 0x3F, 0x3F, 0x3A, 0x3A, 0x00, 0x00, 0x00, - 0x03, 0x3F, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x3F, 0x00, 0x00, 0x0E, 0x01, 0x00, - 0x00, 0x43, 0x00, 0x2A, 0x54, 0x7F, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x03, - 0x00, 0x3E, 0x1A, 0x3F, 0x0F, 0x1B, 0x3F, 0x3F, 0x3A, 0x3A, 0x00, 0x00, 0x00, 0x03, 0x3F, 0x00, - 0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0x12, 0x3F, 0x00, 0x0C, 0x0E, 0x01, 0x00, 0x00, 0x38, 0x00, - 0x2A, 0x54, 0x7F, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x3D, 0x18, - 0x17, 0x11, 0x1D, 0x3F, 0x3F, 0x39, 0x37, 0x00, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x01, 0x00, 0x06, - 0x00, 0x00, 0x01, 0x04, 0x3F, 0x01, 0x00, 0x0E, 0x01, 0x00, 0x00, 0x70, 0x00, 0x53, 0x5B, 0x60, - 0x00, 0x01, 0x00, 0x01, 0x00, 0x7B, 0x00, 0x7B, 0x01, 0x01, 0x00, 0x3F, 0x1F, 0x3F, 0x12, 0x22, - 0x3F, 0x3F, 0x38, 0x38, 0x00, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x13, 0x3F, 0x00, 0x02, 0x0E, 0x01, 0x12, 0x11, 0x56, 0x4B, 0x4C, 0x4D, 0x58, 0x01, 0x00, 0x00, - 0x79, 0x00, 0x7A, 0x00, 0x7C, 0x00, 0x06, 0x00, 0x3E, 0x12, 0x3F, 0x0F, 0x1B, 0x3F, 0x3F, 0x3A, - 0x3A, 0x00, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x10, 0x3F, 0x00, - 0x0A, 0x0E, 0x01, 0x15, 0x12, 0x4E, 0x00, 0x2A, 0x57, 0x58, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, - 0x01, 0x03, 0x00, 0x01, 0x00, 0x2A, 0x17, 0x13, 0x11, 0x21, 0x3F, 0x3F, 0x39, 0x37, 0x00, 0x00, - 0x00, 0x03, 0x34, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, 0x01, 0x14, 0x3F, 0x01, 0x0A, 0x0E, 0x01, - 0x30, 0x00, 0x6F, 0x29, 0x4A, 0x5A, 0x5B, 0x00, 0x01, 0x00, 0x71, 0x00, 0x6B, 0x00, 0x01, 0x00, - 0x01, 0x00, 0x21, 0x3F, 0x3F, 0x3F, 0x3F, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x41, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x02, 0x28, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x2A, 0x54, - 0x7F, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x7F, 0x00, 0x3F, 0x04, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x40, 0x22, 0x22, 0x22, 0x22, 0x22, 0x04, 0x00, 0x4B, 0x4C, 0x4D, 0x01, 0x00, - 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x40, 0x03, - 0x3E, 0x3F, 0x3F, 0x3F, 0x40, 0x40, 0x40, 0x40, 0x40, 0x01, 0x00, 0x00, 0x36, 0x13, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, - 0x40, 0x40, 0x40, 0x40, 0x01, 0x00, 0x48, 0x54, 0x7F, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, - 0x00, 0x01, 0x64, 0x00, 0x3F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x07, 0x00, 0x48, 0x54, 0x7F, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x06, - 0x00, 0x00, 0x3F, 0x0C, 0x0D, 0x0C, 0x1D, 0x3F, 0x3A, 0x02, 0x4B, 0x4C, 0x50, 0x51, 0x01, 0x00, - 0x01, 0x09, 0x01, 0x08, 0x00, 0x7F, 0x06, 0x00, 0x00, 0x08, 0xF7, - ], 0 - ), - expected_patch_count=64, - friendly_bank_name=(0, "Internal"), - ) + return voice_test_data("testData/Yamaha_SY77/bank.syx", 64, [ + (0, "GrandPiano", "IN-A01"), + (6, "Triton", "IN-A07"), + (7, "FrenchHorn", "IN-A08"), + (16, "Dyna Grand", "IN-B01"), + ]) diff --git a/adaptations/Yamaha_TG77.py b/adaptations/Yamaha_TG77.py index 2dfee13a..849fc816 100644 --- a/adaptations/Yamaha_TG77.py +++ b/adaptations/Yamaha_TG77.py @@ -1,171 +1,29 @@ +"""Yamaha TG77 voices. Initial adaptation by hmmbug and Giovanni Candiago. +TG77 hardware testing and all-voice-mode fixture by Giovanni Candiago. """ -# Yamaha SY77 adaptation. -Adaptation created by github.com/hmmbug. - -- Requires synth to be in program change "direct" mode (Utility -> MIDI -> Program Change = direct) -- Requires "Bulk Protect" set to "off" (Utility -> MIDI -> Channel Set -> Bulk Protect = Off) -- The SY77/TG77 has different settings for MIDI Channel and SysEx Device ID. -""" - -from enum import IntEnum -import logging -import sys -from types import ModuleType -from typing import List - -import testing - -logging.basicConfig(level=logging.DEBUG) - -from yamaha.Yamaha_SY_TG_common import ( - SYSEX_START, - YAMAHA_ID, - SYSEX_END, -) -from Yamaha_SY77 import ( - YamahaSY77, - MemoryType, - HELP_STRING, - BANKS, -) - -this_module = sys.modules[__name__] - -class YamahaTG77(YamahaSY77): - # No changes in the subclass, but it'll be easier on the eye in logs - # having the correct synth name when the class is referenced! - pass +from yamaha.Yamaha77Voice import Yamaha77Voice, voice_test_data +Yamaha77Voice("TG77", "SP|Cosmo").install(globals()) -synth = YamahaTG77( - synth_name="Yamaha TG77", - synth_id=0x7a, - # voice - first_preset_name="SP|Cosmo ", - msg_id_voice_dump="LM 8101VC", - voice_default_name="INIT VOICE", - voice_name_length=10, - offset_voice_name=33, +def generalMessageDelay(): + # Giovanni measured up to 800 ms for the 1564-byte 4AFM mono dump. + return 800 - # banks - memory_types=MemoryType, - banks=BANKS, - - # data offsets in voice bulk dumps - offset_memory_type=30, # location of memory type (eg. INT, Preset) - offset_memory_number=31, # location of memory number (eg. patch num.) - offset_req_memory_type=28, # location of memory type in request - offset_req_memory_number=29, # location of memory num. in request - - help_string=HELP_STRING, -) -synth.install(this_module) - -# # ##### TEST FUNCTIONS - -# Unimplemented tests: -# - layers: not applicable -# - legacy_loader: no idea.. it's legacy so I guess it's deprecated... -# - *_via_mock_device: mock device not implemented def make_test_data(): - def programs(data: testing.TestData): - return [ - testing.ProgramTestData( - message=data.all_messages[0], - number=64, - name="SP|Cosmo ", - friendly_number="P1-A01", - rename_name="New Patch" - ), - testing.ProgramTestData( - message=data.all_messages[6], - number=70, - name="SP:Darkpad", - friendly_number="P1-A07", - rename_name="New Patch" - ), - testing.ProgramTestData( - message=data.all_messages[10], - number=74, - name="SP|Annapad", - friendly_number="P1-A11", - rename_name="New Patch" - ), - ] - - def edit_buffers(data: testing.TestData): - edit_buffer = synth.convertToEditBuffer(0, data.all_messages[16]) - return [ - testing.ProgramTestData( - message=edit_buffer, name="BR:Plucky ", number=0, rename_name="0123456789") - ] - - def banks(test_data: testing.TestData): - yield test_data.all_messages[0] - - return testing.TestData( - sysex="testData/Yamaha_TG77/Preset1.syx", - program_generator=programs, - edit_buffer_generator=edit_buffers, - bank_generator=banks, - program_dump_request=[ - # Preset 1, Voice 1 dump request - SYSEX_START, YAMAHA_ID, 0x20, synth.synth_id, 0x4c, 0x4d, 0x20, 0x20, - 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, SYSEX_END - ], - device_detect_call=[ - SYSEX_START, YAMAHA_ID, 0x20, synth.synth_id, 0x4c, 0x4d, 0x20, 0x20, - 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, SYSEX_END - ], - device_detect_reply=( - [ - # Preset 1 bank, voice 1 - 0xF0, 0x43, 0x00, 0x7A, 0x04, 0x43, 0x4C, 0x4D, 0x20, 0x20, 0x38, 0x31, 0x30, 0x31, 0x56, 0x43, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, - 0x08, 0x53, 0x50, 0x7C, 0x43, 0x6F, 0x73, 0x6D, 0x6F, 0x20, 0x20, 0x01, 0x01, 0x64, 0x64, 0x05, - 0x64, 0x2A, 0x00, 0x03, 0x64, 0x64, 0x08, 0x64, 0x00, 0x00, 0x01, 0x20, 0x64, 0x18, 0x0A, 0x29, - 0x0A, 0x20, 0x64, 0x4B, 0x3F, 0x3E, 0x01, 0x00, 0x02, 0x00, 0x79, 0x11, 0x0C, 0x00, 0x0D, 0x00, - 0x0D, 0x00, 0x01, 0x43, 0x0A, 0x00, 0x02, 0x00, 0x0E, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x7F, - 0x00, 0x00, 0x7F, 0x00, 0x40, 0x00, 0x7F, 0x01, 0x7F, 0x44, 0x06, 0x7F, 0x00, 0x58, 0x00, 0x7F, - 0x01, 0x7F, 0x40, 0x06, 0x3F, 0x3F, 0x3F, 0x3F, 0x0A, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x00, 0x00, - 0x03, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x3F, 0x00, 0x01, 0x06, 0x01, 0x00, - 0x14, 0x69, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, 0x00, 0x00, 0x78, 0x00, 0x68, 0x00, 0x01, - 0x00, 0x1E, 0x3F, 0x3F, 0x3F, 0x1B, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x00, 0x00, 0x03, 0x3F, 0x00, - 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x04, 0x38, 0x03, 0x0C, 0x0F, 0x01, 0x00, 0x00, 0x7F, 0x24, - 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x6D, 0x00, 0x00, 0x00, 0x3F, 0x3F, - 0x3F, 0x3F, 0x0A, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x12, 0x3F, 0x00, 0x0B, 0x0E, 0x01, 0x00, 0x00, 0x69, 0x24, 0x37, 0x4C, 0x60, - 0x01, 0x00, 0x01, 0x00, 0x00, 0x78, 0x00, 0x71, 0x00, 0x01, 0x00, 0x1E, 0x3F, 0x3F, 0x3F, 0x1B, - 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, - 0x14, 0x38, 0x03, 0x0C, 0x03, 0x01, 0x00, 0x07, 0x7F, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, - 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F, 0x3F, 0x3F, 0x0A, 0x3F, 0x3F, 0x3F, - 0x3F, 0x3F, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x3F, 0x00, - 0x0A, 0x02, 0x01, 0x00, 0x07, 0x69, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, 0x00, 0x00, 0x78, - 0x00, 0x71, 0x00, 0x01, 0x00, 0x1E, 0x3F, 0x3F, 0x3F, 0x1B, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x00, - 0x00, 0x03, 0x3F, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x14, 0x38, 0x03, 0x0C, 0x07, 0x01, - 0x00, 0x14, 0x7F, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x29, 0x3F, 0x3F, 0x3F, 0x3F, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x42, - 0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x01, 0x64, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x24, 0x37, 0x4C, - 0x60, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x64, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x24, 0x37, 0x4C, 0x60, 0x00, 0x62, - 0x00, 0x6C, 0x00, 0x76, 0x01, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, 0x1D, 0x00, 0x3C, 0x40, 0x03, - 0x3F, 0x3F, 0x3F, 0x3F, 0x40, 0x40, 0x40, 0x40, 0x40, 0x01, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x5E, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, - 0x40, 0x40, 0x40, 0x40, 0x00, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, - 0x00, 0x01, 0x6A, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, - 0x40, 0x00, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x16, 0x3F, 0x3F, 0x00, 0x18, 0x3F, 0x3F, 0x00, 0x24, 0x37, 0x4C, 0x60, 0x01, 0x00, - 0x01, 0x00, 0x00, 0x7A, 0x00, 0x73, 0x02, 0x01, 0x00, 0x09, 0xF7, 0x2E, 0xF0, 0x86, 0x66, 0xF7 - ], 0 - ), - expected_patch_count=64, - friendly_bank_name=(0, "Internal"), - ) + return voice_test_data("testData/Yamaha_SY77-TG77/TG77_test_voices.syx", 75, [ + (0, "PD:PUFF AT", "IN-A01"), + (2, "PD:WARM", "IN-A03"), + (4, "PD:CHRSTRG", "IN-A05"), + (6, "WN:PICCOLO", "IN-A07"), + (12, "PD:GB AGE", "IN-A13"), + (19, "PD:PUFF AT", "IN-B04"), + (48, "PD:OPET", "IN-D01"), + ], mode_samples=[ + (64, "1AFM mono"), (65, "2AFM mono"), (66, "4AFM mono"), + (67, "1AFM poly"), (68, "2AFM poly"), (69, "1AWM poly"), + (70, "2AWM poly"), (71, "4AWM poly"), (72, "1AFM&1AWM"), + (73, "2AFM&2AWM"), (74, "Drum Set"), + ]) diff --git a/adaptations/test_Yamaha_SY77_TG77.py b/adaptations/test_Yamaha_SY77_TG77.py index dd329209..a6deaafc 100644 --- a/adaptations/test_Yamaha_SY77_TG77.py +++ b/adaptations/test_Yamaha_SY77_TG77.py @@ -1,43 +1,192 @@ -import importlib from pathlib import Path import knobkraft +import pytest +import Yamaha_SY77 as sy77 +import Yamaha_TG77 as tg77 +from yamaha.Yamaha77Voice import Yamaha77Voice -yamaha = importlib.import_module("Yamaha_SY77-TG77") -FIXTURE = Path(__file__).parent / "testData" / "Yamaha_SY77-TG77" / "TG77_test_voices.syx" +FIXTURES = Path(__file__).parent / "testData" +SY77_INTERNAL = "Yamaha_SY77/bank.syx" +TG77_PRESETS = "Yamaha_TG77/Preset1.syx" +TG77_PRESET_ONE = "Yamaha_TG77/Preset1_01_SP_Cosmo__.syx" +TG77_INTERNAL = "Yamaha_SY77-TG77/TG77_test_voices.syx" -def test_detection_requests_only_system_data(): - assert yamaha.needsChannelSpecificDetection() - for device_number in range(16): - assert yamaha.createDeviceDetectMessage(device_number) == [ - 0xF0, 0x43, 0x20 | device_number, 0x7A, - *b"LM 8101SY", *([0] * 16), 0xF7, + +def _system_reply(device, voice_channel): + payload = [*b"LM 8101SY", *([0] * 80)] + payload[80 - 6] = voice_channel + return [0xF0, 0x43, device, 0x7A, 0, 90, *payload, (-sum(payload)) & 0x7F, 0xF7] + + +def _with_memory(voice, device, memory, slot): + result = voice.copy() + result[2] = device + result[30:32] = [memory, slot] + result[-2] = (-sum(result[6:-2])) & 0x7F + return result + + +@pytest.mark.parametrize("module", [sy77, tg77]) +@pytest.mark.parametrize("file,count", [ + (SY77_INTERNAL, 64), (TG77_PRESETS, 64), (TG77_PRESET_ONE, 1), (TG77_INTERNAL, 75), +]) +def test_both_models_import_all_captured_voices(module, file, count): + voices = knobkraft.load_sysex(str(FIXTURES / file)) + assert len(voices) == count + for voice in voices: + expected_program = (64 if voice[30] == 2 else 0) + voice[31] + assert module.isSingleProgramDump(voice) + assert not module.isEditBufferDump(voice) + assert module.numberFromDump(voice) == expected_program + edit = module.convertToEditBuffer(11, voice) + assert module.isEditBufferDump(edit) + assert not module.isSingleProgramDump(edit) + assert edit[2] == 11 + assert module.calculateFingerprint(edit) == module.calculateFingerprint(voice) + + +@pytest.mark.parametrize("system_first", [True, False]) +@pytest.mark.parametrize("name,first_preset,other_preset,file,other_file", [ + ("SY77", "GrandPiano", "SP|Cosmo", SY77_INTERNAL, TG77_PRESET_ONE), + ("TG77", "SP|Cosmo", "GrandPiano", TG77_PRESET_ONE, SY77_INTERNAL), +]) +def test_detection_matches_only_its_factory_voice_and_learns_midi_channel( + system_first, name, first_preset, other_preset, file, other_file): + synth = Yamaha77Voice(name, first_preset) + device = 15 + for address in range(16): + assert knobkraft.splitSysex(synth.createDeviceDetectMessage(address)) == [ + [0xF0, 0x43, 0x20 | address, 0x7A, *b"LM 8101VC", + *([0] * 14), 2, 0, 0xF7], + [0xF0, 0x43, 0x20 | address, 0x7A, *b"LM 8101SY", + *([0] * 16), 0xF7], ] + system = _system_reply(device, 8) + # The SY77 hardware reply uses the edit-buffer address for the requested preset. + # The TG77 preset file stands in for a factory preset reply in this test. + model_data = knobkraft.load_sysex(str(FIXTURES / file))[0] + match = _with_memory(model_data, device, 0x7F if name == "SY77" else 2, 0) + other_data = knobkraft.load_sysex(str(FIXTURES / other_file))[0] + wrong_model = _with_memory(other_data, device, 2, 0) + assert synth.channelIfValidDeviceResponse(wrong_model) == -1 + + replies = [(system, -1), (match, device)] + for message, expected in replies if system_first else reversed(replies): + assert synth.channelIfValidDeviceResponse(message) == expected + + expected_pc = [0xC8, 122, 0xC8, 17] if name == "SY77" else [0xC8, 17] + assert synth.createCustomProgramChange(device, 17) == expected_pc + + other = Yamaha77Voice("TG77" if name == "SY77" else "SY77", other_preset) + other.createDeviceDetectMessage(device) + assert other.channelIfValidDeviceResponse(system) == -1 + assert other.channelIfValidDeviceResponse(match) == -1 + + +def test_system_reply_alone_cannot_replace_an_identified_devices_voice_channel(): + synth = Yamaha77Voice("TG77", "SP|Cosmo") + device = 5 + preset = knobkraft.load_sysex(str(FIXTURES / TG77_PRESET_ONE))[0] + match = _with_memory(preset, device, 2, 0) + synth.createDeviceDetectMessage(device) + assert synth.channelIfValidDeviceResponse(match) == device + assert synth.channelIfValidDeviceResponse(_system_reply(device, 8)) == -1 + + synth.createDeviceDetectMessage(device) + assert synth.channelIfValidDeviceResponse(_system_reply(device, 3)) == -1 + assert synth.createCustomProgramChange(device, 17) == [0xC8, 17] + assert synth.channelIfValidDeviceResponse(match) == device + assert synth.createCustomProgramChange(device, 17) == [0xC3, 17] + -def test_system_dump_sets_voice_receive_channel(monkeypatch): - monkeypatch.setattr(yamaha, "_voice_receive_channels", {}) - system_data = [*b"LM 8101SY", *([0] * 80)] - system_data[80 - 6] = 8 - reply = [0xF0, 0x43, 0x0F, 0x7A, 0, 90, *system_data, (-sum(system_data)) & 0x7F, 0xF7] +@pytest.mark.parametrize("program,bank_selector", [(0, 122), (64, 124), (191, 117)]) +def test_sy77_direct_mode_selects_voice_bank_then_slot(program, bank_selector): + assert sy77.createCustomProgramChange(4, program) == [ + 0xC4, bank_selector, 0xC4, program % 64, + ] - assert yamaha.channelIfValidDeviceResponse(reply) == 15 - assert yamaha.createCustomProgramChange(15, 21) == [0xC8, 21] - assert yamaha.createCustomProgramChange(3, 21) == [0xC3, 21] - reply[80] = 4 - assert yamaha.channelIfValidDeviceResponse(reply) == -1 - assert yamaha.createCustomProgramChange(15, 21) == [0xC8, 21] +def test_tg77_normal_mode_uses_the_selected_internal_bank(): + assert tg77.createCustomProgramChange(4, 63) == [0xC4, 63] + assert tg77.createCustomProgramChange(4, 64) == [] -def test_large_voices_require_an_explicit_bank_d_slot(): - voices = knobkraft.load_sysex(str(FIXTURE)) +@pytest.mark.parametrize("module", [sy77, tg77]) +@pytest.mark.parametrize("program", [-1, 192]) +def test_invalid_program_never_becomes_wire_data(module, program): + assert module.createCustomProgramChange(3, program) == [] + assert module.createProgramDumpRequest(3, program) == [] + + +@pytest.mark.parametrize("module", [sy77, tg77]) +def test_preset_bank_reads_and_writes_are_distinct(module): + assert [desc["isROM"] for desc in module.bankDescriptors()] == [False, True, True] + for program, address in ((0, [0, 0]), (63, [0, 63]), (64, [2, 0]), (127, [2, 63]), + (128, [3, 0]), (191, [3, 63])): + request = module.createProgramDumpRequest(5, program) + assert request[2] == 0x25 + assert request[-3:-1] == address + + preset = knobkraft.load_sysex(str(FIXTURES / TG77_PRESET_ONE))[0] + assert module.convertToProgramDump(7, preset, 64) == [] + assert module.numberFromDump(module.convertToProgramDump(7, preset, 15)) == 15 + assert not hasattr(module, "convertPatchesToBankDump") + + +@pytest.mark.parametrize("module", [sy77, tg77]) +def test_large_voices_require_an_explicit_bank_d_slot(module): + voices = knobkraft.load_sysex(str(FIXTURES / TG77_INTERNAL)) for index in (66, 71, 73, 74): voice = voices[index] - assert yamaha.convertToProgramDump(5, voice, 47) == [] - converted = yamaha.convertToProgramDump(5, voice, 48) - assert yamaha.numberFromDump(converted) == 48 + assert module.convertToProgramDump(5, voice, 47) == [] + converted = module.convertToProgramDump(5, voice, 48) + assert module.numberFromDump(converted) == 48 assert converted[2] == 5 - assert yamaha.calculateFingerprint(voice) == yamaha.calculateFingerprint(converted) + assert module.calculateFingerprint(voice) == module.calculateFingerprint(converted) + + +def test_model_specific_edit_buffer_requests(): + dump = [0xF0, 0x43, 0x26, 0x7A, *b"LM 8101VC", *([0] * 14), 0x7F, 0, 0xF7] + assert knobkraft.splitSysex(sy77.createEditBufferRequest(6)) == [dump] + assert knobkraft.splitSysex(tg77.createEditBufferRequest(6)) == [ + [0xF0, 0x43, 0x16, 0x34, 0x0D, 0, 0, 5, 0, 0x7F, 0xF7], + dump, + [0xF0, 0x43, 0x16, 0x34, 0x0D, 0, 0, 0, 0, 0x7F, 0xF7], + ] + assert tg77.generalMessageDelay() == 800 + + +def test_tg77_front_panel_single_voice_preserves_the_reported_slot(): + voice = knobkraft.load_sysex(str(FIXTURES / TG77_INTERNAL))[0] + manual = _with_memory(voice, 6, 0x7F, 0x2E) + assert tg77.numberFromDump(manual) == 0x2E + assert tg77.isSingleProgramDump(manual) + assert not tg77.isEditBufferDump(manual) + + # A01 has the same address as the edit buffer. + manual_a01 = _with_memory(voice, 6, 0x7F, 0) + assert tg77.isEditBufferDump(manual_a01) + assert not tg77.isSingleProgramDump(manual_a01) + + +def test_malformed_dumps_are_rejected_and_renames_preserve_sound(): + voices = knobkraft.load_sysex(str(FIXTURES / TG77_INTERNAL)) + voice = voices[0] + invalid_length = voice.copy() + invalid_length[5] ^= 1 + invalid_checksum = voice.copy() + invalid_checksum[-2] ^= 1 + for corrupt in (voice[:-1], invalid_length, invalid_checksum, _system_reply(0, 8)): + assert not tg77.isSingleProgramDump(corrupt) + assert not tg77.isEditBufferDump(corrupt) + assert tg77.convertToProgramDump(0, corrupt, 0) == [] + + renamed = tg77.renamePatch(voice, "Tést") + assert tg77.nameFromDump(renamed) == "T st" + assert tg77.isSingleProgramDump(renamed) + assert tg77.calculateFingerprint(renamed) == tg77.calculateFingerprint(voice) + assert tg77.calculateFingerprint(voices[19]) != tg77.calculateFingerprint(voice) diff --git a/adaptations/yamaha/Yamaha77Voice.py b/adaptations/yamaha/Yamaha77Voice.py new file mode 100644 index 00000000..346d68d0 --- /dev/null +++ b/adaptations/yamaha/Yamaha77Voice.py @@ -0,0 +1,297 @@ +"""Shared SY77/TG77 voice support by hmmbug and Giovanni Candiago.""" + +import hashlib + +YAMAHA = 0x43 +FORMAT = 0x7A +VOICE = b"LM 8101VC" +SYSTEM = b"LM 8101SY" + +INTERNAL, PRESET_1, PRESET_2, EDIT = 0x00, 0x02, 0x03, 0x7F +BANKS = (INTERNAL, PRESET_1, PRESET_2) +BANK_NAMES = ("Internal", "Preset 1", "Preset 2") +BANK_LABELS = ("IN", "P1", "P2") +VOICE_MODE_PROGRAM_CHANGES = (122, 124, 117) +BANK_SIZE = 64 +BANK_D_START = 48 +BANK_D_ONLY = {0x02: "4AFM mono", 0x07: "4AWM", 0x09: "2AFM+2AWM", 0x0A: "Drum Set"} + +MEMORY_TYPE = 30 +MEMORY_NUMBER = 31 +VOICE_TYPE = 32 +VOICE_NAME = slice(33, 43) +VOICE_RECEIVE_CHANNEL = 80 + + +def _device_number(channel): + return channel if channel is not None and 0 <= channel < 16 else 0 + + +def _checksum(data): + return (-sum(data)) & 0x7F + + +def _is_bulk_dump(message, identifier, minimum_size): + return ( + len(message) >= minimum_size + and message[0] == 0xF0 + and message[1] == YAMAHA + and 0 <= message[2] < 16 + and message[3] == FORMAT + and message[-1] == 0xF7 + and (message[4] << 7) + message[5] == len(message) - 8 + and all(0 <= byte < 0x80 for byte in message[1:-1]) + and bytes(message[6:16]) == identifier + and message[-2] == _checksum(message[6:-2]) + ) + + +def _voice_address(message): + if not _is_bulk_dump(message, VOICE, 45): + return None + memory, slot = message[MEMORY_TYPE:MEMORY_NUMBER + 1] + if memory == INTERNAL: + return memory, slot & 0x3F + if memory in (PRESET_1, PRESET_2, EDIT) and slot < BANK_SIZE: + return memory, slot + return None + + +def _dump_request(channel, identifier, memory=0, slot=0): + return [ + 0xF0, YAMAHA, 0x20 | _device_number(channel), FORMAT, + *identifier, *([0] * 14), memory, slot, 0xF7, + ] + + +def _with_address(channel, message, memory, slot): + result = list(message) + result[2] = _device_number(channel) + result[MEMORY_TYPE:MEMORY_NUMBER + 1] = [memory, slot] + result[-2] = _checksum(result[6:-2]) + return result + + +def bankDescriptors(): + return [ + {"bank": bank, "name": name, "size": BANK_SIZE, "type": "Voice", "isROM": bank != 0} + for bank, name in enumerate(BANK_NAMES) + ] + + +def friendlyBankName(bank): + return BANK_NAMES[bank] + + +def friendlyProgramName(program): + if not 0 <= program < BANK_SIZE * len(BANKS): + return "Edit voice" + bank, slot = divmod(program, BANK_SIZE) + group, position = divmod(slot, 16) + return f"{BANK_LABELS[bank]}-{'ABCD'[group]}{position + 1:02d}" + + +def createProgramDumpRequest(channel, program): + if not 0 <= program < BANK_SIZE * len(BANKS): + return [] + bank, slot = divmod(program, BANK_SIZE) + return _dump_request(channel, VOICE, BANKS[bank], slot) + + +def numberFromDump(message): + address = _voice_address(message) + if address is None or address == (EDIT, 0): + return -1 + memory, slot = address + # A TG77 front-panel single-voice dump can carry EDIT and its source slot. + return slot if memory == EDIT else BANKS.index(memory) * BANK_SIZE + slot + + +def isSingleProgramDump(message): + return numberFromDump(message) >= 0 + + +def isEditBufferDump(message): + return _voice_address(message) == (EDIT, 0) + + +def convertToEditBuffer(channel, message): + if _voice_address(message) is None: + return [] + return _with_address(channel, message, EDIT, 0) + + +def convertToProgramDump(channel, message, program): + if _voice_address(message) is None or not 0 <= program < BANK_SIZE: + print("Yamaha SY77/TG77: choose a valid voice and an internal slot from A01 to D16.") + return [] + + voice_type = message[VOICE_TYPE] + if voice_type in BANK_D_ONLY and program < BANK_D_START: + print(f"Yamaha SY77/TG77: {BANK_D_ONLY[voice_type]} cannot be stored at " + f"{friendlyProgramName(program)}. Choose an internal slot from D01 to D16.") + return [] + return _with_address(channel, message, INTERNAL, program) + + +def nameFromDump(message): + return "".join(chr(byte) if 32 <= byte <= 126 else " " for byte in message[VOICE_NAME]).strip() + + +def isDefaultName(patch_name): + return patch_name.strip().upper() in ("", "INIT VOICE") + + +def renamePatch(message, new_name): + if _voice_address(message) is None: + return list(message) + result = list(message) + result[VOICE_NAME] = [ + ord(character) if " " <= character <= "~" else 0x20 + for character in new_name[:10].ljust(10) + ] + result[-2] = _checksum(result[6:-2]) + return result + + +def calculateFingerprint(message): + # Ignore addressing, name, framing and checksum. Keep the voice type and + # effect mode along with the other sound parameters, as in Giovanni's PR. + return hashlib.md5(bytes(message[VOICE_TYPE:VOICE_TYPE + 1]) + bytes(message[43:-2])).hexdigest() + + +class Yamaha77Voice: + def __init__(self, model, first_preset_name): + self.model = model + self.first_preset_name = first_preset_name + self._probe_replies = {} + self._voice_channels = {} + + def name(self): + return f"Yamaha {self.model}" + + def setupHelp(self): + if self.model == "TG77": + program_change = ( + "For Program change send mode, use Normal mode with Internal selected in Voice Play. " + "Audition presets using the edit buffer." + ) + else: + program_change = "For Program change send mode, set Program Change to Direct." + return ( + f"This adaptation supports voices. {program_change} " + "Run detection again after changing the Voice Receive Channel. If the system reply is " + "unavailable, Program Change uses the SysEx device number's corresponding MIDI channel. " + "Turn Bulk Protect off on the instrument before writing to internal memory. " + "4AFM mono, 4AWM, 2AFM+2AWM and Drum Set voices require an internal slot from D01 to D16." + ) + + def needsChannelSpecificDetection(self): + return True + + def createDeviceDetectMessage(self, channel): + device = _device_number(channel) + self._probe_replies[device] = (False, None) + # The first factory preset identifies the model. The separate system + # reply provides the MIDI voice channel without changing any settings. + return _dump_request(device, VOICE, PRESET_1, 0) + _dump_request(device, SYSTEM) + + def channelIfValidDeviceResponse(self, message): + if _is_bulk_dump(message, SYSTEM, VOICE_RECEIVE_CHANNEL + 3): + device = message[2] + matched, _ = self._probe_replies.get(device, (False, None)) + voice_channel = message[VOICE_RECEIVE_CHANNEL] + voice_channel = voice_channel if voice_channel < 16 else device + self._probe_replies[device] = (matched, voice_channel) + if matched: + self._voice_channels[device] = voice_channel + return -1 + + if _voice_address(message) not in ((PRESET_1, 0), (EDIT, 0)): + return -1 + if nameFromDump(message) != self.first_preset_name: + return -1 + + device = message[2] + _, voice_channel = self._probe_replies.get(device, (False, None)) + self._probe_replies[device] = (True, voice_channel) + self._voice_channels[device] = device if voice_channel is None else voice_channel + return device + + def createEditBufferRequest(self, channel): + request = _dump_request(channel, VOICE, EDIT, 0) + if self.model == "SY77": + return request + + # The TG77 requires entering Edit before requesting its current voice. + device = 0x10 | _device_number(channel) + enter_edit = [0xF0, YAMAHA, device, 0x34, 0x0D, 0, 0, 5, 0, 0x7F, 0xF7] + enter_voice = [0xF0, YAMAHA, device, 0x34, 0x0D, 0, 0, 0, 0, 0x7F, 0xF7] + return enter_edit + request + enter_voice + + def createCustomProgramChange(self, channel, program): + if not 0 <= program < BANK_SIZE * len(BANKS): + return [] + device = _device_number(channel) + status = 0xC0 | self._voice_channels.get(device, device) + bank, slot = divmod(program, BANK_SIZE) + if self.model == "SY77": + # Yamaha's Direct mode uses PC 124 for Voice Preset 1. + return [status, VOICE_MODE_PROGRAM_CHANGES[bank], status, slot] + if bank == 0: + return [status, slot] + print("Yamaha TG77: use edit-buffer send mode to audition preset voices.") + return [] + + def install(self, namespace): + for name in ( + "name", "setupHelp", "needsChannelSpecificDetection", + "createDeviceDetectMessage", "channelIfValidDeviceResponse", + "createEditBufferRequest", "createCustomProgramChange", + ): + namespace[name] = getattr(self, name) + + for function in ( + bankDescriptors, friendlyBankName, friendlyProgramName, + createProgramDumpRequest, numberFromDump, isSingleProgramDump, + isEditBufferDump, convertToEditBuffer, convertToProgramDump, + nameFromDump, isDefaultName, renamePatch, calculateFingerprint, + ): + namespace[function.__name__] = function + namespace["isPartOfSingleProgramDump"] = isSingleProgramDump + + +def voice_test_data(fixture, count, samples, mode_samples=()): + """Build generic tests from captures of internal voices.""" + import testing + + def programs(data): + regular_voices = [ + (index, index, name, label) for index, name, label in samples + ] + # Giovanni placed the 11 additional modes at D01 to D11. + mode_voices = [ + (fixture_index, 48 + mode, name, f"IN-D{mode + 1:02d}") + for mode, (fixture_index, name) in enumerate(mode_samples) + ] + return [ + testing.ProgramTestData( + message=data.all_messages[index], number=slot, name=name, + friendly_number=label, rename_name="New Patch", target_no=slot, + ) + for index, slot, name, label in regular_voices + mode_voices + ] + + def edit_buffers(data): + return [ + testing.ProgramTestData( + message=convertToEditBuffer(0, program.message.byte_list), + name=program.name, rename_name=program.rename_name, target_no=program.target_no, + ) + for program in programs(data) + ] + + return testing.TestData( + sysex=fixture, expected_patch_count=count, program_generator=programs, + edit_buffer_generator=edit_buffers, friendly_bank_name=(0, "Internal"), + ) diff --git a/adaptations/yamaha/Yamaha_SY_TG_common.py b/adaptations/yamaha/Yamaha_SY_TG_common.py deleted file mode 100644 index 9480c4e5..00000000 --- a/adaptations/yamaha/Yamaha_SY_TG_common.py +++ /dev/null @@ -1,475 +0,0 @@ -""" -Yamaha SY/TG-series synth adaptation base class. - -Created by github.com/hmmbug. - -This base class provides a foundation for Knobcraft ORM adaptations for the -Yamaha SY/TG synth series. To create a synth-specific implementation: - -Methods to add: - convertPatchesToBankDump(self, patches: List[List[int]]) -> List[int] - createCustomProgramChange(self, channel: int, patchNo: int) -> List[int] - -Methods to override: - friendlyProgramName(self, patchNo: int) -> str - bankSlotToPatchNo(self, memory_type:int, memory_number: int) -> int - _mapPatchNumToSynthMemory(self, patchno: int) -> tuple[int, int] - -Data structures to define: - - a MemoryType(IntEnum) class representing the INTERNAL/PRESET banks. - This varies for each synth (example below) - - a 'banks' dictionary. See the Knobcraft Adaption Programming Guide or - the SY77 adaptation for examples. - -Device detection may require overrides to other methods such as -`createDeviceDetectMessage()` and/or `channelIfValidDeviceResponse`. - - -## BULK DATA DUMP OVERVIEW - -This series of synths have a (mostly) common SysEx format. Each message header -is of the format (hex): - - HEADER: - f0 4d - where: - f0: start of sysex - 4d: manufacturer id for Yamaha - device id: the MIDI device id for SysEx messages. This is not the - same as MIDI channel. - synth id: a marker for (I guess) a hardware series or protocol - version. For example 0x7a is used for SY55/77/85/99. It's unnamed - in most of the MIDI Data Format manuals, but the SY55 manual - refers to it as a "format number". - -Next is a 10 character string in 3 parts: - - SUBHEADER (msg_id) - xxxxyyyyzz - where: - xxxx is always 2 upper case characters plus spaces, usually "LM " - ("LM" + 2x spaces) - Referred to as a "Classification Number" in some manuals. - yyyy is a 4 digit decimal number - Referred to as a "Data Format Name" in some manuals, but seemingly - unrelated to the above "format number" - zz is a 2 digit code for the data type (eg. voice, multi etc) - - Examples: - SY22/SY35: "PK 2203AE" - TG33: "LM 0012VE" - SY55/TG55: "LM 8103VC" - SY77/TG77: "LM 8101VC" - SY85/TG500: "LM 0065VC" - SY99: "LM 8101VC" and "LM 0040VC" - -Some synths also then have a 16 byte value, mostly null padding, sometimes with -memory type (Internal, Preset etc) and memory slot. - -A message tail comprises: - - TAIL - checksum: a 1 byte checksum value based on a simple algorithm - Only used for dump records, not for dump requests - f0: end of SysEx - - -## DEVICE DETECTION OVERVIEW - -Mostly this can be accomplished with the SUBHEADER value in conjunction with -the name of PRESET sound. For example, the message formats of the SY77 and -TG77 are identical but the PRESET sounds differ. - -There are some exceptions to this. The SY85 has no (read-only) PRESET banks -while the rack version of it (the TG500) does have PRESET banks. -""" - -import hashlib -import logging -from types import ModuleType -from typing import List - -import knobkraft.sysex - -logging.basicConfig(level=logging.DEBUG) - -# SysEx constants -SYSEX_START = 0xf0 -SYSEX_END = 0xf7 -YAMAHA_ID = 0x43 -OFFSET_DEVICE_ID = 2 # offsets into SysEx msgs -OFFSET_CHECKSUM = -2 # penultimate byte -OFFSET_SIZE_BYTE1 = 4 -OFFSET_SIZE_BYTE2 = OFFSET_SIZE_BYTE1 + 1 -MESSAGE_TYPE_LENGTH = 10 -OFFSET_MESSAGE_TYPE = 6 -OFFSET_MESSAGE_TYPE_END = OFFSET_MESSAGE_TYPE + MESSAGE_TYPE_LENGTH - -# Example MemoryType enum: -# -# class MemoryType(IntEnum): -# INTERNAL = 0xF0 -# PRESET1 = 0xF2 -# PRESET2 = 0xF3 -# EDIT = 0xFF - -class YamahaSYTGBase: - - def __init__( - self, - synth_name:str, - synth_id:int, - first_preset_name:str, # Verbatim preset name. Used for device detection. - - # voice dump parameters - msg_id_voice_dump:str, # Used for device detection. - voice_default_name:str, - voice_name_length:int, - offset_voice_name:int, - - # memory banks - memory_types, # TODO: typing for subclass of IntEnum?? - banks:List[dict], - - # offsets in sysex messages - # these are the offsets in a bulk dump to where the memory_type - # (INTERNAL, PRESET1 etc) and voice slot is specified - offset_memory_type:int, - offset_memory_number:int, - - # ...and the same but for a bulk dump request. The request messages - # are slightly different because there's no byte count field in - # requests - offset_req_memory_type:int, - offset_req_memory_number:int, - - # misc - help_string:str="", - needs_channel_specific_detection:bool=True, - ) -> None: - self.synth_name = synth_name - self.synth_id = synth_id - self.first_preset_name = first_preset_name - - # voice - self.msg_id_voice_dump = msg_id_voice_dump - self.voice_default_name = voice_default_name - self.voice_name_length = voice_name_length - self.offset_voice_name = offset_voice_name - - # banks - self.memory_types = memory_types - if banks is None: - raise ValueError("'banks' is undefined.") - self.banks = banks - - self.offset_memory_type = offset_memory_type - self.offset_memory_number = offset_memory_number - self.offset_req_memory_type = offset_req_memory_type - self.offset_req_memory_number = offset_req_memory_number - - # misc - self.help_string = help_string - self.needs_channel_specific_detection = needs_channel_specific_detection - - # not user-configurable beyond her - self.detected_device_id = None - - def name(self) -> str: - return self.synth_name - - def setupHelp(self) -> str: - return self.help_string - - - # ##### DEVICE DETECTION CAPACBILITIES - - def createDeviceDetectMessage(self, channel: int) -> List[int]: - device_id = 0x20 | (channel & 0x0f) - # Request PRESET1, voice 1 by default. Override this method if something different is needed. - bank_name = 'PRESET1' if 'PRESET1' in self.memory_types.__members__ else 'PRESET' - msg = str2bytes(self.msg_id_voice_dump) + [0x00]*14 + [int(self.memory_types[bank_name]), 0] - buf = self._makeMessage(device_id, msg, add_checksum=False) - logging.debug(f"createDeviceDetectMessage({channel}: {bytes2str(buf[:32])} ... {bytes2str(buf[-2:])}") - return buf - - def channelIfValidDeviceResponse(self, buf: List[int]) -> int: - if len(buf) < 32: - return False # filter out irrelevant messages like active sensing - if self._validateVoiceMessage(buf): - if self.nameFromDump(buf).strip() == self.first_preset_name.strip(): # ignore whitespace - rtn = buf[OFFSET_DEVICE_ID] - self.detected_device_id = rtn - else: - rtn = -1 - else: - rtn = -1 - return rtn - - def needsChannelSpecificDetection(self) -> bool: - return self.needs_channel_specific_detection - - - # ##### PROGRAM DUMP CAPABILITY - - def createProgramDumpRequest(self, channel: int, patchNo: int) -> List[int]: - device_id = 0x20 | (channel & 0x0f) - memory_type, memory_number = self._mapPatchNumToSynthMemory(patchNo) - msg = [*str2bytes(self.msg_id_voice_dump), *[0]*14, int(memory_type), memory_number] - # print(f"DEBUG ch:{channel} pN:{patchNo}", msg) - buf = self._makeMessage(device_id, msg, add_checksum=False) - logging.debug(f"createProgramDumpRequest({channel}, {patchNo}): {bytes2str(buf[:32])}") - return buf - - def isSingleProgramDump(self, buf: List[int]) -> bool: - if self._validateVoiceMessage(buf): - msg_size = self._getMessageSize(buf) - rtn = msg_size == len(buf) - logging.debug(f"isSingleProgramDump: msgSize:{msg_size} totalSize:{len(buf)} -> {rtn}") - else: - rtn = False - logging.debug(f"isSingleProgramDump: invalid msg: {buf}") - return rtn - - def convertToProgramDump(self, channel: int, message: List[int], patchNo: int) -> List[int]: - buf = message.copy() - buf[OFFSET_DEVICE_ID] = channel & 0x0f - buf[self.offset_memory_type], buf[self.offset_memory_number] = self._mapPatchNumToSynthMemory(patchNo) - buf[OFFSET_CHECKSUM] = self._calculateChecksum(buf) - logging.debug(f"convertToProgramDump({channel}, msg): " - f"MemType/Num:{message[self.offset_memory_type]:02x}{message[self.offset_memory_number]:02x}" - f"->{buf[self.offset_memory_type]:02x}{buf[self.offset_memory_number]:02x}") - return buf - - - # ##### EDIT BUFFER CAPABILITIES - - def convertToEditBuffer(self, channel: int, msg: List[int]) -> List[int]: - buf = msg.copy() - buf[OFFSET_DEVICE_ID] = channel & 0x0f - buf[self.offset_memory_type] = self.memory_types.EDIT - buf[self.offset_memory_number] = 0 - buf[OFFSET_CHECKSUM] = self._calculateChecksum(buf) - logging.debug(f"convertToEditBuffer({channel}, msg): " - f"MemType/Num:{msg[self.offset_memory_type]:02x}{msg[self.offset_memory_number]:02x}" - f"->{buf[self.offset_memory_type]:02x}{buf[self.offset_memory_number]:02x}") - return buf - - def createEditBufferRequest(self, channel: int) -> List[int]: - device_id = 0x20 | (channel & 0x0f) - msg = [*str2bytes(self.msg_id_voice_dump), *[0]*14, int(self.memory_types['EDIT']), 0] - buf = self._makeMessage(device_id, msg, add_checksum=False) - logging.debug(f"createEditBufferRequest({channel}: {bytes2str(buf[:32])} ... {bytes2str(buf[-2:])}") - return buf - - def isEditBufferDump(self, buf: List[int]) -> bool: - rtn = self._validateVoiceMessage(buf) and (buf[self.offset_memory_type] == self.memory_types['EDIT']) - logging.debug(f"isEditBufferDump: MemType:{buf[self.offset_memory_type]:02x} " - f"{buf[self.offset_memory_type] == self.memory_types['EDIT']} -> {rtn}") - return rtn - - - # ##### BANK CAPABILITIES - - def bankDescriptors(self) -> List[dict]: - return self.banks - - def isPartOfBankDump(self, first_message: List[int]) -> bool: - return self._getMessageSize(first_message) < len(first_message) - - def friendlyProgramName(self, patchNo: int) -> str: - rtn ="OVERRIDE friendlyProgramName()" - return rtn - - def friendlyBankName(self, bank_number: int) -> str: - rtn = self.banks[bank_number]["name"] - logging.debug(f"friendlyBankName(bank_number) -> {rtn}") - return rtn - - - # ##### SYSEX MESSAGE HELPERS - - def _makeMessage(self, device_id: int, msg: List[int], add_checksum: bool=True) -> List[int]: - buf = [SYSEX_START, YAMAHA_ID, device_id, self.synth_id] + msg - if add_checksum: - buf += [0, SYSEX_END] - buf[OFFSET_CHECKSUM] = self._calculateChecksum(buf) - else: - buf += [SYSEX_END] - logging.debug(f"make_message({device_id}, msg={msg}, add_checksum={add_checksum}): {bytes2str(buf)}") - return buf - - def _calculateChecksum(self, data: List[int]) -> int: - """ - Checksum the SysEx array. This excludes the first 6 bytes (f0 43 0n, 7a + 2 byte data length). - Returns the checksum byte to be inserted at OFFSET_CHECKSUM. - """ - data_sum = sum(data[6:-2]) & 0x7f # sum & mask to 7 bit values - checksum = (0x80 - data_sum) & 0x7f # subtract from 128 (0x80), mask again for 7-bit value - return checksum - - def _validateMessage(self, buf: List[int]) -> bool: - if len(buf) < 32: - return False - csum = self._calculateChecksum(buf) - rtn = ( - buf[0] == SYSEX_START and - buf[1] == YAMAHA_ID and - buf[3] == self.synth_id and - buf[OFFSET_CHECKSUM] == csum and - buf[-1] == SYSEX_END - ) - logging.debug(f"validate_message: {bytes2str(buf[:32])} ... {bytes2str(buf[-2:])}" - f" chk:{buf[-2]:02x} ?? ver:{csum:02x} --> {rtn}") - return rtn - - def _validateVoiceMessage(self, buf: List[int]) -> bool: - rtn = self._validateMessage(buf) and self._getMessageType(buf) == str2bytes(self.msg_id_voice_dump) - logging.debug(f"validate_voice_message: rtn:{rtn}") - return rtn - - def _getMemoryType(self, buf: List[int]) -> int: - return self.memory_types(buf[self.offset_memory_type]) - - def _getMemoryNumber(self, buf: List[int]) -> int: - return buf[self.offset_memory_number] - - def _getMessageType(self, buf: List[int]) -> List[int]: - return buf[OFFSET_MESSAGE_TYPE:OFFSET_MESSAGE_TYPE_END] - - def __nameFromDump(self, buf: List[int]) -> str: - return "".join( - chr(c) for c in buf[self.offset_voice_name:self.offset_voice_name+self.voice_name_length] - ) - - def nameFromDump(self, buf: List[int]) -> str: - rtn = self.__nameFromDump(buf) - logging.debug(f"nameFromDump: rtn:{rtn}") - return rtn - - def numberFromDump(self, buf: List[int]) -> int: - rtn = self.bankSlotToPatchNo(buf[self.offset_memory_type], buf[self.offset_memory_number]) - logging.debug(f"numberFromDump: MemType/Num: {buf[self.offset_memory_type]}/{buf[self.offset_memory_number]} -> rtn:{rtn} -> rtn:{rtn}") - return rtn - - def _getPayloadSize(self, buf: List[int]) -> int: - "Returns payload size - the size field" - if len(buf) > OFFSET_SIZE_BYTE2: - return (buf[OFFSET_SIZE_BYTE1] << 7) + buf[OFFSET_SIZE_BYTE2] - else: - return 0 - - def _getMessageSize(self, buf: List[int]) -> int: - """ - Returns message size (inc. headers/tail): - - header (4 bytes) - - payload size field: 2 bytes - - payload (variable) - - tail (2 bytes: checksum and End of SysEx byte) - For a single voice a simple `len(buf)` would work fine, but for banks of voices - we need to use the size supplied in the message. - """ - return 4 + 2 + self._getPayloadSize(buf) + 2 - - def extractPatchesFromBank(self, bank: List[int]) -> List[List[int]]: - patches = [ - p for p in knobkraft.sysex.splitSysexMessage(bank) - if self._validateVoiceMessage(p) - ] - logging.debug(f"extractPatchesFromBank(): {len(patches)} patches extracted") - return patches - - def _mapPatchNumToSynthMemory(self, patchno: int) -> tuple[int, int]: - "Maps Knobcraft flat patch numbers to synth memory types and banks" - raise NotImplementedError - - def bankSlotToPatchNo(self, memory_type:int, memory_number: int) -> int: - return -1 # Override in child class - - def _memoryTypeNumberChecks(self, memory_type:int, memory_number: int): - if memory_type not in self.memory_types: - raise Exception(f"Invalid format (memory_type) for SY77/TG77 dump request given: {format}") - if not (0 <= memory_number <= 63): - raise Exception(f"Invalid format (memory_number) for SY77/TG77 dump request given: {format} (out of range)") - - def isDefaultName(self, patchName: int) -> bool: - rtn = patchName == self.voice_default_name - logging.debug(f"isDefaultName({patchName}) -> {rtn}") - return rtn - - def renamePatch(self, message, new_name) -> List[int]: - if not self._validateVoiceMessage(message): - raise ValueError("Not a Voice Dump") - - # truncate / space pad new_name - fmt_name = [0x20] * self.voice_name_length - for i, c in enumerate(new_name[:self.voice_name_length]): - fmt_name[i] = ord(c) - - # build new message - rtn = message.copy() - for i in range(0, self.voice_name_length): - rtn[self.offset_voice_name + i] = fmt_name[i] - rtn[OFFSET_CHECKSUM] = self._calculateChecksum(rtn) - logging.debug(f"renamePatch({new_name}): {self.__nameFromDump(rtn)}") - return rtn - - - # ##### KNOBCRAFT FUNCTIONS - - def blankedOut(self, buf: List[int]) -> List[int]: - buf[OFFSET_DEVICE_ID] = 0 - buf[self.offset_memory_type] = 0 - buf[self.offset_memory_number] = 0 - buf[OFFSET_CHECKSUM] = 0 - buf[self.offset_voice_name:self.offset_voice_name+self.voice_name_length] = [0] * self.voice_name_length - return buf - - def calculateFingerprint(self, buf: List[int]) -> str: - rtn = buf.copy() - rtn = self.blankedOut(rtn) - return hashlib.md5(bytearray(rtn)).hexdigest() - - # ##### CLASS OPERATIONS METHODS - - def install(self, module: ModuleType) -> None: - # This is required because the original KnobKraft modules are not objects, but rather a module namespace with - # methods declared. Expose our objects methods in the top level module namespace so the C++ code finds it - # TODO Make this a loop - for m in [ - 'name', - 'setupHelp', - # ##### DEVICE DETECTION CAPACBILITIES - 'createDeviceDetectMessage', - 'channelIfValidDeviceResponse', - 'needsChannelSpecificDetection', - # ##### PROGRAM DUMP CAPABILITY - 'createProgramDumpRequest', - 'isSingleProgramDump', - 'convertToProgramDump', - # ##### EDIT BUFFER CAPABILITIES - 'convertToEditBuffer', - 'createEditBufferRequest', - 'isEditBufferDump', - # ##### BANK CAPABILITIES - 'bankDescriptors', - 'isPartOfBankDump', - 'friendlyBankName', - # ##### SYSEX MESSAGE HELPERS - 'nameFromDump', - 'numberFromDump', - 'extractPatchesFromBank', - 'bankSlotToPatchNo', - 'isDefaultName', - 'renamePatch', - # ##### KNOBCRAFT FUNCTIONS - 'blankedOut', - 'calculateFingerprint', - ]: - setattr(module, m, getattr(self, m)) - -def str2bytes(s: str) -> List[int]: - return [ord(x) for x in s] - -def bytes2str(b: List[int], delimiter: str=' ') -> str: - return delimiter.join(f"{x:02x}" for x in b) diff --git a/data/supported-synths.json b/data/supported-synths.json index 92b16525..74c2aa2b 100644 --- a/data/supported-synths.json +++ b/data/supported-synths.json @@ -1,7 +1,7 @@ { "source_revision": "76b39b7c767129eaeb01534008547e8a320b0886", "release_checked": "2.10.2", - "count": 93, + "count": 94, "synths": [ { "manufacturer": "Access", @@ -797,11 +797,20 @@ }, { "manufacturer": "Yamaha", - "synth": "SY77 / TG77 (voices)", + "synth": "SY77 (voices)", "status": "beta", "statusLabel": "Beta", "type": "adaptation", - "kudos": "Contributed and tested on TG77 by Giovanni Candiago. SY77 hardware testing pending.", + "kudos": "Contributed by @hmmbug and Giovanni Candiago. Original SY77 hardware testing by @hmmbug.", + "availability": "After 2.10.2" + }, + { + "manufacturer": "Yamaha", + "synth": "TG77 (voices)", + "status": "beta", + "statusLabel": "Beta", + "type": "adaptation", + "kudos": "Contributed by @hmmbug and Giovanni Candiago. Original TG77 hardware testing by Giovanni Candiago.", "availability": "After 2.10.2" }, { diff --git a/docs/data/supported-synths.yml b/docs/data/supported-synths.yml index 8a6e7685..95bf3ad0 100644 --- a/docs/data/supported-synths.yml +++ b/docs/data/supported-synths.yml @@ -532,10 +532,16 @@ synths: kudos: Thanks to @milnak! availability: 2.10.2 - manufacturer: Yamaha - synth: SY77 / TG77 (voices) + synth: SY77 (voices) status: beta type: adaptation - kudos: Contributed and tested on TG77 by Giovanni Candiago. SY77 hardware testing pending. + kudos: Contributed by @hmmbug and Giovanni Candiago. Original SY77 hardware testing by @hmmbug. + availability: After 2.10.2 +- manufacturer: Yamaha + synth: TG77 (voices) + status: beta + type: adaptation + kudos: Contributed by @hmmbug and Giovanni Candiago. Original TG77 hardware testing by Giovanni Candiago. availability: After 2.10.2 - manufacturer: Yamaha synth: TX7 diff --git a/docs/supported-synths.md b/docs/supported-synths.md index 257e9a02..1649908b 100644 --- a/docs/supported-synths.md +++ b/docs/supported-synths.md @@ -287,7 +287,8 @@ Use the searchable model filter, or choose a manufa | FS1R | alpha | adaptation | 2.10.2 | Thanks to @markusschlosser for testing! | | reface DX | works | adaptation | 2.10.2 | | | reface CP | beta | adaptation | 2.10.2 | Thanks to @milnak! | -| SY77 / TG77 (voices) | beta | adaptation | After 2.10.2 | Contributed and tested on TG77 by Giovanni Candiago. SY77 hardware testing pending. | +| SY77 (voices) | beta | adaptation | After 2.10.2 | Contributed by @hmmbug and Giovanni Candiago. Original SY77 hardware testing by @hmmbug. | +| TG77 (voices) | beta | adaptation | After 2.10.2 | Contributed by @hmmbug and Giovanni Candiago. Original TG77 hardware testing by Giovanni Candiago. | | TX7 | works | adaptation | 2.10.2 | Thanks to Gerome S! | | TX81Z | works | adaptation | 2.10.2 | Contributed by @summersetter! | | Yamaha YC61/YC73/YC88 | works | adaptation | 2.10.2 | Thanks to @milnak! | diff --git a/docs/yamaha-sy77-tg77.md b/docs/yamaha-sy77-tg77.md new file mode 100644 index 00000000..6d6f77bf --- /dev/null +++ b/docs/yamaha-sy77-tg77.md @@ -0,0 +1,28 @@ +# Yamaha SY77 and TG77 voice support + +The two adaptations share the Yamaha voice SysEx format. Both expose 64 writable Internal slots and two read-only 64-voice preset banks. The TG77 uses a timed Edit → Dump → Voice sequence to read the edit buffer. The SY77 sends the edit-buffer request directly. + +For SY77 Program change send mode, set Program Change to Direct. The app sends the voice-bank selector followed by the slot. For TG77 Program change send mode, set Program Change to Normal and select Internal in Voice Play before auditioning internal patches. Use edit-buffer send mode to audition TG77 presets. Program Change uses the Voice Receive Channel from the System dump, with the SysEx device number as a fallback. Run detection again after changing these settings. + +Detection requests the first factory preset and the System dump so it can identify the model and read the MIDI channel without changing Bulk Protect. The app also accepts the TG77's front-panel voice dumps. A front-panel dump of A01 carries the same address as an edit-buffer dump and is classified as an edit-buffer voice. + +Turn Bulk Protect off on the instrument before writing to internal memory. 4AFM mono, 4AWM, 2AFM+2AWM, and Drum Set voices require a slot in D01–D16. The adaptation rejects an incompatible destination. The dedicated bank-dump writer is deferred. The app can still send a bank as individual slot writes, so an incompatible slot can stop a transfer after earlier valid slots have been written. + +## Contributors and hardware evidence + +| Contributor | Hardware evidence from the original contributions | +| --- | --- | +| [@hmmbug](https://github.com/hmmbug) | Wrote the original SY77 and TG77 adaptations, supplied their bank mapping and three fixtures, and reported several weeks of stable use of the SY77 adaptation on an SY77 with ROM 1.5. See [PR #551](https://github.com/christofmuc/KnobKraft-orm/pull/551) and the [SY77 hardware report](https://github.com/christofmuc/KnobKraft-orm/pull/551#issuecomment-4946532875). | +| Giovanni Candiago | Wrote the TG77-tested adaptation and supplied a fixture with 64 internal voices and all 11 voice modes. On a TG77 he verified detection with the original System-dump probe, edit-buffer retrieval including the largest voice and send to the edit buffer, reads of all 64 internal voices, front-panel single and full-memory dumps, and Normal-mode Program Change with SysEx device number 1 and Voice Receive Channel 9. See [PR #597](https://github.com/christofmuc/KnobKraft-orm/pull/597). | + +These reports cover the contributors' original versions. The combined version still needs retesting on both instruments. + +## Combined-version retest + +- On each model, run detection with different SysEx and voice channels. Confirm the model is identified, the program change arrives on the voice channel, and Bulk Protect retains its initial setting. When both units are available, check that only the matching adaptation detects each unit. +- On each model, read Internal and both preset banks. Retrieve a 4AFM mono edit-buffer voice and send a voice back to the edit buffer. On TG77, confirm the front panel returns to Voice Play and verify both a single front-panel dump and a full 64-voice dump. +- On SY77, in Direct mode, audition an internal voice and a voice from each preset bank. Start in Multi mode for the Preset 1 check and verify that the synth switches to the correct Voice bank. +- On TG77, in Normal mode, select Internal in Voice Play and audition an internal voice. Switch to edit-buffer send mode to audition a preset. +- Back up internal memory before testing a write. Test individual writes to scratch slots and read them back before attempting any bank transfer. Check that an incompatible write to A–C leaves the slot intact and that an explicit D-slot write works for the same voice. + +The bank selectors are documented in the [Yamaha SY77 operating manual](https://chrisarndt.de/files/yamaha/sy77/SY77%20-%20Operating%20Manual%20-%20Complete.pdf) and [Yamaha TG77 MIDI Data Format](https://manualzz.com/doc/1538269/yamaha-tg77-user-manual).