From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- files/ko/web/api/audiobuffer/index.html | 172 ++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 files/ko/web/api/audiobuffer/index.html (limited to 'files/ko/web/api/audiobuffer') diff --git a/files/ko/web/api/audiobuffer/index.html b/files/ko/web/api/audiobuffer/index.html new file mode 100644 index 0000000000..8c5e1a8736 --- /dev/null +++ b/files/ko/web/api/audiobuffer/index.html @@ -0,0 +1,172 @@ +--- +title: AudioBuffer +slug: Web/API/AudioBuffer +translation_of: Web/API/AudioBuffer +--- +

{{APIRef}}

+
+

AudioBuffer는 {{ domxref("AudioContext.decodeAudioData()") }} 혹은 {{ domxref("AudioContext.createBuffer()") }}를 통해 만들어진 로우 데이터를 메모리상에 두고 사용하는 기술이다. 일단 한번 AudioBuffer 에 들어간 정보는 {{ domxref("AudioBufferSourceNode") }}를 통해 재생이 가능하다.

+

이 객체는 일반적으로 45초 이하의 오디오 정보를 가지고 있다. 더 긴 시간의 소리정보는 {{domxref("MediaElementAudioSourceNode")}}를 사용하는 것이 더 적합하다.  The buffer contains data in the following format:  non-interleaved IEEE754 32-bit linear PCM with a nominal range between -1 and +1, that is, 32bits floating point buffer, with each samples between -1.0 and 1.0.  만약에  {{domxref("AudioBuffer")}} 가 멀티 채널을 가진다면 이는 버퍼를 나눠서 저장을 합니다.

+
+

Properties

+
+
+ {{domxref("AudioBuffer.sampleRate")}} {{readonlyInline}}
+
+ 버퍼에 저장된 샘플정보의 매 초당 배율을 float형으로 리턴한다.
+
+ {{domxref("AudioBuffer.length")}} {{readonlyInline}}
+
+ 샘플프레임안의 버퍼에 저장된 PCM정보의 길이를 정수형으로 리턴한다.
+
+ {{domxref("AudioBuffer.duration")}} {{readonlyInline}}
+
+ 버퍼에 저장된 PCM정보의 재생길이를 double형으로 리턴한다.
+
+ {{domxref("AudioBuffer.numberOfChannels")}} {{readonlyInline}}
+
+ 버퍼에 저장된 PCM정보에 의해 구분된 채널의 갯수를 정수형으로 리턴한다.
+
+

Methods

+
+
+ {{domxref("AudioBuffer.getChannelData()")}}
+
+ {{jsxref("Float32Array")}}에 담긴 PCM데이터와 channel 파라메로 정의된 채널 정보(첫번째 채널은 0)를 리턴한다.
+
+ {{domxref("AudioBuffer.copyFromChannel()")}}
+
+ 특정 채널의 AudioBuffer를 destination배열로 복사를 한다.
+
+ {{domxref("AudioBuffer.copyToChannel()")}}
+
+ 특정 채널의 AudioBuffer에 source배열로 부터 정보를 복사해 온다.
+
+

Example

+

이 예제는 어떻게 AudioBuffer 를 생성하고 랜덤한 화이트 노이즈를 채우는 방법을 설명한다.  audio-buffer demo 에서 전체 소스를 확인 가능하고 running live 실시간 테스트고 가능하다.

+
// Stereo
+var channels = 2;
+
+// Create an empty two second stereo buffer at the
+// sample rate of the AudioContext
+var frameCount = audioCtx.sampleRate * 2.0;
+var myArrayBuffer = audioCtx.createBuffer(channels, frameCount, audioCtx.sampleRate);
+
+button.onclick = function() {
+  // Fill the buffer with white noise;
+  // just random values between -1.0 and 1.0
+  for (var channel = 0; channel < channels; channel++) {
+    // This gives us the actual array that contains the data
+    var nowBuffering = myArrayBuffer.getChannelData(channel);
+    for (var i = 0; i < frameCount; i++) {
+      // Math.random() is in [0; 1.0]
+      // audio needs to be in [-1.0; 1.0]
+      nowBuffering[i] = Math.random() * 2 - 1;
+    }
+  }
+
+  // Get an AudioBufferSourceNode.
+  // This is the AudioNode to use when we want to play an AudioBuffer
+  var source = audioCtx.createBufferSource();
+
+  // set the buffer in the AudioBufferSourceNode
+  source.buffer = myArrayBuffer;
+
+  // connect the AudioBufferSourceNode to the
+  // destination so we can hear the sound
+  source.connect(audioCtx.destination);
+
+  // start the source playing
+  source.start();
+
+}
+
+

Specification

+ + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Audio API', '#the-audiobuffer-interface', 'AudioBuffer')}}{{Spec2('Web Audio API')}}Initial definition.
+

Browser compatibility

+
+ {{CompatibilityTable}}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support14 {{property_prefix("webkit")}}{{CompatGeckoDesktop(25)}}{{CompatNo}}15 {{property_prefix("webkit")}}
+ 22 (unprefixed)
6 {{property_prefix("webkit")}}
copyFromChannel() and copyToChannel(){{CompatUnknown}}{{CompatGeckoDesktop(27)}}{{CompatNo}}{{CompatUnknown}}{{CompatUnknown}}
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChromeFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support{{CompatNo}}28 {{property_prefix("webkit")}}{{CompatGeckoMobile(25)}}1.2{{CompatNo}}{{CompatNo}}6 {{property_prefix("webkit")}}
copyFromChannel() and copyToChannel(){{CompatNo}}{{CompatUnknown}}{{CompatGeckoMobile(27)}} {{CompatNo}}{{CompatNo}}{{CompatUnknown}}
+
+

See also

+ -- cgit v1.2.3-54-g00ecf