Open pgee70 opened 9 years ago
Hi try this:
use this snippet to construct: AudioRecorderConfig = {worker_path:'assets/js/ogg/worker.min.js'};
AudioRecorderConfig.audioContext = audioCtx; AudioRecorderConfig.stream = stream; AudioRecorder.init(AudioRecorderConfig);
On 17 Mar 2015, at 2:13 am, jhiswin notifications@github.com wrote:
@pgee70 https://github.com/pgee70 Can you post the full source for your modified audiorecorder.js and worker.js? I've tried manually making the changes you posted, and it does not seem to produce working code.
— Reply to this email directly or view it on GitHub https://github.com/dbieber/audiorecorder/issues/11#issuecomment-81726754.
@pgee70 Nice, performs much faster and does create smaller files.
Suggestion: Use this for .chunk, performs better:
Array.prototype.chunk = function(chunkSize) {
var arr=this;
var R = [];
for (var i=0,len=arr.length; i<len; i+=chunkSize)
R.push(arr.slice(i,i+chunkSize));
return R;
}
I can't seem to extract working .speex data, or a valid speex file. I get garbled cut up audio as a file, and the .speex data doesn't work with .decode()
Alright, got it working after modifying worker.js AudioRecorder.playClip(Clip.createFromSamples(Codec.speex.decode(clips[0].speex[0],clips[0].speex[1]))). I've got the source files patched up, so I can probably send a pull request in a bit.
@pgee70 Would you happen to know how to resample and set to narrowband?
Thanks for the suggestion. I really should learn to prototype… there is just too much to learn…..
here is some of the code in my code that calls the audiorecorder.js it may help you. please don’t publish this. but you can use snippets to make your examples work.
here is an example of the fourier transformer working + the buttons in the code included.
On 17 Mar 2015, at 7:32 am, jhiswin notifications@github.com wrote:
@pgee70 https://github.com/pgee70 Performs much faster and does create smaller files.
Suggestion: Use this for .chunk, performs better than your custom function and speeds up emscripten code: Array.prototype.chunk = function(chunkSize) { var arr=this; var R = []; for (var i=0,len=arr.length; i<len; i+=chunkSize) R.push(arr.slice(i,i+chunkSize)); return R; }
I can't seem to extract working .speex data, or a valid speex file. I get garbled cut up audio as a file, and the .speex data doesn't work with .decode()
— Reply to this email directly or view it on GitHub https://github.com/dbieber/audiorecorder/issues/11#issuecomment-81922842.
ok, i didn’t use the play clip function. I just wanted to make a recorder, not a player…
No, I really don’t understand audio that well. It has been a struggle for me to get working what I have, with your help to guide me.
The other nights when I was testing it was so frustrating - it would record for 10 minutes, not 15, then 20 but not 30, then 30 but not 60. Each time was a different error, something failing because it couldn’t handle the amount of data. But after I got it to record for 60 minutes, post the data and download it again, it haven’t thought about it again…..
On 17 Mar 2015, at 8:51 am, jhiswin notifications@github.com wrote:
Alright, got it working after modifying worker.js AudioRecorder.playClip(Clip.createFromSamples(Codec.speex.decode(clips[0].speex[0],clips[0].speex[1]))). I've got the source files patched up, so I can probably send a pull request.
@pgee70 https://github.com/pgee70 Would you happen to know how to resample and set to narrowband?
— Reply to this email directly or view it on GitHub https://github.com/dbieber/audiorecorder/issues/11#issuecomment-81957278.
@pgee70 Another tip to speed it up if you target Firefox users. speex.min.js minifies the initializer, which prevents Firefox from recognizing and precompiling as asm.js. Make sure the section between "// EMSCRIPTEN_START_ASM" and "// EMSCRIPTEN_END_ASM" is pasted into the final file unminified.
Hi. Firstly thanks very much for putting this together. It was very helpful. I noted that in your demo you have a worker to compress the microphone stream into a speex format, but when you export as speex, you compressed the samples again. I was finding that this caused unnecessary delays in the saving process, so I tried to use the speex file that was being compressed on the worker's interval script, however i run into issues using it - the code did not work. I also found that the interval to set to process the Encoder was too low, resulting in poorly compressed audio, and Chrome at least was running into a problem creating the .ogg file in the .mux function where it was getting stack overflow errors for larger files caused by String.fromCharCode.apply not working properly. In larger files I found some bits of your code broke, so I rewrote them, I also managed the memory better by not storing the PCM recorded data after it had been compressed. I also added a little more padding at the end of the file to stop clipping of the audio.
In my implementation I used the AudioContext to drive other tools (like a visualiser) so I changed the constructor slightly. enc. are the files I modified for your perusal. hope it is of help to you. Using this code, I have been able to record for 60 minutes, to a 17.9MB file that has intelligible audio quality, suitable for transcription/notes.
in audiorecorder.js Ogg.prototype.mux = function (d, o) { function OggPageHeader(type, length, checksum, granulePos) { return page = { capturePattern: [0x4f, 0x67, 0x67, 0x53] , version: 0 , headerType: type , granulePos: granulePos || 0 , serial: 406 , sequence: 0 , checksum: checksum || 0 , pageSegments: 1 , segments: [ length || 0 ] , frames: "" }; }
// in worker.js .... // data page var data = d[2]; // this replaces the .chunk which fails in large file sizes. var segments = []; while ( data[1].length > 0 ){ b = Math.min(data[1].length,100); segments.push(data[1].splice(0,b)); } var stream = String.fromCharCode.apply(null, new Uint8Array(data[0].buffer)) , a = 0 , b = 0 , len = segments.length;