Division in S-Rate?


#1

Hello!

Was trying to build a patch I build in Pure Data in Axoloti and I have run into a problem. I am not sure how to do division in S-rate, besides the standard division by the power of 2.

I am trying to divide 2 audio signals with each other, in PD, it can be done with this object:

But as mentioned above, in Axoloti I (think) i can only divide by the power of 2. I tried this, but it didnt work:

outlet_result= __SMMUL(inleta<<1,inlet_b);

I think I am stumbling over this bitshufting stiff.... Any ideas? :slight_smile:


#2

Maybe you can have a look at factory/math/reciprocal and combine it with a multiplication.


#3

Ahh yes reciprocal.

It crossed my mind very shortly, cause I used it for something similar in PD; but then it slipped again, I wasnt sure it would work. Will try that. Thanks :slight_smile:


#4

Hey @SmashedTransistors

I been experimenting a bit with the reciprocal this morning and I am not sure I am using it correctly.

Anyway here is the project I am working on:
A patch I made in PD, which is basically a morph oscillator, that lets you morph between all the regular basic waveforms as saw/sin/tri and also square with a little modification to it and EVERYTHING in between. you can set rise and fall time, which can add a lot of "analog character". Or you can mix a saw and a sine as you like for more "analog character".

I have been looking at my friends old synths like the Arp and this oscillator can create waveforms that are very similar to many of the waveforms found in his synth collection, like the arp, like softened saw waves for example. The pd patch looks like this and everything works as intended:

I tried doing some calculations at k-rate first, but the result is not correct, so I am pretty sure I am not doing it right:


Patch with calculations from the picture:
MORPH OSC RECIPROCAL Calculations.axp (6.2 KB)

And finally here is the main patch with the morph osc:
MORPH OSC PD VERSION 1.3 FUCKED .axp (22.2 KB)

As you can tell from the name, it doesnt work. No sound comes out at all and the Axometer goes crazy jumping up and down to 100%. Yikes! There are a couple of things that could be wrong, the division/reciprocal stuff and a POW function, I am not 100% sure I made correctly.

For the fun of it I then tried to connect the phasor directly to the output and wow, some harsh noises coming from it.. And Axometer is going insane. Try mess with the breakpoint dial and the pitch... Instant, harshcore :slight_smile: Even thought the breakpoint it not even connected to the phasor in anyway at all and should not be influencing the sound at all. Try it :wink: :
MORPH OSC PD VERSION 1.3 FUCKED FUN.axp (22.2 KB)

One last thing I am a little bit in doubt about is using "POW" function in Axoloti. See the first PD picture, the POW is used as last step, lifting the left side to the power of the right side........ I tried making a pow function like this:
outlet_out = pow(inlet_1,inlet_2);
(code in samplerate)
....
Which should give you inlet 1 lifted to the power of inlet 2, right? This should be allowed at sample rate, right?

Many questions here. Going to leave it for the afternoon and get back to it tomorrow again maybe with a fresh mind.

Meanwhile, comments/tips are welcome :wink:


#5

I don't really get how your screenshots should work...

For a simple division I'll do something like that:
A / B = A * (1 / B)

Division.axp (1.7 KB)


I'm not familiar with PD, but it looks like some sort of waveshaping, the initial wave being the phasor ?


#6

Cool Ill see if that works, thanks :slight_smile:

Here is a short video of the oscillator in action in Pure Data:

I think it makes some pretty interesting waveforms. Yes all of the waveforms are made from a single phasor and a bunch of audio rate math. In PD the ~ means it is audio objects, so everything is done at samplerate.

It is mostly - + / * POW used, but all in audio rate. The pack & line is parameter smoothing.


#7

pow(x,y) is "evil", if you really need to use a floating point pow function, use powf(x,y)
Division should be used with care, dividing by 0 is undefined, in case of floating point could result in a "NaN" that often would keep recirculating in recursive algorithms (yours is not recursive).

Audio inlets use fractional representations of value, need to convert/scale those to float first if you want to use pow(x,y).


(More) Math help needed!
#8

Hey guys

Thanks for the answers. Tomorrow I have time to give it ago.