max v2; #N vpatcher 2 48 815 766; #P origin 9 -17; #P window setfont Times 10.; #P comment 606 340 95 1310730 D = sqrt((x*x)+(y*y)); #P comment 276 84 273 1310730 In the virtual space \, the listener is situated at the x \, y location 0 \, 0 \, and the car travels from location -200 \, 1 to 200 \, 1 in 36 seconds.; #P comment 266 67 296 1310730 This is a simulation of a car passing the listener at a speed of 40 km/hr.; #P comment 509 143 181 1310730 Click here to begin the 36-second example. (Make sure audio is on first.); #P comment 331 593 154 1310730 send the signal (which already has its amplitude and filtering adjusted based on the distance of the source) on to the constant-power panner for azimuth angle simulation; #P comment 577 535 154 1310730 this simulates the lowpass filtering effect of air absorption \, proportional to the distance of the sound source; #P comment 577 497 154 1310730 use the distance to calculate a changing balance between unfiltered sound and lowpass filtered sound; #P comment 725 428 67 1310730 get the inverse of the distance; #P comment 466 443 246 1310730 vary the amplitude inversely with the distance of the source; #P comment 490 391 141 1310730 that tells how many milliseconds of delay would occur \, based on the sound source location; #P comment 620 364 96 1310730 divide by the speed of sound (.344 m/ms); #P comment 424 270 136 1310730 (the y-axis location is always 1); #P comment 424 257 143 1310730 this represents the x-axis location; #P comment 446 340 121 1310730 square root gives distance of sound source from listener; #P comment 606 318 121 1310730 (the square of 1 is always 1); #P comment 472 314 95 1310730 plus the square of the location on the y axis; #P comment 472 289 95 1310730 the square of the location on the x axis; #P comment 616 252 119 1310730 (traveling a distance of 400 meters in 36 seconds yields a velocity of 40 km/hr); #P comment 575 186 160 1310730 Create a continuous change in "location" of the virtual sound source \, by going from point -200 \, 1 to point 200 \, 1 in thirty-six seconds; #P button 494 147 15 0; #P comment 45 570 131 1310730 Turn audio on for this window; #P comment 94 414 171 1310730 Divide by pi to get it in the range 0 to 1; #P comment 88 438 177 1310730 Use the azimuth angle to determine the left-right speaker panning \, using the constant-power (square root) algorithm.; #P comment 88 375 177 1310730 Calculate the azimuth angle of the sound based on the constantly changing position of the moving sound source.; #P comment 282 181 193 1310730 This part has nothing to do with the spatialization simulation. It's just a way of fading the car sound in and out gracefully at the beginning and end of the example.; #P window setfont "Fixedwidth Serif" 10.; #P newex 478 515 27 1441802 *~; #P newex 439 515 27 1441802 *~; #P newex 439 568 49 1441802 +~; #P newex 495 492 43 1441802 !-~ 1.; #P newex 478 538 99 1441802 lores~ 220. 0.5; #P message 280 235 133 1441802 1 3000 1 30000 0 3000; #P newex 280 255 39 1441802 line~; #P newex 9 333 27 1441802 *~; #P newex 265 460 39 1441802 sqrt~; #P newex 308 460 39 1441802 sqrt~; #P newex 265 366 51 1441802 sig~ 1.; #P newex 291 606 27 1441802 *~; #P newex 248 606 27 1441802 *~; #P newex 308 437 43 1441802 !-~ 1.; #P newex 265 410 73 1441802 /~ 3.141593; #P newex 265 388 60 1441802 atan2~; #P newex 9 306 27 1441802 +~; #P newex 136 262 69 1441802 cycle~ 39.; #P newex 9 284 137 1441802 *~; #P newex 26 262 107 1441802 *~; #P newex 123 235 39 1441802 pink~; #P newex 26 235 94 1441802 *~; #P newex 110 213 69 1441802 cycle~ 45.; #P newex 26 213 81 1441802 phasor~ 110.; #P newex 439 441 27 1441802 *~; #P newex 718 410 43 1441802 !/~ 1.; #P newex 567 367 53 1441802 /~ 0.344; #P newex 567 338 39 1441802 sqrt~; #P newex 567 316 39 1441802 +~ 1.; #P newex 567 293 27 1441802 *~; #P message 567 236 99 1441802 -200 \, 200 36000; #P newex 567 256 49 1441802 line~; #P newex 439 394 51 1441802 tapout~; #P newex 439 368 73 1441802 tapin~ 1000; #P newex 249 632 52 1441802 dac~; #P toggle 30 570 15 0; #P newex 30 588 82 1441802 select 0 1; #P message 66 609 73 1441802 startwindow; #P message 30 609 33 1441802 stop; #P window setfont Times 10.; #P comment 1 187 269 1310730 This is a noisemaker that's supposed to be a crude emulation of a car engine \, using noise and tones in a mess of ring modulation.; #P window setfont Times 14.; #P comment 350 45 107 1310734 Doppler Example; #P fasten 19 0 22 0 31 257 14 257; #P connect 22 0 24 0; #P connect 24 0 33 0; #P connect 17 0 19 0; #P connect 19 0 21 0; #P connect 21 0 24 1; #P fasten 34 0 33 1 285 328 31 328; #P connect 5 0 4 0; #P connect 4 0 2 0; #P connect 4 1 3 0; #P connect 18 0 19 1; #P connect 20 0 21 1; #P connect 23 0 22 1; #P fasten 38 0 28 0 444 591 253 591; #P connect 28 0 6 0; #P fasten 3 0 6 0 71 628 254 628; #P fasten 2 0 6 0 35 628 254 628; #P connect 30 0 25 0; #P connect 25 0 26 0; #P connect 26 0 32 0; #P connect 32 0 28 1; #P fasten 46 0 35 0 499 231 285 231; #P connect 35 0 34 0; #P fasten 38 0 29 0 444 591 296 591; #P connect 29 0 6 1; #P fasten 26 0 27 0 270 432 313 432; #P connect 27 0 31 0; #P connect 31 0 29 1; #P fasten 9 0 25 1 572 287 320 287; #P fasten 33 0 7 0 14 358 444 358; #P fasten 14 0 8 0 572 389 444 389; #P connect 7 0 8 0; #P connect 8 0 16 0; #P connect 16 0 39 0; #P connect 39 0 38 0; #P fasten 15 0 16 1 723 436 461 436; #P fasten 15 0 39 1 723 468 461 468; #P fasten 16 0 40 0 444 483 483 483; #P connect 40 0 36 0; #P connect 36 0 38 1; #P fasten 15 0 37 0 723 468 500 468; #P connect 37 0 40 1; #P connect 46 0 10 0; #P connect 10 0 9 0; #P connect 9 0 11 0; #P connect 11 0 12 0; #P connect 12 0 13 0; #P connect 13 0 14 0; #P connect 9 0 11 1; #P fasten 13 0 15 0 572 360 723 360; #P pop;