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

+20 -4
View File
@@ -1,11 +1,17 @@
import { clampTempoBpm, DEFAULT_BEATS_PER_BAR, getTotalSteps, TEMPO_BPM } from './sequencer';
import {
clampTempoBpm,
DEFAULT_BEATS_PER_BAR,
getTotalSteps,
TEMPO_BPM,
} from './sequencer';
import type { BeatsPerBar, BeatPoint } from './sequencer';
import type { SoundId } from './sounds';
import { clampPitchSemitones } from './instruments';
import type { InstrumentId } from './instruments';
export interface SequencerState {
beats: BeatPoint[];
selectedBeatId: string | null;
focusedSoundId: SoundId | null;
focusedSoundId: InstrumentId | null;
tempoBpm: number;
beatsPerBar: BeatsPerBar;
}
@@ -13,8 +19,9 @@ export interface SequencerState {
export type SequencerAction =
| { type: 'beat-added'; beat: BeatPoint }
| { type: 'beat-moved'; beatId: string; step: number }
| { type: 'beat-pitch-changed'; beatId: string; pitchSemitones: number }
| { type: 'beat-selected'; beatId: string }
| { type: 'sound-selected'; soundId: SoundId }
| { type: 'sound-selected'; soundId: InstrumentId }
| { type: 'selected-beat-removed' }
| { type: 'focused-sound-removed' }
| { type: 'tempo-changed'; tempoBpm: number }
@@ -51,6 +58,15 @@ export function sequencerReducer(state: SequencerState, action: SequencerAction)
beat.id === action.beatId ? { ...beat, step: action.step } : beat
)),
};
case 'beat-pitch-changed':
return {
...state,
beats: state.beats.map((beat) => (
beat.id === action.beatId
? { ...beat, pitchSemitones: clampPitchSemitones(action.pitchSemitones) }
: beat
)),
};
case 'beat-selected': {
const beat = state.beats.find((candidate) => candidate.id === action.beatId);
if (!beat) return state;