SynthMaker

oscillators WaveTables vs Formulas

Archive · 2011 15 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

GhostAddicts ·

all the oscillators in SM seem to be based on wavetables. Formulas seem to be more usable, especially when making LFO's. My question now is can i have some help making oscillators?

I have an efficent sine wave with phase inputcontrol. Frequency modulation doesnt work however, but i dont see how frequency modulation would work in softsynths anyways. my question now is how can i make saw,ramp,triangle, and square osc. ramp seems kinda easy, take phase that would be used in sin subtract 1 and multiply by 2 and the phase becomes ramp output, saw is ramp multiplied by -1. square would output 1 or -1 depending if phase is greater then or less then 0(this can be modified for pulse modification.) triangle would need 2 stages, a less then the last sample phase and a greater then the last sample phase. Could i get this into a formula? It's been awhile since i have been on SM and my coding is kinda foggy

trogluddite ·

All of the regular waves can certainly be calculated from formulae - but with audio oscillators there is a catch...

Aliasing... A calculated 'pure' wave will always contain harmonics well above 1/2 the sample rate (apart from the sine wave) - it might seem weird that this can happen given that our code runs at sample rate, but nevertheless, it will always happen.

This is why the regular oscillators use wavetables - they each contain many small waves, which are all 'pure' waveforms minus the >SR/2 harmonics. The oscillators switch between the different waves depending on the input frequency to ensure that you hear the maximum bandwidth that will still have no aliasing.

Because alias frequencies are 'reflected' back to lower frequencies within the audio bandwidth, there is no way to simply filter them out, you have to use oscillators that don't alias in the first place. The code to generate such alias free waves by calculation would be far more complex and processor intensive than using a wavetable.

When using FM, it is even more complex, because even two non-aliasing oscillators can generate extra high harmonics when FM'ed - at that point you have to start using oversampling to have any chance of removing the aliases.

Having said all that - if you don't mind a bit of digital 'crunch', it can be quite fun to mess with generated waves - and they are certainly useful for 'non-audio' signals like LFO's.

Assuming you are starting with a ramp from 0...1, the other waves are...

Sine = sin1 (Ramp); Saw = 2 * Ramp -1; Square = 1 - 2 & (Ramp >= PulseWidth); Triangle = (4 * Ramp - 1) + (4 - 8 * Ramp) & (Ramp >= 0.5);

..which all give a -1....+1 output.

GhostAddicts ·

Trogg, your always there to help me. I have another question to ask though, not really related to this but why spam up the forums with my new questions. I tried to replicate Benny Bennasis sound, namely the satisfaction sound. And well i came up with this, the main problem is that it seems to have a nasty pop at the begging of the note, and after a note ends there seems to be some low frequency, low level noise coming thru. And at higher notes there is DC offset. This is meant to be played around c2-c3. if you play C-B-F on either of those octaves you will hear what i believe to be bennys sound without distortion or compression.

Mo ·

😀,

An saw would do.

Add a ramp primitive to:

streamin in; streamout out; float F0P5=0.5; float F2=2; movaps xmm0,in; subps xmm0,F0P5; mulps xmm0,F2; movaps out,xmm0;

..in a assembler primitive. That would give a clean saw. Then portamento/glide is needed to make benassi bass leads too.

trogluddite ·

Your popping should disappear once you have an output envelope and volume control in there. Without an envelope the notes will cut in and out too quickly. You will also get nasty 'splats' when two notes overlap - that is just distortion from the signal level being two high. The stock oscillators output the maximum range -1...+1, so they will always need turning down if you have poly voices or multiple oscillators.

I don't hear any low level 'breakthrough' noise - and a readout shows that the output drops to zero when no notes are playing. The only thing I can think of is that maybe your soundcard hardware doesn't like the DC offset, and you are hearing a capacitor circuit somewhere discharging or resonating.

