oscillators WaveTables vs Formulas

If you require help or assistance with anything then please post here

Moderators: electrogear, exonerate

oscillators WaveTables vs Formulas

Postby GhostAddicts on Tue Aug 23, 2011 12:33 pm

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
GhostAddicts
essemist
 
Posts: 82
Joined: Wed May 11, 2011 12:02 pm

Re: oscillators WaveTables vs Formulas

Postby trogluddite on Tue Aug 23, 2011 5:08 pm

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...
Code: Select all
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.
Feel free to use any schematics and algorithms I post on the forum in your own designs - a credit is appreciated (but not a requirement).
Don't stagnate, mutate to create. Without randomness and serendipity the earth would be just another barren rock.
User avatar
trogluddite
smychopath
 
Posts: 3024
Joined: Mon Oct 20, 2008 3:52 pm
Location: Yorkshire, UK

Re: oscillators WaveTables vs Formulas

Postby GhostAddicts on Tue Aug 23, 2011 9:17 pm

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.
Benny.osm
(6.27 KiB) Downloaded 95 times
GhostAddicts
essemist
 
Posts: 82
Joined: Wed May 11, 2011 12:02 pm

Re: oscillators WaveTables vs Formulas

Postby Mo on Tue Aug 23, 2011 9:35 pm

:D,

An saw would do.

Add a ramp primitive to:
Code: Select all
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.
User avatar
Mo
essemilian
 
Posts: 439
Joined: Thu Jan 24, 2008 2:00 pm
Location: Copenhagen

Re: oscillators WaveTables vs Formulas

Postby trogluddite on Tue Aug 23, 2011 10:54 pm

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.
Feel free to use any schematics and algorithms I post on the forum in your own designs - a credit is appreciated (but not a requirement).
Don't stagnate, mutate to create. Without randomness and serendipity the earth would be just another barren rock.
User avatar
trogluddite
smychopath
 
Posts: 3024
Joined: Mon Oct 20, 2008 3:52 pm
Location: Yorkshire, UK

Re: oscillators WaveTables vs Formulas

Postby GhostAddicts on Tue Aug 23, 2011 11:11 pm

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?
GhostAddicts
essemist
 
Posts: 82
Joined: Wed May 11, 2011 12:02 pm

Re: oscillators WaveTables vs Formulas

Postby trogluddite on Wed Aug 24, 2011 6:05 am

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.
Feel free to use any schematics and algorithms I post on the forum in your own designs - a credit is appreciated (but not a requirement).
Don't stagnate, mutate to create. Without randomness and serendipity the earth would be just another barren rock.
User avatar
trogluddite
smychopath
 
Posts: 3024
Joined: Mon Oct 20, 2008 3:52 pm
Location: Yorkshire, UK

Re: oscillators WaveTables vs Formulas

Postby GhostAddicts on Thu Aug 25, 2011 12:34 pm

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.
GhostAddicts
essemist
 
Posts: 82
Joined: Wed May 11, 2011 12:02 pm

Re: oscillators WaveTables vs Formulas

Postby infuzion on Thu Aug 25, 2011 3:46 pm

GhostAddicts wrote: an ADSR that has that backwards logic.
What do you mean plz?
Need help? First search the forum & WiKi, then post in the help forum with a clear topic, request, & OSM. Then please WiKi the correct solution. If you want my personal assistance, I charge by the hour or for an exchange of services.
infuzion
smstar
smstar
 
Posts: 6163
Joined: Wed May 04, 2005 8:02 pm
Location: Earth, USA, CO, Denver

Re: oscillators WaveTables vs Formulas

Postby GhostAddicts on Thu Aug 25, 2011 4:02 pm

Nevermind i figured it out, hold sound until after release was false.
GhostAddicts
essemist
 
Posts: 82
Joined: Wed May 11, 2011 12:02 pm

Re: oscillators WaveTables vs Formulas

Postby loopeytunes on Thu Aug 25, 2011 9:21 pm

this is what i got with SM for a benassi sound:
Benassi Loopey Bass.mp3
(469.79 KiB) Downloaded 63 times
. not great but the bass sounds very similar :D
User avatar
loopeytunes
essemilian
 
Posts: 452
Joined: Tue Dec 22, 2009 12:25 am
Location: Yorkshire, UK

Re: oscillators WaveTables vs Formulas

Postby GhostAddicts on Fri Aug 26, 2011 6:29 am

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.
GhostAddicts
essemist
 
Posts: 82
Joined: Wed May 11, 2011 12:02 pm

Re: oscillators WaveTables vs Formulas

Postby trogluddite on Fri Aug 26, 2011 7:47 am

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!
Feel free to use any schematics and algorithms I post on the forum in your own designs - a credit is appreciated (but not a requirement).
Don't stagnate, mutate to create. Without randomness and serendipity the earth would be just another barren rock.
User avatar
trogluddite
smychopath
 
Posts: 3024
Joined: Mon Oct 20, 2008 3:52 pm
Location: Yorkshire, UK

Re: oscillators WaveTables vs Formulas

Postby GhostAddicts on Fri Aug 26, 2011 4:15 pm

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?
GhostAddicts
essemist
 
Posts: 82
Joined: Wed May 11, 2011 12:02 pm

Re: oscillators WaveTables vs Formulas

Postby trogluddite on Fri Aug 26, 2011 5:44 pm

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).
Feel free to use any schematics and algorithms I post on the forum in your own designs - a credit is appreciated (but not a requirement).
Don't stagnate, mutate to create. Without randomness and serendipity the earth would be just another barren rock.
User avatar
trogluddite
smychopath
 
Posts: 3024
Joined: Mon Oct 20, 2008 3:52 pm
Location: Yorkshire, UK


Return to Help

Who is online

Users browsing this forum: No registered users and 1 guest