The packaged app doesn't bundle ffmpeg, so on Macs without a system ffmpeg the waveform stayed blank. Compute peaks by reading the file bytes (new file:read IPC) and decoding with Web Audio's decodeAudioData in a low-rate AudioContext; ffmpeg in main remains only as a fallback. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
41 lines
2.0 KiB
JavaScript
41 lines
2.0 KiB
JavaScript
const { contextBridge, ipcRenderer, webUtils } = require('electron');
|
|
|
|
// Each window is launched with --role=control or --role=output.
|
|
const roleArg = process.argv.find(a => a.startsWith('--role='));
|
|
const role = roleArg ? roleArg.split('=')[1] : 'control';
|
|
|
|
contextBridge.exposeInMainWorld('djv', {
|
|
role,
|
|
// Control -> Output commands.
|
|
send: (msg) => ipcRenderer.send('ctl', msg),
|
|
onControl: (cb) => ipcRenderer.on('ctl', (_e, m) => cb(m)),
|
|
// Output -> Control reports.
|
|
report: (msg) => ipcRenderer.send('rpt', msg),
|
|
onReport: (cb) => ipcRenderer.on('rpt', (_e, m) => cb(m)),
|
|
// Display management (control window).
|
|
// Bundled svg/ folder, read in the main process, as same-origin data URLs.
|
|
listBuiltinSvgs: () => ipcRenderer.invoke('svg:listBuiltin'),
|
|
// Resolve a dropped/picked File to its absolute filesystem path.
|
|
pathForFile: (file) => {
|
|
try { return webUtils.getPathForFile(file); }
|
|
catch (e) { return file && file.path ? file.path : null; }
|
|
},
|
|
listDisplays: () => ipcRenderer.invoke('displays:list'),
|
|
moveOutputTo: (id) => ipcRenderer.invoke('output:moveTo', id),
|
|
toggleOutputFullscreen: () => ipcRenderer.invoke('output:toggleFullscreen'),
|
|
// Recording (output streams chunks to main, which muxes/transcodes to MP4).
|
|
recStart: () => ipcRenderer.invoke('rec:start'),
|
|
recChunk: (bytes) => ipcRenderer.send('rec:chunk', bytes),
|
|
recStop: (opts) => ipcRenderer.invoke('rec:stop', opts),
|
|
openRecordingsFolder: () => ipcRenderer.invoke('rec:openFolder'),
|
|
// Pad bank persistence.
|
|
loadPads: () => ipcRenderer.invoke('pads:load'),
|
|
savePads: (data) => ipcRenderer.invoke('pads:save', data),
|
|
loadPlaylist: () => ipcRenderer.invoke('playlist:load'),
|
|
savePlaylist: (data) => ipcRenderer.invoke('playlist:save', data),
|
|
exportPlaylist: (data) => ipcRenderer.invoke('playlist:export', data),
|
|
importPlaylist: () => ipcRenderer.invoke('playlist:import'),
|
|
peaks: (path, buckets) => ipcRenderer.invoke('audio:peaks', path, buckets),
|
|
readFile: (path) => ipcRenderer.invoke('file:read', path)
|
|
});
|