Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(music): an instrument only struck as a drum is not told its recording is the wrong note - the pitch found in a drum is not a note it can be out of

yhh0ab6e56eafbf
diff --git a/pipeline/src/music/musicRender.ts b/pipeline/src/music/musicRender.ts
index 7724a376a..b0e79acf7 100644
--- a/pipeline/src/music/musicRender.ts
+++ b/pipeline/src/music/musicRender.ts
@@ -586,7 +586,8 @@ export function renderMusic(source: MusicSource, given: Readonly<Record<string,
// A recording called a note it is not puts every note played from it out of tune, and nothing in the notes shows it.
for (const name of names) {
const wrong: { file: string; said: number; is: number }[] = [];
- const zones = source.instruments[name]!.samples ?? [];
+ // A drum is struck as it was recorded, at no note: whatever pitch is found in it, it is not out of tune with anything.
+ const zones = compiled.events.some((e) => e.instrument === name && e.midi !== null) ? source.instruments[name]!.samples ?? [] : [];
const heard = new Set<string>();
for (const zone of zones) {
const data = given[zone.file];
diff --git a/pipeline/tests/music.test.ts b/pipeline/tests/music.test.ts
index ed427ee1d..25138dfde 100644
--- a/pipeline/tests/music.test.ts
+++ b/pipeline/tests/music.test.ts
@@ -314,6 +314,8 @@ describe('an instrument made of recordings', () => {
const files = { 'a.wav': rich(220), 'e.wav': rich(329.63) };
expect(notes([{ file: 'a.wav', note: 'A3' }, { file: 'e.wav', note: 'E4' }], files)).toEqual([]);
expect(notes([{ file: 'a.wav', note: 'A3' }, { file: 'e.wav', note: 'D4' }], files)).toEqual(['"keys": e.wav is said to be D4 and sounds as E4: every note played from it is 2 semitones higher than written. Set its note to "E4"']);
+ // An instrument that is only ever struck as a drum has no note to be out of.
+ expect(renderMusic(validateMusicSource({ tempo: 120, key: 'A', humanize: 0, instruments: { keys: { samples: [{ file: 'a.wav', note: 'C2' }] } }, patterns: { a: { bars: 1, tracks: { keys: 'x . . . x . . . . . . . . . . .' } } }, song: ['a'] }), files).notes).toEqual([]);
// A library that counts its octaves from another C is out everywhere, and that is said once.
const octave = notes([{ file: 'a.wav', note: 'A2' }, { file: 'e.wav', note: 'E3' }], files);
expect(octave).toHaveLength(1);
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index d524612de..e4ced09ba 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -4646,6 +4646,8 @@ export const NOTED = {
{"note": "An AI can make background music."},
"chore(desktop): the music tool text puts leaving a part alone before adding to it":
{"note": "An AI can make background music."},
+ "fix(music): an instrument only struck as a drum is not told its recording is the wrong note - the pitch found in a drum is not a note it can be out of":
+ {"note": "An AI can make background music."},
"feat(sky): a sky of your own shades the ground under its clouds - defineSkyEffect takes groundShadow and a second function, skyShadow(world, sun), what is left of the light at a world position, and the sky pass multiplies every surface it finds by it, as Sky Atmosphere does with its own clouds":
{"note": "A sky of your own shades the ground under its clouds."},
"fix(terrain): a colour map and an occlusion map lie the way the heightmap does - Terrain.colorMap, Terrain.occlusionMap and Foliage.colorMap were sampled with their rows turned over, so a picture painted to match a heightmap, a splatmap or a density map came out mirrored north to south under them; an image over an area now has its first row along the least z whoever reads it":