SoundFont local initialAttenuation does not override global attenuation, making affected presets too quiet
Les mainteneurs répondent en général sous 1 jour
@Danielku15 y travaille déjà.
Depuis le 27/10/2026.
Évaluation
Cette issue n'a pas encore été évaluée.
Description
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.
- Langage dominant
- TypeScript
- Étoiles
- 1.9k
- Forks
- 297
- Merge moyen
- 9 h 41 min
- PR mergées (30 j)
- 41
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de CoderLine/alphaTab
-
ai-authored
Difficulté 2/5 1-3 heures Accessibilité débutants 69/100
Les mainteneurs répondent en général sous 1 jour
-
Fade out: track silent until the endPeut-être pris @Danielku15 l’a pris il y a 1 jour. Ouverte
CoderLine/alphaTab#2978 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
Rendering issue: Unable to switch to Numbered Notation (jianpu) for specific tracks in v1.8.4Peut-être pris @Danielku15 l’a pris il y a 3 jours. Ouverte
CoderLine/alphaTab#2976 · 3 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
ai-authored
Difficulté 3/5 1-2 jours Accessibilité débutants 66/100
Les mainteneurs répondent en général sous 1 jour
-
Respect systems layout of MusicXMLPeut-être pris @Danielku15 l’a pris il y a 23 jours. Ouverte
CoderLine/alphaTab#2909 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de CoderLine/alphaTab
Issues similaires
-
Difficulté 1/5 1-3 heures Accessibilité débutants 66/100
Les mainteneurs répondent en général sous 1 jour
-
area:plugins area:security area:skills bug has repro
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
anthropics/claude-code#105911 ·
Les mainteneurs répondent en général sous 1 jour
-
[ko] Translate /team into KoreanOuvertedocumentation good first issue help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
dev-five-git/devup-ui#879 ·
Les mainteneurs répondent en général sous 11 jours
-
openspec-apply-change skill: when blocked, may select a ready artifact unrelated to missingArtifactsOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Fission-AI/OpenSpec#2165 ·
Les mainteneurs répondent en général sous 1 jour
-
🐞 bug 🧐 unconfirmed
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
Tencent/tdesign-vue-next#7032 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour