Audio and frame delay timing using fft and screen position. X-Post from reddit

X-posted from here

Hi all, I'm using the spectrum data from an FFT i'm performing to control the speed of the audio file as well as the delay between frames being drawn. This is what creates the avg. The issue is that i'm not sure how to make this work for a range of different files. Sometimes there'll be 1440 frames to play, othertimes there's 1700 and the audio is similarly varied.

How can a build this so that it'll always playback in the right amount of time, which is currently 1 minute but could be 2 or 3.

Thanks.

Apologies for the state of the code.

Full project here
A folder that the program needs to process here
FFT function was taken from here

code snippet that i'm using to control the playback and delay:

if (tConnectSound) {
  if (avg > height/6+height/6*4 && avg < height) {
    //rateControl.value.setLastValue(frameSkipLoad/32);
    cp5.getController("sDelay").setValue(frameSkipLoad/32);
  }//
  else if (avg > height/6+height/6*3 && avg <  height/6+height/6*4) {
    //rateControl.value.setLastValue(frameSkipLoad/16);
    cp5.getController("sDelay").setValue(frameSkipLoad/16);
  }//
  else if (avg > height/6+height/6*2 && avg < height/6+height/6*3) {
    //rateControl.value.setLastValue(frameSkipLoad/8);
    cp5.getController("sDelay").setValue(frameSkipLoad/8);
  }//
  else if (avg > height/6+height/6 && avg < height/6+height/6*2) {
    //rateControl.value.setLastValue(frameSkipLoad/4);
    cp5.getController("sDelay").setValue(frameSkipLoad/4);
  }//
  else if (avg > height/6 && avg < height/6+height/6) {
    //rateControl.value.setLastValue(frameSkipLoad/2);
    cp5.getController("sDelay").setValue(frameSkipLoad/2);
  }//
  else if (avg > 0 && avg < height/6) {
    //rateControl.value.setLastValue(frameSkipLoad);
    cp5.getController("sDelay").setValue(frameSkipLoad);
  }
  delay = cp5.getController("sDelay").getValue();
}

Answers

  • I'm using the spectrum data from an FFT i'm performing to control the speed of the audio file as well as the delay between frames being drawn. This is what creates the avg. The issue is that i'm not sure how to make this work for a range of different files.

    How is the control of speed and the delay related to your fft spectrum?

    What is avg? Do you mean avg? Average of the FFT spectrum?

    How does all relate to the range of different files?

    Please post clear and full detail questions.

    Kf

  • Sorry about that. The avg is the average of all of the fft spectrum bars, it ends up giving the average position on screen. This is what I am using, in conjunction with the above code snippet to control the tickRate and frame delay.

    My issue is that the above snippet works to affect the tickRate and delay but I am trying to always have the audio and visuals play out in 1 minute and this code structure doesn't take into account the length of the audio file or the number of frames to play which throws out my synchronisation. I was wondering how I need to structure things in order to have this work for different files but still work in the desired 1 minute.

    Hope that's clearer, sorry about the confusion.

Sign In or Register to comment.