fixed bug

This commit is contained in:
tamat
2019-04-01 20:15:17 +02:00
parent 24a4f3a930
commit 7b77be53bf
23 changed files with 4123 additions and 2320 deletions

View File

@@ -968,6 +968,67 @@ LGAudioMixer.desc = "Audio mixer";
LiteGraph.registerNodeType("audio/mixer", LGAudioMixer);
function LGAudioADSR()
{
//default
this.properties = {
A: 0.1,
D: 0.1,
S: 0.1,
R: 0.1
};
this.audionode = LGAudio.getAudioContext().createGain();
this.audionode.gain.value = 0;
this.addInput("in","audio");
this.addInput("gate","bool");
this.addOutput("out","audio");
this.gate = false;
}
LGAudioADSR.prototype.onExecute = function()
{
var audioContext = LGAudio.getAudioContext();
var now = audioContext.currentTime;
var node = this.audionode;
var gain = node.gain;
var current_gate = this.getInputData(1);
var A = this.getInputOrProperty("A");
var D = this.getInputOrProperty("D");
var S = this.getInputOrProperty("S");
var R = this.getInputOrProperty("R");
if( !this.gate && current_gate )
{
gain.cancelScheduledValues(0);
gain.setValueAtTime( 0, now );
gain.linearRampToValueAtTime(1, now + A );
gain.linearRampToValueAtTime(S, now + A + D );
}
else if( this.gate && !current_gate )
{
gain.cancelScheduledValues( 0 );
gain.setValueAtTime( gain.value, now );
gain.linearRampToValueAtTime( 0, now + R );
}
this.gate = current_gate;
}
LGAudioADSR.prototype.onGetInputs = function()
{
return [["A","number"],["D","number"],["S","number"],["R","number"]];
}
LGAudio.createAudioNodeWrapper( LGAudioADSR );
LGAudioADSR.title = "ADSR";
LGAudioADSR.desc = "Audio envelope";
LiteGraph.registerNodeType("audio/adsr", LGAudioADSR);
function LGAudioDelay()
{
//default
@@ -1066,7 +1127,13 @@ LGAudioOscillatorNode.prototype.onStart = function()
if(!this.audionode.started)
{
this.audionode.started = true;
this.audionode.start();
try
{
this.audionode.start();
}
catch (err)
{
}
}
}