diff options
| author | Tharo <tharo10600@gmail.com> | 2026-03-09 21:22:28 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-10 06:22:28 +0900 |
| commit | 970af5600ad343a33caea577daa0d80a758b9933 (patch) | |
| tree | dca00c3c25f96bf2a49cf21d28e5963977a3fd1f /tools/audio/extraction/audiobank_structs.py | |
| parent | bc6d153a21e3fc7a729ea2154f2ff16111d5e704 (diff) | |
Audio: Fix note values (#2716)
Due to the layout of the pitch_frequencies lookup table, note values
computed in extraction were reflected around middle C (midi note
number 60). This didn't matter for matching, values would successfully
roundtrip. However when using samples in external programs or
converting soundfonts to standard formats the note values would lead
to incorrect playback of sounds. This change corrects the note values
so that external programs correctly infer the pitch of the sound when
played at a particular MIDI key.
Diffstat (limited to 'tools/audio/extraction/audiobank_structs.py')
| -rw-r--r-- | tools/audio/extraction/audiobank_structs.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/audio/extraction/audiobank_structs.py b/tools/audio/extraction/audiobank_structs.py index fa6afa37d..beb2e1a57 100644 --- a/tools/audio/extraction/audiobank_structs.py +++ b/tools/audio/extraction/audiobank_structs.py @@ -64,7 +64,7 @@ class SoundFontSample: # SampleHeader ? if rate_override is not None: attrs["SampleRate"] = rate_override if note_override is not None: - attrs["BaseNote"] = note_override + attrs["BaseNote"] = pitch_names[note_override] if self.medium != 0: attrs["IsDD"] = "true" if self.cached: @@ -235,7 +235,7 @@ class SoundFontSound: if self.needs_rate_override: attrs["SampleRate"] = self.sample_rate if self.needs_note_override: - attrs["BaseNote"] = self.base_note + attrs["BaseNote"] = pitch_names[self.base_note] xml.write_element("Effect", attrs) @@ -383,7 +383,7 @@ class Instrument: if self.needs_rate_override[1]: attributes["SampleRate"] = self.sample_rate[1] if self.needs_note_override[1]: - attributes["BaseNote"] = self.base_note[1] + attributes["BaseNote"] = pitch_names[self.base_note[1]] if self.normal_range_lo != 0: attributes["RangeLo"] = pitch_names[self.normal_range_lo] @@ -392,7 +392,7 @@ class Instrument: if self.needs_rate_override[0]: attributes["SampleRateLo"] = self.sample_rate[0] if self.needs_note_override[0]: - attributes["BaseNoteLo"] = self.base_note[0] + attributes["BaseNoteLo"] = pitch_names[self.base_note[0]] if self.normal_range_hi != 127: attributes["RangeHi"] = pitch_names[self.normal_range_hi] @@ -401,6 +401,6 @@ class Instrument: if self.needs_rate_override[2]: attributes["SampleRateHi"] = self.sample_rate[2] if self.needs_note_override[2]: - attributes["BaseNoteHi"] = self.base_note[2] + attributes["BaseNoteHi"] = pitch_names[self.base_note[2]] xml.write_element("Instrument" if not self.unused else "InstrumentUnused", attributes) |
