not sure
This commit is contained in:
parent
560398fefb
commit
80ed37298b
73 changed files with 3619 additions and 1295 deletions
|
|
@ -86,6 +86,15 @@ test('keeps fallback controls interactive and accessible', async ({ page }) => {
|
||||||
await expect(settingsButton).toHaveAttribute('aria-expanded', 'false');
|
await expect(settingsButton).toHaveAttribute('aria-expanded', 'false');
|
||||||
|
|
||||||
const soundButton = page.locator('button.sound');
|
const soundButton = page.locator('button.sound');
|
||||||
|
const volumeSlider = page.getByLabel('Master volume');
|
||||||
|
await expect(volumeSlider).toHaveValue('0.42');
|
||||||
|
await volumeSlider.evaluate((input) => {
|
||||||
|
const slider = input as HTMLInputElement;
|
||||||
|
slider.value = '0.25';
|
||||||
|
slider.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
});
|
||||||
|
await expect(volumeSlider).toHaveValue('0.25');
|
||||||
|
await expect(volumeSlider).toHaveAttribute('aria-valuetext', '25%');
|
||||||
await expect(soundButton).toHaveAttribute('aria-pressed', 'false');
|
await expect(soundButton).toHaveAttribute('aria-pressed', 'false');
|
||||||
await soundButton.click();
|
await soundButton.click();
|
||||||
await expect(soundButton).toHaveAttribute('aria-pressed', 'true');
|
await expect(soundButton).toHaveAttribute('aria-pressed', 'true');
|
||||||
|
|
@ -93,6 +102,11 @@ test('keeps fallback controls interactive and accessible', async ({ page }) => {
|
||||||
await page.reload();
|
await page.reload();
|
||||||
await expect(page.locator('body')).not.toHaveClass(/is-loading/);
|
await expect(page.locator('body')).not.toHaveClass(/is-loading/);
|
||||||
await expect(page.locator('button.sound')).toHaveAttribute('aria-pressed', 'true');
|
await expect(page.locator('button.sound')).toHaveAttribute('aria-pressed', 'true');
|
||||||
|
await expect(page.getByLabel('Master volume')).toHaveValue('0.25');
|
||||||
|
await expect(page.getByLabel('Master volume')).toHaveAttribute(
|
||||||
|
'aria-valuetext',
|
||||||
|
'Muted, 25%'
|
||||||
|
);
|
||||||
|
|
||||||
const initialSwatchColor = await getFirstSwatchColor(page);
|
const initialSwatchColor = await getFirstSwatchColor(page);
|
||||||
const initialBackground = await getGardenBackground(page);
|
const initialBackground = await getGardenBackground(page);
|
||||||
|
|
|
||||||
17
index.html
17
index.html
|
|
@ -167,12 +167,17 @@
|
||||||
aria-expanded="false"
|
aria-expanded="false"
|
||||||
title="Show config overlay"
|
title="Show config overlay"
|
||||||
></button>
|
></button>
|
||||||
<button
|
<div class="audio-control">
|
||||||
class="sound"
|
<button
|
||||||
aria-label="Mute audio"
|
class="sound"
|
||||||
aria-pressed="false"
|
aria-label="Mute audio"
|
||||||
title="Mute audio"
|
aria-pressed="false"
|
||||||
></button>
|
title="Mute audio"
|
||||||
|
></button>
|
||||||
|
<label class="volume-control" title="Master volume">
|
||||||
|
<input class="volume-slider" type="range" aria-label="Master volume" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<button
|
<button
|
||||||
class="export-4k"
|
class="export-4k"
|
||||||
aria-label="Download 4K upscale image"
|
aria-label="Download 4K upscale image"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { appConfig } from '../config';
|
import { appConfig } from '../config';
|
||||||
|
import type { PianoNoteRole } from './garden-audio-types';
|
||||||
|
|
||||||
type GardenAudioChordQuality = 'major' | 'minor';
|
type GardenAudioChordQuality = 'major' | 'minor';
|
||||||
|
|
||||||
|
|
@ -27,7 +28,154 @@ export interface GardenAudioStylePool extends GardenAudioRegister {
|
||||||
interface GardenAudioGenerativePianoConfig {
|
interface GardenAudioGenerativePianoConfig {
|
||||||
stylePools: [GardenAudioStylePool, GardenAudioStylePool, GardenAudioStylePool];
|
stylePools: [GardenAudioStylePool, GardenAudioStylePool, GardenAudioStylePool];
|
||||||
padRegisters: [GardenAudioRegister, GardenAudioRegister, GardenAudioRegister];
|
padRegisters: [GardenAudioRegister, GardenAudioRegister, GardenAudioRegister];
|
||||||
|
chordVoicings: {
|
||||||
|
majorOpen: Array<number>;
|
||||||
|
minorOpen: Array<number>;
|
||||||
|
majorClosed: Array<number>;
|
||||||
|
minorClosed: Array<number>;
|
||||||
|
};
|
||||||
|
vibeChangeStinger: {
|
||||||
|
velocities: [number, number, number];
|
||||||
|
pans: [number, number, number];
|
||||||
|
delaySends: [number, number, number];
|
||||||
|
lowpassExpression: number;
|
||||||
|
};
|
||||||
|
highActivityExtra: {
|
||||||
|
barOffset: number;
|
||||||
|
expressionMultiplier: number;
|
||||||
|
};
|
||||||
|
padChord: {
|
||||||
|
velocities: [number, number, number];
|
||||||
|
expressionVelocityWeight: number;
|
||||||
|
delaySend: number;
|
||||||
|
lowpassExpressionWeight: number;
|
||||||
|
};
|
||||||
|
supportNote: {
|
||||||
|
velocityBase: number;
|
||||||
|
velocityExpressionWeight: number;
|
||||||
|
durationBaseSeconds: number;
|
||||||
|
durationExpressionSeconds: number;
|
||||||
|
delaySendBase: number;
|
||||||
|
delaySendExpressionWeight: number;
|
||||||
|
lowpassExpressionWeight: number;
|
||||||
|
expressionThreshold: number;
|
||||||
|
offsetsByStyle: [Array<number>, Array<number>, Array<number>];
|
||||||
|
};
|
||||||
|
textureNote: {
|
||||||
|
velocityBase: number;
|
||||||
|
velocityExpressionWeight: number;
|
||||||
|
durationBaseSeconds: number;
|
||||||
|
durationExpressionSeconds: number;
|
||||||
|
delaySendBase: number;
|
||||||
|
delaySendExpressionWeight: number;
|
||||||
|
idleExpressionThreshold: number;
|
||||||
|
mediumExpressionThreshold: number;
|
||||||
|
intenseSpacing: number;
|
||||||
|
idlePhase: number;
|
||||||
|
};
|
||||||
|
gestureAccent: {
|
||||||
|
rotationStrengthMultiplier: number;
|
||||||
|
quantizeStepLookahead: number;
|
||||||
|
velocityBase: number;
|
||||||
|
velocityStrengthWeight: number;
|
||||||
|
durationBaseSeconds: number;
|
||||||
|
durationStrengthSeconds: number;
|
||||||
|
delaySend: number;
|
||||||
|
};
|
||||||
|
touchNote: {
|
||||||
|
registerBiasManiaAmount: number;
|
||||||
|
velocityBase: number;
|
||||||
|
velocityStrengthWeight: number;
|
||||||
|
durationBaseSeconds: number;
|
||||||
|
durationStrengthSeconds: number;
|
||||||
|
delaySend: number;
|
||||||
|
lowpassBaseExpression: number;
|
||||||
|
lowpassStrengthWeight: number;
|
||||||
|
};
|
||||||
|
brushPhrase: {
|
||||||
|
initialMotifOffset: number;
|
||||||
|
energyRetain: number;
|
||||||
|
maniaRetain: number;
|
||||||
|
energyDecaySeconds: number;
|
||||||
|
maniaDecaySeconds: number;
|
||||||
|
fadeMinimumLifetimeSeconds: number;
|
||||||
|
layerIntensityBase: number;
|
||||||
|
layerIntensityManiaWeight: number;
|
||||||
|
frameActivityWeight: number;
|
||||||
|
frameManiaWeight: number;
|
||||||
|
};
|
||||||
|
brushStream: {
|
||||||
|
inferredManiaThreshold: number;
|
||||||
|
inferredManiaRange: number;
|
||||||
|
registerManiaShift: number;
|
||||||
|
chordToneEverySteps: number;
|
||||||
|
durationBaseSeconds: number;
|
||||||
|
durationIntensitySeconds: number;
|
||||||
|
durationManiaSeconds: number;
|
||||||
|
durationMinSeconds: number;
|
||||||
|
durationMaxSeconds: number;
|
||||||
|
delaySendBase: number;
|
||||||
|
delaySendIntensityWeight: number;
|
||||||
|
delaySendManiaWeight: number;
|
||||||
|
delaySendMin: number;
|
||||||
|
delaySendMax: number;
|
||||||
|
velocityBase: number;
|
||||||
|
velocityIntensityWeight: number;
|
||||||
|
lowpassBaseExpression: number;
|
||||||
|
lowpassIntensityWeight: number;
|
||||||
|
lowpassManiaWeight: number;
|
||||||
|
manicThreshold: number;
|
||||||
|
intenseThreshold: number;
|
||||||
|
activeThreshold: number;
|
||||||
|
};
|
||||||
|
brushStreamEcho: {
|
||||||
|
maniaThreshold: number;
|
||||||
|
stepModulo: number;
|
||||||
|
stepRemainder: number;
|
||||||
|
intensityThreshold: number;
|
||||||
|
octaveSemitones: number;
|
||||||
|
maxMidi: number;
|
||||||
|
velocityBase: number;
|
||||||
|
velocityIntensityWeight: number;
|
||||||
|
durationMinSeconds: number;
|
||||||
|
durationScale: number;
|
||||||
|
panScale: number;
|
||||||
|
delaySendMin: number;
|
||||||
|
delaySendScale: number;
|
||||||
|
lowpassBaseExpression: number;
|
||||||
|
lowpassManiaWeight: number;
|
||||||
|
};
|
||||||
|
brushMotif: {
|
||||||
|
highThreshold: number;
|
||||||
|
mediumThreshold: number;
|
||||||
|
highOffset: number;
|
||||||
|
mediumOffset: number;
|
||||||
|
lowOffset: number;
|
||||||
|
minOffset: number;
|
||||||
|
maxOffset: number;
|
||||||
|
};
|
||||||
|
registerBias: {
|
||||||
|
maniaShiftSemitones: number;
|
||||||
|
midiMin: number;
|
||||||
|
midiMaxForMin: number;
|
||||||
|
minimumSpan: number;
|
||||||
|
midiMax: number;
|
||||||
|
};
|
||||||
|
candidateOctaveSearch: {
|
||||||
|
min: number;
|
||||||
|
max: number;
|
||||||
|
};
|
||||||
|
styleRotationMinSeconds: number;
|
||||||
|
stylePanOffsetScale: number;
|
||||||
|
lowpass: {
|
||||||
|
midiBase: number;
|
||||||
|
midiRange: number;
|
||||||
|
midiLiftHz: number;
|
||||||
|
expressionBase: number;
|
||||||
|
expressionWeight: number;
|
||||||
|
};
|
||||||
styleRotationSeconds: number;
|
styleRotationSeconds: number;
|
||||||
|
styleRotationBars: number;
|
||||||
chordBars: number;
|
chordBars: number;
|
||||||
supportBarSpacing: number;
|
supportBarSpacing: number;
|
||||||
supportBarOffset: number;
|
supportBarOffset: number;
|
||||||
|
|
@ -38,13 +186,16 @@ interface GardenAudioGenerativePianoConfig {
|
||||||
highActivityExtraThreshold: number;
|
highActivityExtraThreshold: number;
|
||||||
noteScorePreferenceWeight: number;
|
noteScorePreferenceWeight: number;
|
||||||
noteScoreRegisterWeight: number;
|
noteScoreRegisterWeight: number;
|
||||||
|
noteScoreChordToneWeight: number;
|
||||||
noteScoreRepeatPenalty: number;
|
noteScoreRepeatPenalty: number;
|
||||||
gestureAccentMinIntervalSeconds: number;
|
gestureAccentMinIntervalSeconds: number;
|
||||||
strokeAccentMinIntervalSeconds: number;
|
strokeAccentMinIntervalSeconds: number;
|
||||||
|
strokeAccentMinSteps: number;
|
||||||
strokeAccentThreshold: number;
|
strokeAccentThreshold: number;
|
||||||
stingerDurationSeconds: number;
|
stingerDurationSeconds: number;
|
||||||
stingerSpacingSeconds: number;
|
stingerSpacingSeconds: number;
|
||||||
maxBrushPhraseLayers: number;
|
maxBrushPhraseLayers: number;
|
||||||
|
maxBrushStreamNotesPerBar: number;
|
||||||
brushLayerBaseSeconds: number;
|
brushLayerBaseSeconds: number;
|
||||||
brushLayerEnergySeconds: number;
|
brushLayerEnergySeconds: number;
|
||||||
brushLayerMinIntensity: number;
|
brushLayerMinIntensity: number;
|
||||||
|
|
@ -80,10 +231,15 @@ export interface GardenAudioConfig {
|
||||||
feedbackMin: number;
|
feedbackMin: number;
|
||||||
outputActivityWeight: number;
|
outputActivityWeight: number;
|
||||||
outputBase: number;
|
outputBase: number;
|
||||||
|
outputActivityDuck: number;
|
||||||
timeRampSeconds: number;
|
timeRampSeconds: number;
|
||||||
|
feedbackHighPassHz: number;
|
||||||
|
feedbackLowPassHz: number;
|
||||||
|
returnLowPassHz: number;
|
||||||
};
|
};
|
||||||
piano: {
|
piano: {
|
||||||
maxVoices: number;
|
maxVoices: number;
|
||||||
|
filterType: BiquadFilterType;
|
||||||
gain: number;
|
gain: number;
|
||||||
sustainSeconds: number;
|
sustainSeconds: number;
|
||||||
sustainLevel: number;
|
sustainLevel: number;
|
||||||
|
|
@ -103,6 +259,12 @@ export interface GardenAudioConfig {
|
||||||
tailStopExtraSeconds: number;
|
tailStopExtraSeconds: number;
|
||||||
voiceStealFadeSeconds: number;
|
voiceStealFadeSeconds: number;
|
||||||
voiceStealStopSeconds: number;
|
voiceStealStopSeconds: number;
|
||||||
|
sampleBaseUrl: string;
|
||||||
|
preloadDecode: {
|
||||||
|
channels: number;
|
||||||
|
frames: number;
|
||||||
|
sampleRateHz: number;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
rhythm: {
|
rhythm: {
|
||||||
bpm: number;
|
bpm: number;
|
||||||
|
|
@ -117,6 +279,8 @@ export interface GardenAudioConfig {
|
||||||
filterMinHz: number;
|
filterMinHz: number;
|
||||||
filterMaxHz: number;
|
filterMaxHz: number;
|
||||||
durationSeconds: number;
|
durationSeconds: number;
|
||||||
|
pan: number;
|
||||||
|
pianoActivity: number;
|
||||||
};
|
};
|
||||||
energy: {
|
energy: {
|
||||||
attackSeconds: number;
|
attackSeconds: number;
|
||||||
|
|
@ -134,12 +298,37 @@ export interface GardenAudioConfig {
|
||||||
noiseMin: number;
|
noiseMin: number;
|
||||||
unlockTickFrequencyHz: number;
|
unlockTickFrequencyHz: number;
|
||||||
unlockTickSeconds: number;
|
unlockTickSeconds: number;
|
||||||
|
unlockTickType: OscillatorType;
|
||||||
|
latencyHint: AudioContextLatencyCategory;
|
||||||
|
outputFilterType: BiquadFilterType;
|
||||||
|
noiseBufferChannels: number;
|
||||||
|
noiseBufferDurationSeconds: number;
|
||||||
|
pianoBusGains: Record<PianoNoteRole, number>;
|
||||||
|
pianoBusActivityDucking: Record<PianoNoteRole, number>;
|
||||||
|
noiseBusGain: number;
|
||||||
|
compressor: {
|
||||||
|
thresholdDb: number;
|
||||||
|
kneeDb: number;
|
||||||
|
ratio: number;
|
||||||
|
attackSeconds: number;
|
||||||
|
releaseSeconds: number;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
input: {
|
input: {
|
||||||
distanceWindowForFullActivityPixels: number;
|
distanceWindowForFullActivityPixels: number;
|
||||||
distanceWindowSeconds: number;
|
distanceWindowSeconds: number;
|
||||||
fallbackFrameSeconds: number;
|
fallbackFrameSeconds: number;
|
||||||
|
fullActivitySpeed: number;
|
||||||
|
activityNoiseFloorSpeed: number;
|
||||||
|
activityCurve: number;
|
||||||
|
activitySoftCeiling: number;
|
||||||
|
activityAttackSeconds: number;
|
||||||
|
activityReleaseSeconds: number;
|
||||||
|
minAudibleDistance: number;
|
||||||
manicActivityThreshold: number;
|
manicActivityThreshold: number;
|
||||||
|
manicReleaseThreshold: number;
|
||||||
|
maniaSmoothingSeconds: number;
|
||||||
|
minElapsedSeconds: number;
|
||||||
};
|
};
|
||||||
muteGain: number;
|
muteGain: number;
|
||||||
muteRampSeconds: number;
|
muteRampSeconds: number;
|
||||||
|
|
@ -149,6 +338,7 @@ export interface GardenAudioConfig {
|
||||||
offsetRandomSeconds: number;
|
offsetRandomSeconds: number;
|
||||||
scheduleAheadSeconds: number;
|
scheduleAheadSeconds: number;
|
||||||
silentGain: number;
|
silentGain: number;
|
||||||
|
filterType: BiquadFilterType;
|
||||||
};
|
};
|
||||||
startDelaySeconds: number;
|
startDelaySeconds: number;
|
||||||
vibeChangeStingerMinIntervalSeconds: number;
|
vibeChangeStingerMinIntervalSeconds: number;
|
||||||
|
|
|
||||||
|
|
@ -2,38 +2,94 @@ import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
import { gardenAudioConfig } from './garden-audio-config';
|
import { gardenAudioConfig } from './garden-audio-config';
|
||||||
import { GardenAudioGestureState } from './garden-audio-gesture-state';
|
import { GardenAudioGestureState } from './garden-audio-gesture-state';
|
||||||
|
import type { GardenAudioStrokeMetrics } from './garden-audio-input';
|
||||||
|
|
||||||
|
const makeMetrics = ({
|
||||||
|
elapsedSeconds,
|
||||||
|
normalizedDistance,
|
||||||
|
}: {
|
||||||
|
elapsedSeconds: number;
|
||||||
|
normalizedDistance: number;
|
||||||
|
}): GardenAudioStrokeMetrics => ({
|
||||||
|
distancePixels: normalizedDistance * 1000,
|
||||||
|
elapsedSeconds,
|
||||||
|
normalizedDistance,
|
||||||
|
normalizedSpeed: normalizedDistance / elapsedSeconds,
|
||||||
|
});
|
||||||
|
|
||||||
describe('GardenAudioGestureState', () => {
|
describe('GardenAudioGestureState', () => {
|
||||||
it('uses only distance accumulated in the last half second', () => {
|
it('ignores tiny jitter below the activity speed floor', () => {
|
||||||
const state = new GardenAudioGestureState(gardenAudioConfig.input);
|
const state = new GardenAudioGestureState(gardenAudioConfig.input);
|
||||||
|
|
||||||
state.beginGesture();
|
state.beginGesture();
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
state.recordStroke({
|
state.recordStroke({
|
||||||
metrics: {
|
metrics: makeMetrics({
|
||||||
distancePixels: 70,
|
|
||||||
elapsedSeconds: 0.1,
|
elapsedSeconds: 0.1,
|
||||||
},
|
normalizedDistance: 0.001,
|
||||||
}).activity
|
}),
|
||||||
).toBeCloseTo(0.5);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
state.recordStroke({
|
|
||||||
metrics: {
|
|
||||||
distancePixels: 70,
|
|
||||||
elapsedSeconds: 0.1,
|
|
||||||
},
|
|
||||||
}).activity
|
|
||||||
).toBe(1);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
state.recordStroke({
|
|
||||||
metrics: {
|
|
||||||
distancePixels: 0,
|
|
||||||
elapsedSeconds: 0.51,
|
|
||||||
},
|
|
||||||
}).activity
|
}).activity
|
||||||
).toBe(0);
|
).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('normalizes equal drawing speeds across pointer sample rates', () => {
|
||||||
|
const lowRate = new GardenAudioGestureState(gardenAudioConfig.input);
|
||||||
|
const highRate = new GardenAudioGestureState(gardenAudioConfig.input);
|
||||||
|
|
||||||
|
lowRate.beginGesture();
|
||||||
|
highRate.beginGesture();
|
||||||
|
|
||||||
|
const lowRateFrame = lowRate.recordStroke({
|
||||||
|
metrics: makeMetrics({
|
||||||
|
elapsedSeconds: 0.1,
|
||||||
|
normalizedDistance: 0.07,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
let highRateFrame = { activity: 0, maniaAmount: 0 };
|
||||||
|
for (let index = 0; index < 5; index += 1) {
|
||||||
|
highRateFrame = highRate.recordStroke({
|
||||||
|
metrics: makeMetrics({
|
||||||
|
elapsedSeconds: 0.02,
|
||||||
|
normalizedDistance: 0.014,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(highRateFrame.activity).toBeCloseTo(lowRateFrame.activity, 5);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('holds mania with hysteresis before releasing', () => {
|
||||||
|
const state = new GardenAudioGestureState(gardenAudioConfig.input);
|
||||||
|
|
||||||
|
state.beginGesture();
|
||||||
|
|
||||||
|
const manicFrame = state.recordStroke({
|
||||||
|
metrics: makeMetrics({
|
||||||
|
elapsedSeconds: 0.25,
|
||||||
|
normalizedDistance: 0.3,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(manicFrame.maniaAmount).toBeGreaterThan(0);
|
||||||
|
|
||||||
|
const heldFrame = state.recordStroke({
|
||||||
|
metrics: makeMetrics({
|
||||||
|
elapsedSeconds: 0.06,
|
||||||
|
normalizedDistance: 0.04,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(heldFrame.maniaAmount).toBeGreaterThan(0);
|
||||||
|
|
||||||
|
const releasedFrame = state.recordStroke({
|
||||||
|
metrics: makeMetrics({
|
||||||
|
elapsedSeconds: 0.7,
|
||||||
|
normalizedDistance: 0,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(releasedFrame.maniaAmount).toBeLessThan(heldFrame.maniaAmount);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { clamp01 } from '../utils/clamp';
|
import { clamp, clamp01 } from '../utils/clamp';
|
||||||
import type { GardenAudioConfig } from './garden-audio-config';
|
import type { GardenAudioConfig } from './garden-audio-config';
|
||||||
import type { GardenAudioStrokeMetrics } from './garden-audio-input';
|
import type { GardenAudioStrokeMetrics } from './garden-audio-input';
|
||||||
|
|
||||||
|
|
@ -7,14 +7,11 @@ interface GardenAudioGestureFrame {
|
||||||
maniaAmount: number;
|
maniaAmount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GestureDistanceSample {
|
|
||||||
at: number;
|
|
||||||
distancePixels: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class GardenAudioGestureState {
|
export class GardenAudioGestureState {
|
||||||
private readonly samples: Array<GestureDistanceSample> = [];
|
|
||||||
private gestureClockSeconds = 0;
|
private gestureClockSeconds = 0;
|
||||||
|
private activity = 0;
|
||||||
|
private maniaAmount = 0;
|
||||||
|
private isManic = false;
|
||||||
|
|
||||||
public constructor(private readonly inputConfig: GardenAudioConfig['input']) {}
|
public constructor(private readonly inputConfig: GardenAudioConfig['input']) {}
|
||||||
|
|
||||||
|
|
@ -33,41 +30,79 @@ export class GardenAudioGestureState {
|
||||||
}): GardenAudioGestureFrame {
|
}): GardenAudioGestureFrame {
|
||||||
this.gestureClockSeconds += metrics.elapsedSeconds;
|
this.gestureClockSeconds += metrics.elapsedSeconds;
|
||||||
|
|
||||||
if (metrics.distancePixels > 0) {
|
const targetActivity = this.getTargetActivity(metrics);
|
||||||
this.samples.push({
|
const activityTimeConstant =
|
||||||
at: this.gestureClockSeconds,
|
targetActivity > this.activity
|
||||||
distancePixels: metrics.distancePixels,
|
? this.inputConfig.activityAttackSeconds
|
||||||
});
|
: this.inputConfig.activityReleaseSeconds;
|
||||||
}
|
this.activity = approach(
|
||||||
this.trimSamples();
|
this.activity,
|
||||||
|
targetActivity,
|
||||||
const windowDistancePixels = this.samples.reduce(
|
metrics.elapsedSeconds,
|
||||||
(total, sample) => total + sample.distancePixels,
|
activityTimeConstant
|
||||||
0
|
|
||||||
);
|
);
|
||||||
const activity = clamp01(
|
|
||||||
windowDistancePixels / this.inputConfig.distanceWindowForFullActivityPixels
|
if (this.activity >= this.inputConfig.manicActivityThreshold) {
|
||||||
|
this.isManic = true;
|
||||||
|
} else if (this.activity <= this.inputConfig.manicReleaseThreshold) {
|
||||||
|
this.isManic = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const maniaTarget = this.isManic
|
||||||
|
? smoothstep(this.inputConfig.manicReleaseThreshold, 1, this.activity)
|
||||||
|
: 0;
|
||||||
|
this.maniaAmount = approach(
|
||||||
|
this.maniaAmount,
|
||||||
|
maniaTarget,
|
||||||
|
metrics.elapsedSeconds,
|
||||||
|
this.inputConfig.maniaSmoothingSeconds
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activity,
|
activity: this.activity,
|
||||||
maniaAmount: smoothstep(this.inputConfig.manicActivityThreshold, 1, activity),
|
maniaAmount: this.maniaAmount,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public reset(): void {
|
public reset(): void {
|
||||||
this.samples.length = 0;
|
|
||||||
this.gestureClockSeconds = 0;
|
this.gestureClockSeconds = 0;
|
||||||
|
this.activity = 0;
|
||||||
|
this.maniaAmount = 0;
|
||||||
|
this.isManic = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private trimSamples(): void {
|
private getTargetActivity(metrics: GardenAudioStrokeMetrics): number {
|
||||||
const earliest = this.gestureClockSeconds - this.inputConfig.distanceWindowSeconds;
|
const normalizedSpeed = Math.max(0, metrics.normalizedSpeed);
|
||||||
while (this.samples.length > 0 && this.samples[0].at < earliest) {
|
const activeSpeed = Math.max(
|
||||||
this.samples.shift();
|
this.inputConfig.activityNoiseFloorSpeed,
|
||||||
}
|
this.inputConfig.fullActivitySpeed
|
||||||
|
);
|
||||||
|
const speedAmount = clamp01(
|
||||||
|
(normalizedSpeed - this.inputConfig.activityNoiseFloorSpeed) /
|
||||||
|
(activeSpeed - this.inputConfig.activityNoiseFloorSpeed)
|
||||||
|
);
|
||||||
|
const distanceAmount = clamp01(
|
||||||
|
metrics.normalizedDistance / this.inputConfig.minAudibleDistance
|
||||||
|
);
|
||||||
|
const activity = Math.pow(
|
||||||
|
speedAmount,
|
||||||
|
Math.max(0.001, this.inputConfig.activityCurve)
|
||||||
|
);
|
||||||
|
|
||||||
|
return clamp(activity * distanceAmount, 0, this.inputConfig.activitySoftCeiling);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const approach = (
|
||||||
|
current: number,
|
||||||
|
target: number,
|
||||||
|
elapsedSeconds: number,
|
||||||
|
timeConstantSeconds: number
|
||||||
|
): number => {
|
||||||
|
const amount = 1 - Math.exp(-elapsedSeconds / Math.max(0.001, timeConstantSeconds));
|
||||||
|
return current + (target - current) * amount;
|
||||||
|
};
|
||||||
|
|
||||||
const smoothstep = (edge0: number, edge1: number, value: number): number => {
|
const smoothstep = (edge0: number, edge1: number, value: number): number => {
|
||||||
const amount = clamp01((value - edge0) / (edge1 - edge0));
|
const amount = clamp01((value - edge0) / (edge1 - edge0));
|
||||||
return amount * amount * (3 - 2 * amount);
|
return amount * amount * (3 - 2 * amount);
|
||||||
|
|
|
||||||
92
src/audio/garden-audio-graph.test.ts
Normal file
92
src/audio/garden-audio-graph.test.ts
Normal file
|
|
@ -0,0 +1,92 @@
|
||||||
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||||
|
|
||||||
|
import { VIBE_PRESETS } from '../vibes';
|
||||||
|
import { gardenAudioConfig } from './garden-audio-config';
|
||||||
|
import { GardenAudioGraph } from './garden-audio-graph';
|
||||||
|
|
||||||
|
class FakeAudioParam {
|
||||||
|
public value = 0;
|
||||||
|
public setTargetAtTime = vi.fn();
|
||||||
|
}
|
||||||
|
|
||||||
|
class FakeAudioNode {
|
||||||
|
public readonly gain = new FakeAudioParam();
|
||||||
|
public readonly frequency = new FakeAudioParam();
|
||||||
|
public readonly threshold = new FakeAudioParam();
|
||||||
|
public readonly knee = new FakeAudioParam();
|
||||||
|
public readonly ratio = new FakeAudioParam();
|
||||||
|
public readonly attack = new FakeAudioParam();
|
||||||
|
public readonly release = new FakeAudioParam();
|
||||||
|
public readonly delayTime = new FakeAudioParam();
|
||||||
|
public readonly connections: Array<unknown> = [];
|
||||||
|
public type = '';
|
||||||
|
|
||||||
|
public connect(target: unknown): unknown {
|
||||||
|
this.connections.push(target);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FakeAudioBuffer {
|
||||||
|
private readonly data: Float32Array;
|
||||||
|
|
||||||
|
public constructor(length: number) {
|
||||||
|
this.data = new Float32Array(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getChannelData(): Float32Array {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FakeAudioContext {
|
||||||
|
public readonly currentTime = 1;
|
||||||
|
public readonly destination = new FakeAudioNode() as unknown as AudioDestinationNode;
|
||||||
|
public readonly sampleRate = 16;
|
||||||
|
public readonly state = 'running';
|
||||||
|
public readonly compressors: Array<FakeAudioNode> = [];
|
||||||
|
|
||||||
|
public createGain(): GainNode {
|
||||||
|
return new FakeAudioNode() as unknown as GainNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public createBiquadFilter(): BiquadFilterNode {
|
||||||
|
return new FakeAudioNode() as unknown as BiquadFilterNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public createDelay(): DelayNode {
|
||||||
|
return new FakeAudioNode() as unknown as DelayNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public createDynamicsCompressor(): DynamicsCompressorNode {
|
||||||
|
const node = new FakeAudioNode();
|
||||||
|
this.compressors.push(node);
|
||||||
|
return node as unknown as DynamicsCompressorNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public createBuffer(_channels: number, length: number): AudioBuffer {
|
||||||
|
return new FakeAudioBuffer(length) as unknown as AudioBuffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('GardenAudioGraph', () => {
|
||||||
|
afterEach(() => {
|
||||||
|
vi.unstubAllGlobals();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('builds controlled output, role buses, and delay automation', () => {
|
||||||
|
vi.stubGlobal('AudioContext', FakeAudioContext);
|
||||||
|
const graph = new GardenAudioGraph(gardenAudioConfig);
|
||||||
|
const context = graph.ensureContext(true) as unknown as FakeAudioContext;
|
||||||
|
|
||||||
|
expect(context.compressors).toHaveLength(1);
|
||||||
|
expect(graph.getPianoBus('pad')).not.toBeNull();
|
||||||
|
expect(graph.getPianoBus('pad')).not.toBe(graph.getPianoBus('gesture'));
|
||||||
|
expect(graph.noiseBus).not.toBeNull();
|
||||||
|
|
||||||
|
graph.updateDelay(VIBE_PRESETS[0].audio, 1);
|
||||||
|
|
||||||
|
expect(graph.getPianoBus('pad')?.gain.setTargetAtTime).toHaveBeenCalled();
|
||||||
|
expect(graph.getPianoBus('brush')?.gain.setTargetAtTime).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -1,16 +1,19 @@
|
||||||
import { clamp } from '../utils/clamp';
|
import { clamp } from '../utils/clamp';
|
||||||
import { GardenAudioConfig, GardenAudioVibeProfile } from './garden-audio-config';
|
import { GardenAudioConfig, GardenAudioVibeProfile } from './garden-audio-config';
|
||||||
|
import type { PianoNoteRole } from './garden-audio-types';
|
||||||
|
|
||||||
export class GardenAudioGraph {
|
export class GardenAudioGraph {
|
||||||
public context: AudioContext | null = null;
|
public context: AudioContext | null = null;
|
||||||
public eventBus: GainNode | null = null;
|
public eventBus: GainNode | null = null;
|
||||||
public delayInput: GainNode | null = null;
|
public delayInput: GainNode | null = null;
|
||||||
|
public noiseBus: GainNode | null = null;
|
||||||
public noiseBuffer: AudioBuffer | null = null;
|
public noiseBuffer: AudioBuffer | null = null;
|
||||||
|
|
||||||
private masterGain: GainNode | null = null;
|
private masterGain: GainNode | null = null;
|
||||||
private delayNode: DelayNode | null = null;
|
private delayNode: DelayNode | null = null;
|
||||||
private delayFeedback: GainNode | null = null;
|
private delayFeedback: GainNode | null = null;
|
||||||
private delayOutput: GainNode | null = null;
|
private delayOutput: GainNode | null = null;
|
||||||
|
private readonly pianoBuses = new Map<PianoNoteRole, GainNode>();
|
||||||
|
|
||||||
public constructor(private readonly config: GardenAudioConfig) {}
|
public constructor(private readonly config: GardenAudioConfig) {}
|
||||||
|
|
||||||
|
|
@ -30,19 +33,28 @@ export class GardenAudioGraph {
|
||||||
|
|
||||||
let context: AudioContext;
|
let context: AudioContext;
|
||||||
try {
|
try {
|
||||||
context = new AudioContextConstructor({ latencyHint: 'interactive' });
|
context = new AudioContextConstructor({
|
||||||
|
latencyHint: this.config.graph.latencyHint,
|
||||||
|
});
|
||||||
} catch {
|
} catch {
|
||||||
context = new AudioContextConstructor();
|
context = new AudioContextConstructor();
|
||||||
}
|
}
|
||||||
const masterGain = context.createGain();
|
const masterGain = context.createGain();
|
||||||
const highPass = context.createBiquadFilter();
|
const highPass = context.createBiquadFilter();
|
||||||
|
const compressor = context.createDynamicsCompressor();
|
||||||
|
|
||||||
masterGain.gain.value = 0;
|
masterGain.gain.value = 0;
|
||||||
highPass.type = 'highpass';
|
highPass.type = this.config.graph.outputFilterType;
|
||||||
highPass.frequency.value = this.config.highPassFrequencyHz;
|
highPass.frequency.value = this.config.highPassFrequencyHz;
|
||||||
|
compressor.threshold.value = this.config.graph.compressor.thresholdDb;
|
||||||
|
compressor.knee.value = this.config.graph.compressor.kneeDb;
|
||||||
|
compressor.ratio.value = this.config.graph.compressor.ratio;
|
||||||
|
compressor.attack.value = this.config.graph.compressor.attackSeconds;
|
||||||
|
compressor.release.value = this.config.graph.compressor.releaseSeconds;
|
||||||
|
|
||||||
masterGain.connect(highPass);
|
masterGain.connect(highPass);
|
||||||
highPass.connect(context.destination);
|
highPass.connect(compressor);
|
||||||
|
compressor.connect(context.destination);
|
||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.masterGain = masterGain;
|
this.masterGain = masterGain;
|
||||||
|
|
@ -65,7 +77,7 @@ export class GardenAudioGraph {
|
||||||
const source = this.context.createOscillator();
|
const source = this.context.createOscillator();
|
||||||
const gain = this.context.createGain();
|
const gain = this.context.createGain();
|
||||||
|
|
||||||
source.type = 'sine';
|
source.type = this.config.graph.unlockTickType;
|
||||||
source.frequency.setValueAtTime(this.config.graph.unlockTickFrequencyHz, now);
|
source.frequency.setValueAtTime(this.config.graph.unlockTickFrequencyHz, now);
|
||||||
gain.gain.setValueAtTime(this.config.piano.minGain, now);
|
gain.gain.setValueAtTime(this.config.piano.minGain, now);
|
||||||
gain.gain.exponentialRampToValueAtTime(
|
gain.gain.exponentialRampToValueAtTime(
|
||||||
|
|
@ -116,6 +128,7 @@ export class GardenAudioGraph {
|
||||||
}
|
}
|
||||||
|
|
||||||
const now = this.context.currentTime;
|
const now = this.context.currentTime;
|
||||||
|
const normalizedActivity = clamp(activity, 0, 1);
|
||||||
this.delayNode.delayTime.setTargetAtTime(
|
this.delayNode.delayTime.setTargetAtTime(
|
||||||
this.config.delay.timeSeconds * profile.delayTimeMultiplier,
|
this.config.delay.timeSeconds * profile.delayTimeMultiplier,
|
||||||
now,
|
now,
|
||||||
|
|
@ -123,7 +136,8 @@ export class GardenAudioGraph {
|
||||||
);
|
);
|
||||||
this.delayFeedback.gain.setTargetAtTime(
|
this.delayFeedback.gain.setTargetAtTime(
|
||||||
clamp(
|
clamp(
|
||||||
this.config.delay.feedback + activity * this.config.delay.activityFeedbackWeight,
|
this.config.delay.feedback +
|
||||||
|
normalizedActivity * this.config.delay.activityFeedbackWeight,
|
||||||
this.config.delay.feedbackMin,
|
this.config.delay.feedbackMin,
|
||||||
this.config.delay.feedbackMax
|
this.config.delay.feedbackMax
|
||||||
),
|
),
|
||||||
|
|
@ -133,10 +147,16 @@ export class GardenAudioGraph {
|
||||||
this.delayOutput.gain.setTargetAtTime(
|
this.delayOutput.gain.setTargetAtTime(
|
||||||
this.config.delay.wetGain *
|
this.config.delay.wetGain *
|
||||||
(this.config.delay.outputBase +
|
(this.config.delay.outputBase +
|
||||||
activity * this.config.delay.outputActivityWeight),
|
normalizedActivity * this.config.delay.outputActivityWeight) *
|
||||||
|
(1 - normalizedActivity * this.config.delay.outputActivityDuck),
|
||||||
now,
|
now,
|
||||||
this.config.updateRampSeconds
|
this.config.updateRampSeconds
|
||||||
);
|
);
|
||||||
|
this.updatePianoBusGains(normalizedActivity, now);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getPianoBus(role: PianoNoteRole | undefined): GainNode | null {
|
||||||
|
return this.pianoBuses.get(role ?? 'gesture') ?? this.eventBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async close(): Promise<void> {
|
public async close(): Promise<void> {
|
||||||
|
|
@ -165,15 +185,27 @@ export class GardenAudioGraph {
|
||||||
const delayNode = context.createDelay(this.config.graph.delayMaxSeconds);
|
const delayNode = context.createDelay(this.config.graph.delayMaxSeconds);
|
||||||
const delayFeedback = context.createGain();
|
const delayFeedback = context.createGain();
|
||||||
const delayOutput = context.createGain();
|
const delayOutput = context.createGain();
|
||||||
|
const feedbackHighPass = context.createBiquadFilter();
|
||||||
|
const feedbackLowPass = context.createBiquadFilter();
|
||||||
|
const returnLowPass = context.createBiquadFilter();
|
||||||
|
|
||||||
delayNode.delayTime.value = this.config.delay.timeSeconds;
|
delayNode.delayTime.value = this.config.delay.timeSeconds;
|
||||||
delayFeedback.gain.value = this.config.delay.feedback;
|
delayFeedback.gain.value = this.config.delay.feedback;
|
||||||
delayOutput.gain.value = this.config.delay.wetGain;
|
delayOutput.gain.value = this.config.delay.wetGain;
|
||||||
|
feedbackHighPass.type = 'highpass';
|
||||||
|
feedbackHighPass.frequency.value = this.config.delay.feedbackHighPassHz;
|
||||||
|
feedbackLowPass.type = 'lowpass';
|
||||||
|
feedbackLowPass.frequency.value = this.config.delay.feedbackLowPassHz;
|
||||||
|
returnLowPass.type = 'lowpass';
|
||||||
|
returnLowPass.frequency.value = this.config.delay.returnLowPassHz;
|
||||||
|
|
||||||
delayInput.connect(delayNode);
|
delayInput.connect(delayNode);
|
||||||
delayNode.connect(delayFeedback);
|
delayNode.connect(feedbackHighPass);
|
||||||
|
feedbackHighPass.connect(feedbackLowPass);
|
||||||
|
feedbackLowPass.connect(delayFeedback);
|
||||||
delayFeedback.connect(delayNode);
|
delayFeedback.connect(delayNode);
|
||||||
delayNode.connect(delayOutput);
|
delayNode.connect(returnLowPass);
|
||||||
|
returnLowPass.connect(delayOutput);
|
||||||
delayOutput.connect(masterGain);
|
delayOutput.connect(masterGain);
|
||||||
|
|
||||||
this.delayInput = delayInput;
|
this.delayInput = delayInput;
|
||||||
|
|
@ -183,13 +215,50 @@ export class GardenAudioGraph {
|
||||||
}
|
}
|
||||||
|
|
||||||
private createBuses(context: AudioContext, masterGain: GainNode): void {
|
private createBuses(context: AudioContext, masterGain: GainNode): void {
|
||||||
this.eventBus = context.createGain();
|
const eventBus = context.createGain();
|
||||||
this.eventBus.gain.value = this.config.graph.eventBusGain;
|
eventBus.gain.value = this.config.graph.eventBusGain;
|
||||||
this.eventBus.connect(masterGain);
|
eventBus.connect(masterGain);
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
this.pianoBuses.clear();
|
||||||
|
|
||||||
|
(Object.keys(this.config.graph.pianoBusGains) as Array<PianoNoteRole>).forEach(
|
||||||
|
(role) => {
|
||||||
|
const bus = context.createGain();
|
||||||
|
bus.gain.value = this.config.graph.pianoBusGains[role];
|
||||||
|
bus.connect(eventBus);
|
||||||
|
this.pianoBuses.set(role, bus);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.noiseBus = context.createGain();
|
||||||
|
this.noiseBus.gain.value = this.config.graph.noiseBusGain;
|
||||||
|
this.noiseBus.connect(eventBus);
|
||||||
|
}
|
||||||
|
|
||||||
|
private updatePianoBusGains(activity: number, now: number): void {
|
||||||
|
this.pianoBuses.forEach((bus, role) => {
|
||||||
|
const baseGain = this.config.graph.pianoBusGains[role];
|
||||||
|
const ducking = this.config.graph.pianoBusActivityDucking[role];
|
||||||
|
bus.gain.setTargetAtTime(
|
||||||
|
Math.max(0, baseGain * (1 - activity * ducking)),
|
||||||
|
now,
|
||||||
|
this.config.updateRampSeconds
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private createNoiseBuffer(context: AudioContext): AudioBuffer {
|
private createNoiseBuffer(context: AudioContext): AudioBuffer {
|
||||||
const buffer = context.createBuffer(1, context.sampleRate, context.sampleRate);
|
const buffer = context.createBuffer(
|
||||||
|
appPositiveInteger(this.config.graph.noiseBufferChannels),
|
||||||
|
Math.max(
|
||||||
|
1,
|
||||||
|
Math.floor(
|
||||||
|
context.sampleRate *
|
||||||
|
Math.max(0.001, this.config.graph.noiseBufferDurationSeconds)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
context.sampleRate
|
||||||
|
);
|
||||||
const data = buffer.getChannelData(0);
|
const data = buffer.getChannelData(0);
|
||||||
|
|
||||||
for (let index = 0; index < data.length; index++) {
|
for (let index = 0; index < data.length; index++) {
|
||||||
|
|
@ -205,10 +274,15 @@ export class GardenAudioGraph {
|
||||||
this.context = null;
|
this.context = null;
|
||||||
this.eventBus = null;
|
this.eventBus = null;
|
||||||
this.delayInput = null;
|
this.delayInput = null;
|
||||||
|
this.noiseBus = null;
|
||||||
this.noiseBuffer = null;
|
this.noiseBuffer = null;
|
||||||
this.masterGain = null;
|
this.masterGain = null;
|
||||||
this.delayNode = null;
|
this.delayNode = null;
|
||||||
this.delayFeedback = null;
|
this.delayFeedback = null;
|
||||||
this.delayOutput = null;
|
this.delayOutput = null;
|
||||||
|
this.pianoBuses.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const appPositiveInteger = (value: number): number =>
|
||||||
|
Math.max(1, Math.floor(Number.isFinite(value) ? value : 1));
|
||||||
|
|
|
||||||
52
src/audio/garden-audio-input.test.ts
Normal file
52
src/audio/garden-audio-input.test.ts
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
|
import { gardenAudioConfig } from './garden-audio-config';
|
||||||
|
import { getStrokeMetrics } from './garden-audio-input';
|
||||||
|
|
||||||
|
describe('getStrokeMetrics', () => {
|
||||||
|
it('normalizes stroke distance against canvas size', () => {
|
||||||
|
const standardDensity = getStrokeMetrics(
|
||||||
|
{
|
||||||
|
vibe: {} as never,
|
||||||
|
from: [0, 0],
|
||||||
|
to: [100, 0],
|
||||||
|
canvasSize: [1000, 500],
|
||||||
|
elapsedSeconds: 0.1,
|
||||||
|
isErasing: false,
|
||||||
|
},
|
||||||
|
gardenAudioConfig.input
|
||||||
|
);
|
||||||
|
const highDensity = getStrokeMetrics(
|
||||||
|
{
|
||||||
|
vibe: {} as never,
|
||||||
|
from: [0, 0],
|
||||||
|
to: [200, 0],
|
||||||
|
canvasSize: [2000, 1000],
|
||||||
|
elapsedSeconds: 0.1,
|
||||||
|
isErasing: false,
|
||||||
|
},
|
||||||
|
gardenAudioConfig.input
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(highDensity.normalizedDistance).toBeCloseTo(
|
||||||
|
standardDensity.normalizedDistance
|
||||||
|
);
|
||||||
|
expect(highDensity.normalizedSpeed).toBeCloseTo(standardDensity.normalizedSpeed);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('uses configured elapsed-time floors for missing or invalid samples', () => {
|
||||||
|
const metrics = getStrokeMetrics(
|
||||||
|
{
|
||||||
|
vibe: {} as never,
|
||||||
|
from: [0, 0],
|
||||||
|
to: [10, 0],
|
||||||
|
elapsedSeconds: 0,
|
||||||
|
isErasing: false,
|
||||||
|
},
|
||||||
|
gardenAudioConfig.input
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(metrics.elapsedSeconds).toBe(gardenAudioConfig.input.fallbackFrameSeconds);
|
||||||
|
expect(Number.isFinite(metrics.normalizedSpeed)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -4,6 +4,8 @@ import type { GardenAudioStroke } from './garden-audio-types';
|
||||||
export interface GardenAudioStrokeMetrics {
|
export interface GardenAudioStrokeMetrics {
|
||||||
distancePixels: number;
|
distancePixels: number;
|
||||||
elapsedSeconds: number;
|
elapsedSeconds: number;
|
||||||
|
normalizedDistance: number;
|
||||||
|
normalizedSpeed: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getStrokeMetrics = (
|
export const getStrokeMetrics = (
|
||||||
|
|
@ -12,10 +14,16 @@ export const getStrokeMetrics = (
|
||||||
): GardenAudioStrokeMetrics => {
|
): GardenAudioStrokeMetrics => {
|
||||||
const dx = stroke.to[0] - stroke.from[0];
|
const dx = stroke.to[0] - stroke.from[0];
|
||||||
const dy = stroke.to[1] - stroke.from[1];
|
const dy = stroke.to[1] - stroke.from[1];
|
||||||
|
const distancePixels = Math.hypot(dx, dy);
|
||||||
|
const elapsedSeconds = getElapsedSeconds(stroke, inputConfig);
|
||||||
|
const normalizedDistance =
|
||||||
|
distancePixels / getStrokeNormalizationPixels(stroke, inputConfig);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
distancePixels: Math.hypot(dx, dy),
|
distancePixels,
|
||||||
elapsedSeconds: getElapsedSeconds(stroke, inputConfig),
|
elapsedSeconds,
|
||||||
|
normalizedDistance,
|
||||||
|
normalizedSpeed: normalizedDistance / elapsedSeconds,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -28,8 +36,28 @@ const getElapsedSeconds = (
|
||||||
Number.isFinite(stroke.elapsedSeconds) &&
|
Number.isFinite(stroke.elapsedSeconds) &&
|
||||||
stroke.elapsedSeconds > 0
|
stroke.elapsedSeconds > 0
|
||||||
) {
|
) {
|
||||||
return Math.max(0.001, stroke.elapsedSeconds);
|
return Math.max(inputConfig.minElapsedSeconds, stroke.elapsedSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputConfig.fallbackFrameSeconds;
|
return inputConfig.fallbackFrameSeconds;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getStrokeNormalizationPixels = (
|
||||||
|
stroke: GardenAudioStroke,
|
||||||
|
inputConfig: GardenAudioConfig['input']
|
||||||
|
): number => {
|
||||||
|
const width = stroke.canvasSize?.[0];
|
||||||
|
const height = stroke.canvasSize?.[1];
|
||||||
|
if (
|
||||||
|
width !== undefined &&
|
||||||
|
height !== undefined &&
|
||||||
|
Number.isFinite(width) &&
|
||||||
|
Number.isFinite(height) &&
|
||||||
|
width > 0 &&
|
||||||
|
height > 0
|
||||||
|
) {
|
||||||
|
return Math.max(1, Math.min(width, height));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.max(1, inputConfig.distanceWindowForFullActivityPixels);
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
import { VibePreset } from '../vibes';
|
import { VibePreset } from '../vibes';
|
||||||
import { GardenAudioChord, GardenAudioVibeProfile } from './garden-audio-config';
|
import {
|
||||||
|
GardenAudioChord,
|
||||||
|
gardenAudioConfig,
|
||||||
|
GardenAudioVibeProfile,
|
||||||
|
} from './garden-audio-config';
|
||||||
|
|
||||||
export const getVibeProfile = (vibe: VibePreset): GardenAudioVibeProfile => vibe.audio;
|
export const getVibeProfile = (vibe: VibePreset): GardenAudioVibeProfile => vibe.audio;
|
||||||
|
|
||||||
|
|
@ -8,10 +12,14 @@ export const getChordIntervals = (
|
||||||
openVoicing: boolean
|
openVoicing: boolean
|
||||||
): Array<number> => {
|
): Array<number> => {
|
||||||
if (openVoicing) {
|
if (openVoicing) {
|
||||||
return chord.quality === 'major' ? [0, 7, 12, 16] : [0, 7, 12, 15];
|
return chord.quality === 'major'
|
||||||
|
? gardenAudioConfig.generativePiano.chordVoicings.majorOpen
|
||||||
|
: gardenAudioConfig.generativePiano.chordVoicings.minorOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
return chord.quality === 'major' ? [0, 4, 7, 12, 16] : [0, 3, 7, 12, 15];
|
return chord.quality === 'major'
|
||||||
|
? gardenAudioConfig.generativePiano.chordVoicings.majorClosed
|
||||||
|
: gardenAudioConfig.generativePiano.chordVoicings.minorClosed;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const degreeToSemitone = (
|
export const degreeToSemitone = (
|
||||||
|
|
@ -21,5 +29,7 @@ export const degreeToSemitone = (
|
||||||
const scaleIndex =
|
const scaleIndex =
|
||||||
((degree % profile.scale.length) + profile.scale.length) % profile.scale.length;
|
((degree % profile.scale.length) + profile.scale.length) % profile.scale.length;
|
||||||
const octave = Math.floor(degree / profile.scale.length);
|
const octave = Math.floor(degree / profile.scale.length);
|
||||||
return profile.scale[scaleIndex] + octave * 12;
|
return (
|
||||||
|
profile.scale[scaleIndex] + octave * gardenAudioConfig.piano.pitchSemitonesPerOctave
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ export interface GardenAudioStroke {
|
||||||
vibe: VibePreset;
|
vibe: VibePreset;
|
||||||
from: ArrayLike<number>;
|
from: ArrayLike<number>;
|
||||||
to: ArrayLike<number>;
|
to: ArrayLike<number>;
|
||||||
|
canvasSize?: ArrayLike<number>;
|
||||||
isErasing: boolean;
|
isErasing: boolean;
|
||||||
elapsedSeconds?: number;
|
elapsedSeconds?: number;
|
||||||
}
|
}
|
||||||
|
|
@ -34,10 +35,19 @@ export interface PianoNote {
|
||||||
startTime: number;
|
startTime: number;
|
||||||
durationSeconds: number;
|
durationSeconds: number;
|
||||||
pan: number;
|
pan: number;
|
||||||
|
role?: PianoNoteRole;
|
||||||
delaySend?: number;
|
delaySend?: number;
|
||||||
lowpassHz?: number;
|
lowpassHz?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PianoNoteRole =
|
||||||
|
| 'pad'
|
||||||
|
| 'support'
|
||||||
|
| 'texture'
|
||||||
|
| 'gesture'
|
||||||
|
| 'brush'
|
||||||
|
| 'stinger';
|
||||||
|
|
||||||
export interface NoiseBurst {
|
export interface NoiseBurst {
|
||||||
startTime: number;
|
startTime: number;
|
||||||
durationSeconds: number;
|
durationSeconds: number;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ const calls = {
|
||||||
resumed: 0,
|
resumed: 0,
|
||||||
sourcesStarted: 0,
|
sourcesStarted: 0,
|
||||||
sources: [] as Array<FakeScheduledSourceNode>,
|
sources: [] as Array<FakeScheduledSourceNode>,
|
||||||
|
gains: [] as Array<FakeAudioNode>,
|
||||||
};
|
};
|
||||||
|
|
||||||
let contextState: AudioContextState = 'suspended';
|
let contextState: AudioContextState = 'suspended';
|
||||||
|
|
@ -80,7 +81,9 @@ class FakeAudioContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
public createGain(): GainNode {
|
public createGain(): GainNode {
|
||||||
return new FakeAudioNode() as unknown as GainNode;
|
const node = new FakeAudioNode();
|
||||||
|
calls.gains.push(node);
|
||||||
|
return node as unknown as GainNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public createBiquadFilter(): BiquadFilterNode {
|
public createBiquadFilter(): BiquadFilterNode {
|
||||||
|
|
@ -91,6 +94,10 @@ class FakeAudioContext {
|
||||||
return new FakeAudioNode() as unknown as DelayNode;
|
return new FakeAudioNode() as unknown as DelayNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public createDynamicsCompressor(): DynamicsCompressorNode {
|
||||||
|
return new FakeAudioNode() as unknown as DynamicsCompressorNode;
|
||||||
|
}
|
||||||
|
|
||||||
public createStereoPanner(): StereoPannerNode {
|
public createStereoPanner(): StereoPannerNode {
|
||||||
return new FakeAudioNode() as unknown as StereoPannerNode;
|
return new FakeAudioNode() as unknown as StereoPannerNode;
|
||||||
}
|
}
|
||||||
|
|
@ -151,6 +158,7 @@ describe('GardenAudio startup policy', () => {
|
||||||
calls.resumed = 0;
|
calls.resumed = 0;
|
||||||
calls.sourcesStarted = 0;
|
calls.sourcesStarted = 0;
|
||||||
calls.sources = [];
|
calls.sources = [];
|
||||||
|
calls.gains = [];
|
||||||
contextState = 'suspended';
|
contextState = 'suspended';
|
||||||
resumeError = null;
|
resumeError = null;
|
||||||
vi.stubGlobal('AudioContext', FakeAudioContext);
|
vi.stubGlobal('AudioContext', FakeAudioContext);
|
||||||
|
|
@ -210,6 +218,40 @@ describe('GardenAudio startup policy', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('updates live master gain from adjustable volume', () => {
|
||||||
|
const config = makeConfig();
|
||||||
|
const audio = new GardenAudio(config);
|
||||||
|
const vibe = VIBE_PRESETS[0];
|
||||||
|
|
||||||
|
audio.start(vibe, { userGesture: true });
|
||||||
|
const masterGain = calls.gains[0]?.gain;
|
||||||
|
if (!masterGain) {
|
||||||
|
throw new Error('Missing fake master gain');
|
||||||
|
}
|
||||||
|
|
||||||
|
audio.setMasterVolume(0.2);
|
||||||
|
|
||||||
|
expect(masterGain.setTargetAtTime).toHaveBeenLastCalledWith(
|
||||||
|
0.2,
|
||||||
|
1,
|
||||||
|
config.updateRampSeconds
|
||||||
|
);
|
||||||
|
|
||||||
|
audio.setMuted(true);
|
||||||
|
const mutedCallCount = masterGain.setTargetAtTime.mock.calls.length;
|
||||||
|
audio.setMasterVolume(0.8);
|
||||||
|
|
||||||
|
expect(masterGain.setTargetAtTime).toHaveBeenCalledTimes(mutedCallCount);
|
||||||
|
|
||||||
|
audio.setMuted(false);
|
||||||
|
|
||||||
|
expect(masterGain.setTargetAtTime).toHaveBeenLastCalledWith(
|
||||||
|
0.8,
|
||||||
|
1,
|
||||||
|
config.fadeInSeconds
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('stays silent without piano samples while preserving eraser noise', () => {
|
it('stays silent without piano samples while preserving eraser noise', () => {
|
||||||
const audio = new GardenAudio(makeConfig());
|
const audio = new GardenAudio(makeConfig());
|
||||||
const vibe = VIBE_PRESETS[0];
|
const vibe = VIBE_PRESETS[0];
|
||||||
|
|
|
||||||
|
|
@ -34,12 +34,14 @@ export class GardenAudio {
|
||||||
private hasStarted = false;
|
private hasStarted = false;
|
||||||
private isDestroyed = false;
|
private isDestroyed = false;
|
||||||
private isMuted = false;
|
private isMuted = false;
|
||||||
|
private masterVolume: number;
|
||||||
private isGestureActive = false;
|
private isGestureActive = false;
|
||||||
private hasQueuedPianoLoad = false;
|
private hasQueuedPianoLoad = false;
|
||||||
private lastEraserAt = Number.NEGATIVE_INFINITY;
|
private lastEraserAt = Number.NEGATIVE_INFINITY;
|
||||||
private lastVibeStingerAt = Number.NEGATIVE_INFINITY;
|
private lastVibeStingerAt = Number.NEGATIVE_INFINITY;
|
||||||
|
|
||||||
public constructor(private readonly config: GardenAudioConfig) {
|
public constructor(private readonly config: GardenAudioConfig) {
|
||||||
|
this.masterVolume = clamp01(config.masterVolume);
|
||||||
this.graph = new GardenAudioGraph(config);
|
this.graph = new GardenAudioGraph(config);
|
||||||
this.piano = new PianoSampler(config, this.graph);
|
this.piano = new PianoSampler(config, this.graph);
|
||||||
this.noise = new NoiseBurstPlayer(config, this.graph);
|
this.noise = new NoiseBurstPlayer(config, this.graph);
|
||||||
|
|
@ -81,7 +83,7 @@ export class GardenAudio {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (this.graph.context === context && !this.isDestroyed && !this.isMuted) {
|
if (this.graph.context === context && !this.isDestroyed && !this.isMuted) {
|
||||||
this.graph.unlock();
|
this.graph.unlock();
|
||||||
this.graph.setMasterGain(this.config.masterVolume, startupRampSeconds);
|
this.graph.setMasterGain(this.masterVolume, startupRampSeconds);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|
@ -95,7 +97,7 @@ export class GardenAudio {
|
||||||
this.hasStarted = true;
|
this.hasStarted = true;
|
||||||
this.applyVibe(vibe);
|
this.applyVibe(vibe);
|
||||||
this.pianoEngine.prime(context.currentTime);
|
this.pianoEngine.prime(context.currentTime);
|
||||||
this.graph.setMasterGain(this.config.masterVolume, startupRampSeconds);
|
this.graph.setMasterGain(this.masterVolume, startupRampSeconds);
|
||||||
|
|
||||||
if (!this.hasQueuedPianoLoad) {
|
if (!this.hasQueuedPianoLoad) {
|
||||||
this.hasQueuedPianoLoad = true;
|
this.hasQueuedPianoLoad = true;
|
||||||
|
|
@ -132,13 +134,24 @@ export class GardenAudio {
|
||||||
}
|
}
|
||||||
|
|
||||||
public setMuted(isMuted: boolean): void {
|
public setMuted(isMuted: boolean): void {
|
||||||
|
if (this.isMuted === isMuted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.isMuted = isMuted;
|
this.isMuted = isMuted;
|
||||||
this.graph.setMasterGain(
|
this.graph.setMasterGain(
|
||||||
isMuted ? this.config.muteGain : this.config.masterVolume,
|
isMuted ? this.config.muteGain : this.masterVolume,
|
||||||
isMuted ? this.config.muteRampSeconds : this.config.fadeInSeconds
|
isMuted ? this.config.muteRampSeconds : this.config.fadeInSeconds
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setMasterVolume(masterVolume: number): void {
|
||||||
|
this.masterVolume = clamp01(masterVolume);
|
||||||
|
if (!this.isMuted) {
|
||||||
|
this.graph.setMasterGain(this.masterVolume, this.config.updateRampSeconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public beginGesture(): void {
|
public beginGesture(): void {
|
||||||
const context = this.graph.context;
|
const context = this.graph.context;
|
||||||
if (!context) {
|
if (!context) {
|
||||||
|
|
@ -174,7 +187,9 @@ export class GardenAudio {
|
||||||
this.pianoEngine.renderLookahead({
|
this.pianoEngine.renderLookahead({
|
||||||
vibe: snapshot.vibe,
|
vibe: snapshot.vibe,
|
||||||
now: context.currentTime,
|
now: context.currentTime,
|
||||||
activity: snapshot.isErasing ? 0 : this.energy.getLevel(),
|
activity: snapshot.isErasing
|
||||||
|
? this.config.eraser.pianoActivity
|
||||||
|
: this.energy.getLevel(),
|
||||||
});
|
});
|
||||||
this.updateDelay(snapshot);
|
this.updateDelay(snapshot);
|
||||||
}
|
}
|
||||||
|
|
@ -267,7 +282,7 @@ export class GardenAudio {
|
||||||
durationSeconds: this.config.eraser.durationSeconds,
|
durationSeconds: this.config.eraser.durationSeconds,
|
||||||
gain: this.config.eraser.noiseGain * distanceActivity,
|
gain: this.config.eraser.noiseGain * distanceActivity,
|
||||||
filterHz,
|
filterHz,
|
||||||
pan: 0,
|
pan: this.config.eraser.pan,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,14 @@ const countNotesBetween = (
|
||||||
notes.filter((note) => note.startTime >= startSeconds && note.startTime < endSeconds)
|
notes.filter((note) => note.startTime >= startSeconds && note.startTime < endSeconds)
|
||||||
.length;
|
.length;
|
||||||
|
|
||||||
|
const getNoteKey = (note: PianoNote): string =>
|
||||||
|
[
|
||||||
|
note.startTime.toFixed(3),
|
||||||
|
note.midi,
|
||||||
|
note.role ?? 'none',
|
||||||
|
note.pan.toFixed(3),
|
||||||
|
].join(':');
|
||||||
|
|
||||||
describe('GenerativePianoEngine', () => {
|
describe('GenerativePianoEngine', () => {
|
||||||
it('plays quiet background music even when the garden is idle', () => {
|
it('plays quiet background music even when the garden is idle', () => {
|
||||||
const { engine, notes } = makeEngine();
|
const { engine, notes } = makeEngine();
|
||||||
|
|
@ -187,4 +195,55 @@ describe('GenerativePianoEngine', () => {
|
||||||
|
|
||||||
expect(second.notes).toEqual(first.notes);
|
expect(second.notes).toEqual(first.notes);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not duplicate notes across overlapping lookahead windows', () => {
|
||||||
|
const { engine, notes } = makeEngine();
|
||||||
|
|
||||||
|
engine.renderLookahead({
|
||||||
|
vibe: VIBE_PRESETS[0],
|
||||||
|
now: 0,
|
||||||
|
activity: 0.72,
|
||||||
|
lookaheadSeconds: getBeatSeconds() * 2,
|
||||||
|
});
|
||||||
|
engine.renderLookahead({
|
||||||
|
vibe: VIBE_PRESETS[0],
|
||||||
|
now: getBeatSeconds() * 0.5,
|
||||||
|
activity: 0.72,
|
||||||
|
lookaheadSeconds: getBeatSeconds() * 2,
|
||||||
|
});
|
||||||
|
|
||||||
|
const noteKeys = notes.map(getNoteKey);
|
||||||
|
expect(new Set(noteKeys).size).toBe(noteKeys.length);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps generated notes inside the audio contract', () => {
|
||||||
|
const { engine, notes } = makeEngine();
|
||||||
|
|
||||||
|
VIBE_PRESETS.forEach((vibe) => {
|
||||||
|
engine.cue(0);
|
||||||
|
engine.renderLookahead({
|
||||||
|
vibe,
|
||||||
|
now: 0,
|
||||||
|
activity: 1,
|
||||||
|
lookaheadSeconds: getBeatSeconds() * getBeatsPerBar() * 4,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
notes.forEach((note) => {
|
||||||
|
expect(Number.isFinite(note.startTime)).toBe(true);
|
||||||
|
expect(note.midi).toBeGreaterThanOrEqual(21);
|
||||||
|
expect(note.midi).toBeLessThanOrEqual(108);
|
||||||
|
expect(note.velocity).toBeGreaterThan(0);
|
||||||
|
expect(note.velocity).toBeLessThanOrEqual(0.4);
|
||||||
|
expect(note.pan).toBeGreaterThanOrEqual(-1);
|
||||||
|
expect(note.pan).toBeLessThanOrEqual(1);
|
||||||
|
expect(note.durationSeconds).toBeGreaterThan(0);
|
||||||
|
expect(note.lowpassHz ?? gardenAudioConfig.piano.lowpassHz).toBeGreaterThanOrEqual(
|
||||||
|
gardenAudioConfig.piano.lowpassMinHz
|
||||||
|
);
|
||||||
|
expect(note.lowpassHz ?? gardenAudioConfig.piano.lowpassHz).toBeLessThanOrEqual(
|
||||||
|
gardenAudioConfig.piano.lowpassMaxHz
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -9,8 +9,9 @@ export class NoiseBurstPlayer {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public play({ startTime, durationSeconds, gain, filterHz, pan }: NoiseBurst): void {
|
public play({ startTime, durationSeconds, gain, filterHz, pan }: NoiseBurst): void {
|
||||||
const { context, eventBus, noiseBuffer } = this.graph;
|
const { context, eventBus, noiseBus, noiseBuffer } = this.graph;
|
||||||
if (!context || !eventBus || !noiseBuffer) {
|
const outputBus = noiseBus ?? eventBus;
|
||||||
|
if (!context || !outputBus || !noiseBuffer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,7 +26,7 @@ export class NoiseBurstPlayer {
|
||||||
const stopAt = scheduledStart + durationSeconds;
|
const stopAt = scheduledStart + durationSeconds;
|
||||||
|
|
||||||
source.buffer = noiseBuffer;
|
source.buffer = noiseBuffer;
|
||||||
filter.type = 'bandpass';
|
filter.type = this.config.noiseBurst.filterType;
|
||||||
filter.frequency.setValueAtTime(filterHz, scheduledStart);
|
filter.frequency.setValueAtTime(filterHz, scheduledStart);
|
||||||
filter.Q.value = this.config.noiseBurst.filterQ;
|
filter.Q.value = this.config.noiseBurst.filterQ;
|
||||||
envelope.gain.setValueAtTime(this.config.noiseBurst.silentGain, scheduledStart);
|
envelope.gain.setValueAtTime(this.config.noiseBurst.silentGain, scheduledStart);
|
||||||
|
|
@ -39,7 +40,7 @@ export class NoiseBurstPlayer {
|
||||||
source.connect(filter);
|
source.connect(filter);
|
||||||
filter.connect(envelope);
|
filter.connect(envelope);
|
||||||
envelope.connect(panner);
|
envelope.connect(panner);
|
||||||
panner.connect(eventBus);
|
panner.connect(outputBus);
|
||||||
source.start(
|
source.start(
|
||||||
scheduledStart,
|
scheduledStart,
|
||||||
Math.random() * this.config.noiseBurst.offsetRandomSeconds
|
Math.random() * this.config.noiseBurst.offsetRandomSeconds
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ const makeSampler = async (context: AudioContext): Promise<PianoSampler> => {
|
||||||
context,
|
context,
|
||||||
delayInput: null,
|
delayInput: null,
|
||||||
eventBus,
|
eventBus,
|
||||||
|
getPianoBus: vi.fn(() => eventBus),
|
||||||
} as unknown as GardenAudioGraph;
|
} as unknown as GardenAudioGraph;
|
||||||
|
|
||||||
return new PianoSampler(gardenAudioConfig, graph);
|
return new PianoSampler(gardenAudioConfig, graph);
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,12 @@ export class PianoSampler {
|
||||||
startTime,
|
startTime,
|
||||||
durationSeconds,
|
durationSeconds,
|
||||||
pan,
|
pan,
|
||||||
|
role,
|
||||||
delaySend = 0,
|
delaySend = 0,
|
||||||
lowpassHz = this.config.piano.lowpassHz,
|
lowpassHz = this.config.piano.lowpassHz,
|
||||||
}: PianoNote): void {
|
}: PianoNote): void {
|
||||||
const { context, eventBus, delayInput } = this.graph;
|
const { context, delayInput } = this.graph;
|
||||||
|
const eventBus = this.graph.getPianoBus(role);
|
||||||
if (!context || !eventBus) {
|
if (!context || !eventBus) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +90,7 @@ export class PianoSampler {
|
||||||
Math.pow(2, (midi - sample.midi) / this.config.piano.pitchSemitonesPerOctave),
|
Math.pow(2, (midi - sample.midi) / this.config.piano.pitchSemitonesPerOctave),
|
||||||
scheduledStart
|
scheduledStart
|
||||||
);
|
);
|
||||||
filter.type = 'lowpass';
|
filter.type = this.config.piano.filterType;
|
||||||
filter.frequency.setValueAtTime(
|
filter.frequency.setValueAtTime(
|
||||||
clamp(lowpassHz, this.config.piano.lowpassMinHz, this.config.piano.lowpassMaxHz),
|
clamp(lowpassHz, this.config.piano.lowpassMinHz, this.config.piano.lowpassMaxHz),
|
||||||
scheduledStart
|
scheduledStart
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { gardenAudioConfig } from './garden-audio-config';
|
||||||
import type { LoadedPianoSample } from './garden-audio-types';
|
import type { LoadedPianoSample } from './garden-audio-types';
|
||||||
|
|
||||||
interface PianoSampleDefinition {
|
interface PianoSampleDefinition {
|
||||||
|
|
@ -11,8 +12,6 @@ export interface PianoSampleLoadProgress {
|
||||||
sample?: PianoSampleDefinition;
|
sample?: PianoSampleDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sampleBaseUrl = `${import.meta.env.BASE_URL}audio/piano/`;
|
|
||||||
|
|
||||||
const sampleFiles: Array<[fileName: string, midi: number]> = [
|
const sampleFiles: Array<[fileName: string, midi: number]> = [
|
||||||
['A0v12.m4a', 21],
|
['A0v12.m4a', 21],
|
||||||
['C1v12.m4a', 24],
|
['C1v12.m4a', 24],
|
||||||
|
|
@ -49,7 +48,7 @@ const sampleFiles: Array<[fileName: string, midi: number]> = [
|
||||||
const pianoSampleDefinitions: Array<PianoSampleDefinition> = sampleFiles
|
const pianoSampleDefinitions: Array<PianoSampleDefinition> = sampleFiles
|
||||||
.map(([fileName, midi]) => ({
|
.map(([fileName, midi]) => ({
|
||||||
midi,
|
midi,
|
||||||
url: `${sampleBaseUrl}${fileName}`,
|
url: `${gardenAudioConfig.piano.sampleBaseUrl}${fileName}`,
|
||||||
}))
|
}))
|
||||||
.sort((a, b) => a.midi - b.midi);
|
.sort((a, b) => a.midi - b.midi);
|
||||||
|
|
||||||
|
|
@ -68,7 +67,11 @@ export const preloadPianoSamples = (
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const decodeContext = new OfflineAudioContextConstructor(1, 1, 44_100);
|
const decodeContext = new OfflineAudioContextConstructor(
|
||||||
|
gardenAudioConfig.piano.preloadDecode.channels,
|
||||||
|
gardenAudioConfig.piano.preloadDecode.frames,
|
||||||
|
gardenAudioConfig.piano.preloadDecode.sampleRateHz
|
||||||
|
);
|
||||||
return loadPianoSamples(decodeContext, onProgress);
|
return loadPianoSamples(decodeContext, onProgress);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
280
src/config.ts
280
src/config.ts
|
|
@ -3,6 +3,8 @@ import { runtimeControls } from './config/runtime-controls';
|
||||||
import type { GardenAppConfig } from './config/types';
|
import type { GardenAppConfig } from './config/types';
|
||||||
import { defaultVibeId, vibePresets } from './config/vibe-presets';
|
import { defaultVibeId, vibePresets } from './config/vibe-presets';
|
||||||
|
|
||||||
|
const defaultAudioMasterVolume = 0.42;
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
GardenAppConfig,
|
GardenAppConfig,
|
||||||
GardenRuntimeSettings,
|
GardenRuntimeSettings,
|
||||||
|
|
@ -12,7 +14,7 @@ export type {
|
||||||
|
|
||||||
export const appConfig = {
|
export const appConfig = {
|
||||||
audio: {
|
audio: {
|
||||||
masterVolume: 0.42,
|
masterVolume: defaultAudioMasterVolume,
|
||||||
fadeInSeconds: 0.45,
|
fadeInSeconds: 0.45,
|
||||||
updateRampSeconds: 0.08,
|
updateRampSeconds: 0.08,
|
||||||
highPassFrequencyHz: 45,
|
highPassFrequencyHz: 45,
|
||||||
|
|
@ -26,10 +28,15 @@ export const appConfig = {
|
||||||
feedbackMin: 0.04,
|
feedbackMin: 0.04,
|
||||||
outputActivityWeight: 0.5,
|
outputActivityWeight: 0.5,
|
||||||
outputBase: 0.65,
|
outputBase: 0.65,
|
||||||
|
outputActivityDuck: 0.28,
|
||||||
timeRampSeconds: 0.12,
|
timeRampSeconds: 0.12,
|
||||||
|
feedbackHighPassHz: 180,
|
||||||
|
feedbackLowPassHz: 5200,
|
||||||
|
returnLowPassHz: 6200,
|
||||||
},
|
},
|
||||||
piano: {
|
piano: {
|
||||||
maxVoices: 24,
|
maxVoices: 24,
|
||||||
|
filterType: 'lowpass',
|
||||||
gain: 0.48,
|
gain: 0.48,
|
||||||
sustainSeconds: 0.42,
|
sustainSeconds: 0.42,
|
||||||
sustainLevel: 0.32,
|
sustainLevel: 0.32,
|
||||||
|
|
@ -49,6 +56,12 @@ export const appConfig = {
|
||||||
tailStopExtraSeconds: 0.05,
|
tailStopExtraSeconds: 0.05,
|
||||||
voiceStealFadeSeconds: 0.025,
|
voiceStealFadeSeconds: 0.025,
|
||||||
voiceStealStopSeconds: 0.05,
|
voiceStealStopSeconds: 0.05,
|
||||||
|
sampleBaseUrl: `${import.meta.env.BASE_URL}audio/piano/`,
|
||||||
|
preloadDecode: {
|
||||||
|
channels: 1,
|
||||||
|
frames: 1,
|
||||||
|
sampleRateHz: 44_100,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rhythm: {
|
rhythm: {
|
||||||
bpm: 74,
|
bpm: 74,
|
||||||
|
|
@ -63,6 +76,8 @@ export const appConfig = {
|
||||||
filterMinHz: 650,
|
filterMinHz: 650,
|
||||||
filterMaxHz: 3600,
|
filterMaxHz: 3600,
|
||||||
durationSeconds: 0.08,
|
durationSeconds: 0.08,
|
||||||
|
pan: 0,
|
||||||
|
pianoActivity: 0,
|
||||||
},
|
},
|
||||||
energy: {
|
energy: {
|
||||||
attackSeconds: 0.08,
|
attackSeconds: 0.08,
|
||||||
|
|
@ -80,12 +95,51 @@ export const appConfig = {
|
||||||
noiseMin: -1,
|
noiseMin: -1,
|
||||||
unlockTickFrequencyHz: 440,
|
unlockTickFrequencyHz: 440,
|
||||||
unlockTickSeconds: 0.035,
|
unlockTickSeconds: 0.035,
|
||||||
|
unlockTickType: 'sine',
|
||||||
|
latencyHint: 'interactive',
|
||||||
|
outputFilterType: 'highpass',
|
||||||
|
noiseBufferChannels: 1,
|
||||||
|
noiseBufferDurationSeconds: 1,
|
||||||
|
pianoBusGains: {
|
||||||
|
pad: 0.86,
|
||||||
|
support: 0.94,
|
||||||
|
texture: 0.88,
|
||||||
|
gesture: 1,
|
||||||
|
brush: 0.9,
|
||||||
|
stinger: 0.92,
|
||||||
|
},
|
||||||
|
pianoBusActivityDucking: {
|
||||||
|
pad: 0.42,
|
||||||
|
support: 0.18,
|
||||||
|
texture: -0.06,
|
||||||
|
gesture: 0,
|
||||||
|
brush: -0.08,
|
||||||
|
stinger: 0,
|
||||||
|
},
|
||||||
|
noiseBusGain: 0.72,
|
||||||
|
compressor: {
|
||||||
|
thresholdDb: -18,
|
||||||
|
kneeDb: 18,
|
||||||
|
ratio: 2.1,
|
||||||
|
attackSeconds: 0.018,
|
||||||
|
releaseSeconds: 0.18,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
input: {
|
input: {
|
||||||
distanceWindowForFullActivityPixels: 140,
|
distanceWindowForFullActivityPixels: 140,
|
||||||
distanceWindowSeconds: 0.5,
|
distanceWindowSeconds: 0.5,
|
||||||
fallbackFrameSeconds: 1 / 60,
|
fallbackFrameSeconds: 1 / 60,
|
||||||
manicActivityThreshold: 0.82,
|
fullActivitySpeed: 0.86,
|
||||||
|
activityNoiseFloorSpeed: 0.025,
|
||||||
|
activityCurve: 0.74,
|
||||||
|
activitySoftCeiling: 0.96,
|
||||||
|
activityAttackSeconds: 0.055,
|
||||||
|
activityReleaseSeconds: 0.2,
|
||||||
|
minAudibleDistance: 0.0025,
|
||||||
|
manicActivityThreshold: 0.9,
|
||||||
|
manicReleaseThreshold: 0.76,
|
||||||
|
maniaSmoothingSeconds: 0.12,
|
||||||
|
minElapsedSeconds: 0.001,
|
||||||
},
|
},
|
||||||
muteGain: 0.0001,
|
muteGain: 0.0001,
|
||||||
muteRampSeconds: 0.02,
|
muteRampSeconds: 0.02,
|
||||||
|
|
@ -95,6 +149,7 @@ export const appConfig = {
|
||||||
offsetRandomSeconds: 0.4,
|
offsetRandomSeconds: 0.4,
|
||||||
scheduleAheadSeconds: 0.002,
|
scheduleAheadSeconds: 0.002,
|
||||||
silentGain: 0.0001,
|
silentGain: 0.0001,
|
||||||
|
filterType: 'bandpass',
|
||||||
},
|
},
|
||||||
startDelaySeconds: 0.02,
|
startDelaySeconds: 0.02,
|
||||||
vibeChangeStingerMinIntervalSeconds: 0.45,
|
vibeChangeStingerMinIntervalSeconds: 0.45,
|
||||||
|
|
@ -142,7 +197,158 @@ export const appConfig = {
|
||||||
pan: 0.2,
|
pan: 0.2,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
chordVoicings: {
|
||||||
|
majorOpen: [0, 7, 12, 16],
|
||||||
|
minorOpen: [0, 7, 12, 15],
|
||||||
|
majorClosed: [0, 4, 7, 12, 16],
|
||||||
|
minorClosed: [0, 3, 7, 12, 15],
|
||||||
|
},
|
||||||
|
vibeChangeStinger: {
|
||||||
|
velocities: [0.1, 0.085, 0.07],
|
||||||
|
pans: [-0.16, 0, 0.16],
|
||||||
|
delaySends: [0.012, 0.014, 0.016],
|
||||||
|
lowpassExpression: 0.35,
|
||||||
|
},
|
||||||
|
highActivityExtra: {
|
||||||
|
barOffset: 1,
|
||||||
|
expressionMultiplier: 0.9,
|
||||||
|
},
|
||||||
|
padChord: {
|
||||||
|
velocities: [0.052, 0.041, 0.033],
|
||||||
|
expressionVelocityWeight: 0.02,
|
||||||
|
delaySend: 0.008,
|
||||||
|
lowpassExpressionWeight: 0.28,
|
||||||
|
},
|
||||||
|
supportNote: {
|
||||||
|
velocityBase: 0.105,
|
||||||
|
velocityExpressionWeight: 0.07,
|
||||||
|
durationBaseSeconds: 1.35,
|
||||||
|
durationExpressionSeconds: 0.4,
|
||||||
|
delaySendBase: 0.016,
|
||||||
|
delaySendExpressionWeight: 0.006,
|
||||||
|
lowpassExpressionWeight: 0.7,
|
||||||
|
expressionThreshold: 0.55,
|
||||||
|
offsetsByStyle: [
|
||||||
|
[0, 2, 12],
|
||||||
|
[1, 2, 0, 12],
|
||||||
|
[2, 12, 3, 13],
|
||||||
|
],
|
||||||
|
},
|
||||||
|
textureNote: {
|
||||||
|
velocityBase: 0.09,
|
||||||
|
velocityExpressionWeight: 0.08,
|
||||||
|
durationBaseSeconds: 0.62,
|
||||||
|
durationExpressionSeconds: 0.24,
|
||||||
|
delaySendBase: 0.016,
|
||||||
|
delaySendExpressionWeight: 0.006,
|
||||||
|
idleExpressionThreshold: 0.35,
|
||||||
|
mediumExpressionThreshold: 0.7,
|
||||||
|
intenseSpacing: 1,
|
||||||
|
idlePhase: 1,
|
||||||
|
},
|
||||||
|
gestureAccent: {
|
||||||
|
rotationStrengthMultiplier: 3,
|
||||||
|
quantizeStepLookahead: 1,
|
||||||
|
velocityBase: 0.12,
|
||||||
|
velocityStrengthWeight: 0.09,
|
||||||
|
durationBaseSeconds: 0.48,
|
||||||
|
durationStrengthSeconds: 0.22,
|
||||||
|
delaySend: 0.012,
|
||||||
|
},
|
||||||
|
touchNote: {
|
||||||
|
registerBiasManiaAmount: 0,
|
||||||
|
velocityBase: 0.14,
|
||||||
|
velocityStrengthWeight: 0.11,
|
||||||
|
durationBaseSeconds: 0.55,
|
||||||
|
durationStrengthSeconds: 0.18,
|
||||||
|
delaySend: 0.006,
|
||||||
|
lowpassBaseExpression: 0.55,
|
||||||
|
lowpassStrengthWeight: 0.35,
|
||||||
|
},
|
||||||
|
brushPhrase: {
|
||||||
|
initialMotifOffset: -1,
|
||||||
|
energyRetain: 0.94,
|
||||||
|
maniaRetain: 0.92,
|
||||||
|
energyDecaySeconds: 0.72,
|
||||||
|
maniaDecaySeconds: 0.54,
|
||||||
|
fadeMinimumLifetimeSeconds: 0.001,
|
||||||
|
layerIntensityBase: 0.8,
|
||||||
|
layerIntensityManiaWeight: 0.42,
|
||||||
|
frameActivityWeight: 0.42,
|
||||||
|
frameManiaWeight: 0.18,
|
||||||
|
},
|
||||||
|
brushStream: {
|
||||||
|
inferredManiaThreshold: 0.82,
|
||||||
|
inferredManiaRange: 0.18,
|
||||||
|
registerManiaShift: 0.45,
|
||||||
|
chordToneEverySteps: 4,
|
||||||
|
durationBaseSeconds: 0.48,
|
||||||
|
durationIntensitySeconds: 0.08,
|
||||||
|
durationManiaSeconds: 0.34,
|
||||||
|
durationMinSeconds: 0.14,
|
||||||
|
durationMaxSeconds: 0.62,
|
||||||
|
delaySendBase: 0.012,
|
||||||
|
delaySendIntensityWeight: 0.011,
|
||||||
|
delaySendManiaWeight: 0.006,
|
||||||
|
delaySendMin: 0.006,
|
||||||
|
delaySendMax: 0.032,
|
||||||
|
velocityBase: 0.1,
|
||||||
|
velocityIntensityWeight: 0.13,
|
||||||
|
lowpassBaseExpression: 0.39,
|
||||||
|
lowpassIntensityWeight: 0.48,
|
||||||
|
lowpassManiaWeight: 0.18,
|
||||||
|
manicThreshold: 0.85,
|
||||||
|
intenseThreshold: 0.62,
|
||||||
|
activeThreshold: 0.34,
|
||||||
|
},
|
||||||
|
brushStreamEcho: {
|
||||||
|
maniaThreshold: 0.86,
|
||||||
|
stepModulo: 2,
|
||||||
|
stepRemainder: 1,
|
||||||
|
intensityThreshold: 0.95,
|
||||||
|
octaveSemitones: 12,
|
||||||
|
maxMidi: 88,
|
||||||
|
velocityBase: 0.045,
|
||||||
|
velocityIntensityWeight: 0.05,
|
||||||
|
durationMinSeconds: 0.11,
|
||||||
|
durationScale: 0.68,
|
||||||
|
panScale: -0.75,
|
||||||
|
delaySendMin: 0.006,
|
||||||
|
delaySendScale: 0.72,
|
||||||
|
lowpassBaseExpression: 0.62,
|
||||||
|
lowpassManiaWeight: 0.24,
|
||||||
|
},
|
||||||
|
brushMotif: {
|
||||||
|
highThreshold: 0.82,
|
||||||
|
mediumThreshold: 0.55,
|
||||||
|
highOffset: 1,
|
||||||
|
mediumOffset: 0,
|
||||||
|
lowOffset: -1,
|
||||||
|
minOffset: -3,
|
||||||
|
maxOffset: 4,
|
||||||
|
},
|
||||||
|
registerBias: {
|
||||||
|
maniaShiftSemitones: 4,
|
||||||
|
midiMin: 36,
|
||||||
|
midiMaxForMin: 86,
|
||||||
|
minimumSpan: 4,
|
||||||
|
midiMax: 91,
|
||||||
|
},
|
||||||
|
candidateOctaveSearch: {
|
||||||
|
min: -3,
|
||||||
|
max: 3,
|
||||||
|
},
|
||||||
|
styleRotationMinSeconds: 0.001,
|
||||||
|
stylePanOffsetScale: 0.35,
|
||||||
|
lowpass: {
|
||||||
|
midiBase: 48,
|
||||||
|
midiRange: 33,
|
||||||
|
midiLiftHz: 720,
|
||||||
|
expressionBase: 0.58,
|
||||||
|
expressionWeight: 0.32,
|
||||||
|
},
|
||||||
styleRotationSeconds: 8,
|
styleRotationSeconds: 8,
|
||||||
|
styleRotationBars: 2,
|
||||||
chordBars: 4,
|
chordBars: 4,
|
||||||
supportBarSpacing: 2,
|
supportBarSpacing: 2,
|
||||||
supportBarOffset: 1,
|
supportBarOffset: 1,
|
||||||
|
|
@ -153,20 +359,23 @@ export const appConfig = {
|
||||||
highActivityExtraThreshold: 0.45,
|
highActivityExtraThreshold: 0.45,
|
||||||
noteScorePreferenceWeight: 1.8,
|
noteScorePreferenceWeight: 1.8,
|
||||||
noteScoreRegisterWeight: 0.28,
|
noteScoreRegisterWeight: 0.28,
|
||||||
|
noteScoreChordToneWeight: 0.75,
|
||||||
noteScoreRepeatPenalty: 3.2,
|
noteScoreRepeatPenalty: 3.2,
|
||||||
gestureAccentMinIntervalSeconds: 2.5,
|
gestureAccentMinIntervalSeconds: 2.5,
|
||||||
strokeAccentMinIntervalSeconds: 3.2,
|
strokeAccentMinIntervalSeconds: 3.2,
|
||||||
|
strokeAccentMinSteps: 12,
|
||||||
strokeAccentThreshold: 0.58,
|
strokeAccentThreshold: 0.58,
|
||||||
stingerSpacingSeconds: 0.08,
|
stingerSpacingSeconds: 0.08,
|
||||||
stingerDurationSeconds: 1.1,
|
stingerDurationSeconds: 1.1,
|
||||||
maxBrushPhraseLayers: 5,
|
maxBrushPhraseLayers: 3,
|
||||||
|
maxBrushStreamNotesPerBar: 9,
|
||||||
brushLayerBaseSeconds: 5.5,
|
brushLayerBaseSeconds: 5.5,
|
||||||
brushLayerEnergySeconds: 2.5,
|
brushLayerEnergySeconds: 2.5,
|
||||||
brushLayerMinIntensity: 0.08,
|
brushLayerMinIntensity: 0.12,
|
||||||
brushStreamIdleIntervalBeats: 2,
|
brushStreamIdleIntervalBeats: 2,
|
||||||
brushStreamActiveIntervalBeats: 1,
|
brushStreamActiveIntervalBeats: 1,
|
||||||
brushStreamIntenseIntervalBeats: 0.5,
|
brushStreamIntenseIntervalBeats: 0.5,
|
||||||
brushStreamManicIntervalBeats: 0.25,
|
brushStreamManicIntervalBeats: 0.5,
|
||||||
brushMotifMaxSteps: 8,
|
brushMotifMaxSteps: 8,
|
||||||
brushMotifCanonDelaySeconds: 0.055,
|
brushMotifCanonDelaySeconds: 0.055,
|
||||||
padDurationBarScale: 0.46,
|
padDurationBarScale: 0.46,
|
||||||
|
|
@ -195,10 +404,15 @@ export const appConfig = {
|
||||||
},
|
},
|
||||||
export4k: {
|
export4k: {
|
||||||
bytesPerPixel: 4,
|
bytesPerPixel: 4,
|
||||||
|
filenameExtension: 'png',
|
||||||
|
filenamePrefix: 'fleeting-garden',
|
||||||
|
filenameSuffix: '-upscale',
|
||||||
height: 2160,
|
height: 2160,
|
||||||
jsHeapSafetyMultiplier: 1.5,
|
jsHeapSafetyMultiplier: 1.5,
|
||||||
|
jsHeapTextureBytesMultiplier: 4,
|
||||||
lowMemoryDeviceGiB: 2,
|
lowMemoryDeviceGiB: 2,
|
||||||
lowMemoryExportFraction: 0.08,
|
lowMemoryExportFraction: 0.08,
|
||||||
|
mimeType: 'image/png',
|
||||||
rowAlignmentBytes: 256,
|
rowAlignmentBytes: 256,
|
||||||
width: 3840,
|
width: 3840,
|
||||||
},
|
},
|
||||||
|
|
@ -208,6 +422,17 @@ export const appConfig = {
|
||||||
hideDelayMs: 3000,
|
hideDelayMs: 3000,
|
||||||
},
|
},
|
||||||
pipelines: {
|
pipelines: {
|
||||||
|
common: {
|
||||||
|
noiseChannelSeeds: [0, 1, 2, 3],
|
||||||
|
noiseClearValue: { r: 1, g: 1, b: 1, a: 1 },
|
||||||
|
noiseDrawInstanceCount: 1,
|
||||||
|
noiseDrawVertexCount: 3,
|
||||||
|
noiseHashMultiplier: 43758.5453123,
|
||||||
|
noiseHashX: 12.9898,
|
||||||
|
noiseHashY: 78.233,
|
||||||
|
noiseTextureFormat: 'rgba8unorm',
|
||||||
|
noiseTextureSize: 2048,
|
||||||
|
},
|
||||||
brush: {
|
brush: {
|
||||||
maxLineCount: 240,
|
maxLineCount: 240,
|
||||||
},
|
},
|
||||||
|
|
@ -228,20 +453,27 @@ export const appConfig = {
|
||||||
adaptiveCapInitial: 1_000_000,
|
adaptiveCapInitial: 1_000_000,
|
||||||
adaptiveCapMax: 2_000_000,
|
adaptiveCapMax: 2_000_000,
|
||||||
adaptiveCapMin: 500_000,
|
adaptiveCapMin: 500_000,
|
||||||
|
adaptiveRefreshTargetFps: 60,
|
||||||
|
frameGapResetSeconds: 1,
|
||||||
fpsHeadroom: 0.95,
|
fpsHeadroom: 0.95,
|
||||||
fpsSmoothingNew: 0.06,
|
fpsSmoothingNew: 0.06,
|
||||||
fpsSmoothingRetain: 0.94,
|
fpsSmoothingRetain: 0.94,
|
||||||
|
initialFps: 60,
|
||||||
},
|
},
|
||||||
brushEffectFramesPerSecond: 60,
|
brushEffectFramesPerSecond: 60,
|
||||||
|
clearColor: { r: 0, g: 0, b: 0, a: 0 },
|
||||||
initialAgentCount: 180_000,
|
initialAgentCount: 180_000,
|
||||||
intro: {
|
intro: {
|
||||||
angleJitterRadians: Math.PI * 0.08,
|
angleJitterRadians: Math.PI * 0.08,
|
||||||
|
angleEaseEnd: 1,
|
||||||
|
angleEaseStart: 0.6,
|
||||||
circleMaxSideRatio: 0.46,
|
circleMaxSideRatio: 0.46,
|
||||||
circleMinSideRatio: 0.32,
|
circleMinSideRatio: 0.32,
|
||||||
drawHintDelayMs: 3000,
|
drawHintDelayMs: 3000,
|
||||||
durationSeconds: 4,
|
durationSeconds: 4,
|
||||||
entryJitterSideRatio: 0.035,
|
entryJitterSideRatio: 0.035,
|
||||||
fontScaleDown: 0.94,
|
fontScaleDown: 0.94,
|
||||||
|
fontFamily: '"Open Sans", sans-serif',
|
||||||
initialFontHeightRatio: 0.28,
|
initialFontHeightRatio: 0.28,
|
||||||
initialFontWidthRatio: 0.19,
|
initialFontWidthRatio: 0.19,
|
||||||
letterSpacingEm: 0.07,
|
letterSpacingEm: 0.07,
|
||||||
|
|
@ -253,7 +485,12 @@ export const appConfig = {
|
||||||
minEntryJitterPx: 6,
|
minEntryJitterPx: 6,
|
||||||
minFontSizePx: 18,
|
minFontSizePx: 18,
|
||||||
minTargetJitterPx: 1,
|
minTargetJitterPx: 1,
|
||||||
|
pathEasing: 'easeOutQuad' as GardenAppConfig['simulation']['intro']['pathEasing'],
|
||||||
|
pathProgressEpsilon: 0.001,
|
||||||
radialJitterRatio: 0.35,
|
radialJitterRatio: 0.35,
|
||||||
|
radialStartEpsilon: 0.001,
|
||||||
|
resizeMinimumRemainingSeconds: 1.4,
|
||||||
|
resizeSettleMs: 120,
|
||||||
targetDelayDistanceMultiplier: 0.12,
|
targetDelayDistanceMultiplier: 0.12,
|
||||||
targetDelayMax: 0.22,
|
targetDelayMax: 0.22,
|
||||||
targetDelayRandomMultiplier: 0.06,
|
targetDelayRandomMultiplier: 0.06,
|
||||||
|
|
@ -272,10 +509,12 @@ export const appConfig = {
|
||||||
densityMultiplier: 110,
|
densityMultiplier: 110,
|
||||||
maxAgentCount: 2_400,
|
maxAgentCount: 2_400,
|
||||||
minAgentCount: 140,
|
minAgentCount: 140,
|
||||||
|
minSegmentLengthPx: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
storage: {
|
storage: {
|
||||||
audioMutedKey: 'fleeting-garden:audio-muted',
|
audioMutedKey: 'fleeting-garden:audio-muted',
|
||||||
|
audioVolumeKey: 'fleeting-garden:audio-volume',
|
||||||
vibeKey: 'fleeting-garden:vibe',
|
vibeKey: 'fleeting-garden:vibe',
|
||||||
},
|
},
|
||||||
toolbar: {
|
toolbar: {
|
||||||
|
|
@ -289,6 +528,7 @@ export const appConfig = {
|
||||||
},
|
},
|
||||||
mirror: {
|
mirror: {
|
||||||
default: 1,
|
default: 1,
|
||||||
|
fallbackSegmentName: 'slices',
|
||||||
max: 12,
|
max: 12,
|
||||||
min: 1,
|
min: 1,
|
||||||
names: {
|
names: {
|
||||||
|
|
@ -304,8 +544,38 @@ export const appConfig = {
|
||||||
11: 'elevenths',
|
11: 'elevenths',
|
||||||
12: 'twelfths',
|
12: 'twelfths',
|
||||||
},
|
},
|
||||||
|
offLabel: 'Mirror off',
|
||||||
step: 1,
|
step: 1,
|
||||||
},
|
},
|
||||||
|
contrast: {
|
||||||
|
backgroundOpacityMax: 0.82,
|
||||||
|
brightLuminanceThreshold: 0.32,
|
||||||
|
brightWeight: 0.65,
|
||||||
|
bytesPerSample: 4,
|
||||||
|
contrastOffset: 0.05,
|
||||||
|
linearChannelBreakpoint: 0.03928,
|
||||||
|
linearChannelDivisor: 12.92,
|
||||||
|
linearChannelGamma: 2.4,
|
||||||
|
linearChannelOffset: 0.055,
|
||||||
|
linearChannelScale: 1.055,
|
||||||
|
lowContrastThreshold: 3,
|
||||||
|
lowContrastWeight: 1.8,
|
||||||
|
luminanceBase: 0.11,
|
||||||
|
luminanceBlueWeight: 0.0722,
|
||||||
|
luminanceGreenWeight: 0.7152,
|
||||||
|
luminanceRange: 0.28,
|
||||||
|
luminanceRedWeight: 0.2126,
|
||||||
|
sampleColumns: 13,
|
||||||
|
sampleIntervalMs: 300,
|
||||||
|
sampleRows: 7,
|
||||||
|
whiteContrastNumerator: 1.05,
|
||||||
|
},
|
||||||
|
volume: {
|
||||||
|
default: defaultAudioMasterVolume,
|
||||||
|
max: 1,
|
||||||
|
min: 0,
|
||||||
|
step: 0.01,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
tuningPane: {
|
tuningPane: {
|
||||||
expandedDepth: 1,
|
expandedDepth: 1,
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue