Recording the Happy Coding Theme Song with Processing and Minim

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey there happy coders uh tonight's going to be kind of a weird one um and i'll explain what i mean in a second but what i originally meant to do today was i i sat down and i got all the video stuff set up uh and i had planned to make an intro sort of theme song to to the happy coding video uh series so like by that i mean hold on let's see if i can go to this um in the last few videos i've really upped my production quality and i've added a little like three second like title card um let me see if i can go to that and show you what i mean oh my god no no one wants that um so so there it was in all its glory let me turn the volume down um so you see that this starts out with like a happy coding sign and then it's just up for just a couple seconds and then fades into me talking about whatever i'm talking about um and you know i've just been having fun and experimenting with different like video tutorial things and this is just a kind of a small like bookkeeping nice to have kind of thing at the beginning and maybe the end just to just to remind people what they're looking at um you know because really what i want is folks to come to happy coding and check out our stuff and check out our forum um so anyway i sat down tonight with the the grand plan of adding some some music to this and i thought i would do it as a video because i'm going to do it doing code because like i've got a guitar but you do not want to hear me play it so i thought i would maybe like make a random note player or something like that and i would do that as as today's video uh but then a funny thing happened where i realized that i had done that before i had already done it so i like something had like i don't know bounced around in my brain i was like wait a second this is starting to seem familiar so i came to happycoding.io and i went to a processing examples and i scrolled down and sure enough i got this uh this random synthesizer um which is pretty much exactly what i was going to to do today uh here it is um i use minim here to play random notes and if i hit play here [Music] you know there it is um so i you know when i got here i was like well i guess i guess there's no point in making a video because here's the code already um but i don't know i was kind of in the mood to do a video and maybe this is stretching a little bit but um i realized that what i still need to do is record this so this is a program right this is a sketch and i can run this code and this code does play this this glorious random note kind of thing um but that doesn't help me right i i still need to connect the pieces i need still need to like record it as a as a sound file that i can then use to like overlay in my in my video um so i don't know i don't know if it's gonna be interesting but i'm gonna kind of walk through the process of figuring out how to do that um yeah so so that that's the background here we are um the only other thing i did was figure out some video like behind the scenes stuff of how to uh talk while recording audio um that was a lot of me messing around with like plugging in microphones and stuff uh so don't worry you didn't miss much that wouldn't that wouldn't have been a good thing to record it was a lot of swearing and plugging and unplugging um so you know hopefully you can hear it anyway so now what i want to do is i'm going to take this code and i want to record the output um so uh one thing that immediately came to mind uh when i when i was first sitting down to this was i know that windows has a recorder or something so i started looking at this and i was like voice recorder that doesn't seem right like sound recorder maybe uh you know i don't know windows is kind of annoying with like what it's how the start menu works now like i just want to see what's on my computer um but i'm pretty sure there's a recorder that comes with my computer but uh i can't find it honestly and that's kind of the i don't know maybe a side effect of these new ui things in windows but whatever i'm not going to complain uh instead what i'm going to do is uh look at the minim uh the minim documentation and see if maybe the library that i'm using here has a way to record and so was processing minim record maybe something like that and okay i'm on the google search page and i see audio recorder and yeah okay audio recorder can be used to record audio that's being played by a recordable object such as these things okay so do i have one of those things so i have audio output in the existing code okay yeah that that that looks right and then there's this sample code and i can read through this this does some stuff uh font stuff doesn't really belong here but whatever uh so this is recording so this is recording line in uh that might be interesting okay uh and then there's like some key released and some recording stuff so we've got r key to record and like s key to save maybe okay so at this point i have a couple options one option is to start with this code and try to add this code into it or parts of this code so all right now i'm feeling a little bit better about sitting down and making this video because this is actually a pretty common question in uh encoding is i have one program that does one thing and i have another program that does another thing and i want to combine them so how do i do that and you know there's different things you could try like copy this into processing and then copy all of this into processing and you know hope for the best but that won't work because you know this has a setup function this has a setup function you don't necessarily want you know two setup functions what you want is one setup function with the code from this and the code from this but even that's not quite right because you know you don't need all of this code probably you want to like look at the code and understand it to to to know what to take from it um okay anyway that's that's just me talking to myself um so so now i i have this program and i have this program and so i could either start with this and try to like work in like copy pasting some of this stuff but uh what i maybe want to do first is just start with this example so i'm going to copy this whole example and i'm going to open up processing and all right this is really annoying i should probably update processing because i know this is like a known issue that they keep showing this message but maybe that's a i won't do that one for you uh so i'm gonna paste that in okay and let's see if this becomes interesting i don't know if it will uh so i i i can read through the code a little bit so i've got my minim instance and i've got a line in or an audio in or whatever that thing's called audio input in and some of this is not actually useful to me because i don't actually want to record my microphone which is i think what this is doing also i don't know if this will work well with my setup i just realized that like i've got some some hardware things happening but we'll find out um and then all right so i've got draw and this is drawing some lines to the screen i guess and okay and then i can push r to record it looks like i have to hit it twice start and stop okay and then i hit s do do i do that before after i hit r maybe i should read this comment here to use a sketch you need to have something plugged into the line in i certainly do press r to toggle recording on and off and press s to save to disk okay so i don't know if that actually if like i need to hit r and then r again and then s or r and then s and then r but that stuff we can play with so all right here goes nothing i don't know if it's going to work on the video and stuff but let's find out so i'm going to hit play and okay all right it's doing something it seems to be like responding to my voice uh my my computer fans are also turning on so it's definitely thinking pretty hard uh so i i don't know if you can you know i don't know what you can hear and stuff but so i'm gonna hit r and i'm gonna keep talking i'm gonna say hello world and i'm gonna say hit r again and okay now i'm gonna hit s and i'm going to keep talking i'm going to say hello world and i'm going to say hit r again and it just wait it just played wait that that's right that's right okay that's right it just played i don't know if you heard that but it just played uh so let's try it again so i'm gonna hit r so here we are in uh in the audio that's being recorded and so this is what i'm about to save and i guess it plays it back when when you when you save it which i was not expecting because i didn't really read the code very carefully but let me hit r again okay and okay now let me hit s and i'm going to keep talking i'm going to say hello world and i'm going to okay all right so that's i can kind of get a feel for how it's working okay and i'm also seeing that there's maybe some errors down here so that doesn't bode well um but let's maybe open the sketch folder oh okay well maybe that's why i got this error um so okay let me save that to my desktop i guess and let's say like uh voice recorder sketch something like that okay so uh now that it's saved let me do this one more actually let me check the folder does that is that smart enough to have the recordings in there oh maybe um okay so with this dot wave i have no idea what that's going to open but let's find out so i'm going to double click this and it's going to open a file it's going to play it and again i don't know if you'll be able to hear it but let's see oh my god windows uh groov what what is groove music uh i i get so grouchy about this like anti-pattern of like trying to sell me things when i just want to open a file vlc it is and yeah always always and i'm going to keep talking i'm going to say hello world okay hit r again okay that that seems to work that seems to work well uh i've said it many times now so like it's probably getting annoying but i don't know like what you can actually hear i should have maybe tested this a little bit more but the nature of these videos is me kind of messing around and and figuring things out like while i record rather than figuring it all out and then recording only the parts that uh make sense i have no idea if that's interesting but i don't know i think it's honest okay so this this works pretty well and um i'm pretty happy with that so so what i've done so far is just run an example honestly and i get a feel for the things that i need to do and uh you know i don't need to do all of them so it's not like i'm going to copy paste all of this code but i need to kind of pick and choose the things that i do want um and and you know only take the things that are actually useful to me so i am going to start over i think with a new sketch that sketch was helpful in like helping me understand the uh the library and stuff but um for my for my actual output what i want is is this this sketch that i had created previously when was this stated no um so i want to start with like the the random note playing sketch and then add the recording code to it okay so let me copy paste this code and okay let me save it first of all because apparently that's an issue um so what do i want to call this like let's call it like happy coding theme so goofy uh whatever um the theme is random notes which actually is pretty on brand um okay so i'm gonna hit play and okay cool [Music] so there that you know hopefully you could hear that but that's just the the existing code that's playing a random note uh four times a second so i could play with this code a little bit more um you know maybe instead of between zero and a thousand maybe this is between i don't know five hundred and one thousand you know sometimes those those notes were a little low which might be cool for you know the sake of randomness but i think for what i'm going to use it for i think maybe a happier theme would be better and hopefully higher pitched is uh happier i don't know i don't know anything about music so we'll see if this does anything [Music] maybe maybe i don't i honestly don't know um so maybe i'm going to put it back i'm sure there's something with like major and minor key keys something something like that that is probably something i should look into but for now i don't know if i'm going to care i'm just going to say stick with playing a random note okay so i have that and now what do i want to do so my end goal is to create like a two or three second recording um and how i do that is by taking some of this code not all of it and using that to output a file so let me steal some of this so this seems like i'm going to need it so let me put that sort of towards the top so i've got in and recorder okay and i need some import statements um a lot of processing libraries and stuff use these like uh wild card um import statements and you know that's fine but i kind of personally prefer these uh explicit uh imports but it's kind of up to you audio output and then import ddf dot minimum dot uh audio recorder kind of guessing at the package but i'm guessing it's probably in the same package as everything else and i wait audio output oh my god i can't i can't type um okay so i've got my output i've got my input and i got my recorder okay and it's not complaining so i think i got those packages right and um okay cool so that's just like declaring the variable and then i need to like read through the code to understand you know what it's doing so i've got my in which i do not care about actually right yeah yeah okay so now i'm thinking about it this in is the microphone right and i don't care about the microphone i don't i don't want people to hear me singing so actually i think i'm going to get rid of this in and we'll see if i need it but for now i'm just going to get rid of it so i'm kind of minimizing the the amount of code i'm looking at and okay i've got a recorder here so i've got alt and i've got recorder okay so minimum dot create recorder in oh maybe this is alt maybe yeah okay um so i'm recording the output which makes sense for my goal i'm not recording the input which is the microphone i'm recording the output which is the notes that are being played so i could give my name my file a name so i could maybe um i like can i can i do is there like processing year so i know i could like record the date using java um let's look so if i go to the processing reference reference um i'm just looking at like what to name my file and i don't want to call it the same thing every time um so maybe i have like date update no no update okay so i could do year month day hour minute it's unlikely i record a bunch in a minute well actually for this video i might so i could go with java date format uh uh you know what let's just do um i could do system dot like the millisecond that the the system time [Music] you know what for now maybe i just don't actually care too much uh yeah let's just say i don't care so let's just call it notes.wave and you know maybe eventually i'll want to uh have the file name be smarter but for now i'm just going to call it nodes.wave i'm curious if it needs to be a wave so i'm going to play that as well later but whatever so i've got my recorder okay and so let's go back to this example code i don't care about stuff like the the font how to get line out so i'm probably already doing that yeah i am so line out so they pass in stereo i wonder what the um i wonder what the default is so minim dot get line out so processing i could probably got to it from the other page but whatever where's the where's the api i don't actually know know i just got this from google so uh all right so if i go up here maybe what do i want i want the minim class minimum and i want the get line out function and i'm just curious about what the default is i don't know if it tells me default parameters stereo okay so stereo so i think i'm fine with the default i don't know if i care maybe eventually i'll play with like left and right channels but whatever um i don't think i care too much right now so okay that's that seems fine so back to this code i've got my out and now here's what i really want to know the recording so i've got this kind of i mean i get what they're doing here but you kind of have to read through it to really understand all right so i've got begin record and end record which i think that's the magic okay and then i need what player player on patch okay i don't really know what that means but it's fine so i begin record and record seem to be the magic things so can i do can i just begin recording at the beginning and when do i want to end recording so i i want this to be really short i want to be like three seconds long so what i can do is all right frame rate is four so i'm going to do a little bit of math but then maybe that's okay what i want to do is say if frame count is greater it's actually let's go equal to something i don't know that something is yet so um let's do let's do something like put something in a variable i don't know if it's going to let me do it so int um beats per second is that right yeah yeah it is equals four so that's why i did this frame rate four here so it was like one two three four kinda like a kind of like a song um so let me just put that in a variable so i can use that here and then if frame count is greater or equal to exactly equal to beats per second times the number of seconds that i want to record so 3 in this case then i'm done let's let's see so then i want uh end record so i want recorder.end record okay and so that's that's part of it okay but when i ran this kind of example program i still had to save it so so player.unpatch why do i do that before i wonder if that's what wait what's player it's a player's file player oh no what is that i don't have one of those maybe i don't care maybe that's what's like where's that created player equals so that's only created when i hit s okay oh all right okay this is starting to make sense so if it's not equal to null then i i kind of close it out so and then i create a file player oh okay i see i see what they're doing here um they're doing a couple things in one line of code which i don't love uh but whatever we can we can parse it so they're doing recorder.save first which i guess returns a like maybe the file name or something and then they're passing that file name into the file player patching it into the alt which is like the speakers and then they're playing it um which is why when i hit s it played back and again i don't know if you could actually hear that so maybe i was just making dumb faces and listening to myself talk but i don't care about that part i don't i don't want that uh so all i care about this recorder.save okay um so i end the recording and then i save the recording maybe maybe maybe maybe maybe yeah okay so i think this is just about done um so i make my minim variables i begin the recording at the very beginning i play a random note four times a second and if we are if we've played exactly in this case 12 notes then we save the recording we're done with recording uh the program will keep playing but the recording will be there um let's see let's see what that does so i'm gonna hit play actually let me print something out so i know that three seconds has elapsed print line done okay now let me run this [Music] okay so that's done and now i want to open up this sketch folder show sketch folder okay and i've got uh the sketch file and i've got my note style wave so that's pretty promising and it's two seconds long well we'll see maybe maybe i don't know uh why is it two seconds long can i get like the exact uh length i thought it would be exactly three seconds long um length doesn't give me like milliseconds there might be a way to get to it but i don't know how to do it but it worked it mostly worked anyway so i've got a file i i honestly don't love that it's kind of like i don't know sounds sad it sounds like i'm playing a video game and i'm in a dungeon whereas like i want it to sound more like you know happy like dude you know i don't know um so i don't know if that's the number i pass in here play note um i wonder if there's a way to like play specific notes and i just like give it i don't know a string maybe so let me look at that so um what i want i want the audio i don't like that it doesn't show you the other options in this left nav so i've got audio input and what i really want is audio output and play note play note and okay oh pitch name okay maybe although i'm guessing that that's going to turn into a lot of me fiddling around with note names which might not be super exciting um but so okay pitch name so what's a pitch name so like note pitch name okay okay so it's like a b c d e f g okay okay now this is this is getting into stuff that i do have no idea uh about but i know there's like major and minor i don't know if it's notes or pitches or chords probably chords right uh major verse minor scale i don't know i don't know i don't know i don't know if we care uh yeah this is getting into some stuff that i do not understand i just want to play happy notes i just want to play random happy notes uh so i might i don't know i might i might mess around with that a little bit i might assign that to myself as homework because i don't know how interesting it's going to be like having me fiddle around with notes um because that's pretty specific to what i am trying to do here but uh okay let me think about this i mean this is pretty close to what i want i'm curious about the two-second thing there's a few things that are not working exactly how i would expect them to work uh but maybe that's okay but let me maybe open this with something else um what else do i got i got groove music apparently uh let's try this so does this give me more info somewhere i just want to know like how many milliseconds long this file is how can i find that out because if it's like 2.99999 seconds then fine i don't care but it's exactly two then something is like off with my math or something um yeah it's really annoying i'm almost tempted to be like okay it's 496 kilobytes and it's 14 11 kilobytes per second so can i use math there but no i don't know it probably doesn't make sense okay you know what i don't think we care i i think it's probably pretty boring to watch so maybe one thing i'll do is maybe i will play with this number so like what happens if i make it 10. [Music] okay i was waiting for this done thing to come print by uh okay so now if i go back to that directory which i closed for some reason now i've got notes and let's see is it ten nine huh interesting i mean i kind of think it's probably nine point nine nine nine nine nine is my guess but um i don't actually know and again i don't know if i care because like if it's one second off of a two second thing i you know i don't know uh so this is the kind of thing i could get nitpicky about and i could care more about i could do a lot more research and try to figure out like i could google like how to find length of wave files something like that um but i think it's probably okay uh another thing i could do is like all right say i want something that's three seconds long so fine i'll change this number to four since apparently it doesn't work the way i i thought it did [Music] and like hey guess what now this is three nine all right let's refresh uh now this is three seconds long so you know i don't know there's different ways to play with it but maybe i don't care uh maybe that's good enough okay so what else what else do i need to do i mean honestly that's kind of it um the other thing i might do is you know there's a couple things i could do like uh so right now i play a completely random note and you know this is stuff i could have played around with when i first created i wonder if i put it down here uh so you know you play speed you could play with yeah here here's actually what i was going for so the idea of like an audio random walker um so i could play with that a little bit so like let's say like and note equals let's start it right off in the middle and then what do i want to do i want to do something like uh note plus equals random and then let's say like negative i don't know 100 to 100 or something like that and then note equals constrain between zero and a thousand so i am changing it by a hundred each time um but i'm not letting it go less than zero or more than a thousand okay and so now instead of being like all over the place my hope anyway is that it will be a little bit more i don't know uh like it'll be a scale instead of just random all over the place i don't know we'll see maybe i don't really know i think maybe that 100 is too big so maybe let's go to 25. i also don't really know what this number is doing i'm i'm assuming that like lower is lower pitched and higher is higher pitched but that could be wrong [Music] oh i'm also dumb uh so i didn't actually use that so no wonder um right right right right uh oh wait float note equals oh uh well this is goofy um so i actually don't need that variable anymore i guess so let's do it that way all right i just wasn't using the variable so let's go back to 100 it doesn't really matter but okay so that's just completely my fault so you can kind of see that like instead of going all over the place they the notes are based on the previous note so it'll go up and down but it'll be based on our current note and you know maybe maybe maybe maybe maybe i also realized that like even in the higher pitched notes like they still sound kind of sad i don't i don't know if that makes any sense but like it's not necessarily that like the lower ones are sadder than the higher ones it's something else i don't quite understand it and maybe it's like the combination of them um so maybe it's like going from higher to lower or something like that but like it still sounds kind of kind of dreary [Music] um another thing i could do is speed it up so it's nice that i put this in variable because like let's double it let's see what that does maybe i mean this is all like stuff you you know you can play with so maybe what i'll do is constrain it like i don't know let's make it really small like 800 to 1000 like really small like window that it can be in maybe let's change that i don't know it also sounds kind of spooky so it should rebrand this as a halloween sketch um another thing i could do let's see how this would work so can i say started out low and then and then only increase it maybe well i don't know oh wait i'm still constraining it so i don't need to well i do need to constrain it but let me start it at zero all right that's pretty cool i really like that uh and i think that gets at what i was kind of guessing at where it's like if you go from a high note to a low note it's like it sounds sad i don't know a better way to say it but like it sounds it's like kind of depressing whereas with this i don't know going from lower to higher sounds happier all right i'm into that uh i think that going up to a thousand is too much so a thousand seems like quite high pitched so i don't know how annoying it is in your ears but it's it's a bit much for me so let me let me hear it one more time [Music] yeah so let's let's see how we feel about like 750 maybe [Music] okay okay i mean i'm not gonna just like let it sit there at the at the high end and actually what i might do is instead of frame count instead of this stuff what i might do is if uh what if note is greater than or equal to some number so greater than or equal to you know 750 or whatever um let's actually let me put that in a variable so i've got bps i've got into max note equals 750 okay and where do i want to put this max note and max note and uh you know this doesn't really matter but max note next note i mean i don't actually care about the visualization part of this sketch but just for funsies so i'll fix that as well [Music] oh i clicked the wrong thing my bad um i wanted the tidy code thing not tweak uh wait that's in here somewhere right auto format yeah all right i didn't change much i thought over that spaces here which is actually what i was going for um okay so now i'm gonna end my recording when i hit like the top um instead of waiting a certain number of seconds so let's let's see what this ends up being [Music] okay okay all right i don't know why i got an error but whatever all right so i've got my still wait this is my old one so if i refresh now it's whatever two seconds long again i don't know how much i care about the actual length because i'm just going to put it like right at the beginning of the video which is only a couple seconds long anyway so let me hit let me let me just play this [Music] i don't know maybe it still kind of cuts out i think so actually i think i know why that is so if i play like i think notes like keep playing for a while so what i might do is only play the note hold on let me think about how i want to do this um basically i want to give it a like a second for the notes to end because it's not like a note is played and then it's over a note is played and then it kind of fades out or something i'm not sure but um but if i just end recording right then it kind of it feels truncated [Music] yeah here like it cuts off so what i'm actually going to do is what is maybe have a boolean that's like playing fully and playing equals true and then i'm going to say if note is greater than or equal to max note then playing equals false and then i'm going to say only do this if playing okay it's getting a little messy but maybe that's okay so if i'm playing i play a note okay i should probably move that into that code again i don't care about the visualization but whatever just to keep it around and okay so then if note is greater than equals to max node then i am done playing and then what do i want to do i kind of want to just wait a second so you know there's many ways to do this but what i maybe want to do is playing and then i want to say like [Music] stopped playing at time or stop playing time stop playing time equals i'm not going to say anything yet so stop playing time and if note is greater than equal to max note that's when i stop it so i'm going to say s stopped playing time equals millies so i'm just going to record the time okay so let me add playing to this so if i'm playing and so if i'm already if i'm still playing and the note is higher then playing is false and i record the time okay and i don't actually uh i don't actually save my file yet so now what i want to say is if millie's is greater wait millie's yeah if miller's is greater than stops playing time plus plus a second which i wouldn't need to figure out in a second but let me paste this code while i have it plus and it's going to be bps times weight pps times one wait uh no it's just millies so it's just a thousand yeah right here so this is this is independent of um of your frame rate so this is just recording like how many milliseconds have elapsed since the start of the program right so i used that function to record how many milliseconds had elapsed like what is the current time basically when i stopped playing so i record that in this variable and then i say if the current time sorry bump the microphone that's fun if you're wearing headphones if the current time is greater than the time that we stopped playing plus a second plus plus 1 000 milliseconds then i record then i print done and then i don't want to do any of this again so no loop maybe maybe it's called no loop so that it stops calling the the draw function maybe all right let's just let's just see what let's see what i broke [Music] okay maybe although that done might come a little fast let's find out yeah so maybe one second isn't enough also i feel like it's not really getting all of the all of the nodes okay yeah i think it's just timing i guess so oh this is goofy because like i don't want to be that long [Music] yeah see how much there was delay between like when it stopped playing and when the done came and that makes this thing five seconds long which is like you know i know i'm being nitpicky but it's a little longer than i wanted it to be [Music] no see that delay is still there so it's weird it's like 3 000 is too much i don't know man [Music] yeah i mean just looking at it like that's it's too much of a delay [Music] yeah it's way too much um so 1000 i'm just going back to what i had it before no what the heck something's goofy yeah like that that doesn't make sense like this number shouldn't change how long the song is so if i go to 500 it'll be a lot shorter no no that's not right so i'm doing something dumb um [Music] i can tell like it's dinner time because like my brain is not working anymore oh fun um so it's probably here it's probably in this if statement so if my current time is greater than when i stopped playing plus 1000 that feels right to me hmm i mean that shouldn't be like a less than should it no no no no so if my current time is greater than when i stopped playing plus one second yeah i mean that's right but obviously it's not oh wait you know what i know why um okay so i only want to do this if um if i'm not playing so i have probably a couple ways to do this but let's do it this way i'm not playing and yeah yeah okay maybe that should be an else or something but whatever i'm kind of keeping my logic separate so if i am playing and i do this actually let me do it this way so um what i can do is move this inside of this so if i'm playing so i already know that i'm playing here so i don't need to double check this so now i say all right if i'm playing then i play a note and then if that note is bigger than my my maximum note then i'm done playing and i record the the time okay and so now i say else if this stuff yeah yeah this feels better um else if and i know i'm not playing so i don't need to check that so otherwise um have has a second gone by since i since i stopped playing then i root then i record the file okay okay okay maybe let's see if this changes anything okay that timing felt right okay i think one second is probably too long so maybe like 750s like three quarters of a second [Music] and i can play with the timing stuff but really what i'm trying to get right here is like the distance between the note playing and the recording stopping [Music] uh maybe that's too much so you know now i'm getting into diminishing returns probably but like 850 85 of a second [Music] okay you know i could i could keep fiddling nine tenths of a second i don't know there is probably some some way to figure this out that feels right though that feels like it ends just as the file ends and one second is like it's just a little bit too long and you know maybe i'm just wrong and i should just stick with 1000 but i don't know let's let's see so that's one full second waiting [Music] you know what whatever seems fine actually so wait a second and then i'm done so good enough and i think i'm just about done um what else might i do [Music] so if i play that at the beginning of a happy coding video like when the happy coding thing is popping up um is that cool maybe i think maybe what i'll do is increase some of these numbers so bps i don't know if this needs to be a multiple of four we'll find out and maybe instead of um let me put this in a variable as well so like max node i think we're going to stick with but like um delta note like how much we change the note each time right now what is that that's at a hundred so maybe i decrease that quite a bit um and then do i need to constrain this anymore no i don't because i'm just quitting when it's done and okay so i play my note and i draw a line for funsies and then i say if my note is greater than my max then i'm done and i do the logic where i wait a second and then um and i save the file so what i've changed is now it's going to play twice as many notes per second and it's going to go up by a smaller amount each each note [Music] i mean that's fun but i don't know if it's like theme song fun [Music] yeah i mean that one second delay is pretty nice but um it sounds like we're entering like some kind of dreamland or something so let me take this down a bit wait that did the opposite um yeah let me let me increase that quite a bit actually um maybe i think it's getting pretty close you know i don't know i don't know i don't know i don't know um so maybe one thing i could play with like the strummy like going up pattern is kind of cool but i don't know when i was when i was originally sitting down to picture this that's not what i had in mind i really kind of liked the idea of like kind of going up and down a little bit you know maybe what i should do is just pay a musician to come up with three seconds of music but i kind of like the idea of doing it randomly so now i'm going to maybe add a small chance of going down a little bit but overall we'll go up uh wait it needs to be comma so negative delta note over two so i might go down half uh i'm calling it a note that's not the right that's not the right word for it but um like i'll go down half a note or i might go up to up to a full note um so overall it'll still go up but it still might go down sometimes let's see oh uh so now i do need to constrain it oh my goodness it's getting annoying um note equals constrain note zero uh what did i call that max note um yeah so like that was buggy because it went negative so we don't want that so constrain it to prevent that case maybe i think maybe this delta node is too small now because i i don't know i didn't want a lot of notes i just wanted like a few notes that went up and down [Music] maybe maybe maybe maybe so now now we're at the fiddling with parameters phase which is always my favorite that's that's really close that's really close to what i'm picturing [Music] i'm into this [Music] something like that it's just like super simple like a little jingle a little just like um that's really close to what i was picturing [Music] [Laughter] that's getting jazzy yeah okay okay okay i think i'm getting into this um i think that maybe i could play with this number so like instead of dividing by two which is like multiplying by 0.5 maybe what if i do like 0.75 [Music] okay i think we are very close [Music] i love the randomness of it i love it [Music] i love how it kind of like fights with itself like it goes like way down and tries to come back up but like it's kind of a struggle [Music] there's a there's a metaphor in there somewhere but uh so maybe 0.75 was too much okay i think this is pretty pretty close yeah okay so here's here's what i'm going to do i think i want to call it there because honestly the way these things work well for me anyway is i have this thing that like the randomness gets is pretty close that's actually really close um so maybe what i should have done is like add 300 each time or something there's probably an easier way to do this but anyway the way this often works is like when i have this randomness component to it and i i'm i don't like to call myself my stuff art but if i want some output that looks nice but has randomness to it uh what i'll do is just run it a bunch of times honestly so i'll hit play and i'll listen to it and i'll say you know that's pretty good but i think we can probably get better so hit it again i'll say you know what that i didn't like that one actually randomness so we'll play it again and i'll say oh actually that one's the right one and i'll i'll save that one and uh that's i'll like put that like either on the web page or like in this case i would use that as that day's um that day's theme song or whatever um but i would just throw out all of the ones i didn't like and so i don't need it to be perfect every time i think is my point um i actually i'm going to save this one because i like that um so i don't need to be perfect every time because it's just random and a lot of them are not going to be great and what i do is i just throw those away and i only keep the ones that i really liked and that's that's good enough that's that's okay but i think i'm pretty happy with this because i hit run [Music] and i get a little uh theme song and it's short and like to the point i guess and it i think it'll play nicely when i like overlay it on like a video so i lost it but you know actually if you just jump back to the very beginning of the video uh you'll see an example of this but if i if i overlay that here if we're like there and then i start talking you know i think that'll be that'll be cool that'll be nice it's kind of digital and random which is right in the wheelhouse of what i'm going for with happy coding so so i'm pretty happy with that okay so what did we do i i sat down with the intention of making this a super short video because i thought i had already done most of the work and it turned out to be kind of long-ish and uh you know we went down some rabbit holes but that's kind of fun um so to kind of summarize what i did was what did i do so i started with this example code so i had this sketch and i had this sketch and one of them did part of what i wanted to do and the other one did a different part of what i wanted to do and to combine them what i did was first of all i ran both of them to understand exactly how they worked and then i kind of pick and pick picked and chose uh from each one like the parts that i needed so i took you know most of the code from here because that's kind of what i wanted to do but i needed to add recording capability to this code so i went over here and i like kind of read through it and i took only what i needed so like i didn't care about the microphone stuff for example or this font stuff um or like you know the way they are drawing their their output like i didn't care about any of that stuff but i i read through it so that i could see which parts of the code i needed to to copy over i copied those over and i you know i ran the code a bunch of times and it sometimes it worked sometimes it didn't um and then i filled around with some of the parameters just to to get the output that i that i wanted um so that's kind of the the general i don't know workflow of of how you combine two sketches uh and you know i specifically was doing something with sound here but you know the ideas are the same no matter no matter what you're working with so if you have some code that does something and another piece of code that does a different thing and you want to combine them you'll follow the same kind of pattern of understanding the code first and then picking and choosing only the parts that make sense for you into your final output so you know hopefully that was interesting and if not that's okay we at least have a cool theme song out of it um all right so from here what you might do is you know maybe you have two sketches out in the world that you want to combine you know there's a bunch of examples on happy coding so you know come here and check us out um or you could stick with the code that i have here honestly i'm not sure if i want to post this code i don't know if that makes sense or if maybe i'll post it as part of this page or maybe this is just a video without a without a happy coding website uh i don't know we'll see um but anyway uh you could take this code and you know maybe play around with the notes a little bit more so like maybe you liked the kind of sadder sounding music so maybe this is a soundtrack for a rainy day or something like that or maybe you want to play with some of what i started to search for in this like in this reference where it's like got a pitch name which is a string which i didn't fully understand uh so maybe you're a little bit more musically inclined or maybe you just feel like going down the rabbit hole of googling some of that stuff to to figure it out um so those could be fun things to play with and if you do end up playing with that stuff please let me know i'd love to hear from you either in a comment or come over to happy coding and come over to our forum this is where i generally hang out so i would absolutely love to hear from you and of course as i advertise it it's slow but it's not always slow i promise anyway come here and come say hi um okay so i'm going to sign off and as always i will say have a great day thanks for watching and happy coding but i think for fun i think we're going to have our our new uh uh happy coding theme song play us out so here we go good enough
Info
Channel: Kevin Workman
Views: 139
Rating: undefined out of 5
Keywords:
Id: YYVARbW8iJ8
Channel Id: undefined
Length: 63min 13sec (3793 seconds)
Published: Sat Nov 06 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.