Javascript 使用soundtouch js在多声道模式下进行音调偏移
我正在使用soundtouch库对音频文件进行一些音调转换。lib可以很好地进行音调转换,但我不知道如何控制音频文件的频道来打开/关闭它们 我在跟踪这支钢笔Javascript 使用soundtouch js在多声道模式下进行音调偏移,javascript,soundtouch,Javascript,Soundtouch,我正在使用soundtouch库对音频文件进行一些音调转换。lib可以很好地进行音调转换,但我不知道如何控制音频文件的频道来打开/关闭它们 我在跟踪这支钢笔 var源={ 摘录:函数(目标、numFrames、位置){ $(“#当前时间”).html(minsSecs(position/(context.sampleRate)); log('width:',100*位置/(bufferDuration*context.sampleRate)); $(“#进度”).width(100*positi
var源={
摘录:函数(目标、numFrames、位置){
$(“#当前时间”).html(minsSecs(position/(context.sampleRate));
log('width:',100*位置/(bufferDuration*context.sampleRate));
$(“#进度”).width(100*position/(bufferDuration*context.sampleRate)+“%”;
if(Math.round(100*position/(bufferDuration*context.sampleRate))==100&&U正在播放){
//停止记录器
记录器(&R)记录器停止();
__日志(“记录完成”);
//使用音频数据块创建WAV下载链接
createDownloadLink();
if(记录器类型!=“未定义”){
记录器。清除();
}
正在播放=错误;
}
var l=缓冲区。getChannelData(0);
如果(buffer.numberofChannels>1){
var r=buffer.getChannelData(1);
}否则{
var r=buffer.getChannelData(0);
}
对于(变量i=0;i
有什么帮助吗?首先,我有一个电话。可能会让你的黑客行为变得更容易
其次,您可能希望将连接的音频上下文附加到。我还没有玩过这个,但我认为这就是你需要独立控制每个通道的增益。同样,我也在猜测,但希望这会将您推向正确的方向。谢谢您的回复,我对库做了一些修改,以支持多通道而不是双通道channel@Ahmedezzat那太好了。你应该提交一份公关。
var source = {
extract: function (target, numFrames, position) {
$("#current-time").html(minsSecs(position / (context.sampleRate)));
console.log('width: ', 100 * position / (bufferDuration * context.sampleRate));
$("#progress").width(100 * position / (bufferDuration * context.sampleRate) + "%");
if (Math.round(100 * position / (bufferDuration * context.sampleRate)) == 100 && is_playing) {
//stop recorder
recorder && recorder.stop();
__log('Recording complete.');
// create WAV download link using audio data blob
createDownloadLink();
if (typeof recorder != "undefined") {
recorder.clear();
}
is_playing = false;
}
var l = buffer.getChannelData(0);
if (buffer.numberofChannels > 1) {
var r = buffer.getChannelData(1);
} else {
var r = buffer.getChannelData(0);
}
for (var i = 0; i < numFrames; i++) {
target[i * 2] = l[i + position];
target[i * 2 + 1] = r[i + position];
}
return Math.min(numFrames, l.length - position);
}
};
node.onaudioprocess = function (e) {
if (buffer.getChannelData) {
pos += BUFFER_SIZE / context.sampleRate;
console.log('position: ', pos);
var l = e.outputBuffer.getChannelData(0);
var r = e.outputBuffer.getChannelData(1);
var framesExtracted = f.extract(samples, BUFFER_SIZE);
if (framesExtracted == 0) {
node.disconnect();
}
for (var i = 0; i < framesExtracted; i++) {
l[i] = samples[i * 2];
r[i] = samples[i * 2 + 1];
}
leftchannel.push(new Float32Array(l));
rightchannel.push(new Float32Array(r));
recordingLength += BUFFER_SIZE;
}
};