SoundFont local initialAttenuation does not override global attenuation, making affected presets too quiet
Maintainer antworten meist innerhalb von 1 Tag
@Danielku15 arbeitet bereits daran.
Seit 27.10.2026.
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
Is there an existing issue for this?
- I have searched the existing issues
I have read the contribution rules
- I have read CONTRIBUTING.md and, if any AI agent helped draft this issue, AGENTS.md.
AI authorship
AI-assisted (disclosure block included as described in AGENTS.md)
Current Behavior
[!NOTE]
AI-authored disclosure (alphatab-ai-authored-v1)Portions of this content were authored by an AI agent. The agent has read
AGENTS.md and the human submitter accepts responsibility for
compliance with the rules in that document.
With the official npm package @coderline/[email protected], two SoundFonts that should be equivalent produce different PCM levels when one contains a global initialAttenuation value that is overridden locally.
For example, a preset with global attenuation = 200 cB and local attenuation = 120 cB renders at 32 dB attenuation, instead of 12 dB. Removing only the overridden global value makes the output 20 dB louder. The sample, MIDI note, velocity, channel controls, and export settings are identical. The same behavior occurs at the instrument level, including an explicit local value of zero.
This was initially noticed as unusually quiet overdriven guitar playback. The reproduction below uses program 0 and an original generated sine-wave sample, so it does not depend on a particular commercial SoundFont, guitar preset, application, or private score.
Measured attenuation relative to the identical unattenuated fixture:
| Case | Expected dB | Actual dB in 1.8.4 |
|---|---|---|
| Preset global 200 cB, local 120 cB | 12 | 32 |
| Instrument global 127 cB, local 50 cB | 5 | 17.7 |
| Both of the above | 17 | 49.7 |
| Missing locals: preset global 200 cB + instrument global 50 cB | 25 | 25 |
| Preset global 200 cB, local 0; instrument local 50 cB | 5 | 25 |
| Preset local 120 cB; instrument global 127 cB, local 0 | 12 | 24.7 |
| Preset local 120 cB + instrument local 50 cB | 17 | 17 |
| Preset local -60 cB + instrument local 100 cB | 4 | 4 |
| No attenuation generators | 0 | 0 |
Expected Behavior
A local initialAttenuation generator should replace the corresponding global generator at the same level. An omitted local value should inherit the global value; an explicit zero should override it. After resolving each level, preset attenuation should still be added to instrument attenuation.
The two equivalent preset fixtures (global 200 cB/local 120 cB versus local 120 cB alone) should therefore have identical output.
Normative basis: SoundFont 2.04 specification, section 9.4, PDF pages 50–51. It specifies local-over-global replacement separately at the instrument and preset levels, and addition between the preset and instrument levels. Section 9.3 defines one centibel as one tenth of a decibel.
Steps To Reproduce
- Create an empty directory and install the pinned official package:
npm init -y
npm install --ignore-scripts --save-exact @coderline/[email protected]
- Save the following as
repro.cjs. - Run
node repro.cjs(tested with Node v24.11.1). - It prints the table shown above and exits with an assertion failure: five override cases fail, while the four control cases pass. All SF2 data and the MusicXML score are generated in memory; no external assets are required.
Self-contained reproduction: repro.cjs
const assert = require('node:assert/strict');
const alphaTab = require('@coderline/alphatab');
// Build an original, looping sine-wave SF2 in memory. Generator 48 uses centibels.
function sf2({ pg, pl, ig, il } = {}) {
const words = (size, values) => {
const b = Buffer.alloc(size * values.length);
values.forEach((v, i) => size === 2 ? b.writeUInt16LE(v & 65535, i * size) : b.writeUInt32LE(v, i * size));
return b;
};
const u16 = (...v) => words(2, v), u32 = (...v) => words(4, v);
const name = s => { const b = Buffer.alloc(20); b.write(s); return b; };
const chunk = (id, ...parts) => {
const body = Buffer.concat(parts);
return Buffer.concat([Buffer.from(id), u32(body.length), body, Buffer.alloc(body.length % 2)]);
};
function zones(global, local, terminal) {
const gens = [], bags = [u16(0, 0)];
if (global !== undefined) { gens.push(u16(48, global)); bags.push(u16(gens.length, 0)); }
if (local !== undefined) gens.push(u16(48, local));
gens.push(...terminal);
bags.push(u16(gens.length, 0));
gens.push(u16(0, 0));
return { bags: Buffer.concat(bags), gens: Buffer.concat(gens), count: bags.length - 1 };
}
const p = zones(pg, pl, [u16(41, 0)]);
const i = zones(ig, il, [u16(54, 1), u16(53, 0)]);
const pcm = Buffer.alloc((512 + 46) * 2);
for (let n = 0; n < 512; n++) pcm.writeInt16LE(Math.round(8000 * Math.sin(2 * Math.PI * n / 64)), n * 2);
return chunk('RIFF', Buffer.from('sfbk'),
chunk('LIST', Buffer.from('INFO'), chunk('ifil', u16(2, 1))),
chunk('LIST', Buffer.from('sdta'), chunk('smpl', pcm)),
chunk('LIST', Buffer.from('pdta'),
chunk('phdr', name('Test'), u16(0, 0, 0), u32(0, 0, 0), name('EOP'), u16(0, 0, p.count), u32(0, 0, 0)),
chunk('pbag', p.bags), chunk('pmod', Buffer.alloc(10)), chunk('pgen', p.gens),
chunk('inst', name('Test'), u16(0), name('EOI'), u16(i.count)),
chunk('ibag', i.bags), chunk('imod', Buffer.alloc(10)), chunk('igen', i.gens),
chunk('shdr', name('Sine'), u32(0, 512, 64, 448, 22050), Buffer.from([60, 0]), u16(0, 1),
name('EOS'), u32(512, 512, 512, 512, 0), Buffer.from([0, 0]), u16(0, 1))));
}
const xml = `<score-partwise version="4.0"><part-list><score-part id="P">
<part-name>Test</part-name><score-instrument id="I"><instrument-name>Test</instrument-name></score-instrument>
<midi-instrument id="I"><midi-channel>1</midi-channel><midi-program>1</midi-program></midi-instrument>
</score-part></part-list><part id="P"><measure number="1"><attributes><divisions>1</divisions>
<time><beats>4</beats><beat-type>4</beat-type></time><clef><sign>G</sign><line>2</line></clef></attributes>
<direction><sound tempo="96"/></direction><note><pitch><step>C</step><octave>4</octave></pitch>
<duration>4</duration><type>whole</type></note></measure></part></score-partwise>`;
const score = alphaTab.importer.ScoreLoader.loadScoreFromBytes(new TextEncoder().encode(xml));
const midi = new alphaTab.midi.MidiFile();
const generator = new alphaTab.midi.MidiFileGenerator(score, new alphaTab.Settings(), new alphaTab.midi.AlphaSynthMidiFileHandler(midi));
generator.generate();
class Event { on(f) { this.f = f; } trigger() { this.f?.(); } }
function render(parameters) {
// Offline output adapter: no browser, audio device, network, or external SF2 needed.
const output = {
sampleRate: 44100, ready: new Event(), sampleRequest: new Event(), samplesPlayed: new Event(),
open() { this.ready.trigger(); }, destroy() {}, pause() {}, play() {}, resetSamples() {}, addSamples() {}
};
const synth = new alphaTab.synth.AlphaSynth(output, 200);
const options = new alphaTab.synth.AudioExportOptions();
options.soundFonts = [sf2(parameters)];
const exporter = synth.exportAudio(options, midi, generator.syncPoints, generator.transpositionPitches);
return exporter.render(400).samples;
}
const rms = samples => Math.sqrt(samples.reduce((sum, v) => sum + v * v, 0) / samples.length);
const reference = rms(render({}));
assert.ok(reference > 0.0001, 'Reference must be audible');
const cases = [
['preset override', { pg: 200, pl: 120 }, 12],
['instrument override', { ig: 127, il: 50 }, 5],
['both overrides', { pg: 200, pl: 120, ig: 127, il: 50 }, 17],
['inherit missing locals', { pg: 200, ig: 50 }, 25],
['preset zero override', { pg: 200, pl: 0, il: 50 }, 5],
['instrument zero override', { pl: 120, ig: 127, il: 0 }, 12],
['cross-level addition', { pl: 120, il: 50 }, 17],
['negative preset offset', { pl: -60, il: 100 }, 4],
['default', {}, 0]
];
const results = cases.map(([name, parameters, expectedDb]) => {
const actualDb = -20 * Math.log10(rms(render(parameters)) / reference);
return { name, expectedDb, actualDb: Number(actualDb.toFixed(4)), pass: Math.abs(actualDb - expectedDb) < 0.00001 };
});
console.table(results);
assert.ok(results.every(r => r.pass), 'Local attenuation must replace global attenuation at the same level');
Link to jsFiddle, CodePen, Project
No response
Version and Environment
[Actual output from alphaTab.Environment.printEnvironmentInfo()]
[AlphaTab][VersionInfo] alphaTab 1.8.4
[AlphaTab][VersionInfo] commit: 022a45c8e42370f9e12e68949d11eada370da83d
[AlphaTab][VersionInfo] build date: 2026-07-05T14:46:18.224Z
[AlphaTab][VersionInfo] High DPI: 1
[AlphaTab][VersionInfo] Platform: NodeJs
[AlphaTab][VersionInfo] WebPack: false
[AlphaTab][VersionInfo] Vite: false
Node v24.11.1; process.platform = darwin; process.arch = arm64.
Official npm 1.8.4 tarball verified against its registry SHA512 integrity value.
Offline PCM export at 44100 Hz; no browser or audio device is required.
Platform
Node.js
Anything else?
The reproduction measures PCM from the public AlphaSynth export API, rather than inferring the behavior from internal fields. It also includes passing controls for inheritance, cross-level addition, signed preset offsets, and the default gain.
The generated sine wave, MusicXML, and SF2 are contained entirely in the script; no external score, sample library, or hosted reproduction is required. No files are uploaded separately.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 1.9k
- Forks
- 297
- Ø Merge
- 9 Std. 41 Min.
- Gemergte PRs (30 T.)
- 41
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus CoderLine/alphaTab
-
ai-authored
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 69/100
Maintainer antworten meist innerhalb von 1 Tag
-
Fade out: track silent until the endEvtl. vergeben @Danielku15 hat das vor 1 Tag übernommen. Offen
CoderLine/alphaTab#2978 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Rendering issue: Unable to switch to Numbered Notation (jianpu) for specific tracks in v1.8.4Evtl. vergeben @Danielku15 hat das vor 2 Tagen übernommen. Offen
CoderLine/alphaTab#2976 · 3 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
ai-authored
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 1 Tag
-
Respect systems layout of MusicXMLEvtl. vergeben @Danielku15 hat das vor 23 Tagen übernommen. Offen
CoderLine/alphaTab#2909 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in CoderLine/alphaTab
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
gnosis/gnosis_vpn#661 ·
Maintainer antworten meist innerhalb von 1 Tag
-
content-freshness: staleOwnedContent doc comments still say 'complete receipt' (follow-up to #7912)Offentriage:bug-verified
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
Maintainer antworten meist innerhalb von 1 Tag
-
fix: reject sourceStorage/packagedStorage bucket that differs from the stack default (fail loud)Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Eyevinn/open-videocore#1300 ·
Maintainer antworten meist innerhalb von 1 Tag
-
nextjs-tracking
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
cloudflare/vinext#4390 ·
Maintainer antworten meist innerhalb von 1 Tag
-
kind/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
kubernetes-sigs/headlamp#8175 ·
Maintainer antworten meist innerhalb von 2 Tagen