aboutsummaryrefslogtreecommitdiff
path: root/files/pl/web/api/audioparam/setvalueattime/index.html
blob: 7d733e7b2b85d8c8b01cab60d2a36bb272c676cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
---
title: AudioParam.setValueAtTime()
slug: Web/API/AudioParam/setValueAtTime
tags:
  - API
  - AudioParam
  - Metodă
  - Referencja
  - Web Audio API
  - setValueAtTime
translation_of: Web/API/AudioParam/setValueAtTime
---
<p>{{ APIRef("Web Audio API") }}</p>

<div>
<p>Metoda <code>setValueAtTime()</code> interfejsu {{ domxref("AudioParam") }} odpowiada za precyzyjne przyporządkowanie nagłych zmian do wartości {{domxref("AudioParam")}} w określonym czasie względem {{domxref("AudioContext.currentTime")}}. Nowa wartość zostaje podana w wartości parametru.</p>
</div>

<h2 id="Składnia">Składnia</h2>

<pre class="syntaxbox">var AudioParam = AudioParam.setValueAtTime(<em>value</em>, <em>startTime</em>)</pre>

<h3 id="Parametry">Parametry</h3>

<dl>
 <dt>value</dt>
 <dd>Liczba zmiennoprzecinkowa reprezentująca wartość <code>AudioParam</code> przyporządkuje się do podanego czasu.</dd>
 <dt>startTime</dt>
 <dd>Zmienna <code>double </code>reprezentująca czas (w sekundach) po {{ domxref("AudioContext") }} została utworzona jako pierwsza, dzięki czemu dochodzi do zmiany wartości. {{jsxref("TypeError")}} zostanie zwrócony, jeśli uzyskana wartość jest negatywna.</dd>
</dl>

<h3 id="Zwracanie_wartości_funkcji_(return)">Zwracanie wartości funkcji (return)</h3>

<p>Odnośnik do obiektu <code>AudioParam</code>. W niektórych przeglądarkach wprowadzenie tego interfejsu zaskutkuje zwróceniem pustego typu danych (<code>void</code>).</p>

<h2 id="Przykłady">Przykłady</h2>

<p>Ten stosunkowo prosty przykład zawiera źródło mediaelementu z dwiema kontrolkami (sprawdź kod źródłowy poprzez nasze <a href="https://github.com/mdn/audio-param">repo audio-param</a> lub <a href="http://mdn.github.io/audio-param/">zobacz przykład live</a>). Jeśli kontrolki są wciśnięte, zmienna <code>currGain</code> jest inkrementowana/dekrementowana o 0.25. Wówczas metoda <code>setValueAtTime() </code>zostaje użyta do ustawienia wartości przedwzmacniacza (gain) jako równej currGain, jedną sekundę od teraz (audioCtx.currentTime + 1).</p>

<pre class="brush: js;highlight[32,37]">// utworzenie kontekstu audio
var AudioContext = window.AudioContext || window.webkitAudioContext;
var audioCtx = new AudioContext();

// podanie podstawowych zmiennych dla przykładu
var myAudio = document.querySelector('audio');
var pre = document.querySelector('pre');
var myScript = document.querySelector('script');

pre.innerHTML = myScript.innerHTML;

var targetAtTimePlus = document.querySelector('.set-target-at-time-plus');
var targetAtTimeMinus = document.querySelector('.set-target-at-time-minus');

// utworzenie MediaElementAudioSourceNode
// wprowadzenie HTMLMediaElement
var source = audioCtx.createMediaElementSource(myAudio);

// utworzenie parametrów <span class="st">przedwzmacniacz</span>a (gain node) i ustawienie wartości przedwzmacniacza na wartość 0.5
var gainNode = audioCtx.createGain();
gainNode.gain.value = 0.5;
var currGain = gainNode.gain.value;

// podłączenie AudioBufferSourceNode do gainNode
// oraz gainNode do destynacji
source.connect(gainNode);
gainNode.connect(audioCtx.destination);

// określenie, co ma się wykonać po kliknięciu
targetAtTimePlus.onclick = function() {
  currGain += 0.25;
  gainNode.gain.setValueAtTime(currGain, audioCtx.currentTime + 1);
}

targetAtTimeMinus.onclick = function() {
  currGain -= 0.25;
  gainNode.gain.setValueAtTime(currGain, audioCtx.currentTime + 1);
}</pre>

<h2 id="Specyfikacje">Specyfikacje</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specifikacja</th>
   <th scope="col">Status</th>
   <th scope="col">Komentarz</th>
  </tr>
  <tr>
   <td>{{SpecName('Web Audio API', '#widl-AudioParam-setValueAtTime-void-float-value-double-startTime', 'setValueAtTime')}}</td>
   <td>{{Spec2('Web Audio API')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="Zgodność_z_przeglądarkami">Zgodność z przeglądarkami</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Cecha</th>
   <th>Chrome</th>
   <th>Edge</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Wsparcie podstawowe</td>
   <td>{{CompatChrome(14)}} {{property_prefix("webkit")}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>23</td>
   <td>{{CompatNo}}</td>
   <td>15 {{property_prefix("webkit")}}<br>
    22 (unprefixed)</td>
   <td>6 {{property_prefix("webkit")}}</td>
  </tr>
  <tr>
   <td>Bez prefiksu</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Cecha</th>
   <th>Android</th>
   <th>Android Webview</th>
   <th>Edge</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>Wsparcie podstawowe</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>25</td>
   <td>1.2</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{property_prefix("webkit")}}</td>
   <td>{{CompatChrome(28)}} {{property_prefix("webkit")}}</td>
  </tr>
  <tr>
   <td>Bez prefiksu</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="Zobacz_również">Zobacz również</h2>

<ul>
 <li><a href="/en-US/docs/Web_Audio_API/Using_Web_Audio_API">Używanie Web Audio API</a></li>
</ul>