Getting Guitarix Ampsim to work

All your LV2 and LADSPA goodness and more.

Moderators: MattKingUSA, khz

zioaxiom
Established Member
Posts: 8
Joined: Fri Sep 22, 2017 9:34 pm

Getting Guitarix Ampsim to work

Post by zioaxiom »

Hi guys,
I'm trying to get ampsim/DK working, but despite I have downloaded tons of dependencies when I try to run "python circ.py" I get nothing.

I tried with a freshly installed Ubuntu 16.04 LTS after an apt-get update + upgrade.

Is there any information about how to get it up and running?

Thanks!
User avatar
sysrqer
Established Member
Posts: 2595
Joined: Thu Nov 14, 2013 11:47 pm
Has thanked: 377 times
Been thanked: 170 times
Contact:

Re: Getting Guitarix Ampsim to work

Post by sysrqer »

What are you trying to do, build it from source?
zioaxiom
Established Member
Posts: 8
Joined: Fri Sep 22, 2017 9:34 pm

Re: Getting Guitarix Ampsim to work

Post by zioaxiom »

no, I just need to run the python code in order to translate the schematics in code.

Thanks
tramp
Established Member
Posts: 2439
Joined: Mon Jul 01, 2013 8:13 am
Has thanked: 11 times
Been thanked: 557 times

Re: Getting Guitarix Ampsim to work

Post by tramp »

README wrote:Warning: experimental/unfinished code, missing documentation...
Try "python simu.py" instead "python circ.py", this function is moved over.
On the road again.
zioaxiom
Established Member
Posts: 8
Joined: Fri Sep 22, 2017 9:34 pm

Re: Getting Guitarix Ampsim to work

Post by zioaxiom »

Thanks tramp, this one worked but just for a couple of examples.
I understand that this is experimental code, but it's strange that almost all examples are not working. I usually get these errors:

Code: Select all

dk_simulator.py:564: VisibleDeprecationWarning: converting an array with ndim > 0 to an index will result in an error in the future
  V[L[i]] -= 1
Traceback (most recent call last):
  File "simu.py", line 1420, in <module>
    main()
  File "simu.py", line 1416, in main
    plot_output(g, tests, args)
  File "simu.py", line 1219, in plot_output
    plot_one(g[t](), args, t)
  File "simu.py", line 1187, in plot_one
    c_debug_load=args.c_debug_load, linearize=args.linearize, c_real=("float" if args.c_float else "double"))
  File "/home/lcapozzi/Desktop/guitarix-0.35.6/tools/ampsim/DK/dk_simulator.py", line 1869, in get_executor
    return BuildCModule(name, sim, solver, c_tempdir, c_verbose, c_real, extra_sources, linearize).get_executor()[1]
  File "/home/lcapozzi/Desktop/guitarix-0.35.6/tools/ampsim/DK/dk_simulator.py", line 1351, in get_executor
    return self.compile_c_func().wrap_code()
  File "/home/lcapozzi/Desktop/guitarix-0.35.6/tools/ampsim/DK/dk_simulator.py", line 178, in wrap_code
    self._process_files(None)
  File "/home/lcapozzi/Desktop/guitarix-0.35.6/tools/ampsim/DK/dk_simulator.py", line 149, in _process_files
    "Error while executing command: %s" % " ".join(command))
dk_simulator.CodeWrapError: Error while executing command: ./build_script_0
tramp
Established Member
Posts: 2439
Joined: Mon Jul 01, 2013 8:13 am
Has thanked: 11 times
Been thanked: 557 times

Re: Getting Guitarix Ampsim to work

Post by tramp »

zioaxiom wrote:I tried with a freshly installed Ubuntu 16.04 LTS after an apt-get update + upgrade
You may try it on a debian/jessie system, that's what I use for the Dk simulator, and where all examples work out.
I've no idea what goes wrong on ubuntu 16.04, but it's properly related to some library version differences.
On the road again.
zioaxiom
Established Member
Posts: 8
Joined: Fri Sep 22, 2017 9:34 pm

Re: Getting Guitarix Ampsim to work

Post by zioaxiom »

Thanks tramp. What debian version do you suggest?
tramp
Established Member
Posts: 2439
Joined: Mon Jul 01, 2013 8:13 am
Has thanked: 11 times
Been thanked: 557 times

Re: Getting Guitarix Ampsim to work

Post by tramp »

debian jessie means debian 8.X
It's now old stable. You may be must search a bit to find a install CD for it. :(
On the road again.
zioaxiom
Established Member
Posts: 8
Joined: Fri Sep 22, 2017 9:34 pm

Re: Getting Guitarix Ampsim to work

Post by zioaxiom »

we are almost there :) Got a debian 8.8 installed, all missing packages installed... the example simulations now seems to work, but if I try to linearize any scheme I get:

