Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

57
Views
Audio plays faster than recorder can keep up in music animation video program in p5.js

EDIT: Before you can access the data from a song you need to have user input. additional note: the song plays at normal speed but the recorder runs at 1-2 fps. So the animation is short and fast.

I'm working in p5.js to make a music visualization, I have a playlist of mp3's I want to make clips for, and I am using frameCount to reset the capturer when the song is over.

I've included all code that would be relevant as to the why song.duration() returns zero.

var song

// var songs = []

var fft

var particles = []

var backgroundimage

var focus

var s


function preload() {

  // for(var i = 0; i < 20; i++) {

  //   songs.push(loadSound('audio/audio'+(i+1)+'.mp3'))

  //   console.log(songs[i].duration())

  // }


  song = loadSound('audio1.mp3')

  console.log(song.duration())

  img = loadImage('picture/image.png')

}


function setup() {

  createCanvas(1920, 1080)

  fft = new p5.FFT()

  imageMode(CENTER)

  angleMode(DEGREES)

  focus = {x: 250, y: 250}

  s=0

  //backgroundimage = new AnimatedImage(img)

}

function draw() {

  //This is to test why the array of songs have no duration()

  if( frameCount === 1){

    capturer.start()

    song.play()

  } else if (frameCount === timetoframes(song.duration())) {

    capturer.stop()

    capturer.save()

    noLoop()

  }


  // if (frameCount === songs[s].duration() * 24) {

  //   capturer.stop()

  //   capturer.save()

  //   frameCount = 1

  //   s++

  // } 

  // if( frameCount === 1 ) {

  //   capturer.start()

  //   songs[s].play()

  // }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!