Next lesson playing in 5 seconds

Cancel
  • Overview
  • Transcript

2.6 Different Sounds

In this lesson you’ll learn about different types of oscillators and how they can be combined to make different sounds.

Related Links

2.6 Different Sounds

So while that our synth makes a sound, the sound it makes isn't particularly interesting. The default sound an oscillator produces is that of a sine wave. A sine wave is a very pure sound. And it is this wave that gets repeated hundreds of times a second, in order to produce the note we hear when we play our synth. But as we learned earlier, different sines have different shapes. And we can see here the built in shapes that wave audio oscillator comes with. Sine, square, triangle, and saw tooth. Each of these waves sound different. Let's change our synth to play a square wave instead. We just add this line. Asc.type equals square. Easy. Let's hear how it sounds. [SOUND] Now you can hear that's quite a bit different, a lot harsher. Take the time to play with the different types. Now another interesting thing you can do is combine these sounds. Most synthesizers have more than one oscillator, and because of the way the API's routing works, that is connecting nodes to each other in any combination we like. Then we can have different oscillators playing different sounds at the same time. Let's double up our oscillators. Let's rename our oscillator's object to square oscillators, and create another one called sorted oscillators. Okay, before we continue, we'll have to rename all mentions of oscillators to square oscillators. As well as the individual oscillator to make things nicer. Let's just do a find and replace to speed this up. There we go. So let's double up. Everywhere we see a square oscillator mentioned, we'll do similar with a saw tooth oscillator. We'll need to add our new oscillator to our new saw tooth object. We'll have to connect it to our volume node. Note here that we don't have to create a separate volume node. We can have as many oscillators as we like sharing that node. And we'll obviously have to change the type of node here. I will, however, start at the same time. We'll have to double up in our key op function, as well. Stopping and disconnecting when a key is lifted. Great, so now we have two different oscillators playing at the same time. Let's hear how that sounds. [SOUND] So it sounds pretty good, and a bit different to either of the oscillators played on their own. However, there's we can do to make the sound even better. We can de-tune the oscillators. Hmm, de-tune the oscillators? Well, you may be worried that your synth's going to be all out of tune and you won't be able to jam along to your Gary Newman records, but just trust me on this one. We take our first oscillator and detune it by saying squareOsc.detune.value = -10. This value here is in cents, so if you imagine the difference in two adjacent notes on our keyboard, the difference between these two notes can be divided into 100 cents. By detuning our to minus ten cents, we're seeing make the pitch of the source letter 10% closer to the note below it. So is this going to sound out of tune? Yes. But we're going to balance it out by detuning the other oscillator in the other direction. Sawtoothask.detune.value = 10. So here we're going 10% closer to the above. So why are we doing this? Well, by detuning each oscillator, we end up with what is known as a chorus effect. Let's hear it. [MUSIC] You should be able to notice our synth sounds a little bit more shimmery, softer and overall more pleasing. Imagine a group of people singing together. No one's vocal chords vibrate at the perfect frequency. So when you have a group of people that all sing very slightly out of tune with each other, but they're more or less there, and we end up again with this pleasing chorus effect. Now if a couple of people in the group are really out of tune, and things aren't going to sound too great. Much like a our synth too much. You can read more about this effect on Wikipedia. So I'd say we got a pretty sounding synth now. There isn't much to look at, though. Let's sort that out in the next couple of lessons.

Back to the top