Using rrand in classes?

Hello! I’m fiddling with the source code of SimpleMIDIFile from wslib and I want to include an rrand(n1, n2) function in a method I’m creating, but I get an error message when recompiling the class library due to using the rrand function inside the class definition.
Is there any way around this?

Without seeing the code it’s hard to say …
Principally there’s no reason why rrand shouldn’t work in a method.

Hey! The code looks like this.

nudge_durations {|prob, offset_value|{
			if(prob.coin == true, {
				event[1] = event[1] + rrand(-offset_value, offset_value);

it’s a method in a .sc file as opposed to an .scd file if that matters any.

Pretty sure it needs to be offset_value.neg rather than -offset_value. I could be wrong but I’m fairly certain - should always be a binary operator (two operands), not unary.


1 Like

ahaa! That worked, thanks!