Building a Synthesizer, part 1: Oscillators

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay you're gonna build a synthesizer now how do you even start a project like that well the first thing that we need to do is we need to ask ourselves what is a synthesizer what does it do and how does it work because we really need to understand the kind of architecture of the instrument if we're going to be able to build one and design one ourselves and because the whole point of this little project is that you're not going to build my synthesizer necessarily we're just going to work through the steps together and you'll come up with your own instrument now of this so this is how do we build your synthesizer so a good starting point is the question what is a synthesizer well a very simple very basic jumping-off point might be an electronic instrument for generating and controlling sound okay it's a musical instrument we we play it like any other musical instrument it has a kind of interface that we can interact with musically to perform its generating synthetic sound I mean it might be a sampling instrument a sampling synthesizer but for the most part here we're going to work with kind of classic waveform synthesis and then a synthesizer can usually process or control or manipulate that sound okay so that's going to be our jumping-off point here an electronic instrument for generating and controlling sound so with that in mind we need a very basic architecture and we'll start kind of zoomed out we'll start at the kind of highest level and slowly we'll break it down into parts that we can then start to build up and create ourselves in max so synthesizer starts with a sound source okay then the signal from our sound source moves down and then we can modify it we can process it somehow and then finally it goes to the output okay it's very simple three steps sound source modifier output okay job done we understand that now we can start to move kind of down to a lower level we can zoom in on the architecture of the synthesizer okay so what my a sound source be well kind of said already but waveforms okay we need to generate some sort of waveform and this is usually done by an oscillator and that's going to be the focus of today's video we're gonna look at oscillators and kind of working with them in Max so what comes after the oscillator well in a very basic framework we move on to the modification stage now the modifier can do lots and lots of things this could be a whole range of kind of different effects but we're going to keep things quite simple and kind of classic synthesis here so the most common modifier to our sound source would be a filter okay now this style of synthesis is is generally known as subtractive synthesis okay I like to think of it as sculpting synthesis so what's happening here is we're feeding our filter a really rich sound source okay this this is a complex oscillator a complex waveform that then that we can use the filter to kind of sculpt the kind of harmonic shape of our sound okay this is the form of synthesis that we'll work with today is known as subtractive synthesis now the modifier can include other things the most common after the filter would be the amplifier okay now the amplifier we can imagine as opening and closing to kind of create the shape of a note so if you imagine pressing down on a key the amplifier opens and then when we take our finger off the key the amplifier closes so we get a note start and a note end okay and then this signal is then fed to the to the to the output so a really really general design schematic at the architecture of a synthesizer might look something like this so we've got two oscillators and that's in order to create a kind of complex waveform that we can then sculpt with our filter the output goes to an amplifier and then the output of the employer goes to our main help supply so that we can hear it but we've got all kinds of other options for control okay because remember this is a musical instrument we want to be able to play it it wants to have kind of certain interactive abilities so that could be the the keyboard controlling the pitch of the oscillator that could be linked to an envelope that controls the amplifier tells the amplifier when to open and close we can have other things like LFOs which are low frequency oscillators that will kind of pulse and manipulate things like the filter frequency or the the cutoff frequency and and really kind of start to do interesting and dynamic things to our synthesizers sound so without going on too much we need to think a little bit about our sound source okay we need to think about what our oscillators are doing so we've got four maybe five basic waveforms okay now here they are these might be familiar to you but just running down the list we have a sine wave we have a triangle wave we have a sawtooth wave we have a pulse wave which is commonly known as a square wave okay and this this can be be changed into sort of other pulses and then there's sometimes a fifth waveform option which is noise and we'll talk about this a little bit later but it's it might sound noisy at first but it can be really really useful if we use it if we use it well so how do we turn these basic simple waveforms into a complex waveform that we can then sculpt it with our filter well it's just a matter of combining them essentially and that's what we're gonna do now we're going to use Mac's to create a complex waveform and listen to how that works okay okay so here we are in Macs I've created a new Macs patch by going to file and new patch er and just a quick word before we get started I'm using Mac's version 8 and I'm using it on a Windows operating system at the moment so you are probably using something different you might be using an earlier version of max maybe max 7 and you might be using on a Mac but ultimately it's the same max 7 and a quite similar and they look very similar as well so so don't worry too much some of the keyboard shortcuts that I use might be a little bit different but I will try to kind of call out the differences or use kind of manual manual buttons to create things as we go just to take care of any difference so what we want to do is create a complex waveform in Max and we're going to do this by combining simple waveforms so I'm just going to create a new comment just so we have a list of what waveforms we want to make so we know that we want to make a sine wave and we want to make a triangle wave and we wanted to make a sawtooth wave and a pulse wave and maybe if we have time we'll make a little noise noise wave okay so max makes this really easy for us because it gives us objects that take care of most of these functions now the names are a little different but but don't worry you'll kind of pick them up this is something that beginners find hardest about max just knowing what name is linked to what object so unfortunately there's no sign object but there is a cycle till take note of the little tilt that comes at the end of an object name that usually denotes that it's an audio object so it's going to generate something in this case so there we go we've created a sine wave but we can't hear anything obviously so there's a few more steps we need to hook this object.isfunction object up to an output so that we can hear it okay so we're just gonna do that now first of all I'm going to I'm going to use the the keyboard shortcut n it's the same on Windows and on Mac but it's going to give me a blank object and then I'm going to I'm going to type gain actually and this is going to autocomplete and you'll see that when I do this the the UI changes the user interface changes so boom there we go now I've got a little gain Slyder like a fader on a on a on a desk so I'm just gonna hook this up here and then this is going to be my gain slider for my sine wave and I'm just gonna hook this up to the output now we're going to use the EZ DAC this is an easy digital or analog converter okay and this is also going to change the UI there we go we have a neat little output button so I'm just gonna check the volume down here so that it doesn't blow up in your ears and now what I need to do is I need to turn on the the audio driver so there's there's two modes in mercs if you've not used Mac's before there's an editing version where we can click on things and grab them and move them around but we can't necessarily interact with them and then you can lock the patcher down here in the bottom left hand corner if I click lock you'll see that my grid disappears and now when I click on things I can't move them but I can interact with them so I'm going to turn on audio and I'm gonna drag this up hmm and we can't hear anything now that's because our oscillator needs it needs an argument it needs to be told something an argument is like information so in this case our cycle object a sine wave needs to be given a pitch it needs to be told what frequency it is gonna play okay and we can do this manually like this so I'm gonna say 440 Hertz that's how a synthesizer generally will read pitch you'll read it in Hertz frequency in Hertz so I'm telling it now play a sine wave at 440 Hertz now when we listen to this you can hear now you'll only hear this in the left ear of your headphones or left channel of your speakers at the moment because you'll see that where any patched up to the left outlet okay so I can just move this across now to the right outlet so we're copying this this channel is going to both the left and right output and now as a turning up it's in mono lovely okay well now what's next well first they I'm gonna create a new number I typed F they're just it's a shortcut for a floating-point number okay so it's a non integer number and I'm going to connect this because now this is going to do the job of telling our oscillator what frequency to play so if I turn this up and then I scrub this number around you'll hear the pitch of the synthesizer change that okay so we've got a little bit of control about oscillator now okay it's you can we're away off from making this a musical instrument but you can see how the gesture of me sliding this number around is changing the pitch and you know in a little while this could be something musical okay but this is a simple basic waveform and what we want to do remember is create a complex waveform so now I'm just going to go ahead and I'm going to create new oscillators to take care of each of the waveform types that we've listed here okay so this is gonna take a little bit of remembering on my part so I'm pretty sure that the triangle wave is just called right there we go now this is going to take a couple more objects a couple more arguments but we don't really need to worry about that so at the moment if we did want to find out what they what they were I would open the help file for this so I would just right click and open try help and that's gonna give me a little pop-up it's gonna tell me all about this object okay and I can do this for anything in max I can just right click on anything and hit open and it's gonna pull up all of this information that tells me how this object works what kind of arguments it takes what it can do how it can be used really really helpful stuff now if I open this one again now if you look over here on the right hand side this might be a little bit small on your screens but there's a see also section and this is really helpful because it's gonna show us related objects to what we're currently looking at so if I just look down this list I see at the top there I've got cycle sine wave oscillator and then I've got other related ones so here I've got a sawtooth signal for a phasor a rectangular oscillator so a pulse wave I've got another sawtooth oscillator and I've got triangle oscillators and things like this so this is really helpful because now I can just very quickly remember which ones I want I'm gonna create my sawtooth with that and I'm gonna finally create my pulse wave rect and there we go I've got our four basic waveforms so I'm gonna hook these up to the same number so they're all playing the same frequency they're playing in unison and then I'm gonna hook these up to the output I'm going to quickly do a little trick just to sum these so I'm going to create a new object I'm gonna put an asterisk in asterisks tilled and what this is gonna do is this is going to multiply our signal so it's gonna sum all of these different oscillators together these four oscillators it's gonna mix them together effectively but I want to multiply them by a small amount because I want to attenuate that signal because otherwise I've got the output of four oscillators all being sent to my headphones at once and that's a little bit much so what I'm going to do is I'm going to say zero point let's make it quite quiet for now so let's just say zero point one now let's get rid of this for a second move a multiplier over here and I'm going to send all of these to this left inlet on the signal multiplier and then patch this down here now if I reset this number to 440 like we started with all of these will now be playing at 440 Hertz and we can listen to this might sound a little bit messy okay not the nicest sound in the world okay let's start to play with the balance of this because at the moment this is kind of brash nasally sound it's not particularly nice but as we start to control things and balance the different oscillators we can come up with something interesting okay so now I'm going to keep these same oscillators but I'm going to change the the routing of that gain slider so that we can control the volume of each oscillator individually so I go back into edit mode and notice when I switch between edit mode and sort of locked mode you'll see the grid on the background disappear and reappear that's how you know which one I'm doing I'm just gonna add a quick note here quick comment because these are so this is always really really important to do so that when we come back to more complex and more complicated patches later on we remember what's going on so I'm just gonna say this is in Hertz and just so we know this is the frequency of all the oscillators almost darling's terrible right there we go just so that we know when we come back to it I'm going to clean things up a little bit I'm going to get rid of this no drop box go away now I'm going to switch things around so instead of having everything go to one multiplier to attenuate and then go to the gain slider I'm going to send I'm gonna create a bunch of gain sliders so I'm going to create a new object with N and it's called gain I've got a bunch of these a shrinking down a little bit and notice when i zoom in there's two there's two outlets here and that when you generally create one they're quite close together see and you can mix them up so I just drag this out a little bit just so it's easy to spot which one is which so now I'm going to create this and if I click on an object and hold alt and drag it it's going to create a copy it's really quick way of just making a bunch of things you can copy and paste like in other software as well but I just like this as it's quick I'm gonna move this out of the way now I still want to do the same thing I still want to attenuate everything a little bit so multiply tilt and let's just say 0.5 and now once again everything is going to come out of the left outlet of our gain slider and go into this and then over here so now if I wait and go back in if I turn and we just have our cycle we just have our sine wave but I going slowly turn up the triangle wave and we can hear the difference I should turn this up a bit [Music] [Music] here how the harmonics change in the tone of the sound kind of shifts subtly now one thing to do would be to see this so I'm just gonna very quickly create a scope this is an oscilloscope and it's going to show us what's going on with this sound now automatic mode I just put on here III did control I will command I on a Mac which will bring up the inspector I think automatic mode is only available on Macs a so if you don't have it don't worry but it's just going to show us what happens at the moment so let's turn all of these down and you'll see this is a sine wave okay this is a straightforward sine wave now as I change this see how the waveform changes now what happens if I slowly bring in the pulse wave the square wave see how it destabilizes that way for now if I bring back in the sine wave if we see something else happen I can change this and as we play around with this thing you can create some really interesting complex waveforms okay and remember this is what we wanted to generate so that then all of this information can be fed into our filter and we can start to sculpt or subtract from this complex sound okay now as it stands just having all of these oscillators feeding into each other at the same pitch is not particularly interesting and frankly it kind of doesn't sound that nice so what I want to do quickly is I want to just look at how we can change this frequency that they're getting to create something a little bit more interesting but at the same time still make it one pitch like rather than just sending them all separate unrelated pictures like building a chord now we could do this really easily because we could just shift the octaves of the frequencies so I'm just going to clear some space for a second let's just get rid of this move this down here that actually does email a little bit hopefully that's still readable now at the moment all of these oscillators are being sent 440 Hertz okay so we all get exactly the same pitch now what I'm gonna do is I'm gonna just do some really really simple division and multiplication to switch the octaves so now what I'm going to do is I'm just gonna say hmm what do I want I think I think I want that sine wave that really pure fundamental tone I think I want that to be an octave lower so rather than have to sit there with a with a calculator and figure out okay well what is an octave below 440 Hertz all I need to do is divide 440 Hertz by 2 so I'm gonna do like this divide which is the forward slash divide two numbers and then I'm gonna say by 2 it's really important though you put in the full stop at the end because that's gonna tell it to keep this number as a floating-point number rather than just round to the nearest integer so let's see if I take this patch this in and now I'm going to create a new floating-point number just to check it see what number we get so I'm going to press F there we go I'm gonna send that number here let's also send it to the sine wave now if I just put 440 and again boom 220 Hertz that's an octave lower so I'm just going to turn all these down turn their audio back on slowly turn sine wave back up now if I turn up the triangle wave which is still at 440 Hertz will hear the difference now [Music] okay gang confusing so I'm just gonna delete that [Music] now what if I went lower [Music] well there we go this is looking interesting in my oscilloscope now and it sounds quite nice we've got more of a separation there's more bass in that low pure sine wave that fundamental so if I bring in these other ones now it's not really changing a whole lot okay so let's try this again let's try and repeat the same process let's do it now with my pulse wave my square wave let's take this down an octave so now I've got my sine wave down two octaves my triangle wave this a regional pitch my sawtooth wave at original pitch and my pulse wave one octave down now each time I do this I just have to give this a little bit of a wiggle just so that it changes all of the numbers so just to check know just to check let's have that there so we can see that these are now all different pitches and when I turn this back up the way [Laughter] and one more and do something different this time this time I'm gonna take our sawtooth wave [Music] up an octave so I'm going to multiply it by two as the sawtooth wave comes in that's an octave above pulse wave is an octave down sine wave is two octaves down triangle staying static 437 Hertz so we've got a bit more spread here we've got some interesting things going on because this is just in octaves we're just spreading the kind of harmonic series around a little bit okay now we don't really have to worry too much about the perfect just intonation at the moment I already care about that that's something we'll get into a little bit later but the time being I do want to make this feel a little bit more like a musical instrument rather than just a test tone generator so what we need to do is we need to solve a little problem we need to say okay how do I control this control this here this frequency expressed in Hertz how I control it by MIDI which is a fundamentally different format it's a different mode of communication it's different it's just a different number so how do I map one number onto another how do I make MIDI understand what frequency is or how do I ant make an oscillator understand or care what MIDI is because normally they don't well max actually again makes it really really easy we just need to know what we're looking for okay so I'm just gonna move some things around just to clear a little bit of space you very quickly tend to run out of space I'm just gonna get rid of these because I don't need these anymore move this over here move this over here and keep our frequency at the top so a nice little thing you can do in max is if I just grab everything now I have to try and remove the shortcut okay I'm not gonna rim the shortcut there we go root patch cords arrange root patch cords there we go it's gonna clean up all of those messy patch cords and okay so our question is I have little MIDI keyboard like this you've probably got a different one in front of you and how do I get this to speak to our oscillators so we know that MIDI data is expressed in MIDI numbers which are kind of just straightforward integers usually from zero to one to seven and that's unrelated to frequency expressed in Hertz Max is going to take care of it because it has handy little object called M to F which as you can see here converts a MIDI note number to frequency hey that's exactly what we want so now I could send it a number like 64 and it knows that that is a specific pitch so let's just turn this back up and now I'm just gonna use my arrow keys to just move through the chromatic scale but that doesn't answer how we get the keyboard to do anything this just gives us a way of translating one format into another so to bring the keyboard in there's another max object called note in now there's a there's a whole bunch of objects related to MIDI and MIDI data if you want to find out where they are again I'm just gonna pull up that help file and you'll see kind of a whole host of related MIDI objects down here in the right hand side or I can click on this question mark up here and there's a reference and there's also tutorials Max's tutorials are really really amazing really helpful and look there's all of this information about how to work with MIDI in Max so the time being though all we want is this note in so if I go back to my lock screen there we go if I double click it you'll see that I've got all devices by channel so that's just gonna listen for all MIDI information coming into my computer and if I just create a couple of numbers just so we can see what's coming up these just these don't have to be floating numbers these can just be integers so I use the shortcut I to make those just kind of hook close up so if you haven't seen this already if you hover your mouse over an inlet or an outlet on an object it will tell you what it needs and what it is sending out so here on this leftmost outlet of no tin we can see that it's sending out pitch the next one along velocity and then the last one MIDI Channel so now fingers cross this works if I press a key a there we go we can see the numbers changing and we've got pitch numbers so let's just put this down here if all we want is this pitch number this MIDI note number which is going to be translated through the m2f object in a frequency in Hertz we should now [Music] my keepo playing is not good for you get the idea okay so now we have musical my performance notwithstanding control of our oscillator this really feels a bit like a synthesizer now we have musical control musical interaction of this sound but I have a problem the problem is that you know music has reached the point now where we are 50 60 70 years past the birth of the synthesizer okay when I make this video it's 2019 why in 2019 do we still insist on using things like this this antiquated interface this this 12 tone equally tempered keyboard why do we want to use this to control something as powerful and as exciting as a synthesizer there's so much more out there and that's what we're gonna look at a little bit later after we finished building a synthesizer we're gonna look at using Arduino boards and kind of various sensors and hardware controls to control aspects of our synthesizer okay now the next few videos are gonna sort of focus more on just building out this synthesizer so we've got our first sound source now and we can start to add things we can start to work with filters and shaping our sound and doing more interesting things but ultimately you know this is this is your instrument to play around with so you know try different numbers see what happens if then this could go really horribly wrong see what happens if we just put in random numbers let's see if I put in 1.3 now my sawtooth wave that's not bad away yeah great okay back to the drawing board play around with the instrument come up with interesting things ask yourself okay well why do I want just straight octaves why couldn't it be what happens if I put it six off tips below so everything is just massive sub bass play around switch numbers out get things wrong and make mistakes because when you start to make mistakes that's where you kind of come up with to use the Bob Ross term happy accidents okay that's where you make fun weird little strange devices and strange instruments okay and that's one of the beautiful things about Max there's a lot to go wrong and therefore there's a lot of serendipity kind of just waiting for you in the instrument okay so that's oscillators that's the sort of start point of our synthesizer play around with this come up with some cool things look at Max's other forms of oscillators other wave generators and see what see what happens there when you start to play around with them you could have you know six sine waves all tuned to slightly different pitches and a bunch of sawtooth waves there's no reason that it has to be these four you could use as many or as few as you like but yeah have fun playing around with it thanks okay I finished filming the video and then I had a lot idea and I wanted to do it so it turned out kind of fun so I thought I'd share it with you so what I've done here is I kind of thought rather than just doing like multiply by two divided by four to change the octave I thought well we can do that with MIDI numbers because we know there's twelve notes in an octave right so for a MIDI number all we have to do to move an octave up or down is add or subtract 12 from that note number so why did was I made a little multiplier thing down here so now what's happening is if you multiply one by twelve you get twelve and if I add that to whatever my current MIDI number is so I use the add addition object now if I add an octave above MIDI note forty-four I get MIDI note 56 if I don't do any I keep I keep 44 if I go down an octave so minus one you see my MIDI note shifts down to 32 so in effect what that means is I get a note that now I can receive my arrow key to move your objects [Music] which is kind of fun the one thing that I really love to use in max is I love to use randomization okay so there is an object just called random and whenever it gets triggered it generates a random number between zero and whatever you asked it for so I'm gonna say generate a random number between zero and eight okay so anytime this gets triggered it's going to output a random number between zero and eight now I'm going to offset it so I'm gonna create a new object and I'm gonna subtract space for from that so now my range of my random number is going to be from minus 4 to plus 4 okay and it's gonna get triggered anytime I change the note so let's see what happens this might go horribly wrong [Music] so I'm not playing the same note and it's generating switching into random octaves [Music] was too far well we could really quickly really easily modify this right so at the moment there are all receiving the same frequency so all of our operatives are tuned to same some just gonna get rid of these for a second so there we go these are all the same octave now what we could do is we could just copy this so I'm going to select all of that little octave switcher device that I just made and I'm going to encapsulate it now because I'm on a Windows computer I can't quite remember a shortcut well this is embarrassing there we go encapsulate ctrl shift E and that's just gonna create a new little sub patcher so I'm just gonna call that octave switcher now if I wanted to see that it's all still there there we go it's in another window it's just hidden now so it makes it smaller it takes up less space and it means that I can very simply I'm just gonna get rid of this for a second I drag this over here and I'm gonna create four of them I'm gonna hook them up yep so now all being well any time I play a note each of those four oscillators is going to receive that note but in one of eight different octaves oh god I hope this works [Music] well that was interesting okay [Music] yeah so that's just an example of you know how you can kind of play around with these things I really really encourage you to use random I mean maybe not too much it can be overkill but if you use it kind of nicely and maybe a range of it was a little bit much there but random can do some really really interesting and really exciting things so so have a play around with that try that out if you want and yeah come up with some cool stuff cool
Info
Channel: oliver thurley
Views: 7,309
Rating: undefined out of 5
Keywords: electronic music, lesson, synthesizer, synthesis, modular synthesizer, Max/MSP, Max, programming music, computer music
Id: ax4n8fGoWIo
Channel Id: undefined
Length: 39min 1sec (2341 seconds)
Published: Tue Jan 29 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.