Page 1 of 3

HardSync FM problem

PostPosted: Sat Jul 27, 2019 3:04 pm
by adamszabo
Hey Guys,

I had a specific issue for a project a while back, and completely forgot about it. Now I found it again, and I still cannot solve it, so I thought maybe someone here can give me a hand.

Basically I have a hard syncable ramp, but I would like to frequency modulate it as well. Now, everything works fine, until you move the "Phase1" knob, and you can see that the first cycle of the ramp with the FM gets totally messed up and starts changing. The rest of the cycles of the ramp are fine. If I turn down the FM knob, then I can move the Phase1 knob fine and it works. I tried so many things I have no idea what else to do, maybe someone can give me some clever tricks or ideas, or maybe my code is wrong?

Thanks!

Re: HardSync FM problem

PostPosted: Sun Jul 28, 2019 9:27 am
by Duckett
While I am the knowledge-equivalent of an eager puppy when it comes to audio DSP, I can see that with FM cranked up, changing Phase2 affects all cycles, while changing Phase1 affects only the first cycle (unless at min or max of course)... I changed the scope's "samples to show" to 1012 in order to look at 6 cycles, and while there is some subtle periodicity that's longer than 1 cycle (depending on Phase2 and FM settings), you're right, there's no creep towards asymmetry. Unless there's a way to apply the FM before Phase1 (which I'm definitely too ignorant to know if that's even possible), I'm not sure there would be a trick that lets you circumvent the issue; any value other than 0 or 1 for the 1st cycle, in the way the schematic is set up, means it's not to going to ever match the rest of the cycles with FM applied. I hope a smart person answers this with something actually useful ;)

Re: HardSync FM problem

PostPosted: Mon Jul 29, 2019 10:17 am
by Spogg
Fascinating issue!

The problem with the first cycle is the incorrect initialisation of Osc2Delta to zero.

I’ve modified the schematic to demonstrate a way towards a solution.

However, since only the very first cycle is messed up, and after that the variable is corrected, does it really matter for an actual synth?

Cheers

Spogg

Re: HardSync FM problem

PostPosted: Mon Jul 29, 2019 9:18 pm
by adamszabo
Thanks Spogg for that solution, I tried this before, however if I move the Phase1 knob the first cycle still gets messed up. I have to manually fix the initalization value for every phase 1 value. However the Phase1 will be a random number which I dont know what it will be, so the init fix knob should do some math to compensate. Unfortunately in a synth this causes problems because the first cycle will sound different from the rest and it will be perceived as a nasty click sound, which is unwanted.

Re: HardSync FM problem

PostPosted: Tue Jul 30, 2019 7:45 am
by Spogg
Yes indeed, you need to derive an initial value every time a new note is played. The knob was just a proof of concept rather than a solution itself. The value needed always fell between 0 and 1. Sorry if that wasn’t clear Adam.

I did try to find a formula to calculate the init value, and I feel certain it’s possible, but the maths was beyond me I’m afraid. It may involve a simultaneous equation or something. As far as I could see there are two variables involved; phase1 and FM level. I bet trigonometry is involved somehow and I reckon someone here is capable of sorting it for you. I would really like to see the answer and, if possible, how it was arrived at. That would be great teamwork!

Having thought more about my comment regarding real-world synth use, I now agree that it would be unacceptable in certain situations. For a bass note at 20Hz, with an instant attack, you could have a click of some sort lasting up to 50mS which would be audible so not good.

Cheers

Spogg

Re: HardSync FM problem

PostPosted: Sat Aug 03, 2019 1:27 pm
by tulamide
The current point I'm at: To calculate the correct phase shift (Spogg's manual value), we need the integral of the modulator (not the modulated signal).

I never had much to do with Analysis, where Integral comes from. But it seems it is the area below the signal between two points a and b. An Integral below the signal along the x-axis will always be negative, but that doesn't matter, since phase is a circular value (and therefore phase shift as well).

0.9 and -0.1 express the same position (0 to 1 normalized)

However, the very special formulas are like a foreign language to me, that I never heard before. Given that a and b are the same spot (the momentary sample), it should be something along the lines of carrier - modulator and then some sin or cos calculation to get the circular phase shift.

I post this status update just in case, somebody reads this and remembers the real way to calculate it based on some mentioned keywords.

Re: HardSync FM problem

PostPosted: Sat Aug 03, 2019 3:49 pm
by adamszabo
Thanks Tom, for the detailed explanation. You have gotten further than me, this integration is beyond my skills at the moment.

Re: HardSync FM problem

PostPosted: Sat Aug 03, 2019 5:36 pm
by martinvicanek
In order to determine the initial phase, you could work your way back from the first sync point to the starting point. Not sure if that is possible in poly though.

Re: HardSync FM problem

PostPosted: Sat Aug 03, 2019 5:45 pm
by adamszabo
Hmm interesting, I think that might work, however I not sure I follow. What exactly do you mean "from the first sync point to the starting point."?

Re: HardSync FM problem

PostPosted: Sat Aug 03, 2019 6:45 pm
by martinvicanek
Ignore my last post.
What you can do is simulate one full cycle. Then you know at each instant the amplitudes and phases, and you can take those values to initiate the real oscillator.