Skip to content

Commit

Permalink
exponent passed into constructor is applied
Browse files Browse the repository at this point in the history
fixes #356
  • Loading branch information
tambien committed Jun 7, 2018
1 parent 20378f6 commit e5892fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Tone/component/FrequencyEnvelope.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ define(["Tone/core/Tone", "Tone/component/ScaledEnvelope", "Tone/component/Envel
Tone.FrequencyEnvelope = function(){

var options = Tone.defaults(arguments, ["attack", "decay", "sustain", "release"], Tone.Envelope);
Tone.ScaledEnvelope.call(this, options);
//merge it with the frequency envelope defaults
options = Tone.defaultArg(options, Tone.FrequencyEnvelope.defaults);
Tone.ScaledEnvelope.call(this, options);

/**
* Stores the octave value
Expand All @@ -37,6 +37,7 @@ define(["Tone/core/Tone", "Tone/component/ScaledEnvelope", "Tone/component/Envel
//setup
this.baseFrequency = options.baseFrequency;
this.octaves = options.octaves;
this.exponent = options.exponent;
};

Tone.extend(Tone.FrequencyEnvelope, Tone.Envelope);
Expand All @@ -48,7 +49,7 @@ define(["Tone/core/Tone", "Tone/component/ScaledEnvelope", "Tone/component/Envel
Tone.FrequencyEnvelope.defaults = {
"baseFrequency" : 200,
"octaves" : 4,
"exponent" : 2
"exponent" : 1
};

/**
Expand Down
4 changes: 3 additions & 1 deletion test/component/FrequencyEnvelope.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ define(["Tone/component/FrequencyEnvelope", "helper/Basic", "helper/Offline", "h
var env0 = new FrequencyEnvelope({
"attack" : 0,
"decay" : 0.5,
"sustain" : 1
"sustain" : 1,
"exponent" : 3
});
expect(env0.attack).to.equal(0);
expect(env0.decay).to.equal(0.5);
expect(env0.sustain).to.equal(1);
expect(env0.exponent).to.equal(3);
env0.dispose();
var env1 = new FrequencyEnvelope(0.1, 0.2, 0.3);
expect(env1.attack).to.equal(0.1);
Expand Down

0 comments on commit e5892fe

Please sign in to comment.