@@ -8,12 +8,13 @@ export const MIC_FORMAT = 's16';
|
||||
/** Raw 16 kHz mono capture from PipeWire. The process is deliberately kept
|
||||
* outside gnome-shell and has a stable node name for routing in Helvum. */
|
||||
export class PipeWireCapture extends EventEmitter {
|
||||
constructor({ command = 'pw-cat', spawnImpl = spawn, sampleRate = MIC_SAMPLE_RATE, nodeName = 'Jarvis' } = {}) {
|
||||
constructor({ command = 'pw-cat', spawnImpl = spawn, sampleRate = MIC_SAMPLE_RATE, nodeName = 'Jarvis', target = '' } = {}) {
|
||||
super();
|
||||
this.command = command;
|
||||
this.spawnImpl = spawnImpl;
|
||||
this.sampleRate = sampleRate;
|
||||
this.nodeName = nodeName;
|
||||
this.target = target;
|
||||
this.process = null;
|
||||
}
|
||||
|
||||
@@ -21,7 +22,7 @@ export class PipeWireCapture extends EventEmitter {
|
||||
if (this.process) return this;
|
||||
this.process = this.spawnImpl(this.command, [
|
||||
'--record', '--raw', '--format', MIC_FORMAT, '--rate', String(this.sampleRate),
|
||||
'--channels', String(MIC_CHANNELS), '--properties', `node.name=${this.nodeName}`, '-',
|
||||
'--channels', String(MIC_CHANNELS), ...(this.target ? ['--target', this.target] : []), '--properties', `node.name=${this.nodeName}`, '-',
|
||||
], { stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
this.process.stdout?.on('data', (chunk) => this.emit('audio', Buffer.from(chunk)));
|
||||
this.process.stderr?.on('data', (chunk) => this.emit('diagnostic', String(chunk).trim()));
|
||||
|
||||
Reference in New Issue
Block a user