[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] (no subject)



i'm working with this doppler shift example using a PlayBuf instead of an FSinOsc. in the example, the LFSaw assigned to y is not starting at it's lowest value (in this case -100) because it's phase is at 0. when i try to correct this by switching the phase to 1.5pi i run into 2 issues: 1. 1.5 is not exactly the lowest value (-100) and i can't determine what phase offset would produce this 2. any phase offset results in an offset in the starting position of the soundfile. how do i compensate for this?
(
{
	var x, y, distance, velocity, pitchRatio, amplitude, azimuth, panValue;
	// object travels 200 meters in 6 secs (=120kph) passing 10 meters
	// from the listener
	x = 10;
	y = LFSaw.kr(1/6, 0, 100);
	distance = hypot(x, y);
	velocity = Slope.kr(distance);
pitchRatio = (344 - velocity) / 344; // speed of sound is 344 meters/sec
	amplitude = 10 / distance.squared;
	azimuth = atan2(y, x); // azimuth in radians
	panValue = (azimuth / 0.5pi).clip2(1);
Pan2.ar(PlayBuf.ar(1,bufnum, BufRateScale.kr(bufnum)*pitchRatio, loop:1), panValue, amplitude)
}.play)

thanks for any input.
cheers,
j