Cabbage Logo
Back to Cabbage Site

UPDATE reinit not working

Hi, I am modifying the Iain McCurdy’s granulefileplayer example by replacing the granule opcode with partikkel. I tried to use the UPDATE to reinite the parameters once the slider value is changed. I am currently changing only the speed and grainsize to test, but the audio file just can be loaded then. I am assuming that something is wrong inside:
if changed:k(gkspeed)==1 then
reinit UPDATE


but it could be other problems. Really appreciate if anyone could find out the problem! (532.5 KB)

What is the purpose of the this reinit? Most of partikel's parameters are k-rate. I can’t see why you would need do any reinits…

Hi rory, I am using a instrument 2 to trigger the play/stop of the audio. I plan to use the reinit once the slider change since in the example this is what is done. But that doesn’t play the audio anymore. What would be the correct way to do it? Thank you.!

But the original example was built around the granule opcode, which is quite different to partikel. If your aim is to simply open a soundfile and have it processed by a partikel code, I think it might be simpler to build it from scratch?

[edit] I just took a look at the source code, but the instrument loading the soundfile doesn’t load. So that’s the first thing that’s wrong. I still think it would be simpler to write your own version from scratch. But if wish to continue with this path, then take a look at why instr 99 is not being triggered :+1:

1 Like

Hi Rory, thank you for the reply. I went back to my plug-in and did some modifications. Now the file plays and it works when changing different files. but the file image is not shown as intended. I am trying to make it work and let the user select a portion of the file for doing granular process. Do you see any problems in the code?

granulatorFilePlayer.csd (9.7 KB)

You’re mixing up the old and new way of using the UI system. The best thing would be to stop using identChannel altogether. And note that they won’t work anyway because you have guiMode("queue"). Here’s an updated version that show the sound file. granulatorFilePlayer.csd (9.7 KB) :+1:

Hi Rory, thank you so much for looking at the csd and help me to fix it! Now the waveform id shown on the screen. My next thought on the project is to let the user toggle the reverse button so the waveform could be reversed. now I have the sample stored using the ftgen opcode and use a phasor opcode acting like a pointer to iterate through the sample. I tried using 1- the phasor but it doesn’t do the reverse. Am I doing it right? Shall I try a circular buffer to store the sample using tablewa?

A negative frequency for the phasor should cause it read backwards. :+1:

Hi Rory, I tried multiply the phasor value by -1, but it doesn’t reverse the sample. I checked the partikkel definition for the asamplepos, and it said: asamplepos1 – start position for reading source waveform 1 (in range 0…1). I guess it convert negative phasor value into positive?

I’m ashamed to say I’ve never used partikel, but a negative frequency with the Csound phasor opcode will cause the output to be reversed.

So probably reversing the waveform would be another way to achieve it? Guess I have to experiment on tablera opcode :thinking:

Yeah, that would also work. And if you update the table then the user would see that things are now backwards. Might be a nice feature. But I’m sure there must be a way to move the read pointer in reverse with partikel.