feat(stage-tamagotchi): expose some values for beat-sync dev

This commit is contained in:
Makito
2025-11-29 05:56:05 +09:00
parent 0a0713d930
commit 68d634ff02
2 changed files with 19 additions and 8 deletions
+17 -6
View File
@@ -5,18 +5,23 @@ import { createDetector, StageEnvironment } from '@proj-airi/stage-shared'
import { ipcRenderer } from 'electron'
import { beatSyncSignalBeat, beatSyncToggle } from '../shared/eventa'
import { exposeWithCustomAPI } from './shared'
const context = createContext(electronAPI.ipcRenderer).context
const signalBeat = defineInvoke(context, beatSyncSignalBeat)
function enableLoopbackAudio() {
return ipcRenderer.invoke('enable-loopback-audio')
}
function disableLoopbackAudio() {
return ipcRenderer.invoke('disable-loopback-audio')
}
const detector = createDetector({
env: StageEnvironment.Tamagotchi,
enableLoopbackAudio() {
return ipcRenderer.invoke('enable-loopback-audio')
},
disableLoopbackAudio() {
return ipcRenderer.invoke('disable-loopback-audio')
},
enableLoopbackAudio,
disableLoopbackAudio,
})
detector.on('beat', () => signalBeat())
@@ -29,3 +34,9 @@ defineInvokeHandler(context, beatSyncToggle, async (enabled) => {
detector.stop()
}
})
exposeWithCustomAPI({
enableLoopbackAudio,
disableLoopbackAudio,
detector,
})
+2 -2
View File
@@ -11,7 +11,7 @@ export interface DetectorEventMap {
beat: (e: AnalyserBeatEvent) => void
}
interface Detector {
export interface Detector {
start: (createSource: (context: AudioContext) => Promise<AudioNode>) => Promise<void>
updateParameters: (params: Partial<AnalyserWorkletParameters>) => void
startScreenCapture: () => Promise<void>
@@ -24,7 +24,7 @@ interface Detector {
readonly source: AudioNode | undefined
}
type CreateDetectorOptions = |
export type CreateDetectorOptions = |
{
env: StageEnvironment.Tamagotchi
enableLoopbackAudio: () => Promise<any>