feat(electron): create recording through tray (#10526)

- added tray menu for controlling recording status
- recording watcher for monitoring system audio input events
This commit is contained in:
pengx17
2025-03-18 04:12:30 +00:00
parent 05329e96c7
commit a016630a82
29 changed files with 1186 additions and 258 deletions

View File

@@ -2,6 +2,7 @@ import { AsyncCall } from 'async-call-rpc';
import type { HelperToMain, MainToHelper } from '../shared/type';
import { exposed } from './provide';
import { encodeToMp3 } from './recording/encode';
const helperToMainServer: HelperToMain = {
getMeta: () => {
@@ -10,6 +11,8 @@ const helperToMainServer: HelperToMain = {
}
return exposed;
},
// allow main process encode audio samples to mp3 buffer (because it is slow and blocking)
encodeToMp3,
};
export const mainRPC = AsyncCall<MainToHelper>(helperToMainServer, {

View File

@@ -0,0 +1,16 @@
import { Mp3Encoder } from '@affine/native';
// encode audio samples to mp3 buffer
export function encodeToMp3(
samples: Float32Array,
opts: {
channels?: number;
sampleRate?: number;
} = {}
): Uint8Array {
const mp3Encoder = new Mp3Encoder({
channels: opts.channels ?? 2,
sampleRate: opts.sampleRate ?? 44100,
});
return mp3Encoder.encode(samples);
}