Until now every sound went straight to the speakers. There was no point where all of them came together, so nothing could turn the music down against the effects, and a compressor or a shared echo over everything had nowhere to sit. The bus technique of #346 was there already, only the end of the chain was missing. - Bus asset (Audio): Volume, Sound FX and Into. Into is empty for the master and never offers the bus itself nor a bus that already goes into it. The list is worked out when the menu opens, so a change made meanwhile counts. A loop that is in a project anyway sends the buses on it into the master. - The master is no asset. Its volume and sound FX are two new rows under Master in Project settings, one undo step each. A project written before has 1 and none, which is how it sounded. - Sound, instrument, pattern and song have a row Bus, empty for the master. Play sound, Play note, Play pattern and Play song have an input bus: From the asset, Master or a bus. Inside a song or a pattern only the bus of the song or pattern counts. - Set bus volume (bus, volume, time, easing) and Bus volume. An empty bus is the master. The volume set holds for the whole run, across scenes, over that of the asset. GameRun resets it at start and end. Set sound FX parameters without a voice now reaches the sound FX of the bus picked in its new bus input. - SoundLibrary: the master is the bus "mix", each bus "mix:<id>". Every bus, the playing masters of #346 included, ends there, and only the master is heard. setMix sets them up once a context exists, so an editor nobody listened to opens no audio device. The same mix again changes nothing, which lets the editor hand it over on every change of the project. - The tabs play as the game does: Sound, Sound FX, Instrument, Pattern and Song tab through the bus of their asset and the master. - Pause game does nothing to the buses (the user's answer 4b). A game that wants quiet in its pause menu sets a bus volume itself. - Streaming long music files is #349, split off as asked. Finding on the way: the Into menu first worked from a list made when the inspector row was built. After another bus was sent into the open one, e2e 34 saw it still offered. It is now asked on open. The SoundLibrary tests expected voices to end at the destination. They now end in the master, which adds its input, level and pan to every wiring and two gains to every list. Those expectations are updated, nothing else in them changed. Tests: - Unit buses (new): 15 green. Ten counter-checks, each red on its own: loop check, bus picked, reset at run start, bus of Set sound FX parameters, master volume in the settings, and in SoundLibrary default into the master, voices into the master, run volume over the mix, no context before a play, a playing on its bus. - Unit sound-library: 90 green (5 new). Node catalog: 416 green (9 new cases). - e2e 34 (melektaus-atx): ALL PASSED, 75 checks (3 new). The voice of the Sound tab was heard on mix:<bus>, that bus into the other, that one at 0.5 into the master. Master volume 0.6 via the dialog, undo back to 1. - Gate (melektaus-atx): CHECK EXIT 0, 262 files, 4072 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
164 lines
4.4 KiB
TypeScript
164 lines
4.4 KiB
TypeScript
import { layerNamesOf } from '../model/collisionLayers';
|
||
import {
|
||
DEFAULT_GAME_LINK_ZOOM,
|
||
DEFAULT_WHILE_PLAYING,
|
||
type GameLinkZoom,
|
||
type PlayFrom,
|
||
type WhilePlaying,
|
||
} from '../model/playSettings';
|
||
import type { Project } from '../model/Project';
|
||
import { clampSymbolScale } from '../model/symbolScale';
|
||
import { clampMasterVolume } from '../model/master';
|
||
import type { Command } from './Command';
|
||
|
||
export class RenameProjectCommand implements Command {
|
||
readonly label = 'Rename project';
|
||
private previous = '';
|
||
|
||
constructor(private readonly name: string) {}
|
||
|
||
execute(project: Project): void {
|
||
this.previous = project.name;
|
||
project.name = this.name;
|
||
}
|
||
|
||
undo(project: Project): void {
|
||
project.name = this.previous;
|
||
}
|
||
}
|
||
|
||
export type LayerList = 'collisionLayers' | 'renderLayers';
|
||
|
||
const LAYER_LIST_LABEL: Record<LayerList, string> = {
|
||
collisionLayers: 'Collision layers',
|
||
renderLayers: 'Render layers',
|
||
};
|
||
|
||
/**
|
||
* The named collision layers (#152) or render layers (#302) of the project. Objects name a layer by
|
||
* number, so removing one shifts what every object below it points at – which is why the dialog only
|
||
* ever hands over a whole list, and why the list is read through `layerNamesOf` here as well.
|
||
*/
|
||
export class SetLayerNamesCommand implements Command {
|
||
readonly label: string;
|
||
private previous: string[] = [];
|
||
|
||
constructor(
|
||
private readonly list: LayerList,
|
||
private readonly names: readonly string[],
|
||
) {
|
||
this.label = LAYER_LIST_LABEL[list];
|
||
}
|
||
|
||
execute(project: Project): void {
|
||
this.previous = project[this.list];
|
||
project[this.list] = layerNamesOf(this.names);
|
||
}
|
||
|
||
undo(project: Project): void {
|
||
project[this.list] = this.previous;
|
||
}
|
||
}
|
||
|
||
/** Size of the scene view's symbol icons, kept inside its range like a loaded project's. */
|
||
export class SetSymbolScaleCommand implements Command {
|
||
readonly label = 'Symbol scale';
|
||
private previous = 1;
|
||
|
||
constructor(private readonly scale: number) {}
|
||
|
||
execute(project: Project): void {
|
||
this.previous = project.symbolScale;
|
||
project.symbolScale = clampSymbolScale(this.scale);
|
||
}
|
||
|
||
undo(project: Project): void {
|
||
project.symbolScale = this.previous;
|
||
}
|
||
}
|
||
|
||
/** Which scene Play starts (#226): saved with the project like the rest of its settings. */
|
||
export class SetPlayFromCommand implements Command {
|
||
readonly label = 'Play starts';
|
||
private previous: PlayFrom = 'start';
|
||
|
||
constructor(private readonly playFrom: PlayFrom) {}
|
||
|
||
execute(project: Project): void {
|
||
this.previous = project.playFrom;
|
||
project.playFrom = this.playFrom;
|
||
}
|
||
|
||
undo(project: Project): void {
|
||
project.playFrom = this.previous;
|
||
}
|
||
}
|
||
|
||
/** How closely the panels follow a running game (#265). */
|
||
export class SetWhilePlayingCommand implements Command {
|
||
readonly label = 'While playing';
|
||
private previous: WhilePlaying = DEFAULT_WHILE_PLAYING;
|
||
|
||
constructor(private readonly whilePlaying: WhilePlaying) {}
|
||
|
||
execute(project: Project): void {
|
||
this.previous = project.whilePlaying;
|
||
project.whilePlaying = this.whilePlaying;
|
||
}
|
||
|
||
undo(project: Project): void {
|
||
project.whilePlaying = this.previous;
|
||
}
|
||
}
|
||
|
||
/** How the page of the released game sizes the camera frame (#279). */
|
||
export class SetGameLinkZoomCommand implements Command {
|
||
readonly label = 'Game link zoom';
|
||
private previous: GameLinkZoom = DEFAULT_GAME_LINK_ZOOM;
|
||
|
||
constructor(private readonly zoom: GameLinkZoom) {}
|
||
|
||
execute(project: Project): void {
|
||
this.previous = project.gameLinkZoom;
|
||
project.gameLinkZoom = this.zoom;
|
||
}
|
||
|
||
undo(project: Project): void {
|
||
project.gameLinkZoom = this.previous;
|
||
}
|
||
}
|
||
|
||
/** The level of the master bus (#325), kept inside 0–1 like a loaded project's. */
|
||
export class SetMasterVolumeCommand implements Command {
|
||
readonly label = 'Master volume';
|
||
private previous = 1;
|
||
|
||
constructor(private readonly volume: number) {}
|
||
|
||
execute(project: Project): void {
|
||
this.previous = project.masterVolume;
|
||
project.masterVolume = clampMasterVolume(this.volume);
|
||
}
|
||
|
||
undo(project: Project): void {
|
||
project.masterVolume = this.previous;
|
||
}
|
||
}
|
||
|
||
/** The sound FX of the master bus (#325), by id; '' for none. */
|
||
export class SetMasterFxCommand implements Command {
|
||
readonly label = 'Master FX';
|
||
private previous = '';
|
||
|
||
constructor(private readonly fx: string) {}
|
||
|
||
execute(project: Project): void {
|
||
this.previous = project.masterFx;
|
||
project.masterFx = this.fx;
|
||
}
|
||
|
||
undo(project: Project): void {
|
||
project.masterFx = this.previous;
|
||
}
|
||
}
|