An experiment in to the Web Audio API and angular.js
A project uses the web audio API to create a monophonic synth in JS. The synth features tone generators, a ADSR envelope and LFO. Functionality written vanilla without dependences (apart for webAudio support). UI Built on angular.js
You'll need the following to work with this repository:
- Node.js
- NPM
- Gulp
- Make sure you have node, npm and gulp installed
- Navigate in bash to project folder
- Run the following command to add all gulp npm modules
npm install --save-dev gulp gulp-sass gulp-autoprefixer gulp-minify-css gulp-rename gulp-notify gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-cache del gulp-livereload
- Run the
gulp watch
task - Develop!
A light weight module for working with the web audio API. Made up of two files, the former (web-audio-componants.js) is dependent on the other.
Create a new instance of the module and init. This method create a new AudioContext is a required before you can use the module
var webAudio = WebAudioComponent;
webAudioComponents.init();
Next create a new voice using a JSON object
webAudioComponents.newVoice();
Create a new voices with the following operations
var newVoiceSettings = {
type: 'sine',
detune: 0,
frequency: 440,
gain: 1,
lfo : true,
lfoSettings : {
type: 'sawtooth',
detune: 10,
frequency: 2,
gain: 10
},
envelope: true,
envelopeSettings : {
attackEnable: true,
decayEnable: true,
sustainEnable: true,
releaseEnable: true,
attack: 300,
decay: 100,
sustain: 0.7,
release: 300,
}
};
webAudioComponents.newVoice(newVoiceSettings);
Play a note by passing a frequency to the playNote() method
webAudioComponents.playNote(440);
Stop a note by passing the frequency to the stopNote() method
webAudioComponents.stopNote(440);
Run using gulp
or gulp default
. Deletes entire dist file before running all tasks.
Run using gulp javascript
. Lints, concat's and minifies all js.
Run using gulp styles
. Compiles sass, concats and minifies into single file.
Run using gulp images
. Compresses & optimises all images.
Run using gulp move-html
. Moves html to dist.
Run using gulp move-svg
. Moves svg to dist.
Run using gulp move-fonts
. Moves fonts to dist.
Run using gulp watch
. Watches for changes to any task (I think). When the file is updated run the related