ratiofpr := targetfps / sourcefps; for(sec :=0; sec < length; sec++) { write_frame_0(frame(0)); source_t := ratio; low_fft := fft(source_t, x, y, rgb); for (f = 1; f < fps; f++) { next_f = ceil(source_t + ratio); ratio_ffts := f - source_t; next_fft := fft(next_f, x, y, rgb); interp := interpolate_ffts(low_fft, next_fft, ratio_ffts); pixels := fft(-1, interp); write_to_pixel(x, y, pixels[64], rgb); source_t += ratio; low_fft = next_fft; } } Frame_complexes : adt { frame : big; x, y, channel : int; complexes : ref Complexes; }; FFT_cache : adt { ffts : array of ref frame_complexes; fft_ptr : int; # ring buffer pointer add : fn(f : self ref FFT_cache, fc : ref Frame_complex) : int; ffts : fn(f : self ref FFT_cache, frame : big); }; new_fft_cache(frame : big, x, y, channel, size : int) : ref fft_cache { f := ref FFT_cache(array[size] of ref frame_complexes, 0); for(i := 0; i < size; i++) f.ffts[i] = ref Frame_complexes(frame, x, y, channel, nil); return f; } FFT_cache.ffts(f : self ref FFT_cache, frame : big, x, y, channel : int) : ref Complexes; { last := f.ffts[f.fft_ptr] if(frame > last.frame || y > last.y || x > last.x || channel > last.channel) { f.fft_ptr++; f.fft_ptr %= len f.ffts; f.ffts[f.fft_ptr] = ref Frame_complexes(frame, x, y, channel, nil); } ptr := f.fft_ptr; for(i := 0; i < len f.ffts; i++) { if(f.ffts[i].frame == frame) { if(f.ffts[i].complexes == nil) { f.ffts[i].complexes = fft->C_from_reals(s.sample_set(frame - 127, frame + 127, x, y, channel)); return } }