gibber-cc / gibberish

Fast, JavaScript DSP library that creates JIT optimized audio callbacks using code generation techniques
387 stars 35 forks source link

Can't modulate the amplitude of Saw3 with adsr #13

Closed thinium closed 8 years ago

thinium commented 8 years ago

Hi, I tried to use ADSR to modulate the amplitude of Saw3, but it doesn't work. If I replace Saw3 with Saw, it works as expected. But I need a band-limited Sawtooth so I'll need to work with Saw3.

Here is the code: Gibberish.Time.export() Gibberish.Binops.export() Gibberish.init(); adsr = new Gibberish.ADSR(22050, 22050, 8200, 2050, 1, .35); line = new Gibberish.Lines([0,400,0,600,0,800,0,200], [10210,1,5000,1, 5000,1,5000], false); a = new Gibberish.Saw3( Add(1440, line), Mul(.5, adsr) ).connect();

Any advice would be very appreciated!

thinium commented 8 years ago

Hi again! I managed to work around this issue by adding a line in the Saw3 function. In the callback function at line 536, the amp is not used, so I added

out *= amp; after Line 551 (out += DC;), to multiply the output by the amp.

charlieroberts commented 8 years ago

Nice catch; thanks! I've pushed the change to the repo. - Charlie