gleb812 / pch2csd

The Clavia Nord Modular G2 Patch Convertor Project
MIT License
139 stars 11 forks source link

List index out of range in csdgen.py #27

Closed muranyia closed 4 months ago

muranyia commented 2 years ago
list index out of range

-----------
  File "/home/muranyia/.local/lib/python3.8/site-packages/pch2csd/app.py", line 164, in main
    convert_pch2(args.arg)
  File "/home/muranyia/.local/lib/python3.8/site-packages/pch2csd/app.py", line 98, in convert_pch2
    udos = zak.connect_patch(p)
  File "/home/muranyia/.local/lib/python3.8/site-packages/pch2csd/csdgen.py", line 115, in connect_patch
    udos = deepcopy({m.id: Udo(p, m) for m in p.modules})
  File "/home/muranyia/.local/lib/python3.8/site-packages/pch2csd/csdgen.py", line 115, in <dictcomp>
    udos = deepcopy({m.id: Udo(p, m) for m in p.modules})
  File "/home/muranyia/.local/lib/python3.8/site-packages/pch2csd/csdgen.py", line 30, in __init__
    self.udo_variant = self._choose_udo_variant(len(ins))
  File "/home/muranyia/.local/lib/python3.8/site-packages/pch2csd/csdgen.py", line 61, in _choose_udo_variant
    tpl_v1_ins = self.tpl.ins[1].types

This happens with every patch that has no invalid UDOs.

ghost commented 2 years ago

Hey @muranyia, could you please attach a patch? I haven’t touched this project for a while, and having a problematic patch at hand will help me greatly to dive in.

I’ll try to take a look at it either next week or a week after.

muranyia commented 2 years ago

Hi Eugene, I'm just getting familiar with the project. By "patch" do you mean a fix? I'm very happy to help you in any way but I'm afraid I cannot code a fix as I don't understand the source code.

ghost commented 2 years ago

@muranyia, no problem, I was referring to the quote from your original post:

This happens with every patch that has no invalid UDOs.

I guess you meant a Nord Modular patch?

muranyia commented 2 years ago

Ah yes, sorry for misunderstanding.

Basically, as I mentioned, the issue manifests with all the stock patches from NORD.

Attaching one of them: BuzzBass NL2.pch2.zip

ghost commented 2 years ago

Hey folks,

The issue seems to be related to the EnvADSR module (20.txt). The text file contains two opcodes, but their annotations are inconsistent: the first opcode only has @ins and @outs annotations, and the second one only has @args. The code bellow wants to get an @ins annotation of the second opcode variant but it doesn't exist:

In csdgen.py#L61:

tpl_v1_ins = self.tpl.ins[1].types

@gleb812, is this a polymorphic module?

ghost commented 2 years ago

I've just added validation for this type of error. Now, trying to convert the .pch2 file from above will show the following error:

C:\Python310\python.exe -m pch2csd.app c:/Users/login/Desktop/test.pch2 --debug
error: error (20.txt): the UDO 'EnvADSR' is invalid
please, run 'pch2csd -c 20' for details

And calling the commands for details will show:

C:\Python310\python.exe -m pch2csd.app --check-udo 20
checking module type '20' (20.txt)
module name: EnvADSR
error (20.txt): in polymorphic modules, all opcodes must have 'ins' and/or 'outs' annotation
muranyia commented 2 years ago

Thank you for tackling this..

Unfortunately, I'm left with zero of the stock patches converted. Each fails with some kind of (decently handled) error. Any advice...?

ghost commented 2 years ago

Are you a Csound user? If so, maybe you could help fixing the EnvADSR implementation in 20.txt file. Otherwise, need to wait till me or Gleb addresses the issue with the module mentioned, as last night I only fixed the converter code.

gleb812 commented 2 years ago

Guys, I will fix this issues soon. I guess in a couple days or something. Stay cool

muranyia commented 2 years ago

Thanks again and in advance too!

As I have barely any CS knowledge, what I can contribute is the frequency distribution of problem UDOs among all the stock NORD patches. This might help you with setting priorities.

       Name (num) Freq
----------------------
     EnvADSR (20)  134
   Operator (180)   63
     FltNord (51)   30
   OscString (13)   17
    OscShpA (163)   16
      EnvADR (84)   15
       Name (126)   13
    FltMulti (49)    6
    FltVoice (45)    6
      Glide (158)    6
       LfoB (190)    6
     LfoShpA (25)    5
    OscPerc (196)    5
   Overdrive (62)    5
    MetNoise (29)    4
    stChorus (94)    4
      Device (30)    3
      Mux81X (60)    3
   EnvADDSR (119)    2
   KeyQuant (152)    2
     ModAHD (169)    2
   PartQuant (22)    2
 PitchTrack (198)    2
      Reverb (12)    2
      shpExp (34)    2
     status (197)    2
    Vocoder (108)    2
   Compress (150)    1
      EnvAHD (46)    1
    EnvMulti (52)    1
   FltPhase (102)    1
     ModADSR (23)    1
          sH (53)    1
gleb812 commented 2 years ago

Much respect for that. Once me back on track for doing models I will use your distribution. Great idea btw

gleb812 commented 2 years ago

@muranyia I am finally back on track again. Added few more envelope generators (hope to finish the whole section soon) and of course did fix an EnvADSR module. Please check!

muranyia commented 2 years ago

Yes, EnvADSR works now, thanks! Only a few errors for EnvADR missing (I guess the template will be a simplified EnvADSR?) All in all, none of the stock patches compile yet, Operator being the next barrier.

gleb812 commented 2 years ago

Well, EnvADR a bit different due to Trig/Gate selector and Decay/Release mode, but I guess I will beat it up soon. Would do you mean by stock patches? As far as I remember for my Nord, there were several banks, one of which was completely stuffed with DX models, so in that case it needed Operator/DXRouter, though others did not use FM in that case at least. Meanwhile, I have separate model of FM operator in Csound, I guess I can include it here.

muranyia commented 2 years ago

I mean these Yes, Patch Bank 2 has a few using DXRouter1 while PatchBank4 is full of DX patches. You are right, Operator is used by those only.