Add app info and instrument controls

This commit is contained in:
Ninosaurier committed 2026-11-15 13:43:06 +01:00
1 parent e23825cdb1
commit 9d8f277971
38 files changed
+4001 -257

No files matched your search

+6 -6
View File
@@ -1,22 +1,22 @@
import { useCallback, useMemo, useState } from 'react';
import type { SoundId } from '../domain/sounds';
import type { InstrumentId } from '../domain/instruments';
import { generateUniqueSoundColor } from '../domain/soundColors';
export interface PaletteSound {
id: SoundId;
id: InstrumentId;
color: string;
}
export interface SoundPalette {
activeSounds: PaletteSound[];
colorBySoundId: Partial<Record<SoundId, string>>;
activateSounds: (soundIds: readonly SoundId[]) => void;
colorBySoundId: Partial<Record<InstrumentId, string>>;
activateSounds: (soundIds: readonly InstrumentId[]) => void;
}
export function useSoundPalette(): SoundPalette {
const [activeSounds, setActiveSounds] = useState<PaletteSound[]>([]);
const activateSounds = useCallback((soundIds: readonly SoundId[]): void => {
const activateSounds = useCallback((soundIds: readonly InstrumentId[]): void => {
setActiveSounds((currentSounds) => {
const nextSounds = [...currentSounds];
const currentCount = nextSounds.length;
@@ -33,7 +33,7 @@ export function useSoundPalette(): SoundPalette {
}, []);
const colorBySoundId = useMemo(() => {
const colors: Partial<Record<SoundId, string>> = {};
const colors: Partial<Record<InstrumentId, string>> = {};
activeSounds.forEach((sound) => {
colors[sound.id] = sound.color;
});