Skip to main content

Integrate the projBox

Lesson 5 from: Audio Visualizer

Joseph Gray

Integrate the projBox

Lesson 5 from: Audio Visualizer

Joseph Gray

buy this class

$00

$00
Sale Ends Soon!

starting under

$13/month*

Unlock this classplus 2200+ more >

Lesson Info

5. Integrate the projBox

Lesson Info

Integrate the projBox

Okay, Segment five, integrate the project box. So this isn't actually quite the final signal is second to last. Um, what we're gonna do is integrated. Implement the project blocks class on. Then we're going to set up knobs to change the wave, amplitude and color. And we're going to set a knob to change background fading. And again, you know this processing an Arduino in tandem. The course uses the product boxes an example. But you know, you can either, you know, go for it directly. Or if you're already really familiar with this stuff, you could probably find other ways to emulate it. So, without further deal, let's go into back into the audiovisual Isar code, and we're going to go and look for the project box code, which had already been which you can go to projects that orig slash software and finding download. I believe it's also came distributed with last week's code. Um, let's see other. It is project box tester, so you just want to open that up. This project accessed er software a...

nd make sure your version of the project boxes running and um, you hit play. It gives you a visualization of what the box looks like. Just test out the switches make and the knobs to make sure they're all working. That's like each one's working on. And if they're not, you know, then I really go through the assembly instructions on how this whole thing is wired up. Step by. Step on. There's more on that on project box that orig slash assembly. Or you could go to make projects. There's also step by step description there as well. And, um, or you could follow the 1st 5 week course of the Siri's. Also explains this during week four of that, of course. Okay, so what we're gonna do is what we're interested about. This thing, though, is getting this project box class software class out of here. This code that does that sort it's gonna go into Project box tab, copy everything. Go back into our audiovisual laser, create a new tab. Just call it project box. So we know what it is and then paste in the code there, then going back into our audiovisual laser main tab like set up and draw. I'm just going to go, um, back into this really quick and look at how everything's in San created here we have a project box object of type Project box which will just set up down here. As you know, Project Box equals New Pradesh box. And the reason we do this is because the Arduino object that the project box uses the reason we declare it up here in an instant. She ate it Here is that, um, the Arduino object that the project box class uses eyes declared up here outside of set up. And it needs to be available before approx box and Stan sheets because it relies on the processing Arduino class heavily so And, you know, you could probably get through here. And if you understand the rest of this, this should be pretty easy to parse out how it's working. But especially if you look at the the Arduino library for processing documentation, which utilizes a thing called for Mata. Um Okay, so we got that thing there then, inside of draw. You can either call this before or after get audio data. It shouldn't matter too much a. So long as you call them both at the very beginning of the program. Before you do anything else that might utilize them. Um, so we're gonna put in here apprised box, get data, which is a method of the project's class that just grabs the data off of the switches and knobs on there. They're connected to the Arduino. Um, every frame and it just gives it to us, gives us ah, inside the project box object. There's a series of raise that Just give us data about those switches and knobs. Okay, So what we want to do now is actually start because we're gonna have a lot of stuff that we're drawing to screen in a moment here or were actually drawing most of it to the screen now. But we're gonna add some other stuff to it, So just kind of conceptually organized things a bit. We're gonna take everything inside of draw that we're using to actually draw stuff to the screen, and we're just gonna cut it out of there for me on the extra control X and inside of effects we're going to create, just pasted it back in there. We're gonna wrap it inside of a function of type void because it's just does what it does. Frequency beat is what I call this one on, If you can call it whatever you want. Um, feelings. Remember to call it in draw later. As such, um, frequency beat. And that's just gonna contain all of that stuff that we were just using directly inside of draw and then we're going to separate out are stuff that's drawing the beats as opposed to the stuff that's drawing the frequencies by creating another function called void. RGB beat and really paste that stuff inside their Cut it out of there and paste it in there. And then that means to get acts to run that code, we need to now call it from another function. Um, and frequency be it Later I'll get called in draw, which will then in turn color Jimmy rgb be on then. Very. And then there you have it. Um and you want to make sure, too, that this RG BB is being called above translate because again, it's drawing to the whole screen and if you put it below, translated, withdrawn Lee on half the screen, which might be a cool effect. Um, Okay, so then what we want to do is actually start integrating this project box itself on. I'm just gonna hit a command T. Or it would be controlled to you that just tidy up to code. Um, and then right beneath no stroke. I'm gonna put a float. Um, PG for background Alfa. We're going to use this to change the amount of background fading that we have. How much of that afterburn that we have? And we put real map that, um it's going to be the map value of Prague box dot knobs, and we're gonna find the first item in that array, which would be on the if you built the projects from the kit, that would be the left most knob and on the box. And then we're going to map it from its range, which is 0 to 10. 23 which is the Arduino analog inputs range. And then we're gonna map it Teoh like standard color mapping range, which is 0 to 2 55 and then we're gonna take this beauty alfa, and we're gonna pass it into the Alfa for background rectangle, then down above where it says, um, right below translate and above, Phil, we're gonna put a float wave. Hugh, which is going to give us the color of our wave. And we're just gonna do something really similar, Sort of gonna copy and paste that, except we're interested in finding the value of the second knob from left. And we're gonna pass that into, uh, our wave, Hugh. And because we're wanting a color, we need to give it a saturation and brightness as well on. So now we'll be able to turn that second novel in the box and change the color of our wave and turning this essentially into kind of a visual performance tool. It also responds directly to audio. And then finally, um or not quite finally, But for this section for this function, float wave amp is gonna be the amplitude of our wave. Instead of just using Mouse y and whips, we're gonna essentially copy that again and will use the third knob from the left, which would be array index to and again, 0 to 10 23 of the analog input. Um, but in this case, I'm gonna put in a smaller number because the frequency ranges give us back some pretty large numbers who only need the map it from like to 10 as a multiplier against this frequencies to give us a nice wave form Visual on with the frequencies. So there's wave amplitude and then fine After that, um, we actually implement those functions now and over inside of draw. We're going to go. If, um, just going to do a one line If in this case Prague box dot switches, we're gonna find the zero index of the very left. Most switch on the box. Uh, if it equals one, then we want to call the RGB beats function. However, if any other thing is going on, if it doesn't equal one, then we want to draw frequency beats, which is gonna draw both of our things to screen both the frequency wave and the actual beats themselves with that switch on. And we only see the beats. And if everything is done right, Bill, play. No. Doesn't like that. Rgb beats does not exist. Go back in the effects. Oh, yeah, I called it rgb beat. Okay. And frequency beats does not exist because I called it frequency. Be there. Will this change the name there? Okay. All right. Uh uh, Nice. Thanks. So, when you were turning that switch on and our stories. So I didn't turn this which I was using The knobs, eso the color changes that you saw. So it's going to go through this, um, So the color changes you're seeing in the way of forms for me turning that second non, Um, changing the wave amplitude eyes that third knob and then that first knob is just giving us amount of background fate. If I turn it all the way down, then nothing ever erases. It's just always there. Um And then if I as I faded up all the way to Max, then nothing ever burns in. It's just always the current stuff, right? So it's kind of like echo for Visual River, right? And it all it's doing is taking advantage of that. The fact that processing doesn't erase the entire graphics buffer every frame and you have to explicitly tell it to OK, ok, And then the thing which was you didn't have the switch hooked up to anything, So it's switch off that. So then now all we get is just the beats, okay? And we don't even get that afterburn thing. We just find one. Yeah, yeah, so it will just end up displaying whatever the color of its last detective beat Waas. Okay? Yeah. And you can get in there and change that around to make it easier to test it home. There's all kind of things you could do to make that morning first in for sure. Okay. I like the color effect with the RGB. That's pretty cool. Um, okay, so what we just did it is set up the project box code into here. Organized are displayed code into the effects tab and then map so that it would just be nice and tidy one we added in some of the knobs to make way visuals and then used to switch to turn the way off. All right, well, we don't have any questions, so let's go on to the next segment.

RELATED ARTICLES

RELATED ARTICLES