Reinit opcode with i-rate params with k-rate?

Hey all,
Quick question and likely its already been answered somewhere but can’t directly find an answer so I figured I’d ask. So say I was using an opcode like lfsr (lfsr) and I wanted to be able to change the i-rate parameters at runtime. Would the best way to do this be with a reinit pass with that particular opcode? I imagine how this works is that that opcode gets initialized at i-time and then each following pass the output is merely getting the result of the next iteration.

I guess the question is after the init pass I assume there is a portion of the opcode that operates at k-rate which returns the output. If I were to call reinit and pass in new i-rate variables I should expect the iterator or however it is tracking its current state to also reinitialize, so realtime modulation of those i-rate parameters would likely not operate similarly to say the Ornament & Crime module it is based off or Music Thing Modular’s Turing Machine as modulating these i-rate parameters in Csounds would effectively reset the iterators state to the beginning correct?

I hope I have been clear enough, if there’s any confusion feel free to ask for clarification. As always, thanks in advance for any responses!

Cheers

As far as I know this is the only way to do this. Well, you could also just restart the instrument that this opcode is part of, but that would of course result in all the other opcodes being reset too.

As for the rest of your question I assume you are correct but I don’t know anything about this algorithm. My advice would be to try it out and see how it goes. Alternatively, you could reach out to @DaveSeidel who wrote it. He’ll be able to tell you what’s what :+1:

Hi @DespairBear . Yes, I think your understanding is correct in general, and certainly correct in the case of the lfsr opcode. The init pass establishes the initial state of the of the opcode in the context of the instrument instance that contains it, and the k pass modifies that state. In the case of lfsr, the state is just two 8-bit integers (length and probability) and a 32-bit integer (the shift register itself). You’re correct that those things can’t be changed at i-time, so you would need to use reinit. It would be possible to make a version of lfsr that exposes k-rate variables that could be used to change these properties at k-time, but it’s not written that way right now. Something I could consider for a future version of Csound, perhaps. Thanks for your question! (and thanks @rory for tagging me so I would see it)

Thanks for the response @DaveSeidel, very much appreciated

1 Like