Synth Tone question

function ready() {
    // given F (Frame), S (Stage), W (width), H (height)
    // put code here
    var mySynth = new Synth();
    mySynth.tone({ note: "A5", duration: 1, volume: 1 });
    timeout(2, function () {
        mySynth.tone({ note: "A5", duration: 1, volume: 0.2 });
var rect=new Rectangle(500,500,white).center();
var btn1=new Label({text:"play tone (volume=1)",color:green,size:20}).loc(rect).mov(10,20).cur()
        mySynth.tone({ note: "A5", duration: 1, volume: 1 });
var btn2=new Label({text:"play tone (volume=0.2)",color:red,size:20}).loc(rect).mov(10,80).cur()
        mySynth.tone({ note: "A5", duration: 1, volume: 0.2 });
    new Label({text:"?",color:black,size:100}).centerReg({addTo:false}).loc(rect).mov(100,180)
makeIcon(white, S, 2).loc(485, 260);

why volume not change?

Each tone is running. Calling the tone() again makes a new one in addition to the old one. So store the tone() in a variable and use the volume property or better yet, use the ramp(volume, time) to adjust the volume without crackle.

    var rect=new Rectangle(500,500,white).center();
    var volumeLabel=new Label({text:'音量',size:50,color:blue}).centerReg(rect)
    var mySynth = new Synth();
    var noteFun=series(['C5','D5','E5','F5','G5','A6','B6'])
    interval(2, function () {
        var note=noteFun()
        var volume=1//Pick.choose([0,3])
        var s1=mySynth.tone({ note: note,duration:.3 });

if i set volume s1.volume=volume then the duration change also,why?

It is getting reset in the ramp function when we cancelScheduledValues() which is standard for changing the volume. Did not realize that it is canceling the duration! So will fix.

But we are not even hearing volume change - so not sure what is going on. Will have to check later this afternoon. All the volume settings are not working for us at the moment (even if we put that line of code back in).

Okay. Volume works but not if a duration is set. So probably that same code that removed the duration when setting the volume is removing the volume when setting the duration. So... we will have a look at that later today.

Ah... back in ZIM CAT 4 (Diamond) we did some adjustments to the synth stop and duration... on line 79091 what we did, may have worked for why we did it, but it calls the ramp() function right away which clears the volume. So trying to figure out why we did what we did and see if the old way can be fixed in some other way.

We have reverted to the timeout code. It seems to work fine for all the scenarios we tested. We can't remember what the problem was that caused us to change. There was a message up above about making the tone and stopping it right away having an issue. So have put that here as well to consider.

ZIM 016 has been patched - let us know how it goes.