Pick a song's sign in one row, and let its patterns keep theirs (#363)
A song had two rows for its meter, Beats per bar and Beat, and the patterns it kept to itself took both from it on every change. Their length is counted in bars, so a new sign cut or stretched them and their items. - The song has one row Sign with 1/2, 2/2, 3/2, 1/4 to 6/4 and 5/8 to 9/8, 4/4 by default. It is stored as `sign`. A value not in the list reads as 4/4. - An embedded pattern keeps its own tempo and meter, as a project pattern does. Its inspector shows Tempo, Beats per bar and Beat again and hides only Bus. - A pattern made in a song still starts with the song's tempo and sign, so its first bar fits the item it gets. - A copy (Embed a copy, a paste from another song) keeps its clock. `clockFollowers` and the follow step in `AssetPropertyCommand` are gone. - No load migration. The two songs of the user's project were moved from `beats`/`beat` to `sign` by hand. No other project had a song with a meter of its own. Tests: - Unit song + embedded + pattern: 44 green, 1 new, 4 rewritten. Counter-probes: a copy taking the song's clock and a sign outside the list both turn a test red. - e2e 65 (melektaus-atx): ALL PASSED, 57 checks (1 new: Sign picked from its list in the inspector). - Gate (melektaus-atx): CHECK EXIT 0, 272 files, 4214 tests. After it, `SIGNS` lost its `as const` and the cast went with it. Typecheck, lint and the 44 unit tests ran again, all green. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d0b76ec355
commit
0d57a2f3c4
7 files changed
+109
-92
No files matched your search
@@ -12,7 +12,7 @@ import type {
|
||||
VariablesAsset,
|
||||
} from '../model/Asset';
|
||||
import type { AssetType } from '../model/AssetTypes';
|
||||
import { clockFollowers, embeddedIn } from '../music/embedded';
|
||||
import { embeddedIn } from '../music/embedded';
|
||||
import { defaultTracks } from '../music/song';
|
||||
import { heldSongGraph } from '../music/routing';
|
||||
import { linearCurve } from '../model/curve';
|
||||
@@ -21,7 +21,7 @@ import { DEFAULT_PALETTE, PIXEL_CANVAS_DEFAULT } from '../model/pixelart';
|
||||
import { isSoundFile, renewClipIds } from '../model/sound';
|
||||
import { removeSubtrees } from '../model/hierarchy';
|
||||
import { dropReferencesToGone, renamedReference, shownObjectIds, swapReferences } from '../model/objectRefs';
|
||||
import { type PropertyBag, type PropertyValue, setBagValue } from '../model/Properties';
|
||||
import type { PropertyBag, PropertyValue } from '../model/Properties';
|
||||
import { objectHolders, type Project } from '../model/Project';
|
||||
import {
|
||||
type Scope,
|
||||
@@ -547,12 +547,8 @@ export class SetMachineStartCommand implements Command {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An embedded pattern follows the tempo and the meter of its song (#355), in the same undo step. A
|
||||
* song that picks another sound FX lets go of the one it kept to itself, in that step too.
|
||||
*/
|
||||
/** A song that picks another sound FX lets go of the one it kept to itself, in the same undo step. */
|
||||
abstract class AssetPropertyCommand extends SetBagValueCommand<Asset> {
|
||||
private followed: { id: string; previous: PropertyValue | undefined }[] = [];
|
||||
private settled: SetSongCommand | null = null;
|
||||
|
||||
protected constructor(
|
||||
@@ -566,11 +562,6 @@ abstract class AssetPropertyCommand extends SetBagValueCommand<Asset> {
|
||||
override execute(project: Project): void {
|
||||
super.execute(project);
|
||||
const asset = requireAsset(project, this.assetId);
|
||||
this.followed = clockFollowers(project, asset, this.key).map((pattern) => {
|
||||
const previous = pattern.props[this.key];
|
||||
setBagValue(pattern.props, this.key, asset.props[this.key]);
|
||||
return { id: pattern.id, previous };
|
||||
});
|
||||
this.settled =
|
||||
asset.type === 'song' && this.key === ASSET_FX_KEY ? new SetSongCommand(asset.id, {}) : null;
|
||||
this.settled?.execute(project);
|
||||
@@ -578,8 +569,6 @@ abstract class AssetPropertyCommand extends SetBagValueCommand<Asset> {
|
||||
|
||||
override undo(project: Project): void {
|
||||
this.settled?.undo(project);
|
||||
for (const { id, previous } of this.followed)
|
||||
setBagValue(requireAsset(project, id).props, this.key, previous);
|
||||
super.undo(project);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user