@@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?
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.
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.
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
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.
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
@@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 :)
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!
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.
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.
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!
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
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.
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).
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?
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 :)
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
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.
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.
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.
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
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.
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!
UA-cam needs your code to enhance the sound reproduction. Thanks for the video.
Can’t hear the audio. But i will code it myself and see haha
Blblabla I cant hear you Speak louder or get a new microphone, This has been so unprofessional
@@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?
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.
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!
I absolutely agree,
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.
I really really respect this, perfectly explaining confusing concepts.
Glad you liked it!
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
What an awesome coincidence! Hope it worked out!
This is the kind of programming tutorial I need, Thanks for your great video
This is one of the best videos on this subject that I have found so far!
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.
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.
Thank you! I'm glad to see you are enjoying it!
That was unbeliavable helpful. I watched it with lot of pause. Extreme good explanations.
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
Thanks for this one!! Would be nice to have more c++ audio content. Is hard to find tbh!
I completely agree, is there any specific c++ audio content you would want to see?
@@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 :)
@@ferrabacus2980 what about sound fx, like a reverb, echo, distortion,... That couls be really nice too 😊
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!
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.
Glad it was helpful!
These videos are really helpful thank you for sharing
Glad you like them!
What a fantastic channel. Thank you for doing this kind of stuff!
Thanks for the video, it was really helpful!😊
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.
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!
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
This is incredible, thank you, this video is super helpful
Glad to help!
Generating wave audio is fun. Recording wave audio is difficult and OS dependent. I'd love a video on recording audio.
Hey bro thanks for your content I just found what I am looking for 😊😊
This is fantastic
good video to understand wav base, thank you
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.
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.
good video! solved alot of questions =D
Awesome! Glad it helped!
Your video was so amazing!!! Please if you are looking for a teaching job come teach c++ at Columbia our current teacher is horrible😂😂
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).
Thanks David, I don’t know how I messed that up in the video. Thanks for pointing that out!
Super helpful. Thanks!
Thank you, thank you, thank you very much
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?
Thank you so much 👋
Cool video
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 :)
Can't you use a short instead of an int for the 2 byte formats?
Hi, this is truly a master class. I need help and please let me know, how can I contact you. Thank you
Thanks!
No problem!
Nice video ,i am curious about getting a voice Signal (Analog input) from a mic and transform analog into to binary with cpp
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
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.
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.
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.
Yeah I noticed this too!
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.
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
is this for a class? Where do you teach?
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.
How to access the microphone in c++
I'm currently working on some stuff, I'll see how I can fit this into that!
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.
Midi next?
Midi?
@@ferrabacus2980 Yes :)
Mong us
Can we record audio using this?
OK OK OK OK OK OK
Can you make me a mod menu for amog us
I don't know too much about mods! Sorry!