added detune to PolySynth

applied when available.
This commit is contained in:
Yotam Mann 2016-05-14 20:49:55 -04:00
parent b3e9ec173a
commit 6060b397ad
2 changed files with 22 additions and 0 deletions

View file

@ -47,11 +47,22 @@ function(Tone){
*/
this._triggers = new Array(options.polyphony);
/**
* The detune in cents
* @type {Cents}
* @signal
*/
this.detune = new Tone.Signal(options.detune, Tone.Type.Cents);
this._readOnly("detune");
//create the voices
for (var i = 0; i < options.polyphony; i++){
var v = new options.voice(arguments[2], arguments[3]);
this.voices[i] = v;
v.connect(this.output);
if (v.hasOwnProperty("detune")){
this.detune.connect(v.detune);
}
this._triggers[i] = {
release : -1,
note : null,
@ -74,6 +85,7 @@ function(Tone){
Tone.PolySynth.defaults = {
"polyphony" : 4,
"volume" : 0,
"detune" : 0,
"voice" : Tone.MonoSynth
};
@ -233,6 +245,9 @@ function(Tone){
this.voices[i].dispose();
this.voices[i] = null;
}
this._writable("detune");
this.detune.dispose();
this.detune = null;
this.voices = null;
this._triggers = null;
return this;

View file

@ -96,6 +96,13 @@ function (PolySynth, Basic, InstrumentTests, OutputAudioStereo, Meter, Instrumen
polySynth.dispose();
});
it ("can be set the detune", function(){
var polySynth = new PolySynth();
polySynth.detune.value = -1200;
expect(polySynth.detune.value).to.equal(-1200);
polySynth.dispose();
});
it ("can get/set attributes", function(){
var polySynth = new PolySynth();
polySynth.set({