update recorder inputs
This commit is contained in:
parent
5c55910e26
commit
37764bb3a0
3 changed files with 39 additions and 30 deletions
4
crash.log
Normal file
4
crash.log
Normal file
|
|
@ -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]
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
// check for stream status
|
||||
console.log('recording')
|
||||
|
||||
console.log(this.ia._readableState.paused);
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue