SynthMaker

oh if only i could grasp the math basis :)

Archive · 2005 19 old posts

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

lalo ·

http://www.active-web.cc/html/research/sine/sin-cos.txt

better i go study some basic (well not so basic) math.. can anyone suggest books/net resources?

this seems to be an interesting wave generation method

maybe can it be done with the code-component? can it?

lalo

stefan ·

This part of the code:

double sin = 0.0, cos = 1.0, frq = 2.0 * M_PI / length;

for ( 1 .. length-1 ) { cos -= sin * frq; sin += cos * frq; }

Is easily ported to SM. But I gotta go to lunch now, I'll get back to you later 🙂

stefan ·

Ok, I've read the whole article now. What parts of it do you really find interesting? All it does is generate sines, but fast. The code I pasted above seems to be the most suitable one to be used in SM oscillators, it should quite easily be realised with a simple schematic without using the code component as well.

ik_ik_ik ·

Hey Lalo,

Have to share [this] link to an unbelievable resource for books, papers and notes on Math, Computation and Physics topics. Some pretty heavy going stuff but certainly the kind of resouorces in which you'll find buried treasures - bit of a pandora's box though. Amongst other things you'll find the excellent The Scientist's And Engineer's Guide To DSP. It's really slow at the moment but hopefully it won't always be like that (or worse disappear altogether).

I know it's been mentioned [elsewhere] by Jorge but the Computer Music Tutorial [amazon] really is probably one of the best (if not heaviest) books you could invest in although it doesn't cover the heavier maths side of things. Dave Benson's Mathematics And Music and again The Scientist's And Engineer's Guide To DSP is also mentioned in that thread and both are well worth reading.

Might well also be worth checking out some of K.A.Stroud's Engineering Mathematics books. We used them at university and they will cover a lot of the principles.

On another tangental tip you can find some pretty interesting articles and publications over at electro-music's composition forum [here].

lalo ·

hey ik! thanx for the links....infact i suggested the Computer Music Tutorial to jorge some month ago 🙂 i have it..but it doesn't (as you said) cover the basic math principles... i really have some little basis about it (no calculus at all).

thanx for the other resources man!

lalo

lalo ·

stefancrs wrote: Ok, I've read the whole article now. What parts of it do you really find interesting? All it does is generate sines, but fast. The code I pasted above seems to be the most suitable one to be used in SM oscillators, it should quite easily be realised with a simple schematic without using the code component as well.

thanx stefan!

i was interested by the fact that the author seems to support the idea of a fast mathematical sine generation instead of a wavetable based one...

how would you implement that code in code component? or with a schematic?

thanx lalo

stefan ·

lalo wrote: stefancrs wrote: Ok, I've read the whole article now. What parts of it do you really find interesting? All it does is generate sines, but fast. The code I pasted above seems to be the most suitable one to be used in SM oscillators, it should quite easily be realised with a simple schematic without using the code component as well.

thanx stefan!

i was interested by the fact that the author seems to support the idea of a fast mathematical sine generation instead of a wavetable based one...

how would you implement that code in code component? or with a schematic?

thanx lalo

In the code component, something this should work:

polyin freq; polyout sin; float sin; float cos; float mul;

// since the code component does not support initialising of variables we have to do a hack float isInitialised; isInitialised= ((cos > 0) & 1.0) + ((cos < 0) & 1.0); cos = (1.0 - isInitialised) + (isInitialised > 0) & cos; mul = freq * 2.0 * 3.141592; // roughly pi

cos = cos - sin * frq; sin = sin - cos * frq;

I might've done something wrong when initialising cos to 1.0, I'm a bit stressed atm 🙂

lalo ·

many thanx stefan! i'll really havet to understand that complex sine thing one day 🙂

lalo

stefan ·

There should ofcourse not be a float sin; in the code I wrote. Since there's a polyout sin...

global goon ·

in the last two lines, should frq be mul?

stefan ·

global goon wrote: in the last two lines, should frq be mul?

darnit, yes.

stefan ·

Here's a working version

polyin freq; polyout sin; float cos; float mul;

// since the code component does not support initialising of variables we have to do a hack float isInitialised; isInitialised= ((cos > 0) & 1.0) + ((cos < 0) & 1.0); cos = (1.0 - isInitialised) * 0.99 + (isInitialised > 0) & cos; mul = freq * 1.0 * 3.141592; // roughly pi

cos = cos - sin * mul; sin = sin + cos * mul;

edit: btw, this uses ridicously low cpu, so thanks for the tip lalo 🙂

stefan ·

I also discovered how to do phase modulation with this kind of sine oscillator implementation. Still ridicously low cpu. So I will have to use this instead of the sin1() function in my oscillators 🙂

Your lesson for today will be: How to add phase modulation? (it is quite simple really 🙂)

Large ·

"How to add phase modulation? (it is quite simple really 🙂)"

Have you figured it out yet? I need an OSM of a low CPU sinewave with a phase input.

Thanks

stefan ·

Have a look here: Is this possible to code? :

The code is however very old and for instance you can more easily initialize variables now when declaring them.

Large ·

I have no idea how to write code. I did find this, and it saves some CPU.

Is there any way you or someone could enhance it further to save more CPU?

polyin freq; polyin phase; polyout out; float cos; float sin; float tCos,tSin; float mul; // since the code component does not support initialising of variables we have to do a hack float isInitialised; isInitialised= ((cos > 0) & 1.0) + ((cos < 0) & 1.0); cos = (1.0 - isInitialised) * 0.99 + (isInitialised > 0) & cos; mul = freq * 1.0 * 3.141592; // roughly pi

cos = cos - sin * mul; sin = sin + cos * mul;

/* this is the "obvious" implementation of phase modulation tCos = cos - sin * phase; tSin = sin + tCos * phase; out = tSin; but we can simplify it into one expression instead for better perfomance, like this */ out = sin + (cos - sin * phase) * phase;

MyCo ·

// since the code component does not support initialising of variables we have to do a hack

That's not correct, you can use stage 0 to initialize, read this: [old link]

Large ·

Hi MyCo, could you optimize the code above so it runs faster? I'm basically needing a very low CPU code that generates sinewaves and allows a phase input. Thanks!

stefan ·

MyCo wrote: // since the code component does not support initialising of variables we have to do a hack

That's not correct, you can use stage 0 to initialize, read this: [old link]

Or just go float cos=1;

like I said, the code is oooold 🙂

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.