Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

63
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda