Chromium Code Reviews| Index: third_party/WebKit/ManualTests/webaudio/multichannel-mediastreamdestination.html |
| diff --git a/third_party/WebKit/ManualTests/webaudio/multichannel.html b/third_party/WebKit/ManualTests/webaudio/multichannel-mediastreamdestination.html |
| similarity index 78% |
| copy from third_party/WebKit/ManualTests/webaudio/multichannel.html |
| copy to third_party/WebKit/ManualTests/webaudio/multichannel-mediastreamdestination.html |
| index d5958520c2f0f8d65fea74e05c0e5347a6122a53..e108070b85e9203dae8b3f51b64b58f9fd6ae6e7 100644 |
| --- a/third_party/WebKit/ManualTests/webaudio/multichannel.html |
| +++ b/third_party/WebKit/ManualTests/webaudio/multichannel-mediastreamdestination.html |
| @@ -1,7 +1,7 @@ |
| <!doctype html> |
| <html> |
| <head> |
| - <title>Test multichannel support.</title> |
| + <title>Test multichannel support for MediaStreamDestination.</title> |
| <style type="text/css"> |
| body { |
| margin: 2em; |
| @@ -19,22 +19,20 @@ |
| </head> |
| <body> |
| - <h1>Test Multichannel Audio Output</h1> |
| + <h1>Test Multichannel Audio Output for MediaStreamDestination</h1> |
| - <p>Tests that multichannel audio output (> 8 channels) is working correctly. |
| - This test cannot be run with an offline audio context because it requires |
| - an actual audio hardware with the multichannel capability.</p> |
| + <p><strong>NOTE: This test requires HTTP server.</strong></p> |
| + |
| + <p>This test is for multichannel (> 2 channels) support for |
|
Raymond Toy
2015/11/20 14:47:18
Do you need to change ">" to ">"?
hongchan
2015/11/20 18:02:59
Although the DOM parser is smart enough to do this
|
| + MediaStreamDestination. This test cannot be run with an offline audio |
| + context because the node is not compatible with the offline context.</p> |
| <p>Press "Start Test Tone" to run the test. You should hear an one-second |
| sine tone from all the available audio output channels from the channel 1 |
| to the last channel.</p> |
| - <p>Note that this test only works on OSX because CoreAudio driver supports |
| - the multichannel streams (more than 2) on a single audio device whereas |
| - other platforms do not.</p> |
| - |
| - <p>CRBUG issue: <a href="https://code.google.com/p/chromium/issues/detail?id=424795" target="_blank"> |
| - 424795</a></p> |
| + <p>CRBUG issue: <a href="https://code.google.com/p/chromium/issues/detail?id=557185" target="_blank"> |
| + 557185</a></p> |
| <div class="manual-test-ui"> |
| <p>Max Channel Count: <span id="eMaxChannelCount">2</span></p> |
| @@ -48,7 +46,7 @@ |
| // The safe range for the equal loudness of sinusoid is roughly between |
| // 200 ~ 1000Hz, which is A3(57) ~ C6(84). In this test, the starting |
| - // pitch is 220Hz and the interval is the whole tone. (2 MIDI pitch) |
| + // pitch is 220Hz and the interval is the whole tone. (2 MIDI pitch) |
| // With 16 speakers, the last test tone will play the MIDI pitch of |
| // F6(89), which is 1396Hz. |
| var startMIDIPitch = 57; |
| @@ -58,18 +56,23 @@ |
| var eChannelIndex = document.querySelector('#eChannelIndex'); |
| var context = new AudioContext(); |
| + var mediaStreamDestination = context.createMediaStreamDestination(); |
| + |
| var maxChannelCount = context.destination.maxChannelCount; |
| - // Sets the destination properties for multichannel access. |
| - context.destination.channelCount = maxChannelCount; |
| - context.destination.channelCountMode = 'explicit'; |
| - context.destination.channelInterpretation = 'discrete'; |
| + // The maximum channel count of MediaStreamDestination is 8. |
| + mediaStreamDestination.channelCount = |
| + maxChannelCount < 8 ? maxChannelCount : 8; |
|
Raymond Toy
2015/11/20 14:47:18
I think this code would be more robust if you adde
hongchan
2015/11/20 18:02:59
Done.
|
| + |
| + var audioElement = new Audio(); |
| + audioElement.src = URL.createObjectURL(mediaStreamDestination.stream); |
| + audioElement.play(); |
| // The ChannelMerger for the individual channel access. |
| var merger = context.createChannelMerger(maxChannelCount); |
| merger.channelCountMode = 'explicit'; |
| merger.channelInterpretation = 'discrete'; |
| - merger.connect(context.destination); |
| + merger.connect(mediaStreamDestination); |
| eMaxChannelCount.textContent = maxChannelCount; |
| @@ -78,6 +81,9 @@ |
| return 440 * Math.pow(2, (midiPitch - 69) / 12); |
| } |
| + // A global storage to keep the OSC reference alive. |
| + var oscs = []; |
| + |
| // Play a test tone for the specified amount of duration at the channel. |
| function playTestToneAtChannel(channelIndex, gain, duration) { |
| var osc = context.createOscillator(); |
| @@ -99,7 +105,7 @@ |
| // The channel index starts from 1. |
| eChannelIndex.textContent = 'Channel #' + (channelIndex + 1); |
| - |
| + |
| var now = context.currentTime; |
| var toneDuration = duration - testToneInterval; |
| @@ -111,6 +117,10 @@ |
| osc.start(now); |
| osc.stop(now + duration); |
| + |
| + // Push osc to keep the reference alive. Otherwise |osc| will be |
| + // collected and the |onended| event won't be fired. |
|
Raymond Toy
2015/11/20 14:47:18
File a bug on this, and put a link to the bug here
hongchan
2015/11/20 18:02:59
Done.
https://code.google.com/p/chromium/issues/d
Raymond Toy
2015/11/30 18:06:09
Add link to this bug in the comments.
hongchan
2015/11/30 18:10:43
This bug is not directly related to this CL, so I
|
| + oscs.push(osc); |
| } |
| // When the button is clicked the button to produce the test sound, |
| @@ -120,7 +130,7 @@ |
| function startTestTones() { |
| eButton.disabled = true; |
| - // Math.SQRT1_2(=0.707..) is -3dB. This is necessary because 1.0 |
| + // Math.SQRT1_2(=0.707..) is -3dB. This is necessary because 1.0 |
| // amplitude can cause overload/distortion on some speakers. |
| playTestToneAtChannel(0, Math.SQRT1_2, 1.0); |
| } |