Page 1 of 2

out of phase tones

Posted: Mon Jul 02, 2018 4:45 pm
by bunny94
I want to create three of the same same frequency sine wave tones which are 120 degrees out of phase with each other. I know how to produce the tones but its the rest I cant get my head round. Any advice much appreciated.

Re: out of phase tones

Posted: Mon Jul 02, 2018 5:01 pm
by steve
Probably the easiest way is to use the Nyquist Prompt effect: https://manual.audacityteam.org/man/nyquist_prompt.html
The command "OSC" can generate a variety of simple tones, the default being a sine tone: http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index381

By default the Nyquist Prompt uses LISP syntax, so the command is:

Code: Select all

(osc pitch [duration table phase])
where "duration", "table" and "phase" are optional parameters.
"pitch" can be thought of as the note number, and there is a simple way to convert from "frequency" (in Hz) to "pitch", using the "HZ-TO-STEP" function: http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index315
By default the Nyquist prompt treats the selection as a duration of "1".

So, for example, to generate a sine tone at 440 Hz, that has the same duration as the selection, with a starting phase of zero:

Code: Select all

(osc (hz-to-step 440) 1 *sine-table* 0)
To generate a sine tone at 440 Hz, that has the same duration as the selection, with a starting phase of 120 degrees:

Code: Select all

(osc (hz-to-step 440) 1 *sine-table* 120)

Re: out of phase tones

Posted: Mon Jul 09, 2018 5:34 pm
by bunny94
Thanks Steve,

I will have a go at that, if I add a third tone , would I have to put in the value 240 for it to be 120 degrees different to the other two. I have downloaded the plug in which folder do I put it in. sorry to be a pain , bit of a learning curve for me.

regards Chris

Re: out of phase tones

Posted: Mon Jul 09, 2018 5:43 pm
by steve
You don't need any plug-ins to do this. Just use the Nyquist Prompt effect and type (or copy & paste) the command into the Nyquist Prompt effect.

You can enter any numeric value for the "phase" parameter. 360 degrees phase is identical to 0 degrees phase, and identical to -360 degrees.

Re: out of phase tones

Posted: Fri Jul 13, 2018 5:54 pm
by bunny94
Hi Steve,

I tried cutting and pasting your code. I got an error, I'm not sure if I am doing it right.

It said , your code looks like SAL syntax, but there is no return statement. Either use a return statement such as return s*0.1 for SAL or begin with an open parethesis such as (Mult s o.1) for LISP.

Can you advise on the code again please. sorry to be a pain. regards Chris

Re: out of phase tones

Posted: Sat Jul 14, 2018 11:44 pm
by steve
bunny94 wrote:
Fri Jul 13, 2018 5:54 pm
Can you advise on the code again please.
(osc (hz-to-step 440) 1 *sine-table* 120)

Re: out of phase tones

Posted: Mon Jul 16, 2018 6:12 pm
by bunny94
thanks again Steve,

I have managed to out phase 3 tones , but i'm getting no sound. I am generating a tone which sounds fine then use the code you give me , changing the number (440) to match the tone. to understand this, is the 440 in your code the output frequency or would it be the frequency of the tone. I'm nearly there and appreciate your patience. regards Chris

Re: out of phase tones

Posted: Mon Jul 16, 2018 6:31 pm
by steve
The number 440 is the frequency in Hz (same as the default frequency of Audacity's "Tone" generator).

Note that if you play two tones at the same time that are 180 degrees out of phase, or three tones that are all 120 degrees out of phase, they will cancel each other out and the result will be silence.

Re: out of phase tones

Posted: Mon Jul 16, 2018 7:04 pm
by DVDdoug
bunny94,

What are you trying to accomplish?

If you combine (mix or sum) phase-shifted waves of the same frequency they either add or subtract and you get the same frequency at a different amplitude. (Unless they sum to zero and completely cancel, then there's no wave and no frequency.) Also, be careful of clipping (distortion) if they add-up to over 1.0 (0dB).

If you are not combining the waves, then phase is pretty much meaningless since phase has to be relative to something.

You can get "interesting results" by shifting the phase (or flipping the polarity) of one channel in a stereo file, but I don't know what you'd do with 3 files/waves...

Re: out of phase tones

Posted: Tue Jul 17, 2018 10:56 am
by bunny94
Basically its the same tone ( frequency ) x 3 . All 120 degrees apart ( 3phase) and then combine them into one wave.

regards Chris