Skip to content

Commit 2c85ee7

Browse files
author
Joe Szynal
committed
StereoAudioRecorder: assigning sample rate from AudioContext
1 parent 17fff6a commit 2c85ee7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

AudioStreamRecorder/StereoAudioRecorder.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@
44
// source code from: http://typedarray.org/wp-content/projects/WebAudioRecorder/script.js
55

66
function StereoAudioRecorder(mediaStream, root) {
7-
// variables
7+
8+
// variables
9+
var deviceSampleRate = 44100; // range: 22050 to 96000
10+
11+
// check device sample rate
12+
if(window.AudioContext){
13+
deviceSampleRate = (new window.AudioContext()).sampleRate;
14+
}
15+
816
var leftchannel = [];
917
var rightchannel = [];
1018
var scriptprocessornode;
1119
var recording = false;
1220
var recordingLength = 0;
1321
var volume;
1422
var audioInput;
15-
var sampleRate = root.sampleRate || 44100; // range: 22050 to 96000
23+
var sampleRate = root.sampleRate || deviceSampleRate;
1624
var audioContext;
1725
var context;
1826

0 commit comments

Comments
 (0)