« Return to Thread: Cross Fading problems

Cross Fading problems

by mayortacoghost :: Rate this Message:

Reply to Author | View in Thread

Hi,

I am having certain problems with a Routine I am trying to run. Essentially I am trying to cross-fade two different sounds ("sine-test" and "saw-test") that are executed seven times over the course of the cross-fade. I've created two extra SynthDefs ("fade-in" and "fade-out") and run the other ones through them to aid me in this process, but "fade-out" is not responding to the .set(\gate, 0) message, unless I have something wrong with the Env.asr part of the SynthDef. I am currently unaware of any crossfading UGens, however, if there is a simpler method to achieve what I'm trying to do, please point me in the right direction.

I am posting this example code here in hopes that someone will catch my blunder. However, in this example as well as in my real code, I am experiencing a ton of artifacts, mostly high frequencies and I have no idea where they are coming from. Thanks a lot.

Bob


(


SynthDef("sine-test",{arg freq_sine, peak_amp_sine;

        var amp = EnvGen.kr(Env.perc( 0.1 , 3 , peak_amp_sine, 'sine'),doneAction:2 );

        var sound = SinOsc.ar( freq_sine , 0 , amp);

        Out.ar(50, sound)

} ).send(s);




SynthDef("fade-out", {arg gate=1 , pan=0;

        var in = Pan2.ar(In.ar(50), pan);
       
        var env = EnvGen.ar(Env.asr(0.02,1,30,1,-7),gate,doneAction:0);
       
        var out = in * env;
       
        Out.ar(0,out)

}).send(s);





SynthDef("saw-test",{arg freq_saw, peak_amp_saw;

        var amp = EnvGen.kr(Env.perc( 0.1 , 3 , peak_amp_saw, 'sine') , doneAction:2);

        var sound = Saw.ar( freq_saw , amp);

        Out.ar(55, sound)

} ).send(s);




SynthDef("fade-in", {arg gate=0 , pan=0;

        var in = Pan2.ar(In.ar(55), pan);
       
        var env = EnvGen.ar(Env.asr(30,1,0.02,1,-7),gate,doneAction:0);
       
        var out = in * env;
       
        Out.ar(0,out)

}).send(s);


)

(
a = Routine ( {

               
                Synth.new("fade-out");
                Synth.new("fade-in");
                0.03.wait;
                Synth("fade-in").set(\gate, 1);
                Synth("fade-out").set(\gate, 0);
               
                7.do{
               
        Synth("sine-test",[\freq_sine, 400, \peak_amp_sine, 0.8]);
       
        Synth("saw-test",[ \freq_saw, 600, \peak_amp_saw, 0.8]);

        5.wait};

       

        loop( {
       
        Synth("saw-test",[ \freq_saw, 600, \peak_amp_saw, 0.8]);

        5.wait

})
});

)

a.play;




 « Return to Thread: Cross Fading problems