Best way to get a numbers out of a signal generator

Oct 26, 2006 at 4:50pm

Best way to get a numbers out of a signal generator

I’m trying to create a Doppler Effect plug using Max/MSP. I’ve worked out the pitch shifting (using gizmo~, which I assume is better than freqshift~), and now I want to adjust the pitch using a sine wave (if this makes sense), so the pitch goes up as the sine wave goes up and the pitch goes down as the sine wave goes down.

Now, I can make a sine wave using cycle~, and display it as a number using number~, but the gizmo~ code requires either an integer or floating point input, and I can’t find any way to get a continuously going sine wave first as a number, and secondly into my gizmo~ code.

Any help gratefully received. I can post example code if necessary. Thanks very much.

#28373
Oct 26, 2006 at 5:00pm

you should try using tapin~ tapout~ instead.

it might look like a cheapo solution but in fact it is
very close to the physical reality of the doppler effect.

tapout~ will allow signal input for the time value.

-110

#87002
Oct 26, 2006 at 5:55pm

To answer your question directly, [cycle~]–[number~]-right outlet–[flonum]. Try it with a low freq for cycle~ (0.1) and a fast refresh interval on number (say, 10 ms), and you will get a good result.

However, as always, Roman’s response is very much to the point. Using cycle~ as a LFO added to the time input to tapout~ gives a very good doppler effect, as demonstrated in the MSP tutorials.

Tim

#87003
Oct 26, 2006 at 7:42pm

Thanks very much guys, that’ll teach me to look at the documentation before fighting with a problem by myself. A little bit of fine tuning and hoping that Pluggo doesn’t have a paddy with it, and everything will be fine. Thanks again.

#87004
Oct 27, 2006 at 9:59pm

Ed Schroeder wrote:
> Any help gratefully received. I can post example code if necessary.
> Thanks very much.

The easiest and most simple way to do a doppler shift is a variable
delay line. It does it exactly the same way as nature. Doppler effect in
nature is changing the distance and the speed for traveling the distance
is the delay time. Thus a tapin~ with an audio rate controlled tapout~
is the most natural way to do it. Absolutely no artefacts at all!!! And
the CPU is around 1% of any other method which sounds so much worse…

I know this doesn’t answer your question, but it will help you to get
the most realistic doppler imaginable…

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com

#87005
Oct 28, 2006 at 11:27am

Quote: Stefan Tiedje wrote on Fri, 27 October 2006 22:59
—————————————————-

> is the delay time. Thus a tapin~ with an audio rate controlled tapout~
> is the most natural way to do it.

What exactly do you mean by audio rate controlled tapout~? Do you mean adjusting the delay time of the tapout~ using a cycle~ or similar?

This is what I’ve got so far, I basically used the MSP documentation and doubled it up for stereo. I’ve noticed artifacts when adjusting the sliders in Logic though.

max v2;
#N vpatcher 1139 623 1690 1078;
#P origin 0 2;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 215 210 26 196617 100;
#P message 215 187 31 196617 0.25;
#P message 215 167 23 196617 2.;
#P newex 215 143 48 196617 loadbang;
#P flonum 141 108 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N pp 3 DelayTime 0 200;
#P newobj 141 83 109 196617 pp 3 DelayTime 0 200;
#P comment 159 287 86 196617 Basic Delay Time;
#P comment 90 221 102 196617 Modulation Amplitude;
#P flonum 90 83 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N pp 2 ModulationAmplitude 0 100;
#P newobj 90 58 155 196617 pp 2 ModulationAmplitude 0 100;
#P flonum 41 58 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N pp 1 ModulationRate 0 100;
#P newobj 41 33 130 196617 pp 1 ModulationRate 0 100;
#P number 107 287 49 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user hslider 130 262 18 128 200 1 0 0;
#P newex 90 262 34 196617 / 10.;
#P user hslider 90 239 18 128 100 1 0 0;
#P flonum 41 239 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 41 214 34 196617 / 10.;
#P user hslider 41 183 18 128 100 1 0 0;
#P newex 41 337 92 196617 +~;
#P newex 41 312 76 196617 *~;
#P newex 41 287 59 196617 *~;
#P newex 41 262 40 196617 cycle~;
#P newex 147 375 44 196617 tapout~;
#P newex 147 339 59 196617 tapin~ 250;
#P number 354 287 49 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user hslider 377 262 18 128 200 1 0 0;
#P newex 337 262 34 196617 / 10.;
#P user hslider 337 239 18 128 100 1 0 0;
#P flonum 288 239 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 288 214 34 196617 / 10.;
#P user hslider 288 183 18 128 100 1 0 0;
#P newex 288 337 92 196617 +~;
#P newex 288 312 76 196617 *~;
#P newex 288 287 59 196617 *~;
#P newex 288 262 40 196617 cycle~;
#P newex 216 375 44 196617 tapout~;
#P newex 216 339 59 196617 tapin~ 250;
#N plugconfig;
#C useviews 1 1 1 1;
#C numprograms 64;
#C preempt 1;
#C sigvschange 1;
#C sigvsdefault 32;
#C autosize;
#C defaultview Interface 0 0 0;
#C dragscroll 1;
#C noinfo;
#C package ????;
#C uniqueid 76 46 190;
#C initialpgm 1;
#P newobj 181 33 55 196617 plugconfig;
#P newex 178 407 48 196617 plugout~;
#P newex 184 307 42 196617 plugin~;
#P comment 41 163 80 196617 Modulation Rate;
#P fasten 31 0 30 0 46 79 34 79 34 27 46 27;
#P connect 30 0 31 0;
#P connect 39 0 23 0;
#P connect 31 0 23 0;
#P connect 23 0 24 0;
#P connect 24 0 25 0;
#P connect 25 0 19 0;
#P connect 19 0 20 0;
#P connect 20 0 21 0;
#P connect 21 0 22 0;
#P fasten 33 0 32 0 95 104 83 104 83 52 95 52;
#P connect 32 0 33 0;
#P connect 40 0 26 0;
#P connect 33 0 26 0;
#P connect 26 0 27 0;
#P connect 27 0 20 1;
#P connect 28 0 29 0;
#P connect 29 0 21 1;
#P connect 29 0 22 1;
#P fasten 37 0 28 0 146 147 135 147;
#P connect 41 0 28 0;
#P fasten 37 0 36 0 146 129 134 129 134 77 146 77;
#P connect 36 0 37 0;
#P connect 1 0 17 0;
#P connect 17 0 18 0;
#P fasten 22 0 18 0 46 367 152 367;
#P connect 18 0 2 0;
#P connect 38 0 39 0;
#P connect 38 0 40 0;
#P connect 38 0 41 0;
#P connect 1 1 4 0;
#P fasten 9 0 5 0 293 367 221 367;
#P connect 4 0 5 0;
#P connect 5 0 2 1;
#P fasten 31 0 10 0 46 132 293 132;
#P connect 39 0 10 0;
#P connect 10 0 11 0;
#P connect 11 0 12 0;
#P connect 12 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 8 0;
#P connect 8 0 9 0;
#P fasten 33 0 13 0 95 232 342 232;
#P connect 40 0 13 0;
#P connect 13 0 14 0;
#P connect 14 0 7 1;
#P connect 15 0 16 0;
#P connect 16 0 8 1;
#P connect 16 0 9 1;
#P fasten 37 0 15 0 146 132 382 132;
#P connect 41 0 15 0;
#P pop;

