Converting circuit models to LV2 plugins

there are many techniques indeed, some are cited as references, but require you to perform circuit analysis to some extent. The often cited reference is WDF, used in white box modeling, was known way long before ML based stuff arrived. I’ve also studied the tool used in Guitarix, which is simply great. Guitarix works with nodal analysis in a similar way as LiveSpice. But simply solving nodal equations as they are won’t make it run in RT, so you have to cut angles. Guitarix does this by introducing a technique where you will extract a table of points (a LUT) to be used in place of nonlinearities. LiveSpice is more advanced and simplifies the original equations with less CPU intensive math functions. Of course the more you know about the circuit and the more you are aware to where those approximations will be applied, the best sounding emulation you will obtain. Still, the problem of all those approaches is finding a proper way to measure how close you are to the original circuit, not necessarily using ears. And still, figure out how it will respond to real audio data. To me loss functions and Datasets used in ML techniques solved both issues. Also, ML scales from black box to white box modeling. If you are interested and you would like to collaborate just drop me a msg!

2 Likes

If it is helpful, our BigMuff and DS-1 plugins were modelled by @couts, who fully modelled the entire circuits manually, created the code and then spent a bunch of time making it run in real time.

The plugins are OSS, so you can check how he did it.

5 Likes

Really interesting topic!

I’ve looked at the code for DS1 and it’s not the same as bigmuff’s, can I ask the author what method he used to model ds1? (Sorry I can’t find the @author button)

@QuanHu, not sure if I understood your issue messaging the author of the plugins.
As Gianfranco said, it was @couts. I’m not sure how active he is nowadays here in the MOD forum, but if you hover over a tag of him (like I just did now), you should get a pop up window with a button that allows you to message him directly. No?

@QuanHu I’ll answer your question about modeling a diode clipper here.

You can either use:

  1. Ordinary Differential Equations. I’ve sent you this link to David Yeh’s dissertation before I think. This is the most accurate. But it most likely uses more processing power.
  2. A lookup table. Depending on how much gain you’re circuit has you need a larger table.
  3. A hyperbolic tangent function or hyperbolic tangent approximation. David Yeh’s dissertation also explains this.

I chose for a hyperbolic tangent approximation and tried to align the shape and frequency response with the lookup table implementation as much as possible. The output gain is also based on the lookup table. I halved that gain because it sounded better. I don’t know exactly how to convert amplitude to voltage and vice versa. Levels depend highly on how much pre-amp gain you apply in the first place.

Thank you! :grinning:Dave

@brummer
Hi,brummer

I know from reading the forums that you have made a very interesting tool called dk-builder, but I have installed it many times on my PC without success.

I’m wondering if it’s not installed correctly on my computer system. If I’m going to buy a raspberry pi, will it be able to install dk-bulider?

Sorry I’m not familiar with linux, but I’ve touched sharc writing guitar effects, as well as making my own guitar pedals with some analog circuits. Now, I want to make more guitar pedals for mod dwarf, and it would be very convenient if I could use dk-bulider. :pleading_face:

Posting a question in
a forum thread would also allow more people with doubts like mine to get by with answers. Hopefully my foolish questions won’t take away from public resources.

Can I try to finish installing guitarix once as a way to install the dependencies needed for dk-bulider? I wonder if that would increase the success of my installation.

dkbuilder is very old by now, the used python version is outdated.
The only way to use it by now is to set it up in a docker container.
You’ll find a dockerfile in the DK folder which could setup a container based on debian10.

1 Like

Hi @brummer ,
I set up the environment using Docker, but I’m encountering these errors. Could you please advise how to resolve this? Initially, FAUST was version 2.14.4 during installation. After checking the link provided above, I downgraded FAUST to 0.9.90, but I’m still unable to get it running.

mmm.
Works here as expected.

S = ((R(12), 'u11', 'u2',),
     (R(11), GND, 'u10',),
     (R('L'), 'u12', 'V6',),
     (L(1), 'u8', 'u12',),
     (R(3), 'u3', '+9V',),
     (V('cc'), '+9V',),
     (P(1), 'u10', 'u11', 'u9',),
     (C(1), 'V2', 'V1',),
     (R(10), GND, 'u6',),
     (R(5), GND, 'V6',),
     (R(7), 'u8', 'V6',),
     (R(6), 'V6', 'u3',),
     (R(8), 'u5', 'u3',),
     (R(1), 'V1', 'u7',),
     (C(4), 'u5', 'u9',),
     (C(3), 'u6', 'u8',),
     (R(4), GND, 'u4',),
     (R(2), 'u8', 'V2',),
     (C(2), 'V6', GND,),
     (T(2), 'u1', 'u5', 'u6',),
     (T(1), 'u3', 'V2', 'u4',),
     (C(6), 'u2', 'u3',),
     (R(9), 'u1', '+9V',),
     (OUT, 'u2',),
     (IN, 'u7',),
     )
V = {C(1): 0.01e-6,
     C(2): 4.7e-6,
     C(3): 0.01e-6,
     C(4): 0.22e-6,
     C(6): 0.22e-6,
     L(1): 0.5,
     P(1): dict(value=80.e3, var='Wah', a=3),
     R('L'): 60.,
     R(1): 68.e3,
     R(10): 10.e3,
     R(11): 10.e3,
     R(12): 10.e3,
     R(2): 1.5e3,
     R(3): 22.e3,
     R(4): 510.,
     R(5): 100.e3,
     R(6): 470.e3,
     R(7): 33.e3,
     R(8): 470.e3,
     R(9): 1.e3,
     T(1): dict(Vt=26e-3, Is=20.3e-15, Bf=1430, Br=4),
     T(2): dict(Vt=26e-3, Is=20.3e-15, Bf=1430, Br=4),
     V('cc'): 9.,
     } 

