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

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

+ +
+

{{ domxref("AudioBuffer") }}インターフェースのsampleRateプロパティは、バッファに格納されたPCMデータの1秒あたりのサンプル数を、サンプルレートとしてfloatで返します。

+
+ +

構文

+ +
var myArrayBuffer = audioCtx.createBuffer(2, frameCount, audioCtx.sampleRate);
+myArrayBuffer.sampleRate;
+ +

+ +

float

+ +

+ +
// ステレオ
+var channels = 2;
+
+// AudioContextのサンプルレートで2秒間の空のステレオバッファを生成する
+var frameCount = audioCtx.sampleRate * 2.0;
+var myArrayBuffer = audioCtx.createBuffer(2, frameCount, audioCtx.sampleRate);
+
+button.onclick = function() {
+  // バッファにホワイトノイズを書き込む;
+  // 単なる-1.0から1.0の間の乱数の値である
+  for (var channel = 0; channel < channels; channel++) {
+    // 実際のデータの配列を得る
+    var nowBuffering = myArrayBuffer.getChannelData(channel);
+    for (var i = 0; i < frameCount; i++) {
+      // Math.random()は[0; 1.0]である
+      // 音声は[-1.0; 1.0]である必要がある
+      nowBuffering[i] = Math.random() * 2 - 1;
+    }
+  }
+
+  console.log(myArrayBuffer.sampleRate);
+}
+ +

仕様

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Audio API', '#widl-AudioBuffer-sampleRate', 'sampleRate')}}{{Spec2('Web Audio API')}} 
+ +

ブラウザ互換性

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support14 {{property_prefix("webkit")}}23{{CompatNo}}15 {{property_prefix("webkit")}}
+ 22 (unprefixed)
6 {{property_prefix("webkit")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChromeFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support{{CompatNo}}28 {{property_prefix("webkit")}}251.2{{CompatNo}}{{CompatNo}}6 {{property_prefix("webkit")}}
+
+ +

参考

+ + -- cgit v1.2.3-54-g00ecf