From the original SynthMaker forum (2004–2014), with its members’ names and dates.
MikeG ·
Hello everyone! A n00b here...
I have yet to learn to write codes and I'd love to experiment with different waveforms... Sooo I'd really appreciate if someone could toss me an oscillator template in which I could type the waveform as trigonometric function.
Eg. Sin(x)+0.5Sin(2x).....
Thanks!
PS: Merry Christmas! :P
infuzion ·
Welcome to SM MikeG & Merry Xmas to you!
Searched for "Sine OSC"?
MikeG ·
Yea, I did.
I'm quite handy with high level modules already, but what I'm looking for is using the code-module. So far I can create inputs and outputs to it but nothing else really. I'd love to get an example of code (and a bit of guidance on how to use it) in which I could type the waveform as a trigonometric function...
I tried to use the codes from ''simple sine oscillator without using sin1()''-thread, but didn't quite catch the drift. 😕
cyto ·
Hi MikeG!
Over here (square-wave oscillator) I posted an example of a few basic coded oscillators. Basically they all use a "saw" as a control signal. In the example, you can see how to translate that control signal into a sine function. Hopefully that will get you going in the right direction and you'll be able to figure out how to create different trigonometric waveforms in a similar manner. If you need any clarification, I'd be more than happy to help out.
-cyto
MikeG ·
Thanks cyto!
I'm learning. Although slowly :/
By the way, I see something similiar to this
stage(0) {
b=1;
}every now and then. What does it mean?
cyto ·
MikeG wrote: By the way, I see something similiar to this
stage(0) {
b=1;
}
every now and then. What does it mean?
SM uses four different "stages" to process its code components. "Stage 0" only gets run on the very first sample. Generally, you would put any initialization routines here to get your variables at their "starting" value. Other times you may use this stage to do CPU intensive math that only needs to get run once (like building lookup tables or something similar).
BTW, the other stages are 1, 2, and 3. They get run every sample, but the difference is that stage 1 gets run first (schematic-wide). Then stage 2 (which is the default stage) gets run schematic-wide. Finally, stage three gets run. Any code that is not in a declared "stage" (and between the little {...} brackets) is assumed to be stage 2. There is a somewhat decent description of this process in the "code" section of the user guide. Apparently, stage 1 and 3 are useful for moving data in and out of buffers while building delay routines, but personally I have never used them.
-cyto
infuzion ·
Just to reiterate what cyto said:
93% of the time you use the default Stage 2
5% of the time Stage0 is used to pre-calculate some things. (actually initializations should be done when declaring: "float counter=1", & others may be done in Green outside the Code)
2% when you use Stage1 or Stage3 it is likely for reverbs/echo
MikeG ·
Thanks a ton guys! Just coded my first osc! \o/
And I found out that it is slightly detuned. At least compared to my synth.
Is it because SM uses so limited amount of decimals in calculations that pitch gets screwed up a bit?
Or maybe I'm just doing something wrong...
However detuning is only like 2 Hz at C8 so it's not really dangerous 😀
cyto ·
MikeG wrote: Thanks a ton guys! Just coded my first osc! \o/
And I found out that it is slightly detuned. At least compared to my synth.
Is it because SM uses so limited amount of decimals in calculations that pitch gets screwed up a bit?
Or maybe I'm just doing something wrong...
However detuning is only like 2 Hz at C8 so it's not really dangerous 😀
Congratulations! Regarding the rounding errors(?), SM uses a 32-bit floating point decimal representation in its code component which is fairly precise. There will inevitably be some rounding errors, but usually nothing too dire. For reference, I use the tool at http://www.h-schmidt.net/FloatApplet/IEEE754.html to see exactly what kind of representation to expect. You need Java installed to use it.
-cyto
Wrote something here? To have a post removed or your name hidden, write to [email protected].