The DC offset is perfectly normal for a sync'ed oscillator - because you only get to hear the initial part of the wave (up to the sync point), it will naturally no longer be centred around zero. There's a nice low-CPU DC remover in the Developer's Toolkit. A nice side effect of adding a DC remover, is that you get a slight blip at the start of notes as the DC filter tries to handle the attack transient - this used to be very common on old analogue synths that used coupling capacitors, and can give a little extra 'oomph' to short attack envelopes.

GhostAddicts ·

Mo thanks for that assembler code, but i'm not sure you took a look at the OSM i posted, it makes a sound identical to bennys bassline in satisfaction. it seems the splat and noise were being caused by the effects in FL which alot seem to have DC remover. I'm not allowed to see that toolkit, it must be from the members only forum. I own the FLSM version and i guess that doesnt make me a customer -_-

EDIT: I've wonder this for a while but now i need to know, how does one actualy use release in SM, at first i didnt know why it didnt work but now i know its because Poly streams are only active on midi note on so how does one keep the oscillator to continue oscillating during the release phase?

trogluddite ·

GhostAddicts wrote: oscillator to continue oscillating during the release phase?

Once you have envelopes in your design, this should happen automatically - the stock envelopes have some hidden logic that talks to the voices module and keeps everything running until the release is finished.

GhostAddicts ·

I tried using a ADSR at my friends house and his release worked, my SM doenst have it though, i have a simple ADSR that i built myself, but it doesnt have that backwards logic, would anybody mind helping me out by making an OSM with an ADSR that has that backwards logic.

infuzion ·

GhostAddicts wrote: an ADSR that has that backwards logic.

What do you mean plz?

GhostAddicts ·

Nevermind i figured it out, hold sound until after release was false.

loopeytunes ·

this is what i got with SM for a benassi sound: . not great but the bass sounds very similar 😀

GhostAddicts ·

Loopey, thats almost identical, i do feel like you put too much reverb though. So i have a couple questions, When an oscillator is hard synced(as i plan to do for unison on the synth im working on building) does it start at 0 phase or does it calculate the phase input? Also has any one heard of HCM, new synthesis technique... and what seperates phase distortion and phase modulation? I know alot of questions but I've hit a couple things that google doesnt know.

trogluddite ·

GhostAddicts wrote: does it start at 0 phase or does it calculate the phase input?

Finding these things out it what the scope module is for! 😉

GhostAddicts wrote: Also has any one heard of HCM, new synthesis technique...

Had a quick browse of the descriptions - sounds very powerful. I would guess from what I've read (morphing of harmonic content, spectral compression etc.), that it uses some form of FFT technique.

GhostAddicts wrote: what seperates phase distortion and phase modulation?

There's a good description of how phase distortion synthesis works (with helpful diagrams) HERE - the only real difference between that and phase modulation is in the frequency and shape of the modulator wave. I suspect that the differences were more to do with trademarks/copyright than anything particularly technical.

@loopey - like your snazzy new logo!

GhostAddicts ·

Ahaha, i thought i might get a kind find out yourself for that first one. I was tired last night and just wanted to see if i could get an answer for when i woke up. xD but HCM i feel like it would be somewhat of the idea my first post in SM forums was about, combining shapes to play some harmonics at different levels to morph how the sound is heard, half triangle half square would give a muted saw type of sound i believe. i wonder if there is a way to replicate that, a synth that uses it has alot of wavetable synths and i bet anything its based off of squared saws and sintriangles. Great link. thanks for that. Another question, when retriggering a note that is already active, how do i have SM create a new voice while allowing the existing voice to finish its release stage?

trogluddite ·

GhostAddicts wrote: Another question, when retriggering a note that is already active, how do i have SM create a new voice while allowing the existing voice to finish its release stage?

AFAIK, that is the default behaviour - if you go inside the MIDI to Poly, you will see that the 'M to V' primitive has a boolean input 'NoRpt' (not connected) where you can turn that off (so that same note re-uses the same voice).

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.