--- title: AudioBuffer.copyToChannel() slug: Web/API/AudioBuffer/copyToChannel translation_of: Web/API/AudioBuffer/copyToChannel ---

{{ APIRef("Web Audio API") }}

{{ domxref("AudioBuffer") }}インターフェースのcopyToChannel()メソッドは、配列から指定のAudioBufferのチャンネルへとコピーします。

構文

myArrayBuffer.copyToChannel(source, channelNumber, startInChannel);

引数

source
コピー元の{{jsxref("Float32Array")}}
channelNumber
コピー先のチャンネル番号。もし、channelNumberが{{domxref("AudioBuffer.numberOfChannels")}}以上ならば、INDEX_SIZE_ERR例外が発生する。
startInChannel {{optional_inline}}
(任意) コピー先のオフセット位置。もし、startInChannelが{{domxref("AudioBuffer.length")}}を超えていれば、INDEX_SIZE_ERR例外が発生する。

var myArrayBuffer = audioCtx.createBuffer(2, frameCount, audioCtx.sampleRate);
var anotherArray = new Float32Array;
// myArrayBufferの2番目のチャンネルからコピーする
myArrayBuffer.copyFromChannel(anotherArray,1,0);
// anotherArrayから、myArrayBufferの1番目のチャンネルにコピーする。これで2つのチャンネルのデータは同じになる
myArrayBuffer.copyToChannel (anotherArray,0,0);

仕様

Specification Status Comment
{{SpecName('Web Audio API', '#widl-AudioBuffer-copyToChannel-void-Float32Array-source-long-channelNumber-unsigned-long-startInChannel', 'copyToChannel')}} {{Spec2('Web Audio API')}}  

ブラウザ互換性

{{Compat("api.AudioBuffer.copyToChannel")}}

参考