Juce Tutorial 14- Creating Your First Plugin (Pt 1)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
it what's up everybody I'd like to welcome you to another juice tutorial and today what we're gonna do rather than going through some more plugin basics what we're going to do is we're gonna actually get started in building our own plugin which is going to be a gain slider so it's just going to be a basic gain slider that's going to control the volume of our our input our input sound okay now I'm going to break this down into two parts first part it's going to be really just taking a look at the way that the front-end plug-in editor interacts with the plug-in processor and then the second part we're going to extend the functionality of our gain slider to make it a little bit more like the way that a real slider works so in case you don't know we here as humans we here logarithmically rather than linearly and we just need a slider that is able to reflect the way that we here as humans okay but I'll explain that more in the next tutorial what we're gonna focus on now is just getting the basic functionality of the front-end plug-in working with the backend DSP processing okay so we're just gonna start off with a new project as always this is gonna be an audio plug-in I'll just call this game tutorial one put this in the development folder okay and just open this up in Xcode so a lot of this stuff is going to be combining a lot of the things that we've done in the past tutorials and just taking those and combining them into making kind of a bigger structure so so I'm not gonna spend a lot of time really explaining stuff that I've already gone through before just because if I did it would take forever okay I'm going to assume as I've said in past tutorials that you do have some DSP knowledge so you know if I had to explain everything would would take a long time so I'm gonna try not to make this too long of a video so as I've said before we have the plug-in processor and just a review we have this function here process block which is where we're going to be doing all of the guts all of our mathematical functions that is going to affect our sounds so we're going to have sound incoming we're gonna do something to it and then the sound is gonna go back out okay and in between that we're gonna have what some people call like a transfer function or a difference equation or just an algorithm and that's going to change the sound in some way might distort it my move it up a pitch might change the volume like what we're going to do today okay and that all happens here in the process block then we have the plugin editor and this is just really a rehash of what we've done with the GUI tutorials creating died dials creating sliders and now what we're going to do is we're just gonna take those things and we're going to combine them into one so getting getting a slider to just control the volume of our input okay so first thing that we're gonna do is we're just gonna go up here to the top left we're creating a au component today so au component plug-in so I'm just switching that to au now first thing that we're gonna do is we're actually just gonna build this just to make sure that that everything is working properly now what we should see is that the output volume and the input volume are are the same okay that the plug-in isn't actually affecting the sound at this point okay it's gonna take a minute to build we're going to open it up in Ableton and it's going to take a it's going to take a second between opening and closing Ableton one thing that I should point out is that when you when you're actually building one of these and you're testing it out you are they have to close close out your da W and and open an open it back up for for your plugin to reflect changes okay juice actually have their own plugin host and that's something that will go will go through in our next audio plug-in basics tutorial but I don't have that set up yet so so I can't so I can't do that yet so we're just gonna have to work with Ableton today I hope you can bear with me so I'm just opening up a table - now we've built the plugin the plug-in succeeded and we're just going to test it out just make sure that we have the same thing going out that we do coming in okay it just takes a second to open by the way thanks to everybody that's been commenting on the on the videos there been some people that are more seasoned than myself you know more experienced that have been giving useful feedback and pointing out some different things so if you get a chance I'll look through some of those past videos and and check out what some people have had to say and it's quite useful cool so I'm just gonna create a audio track here in Ableton just throw a drum loop in there cool sounds good okay now what I'm going to do is I'm just gonna drag our plugin here and here I find this quite exciting you know that we just have like our own plugin that when we haven't done anything with it yet but I just I just think that's cool so at the moment it says hello world we haven't created us a dollar slider yet okay and so so these two volumes here should be the same okay just to show that it's unaffected okay so we can see that those two volumes are the same nothing is actually happening to the sound just yet but that the sound works fine okay so I can just go ahead and close this out for now okay so we're gonna go ahead and get started in thinking about what we need to do to create this slider okay this might be a little bit rough because I've done a little bit of practice this but you know I just think that it's better if I go through this process with you guys and you know so when we encounter problems we can really you know see what we need to do to solve them ok so so first thing that we need to do is we need to create a variable that's gonna control our volume okay so when we're thinking about volume control all we're doing is we're taking the incoming values so you have these this incoming stream of values that are going between negative 1 and positive 1 floating point values and we're just taking those are multiplying all of those values by a number and that's going to change the volume okay so if I have if I have an input value coming in of 1 and I multiply that by the volume that I want which is 0.5 the outgoing value would be 0.5 half of the volume okay so I hope I hope you guys can understand that and if if that's not clear to you just drop me a comment or a message or something and maybe I'll do a separate tutorial of that okay so I'm going to create a global variable for now I'm just gonna call it I'm gonna make it type double gonna call it raw volume for now okay then I'm gonna go into the plugin processor okay so now we just have to adapt this this code a little bit they've been nice enough to give us an output an output stream right away with the default code but we just need to we just need to adapt this a little bit okay I'm just gonna instantiate this the value of raw volume just so I have a default value to start off with okay good practice just gonna make it as point zero one five just so when we test this out if we see a difference between the input volume and the output volume now that we know that this is working properly okay now they've given us our right pointer what we need to do is we need to we need to find the so so basically what we need to do is we need to go to a sample we need to find it and then we need to take that sample and we need to multiply it by by our volume to change it okay so that's what we're gonna do here we're going to do this using a for loop because we're going through everything we need to do this to every sample okay so I'll just do int sample equals zero sample is less and then our buffer size get numb stamps get numb samples plus plus sample okay so so what we need to do is go through our all of our data here and we're just going to take all of that data and we're gonna multiply it by our our value for raw volume okay so we got channel data okay and this we're gonna go sample equals so this is going to be buffer dot get get sample so we're getting the sample okay we're going to the channel we're going to the sample and then we're going to do something to it okay so the channel that we're at we're already iterating through the channel we're going we're going through channel one should I say channel zero channel zero and channel one which are our left speaker and our right speaker okay and then we need to go through the samples okay so we're going through the we're going to the channel or go into the sample now we're just going to multiply that by our raw volume okay and that should work okay so what we're doing is we're seeing output speaker the out the output the value of the output is this sample times R value which is zero which is point zero one five so if we go ahead and build this let's build this see if it succeeds okay and now if we open up Ableton so this is going to take a second once again okay should open any second come all in ableton always takes a second okay that's opening I promise okay so if we go let me just create a track I'm just gonna put the plug in on the track and then grab a sample make it a drum loop turn the tempo down okay if I hit play I should see that the output is less than the input volume okay and you can see that there okay you can see that this volume is getting so so we have these samples that are coming in they're getting multiplied by our value which is point zero one five at the moment and then the output volume is much lower okay cool so that's our raw volume okay so now we need to go and take a look at the front end of our plugin okay where we're going to create the actual slider that's going to that's going to control what the volume is going to be okay so we can just erase all of this hello world business okay set size let's just set the size to 200 say 400 okay so now we just need to create a slider I'll just call it gain gain slider it sounds like a good name now we need to add it as a child of our component add and make visible in slider okay so now we just need to set the slider styles and the values and all of that business so we'll give gain slider set slider style so you've got a slider slider style vertical linear vertical okay we need to set initiative we need to set a range for it so gain slider set range so we're just gonna set this to zero point zero and one point zero I wanted to make it louder I could x values bigger than one but we're not gonna do that okay we're gonna set an initiative value okay set value let's put two 0.5 for now we need to think about the text box okay gain slider set text yeah text box style so we got a slider I'll put I'll put the text box below we'll make it read-only we'll make this a hundred pixels by 25 pixels okay I think I have everything there okay so so now we just actually have to draw the slider itself so we could just say gain slider set bounds we'll just make this arm simple for today so we'll just call this get local bounds so set it to the size of our window okay and I think that's everything okay so I'm just gonna build this quick just to see if just to see that the the slider itself is actually drawn correctly remotely correctly so just opening Ableton again should be up in any second here okay it's opening okay so let's just add audio track loop I don't know why we're doing this because all we want to see really is the GUI okay so there we there we go if we wanted to be picky we could adapt this make this you know attach a label to it all that stuff but I'm not gonna worry about that for now so okay so so we have our slider now and we're good to go now we just need to connect these two things to each other okay well how do we do that okay so as you recall in the past slider slider tutorial we can actually use the functionality of the slider listener class okay so if we look in the slider listener which I conveniently have right here so a class for receiving callbacks from a slider okay so when the slider changes value we need to change the value of our raw volume okay and as you may recall we have a virtual function that we need to define okay so the whole reason that we're adding this that we're going to be inheriting from the slider listener class is because we want something to happen when the slider changes value okay which is we want the we want the value that the that the input stream is getting multiplied by the change okay so in order to do that we need let me make sure I'm in the right place okay so so we need to say public slider listener okay add a comment here now one thing one thing I'm gonna caution you about that I encountered just a couple minutes ago when I was doing this tutorial before and I had to stop because I messed up so if I try to compile right now like even if I put okay if I say void so so this is a this is a this is a virtual function so I need to define so I need to define this this function so what's it called slider value changed so slider value changed right okay and a slider so we're pointing to the slider that we want changed we're gonna say override because we're overriding the function okay if I try to compile this right now it's gonna get in you're gonna get an error I think yeah so and then if we look at the error right you get all this all this craziness okay and you're like whoa what's going on or at least that's what I thought is like what the heck is going on I've defined this I've said I wanted what you have to do is you actually have to you actually have to put it you have to you have to put the function itself okay so if we put void okay and then we just use this because this is where we're talking about slider value change so you actually have to define it here okay just in case you get that same error and you're like what the heck is going on so so now if I compile it should be should be cool I think yeah cool so so we've succeeded now okay so so we've got this function now slider value changed okay and now we just need to define what we want to happen when I changed the value on the slider now conveniently Jews have actually added an object of gain tutorial 1 audio processor which is the back end of our plugin so if we have values that we need to push into our that we need to be changed by our GUI this is this is the way that we do it ok so is using this object processor ok so if you're wondering how those two things connect this is exactly how it connects using this using this object ok so just just to kind of be a little bit more clear about that just in case I'm not so we have so we have this variable raw volume which I need to actually make public is private so let's make that public okay so so I have this so I have the raw volume that's getting multiplied to the values that are coming from our audio stream okay so now I need to control those with the slider the way to do that is by using this object here the processor object that they that use have created for us ok so so in our slider value changed we just need to define what what's actually happening when we change the value of the slider okay so if slider equals and then we reference our gain slider okay something happens here which is for all volume Oh needs to be processed so we need to go processor stop raw volume equals then we just need to get the slider value gain slider get value okay so that should that should be fine okay so let's go ahead and build that see if see if that works okay cool that succeeded and just waiting for Ableton to open for us just takes a second can't wait to get this hopefully the juice post will will be quicker for us when we get that up and running okay cool so so now we have let me just get a loop up again yeah drama bass I love it [Music] sorry just kind of fix that okay so let's load the plug-in itself I think I have to close this out and open it reopen it every time okay cool so let's see what happens okay so it's reading our initial value okay our value is not changing our values not changing okay what's what's going on what's going on okay so let's close this out for a second what did we miss we've missed something okay slider listener slider value changed ah okay so we need to make we need to have our component listening listening for the changes okay so gain slider add listener this I think that's right anything else that could be wrong I'm just gonna go over here and I'm going to comment this raw volume out just so it's not so this is going through so this is looping through that to be potentially tripping us up as well okay cool this game let's let's build this again see if we've got our functionality okay it's open in Ableton hopefully one more time emptying my trash I do that as a habit okay Ableton's open in okay and let's add an audio track okay then let's add our plugin so ah there we go okay okay I'm just gonna stop it right there so as you can see that that works fine you can see that the changes that the changes in the volume are linear okay so what that means is that as we get louder as the volume gets louder we're hearing we aren't registering any sort of change in the volume okay so so it's like we're getting we're seeing we're actually perceiving big changes in volume here for like the probably the first half our first 60% of the the slider itself but as we get louder are our pursue or perceived change to volume gets less and less okay let me see if I can demonstrate this for you so so as you could hear the one I was moving when I was moving that's the gain slider over the last 25% of the slider you aren't really hearing that much of a perceived change in volume you're probably hearing a little bit but there's not that much of a perception okay so what we need to do is we need to make the make create a function which allows us to make the slider behavior more like the way that we as humans hear volume which is logarithmically okay and that's what we're going to do in the next tutorial so I hope you enjoyed this tutorial sorry about the waiting times between opening and closing Ableton and built this build time so on and so forth but I hope you learned a lot and if you have any questions or anything just drop me a comment or a message and I will see you from the next one
Info
Channel: The Audio Programmer
Views: 65,151
Rating: undefined out of 5
Keywords: audio programming, creative coding, audio coding, creative programming, digital signal processing, dsp, plugins, vst, software development, ableton, max msp, c++, sample rate, bit depth, nyquist theorem, juce framework, tutorial, beginner, easy, games development, games programming, basics, openFrameworks, open Frameworks, ofx, Maxim, Maximilian
Id: 7JUvVnRZrjg
Channel Id: undefined
Length: 29min 34sec (1774 seconds)
Published: Mon Sep 04 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.