feat(stage-tamagotchi): expose some values for beat-sync dev
This commit is contained in:
@@ -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,
|
||||
})
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user