9.
• Background music
• audio to Web Audio API
• Sound effects
• 3D Positional sound : AudioPannerNode
• Room effects and filters : ConvolverNode
• Detect clipping : JavaScriptNode
5. Somethig more
• Automation
• Oscillator
• 몇
379. 제공한다.
à hp://www.w3.org/TR/webaudio/#AudioParam
interface AudioParam {
attribute float value;
readonly attribute float defaultValue;
// Parameter automation.
void setValueAtTime(float value, double startTime);
void linearRampToValueAtTime(float value, double endTime);
void exponentialRampToValueAtTime(float value, double endTime);
// Exponentially approach the target value with a rate having the given time constant.
void setTargetAtTime(float target, double startTime, double timeConstant);
// Sets an array of arbitrary parameter values starting at time for the given duration.
// The number of values will be scaled to fit into the desired duration.
void setValueCurveAtTime(Float32Array values, double startTime, double duration);
// Cancels all scheduled parameter changes with times greater than or equal to startTime.
void cancelScheduledValues(double startTime);
};
인터페이스
563. 가능하다.
var audioElement = document.querySelector('audio');
var mediaSourceNode = context.createMediaElementSource(audioElement);
mediaSourceNode.connect(context.destination);
audioElement.play();
§ createAnalyser() creates a RealtimeAnalyserNode which provide real-time frequency and time-
domain analysis information.
à context.createAnalyser()를
616. 있다.
// currentTime은 컨텍스트가 생성된 시점을 기준으로 0의 값으로 시작하며, 실시간 증가되는 값이다.
var time = context.currentTime;
for (var i = 0; i rounds; i++) {
var source = AudioBufferSource;
source.start(time + i * interval);
}
Sound effects : 재생
642. 한다.
var panner = context.createPanner();
// Directional model
panner.coneOuterGain = 0.5;
panner.coneOuterAngle = 180;
panner.coneInnerAngle = 0;
// Position, orientaion and velocity
panner.setPosition(x, y, z); // 3D cartesian coordinate relative to the listener attribute
panner.setOrientation(x, y, z); // pointing in the 3D cartesian coordinate space
panner.setVelocity(x, y, z); // direction of travel and the speed in 3D space
source.connect(panner);
panner.connect(context.destination);
3D Positional sound
694. 있다.
var source = context.createBufferSource();
source.buffer = AudioBufferSource;
var convolver = context.createConvolver();
convolver.buffer = AudioBufferSource; // 임펄스 데이터
source.connect(convolver);
convolver.connect(context.destination);
Room effects and filters
731. 한다.
var meter = context.createScriptProcessor(
buffer_size,
number_input_channel,
number_output_channel
);
meter.onaudioprocess = function(e) {
…
}
Detect clipping
732. // Assume entire sound output is being piped through the mix node.
var mix = context.createGain();
var meter = context.createScriptProcessor(2048, 1, 1);
// Porcess audio event binding
meter.onaudioprocess = function (e) {
var leftBuffer = e.inputBuffer.getChannelData(0);
var rightBuffer = e.inputBuffer.getChannelData(1);
checkClipping(leftBuffer);
checkClipping(rightBuffer);
};
mix.connect(meter);
meter.connect(context.destination);
mix.connect(context.destination);
// Check if buffer exceeds
function checkClipping(buffer) {
var isClipping = false;
// Iterate through buffer to check if any of the |values| exceeds 1.
for (var i = 0; i buffer.length; i++) {
var absValue = Math.abs(buffer[i]);
if (absValue = 1) {
isClipping = true;
break;
}
}
}
Detect clipping
751. 있다.
var now = context.currentTime;
//
지정된 시간에 특정 값을 갖도록 한다.
source.gain.setValueAtTime(0,
now);
//
특정 시간까지 값을 리니어하게 변경하도록 스케줄링 한다.
source.gain.linearRampToValueAtTime(1.0,
now
+
value);
source.gain.linearRampToValueAtTime(0.0,
now
+
value);
Automation
792. § AnalyserNode
à can be used to expose audio time and frequency data and create data visualisations.
§ WaveShaperNode
à
AudioNode
processor
implemen?ng
non-‐linear
distor?on
effects.
§ AudioChannelSplitter / AudioChannelMerger
More AudioNodes
More
Nodes
:
hps://developer.mozilla.org/en-‐US/docs/Web/API/Web_Audio_API#Web_Audio_API_Interfaces
793. § Firefox Web Audio Editor
à https://developer.mozilla.org/en-US/docs/Tools/Web_Audio_Editor
§ Web Audio API Editor Extension for Google Chrome
à https://github.com/spite/WebAudioExtension
개발도구
794. § Web Audio API Book
à http://chimera.labs.oreilly.com/books/1234000001552/index.html
§ Building a musical instrument with the Web Audio API
à https://www.youtube.com/watch?v=56spBAgOYfg
§ Getting started with Web Audio API
à http://www.html5rocks.com/en/tutorials/webaudio/intro/
§ W3C Web Audio Demo List
à http://webaudio.github.io/demo-list/
§ Web Audio Demos
à
795. http://webaudiodemos.appspot.com/
§ Web Audio Weekly
à http://blog.chrislowis.co.uk/waw.html
§ Synthesising Drum Sounds with the Web Audio API
à https://dev.opera.com/articles/drum-sounds-webaudio/
§ Web Audio Conference 2015
à http://wac.ircam.fr/program.html
§ Developing Game Audio with the Web Audio API
à http://www.html5rocks.com/en/tutorials/webaudio/games/
Reference