Comments (2)
Hey there!
A quick look reveals a few problems:
if(pressed.slice(0,1) == noteOffName){
this will never be true, slice creates a new array, which is a unique object. What you want is if(pressed[0] === noteOffName){
. Also probably a good idea to use triple equals.
volENV = new audioLib.ADSREnvelope(sampleRate, 200, 50, 1, 500, 250, 0);
discard the last two arguments and it should work. If you specify the those two, triggerGate will not react, because the ADSREnvelope assumes that you want a static envelope (i.e. the ADSREnvelope starts to oscillate), since you specified a static time for sustain and release.
volENV.triggerGate(false);
if you turn the oscillator immediately after the key is lifted, you never get to the release part. To get that as well, you need some kind of decay management. Otherwise this is ok, just combined with the way you're dealing with the oscillators makes it malfunction a bit.
osc1 = new audioLib.Oscillator(sampleRate, null);
and osc1 = new audioLib.generators.Note(sampleRate, noteOnName);
it's probably a better idea to keep the same oscillator instance all the time, since you only have one oscillator anyway. Just set the frequency to match the note whenever the key changes, and when the key is lifted, set the frequency to zero. Or even better, if you're making a mono synth, you can make the choice of never setting the frequency to zero, instead just release the gate for the envelope, and the sound will fade out.
Hope this helps!
Cheers,
Jussi
from audiolib.js.
That sorted it. Thanks a lot!
from audiolib.js.
Related Issues (20)
- Include a build please HOT 1
- README.md links broken
- Install it on Mac OS X HOT 4
- Can audiolib.js work with webRTC? HOT 2
- Ownership handover
- how to use mocha + istanbul + grunt HOT 2
- Fails to install on Mac OS X Mavericks / Node.js v0.10.21 HOT 4
- Phasor tests fail HOT 9
- asm.js HOT 2
- Where should nodes' parameters live? HOT 2
- Documentation link is dead
- Build fails on Ubuntu 12.04 / Node v0.10.29 HOT 1
- Sink.js Failing To Initialize
- fail install on ubuntu 14.10 HOT 1
- WebAudio sink fails in recent Chrome update HOT 1
- Android 4.0 and Chrome
- Audio on new browsers is choppy HOT 1
- Resampling
- WeChat 'mini apps' HOT 1
- Node example?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from audiolib.js.