Cross Fading problems

View: New views
4 Messages — Rating Filter:   Alert me  

Cross Fading problems

by mayortacoghost :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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;





Re: Cross Fading problems

by nescivi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wednesday 22 April 2009 13:04:09 mayortacoghost wrote:

> 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.

XFade.ar

sincerely,
Marije

>
> 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;



_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Cross Fading problems

by Dan Stowell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/4/22, nescivi <nescivi@...>:

> On Wednesday 22 April 2009 13:04:09 mayortacoghost wrote:
>  > 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.
>
>
> XFade.ar

or XFade2.ar actually, I think...

Dan

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Cross Fading problems

by scacinto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Robert Pierzak,

Every time you write "Synth(..." you are creating a new instance of whatever synth you are calling.  Synth("whatever") is just shorthand for Synth.new("whatever"). (that info is in the help file)

The below code creates two synths, waits 0.03 seconds then creates two new synths, one with a gate of 1, the other a gate of 0.  Then, in the 7.do function, you create more new synths, and on and on.  

What you must do is a) read the SynthDef and Synth help files, and b) create a variable to reference the the synths by ( x = Synth.new(...  then x.set(\gate, 0) ) or create them explicitly using the server messaging syntax.

Make sense?

Cheers,

SP(e)



P.S. "there's a pattern for that."


mayortacoghost wrote:
                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;
______________________________

Scott Petersen
Assistant Director, YalMusT
Music Technology Specialist
Department of Music
Yale University, New Haven, CT 06511
United States