Code an Audio Visualizer in p5js (from scratch) | Coding Project #17

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 มิ.ย. 2024
  • In this project we will code an audio visualizer from scratch with the p5js library. We will be using FFT and waveform analysis.
    Content of this video:
    0:00 Introduction
    0:48 Load the audio
    2:23 Waveform analysis
    5:58 Wrap the waveform in a circle
    8:32 Create the particles
    13:57 Beat detection
    15:29 Responsive background
    18:47 Patreon
    If you want to improve your coding skills further, head over to codiwy.com. It is totally free to get started, and there will fresh content available every week.
    For more examples of things you can do in p5.js, just head over to Instagram.
    / colorfulcoding
    If you don't know how to get started with p5.js, here's a video covering that:
    • Get started with p5.js...
    Download p5js sound library:
    p5js.org/download/
    p5.js documentation:
    p5js.org/reference/
    If you have any questions or requests for future projects, feel free to leave a comment below 👇

ความคิดเห็น • 91

  • @ConfusedNDazed
    @ConfusedNDazed 3 ปีที่แล้ว +10

    The best tutorial so far, please keep producing them 👍

  • @richardjamesbunker
    @richardjamesbunker 2 ปีที่แล้ว +3

    This is so good! Very inspiring and so happy I learned javascript!

  • @turboblitz4587
    @turboblitz4587 2 ปีที่แล้ว

    This looks amazing! Will try it out with some adjustements :) Thanks for the video

  • @yvonnewu7668
    @yvonnewu7668 2 ปีที่แล้ว

    This is awesome!! your explanation is very clear! thanks!

  • @sunlight8127
    @sunlight8127 3 ปีที่แล้ว

    Been looking for these things, you saved me a lot of time :), to put my things in better way.

  • @alebychac
    @alebychac 9 หลายเดือนก่อน

    This is amazing. I'm so happy to find this video👍

  • @mixtapeverse1184
    @mixtapeverse1184 6 หลายเดือนก่อน

    That was awesome and works great! Definitely checking your patreon. Thank you!

  • @deckermv7530
    @deckermv7530 2 ปีที่แล้ว

    You're mad talented. Just subbed

  • @67Keldar
    @67Keldar 11 หลายเดือนก่อน

    Mind Blown.... 😮❤‼

  • @henryschneiderproductions4061
    @henryschneiderproductions4061 3 ปีที่แล้ว

    very good explanation for what I needed thx a lot 😁

  • @gunjandhanuka9140
    @gunjandhanuka9140 2 ปีที่แล้ว +1

    Great tutorial!

  • @joanmuzik
    @joanmuzik 21 วันที่ผ่านมา

    I skipped through the video as i dont have time now, but definitely interesting, informative and cool!
    Will definitely check it out in depth! Thanks for the video

  • @StevesMakerspace
    @StevesMakerspace 2 ปีที่แล้ว

    Very helpful. Thank you!

  • @u2bMusicBeauty
    @u2bMusicBeauty 3 ปีที่แล้ว +1

    Wow 👏😮, I like it, so far so good, it's really fun.+👍

  • @flaviomarcelo9044
    @flaviomarcelo9044 3 ปีที่แล้ว

    Thank you so much, you are amazing.

  • @umeshrajbanshi
    @umeshrajbanshi 3 หลายเดือนก่อน

    The awesome tutorial i have found❤❤

  • @juanjoherreragimenez3988
    @juanjoherreragimenez3988 4 หลายเดือนก่อน

    Fantastic video tutorial, you help me so more for a job thanks you very much

  • @taihatranduc8613
    @taihatranduc8613 2 ปีที่แล้ว

    very good video. thank you

  • @MOHAMMEDIREX16
    @MOHAMMEDIREX16 2 ปีที่แล้ว

    Thank you very much 😉

  • @leonmatryovsk5637
    @leonmatryovsk5637 2 ปีที่แล้ว

    AWESOME

  • @KevinYu900
    @KevinYu900 10 วันที่ผ่านมา

    I followed your tutorial and came last in the class.

  • @mixtapeverse1184
    @mixtapeverse1184 4 หลายเดือนก่อน

    Thank you for this awesome video! How did you capture/export the visualizer and turn it into a video?

  • @mohankrishna3560
    @mohankrishna3560 2 ปีที่แล้ว

    thanks man

  • @lanenaamorcita
    @lanenaamorcita ปีที่แล้ว

    Can I made this animation with a file mp4 instead of mp3? I uploaded I video with some filters but would be interesting adding this sound visualizer and seeing that the animation works contemporary with the music from the video.

  • @mlvmakesart21
    @mlvmakesart21 ปีที่แล้ว

    is it possible for us to load 2 songs simultaneously and give them different waves to see them reacting differently?

  • @techmasterxd4739
    @techmasterxd4739 2 ปีที่แล้ว +1

    Is there anyway you could make this into an actual program which could visualise audio by inserting a youtube link or something like that, it would be very appreciated as I'm working on this as a school project and need some help

  • @SuilujChannel
    @SuilujChannel 2 ปีที่แล้ว

    Great video! One question: why does the flickering of particles stop if you loop backwards?

    • @SuilujChannel
      @SuilujChannel 2 ปีที่แล้ว

      @@bysho thanks for your detailed answer:)

  • @RemRDS
    @RemRDS ปีที่แล้ว

    What's a substitute for the class function? I get a parsing error: keyword 'class' is reserved

  • @filipsozolins347
    @filipsozolins347 2 ปีที่แล้ว +1

    where did you get this music?

  • @911Kano
    @911Kano 2 ปีที่แล้ว

    My music file won't play at all. The audio is on the right folder, what might be the issue? Even clicking doesn't work.

  • @dianab536
    @dianab536 2 ปีที่แล้ว

    hi, thanks for the video. I'm having issues with the update method for the Particle class. nothing syntactically wrong but no particle display. I'm doing this for a react project but the update method doesn't seem to work in my case. only on the p5 editor

    • @dianab536
      @dianab536 2 ปีที่แล้ว +2

      i figured out the problem my this.vel was suppose to be p5.Vector.random2D().mult(0).

  • @Baeyk
    @Baeyk ปีที่แล้ว

    bro, how you record the screen? Please help me! I want recorde my arts to share

  • @AMITGUPTA-nx1dn
    @AMITGUPTA-nx1dn 3 ปีที่แล้ว

    Awesome content man. I was wondering if p5.js can we used in ReactJs project? Not sure , i have a reactjs project and i need to draw some visuals. Please let me know if it can be done

    • @RishiSingh-sc2sr
      @RishiSingh-sc2sr 3 ปีที่แล้ว

      It can be used in reactjs, go for it.

    • @Merthalophor
      @Merthalophor 2 ปีที่แล้ว

      probably difficult, consider using an

  • @christiancampos86
    @christiancampos86 7 หลายเดือนก่อน

    Hi man! thanks for this video, how can i find you on patreon

  • @dear_dada
    @dear_dada 2 ปีที่แล้ว

    hi can i know why my particles just kept generating even the song was played

  • @SumanMondal-cb8yl
    @SumanMondal-cb8yl 3 ปีที่แล้ว

    How do I make the spikes sharper? Anyways a brilliant tutorial ❤️. Keep it up

    • @ColorfulCoding
      @ColorfulCoding  3 ปีที่แล้ว +1

      You could decrease the number of points in the waveform. That would add some more space between each point and make the spikes sharper :)

  • @lunaeclipse5768
    @lunaeclipse5768 2 ปีที่แล้ว

    this is LIT

  • @shrippie-4214
    @shrippie-4214 2 ปีที่แล้ว +3

    So why does my page just say loading.. forever?

  • @rickierick7532
    @rickierick7532 2 ปีที่แล้ว

    May I ask which editor you use to write your p5.js code?

  • @andrewperkinson8941
    @andrewperkinson8941 2 ปีที่แล้ว

    Hi! i have to stupid questions... is the live preview integrated in your visual studio( somehow cant do that)
    and on chrome in the console i cannot execute fft.waveform() VM97:1 Uncaught TypeError: Cannot read properties of undefined (reading 'waveform')
    at :1:5

  • @Weeniehutnurse
    @Weeniehutnurse 2 ปีที่แล้ว

    i'm getting the error cannot access Particle before initialization

  • @IC-ec7hw
    @IC-ec7hw หลายเดือนก่อน

    Is this doable in Flutter?

  • @tomiwaadesanya7346
    @tomiwaadesanya7346 ปีที่แล้ว

    Is it possible to achieve this same thing using python?

  • @redeye-s0ul949
    @redeye-s0ul949 2 ปีที่แล้ว

    How can I fix these errors
    Uncaught (in promise) ReferenceError: loadSound is not defined
    at preload (assignment2.js:9)
    at p5._start (p5.js:62905)
    at new p5 (p5.js:63261)
    at _globalInit (p5.js:62189)
    Uncaught TypeError: Cannot read properties of undefined (reading 'isPlaying')
    at mouseClicked (assignment2.js:38)
    at p5._main.default._onclick (p5.js:78581)

  • @henrickzhang5868
    @henrickzhang5868 11 หลายเดือนก่อน

    what is this song, please share a link with me, Thanks

  • @alehtsiusiankou7636
    @alehtsiusiankou7636 2 ปีที่แล้ว +1

    a have a problem, The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page

    • @ColorfulCoding
      @ColorfulCoding  2 ปีที่แล้ว

      It just means that you cannot directly start the audio from your code. It has to be started by the user gesture, like a click on a button or the canvas

  • @KingKakashi45
    @KingKakashi45 2 ปีที่แล้ว +1

    The particles doesn't show up and I am not sure why...

  • @klemlloydmwenya2224
    @klemlloydmwenya2224 ปีที่แล้ว

    How can this be archived in React.js?

  • @yodering
    @yodering 8 หลายเดือนก่อน

    I've been trying to make this, however, when I use the preload function, my whole page gets stuck on Loading.... what should I do?

    • @ColorfulCoding
      @ColorfulCoding  8 หลายเดือนก่อน

      You are most likely running into some kind of error during the preload function. Have you made any changes to it or is it like the one in the video?

  • @ShortMaster211
    @ShortMaster211 3 หลายเดือนก่อน

    what word to search in petreon

  • @brunoavelar4003
    @brunoavelar4003 2 ปีที่แล้ว +1

    Could this be done with p5.audioIn() and graph the audio from the users microphone in real time?

    • @ColorfulCoding
      @ColorfulCoding  2 ปีที่แล้ว +2

      Definitely! I think thecodingtrain has made a video doing that

    • @brunoavelar4003
      @brunoavelar4003 2 ปีที่แล้ว

      @@ColorfulCoding What a fast reply! Thanks a lot.

  • @vikramenu
    @vikramenu 10 หลายเดือนก่อน

    hi, Can we get the same effect with the mic stream audio data using P5.js?

    • @ColorfulCoding
      @ColorfulCoding  10 หลายเดือนก่อน

      Yes, you can create a audio stream from the mic like this:
      p5js.org/examples/sound-frequency-spectrum.html

  • @cormacang567
    @cormacang567 ปีที่แล้ว

    Hi, my circle is not meeting at the bottom, there is space in between for some reason, can you please address this ?

    • @victoriagrace2139
      @victoriagrace2139 ปีที่แล้ว +1

      i had the same issue and couldn't find the issue to save my life but i ended up randomly messing with the var under the beginShape and by changing the i+= 5 back down to a smaller number like 0.1 it closes the circle !

  • @ezequielignaciosalgueiro7285
    @ezequielignaciosalgueiro7285 2 ปีที่แล้ว

    what software are you using??

    • @ColorfulCoding
      @ColorfulCoding  2 ปีที่แล้ว

      It is just code. But I'm working in Visual Studio Code if that is what you mean :)

    • @ezequielignaciosalgueiro7285
      @ezequielignaciosalgueiro7285 2 ปีที่แล้ว

      Thanks, i use Eclipse, but i have visual studio too ☺️

  • @rikdehoop9612
    @rikdehoop9612 3 ปีที่แล้ว

    Hey man, I keep getting this error "Cannot read property 'length' of undefined
    at RingBuffer.push (f9bb4b58-d2fe-49e9-9dd4-8cb68d6ca98f:75)
    and
    at AudioWorkletProcessor.process (f9bb4b58-d2fe-49e9-9dd4-8cb68d6ca98f:170)" It seems it's the sounds library but I can't find a fix...
    I really want this to work... I tried it without using FFT but just amp and this was just fine. Can you help me?

    • @ColorfulCoding
      @ColorfulCoding  3 ปีที่แล้ว

      Hey, I think it is just a bug in the sound library. I used to get the same error message, but it didn't affect the code or sound in any way, though. However, I got rid of the error message by downloading the newest version of the p5js sound library. I'm not sure this is available on their website, but it is on GitHub. Hope that helps.

    • @rikdehoop9612
      @rikdehoop9612 3 ปีที่แล้ว

      ​@@ColorfulCoding Hey do you maybe have a link to the version you used? because I tried that earlier but without success... I also get two warnings
      "p5.sound.min.js:2 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page"
      and
      "DevTools failed to load SourceMap: Could not load content for 127.0.0.1:5500/libraries/p5.sound.min.js.map: HTTP error: status code 404,"
      maybe this is whats causing the malfunction?

    • @rikdehoop9612
      @rikdehoop9612 3 ปีที่แล้ว

      Hey Thanks, I got it to work!! still have the error though

    • @ColorfulCoding
      @ColorfulCoding  3 ปีที่แล้ว

      Most browsers don't allow audio to start automatically, so you need to create a function that will start the audio - e.g. when you click on the canvas.

  • @bananahit
    @bananahit ปีที่แล้ว

    how to export to mp4

  • @adityasinha3851
    @adityasinha3851 3 ปีที่แล้ว +1

    After pausing the song, I want to resume from the point it was paused at and not from the beginning. How to handle this ?

    • @ColorfulCoding
      @ColorfulCoding  3 ปีที่แล้ว

      If you use "play" after you have used "pause", the song should resume from the point it was paused. If it doesn't, it might have something to do with the sound library. It might solve the problem, if you use the most recent sound library. I think there was a bug in one of the older versions. I don't think the most recent version is available on their webside, but you can get it on their GitHub page. Hope it helps :)

    • @adityasinha3851
      @adityasinha3851 3 ปีที่แล้ว

      @@ColorfulCoding Thank you for quick response. Can I ask one more thing, it is not related to this actually ? I am using p5.js to display live input from microphone. Is there any way to freeze the display ?

    • @ColorfulCoding
      @ColorfulCoding  3 ปีที่แล้ว

      You can use the noLoop() function to freeze the canvas. To resume you can call loop().

    • @adityasinha3851
      @adityasinha3851 3 ปีที่แล้ว +1

      @@ColorfulCoding Thank you for your suggestion. It worked.

  • @sergiocraverath4646
    @sergiocraverath4646 2 ปีที่แล้ว

    i want this music

  • @Sophia-kf6tm
    @Sophia-kf6tm 2 ปีที่แล้ว

    12:40 Can someone explain to me why it is -width/2 and -height/2? Why isn't it 0? I tried and it didn't work.

    • @ColorfulCoding
      @ColorfulCoding  2 ปีที่แล้ว

      The particles is created in the center of the canvas and the origin has previously been translated to the center instead of the top left corner. So (0, 0) is the center of the canvas. In order to check if a particle has hit the left edge, we need to check if its x position is smaller than -width/2. Hope that makes sense

    • @Sophia-kf6tm
      @Sophia-kf6tm 2 ปีที่แล้ว

      @@ColorfulCoding Yes it does. Thank you😄

  • @timetraining6496
    @timetraining6496 ปีที่แล้ว

    Do you teach? I would like to learn from you.

  • @bypro8511
    @bypro8511 2 ปีที่แล้ว +1

    why you dont doing free site for that can you doing it we all need it too much pls

  • @swiftsausages
    @swiftsausages ปีที่แล้ว +1

    Hello. Great tutorial. Do you have any suggestions to modify this code to make it more alike to this one here? th-cam.com/video/luXtNn64rWY/w-d-xo.html
    I don't think this one uses waveform and instead has different parts of the wave reacting to different elements such as the bass and the treble. Would love some suggestions.

    • @arter9370
      @arter9370 ปีที่แล้ว

      I believe what is happening here is that the audio is separate into 4 parts, like using the Moises app. Then use this tutorial but instead of a mirror, you section this into 4 parts, all using a different instrument of the song like bass, drums, vocals and others.

  • @nelsonfrank
    @nelsonfrank ปีที่แล้ว

    Great content, but i think you should use your own voice or really human voice..