35 lines
682 B
TypeScript
35 lines
682 B
TypeScript
import { atom } from 'nanostores'
|
|
|
|
export interface MappingModeState {
|
|
isActive: boolean
|
|
activeLFO: number | null
|
|
}
|
|
|
|
export const mappingMode = atom<MappingModeState>({
|
|
isActive: false,
|
|
activeLFO: null
|
|
})
|
|
|
|
export function enterMappingMode(lfoIndex: number): void {
|
|
mappingMode.set({
|
|
isActive: true,
|
|
activeLFO: lfoIndex
|
|
})
|
|
}
|
|
|
|
export function exitMappingMode(): void {
|
|
mappingMode.set({
|
|
isActive: false,
|
|
activeLFO: null
|
|
})
|
|
}
|
|
|
|
export function toggleMappingMode(lfoIndex: number): void {
|
|
const current = mappingMode.get()
|
|
if (current.isActive && current.activeLFO === lfoIndex) {
|
|
exitMappingMode()
|
|
} else {
|
|
enterMappingMode(lfoIndex)
|
|
}
|
|
}
|