Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

Recording: main.log says once a minute how loud each side got, and when no call audio was heard (#35)

christianmat883336059468
diff --git a/app/src/main/capture.ts b/app/src/main/capture.ts
index 8315b25f..c7f4ab3f 100644
--- a/app/src/main/capture.ts
+++ b/app/src/main/capture.ts
@@ -7,6 +7,7 @@ import { isFake } from './paths'
import { fakeAudioDuration, fakeCaptureProc, joinFakeParts } from './fakeCapture'
import type { RecordingStart } from './meeting'
import { createCrashPolicy } from './crashPolicy'
+import { createLevelLog } from './levelLog'
import { helperFile } from '../shared/platform'
/**
@@ -375,10 +376,16 @@ export function hookCapture(p: {
hiccup: () => tell({ t: 'hiccup' }),
giveUp: () => { tell({ t: 'gave-up' }); void finish(); p.stopMeeting(m.id) },
})
+ // how loud each side got, once a minute in main.log (levelLog.ts)
+ const levels = createLevelLog()
const attach = (c: Capture) => {
active = c
c.on('warn', (code) => { console.warn('capture warning', code); tell({ t: 'warn', code }) })
- c.on('level', (lv) => tell({ t: 'level', me: s.paused ? 0 : lv.me, them: s.paused ? 0 : lv.them }))
+ c.on('level', (lv) => {
+ tell({ t: 'level', me: s.paused ? 0 : lv.me, them: s.paused ? 0 : lv.them })
+ const line = s.paused ? undefined : levels(lv, Date.now())
+ if (line) console.info(line)
+ })
c.on('ended', (e) => {
// a capture that was stopped on purpose or replaced is not ours to judge
if (active !== c) return
diff --git a/app/src/main/levelLog.ts b/app/src/main/levelLog.ts
new file mode 100644
index 00000000..3db8a3a1
--- /dev/null
+++ b/app/src/main/levelLog.ts
@@ -0,0 +1,16 @@
+/**
+ * Once a minute while recording, how loud each side got (levels are 0..1 over -60..0 dB), for main.log. A report of
+ * "the call isn't recorded" (#35) then shows whether the call side heard anything at all, and nothing of what was said.
+ */
+export function createLevelLog(everyMs = 60_000) {
+ let since: number | undefined
+ let me = 0, them = 0
+ return (lv: { me: number; them: number }, now: number): string | undefined => {
+ since ??= now
+ me = Math.max(me, lv.me); them = Math.max(them, lv.them)
+ if (now - since < everyMs) return undefined
+ const line = `LEVEL last ${Math.round((now - since) / 1000)} s: loudest me ${me.toFixed(2)}, them ${them.toFixed(2)}${them < 0.05 ? ' (no call audio heard)' : ''}`
+ since = now; me = 0; them = 0
+ return line
+ }
+}
diff --git a/app/test/levelLog.test.ts b/app/test/levelLog.test.ts
new file mode 100644
index 00000000..f2a740e1
--- /dev/null
+++ b/app/test/levelLog.test.ts
@@ -0,0 +1,12 @@
+import { expect, it } from 'vitest'
+import { createLevelLog } from '../src/main/levelLog'
+
+// #35: "no call audio" reports need to show whether the call was heard at all, without anything from the meeting
+it('once a minute, logs how loud each side got, and says when the call side heard nothing', () => {
+ const log = createLevelLog(60_000)
+ expect(log({ me: 0.4, them: 0.6 }, 0)).toBeUndefined()
+ expect(log({ me: 0.7, them: 0.2 }, 30_000)).toBeUndefined()
+ expect(log({ me: 0.1, them: 0.1 }, 60_000)).toBe('LEVEL last 60 s: loudest me 0.70, them 0.60')
+ expect(log({ me: 0.5, them: 0 }, 90_000)).toBeUndefined()
+ expect(log({ me: 0.5, them: 0.01 }, 120_000)).toBe('LEVEL last 60 s: loudest me 0.50, them 0.01 (no call audio heard)')
+})