Add app info and instrument controls
This commit is contained in:
1 parent
e23825cdb1
commit
9d8f277971
38 files changed
+4001
-257
No files matched your search
@@ -5,6 +5,16 @@ import {
|
||||
sequencerReducer,
|
||||
} from './domain/sequencerReducer';
|
||||
import { generateUniqueSoundColor } from './domain/soundColors';
|
||||
import {
|
||||
clampPitchSemitones,
|
||||
getPitchLabel,
|
||||
INSTRUMENT_CATEGORIES,
|
||||
INSTRUMENT_CATALOG,
|
||||
INSTRUMENT_BY_ID,
|
||||
MAX_PITCH_SEMITONES,
|
||||
MIN_PITCH_SEMITONES,
|
||||
} from './domain/instruments';
|
||||
import { INSTRUMENT_VOICES } from './audio/soundVoices';
|
||||
import {
|
||||
getNextAvailableStep,
|
||||
getPlaybackTickDurationMs,
|
||||
@@ -108,6 +118,30 @@ describe('sound colors', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('instrument catalog and pitch', () => {
|
||||
it('places every instrument in exactly one category and has a sound voice', () => {
|
||||
const categorizedInstruments = INSTRUMENT_CATEGORIES.flatMap(
|
||||
(category) => category.instrumentIds,
|
||||
);
|
||||
|
||||
expect(new Set(categorizedInstruments).size).toBe(INSTRUMENT_CATALOG.length);
|
||||
INSTRUMENT_CATALOG.forEach((instrument) => {
|
||||
expect(categorizedInstruments).toContain(instrument.id);
|
||||
expect(typeof INSTRUMENT_VOICES[instrument.id]).toBe('function');
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps pitch within two octaves and names notes from C2 through C6', () => {
|
||||
expect(clampPitchSemitones(MIN_PITCH_SEMITONES - 1)).toBe(MIN_PITCH_SEMITONES);
|
||||
expect(clampPitchSemitones(MAX_PITCH_SEMITONES + 1)).toBe(MAX_PITCH_SEMITONES);
|
||||
expect(clampPitchSemitones(3.7)).toBe(4);
|
||||
expect(getPitchLabel(MIN_PITCH_SEMITONES)).toBe('C2');
|
||||
expect(getPitchLabel(0)).toBe('C4');
|
||||
expect(getPitchLabel(MAX_PITCH_SEMITONES)).toBe('C6');
|
||||
expect(getPitchLabel(0, INSTRUMENT_BY_ID.kick.pitchBaseMidi)).toBe('F3');
|
||||
});
|
||||
});
|
||||
|
||||
describe('sequencer state transitions', () => {
|
||||
it('loads a template with a focused first beat and removes a focused sound ring', () => {
|
||||
const templateBeats: BeatPoint[] = [
|
||||
@@ -180,6 +214,27 @@ describe('sequencer state transitions', () => {
|
||||
expect(tooSlow.tempoBpm).toBe(MIN_TEMPO_BPM);
|
||||
expect(tooFast.tempoBpm).toBe(MAX_TEMPO_BPM);
|
||||
});
|
||||
|
||||
it('changes pitch on one selected beat and clamps it to the supported range', () => {
|
||||
const beats: BeatPoint[] = [
|
||||
{ id: 'bass-1', soundId: 'bass', step: 0, pitchSemitones: 0 },
|
||||
{ id: 'piano-1', soundId: 'piano', step: 4, pitchSemitones: 0 },
|
||||
];
|
||||
const loaded = sequencerReducer(createInitialSequencerState(), {
|
||||
type: 'template-loaded',
|
||||
beats,
|
||||
tempoBpm: TEMPO_BPM,
|
||||
beatsPerBar: 4,
|
||||
});
|
||||
const changed = sequencerReducer(loaded, {
|
||||
type: 'beat-pitch-changed',
|
||||
beatId: 'bass-1',
|
||||
pitchSemitones: MAX_PITCH_SEMITONES + 12,
|
||||
});
|
||||
|
||||
expect(changed.beats[0].pitchSemitones).toBe(MAX_PITCH_SEMITONES);
|
||||
expect(changed.beats[1].pitchSemitones).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('dance templates', () => {
|
||||
|
||||
Reference in new issue
Block a user