mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
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:
@@ -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, {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user