}
type inputOptions = {
- channelCount: number,
- sampleFormat: number,
- sampleRate: number,
- deviceId: number,
- closeOnError: boolean
+ channelCount: number;
+ sampleFormat: number;
+ sampleRate: number;
+ deviceId: number;
+ closeOnError: boolean;
}
class StringWritable extends Writable {
this.recorderOptions = options;
this.micWritable = new StringWritable({
defaultEncoding: encoding
- })
- this.restart();
- ipcMain.on('update-recorder', this._update);
+ });
+ try {
+ this.restart();
+ ipcMain.on('update-recorder', this._update);
+ } catch(e) {
+ console.log('MEGA ERROR!');
+ }
}
restart() {
if (record) {
// check for stream status
console.log('recording')
-
-
+ this.resume();
// this.ia.pipe(this.micWritable);
} else {
console.log('stop recording')
// unpipe
- // this.ia.unpipe(this.micWritable);
+ this.ia.unpipe(this.micWritable);
// stop stream
- // this.ia.quit();
- // this.ia = null;
+ this.ia.quit();
+ this.ia = null;
// get stream data
- // this.micWritable.on('finish', () => {
- // console.log('finished writing data');
- // })
- // this.restart();
+ this.micWritable.on('finish', () => {
+ console.log('finished writing data');
+ })
+ this.restart();
}
}
}