Attribute Error: 'LoadedSchema' object has no attribute 'plot'
tramp
Established Member
Posts: 2439
Joined: Mon Jul 01, 2013 8:13 am
Has thanked: 11 times
Been thanked: 557 times

Re: Getting Guitarix Ampsim to work

Post by tramp »

Great you've got it to work so far.
You may check the "build-plug.py" script to start with.
It works like this:

Code: Select all

 python ./build-plug.py -i SCHEMATICFILENAME.sch -m GUITARIXID -n 'PLUGINNAME' -c 'CATEGORY'
were you've to replace the Uppercases with your selection.

As I said, the README is a bit outdated, the example in there isn't best chosen. Read the build-plug.py or the other build- scripts to get your feet wet. :)
On the road again.
zioaxiom
Established Member
Posts: 8
Joined: Fri Sep 22, 2017 9:34 pm

Re: Getting Guitarix Ampsim to work

Post by zioaxiom »

Thanks tramp. In this way it works creating the .so file in the plugin directory. I would also like to be able to get the .dsp faust file and the c++ file out of the sch. I'm looking through the various .py files but I can't find a suitable one.
tramp
Established Member
Posts: 2439
Joined: Mon Jul 01, 2013 8:13 am
Has thanked: 11 times
Been thanked: 557 times

Re: Getting Guitarix Ampsim to work

Post by tramp »

Check the /tmp folder, there you'll find the faust dsp file. Copy it to DK/buildlv2 and run the make_lv2_bundle.sh script. This generate the LV2 C++ source from the dsp file.
usage is:

Code: Select all

./make_lv2_bundle.sh -p ./ FAUSTFILENAME.dsp -n LV2PLUGINNAME
On the road again.
zioaxiom
Established Member
Posts: 8
Joined: Fri Sep 22, 2017 9:34 pm

Re: Getting Guitarix Ampsim to work

Post by zioaxiom »

Thank you very much, tramp. This works like a charm. I tried with one of my schematics and I get the code, but I can't see the non linear tables for the triode, as example, anywhere in the generated code. I've seen some MOD plugins that looks generated via ampsim/DK and I noticed that the tables and nonlin functions are included in the auto-generated code. Please, can you guide me through this?

Thanks!
tramp
Established Member
Posts: 2439
Joined: Mon Jul 01, 2013 8:13 am
Has thanked: 11 times
Been thanked: 557 times

Re: Getting Guitarix Ampsim to work

Post by tramp »

Well, this way you'll only get the linear part of the circuit, as Infinity Impulse Response Filter.
The only plug which is fully generated with DK is the JCM800pre, and this needs a couple of scripting to make it work, and a couple of research to optimize the code to make it really "real-time fit" with a acceptable CPU usage. You'll find the build script in the DK/scripts folder to get a impression what it means. It takes a full development time from more then a year.

However, all other plugs in the MOD which been generated by the ampsim using a simpler approve to implement the non-linear parts.
I've generated interpolation tables from the models in circ.py, which contain only the non-linear part, those I add later per hand to the generated C++ faust code.


For best results I split the circuit into smaller pieces, preferable to get the entry point were the non-linearity appears. Then I define a so called foreign function to implement the non-linearity.
I copy the IIR filter definitions into one file, renaming the "process" to "p1" "p2" etc.
define my foreign function:
clip = ffunction(float nonlin(float), "clipping.h", "");
and do the new process call
process = p1 : p2 : clip : p3 ;

from there you'll have different way's to apply the function. You could put it into "clipping.h", then the DSP class will call it from there, or, you add it to the generated C++ code.
That's what I do, and maybe that's why it looks like fully generated.

I guess that's what you've seen in some MOD plugs from me.
This is the interpolation function to read the values from the table:

Code: Select all

double always_inline Dsp::nonlin(double x) {
    double f = fabs(x);
    f = (f/(3.0+f) - nolintable.low) * nolintable.istep;
    int i = static_cast<int>(f);
    if (i < 0) {
        f = nolintable.data[0];
    } else if (i >= nolintable.size-1) {
        f = nolintable.data[nolintable.size-1];
    } else {
	f -= i;
	f = nolintable.data[i]*(1-f) + nolintable.data[i+1]*f;
    }
    return copysign(f, x);
}
and the tables been always on top of the file.
On the road again.
zioaxiom
Established Member
Posts: 8
Joined: Fri Sep 22, 2017 9:34 pm

Re: Getting Guitarix Ampsim to work

Post by zioaxiom »

Thanks tramp! That's quite useful. Let's say I sketch a circuit with gEDA. I have a simple triode preamp with a bunch of resistors and capacitors and my output is the triode out. I can refer to "input12ax7.sch" as example.

If I perform sch to c++ process, I won't be able to find the entry point of the triode in there, even if I know the signal flow:

input > gain/drive (input * drive) > triode (non linear stage) > output
Post Reply