SynthMaker

Math formula for OSC

Archive · 2009 4 old posts

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

Batteryman ·

I'm seeking for a request, that formula to construct basic OSC. And formulas that shows hows to do the stuff. Considering beginners like me, who whant to understand the basics about OSC, whitout searching itself nuts after formulas. 🙂

If Synthmakers experts here can easly shows examples. I know however there is a formula that make a Sinus OSC, but that version does not work very well as a Carrier if you whant to modulate it whit frequence,but you can use this as a modulator , that modulate a stock OSC. Yet, it doesnt have phase input, however in advantage, this forumula takes around 14.9 Cycles.

streamin f; streamout o; float sin; float cos; float mul; f = f*8; stage (0) {sin=0;cos=1;} hop (2048) {mul = 2*sin1(0.25*f);} hop ( 4 ) { sin = sin + mul * cos; } hop ( 4 ) { cos = cos - mul * sin; } hop (4) { o=(0.25*sin); }

f = f*8 - Works like an pitch offset, like a detuner does, make it sounds like a normal stock OSC would do at C-note, or any other note

hop (2048) - Where you find this number 2048, will make an delay when the signal starts, if you whant to use this code as a modulator, it might be better to set it at 1024 maximum.

hop ( 4 ) { sin = sin + mul * cos; } hop ( 4 ) { cos = cos - mul * sin; } -Bouth this lines seems to effekt the base pitch,therefore i use f*8 to calibrate the pitch

hop (4) { o=(0.25*sin); } - - By increasing this number it seems to make an resolution "distortion" on the signal, in this example it sounds very 8-bit i beleve.

So , i hope thise experts here can bring up more basic formula here, to learn the beginners Coding 🙂

Batteryman ·

This is also an interesting formula, but takes much cycles compare to a stock OSC,however , you can experiemnts whit Hop codes, and the end result is a bit different than plain , saw and square waves.

polyin freq; polyout output; float cnt; float feedback; feedback = 0.2;

cnt = cnt + freq; cnt = cnt - ((cnt >= 1.0) & 1.0); output = sin1(cnt + output * feedback);

Found this on a old post, by Stefan i think

feedback = 0.2; - This value can distort the waveform, 0.0 = Sine "orginal" 0.2 = Sawlike 0.3 = Sawlike whit some resonanse like peaks

If you change output = sin1(cnt + output * feedback); TO output = sin1(cnt + output * output*feedback); You will make a 2 sided waveform, each has mirror side, the result will be square, you can experiement the value between 0.15 to 0.3

aliasant ·

I made some modifications to your first code.

This uses a little more. About 12.7 cycles on my machine. The original used 10 cycles.

The f Input is actually a 0-1 ranged input that probably has little to do with frequency but it works quite well for a fast lfo signal.

And there are no delays or such weirdness so the rate can be varied. Could be useful for some maybe?

streamin f; streamout cos; float sin; float cos; float mul; float f1;

stage (0) {sin=0;cos=1;} hop (128) {f1 = 0.5 + (f*f * 0.25) + 0.00001;} hop (128) {mul = sin1(f1);} sin = sin + mul * cos; cos = cos - mul * sin;

Batteryman ·

aliasant wrote: I made some modifications to your first code.

This uses a little more. About 12.7 cycles on my machine. The original used 10 cycles.

The f Input is actually a 0-1 ranged input that probably has little to do with frequency but it works quite well for a fast lfo signal.

Its seems this code based OSC is more stable , but still there is slighly some flaws on some notes, but its , much betther.

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.