Linux - How to fix corrupted .vcv patch files

I have been running into an issue with VCV where my .vcv patch files would get corrupted, and just wanted to share the fix I found for them.

Background: I would be using VCV with jack, and suddenly my audio output into my DAW would die, I think this was caused by either an xrun and/or pulseaudio getting started up accidentally and messing with jack. When this happens, a lot of the time whatever patch file I’d be working with would become corrupted, where I’d open it and it wouldn’t respond to any midi input or output any audio.

In log.txt, I’d see something like this:

[73.816 info src/rtaudio.cpp:128 openStream] Starting RtAudio JACK device 0
[74.110 warn src/rtaudio.cpp:53 operator()] RtAudio error 5: RtApiJack: the Jack server is shutting down this client ... stream stopped and closed!

When a patch loads successfully, you usually see something like this, which I wasn’t getting:

Opening RtAudio JACK device 0: system (2 in, 4 out, 96000 sample rate, 256 block size)

Solution: First, I made sure that I had proper realtime priority for audio, I had some of this configured in /etc/security/limits.d/audio.conf but not the exact settings mentioned here: VCV Rack on Linux, Detailed Guide FAQ

So, I made sure that /etc/security/limits.d/audio.conf was set to this, that helped fix a lot of the xruns:

@audio   -  rtprio     99
@audio   -  memlock    unlimited
@audio   -  nice      -19

To prevent pulseaudio from interrupting jack, I made sure to start jack with pasuspender, so pulseaudio will be suspended as long as jack is running: /usr/bin/pasuspender -- /usr/bin/jackd -dalsa -dhw:USB -r96000 -n2 &

Next, I started comparing a working patch with a non-working one. Patches are stored as zstd compressed tar archives, so to insepct one, unpack it with this command:

tar -I zstd -xvf patchfile.vcv

That gives you a modules/ folder and a patch.json file. I diffed a working and non working patch.json, and ended up narrowing it down to this section for the AudioInterface2 plugin:

Here is the broken version:

    {
      "id": 8518972980240757,
      "plugin": "Core",
      "model": "AudioInterface2",
      "version": "2.1.2",
      "params": [
        {
          "value": 0.82409608364105225,
          "id": 0
        }
      ],
      "leftModuleId": 6645574615859100,
      "rightModuleId": 5873298757431870,
      "data": {
        "audio": {
          "driver": 4,
          "sampleRate": 0.0,
          "blockSize": 0,
          "inputOffset": 0,
          "outputOffset": 0
        },
        "dcFilter": true
      },
      "pos": [
        79,
        0
      ]
    },

And here is a working version:

    {
      "id": 8518972980240757,
      "plugin": "Core",
      "model": "AudioInterface2",
      "version": "2.1.2",
      "params": [
        {
          "value": 0.82409608364105225,
          "id": 0
        }
      ],
      "leftModuleId": 6645574615859100,
      "rightModuleId": 5873298757431870,
      "data": {
        "audio": {
          "driver": 4,
          "deviceName": "system",
          "sampleRate": 96000.0,
          "blockSize": 1024,
          "inputOffset": 0,
          "outputOffset": 0
        },
        "dcFilter": true
      },
      "pos": [
        103,
        0
      ]
    },

To fix it, I made sure that sampleRate and blockSize matched my jack settings, and then I added "deviceName": "system", back in.

Then, repack the .vcv file:

tar -cf patchfile.tar modules patch.json
zstd -c patchfile.tar -o patchfile.tar.zstd
mv patchfile.tar.zstd patchfile.vcv

Then reopen the .vcv file in VCV and it should work again!

Hope this helps someone else

7 Likes