C++ Wav Audio Programming From Scratch - 4.2 - Mini Lab

Поділитися
Вставка
  • Опубліковано 26 сер 2024

КОМЕНТАРІ • 78

  • @ferrabacus2980
    @ferrabacus2980  3 роки тому +17

    The audio sound is fairly faint, if you can't hear the sound that was created, let me know and I'll post a single clip with the audio again!

    • @yolamontalvan9502
      @yolamontalvan9502 3 роки тому +1

      UA-cam needs your code to enhance the sound reproduction. Thanks for the video.

    • @chopov11
      @chopov11 2 роки тому

      Can’t hear the audio. But i will code it myself and see haha

    • @DanielBrosman08211986
      @DanielBrosman08211986 2 роки тому

      Blblabla I cant hear you Speak louder or get a new microphone, This has been so unprofessional

    • @Silveronix232
      @Silveronix232 Рік тому +5

      @@DanielBrosman08211986 this guy is helping a lot of people with his video and you just come crying about the volume? Don't you know how to turn the volume up or something?

  • @ovi1326
    @ovi1326 2 роки тому +25

    This channel is criminally underrated. I like how you go out of your way to not use uint16_t and uint32_t so they don't scare off the beginners and also just define a bunch of std::strings in the global scope, yet this is a tutorial on binary files and audio generarion which there are not that many beginner-friendly resources on these. Great video.

    • @ferrabacus2980
      @ferrabacus2980  2 роки тому +7

      I really appreciate your comment, it means a lot. I’m hoping I can keep those same qualities in some of the upcoming videos I have planned!

    • @gijahara5345
      @gijahara5345 2 роки тому

      I absolutely agree,

    • @skilz8098
      @skilz8098 Рік тому

      This is just the source code to generate - write audio to a file. Try writing the program that opens an audio file, parses it, reads in the audio data, processes it (compression/decompression, handle codecs, encryption/decryption, etc, ...) and then sends it to the hardware through proper system channels and ports to be played back by your audio/speaker device(s). Then once you're able to play the audio file, you need to be able to pause it, play it in a loop, stop it, etc... Then write the software to dynamically manipulate or alter the sound being played through various filters and effects. So in some regards, this is still just the beginning, and this is being done in C++. Try doing this in direct assembly :) But, yes I can agree with your statement, there are so few beginner friendly resources on these semi-advanced topics.

  • @gijahara5345
    @gijahara5345 2 роки тому +10

    I really really respect this, perfectly explaining confusing concepts.

  • @manuellernst3700
    @manuellernst3700 3 роки тому +4

    I've just tried to do the same thing using fstream a week ago and couldn't do it due to my little experience. Now having this video is this month's most awesome coincidence! I'll make an edit once I try it

    • @ferrabacus2980
      @ferrabacus2980  3 роки тому +2

      What an awesome coincidence! Hope it worked out!

  • @mohsenir69
    @mohsenir69 10 місяців тому +1

    This is the kind of programming tutorial I need, Thanks for your great video

  • @vanessaadams3500
    @vanessaadams3500 4 місяці тому +1

    This is one of the best videos on this subject that I have found so far!

  • @FatalNight199
    @FatalNight199 6 місяців тому

    beautiful, what a perfect video. One week ago, I was finally diving in this programming universe just for fun, and now I casually find this video of you putting in practice a lot of things I read in cplusplus this days. Thank u very much, really.

  • @KarthikRao449
    @KarthikRao449 3 роки тому +3

    Wonderful video. This is the first video of the channel I have seen. For sure will see the other lessons. Good stuff, keep at it and many Thanks.

    • @ferrabacus2980
      @ferrabacus2980  3 роки тому +1

      Thank you! I'm glad to see you are enjoying it!

  • @sabanadminolmayan8265
    @sabanadminolmayan8265 Рік тому

    That was unbeliavable helpful. I watched it with lot of pause. Extreme good explanations.

  • @spamfilter32
    @spamfilter32 2 роки тому

    For those who are unable to hear anything, check your matching parentheses. I had this problem and discovered I was missing a matching parentheses after 'sample_rate' in the formula for assigning 'value', line 65; fixed the amplitude problem.
    it hasn't caused any problems yet, but on line 74 I get a compiler warning about a stack overflow from 8 byte conversion to 4 byte with the "-4"
    as an addition, I created a Pan struct to control the left and right amplitudes and then used that to create a Crossfader, and a fade out, and how to play back to back notes. Next step is to create an ADSR envelop, and then to start abstracting it all out into classes to make more readable code. Future steps will be to create the ability to play 2 notes simultaneously, and then to create an instrument class where each instrument will have a group of harmonic's and overtones and then when I call the instrument, I will feed it the fundamental frequency and the duration to play it, and the class will create the complex wave. Final step will be to add live playback ability

  • @perebalsach
    @perebalsach 3 роки тому +4

    Thanks for this one!! Would be nice to have more c++ audio content. Is hard to find tbh!

    • @ferrabacus2980
      @ferrabacus2980  3 роки тому +1

      I completely agree, is there any specific c++ audio content you would want to see?

    • @perebalsach
      @perebalsach 3 роки тому +6

      @@ferrabacus2980 What about mixing sounds? Displaying a sounds waves (imgui?) Principles of a sound engine or how to tackle a sound engine?
      Maybe is too much or the complexity is quite big. But for example doing a sound engine series would be really nice. There is no content available, so you have an opportunity here :)

    • @perebalsach
      @perebalsach 3 роки тому +2

      @@ferrabacus2980 what about sound fx, like a reverb, echo, distortion,... That couls be really nice too 😊

    • @chopov11
      @chopov11 2 роки тому

      I agree, would like to see some dsp videos using c++. Audio effects such as distortion, reverb or eq as Pere mentioned on this comment thread. Please Keep up the videos they are super helpful!

  • @JackHeslewood
    @JackHeslewood Рік тому +1

    Thank you so much! Can't wait to binge watch the rest of this course. I'm learning C currently however the syntax used here is easily recognisable so it was very helpful.

  • @xyvler3041
    @xyvler3041 3 роки тому +4

    These videos are really helpful thank you for sharing

  • @chillydill4703
    @chillydill4703 Рік тому +1

    What a fantastic channel. Thank you for doing this kind of stuff!

  • @maximdanilov6562
    @maximdanilov6562 3 місяці тому

    Thanks for the video, it was really helpful!😊

  • @AS-kw1ob
    @AS-kw1ob 2 роки тому +1

    This is really nice. I would love to see the opposite way. Reading the data of a wav file and of a mp3 file. I try to compare audio files, that would help me a lot.

  • @nilsdrees9228
    @nilsdrees9228 3 роки тому +9

    Good video!
    Any particular reason why you used std::string over char* ?
    Also, the way you structured the code makes it really easy to outsource the header variables into a nice header struct, this video is very helpful and makes it easy to do further experiments!

    • @ferrabacus2980
      @ferrabacus2980  3 роки тому +4

      Hey Nils, thank you for the feedback! I've been trying to use the modern c++ features when I can. I personally like the ability to use the builtin functions with std::string and the relational operators for comparison. However, I think that choice comes down to which one you are more comfortable with for most programs.
      That is awesome, glad to see you experiment with it! I wanted to put that in a header for the video but it was already so long! haha

  • @LogicEu
    @LogicEu 3 роки тому +2

    This is incredible, thank you, this video is super helpful

  • @kb3khs
    @kb3khs 2 роки тому

    Generating wave audio is fun. Recording wave audio is difficult and OS dependent. I'd love a video on recording audio.

  • @Harshu_awni
    @Harshu_awni 5 місяців тому

    Hey bro thanks for your content I just found what I am looking for 😊😊

  • @mikelong3444
    @mikelong3444 Рік тому +1

    This is fantastic

  • @TobyAdd
    @TobyAdd Рік тому

    good video to understand wav base, thank you

  • @chrisschuller7055
    @chrisschuller7055 3 роки тому +2

    Very good video. The channels are not exactly doing what you intended because of the "amplitude" variable. Should be divided by two instead of the "channel1" in order to get the correct output.

    • @ferrabacus2980
      @ferrabacus2980  3 роки тому +1

      Thanks Chris! That is a really good point. I plan to redo this with GUI soon, and will make sure to fix that. Thank you.

  • @Allition1337
    @Allition1337 2 роки тому +2

    good video! solved alot of questions =D

  • @chopov11
    @chopov11 2 роки тому

    Your video was so amazing!!! Please if you are looking for a teaching job come teach c++ at Columbia our current teacher is horrible😂😂

  • @davidste60
    @davidste60 3 роки тому +3

    Good video. I think subchunk1_size is literally what it says though, the format chunk is 16 bytes, not counting the subchunk1_id and subchunk1_size values. So nothing to do with the bits per sample (except by coincidence in this case).

    • @ferrabacus2980
      @ferrabacus2980  3 роки тому +1

      Thanks David, I don’t know how I messed that up in the video. Thanks for pointing that out!

  • @matsredman7640
    @matsredman7640 Рік тому

    Super helpful. Thanks!

  • @dobcs3236
    @dobcs3236 Рік тому

    Thank you, thank you, thank you very much

  • @nicholas3895
    @nicholas3895 6 місяців тому

    I'm a beginner, could you please help me?
    I understood that at the beginning of the WAV file we have a series of bytes that represent the info of the file and each info has to occupy a specific size in bytes. "Num channels" for example is represented as an INT in the program, but it can't be seen as an INT in the WAV file because it would occupy 4 bytes and not 2, so you convert it with the function write_as_bytes(), but to be honest i didn't understand it at all due to my lack of knowledge. Could you please explain it to me in a simple way?

  • @oneday374
    @oneday374 Рік тому

    Thank you so much 👋

  • @xyvler3041
    @xyvler3041 3 роки тому +1

    Cool video

  • @ayushdave9939
    @ayushdave9939 2 роки тому

    Well, I had to increase the chanel1 and chanel2 value times 500 and it gave me a simple increasing high pitch sound which was interesting though. But I was really looking forward to that bell sound and Yeah the wave form was strangely very minute like I figured it out somehow that I had to increase some value but it was kinda unexpected. Still thanks though, guess my first audio program was a simple high pitch strange sound which if increased a lot could be very sharp or unhearable(you could see it on the decibal scale of Audacity. haha). Thanks again :)

  • @basboerboom9328
    @basboerboom9328 10 місяців тому

    Can't you use a short instead of an int for the 2 byte formats?

  • @nkumar8174
    @nkumar8174 5 місяців тому

    Hi, this is truly a master class. I need help and please let me know, how can I contact you. Thank you

  • @jeordanisfiguereo7592
    @jeordanisfiguereo7592 3 роки тому +1

    Thanks!

  • @mustafaserhatbeyazay3912
    @mustafaserhatbeyazay3912 2 роки тому

    Nice video ,i am curious about getting a voice Signal (Analog input) from a mic and transform analog into to binary with cpp

  • @matthewhurin945
    @matthewhurin945 Рік тому

    I was playing with SSTV recently and I wanted to see if I could program something of the sort. I;m just starting and have no idea how to read a wav file but here are some changes I made
    I have
    8000 bitrate and 1 channel
    const int duration = 2;
    const int hz = 100;
    const int max_amplitude = 32760;
    const double frequency = 1000;
    //160 datapoints becasue 8000 bits per second, for 2 seconds, divided by 100 values per second = 160
    float data[160] = { 1.1, 1.3, 1.4 ,1.5,1.7,1.3,1.2,1.2,1.1,1.6,1.6,1.9,1.8,1.3,1.2,1,1.1, 1.3, 1.4 ,1.5,1.7,1.3,1.2,1.2,1.1,1.6,1.6,1.9,1.8,1.3,1.2,1,1.1, 1.3, 1.4 ,1.5,1.7,1.3,1.2,1.2,1.1,1.6,1.6,1.9,1.8,1.3,1.2,1, 1.1, 1.3, 1.4 ,1.5,1.7,1.3,1.2,1.2,1.1,1.6,1.6,1.9,1.8,1.3,1.2,1, 1.1, 1.3, 1.4 ,1.5,1.7,1.3,1.2,1.2,1.1,1.6,1.6,1.9,1.8,1.3,1.2,1, 1.1, 1.3, 1.4 ,1.5,1.7,1.3,1.2,1.2,1.1,1.6,1.6,1.9,1.8,1.3,1.2,1, 1.1, 1.3, 1.4 ,1.5,1.7,1.3,1.2,1.2,1.1,1.6,1.6,1.9,1.8,1.3,1.2,1, 1.1, 1.3, 1.4 ,1.5,1.7,1.3,1.2,1.2,1.1,1.6,1.6,1.9,1.8,1.3,1.2,1, 1.1, 1.3, 1.4 ,1.5,1.7,1.3,1.2,1.2,1.1,1.6,1.6,1.9,1.8,1.3,1.2,1, 1.1, 1.3, 1.4 ,1.5,1.7,1.3,1.2,1.2,1.1,1.6,1.6,1.9,1.8,1.3,1.2,1};
    for (int i = 0; i < sample_rate * duration; i++) {
    int asdf= round(i / hz);
    double amplitude = 20000;
    double value = sin((2 * 3.14 * i * frequency * data[asdf]) / sample_rate);
    double channel1 = amplitude * value;
    write_as_bytes(wav, channel1, 2);
    }
    It creates a constant amp changing frequency file

  • @missq4024
    @missq4024 2 роки тому

    In this video, you have manually created the shape of the sound wave, I am searching for a tool that is able to activate my microphone I/O to record WAV audio. I use Mac OS as well, anyone has ideas on how can I accomplish that? There are a few tutorials online.

    • @firstnamelastname-oy7es
      @firstnamelastname-oy7es 2 роки тому

      what about a program called audacity? It can record audio from a microphone into a file, you should be able to save it in a wav file.

  • @ayush.kumar.13907
    @ayush.kumar.13907 2 роки тому

    the WAV format image lists some sections being stored in little endian and some in big endian, how is your program dealing with that? you seem to have used the default endianness for all the sections.

    • @doglitbug
      @doglitbug Рік тому

      Yeah I noticed this too!

  • @supergeorgem3599
    @supergeorgem3599 Рік тому

    Dear Mr. Ferrabacus,
    I have a question, some of my students came here and watched your very explanatory video to complete a task that I proposed to them. If you had to rate them, what would be the percentage you would assign from 0% to 100%?
    By the way, where does the name of your profile come from?
    Thanks in advance.

  • @user-kn8tp7jo3c
    @user-kn8tp7jo3c 6 місяців тому

    do you have a github with this file? i typed it over but there isn't any data written to my test.wav
    (edit): i missed "(" in line 65. great tutorial btw

  • @sean8190
    @sean8190 3 роки тому +1

    is this for a class? Where do you teach?

    • @ferrabacus2980
      @ferrabacus2980  3 роки тому +2

      Hey Pean, I do teach CS but not comfortable saying where. I make these videos for UA-cam because I want to see if the ideas I believe in for teaching CS are actually good ideas.

  • @SLguitarGuy
    @SLguitarGuy 3 роки тому

    How to access the microphone in c++

    • @ferrabacus2980
      @ferrabacus2980  3 роки тому

      I'm currently working on some stuff, I'll see how I can fit this into that!

  • @andzejkopytko6694
    @andzejkopytko6694 2 роки тому

    Veeery good explantation, keep it up :) Btw you follow wrong practicies, like 'using namespace std;'. Don't worry, i'm just saying ;) Have a good day.

  • @623-x7b
    @623-x7b 3 роки тому +1

    Midi next?

  • @xyvler3041
    @xyvler3041 3 роки тому +3

    Mong us

  • @gacrux6681
    @gacrux6681 4 місяці тому

    Can we record audio using this?

  • @sbarncar
    @sbarncar 27 днів тому

    OK OK OK OK OK OK

  • @xyvler3041
    @xyvler3041 3 роки тому +1

    Can you make me a mod menu for amog us

    • @ferrabacus2980
      @ferrabacus2980  3 роки тому +1

      I don't know too much about mods! Sorry!