I have two oscillators that produce 0 to 1 ramps at a given frequency. I am using a "sample and hold” (sah) function to get variable samples based on their varying frequencies. One oscillator is a trigger while the other is the sampled value. The sah works by outputting the value of the sampled ramp only when the trigger ramp crosses a certain threshold, say 0.5. So If the trigger has frequency 4Hz and the sampled oscillator has frequency 2Hz the sah will output 4 values per second, but the first couple of values is equal to the second couple since the two oscillators align halfway through. So far so good.
My problem is that I am trying to build an algorithm to calculate the period of the pattern given the two oscillators frequencies. In other words: how long will it take the pattern to start repeating? In the previous example it would be half a second. In particular I encounter problems when the two frequency values are not integers.
I worked with least common multiple function multiplying each value by 100 to get rid of the decimals and the dividing the result again by 100. It didn’t work. At this point I am very confused and could use an expert’s input.
Aucun commentaire:
Enregistrer un commentaire