Juce Tutorial 20- Building a Synthesizer Part 1 (The Synthesiser Class)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up everybody I'd like to welcome you to another juice tutorial and today what we're gonna talk about is starting to build the basic framework that we need to start building a synthesizer okay now there are a couple things that we need to put in place in order to get everything started with building a synthesizer and it's gonna take a couple tutorials to to really go through all the different things and all the different considerations that we can that we can make as we're building this structure because as you know there are a lot of creative decisions that we can make about how we can we can build these bigger structures you know how many voices do we want it to have how do we want it to render the the the waves doing want it to be using wavetable synthesis or do we want those waves to be calculating in real time or do we want them to be samples that we're repeating it at the zero crossing points you know so there are a lot of different decisions that we need to make as far as you know how we how we can start building this synthesizer up but what we need to do first is we need to put a basic framework in place where we can start inserting these different decisions and that's what we're gonna do today so what we have in front of us at the moment is the synthesizer class reference perme and and we're just gonna go through that go through the basic functions that we need to instantiate and that we need to start thinking about in order to get our synthesizer started okay so we're not actually building a synthesizer today we're just building the framework that that we need to have in place in order to start making these decisions and then in the in the subsequent tutorials we'll start talking about some of those decisions and some different things that we can do in order to start building this thing up I should mention that a couple different things that I've kind of referenced along the way it's been it's been quite a challenging it's been it's been quite challenging just to kind of get an idea of the best way to go about this this tutorial and thinking about the approach that we can take and I think that's the reason why if we haven't seen any synthesizer tutorials in juice you know on YouTube but you know I think the the best way to handle this is to really start from a very basic level and then as we're able to understand the basic level dig a little bit deeper get a little bit better understanding and you know hopefully we can start building things up and get you know a more elaborate structure once we get going okay so the things that are referenced mainly one is the juice demo plugin so if you go into let's see if I go into my applications juice examples and then you have audio plug-in demo so there's an audio plug-in demo there that's a that's a basic synthesizer okay and and so I kind of scoured through that kook got a couple things and then also another one is from a guy named Leon paedon okay I think I think he has a couple videos that he's posted online with about his synthesizers and he actually has some synthesizers that you can download from github and look at through his code and and I actually spoke to him today a really nice guy he actually teaches at Goldsmiths and you know he's his code has been really helpful in helping me understand this as well so I'll link you to both of those things in the description below so without further delay let's just go ahead and get started so what we'll do is we'll just build a new project and it will be an audio plug-in we'll just call this just call it synth framework and we'll create okay so a couple things that we need to take a look at I think we need to take a look at them first thing is if we go into the the exporter section and we go into debug what we want to do is this where I want to be now where is it that I want to go here oh yes so if you just if you just click on the COG at the top for the basic settings here then you scroll down a little bit okay we can click on plug-in is a synth plug-in once MIDI input and plug-in produces MIDI output okay and that should help us get things set up properly so just go ahead and save that and open it in the IDE so while while this opening in xcode there was something that that i discovered on the juice forums the other day that was i think i discovered it on the forums or it was something that I just read in one of the tutorials by chance that was a way to get the to get your plugins debugging quicker using the plug-in host and I'll just show you how to do that real quickly while I'm just a lot of just happened to be here and everything's just processing so if you go to product this is if you're building a VST or RNA you plug in and if you go to product then you go to scheme then you go to edit scheme then we have we have things on debug maybe go to executable then you go to other it will just pull up a window and then what you can do is you go to applications juice and then examples plug-in host builds of a Mac OSX build debug plug-in host okay then what will happen there we won't we won't get a chance to do it today but when you build your plugin the host will automatically come up and then you can actually you can actually just drag their plugin in there and it's a lot quicker and you can actually do step through debugging to help debug your plugin so but we'll we'll do that you know sometime down the line okay great so what we what we need to do now okay so we'll just have a look on the API here at the at the class reference because it gives us it gives us a nice description of the things that we need to do to get things started so if we click on more here okay says a base class for a musical device that can play sounds okay to create a synthesizer we have to create a subclass of synthesizer sound to describe each sound available to the synth and a subclass of synthesizer voice which can play back one of these sounds okay and then it goes on to these two these other things which we'll get to okay so first thing that we need to do is we need to create two subclasses okay we've got synthesizer sound and we got synthesizer voice okay so the way we'll do this I've done a little bit of practice in earlier so it'll be good to get this out of the way while it's fresh in my head before I forget so we'll go back to the producer go to the file explorer then we can just hit the the plus sign here and we'll just do add a new header file okay if it was a little bit more elaborate we could we could split it between a header file and a CPP but just for simplicity sake we'll just put it all well we'll just do two header files okay first one I'll call synth sound okay and then I'll add another one okay I'll just call this synth voice now this is great for me too I'm just learning how to do this so you know it's it's just one of those things that sometimes you know you look and you say well how would how would I ever know that if I was just ever just going through the API you know and you know sometimes it's just practice you know just practice repetition you know and just really getting your hands dirty so cool so now we got our header files we can just relaunch here okay and so now we need to put some we need to put some stuff in set sound and sent voice as you can see they're just completely blank okay so the first thing that we need to do is we need to we need to just include produce or juice header in there so it knows what we're talking about when we're creating when we're creating this stuff okay so then we're gonna create a class okay and that's gonna be class synth sound it's called since sound same thing and then I think it's called synthesizer sound okay so we have this class called synthesizer sound just gonna open it in another window okay describes one of the sounds that the synthesizer can play okay so then what we have here is we have two two pure virtual functions that we need to instantiate here okay they're just two boolean's okay and we'll just type those so I'll just get class sent sounds inherits from we'll make it we'll give it public access synthesizer and for all you Americans out there like me synthesizer is with an S rather than is Z or a Z and then we can just do that and then we'll just make we'll just give both of these public access and then we just need to we just need to instantiate these to go to these two pure virtual functions okay so whenever you see that equals zero that lets you know that when I'm calling when I'm calling or inheriting from this class that I need to call these functions that I need to instantiate those so we've got bull applies to note and then int and then I'll just put here's star MIDI note number okay and then I'll just put return true okay then we'll just do the same thing for applies to channel okay so so just to explain to you what I'm doing so it says returns true if this chef if if this sound should be played when a given MIDI note is pressed okay so we want it we want there to be a note there when when a mini nose pressed so of course we want that to be true okay same thing with channel okay so applies to channel to channel it's MIDI Channel okay we're just gonna do return true again and then that's it that's it for that that's it for synthesizer sound okay so that's that's good to go so now we're gonna go to send voice okay we're gonna paste our header there again so once again it is what we're talking about just gonna do a quick build just make sure that everything's building properly and I think everything's gonna be cool okay looks like it's gonna be fine so what we're gonna do here is we're going to include the synth sound header file since sound H okay once again once again all we're doing here is we're just creating that we're just creating that framework we're just creating that kind of skeleton where we can where we can start building where we can start like putting in our stuff and our DSP code and you know start kind of specifying what kind of sense that we want this to be how we want it to to render the sound you know what kind of synthesizer we want it to be so on and so forth so so this is just building that skeleton at the moment okay so what we're gonna do is we're just going to go back to synthesizer now we're going to go to the synthesizer voice class here and you'll see that there are a bunch of pure virtual functions that we need to that we need to declare here okay so first one is so so we're just gonna call this I need to go through my class declaration here class synth voice that's gonna be public access and then this is gonna be synthesizer voice okay here we are we'll give this public access okay and what we're gonna do is we're just gonna fill out these we're just gonna fill out these these functions and then for the next tutorial we'll start we'll start making decisions as far as how we're going to you know what we're gonna do inside inside these methods okay so first one is boolean can play sound then this is just a synthesizer sound pointer sound oh my bad type it at a weird angle okay then I like to do this just to just to separate the functions out cuz I just like to see everything kind of clearly okay now this is this is helpful for me because you know then then I know okay I know now what I need to do just to you know just to start getting everything you know situated with the synthesize aren't okay so we know that we need a we have this one that we need okay start note okay what happens when we press a key okay so void start note int mini the number float velocity since the size or since this size or sound pointer sound its current pitch wheel position okay great that one's done okay and then we need stop new so what happens when we let the key go okay Boyd stop no got flow velocity boolean allow tail off if we want to tail off after the nose let go okay then we got what else do we have here so we have pitch wheel mood okay it new pitch wheel so we could put some pitch wheel functions in there if I want to okay then we've got controller moves so all of these have to be declared okay or else you'll get an error void controller moved it controller number it new controller value I know this might be a little bit tedious you know but if somebody had shown this to me I would have I think I would have found it quite helpful we need most importantly render next block okay so void render next block this is actually like your kind of kind of like your process block here so this is where the majority of your DSP code will go for the synthesizer will some of it float reference to output buffer it's start sample and numb samples okay and then I'll put I'll just put a private in here as well just in case we want to declare some private variables okay so this is just kind of your basic framework here for actually declaring for actually creating a synth so if you want to create a synth in juice you have to you have to do all of this basically so if we go back to our our plugin header file so now we want to include these now so that we can use them so we can use since I'll include since sound dot H and include sense voice H then down here in private I could just I could just create a synthesizer object synthesizer my sense okay and that's where I'm gonna stop now because I just really like I said I just really wanted this to be just kind of okay I want to create a synthesizer in juice what do I need to do to start to get everything started this is what you need to create to get everything started so so next couple tutorials we're gonna start making decisions as far as how we're going to how we're going to create our synthesis engine for our synthesizer I'm leaning towards using the Maximillian library which is a sound library really really good sound library that I'd recommend that makes a lot of things easier and I'm leaning towards using that to build our first synthesizer if you have any suggestions or if you have any comments or if you you know if you have any feedback or anything just uh just leave a comment below otherwise it'd be great if you like the video just so we can get more people you know get the community to be bigger and everything and that's where I'm gonna finish things off and I hope you enjoyed this tutorial and found it helpful and I will see you next time
Info
Channel: The Audio Programmer
Views: 18,993
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, synth, synthesizer, synthesiser, build, how to make a synthesizer, plugin, juce synthesizer, juce synth
Id: kxKEFTQRZPI
Channel Id: undefined
Length: 21min 41sec (1301 seconds)
Published: Tue Oct 03 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.