Recent Posts
Search Topic
Web Audio DAW, abbreviates as WAD. It is an audio manipulator library based on WA API. It greatly simplifies the process of creating, playing, and manipulating audio. It also has support for sprites, various custom-defined FX, microphone input. This library works in any browser that supports the Web Audio API. It audio input and attempt to determine the frequency and note name of the source.

To use WadJS in your project, simply include the script in your HTML file.
<script src="https://unpkg.com/web-audio-daw"></script>WadJS is also available as an npm module.
npm install web-audio-daw
import Wad from 'web-audio-daw';Panning
Wad supports two types of panning: stereo-panning, and 3d-panning. Stereo-panning works simply by specifying the left/right balance of the sound using a number between 1 and -1. Here a value of 1 means the sound is panned hard-right, and a value of -1 means the sound is panned hard-left.
In 3d-panning, directly setting the left/right stereo balance is not possible. It shows the distance of the sound source from the audio listener. Any time you would pass in a panning parameter (either to the constructor, the play() method, or the setPanning() method), you can pass it in as a three element array to specify the X, Y, and Z location of the sound. You can set the panning to arbitrarily high or low values, but it will make the sound very quiet, since it’s very far away. Here two different panning models are available using 3d-panning. The HRTF panning model is higher quality, but the equal power panning model is more performant. Mostly equal power panning model used in practice.
var saw = new Wad({
source : ‘sawtooth’,
panning : [0, 1, 10],
panningModel : ‘HRTF’,
rolloffFactor : 1 // other properties of the panner node can be specified in the constructor, or on play()
})
Filters
The filter constructor argument can be passed an object or an array of objects. If an array is passed, the filters are applied in that order. Whichever form is passed to the constructor should also be passed to the play argument.
play() method on that Wad. To terminate the method thestop() method on a microphone Wad to disconnect your microphone from that Wad. Microphone input needs headphones otherwise problem will occur.
var voice = new Wad({ source : 'mic', reverb : { wet : .4 },
filter : { type : 'highpass', frequency : 500 },
panning : -.2 })
// You must give your browser permission to use your microphone before calling play().
voice.play()
Configuring Reverb
Server needs to send impulse response to use reverb. This type of response is a small audio file like a wav or mp3, that shows the acoustic characteristics along with physical space. Online response can be self created though it is created in online.
Audio Sprites
When many short audio clips are included loading them as a single, longer audio clip, and play sections from that longer clip as needed. It will enhance the level of performance.
Logging
WadJS can log various warnings and notices to the console, but these are totally optional. To view these messages in the console, you can increase Wad’s verbosity.
Wad.logs.verbosity = 0 // WadJS will print nothing to your console. This is the default setting. Wad.logs.verbosity = 1 // View some notices and warnings, e.g. audio context started, midi devices connected, //etc. These logs should not print more than once. Wad.logs.verbosity = 2 // View all notices and warnings, including those from play() and stop(). //These logs might print many times.
Sound Iterator
The SoundIterator object is used for playing sounds in a random order or repeatedly through a loop. It is good for footstep sounds, for example.
The methods are:
iterator.play(args) // Plays the next sound in the list, or next random sound following the random rules. //The passed args are the normal args that can be passed to Wad.play(). The function returns a Promise. iterator.add(sound) // Pass in either a Wad object or an object that would be passed as a source in a new Wad. //It returns the SoundIterator object to be chained. iterator.remove(sound) // pass in the Wad instance you want to have removed from the iterator. //Only Wad objects that were added as Wad objects can be removed.
Tuna Effects
Tuna, everyone’s favorite Web Audio effects library, is included in WadJS. This makes it super easy to add effects from Tuna to any Wad or PolyWad.
Audio Listener
WadJS wraps the AudioListener to provide uniformity across browsers. The AudioListener is only useful when using 3D panning.Though both can be used to influence the listeners. The default position and orientation is: positionX=0, positionY=0, positionZ=0, forwardX=0, forwardY=0, forwardZ=-1, upX=0, upY=1, upZ=0.
listener.positionX.value.Play Labels
When you call stop() on a Wad, it will only stop the most recently triggered note. If you want to retain control over multiple notes that played from the same Wad, you can label those notes when play() is called. When stop() is called, you can pass in a label argument to stop all currently sustained notes with that label.
saw.play({pitch : 'A4', label : 'A4'}) // The label can be any string, //but using the same name as the note is often sensible. saw.play({pitch : 'G4', label : 'G4'}) saw.stop('A4') // The first note will stop, but the second note will continue playing.
External FX
Sometimes you might want to incorporate external libraries into Wad, for example FX or visualizers. You can override the constructExternalFx and setUpExternalFxOnPlay methods to add those nodes to the wad chain. In the following example the values are hardcoded, but they could easily have been passed as arguments to play.
Presets
If you’d like to use a pre-configured Wad, check out the presets. They should give you a better idea of the sorts of sounds that you can create with WadJS. For example, you can create a Wad using the preset ‘hiHatClosed’ like this:
var hat = new Wad(Wad.presets.hiHatClosed);PolyWads
In many cases, it is useful to group multiple Wads together. This can be accomplished with a PolyWad, a multi-purpose object that can store other Wads and PolyWads. There are two main cases where you might want to group several Wads together. One case is when you want to make a complex instrument that uses multiple oscillators. Other audio synthesis programs often have instruments that combine multiple oscillators, with names like ‘TripleOscillator’ or ‘3xOSC’.
var sine = new Wad({ source : 'sine' }) var square = new Wad({ source : 'square' }) var triangle = new Wad({ source : 'triangle' }) var tripleOscillator = new Wad.Poly() tripleOscillator.add(sine).add(square).add(triangle) // Many methods are chainable for convenience. tripleOscillator.play({ pitch : 'G#2'}) tripleOscillator.setVolume(.5) tripleOscillator.stop() // play(), stop(), and various setter methods can be called on a PolyWad just as they would be called on a regular Wad. tripleOscillator.remove(triangle) // It's really just a double-oscillator at this point.
The second main case in which you would want to group several Wads together is to make a mixer track, where several Wads share a set of effects and filters.
var mixerTrack = new Wad.Poly({
filter : {
type : 'lowpass',
frequency : 700,
q : 3
},
panning : 1
})mixerTrack.add(tripleOscillator).add(triangle)Compression
Rich or modern sound needs to compress the range of a song. A compressor can modify the song according to choices.
var compressor = new Wad.Poly({
compressor : {
attack : .003 // The amount of time, in seconds, to reduce the gain by 10dB. //This parameter ranges from 0 to 1.
knee : 30 // A decibel value representing the range above the threshold where the curve smoothly transitions to the "ratio" portion. This parameter ranges from 0 to 40.
ratio : 12 // The amount of dB change in input for a 1 dB change in output. This parameter ranges from 1 to 20.
release : .25 // The amount of time (in seconds) to increase the gain by 10dB. This parameter ranges from 0 to 1.
threshold : -24 // The decibel value above which the compression will start taking effect. This parameter ranges from -100 to 0.
}
})Recording
PolyWads can be created with a recorder, which can save the output of the PolyWad to an audio file.
Audio Meter
When voice is clipping an audio meter can make you aware of it, helps the volume level of Poly WAD’s output. The creation of PolyWADs automatically create audio meter.
Pitch Detection
PolyWads can detect the frequency of their input.
MIDI Input
WadJS can read MIDI data from MIDI instruments and controllers, and you can set handlers to respond to that data. When WadJS initializes, it tries to automatically detect any connected MIDI devices, and creates a reference to it in the array Wad.midiInputs. To handle MIDI data, assign a MIDI handler function to a MIDI device’s onmidimessage property. By default, Wad is configured to log MIDI messages to the console, which should be sufficient if you are quickly testing your devices. If you want to quickly set up a MIDI keyboard to play a Wad, assign a Wad of your choice (or any object with play() and stop() methods) to Wad.midiInstrument.
Wad.midiInstrument = new Wad({source : 'sine'});
If you want to get creative with how WadJS handles MIDI data, I strongly encourage you to write your own MIDI handler functions. For example, note-on velocity (how hard you press a key when playing a note) usually modulates the volume of a note, but it might sound interesting if you configure note-on velocity to modulate the attack or filter frequency instead.
If you have multiple MIDI devices that you would like to use simultaneously, you will need multiple MIDI handler functions. The second argument to Wad.assignMidiMap is used to specify the index of the MIDI device you would like to assign to.
Wad.assignMidiMap can also accept success and failure callbacks as its third and fourth arguments, to handle cases where the MIDI device you are trying to assign to cannot be found.
Access to the Audio Context
WAD at the time of creation an automatic Audio Context creates. It should not use obviously as it is exposed at Wad.audioContext. When A-Frame is using in application and WadJS detects an <a-scene> element on the page, WadJS will use A-Frame’s Audio Context and Audio Listener, instead of creating its own.
Cross-Browser Compatibility
As a JavaScript library Wad renowned in today’s market because of it awesome compatibility with Chrome, decently in Safari for iOS. It works nicely in any browser that supports Web Audio, especially mobile browsers.