Make phazorFm play only one cycle


#1

Hi!
Unfortunately I don't have any programing knowledge, only managed to add some inlets and outlets on objects so far. So maybe this is beyond my scope, but I figured I could try.

After reading this thread I noticed that FM (PM) of sample playback sounds nicest when I use these objects:

It seems much more subtle and useable than when using the FM inlet of sss/table/samplePlayer for example. I have to tune the phazorFM object to -64 to hear the whole sample though and it loops all the time. I could add a vca and an envolope that gets shorter when pitch gets higher, but it would be difficult and I'd still have to add phase reset somehow.

I think better would be to make it only play one cycle when triggered - how would I go about this? Maybe @SirSickSik can help?

K-rate code:

uint32_t freq;
MTOFEXTENDED(param_pitch + inlet_pitch,freq);

This thread suggests that this has something to with pitch correlated phase increments (whatever that is).

S-rate code:

int32_t FM=___SMMUL(inlet _freq<<3,freq<<4);
FM=___SMMUL(FM<<3,inlet _FMW<<2);
Phase += freq + FM;
outlet_phasor = Phase>>5;

[I had to add a blanks between "inlet" and "_" as it wouldn't show correctly otherwise]

So as far as I understand (and this thread explained a bit) it does the ___SMMUL [or x*y/(2^32)] thing twice with bit-shifted values to get the FM going and attenuate it with the FMW inlet and then adds the FM value to "freq". Does "freq" rise linearly because of the k-rate code? Can I just set Phase = 0 with "if" on a rising edge of a boolean inlet to reset the phase? And what is the maximum value, so I can make it stop after reaching that?

Thanks for any advice!


#2

I managed to find a phasor object that plays just one cycle here and tried to edit in the code of the phazorFM object. Unfortunately now the FM doesn't work anymore. Here's what I did:

K-rate code:

uint32_t freq;
MTOFEXTENDED(param_pitch + inlet_pitch,freq);
if ((inlet_trig>0) && !triggered) {
triggered = 1;
first = 1;
} else if (!(inlet_trig>0)) {
triggered = 0;
}

S-rate code:

int32_t FM=___SMMUL(inlet _freq<<3,freq<<4);
FM=___SMMUL(FM<<3,inlet _FMW<<2);
if (first > 0) {
phase += freq + FM;
first = 0;
} else if (phase + freq < freq) { // almost over
phase = 0;
} else if (phase == 0) { // over
//phase = 0; redundant
} else { // normal
phase += freq + FM;
//r = 0; redundant
} outlet_phasor = phase>>5;

I guess adding the FM value messes with the way of detecting the end of the cycle, but I have no idea how to solve that.


#3

I managed to get achieve what I wanted by merging @jfcharles' one peroid phasor object and @SirSickSik's phazorFm object into one and telling it to set the phase of the FM'd phasor to zero when the other ones is at zero as well. I still don't get most of what these objects are doing, but it seems to work. Might be interesting if you're looking for FM on one shot samples, I use it together with "table/read interp". Here's the object:
phazorFM1shot.axo (1.6 KB)

This is what it puts out. It looks a bit different every time triggered and I get these spikes (which are put out by the original phazorFM object as well) - probably these are actually negative values, I wonder if I could flip them.