Code no longer crashes.
This commit is contained in:
parent
b507a9951a
commit
5e8158261f
|
|
@ -327,15 +327,19 @@ AudioEngine.prototype.getBuffersize = function() {
|
|||
};
|
||||
|
||||
AudioEngine.prototype.startRecording = function() {
|
||||
this.recording = true;
|
||||
if (!this.recording) {
|
||||
this.recording = true;
|
||||
}
|
||||
};
|
||||
|
||||
AudioEngine.prototype.stopRecording = function() {
|
||||
this.recording = false;
|
||||
this.recorder.saveRecording(0, "openwebrx.mp3");
|
||||
if (this.recording) {
|
||||
this.recording = false;
|
||||
this.recorder.saveRecording("openwebrx.mp3");
|
||||
}
|
||||
};
|
||||
|
||||
function AudioRecorder(samplerate, kbps) {
|
||||
function AudioRecorder(sampleRate, kbps) {
|
||||
// Mono (1 channel), with given sample rate and bitrate
|
||||
this.mp3encoder = new lamejs.Mp3Encoder(1, sampleRate, kbps);
|
||||
this.blockSize = 1152; // better be a multiple of 576
|
||||
|
|
@ -351,25 +355,24 @@ AudioRecorder.prototype.record = function(samples) {
|
|||
};
|
||||
|
||||
AudioRecorder.prototype.saveRecording = function(name) {
|
||||
// finish writing mp3
|
||||
var mp3buf = this.mp3encoder.flush();
|
||||
if (mp3buf.length>0) this.mp3Data.push(new Int8Array(mp3buf));
|
||||
|
||||
var blob = new Blob(this.mp3Data, {type: "audio/mp3"});
|
||||
this.mp3data = [];
|
||||
|
||||
var a = document.createElement("a");
|
||||
document.body.appendChild(a);
|
||||
a.href = window.URL.createObjectURL(blob);
|
||||
a.style = "display: none";
|
||||
a.download = name;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
|
||||
return function(data, name) {
|
||||
// finish writing mp3
|
||||
var mp3buf = this.mp3encoder.flush();
|
||||
if (mp3buf.length>0) this.mp3Data.push(new Int8Array(mp3buf));
|
||||
|
||||
var blob = new Blob(mp3Data, {type: "audio/mp3"}),
|
||||
var url = window.URL.createObjectURL(blob);
|
||||
|
||||
a.href = url;
|
||||
a.download = name;
|
||||
a.click();
|
||||
|
||||
window.URL.revokeObjectURL(url);
|
||||
this.mp3data = [];
|
||||
};
|
||||
setTimeout(function() {
|
||||
document.body.removeChild(a);
|
||||
window.URL.revokeObjectURL(a.href);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
function ImaAdpcmCodec() {
|
||||
|
|
|
|||
|
|
@ -305,4 +305,3 @@ ia.IXMAX_VAL=8206;var sa={};sa.SFBMAX=3*c.SBMAX_s;c.ENCDELAY=576;c.POSTDELAY=115
|
|||
4,!0);break;default:throw"extended fmt chunk not implemented";}w+=u;u=Fa.data;for(var B=0;u!=n;){n=c.getUint32(w,!1);B=c.getUint32(w+4,!0);if(u==n)break;w+=B+8}k.dataLen=B;k.dataOffset=w+8;return k}};sa.SFBMAX=3*c.SBMAX_s;lamejs.Mp3Encoder=function(c,k,n){3!=arguments.length&&(console.error("WARN: Mp3Encoder(channels, samplerate, kbps) not specified"),c=1,k=44100,n=128);var u=new W,w=new Kc,B=new Y,G=new qa,f=new wc,b=new ia,v=new Ec,a=new zb,m=new mc,z=new Nc,e=new xc,l=new qb,d=new Lc,g=new Mc;
|
||||
u.setModules(B,G,f,b,v,a,m,z,g);G.setModules(B,g,m,a);z.setModules(G,m);f.setModules(u);v.setModules(G,e,b,l);b.setModules(l,e,u.enc.psy);e.setModules(G);l.setModules(b);a.setModules(u,G,m);w.setModules(d,g);d.setModules(m,z,f);var q=u.lame_init();q.num_channels=c;q.in_samplerate=k;q.brate=n;q.mode=la.STEREO;q.quality=3;q.bWriteVbrTag=!1;q.disable_reservoir=!0;q.write_id3tag_automatic=!1;u.lame_init_params(q);var D=1152,p=0|1.25*D+7200,r=new Int8Array(p);this.encodeBuffer=function(a,b){1==c&&(b=a);
|
||||
a.length>D&&(D=a.length,p=0|1.25*D+7200,r=new Int8Array(p));a=u.lame_encode_buffer(q,a,b,a.length,r,0,p);return new Int8Array(r.subarray(0,a))};this.flush=function(){var a=u.lame_encode_flush(q,r,0,p);return new Int8Array(r.subarray(0,a))}};lamejs.WavHeader=Fa}lamejs();
|
||||
kiwi_check_js_version.push({ VERSION_MAJ:1, VERSION_MIN:577, file:'/root/kiwi.config/lame.min.js' });
|
||||
|
|
|
|||
|
|
@ -78,6 +78,14 @@ function toggleNR() {
|
|||
nr_changed();
|
||||
}
|
||||
|
||||
function toggleRecording() {
|
||||
if (audioEngine.recording) {
|
||||
audioEngine.stopRecording();
|
||||
} else {
|
||||
audioEngine.startRecording();
|
||||
}
|
||||
}
|
||||
|
||||
function zoomInOneStep() {
|
||||
zoom_set(zoom_level + 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue