Presets not updating modmatrix

Hi!

I am using the modmatrix opcode to make a plugin to control other vsts.

For some reason, the table doesnt update properly when I load presets.
Both using Reaper presets and the cabbage preset system dont update the table. One value it can handle, but somehow more just doesnt work?
Any ideas?
I’ve been trying different things all day yesterday with no luck.

Here is the full csd file:

Here is the snippet that likely is causing the problem:

  1. instr ModMatrix

  2. ``

  3. prints "ModMatrix initialised"

  4. ``

  5. kSpeed chnget "Speed"

  6. ; printks2 "kSpeed %f\n", kSpeed

  7. #include "output.inc"

  8. OSCsend kwhen, "127.0.0.1", 999, "SpeedOut", "f", kSpeed

  9. ``

  10. cabbageSetValue "VolumeOut", kVolumeOut

  11. ``

  12. if kSpeed > 0 then

  13. OSCsend kwhen, "127.0.0.1", 999, "VolumeOut", "f", kVolumeOut

  14. else

  15. OSCsend kwhen, "127.0.0.1", 999, "VolumeOut", "f", 0

  16. endif

  17. ``

  18. ;velocity of input

  19. ;check the velocity of the input of the featexmod

  20. ;if it is bigger than 0, sound is on (tho as a slider????)

  21. ``

  22. SCoeffs[] cabbageGetWidgetChannels "_type(\"coeff\")"

  23. ``

  24. kIndex init 0

  25. ``

  26. kIndex, kTrig cabbageChanged SCoeffs

  27. ``

  28. SUpdatedChannel, kTrig cabbageChanged SCoeffs

  29. ``

  30. if kTrig == 1 then

  31. kValue cabbageGetValue SUpdatedChannel

  32. tablew kValue, kIndex, giModScale

  33. ftprint giModScale, -1

  34. endif

  35. ; ;for each channel in SCoeffs

  36. ; ;kValue cabbageGetValue SChannel

  37. ; ;tablew kValue, kIndex, giModScale

  38. ; kCount init 0

  39. ; kUpdateValue init 0

  40. ``

  41. kCount init 0

  42. ``

  43. while kCount < lenarray(SCoeffs) do

  44. prints SCoeffs[kCount]

  45. kUpdateValue cabbageGetValue SCoeffs[kCount]

  46. printk2 kUpdateValue

  47. tablew kUpdateValue, kIndex, giModScale

  48. printk2 kCount

  49. kCount += 1

  50. od

  51. ``

  52. ``

  53. cabbageSet kTrig, "label1", sprintfk("text(\"Last updated widget: %s - Index:%d\")", SUpdatedChannel, kIndex)

  54. ftprint giModScale

  55. endin

Sorry, i’ve never used that opcode, and can’t follow the code you posted as I’m not really sure what you’re trying to do. Can you produce a simple, extremely minimal csd file that illustates the problem?

haha, my bad, should have been a bit more clear. Symptom of staring at this code for so long.

Here is a simple version of the ModMatrix instrument
ModMatrixCabbageSimple.csd (22.3 KB)

So: when the I update the UI, it writes to the table as expected. When I load a preset, either in cabbage or in Reaper, the UI updates, but the table does not.

Hope that’s a bit clearer <3 :slight_smile:

Can you prepare a minimal example, this is still far too complex. As you know, Cabbage doesn’t save tables, but the fact that the UI is updating correctly means something is failing to trigger the table to write. The cabbage get value opcodes have an option trigger on i-pass parameter:

kValue [, kTrig] **cabbageGetValue** SChannel[, iTriggerOnPerfPass]
SValue [, kTrig] **cabbageGetValue** SChannel[, iTriggerOnPerfPass]

Can you try enabling that and seeing if that makes a difference?

kValue cabbageGetValue SCoeffs[kIndex], 1

Is that what you mean? When I write the code like that I get an error saying;

error: Unable to find opcode entry for ‘cabbageGetValue’ with matching argument types:

Found: k cabbageGetValue Sc
Line: 373

I also just now tried

kIndex, kTrig cabbageChanged SCoeffs, 0, 3

but then the table doesnt update when I update the UI.

What version of Cabbage are you using? Have you download the latest build from Azure DevOps?

the latest from the website, should I get the latest from azure devops? I’ve never downloaded from there before. Am on Windows

Yes please, you can grab them from here:

There are 3 dots on the right when you hover over the Installers button, you can grab the installers there. Hopefully this will make a difference :+1:

1 Like

I think maybe I understand the problem?

With the code like this, when I load a preset, kIndex goes from 0 to 70. When I use printk2 it never changes. So somehow the index doesn’t update properly and thus it doesn’t write every nslider into giModScale table.
Could that make sense, based on how the opcode works?

I’ll try and actually get a full .csd file that’s clear later:)

   gSCoeffs[] cabbageGetWidgetChannels "_type(\"coeff\")"

    kIndex init 0

    kIndex, kTrig cabbageChanged gSCoeffs, 0, 3

    printk 0, kIndex

   

    if kTrig == 1 then

        kValue cabbageGetValue gSCoeffs[kIndex]

        tablew kValue, kIndex, giModScale

        ftprint giModScale, -1, 0, inum_mod * inum_param

    endif

i 5 time 7.26667: 0.00000
PresetName: C:\Users\mayaf\Documents\Projects\NTNU\Thesis\Project\code\ModMatrix\Presets\B.psts i 5 time 7.26933: 70.00000
ftable 107:
0: 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
10: 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
20: 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
30: 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
40: 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
50: 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
60: 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
70: -1.0000 0.0000
i 5 time 7.27200: 70.00000

You could be right, this all sounds frighteningly familiar! Would be great if you could produce an extremely simple example so I can debug it more easily. :+1:

I think I have it as simple as possible now without breaking it
ModMatrixCabbageSimple.csd (8.0 KB)

I have hacked a fix lol
I added a button that will trigger a loop that cycles through the entire list of nsliders, and writes to the function table. I have to manually press that after loading a preset lol

kPresetCount init 1

    kWritePresets chnget "WritePresets"

    kChanged changed kWritePresets

    if kChanged == 1 then; once per second table values manipulation:

        kPresetCount = 0

        loop:

            kValue cabbageGetValue gSCoeffs[kPresetCount]

            tablew kValue, kPresetCount, giModScale

            printk2 kPresetCount

            loop_lt   kPresetCount, 1, lenarray(gSCoeffs), loop; loop construction

            kPresetCount = kPresetCount + 1; increase counter  

    endif

           

    kIndex init 0

    kIndex, kTrig cabbageChanged gSCoeffs, 0, 3

    ; printk 0, kIndex, 4, 1

   

    if kTrig == 1 then

        kChangedSliderValue cabbageGetValue gSCoeffs[kIndex]

        tablew kChangedSliderValue, kIndex, giModScale

        ftprint giModScale, -1, 0, inum_mod * inum_param

    endif

It’s not ideal to have to manually trigger the button. You never confirmed to be me what version you’re using?

p.s. the reason I ask is becuase this works as expected here with the latest build, although I’m testing on macOS.

I have updated now to the latest version from dev.azure. I am on windows 11. I do have linux mint installed. I can try there too. Maybe it’s windows being silly

I hope it’s not because I’m about to leave for Christmas holidays and won’t have access to a Windows PC until early in the new year :confounded: