From 37764bb3a0fa496e8e25c660de8720c3af3e5d60 Mon Sep 17 00:00:00 2001 From: Enrique Hernandez Date: Thu, 4 Feb 2021 12:34:33 -0600 Subject: [PATCH] update recorder inputs --- crash.log | 4 ++++ src/background.ts | 16 +++++++------ src/background/recorder.ts | 49 ++++++++++++++++++++------------------ 3 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 crash.log diff --git a/crash.log b/crash.log new file mode 100644 index 0000000..cfecd62 --- /dev/null +++ b/crash.log @@ -0,0 +1,4 @@ +PID 335844 received SIGSEGV for address: 0xc +/home/enrique/Developer/electron-app/node_modules/segfault-handler/build/Release/segfault-handler.node(+0x37a5)[0x7f1c071387a5] +/lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7f1c10ffa3c0] +/home/enrique/Developer/electron-app/node_modules/electron/dist/electron dist_electron(+0x72d9550)[0x55ccd61fe550] diff --git a/src/background.ts b/src/background.ts index d3cecd9..4cae5f4 100644 --- a/src/background.ts +++ b/src/background.ts @@ -7,17 +7,19 @@ var portAudio = require('naudiodon'); // NOTE Program Begins Here (async () => { + console.log(portAudio.getDevices()) const isDevelopment = process.env.NODE_ENV !== "production"; - const recorder = new Recorder({ - channelCount: 1, - sampleFormat: portAudio.SampleFormat16Bit, - sampleRate: 16000, - deviceId: -1, // Use -1 or omit the deviceId to select the default device - closeOnError: true - }, 'binary'); try { + + const recorder = new Recorder({ + channelCount: 1, + sampleFormat: 16, + sampleRate: 16000, + deviceId: 24, // Use -1 or omit the deviceId to select the default device + closeOnError: true + }, 'binary'); // await authenticate method initApp(isDevelopment); } catch (e) { diff --git a/src/background/recorder.ts b/src/background/recorder.ts index 36f93ba..d078585 100644 --- a/src/background/recorder.ts +++ b/src/background/recorder.ts @@ -11,6 +11,14 @@ interface RecorderI { pause(): void; } +type inputOptions = { + channelCount: number, + sampleFormat: number, + sampleRate: number, + deviceId: number, + closeOnError: boolean +} + class StringWritable extends Writable { constructor(options: { @@ -37,15 +45,6 @@ class StringWritable extends Writable { } } -type inputOptions = {clear - - channelCount: number, - sampleFormat: string, - sampleRate: number, - deviceId: number, - closeOnError: boolean -} - export class Recorder implements RecorderI { private ia: any; @@ -93,21 +92,25 @@ export class Recorder implements RecorderI { private _update = (Event: any, record: boolean) => { if (record) { - console.log('recording'); - this.micWritable.data = ''; - if(this.ia._readableState.paused){ - this.resume(); - return; - } - this.ia.pipe(this.micWritable); - - console.log(this.ia._readableState.paused); + // check for stream status + console.log('recording') + + + // this.ia.pipe(this.micWritable); } else { - console.log('stop recording'); - this.ia.unpipe(this.micWritable); - this.micWritable.on('finish', () => { - console.log('hello'); - }) + console.log('stop recording') + // unpipe + // this.ia.unpipe(this.micWritable); + + // stop stream + // this.ia.quit(); + // this.ia = null; + + // get stream data + // this.micWritable.on('finish', () => { + // console.log('finished writing data'); + // }) + // this.restart(); } } } -- 2.43.0