Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

64
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda