3 Options for Playing Audio on Arduino

Поделиться
HTML-код
  • Опубликовано: 30 ноя 2024

Комментарии • 131

  • @djsans3
    @djsans3 2 года назад +56

    I'm pretty sure that wav files don't have bad quality. Compared to mp3 files they have a constant bit rate so they should be better quality. Besides that I really enjoy your videos, thank you for your amazing work!

    • @lowlink534
      @lowlink534 Год назад +4

      I think the problem is downsampling, he's using less than 20kHz, so it's gonna be noticeable. I didn't play around with it so I'm not sure if you need to do that so the Arduino can play (I think the max frequency of the CPU itself is lower than 20k or something), also not sure why the mp3 solution doesn't have this problem

    • @soheil5710
      @soheil5710 Год назад +1

      @@lowlink534 Slight correction, the Arduino clock speed is 16MHz. That's mega as in millions, so plenty for this kind of project.

    • @lowlink534
      @lowlink534 Год назад

      @@soheil5710 Lmao did you ever actually try to play audio on Arduino?
      No offence meant, but playing audio is way harder than just using one instruction per cycle. You have to read the samples from memory and write them to the audio out (generally port 9 using the PMW in mysterious ways with Mozzi, for example), plus all the processing you might do to the audio. To change volume, for example, you have to multiply the value, many cycles already going down the drain for every sample. If you have multiple samples, you have to sum them all, if you're using effects, you have process everything they do. Plus any project that actually do anything will have user input that will have to be processed as well. I talked about the less than 20kHz because Mozzi, the only Arduino lib I know that have a decent audio output, doesn't support much more than 16kHz samples (plus the memory on the Arduino itself is the biggest limitation, using only samples at 10kHz max, I was barely able to fit a drumkit of samples on the memory, and the hihat/crash samples are very short, like if you want to sustain, you have to replay them at lower volume while the original is playing. Plus I needed to save the patterns for the drum machine and other stuff on memory, and my Arduino Uno only has 20kb left, after the basic Arduino firmware and the basis of Mozzi running for audio out, so that's all I had to work with. Also Arduino doesn't have proper audio outs, you could do a DAC and output from like 8 digital ports, but that's madness (I saw some projects like that and assumed it was the only way it could be done, totally wrong). Mozzi somehow allows to output decent audio from a single PMW output, but the audio itself can become quite noisy and unstable, since you're kinda "cheating" to output audio and always outputting at 5V, which is way more than let's say an electric guitar or bass, and at the limits of a line in/out, I believe. That, along with the low samplerates often employed because of the low Arduino memory, make the audio quality very lofi

    • @lowlink534
      @lowlink534 Год назад +3

      @@soheil5710 Lol now I see what you mean, I have no idea why in my original comment I said the CPU runs at less than 20k, no CPU probably ever ran at that low of a clock lol
      Back then I also didn't have as much experience with Arduino and Mozzi, but that still is no excuse lmao

    • @soheil5710
      @soheil5710 Год назад +3

      @@lowlink534 No worries I've been confused myself before

  • @BadPractices
    @BadPractices 2 года назад +31

    Fantastic video, fantastic instruction, fantastic presentation, plus you included a pro/con list and timestamps. Instantly subscribed.

  • @nutelhere
    @nutelhere Год назад +9

    cool video, but would be better if you muted bgm while arduino was playing sounds...

  • @spencerharrisonx3700
    @spencerharrisonx3700 Год назад +5

    Why does option 3 need amplifying? Is it because they are .wav files? Can you not set the volume higher with the tmrpcm.setVolume(x); or is it because of the speaker you are using?

  • @nusior
    @nusior 2 года назад +7

    Cool! I'm about to build something like no. 3 with the file on repeat. But I'm a total arduino noob so I hope I'll be able to find some code to do the trick painlessly 😁. Bought it 8 years ago, never even take it out of the box. Finally I have an opportunity to make a little project and start my arduino adventure 😆

    • @JustBaselmansYT
      @JustBaselmansYT  2 года назад +3

      Sounds great! Good luck with the project and the start of hopefully a long arduino journey ;)

  • @MrMat4552
    @MrMat4552 7 месяцев назад +15

    No need for background music as it made it worst

  • @stefanoongaretti9101
    @stefanoongaretti9101 3 месяца назад +2

    Hi, fantastic video. I'm interested in option number 1 but you haven't said the name of the speaker in the video so I don't know how to buy it. ope you can still give me the name o the speaker, thank you

    • @JustBaselmansYT
      @JustBaselmansYT  3 месяца назад

      First of all thank you so much :) It's from an old pc but every 3 watt speaker should work.

    • @stefanoongaretti9101
      @stefanoongaretti9101 3 месяца назад

      @@JustBaselmansYT Thanks

  • @Mokkers_stuff
    @Mokkers_stuff 5 месяцев назад +12

    Re:background music. Just because you can, doesn't mean you should. It detracted so much from your video, especially one that involves audio.......

  • @rokljhui864
    @rokljhui864 10 месяцев назад

    Option 1 has the lowest latency, and can play complex sounds with dynamic volume range and reasonable quality , via 20kHz PWM.

  • @admali2142
    @admali2142 Год назад +2

    Thanks, its very good demonstration. I tried to access the files Zip and the sketch but without success?

  • @soloman3140
    @soloman3140 9 месяцев назад +1

    Amazing sir solved all problems i was facing 😁

    • @JustBaselmansYT
      @JustBaselmansYT  9 месяцев назад +1

      That is amazing to hear! Good luck with your project👍

  • @filipegaspar3572
    @filipegaspar3572 5 месяцев назад +1

    The 2nd option seems to be the best one in terms of quality sound but the fact it can only run 1 audio is a pain. How much different audios can you store to play in the 3rd?

    • @RoseElias
      @RoseElias Месяц назад +1

      almost infinite. like how much fits on the sc card

  • @user-km8tg6pe8o
    @user-km8tg6pe8o 28 дней назад

    May I ask how can I add more bigger speaker.

  • @Anonymous-hd7en
    @Anonymous-hd7en Год назад +3

    I have one question , in the second method (sd card) is the output digital audio (pwm) ?

    • @samir3216-bs1lv
      @samir3216-bs1lv 3 месяца назад +1

      look,this video is pretty old but i will explain it
      Yes,because audio needs the pwm output so it can level up or level down voltage intensity
      meaning that you really need that pwm,like there is no way you would play a audio only using HIGH,LOW

  • @crumbubblethethird1853
    @crumbubblethethird1853 18 дней назад

    Is there a line of code for method 1 to increase or decrease volume?

  • @acousvnt
    @acousvnt Год назад +4

    I don't think background music is ideal on a video where you are demonstrating audio. I'd rather hear the thing by itself, especially in a case like this where the arduino is very quiet.

    • @JustBaselmansYT
      @JustBaselmansYT  Год назад +3

      Thanks for the feedback, in the future I will do this differently

  • @matteodoveri5170
    @matteodoveri5170 Год назад +2

    Hi! I follow every step of your tutorial but the program doesn't work successfully. I think the problem is the convertion of the file in wav. I tried to use the website that you reccommended but (I'm italian) in italy it is down. I'm very sad and frustrated because of this issue. I wish you can help me and my project. Thanks

    • @gavinwilson8554
      @gavinwilson8554 10 месяцев назад

      could you get the website to work with a VPN?

  • @spicyshotz
    @spicyshotz 2 года назад +2

    Hi, How would you reccomend to amplify the sound in example 3? thanks.

    • @lowlink534
      @lowlink534 Год назад

      You can easily do that witha transistor, search for a simple transistor amp, basically you power it and put the sound cord on the other port, you just gonna know which port is which of the transistor

  • @ThaMentalGod2003
    @ThaMentalGod2003 6 месяцев назад +1

    but aint .wav higher quality than .mp3??

    • @ComandanteJ
      @ComandanteJ Месяц назад

      Yeah, .wav is uncompressed so it can go from audioPotato quality to top notch 192khz/24 bit and such

  • @phillipdarrenmperez9364
    @phillipdarrenmperez9364 3 месяца назад

    How do i put a timer in #2,its for a automatic bell with speaker for our school project ,PLEASE HELP ME😢😢😢😢😢😢😢😢

  • @gold-fox
    @gold-fox 8 месяцев назад

    Hello!
    I'm trying to make some sort of detector that can play sounds upon a certain distance, and it'll play a different sound depending on the distance of the object and the detector.
    Do you have any idea where I could find an arduino card that could allow such a thing to happen?

    • @JustBaselmansYT
      @JustBaselmansYT  8 месяцев назад +1

      You need an ultrasonic sensor (to measure distance), an arduino (does not matter which one) and something to play sound. Any of these 3 options can do and I also have a few other videos on ways to play audio using arduino.

    • @gold-fox
      @gold-fox 8 месяцев назад

      @@JustBaselmansYT Oh ok. I'll see it later!
      And thanks by the way!

  • @michaelkim3930
    @michaelkim3930 Год назад +3

    how do you play multiple files with option 3 in the code? do you just separate each file that you want to play by a comma in the .play line?

  • @nickc7039
    @nickc7039 7 месяцев назад

    can you do multiple sounds with option one? Different tone for every bin?

  • @ultralaggerREV1
    @ultralaggerREV1 Год назад

    For option three I want to add the little button that comes with the Arduino starter kits, how would I change the wiring so that every time I hit the button, it plays the audio

    • @JustBaselmansYT
      @JustBaselmansYT  Год назад

      I would connect the button separately to the arduino and in the code only play the audio when the button is pressed. take a look at Arduino's own button examples in order to do this👍

  • @KabbyRobloxGamer
    @KabbyRobloxGamer 6 месяцев назад

    I have a question, I made my humanoid Arduino, so how do I join it to my humanoid?

    • @JustBaselmansYT
      @JustBaselmansYT  6 месяцев назад

      Can you maybe further explain the problem? These functionalities should be able to be added to most arduino projects

    • @KabbyRobloxGamer
      @KabbyRobloxGamer 6 месяцев назад

      @@JustBaselmansYT I got it figured out now, btw I was meaning like only use arduino uno and not the bread board, now no need I got it figured out, thx btw, thx cuz I learned how to put the wires

  • @thomascastelluccio
    @thomascastelluccio Год назад

    For the second option how would i connect the 2 wires without a button and have it be something like everytime a servo reaches a certain position?

    • @JustBaselmansYT
      @JustBaselmansYT  Год назад

      You do not need the button, you can just execute the code when a servo hits a certain angle, if you are able to detect this

  • @digimaks
    @digimaks 11 месяцев назад +10

    I wish you bothered turning off your BACKGROUND PIANO MUSIC when playing back sounds... It interferes very badly.

  • @axok
    @axok 28 дней назад

    good video but please stop background music when testing audio

  • @minckvantuijl8126
    @minckvantuijl8126 11 месяцев назад

    Is it possible to use the speakers of example 2 for the configuration of example 3? or does it need some sort of amplifier?

    • @JustBaselmansYT
      @JustBaselmansYT  11 месяцев назад

      Yes you can use both speakers for the different examples, soon there will also be a video online with a 4th example of how to play audio on an arduino. And this is in my opinion the best way, so keep on the lookout for that ;)

  • @taile-kv3ek
    @taile-kv3ek Год назад

    Rat dang mat tien mua va nghien cuu cac nuoc dang phat trien con nuoc ngheo thi mat thoi gian mot hai the ki nua tu ho moi lam thanh cong ok

  • @rkjayakrishnan3997
    @rkjayakrishnan3997 9 месяцев назад

    how to directly play sound instantly received from an Arduino mic to speaker as the response to be flashy with no delay

  • @As7ik.Mo7amm3d
    @As7ik.Mo7amm3d Год назад

    @justbaselmans is There any options to put 2 audio from sd card?

  • @HaofeiNiu
    @HaofeiNiu 11 месяцев назад

    Hey does anyone know which module is used in the greeting card sample? Can't get the greeting card one from where I live, is it an mp3 module?

    • @JustBaselmansYT
      @JustBaselmansYT  9 месяцев назад

      If you Google "greeting card module DIY" you should definitely find it, good luck!

  • @annamariakiki
    @annamariakiki 9 месяцев назад

    hello, what speaker did you use for the first option?

    • @JustBaselmansYT
      @JustBaselmansYT  9 месяцев назад

      It's from an old pc but every 3 watt speaker should work.

  • @leo935_6
    @leo935_6 Год назад

    In option 2 can you put more than one audio?;Can it be made to play only a random track every time it receives power?

  • @tariareese9546
    @tariareese9546 Год назад

    can you please tell me what you needed to solder in option 2?

    • @JustBaselmansYT
      @JustBaselmansYT  Год назад

      Remove the button that comes with it and solder two wires to it so you interact with it using a breadboard/arduino

  • @derguutebabobauer
    @derguutebabobauer Год назад

    I tried third Option and it works but it's really quiet. I have a 0.2W speaker and connected it directly to VCC. Do you know if there is any way to make it louder. If I use an amplifier I overload the speaker, don't I?

    • @kylorens9537
      @kylorens9537 Год назад

      Get a bigger speaker with more W, but then u also need amplifier

  • @oscarbriones8580
    @oscarbriones8580 Год назад

    Quick question! For option 2 I'm trying to do a similar scenario, but with a IR sensor. When I try to use the code you provided with the IR sensor, my Arduino goes crazy and connects and disconnects from my computer. Would you know the solution for this?

    • @JustBaselmansYT
      @JustBaselmansYT  Год назад

      I would recommend to make sure that all parts behave like you intended without connecting them together. 1.Are you able to detect the infrared signal and writing it to your serial monitor. 2. Are you able to play a sound using a digitalWrite? If you can do both I am not sure where the problem is? Maybe someone elke can coming across your command can help you out or you can ask on an arduino forum.

  • @nickst2797
    @nickst2797 2 года назад

    Such a great video! I was using tone() but i wanted to perform volume control. I found toneAC, but unfortunately, the quality is not as good as the original tone(). Do you know if it is possible to perform volume control? Even with external Hardware. Thanks!

    • @JustBaselmansYT
      @JustBaselmansYT  2 года назад +1

      I am actually not sure, unfortunately I have no experience with this sorry

    • @nickst2797
      @nickst2797 2 года назад

      @@JustBaselmansYT Thank you!!

    • @deodeo803
      @deodeo803 Год назад +2

      if you want volume control, u could get a potentiometer and connect it between the output speaker and the arduino.

  • @mahdikhs4611
    @mahdikhs4611 Год назад

    I just want to use my speaker as an AUX for my pc, how I can do that

    • @tbf79alexis
      @tbf79alexis 9 месяцев назад +1

      buy a mono aux port and an amplifier for arduino speakers, wire them together and there you go

  • @shu_5d
    @shu_5d 6 месяцев назад

    great video, but when i try to use option 2 with a 9V battery instead of usb the speaker just makes clicks and plays no music... do you have an idea how to fix it?
    edit: my 9v battery wasnt gully charged…

    • @JustBaselmansYT
      @JustBaselmansYT  6 месяцев назад

      Hey, hope it is now working! Enjoy the project

    • @shu_5d
      @shu_5d 6 месяцев назад

      yeah it’s working now thnaks for the video

  • @pruthvirajhm
    @pruthvirajhm Год назад +1

    OMG I loved it like anything 😍 💕
    its awesome dude.

  • @voldemortvanhellxing5898
    @voldemortvanhellxing5898 Год назад

    What speaker was used on the 3rd option?

    • @JustBaselmansYT
      @JustBaselmansYT  Год назад +1

      It is a 3watt speaker I think, got it from an old laptop.

  • @nithitechexperimentsdiy9613
    @nithitechexperimentsdiy9613 Год назад

    How to make it more sounder

  • @koenkloosterhuis1710
    @koenkloosterhuis1710 2 года назад

    Hallo, would it be possible to create the second option with a PIR sensor, instead of a button? Also would it be possible to create the third option with a YX5300 mp3 module? Have been struggeling to get a project to work for a while now...

    • @JustBaselmansYT
      @JustBaselmansYT  2 года назад

      Yes ofcourse you can use this code: create.arduino.cc/projecthub/electropeak/pir-motion-sensor-how-to-use-pirs-w-arduino-raspberry-pi-18d7fa and only change the LOW and HIGH arround that should work.I do not know much about the YX5300 mp3 module so no idea, you should do some more googling ;) good luck!

  • @Lasanza227
    @Lasanza227 Год назад

    hey it is not working for me all i changed was i put 2 wires that i would touch together instead of a button and i am using an arduino uno R3 please help if u can

  • @capnac3
    @capnac3 Год назад

    I dont know what im doing wrong but cant activate the module with the button (I'm doing method number 2)

    • @lawrencevaldez7052
      @lawrencevaldez7052 Год назад

      Yeah same here, the other wire connected to the button that was shipped off wasn’t connected

  • @tillytony
    @tillytony Год назад

    What is the name of the third one please?

  • @aripjamaludinrumi
    @aripjamaludinrumi 13 дней назад

    woww thanks for the video 👍

  • @nealmucklow1933
    @nealmucklow1933 6 месяцев назад

    TURN OFF BACKGROUND NOISE WHEN RUNNING SOUND FILRS>>>GEEZE

  • @subvtk
    @subvtk 8 месяцев назад +2

    Thank you! But next time wihout the piano in background, please!

  • @hal47
    @hal47 Год назад

    How can tft 2.8 display video

  • @sahiltamboli7371
    @sahiltamboli7371 Год назад

    what if i want to play live(current) audio (for example: from youtube) instead of playing mp3 file

    • @ishen4430
      @ishen4430 8 месяцев назад

      you would have to use an esp8266 module

    • @sahiltamboli7371
      @sahiltamboli7371 8 месяцев назад

      @@ishen4430 my god. So many things happened in 11 months.

    • @sahiltamboli7371
      @sahiltamboli7371 8 месяцев назад

      @@ishen4430 I stopped working on it because a certain someone used to disturb my peace. Now that person is gone. It feels hollow from inside where I dont have anything else to do other than work to feed myself and pay rent. Dont even go to gym anymore..

  • @BeeKeyPro
    @BeeKeyPro 11 месяцев назад

    Thanks for that amazing video! i subscribe!

  • @tleonard410
    @tleonard410 2 года назад

    Where can I buy the greeting card module in @1:20

    • @JustBaselmansYT
      @JustBaselmansYT  2 года назад

      I found mine on amazone but there are also on AliExpress

    • @tleonard410
      @tleonard410 2 года назад

      @@JustBaselmansYT link?

    • @Chaldaean
      @Chaldaean 2 года назад

      @@tleonard410 the link is in the video description

  • @marchache
    @marchache Месяц назад

    DFPlayer mini by Dfrobot $6 US for original, cheaper for clones. Way better than all those

  • @radzisham
    @radzisham Год назад

    32 gb support fat 32?

  • @jakubbukaj4133
    @jakubbukaj4133 11 месяцев назад

    Can i use piezo in first option ?

  • @otrocanalsincreatividad9640
    @otrocanalsincreatividad9640 Год назад

    Thanks man, You saved me!

  • @Yrekcaz7
    @Yrekcaz7 5 месяцев назад

    4:49 ANKI VECTOR SDK EXAMPLES!?!

    • @Yrekcaz7
      @Yrekcaz7 5 месяцев назад

      Oh, I'm so dumb, I had no clue this channel had much to do with those robots, but vector is literally in his pfp

    • @JustBaselmansYT
      @JustBaselmansYT  5 месяцев назад +1

      Haha insane you noticed and yes, love working with the little guy and am very sad he is currently not really supported anymore :'(

    • @Yrekcaz7
      @Yrekcaz7 5 месяцев назад

      ​@@JustBaselmansYTyeah, I found that out the hard way :(
      The solution is WirePod. It's a free alternative to the servers (which are down). You'll have to Google to find it since my comment with the link got held for review or something, but it's on GitHub.
      I hope that helps!

  • @abramotolani9479
    @abramotolani9479 6 месяцев назад

    Video is a bit good but the background music spoilt it all

  • @sanjana2186
    @sanjana2186 Год назад

    thank you it worked👍

  • @robertrobert5583
    @robertrobert5583 2 года назад +140

    That piano is so irritating.

    • @ElfilinSupporter
      @ElfilinSupporter Год назад +10

      i don’t mind it :o

    • @acousvnt
      @acousvnt Год назад +21

      Especially when the demonstrations involve audio; just let us listen to the actual thing.

    • @mlemery69
      @mlemery69 Год назад +3

      i hate to tell u theres a whole music genre around it

    • @acousvnt
      @acousvnt Год назад +13

      @@mlemery69 it's not the genre, it's the fact that we're trying to listen to something else at the same time.

    • @suprajgabhane
      @suprajgabhane 8 месяцев назад

      It's not a fact

  • @ΝαφαςσκαταΣκασε

    Thenxs

  • @paramtrx9558
    @paramtrx9558 Год назад

    Cool Thx!

  • @pkikon6983
    @pkikon6983 Год назад

    Video is good but the background piano is annoying

  • @Aminfikivza-X1
    @Aminfikivza-X1 Год назад +1

    YASSSSSS

  • @JuggernautICBM
    @JuggernautICBM 4 месяца назад

    Nice

  • @TheUnofficialMaker
    @TheUnofficialMaker 5 месяцев назад

    cut the music

  • @Gallardo6669
    @Gallardo6669 Год назад

    Thx for the video. But your background musik is absolutely horrible.

  • @baldervinje1020
    @baldervinje1020 9 месяцев назад

    i love you

  • @joejimmathew7204
    @joejimmathew7204 Год назад

    absolute bullshit
    the Option 3 did not work

  • @Новости-з3й
    @Новости-з3й 5 месяцев назад

    Your musical taste is of no interest !
    Stop these awfull background noise !!!

  • @LightningGoldStudios
    @LightningGoldStudios 7 месяцев назад

    Hey, what kind of speaker did you use on option number three?

    • @RoseElias
      @RoseElias Месяц назад

      i used some old 4 ohm speaker