I assume from what you said that there is a simpler way to do things.

Ed

#87006
Oct 29, 2006 at 7:40am

Ed Schroeder wrote:
> What exactly do you mean by audio rate controlled tapout~? Do you
> mean adjusting the delay time of the tapout~ using a cycle~ or
> similar?

You would normally smooth the change of a delay parameter with line~

> This is what I’ve got so far, I basically used the MSP documentation
> and doubled it up for stereo. I’ve noticed artifacts when adjusting
> the sliders in Logic though.

Its because you jump (instead of moving) the values with the scheduler
controled parameters.

There is one *~ too much and one missing line~:

> I assume from what you said that there is a simpler way to do things.

It’s not necessary simpler, look at the
./examples/spacialisation/doppler.pat how to do a distance based delay.
then modulate the distance (with a line~ ;-).

I do not quite get what you want to do with a cycle and doppler, do you
invision a moving leslie cabinet? Thats the only real world object which
would need something like that. But then I would call the effect “moving
leslie” and not doppler…. ;-)

A mod for the crucial part of your patch regarding the initial question:
(To get a doppler effect, you’d need to calculate the time based on the
jump in the delay time to translate it into a speed…)

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 83 320 29 196617 mod;
#P flonum 81 340 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 41 340 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 178 320 77 196617 Speed of change;
#P number 174 340 49 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 119 365 65 196617 pack 0. 10;
#P newex 119 386 34 196617 line~;
#P comment 118 320 58 196617 Delay Time;
#P number 119 340 37 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 41 411 88 196617 +~;
#P newex 41 388 50 196617 *~;
#P newex 41 363 40 196617 cycle~;
#P newex 41 446 44 196617 tapout~;
#P comment 41 320 29 196617 freq;
#P connect 5 0 8 0;
#P connect 8 0 7 0;
#P connect 9 0 8 1;
#P connect 12 0 3 1;
#P connect 11 0 2 0;
#P connect 7 0 4 1;
#P connect 3 0 4 0;
#P fasten 4 0 1 0 46 433 46 433;
#P connect 2 0 3 0;
#P window clipboard copycount 14;


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com

#87007
Oct 30, 2006 at 12:55am

Thanks very much indeed. My original intent was to use freqshift~ or gizmo~ to adjust the frequency, while using a sine wave or similar to control them to create a kind of ‘fake’ doppler shift effect.

Since however, we (you) have come up with a better way of simulating it, it’s not something vital for this project, though I might well put the moving leslie cabinet thing to use in another plug in.

Also, thanks for the modification to the patch. It’s not massively important to get the doppler effect mathmatically accurate if you catch my drift, just to recreate the general effect. If you’ve used the GRM Tools Doppler plug in, that’s the kinda thing I’m eventually aiming to get towards.

#87008
Oct 30, 2006 at 2:15am

yes, if you want it smoother when using parameters
manually in logic, you can only 1- interpolate using
line~ and 2. use bigger sliders (= higher resolution)

when modulating using cycle or other audio stuff
this is of course not an issue.

#87009

You must be logged in to reply to this topic.