build lv2_plugin from: ['VoxWahV847.sch']
VoxWahV847
Please select a Plugin type from the list
 1) DelayPlugin	      14) BandpassPlugin    27) FlangerPlugin
 2) ReverbPlugin      15) CombPlugin	    28) PhaserPlugin
 3) DistortionPlugin  16) EQPlugin	    29) ReverbPlugin
 4) WaveshaperPlugin  17) MultiEQPlugin	    30) SimulatorPlugin
 5) DynamicsPlugin    18) ParaEQPlugin	    31) ReverbPlugin
 6) AmplifierPlugin   19) HighpassPlugin    32) SpatialPlugin
 7) CompressorPlugin  20) LowpassPlugin	    33) SpectralPlugin
 8) EnvelopePlugin    21) GeneratorPlugin   34) PitchPlugin
 9) ExpanderPlugin    22) ConstantPlugin    35) UtilityPlugin
10) GatePlugin	      23) InstrumentPlugin  36) AnalyserPlugin
11) LimiterPlugin     24) OscillatorPlugin  37) ConverterPlugin
12) FilterPlugin      25) ModulatorPlugin   38) FunctionPlugin
13) AllpassPlugin     26) ChorusPlugin	    39) MixerPlugin

I guess you’ve downloaded the latest source from guitarix github repository. Then point your terminal to the /trunk/tools/ampsim/DK/docker/ folder and run
‘./docker-dkbuilder’ /were/ever/you’ve/guitarix/downloaded/to/guitarix-git/

The important step is to point the docker script to the guitarix-git source code, otherwise it wouldn’t find them after the docker image is ready to use.

personality failure 1

This looks as if something goes wrong during build the docker image.
You could just run the ./docker-dkbuilder /with/path/to/guitarix-git/ again.
You could run that anytime you want to use the dkbuilder.

EDIT:/
I did some tests, and yes, it indicate that you miss the personality.json file which is needed for security settings.
Ensure you use the docker-dkbuilder script to build the image, and not try to build it directly from the Dockerfile.
docker-dkbuilder download the personality.json file and set it as --security-opt for guitarix-dkbuilder.
It should also be used to start the image, as it set all needed environment variables so that dkbuilder works.

Hi, @brummer

Thank you very much for your answer.

I describe my entire process and show to see where there are errors in the process. I have other errors in the operation now.
企业微信截图_17403165532157
First, I pulled the guitarix directory from github, and I can see that the directory already contains the guitarix folder.
Then I entered the following command as if the docker container had been opened by this step.



At this time the example command has been displayed, is this successful?
But after I enter the content of the example command, the following error appears

This is not the original guitarix source code from the github repository.
Please use

git clone https://github.com/brummer10/guitarix.git
cd guitarix
git submodule update --init --recursive

to get the original actual source code.

analog.py line 772 should looks like this:
print >>f, "\nc = %s;" % c
as it is written for python2
what you have there looks to my like the ‘try to python3 port’ by Dominique Michel, this one never was finished and never works.

Thank you very much for your answer.
I seem to have gotten the program up and running successfully, I don’t know if it’s running correctly or not

1 Like

Yes, you’ve build GxVoxWah from the circuit (check the guitarix-git/trunk/tools/ampsim/DK/gschem-schematics folder for the schematic) and installed it on your system. Looks like you running a virtual box, so it’s installed inside the virtual box. The source code for the plug you find in /guitarix-git/trunk/tools/ampsim/DK/buildlv2/gx_voxwahv847.lv2

now you could create your own circuits and try to build a LV2 plug from them. As pointed out earlier, that may or may not work, circuit solving is highly experimental, and fail often for small issues resulting from small differences between ideal and real values used for resolving.

Note, after you’ve run dkbuilder once, you could run ./build-plug.py directly instead run dkbuilder && ./build-plug.py in that session.
When ever you restart a session you must run dkbuilder once to set the builder up.

I’ve just updated the docker-dkbuilder to add X support to the docker. That means with latest changes you could now use gschem to edit circuits directly from the docker image and display the frequency plots when create a non-linear circuit…
It also ensure now that the resulting build files could be edited as normal user afterwards.
So just do a git pull on the guitarix-git repository and run docker-dkbuilder to get the changes.

2 Likes

Have to say.This tool is so much fun to use!

Now,I found some lv2 plugins and their corresponding dsp files in the guitarix files, like bossds1 and mxrdist, but I didn’t find the corresponding schematic files, and I can’t see the word “auto-generated” at the beginning of the FAUST file code for mxrdist. Are these two codes edited manually on FAUST? Or are they based on different parts of the circuit, such as pre-eq, post-eq, non-linear parts, and finally put together?

1 Like

They are older. Once I’ve generated filters (IIR) from parts of the circuit and stick them together afterwards by hand edit. Also the non-linear parts I’ve generated by extra scripts and wrote the solvers by hand. Later I wrote build-plug.py and circ_table_gen.py to automate those steps.
Now that all could be done by a single command.

I haven’t push all circuit’s I’ve worked on to the repository, that are way to much. I just put enough there to get a inspiration for what could be done.
Keep in mind to split circuits in small pieces to get best match, build-plug.py could stick them together into one faust source file (LV2 plugin) afterwards.

3 Likes

Is it possible to share some sch files by uploading to github or email? At the moment I don’t really understand the way some devices are named when drawing sch, which makes it impossible to convert. Is it possible to send me some pedal sch files that I can splice and modify into other pedal circuit diagrams based on the original.