Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/okaybenji/subpoly
a Web Audio subtractive, polyphonic synthesizer
https://github.com/okaybenji/subpoly
javascript synth synthesizer webaudio
Last synced: 28 days ago
JSON representation
a Web Audio subtractive, polyphonic synthesizer
- Host: GitHub
- URL: https://github.com/okaybenji/subpoly
- Owner: okaybenji
- License: mit
- Created: 2015-09-30T13:37:30.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-10T15:53:43.000Z (almost 8 years ago)
- Last Synced: 2024-09-21T08:12:04.093Z (about 2 months ago)
- Topics: javascript, synth, synthesizer, webaudio
- Language: JavaScript
- Homepage:
- Size: 25.4 KB
- Stars: 19
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-javascript-audio - okaybenji/subpoly - small multi-voice (polyphonic) synth, define sounds as JS objects (MIDI instruments / Synths)
README
# subpoly
A Web Audio subtractive, polyphonic synthesizer. Just need one voice? Check out [submono](https://github.com/okaybenji/submono)!### Create a synth.
```
var audioCtx = new AudioContext();
var synth = new Polysynth(audioCtx);
```**Your new `synth` has an array of [submono](https://github.com/okaybenji/submono) `voices` attached.**
### Play a note.
`synth.voices[i].start();`### Stop playing.
`synth.voices[i].stop();`### Play all voices.
`synth.start();`### Stop all notes.
`synth.stop();`### Use methods to access a voice's pitch and waveform...
```
synth.voices[i].pitch(440); // in hertz
console.log(synth.voices[i].waveform()); // 'sawtooth'
```### ...get or set any other properties directly.
```
synth.voices[i].maxGain = 0.5; // out of 1
synth.voices[i].attack = 1.0; // in seconds
```### Use methods to set any property for all voices at once.
```
synth.maxGain(0.5); // out of 1
synth.attack(1.0); // in seconds
synth.pitch(440); // in hertz
synth.waveform('sawtooth'); // or sine, triangle, square
```### Set the stereo width.
`synth.width(1.0); // out of 1`### Configure any or all the properties on initialization.
```
var config = {
waveform: 'sawtooth', // or sine, triangle, square
pitch: 440, // in hertz
maxGain: 0.5, // out of 1
attack: 0.1, // in seconds
decay: 0.0, // in seconds
sustain: 1.0, // out of 1
release: 0.8, // in seconds
stereoWidth: 0.5, // out of 1
numVoices: 5, // unlimited
cutoff: {
maxFrequency: 7500, // in hertz
attack: 0.1, // in seconds
decay: 2.5, // in seconds
sustain: 0.2 // 0-5; maxFrequency multiplied by this
}
};var synth = new Polysynth(audioCtx, config);
```### Demo
[musical typing](http://okaybenji.github.io/web-synth/)