dkbuilder: from circuit to LV2 plugin

Programming applications for making music on Linux.

Moderators: khz, MattKingUSA

tramp
Established Member
Posts: 1411
Joined: Mon Jul 01, 2013 8:13 am

dkbuilder: from circuit to LV2 plugin

Postby tramp » Sun Feb 17, 2019 6:56 am

Pre-requests:
geda, geda-gattrib, geda-gnetlist, geda-gschem, geda-gsymcheck, geda-symbols, python-virtualenv, virtualenv, virtualenvwrapper, faust 0.9.90, libeigen3-dev, libcminpack-dev, libsundials-serial-dev, maxima (maxima-share) and guitarix source from git repository

when you've installed all that, set up a virtualenv to work with the dkbuilder. Point your terminal to the folder /trunk/tools/ampsim/DK/ in the guitarix source tree, and run :

Code: Select all

source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
mkvirtualenv -r python_venv guitarix


when done, close your terminal and open your ~/.bashrc with a editor and add the following macro at the end of file:

Code: Select all

dkbuilder() {
  source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
  cd /path/to/guitarix-git/trunk/tools/ampsim/DK/gschem-schematics
  workon guitarix
}


of-course, replace the /path/to with your path.

now you could use the dkbuilder by simply typing "dkbuilder" in your terminal.

the dkbuilder use some additional symbols which are in /guitarix-git/trunk/tools/ampsim/DK/gschem-symbols. To use them you need to edit your ~/.gEDA/gafrc file. (if not exist, create it) and add the following line to it:

Code: Select all

(component-library "/path/to/guitarix-git/trunk/tools/ampsim/DK/gschem-symbols")

of-course, you know what to do with the /path/to part.

workflow:
Now you could create a circuit with gschem, the geda schematic editor. For easy starting you could open /guitarix-git/trunk/tools/ampsim/DK/gschem-schematics/Startset.sch which comes with a couple of predefined elements you could use to stick your circuit together.
Image

Now, let's say you would create a plugin from this schematic:
Image

The best way is to split the schematic, we've a input buffer ( or preamp here), a amp (that'S were the non-linearity happen here) and a output buffer (here a passive tone and volume control). So creating 3 circuit's from the circuit above:
BajaTubeDriverp1.sch
Image
BajaTubeDriver.sch
Image
BajaTubeDriverp3.sch
Image

Result:
To build a guitarix plugin from the circuit's start the dkbuilder, and run the build-plug.py script with the following command:

Code: Select all

build-plug.py -i BajaTubeDriverp1.sch BajaTubeDriver.sch BajaTubeDriverp3.sch --table 2  --build -n BajaTubeDriver


this will create the faust source code, create a non-linear response table (a plot of it will be shown*) for the 2. circuit and concatenate all together into one file, and finally build and install the guitarix plugin, which you'll find in guitarix under the "Extern" category.
Check the build-plug-py file for more build options, eg. you could do a frequency plot of a circuit, etc.
* non-linear response
Image
Now, say you would create a LV2 plugin from it, run:

Code: Select all

python build-plug.py -i BajaTubeDriverp1.sch BajaTubeDriver.sch BajaTubeDriverp3.sch --table 2  --buildlv2 -n BajaTubeDriver


this will build a LV2 bundle with a X11 based interface and install it to your ~/.lv2 directory, so do a rescan in your LV2 host and you could use it.
Image

All that said, please note that the dkbuilder is still experimental, only advanced users (developers) should use it, however, I like to share my workflow here with you, so, if you interested in electronic circuit's, C++ development and open source, you may have fun with this toolkit.

regads
hermann
On the road again.

Basslint
Established Member
Posts: 166
Joined: Sun Jan 27, 2019 2:25 pm
Location: Italy

Re: dkbuilder: from circuit to LV2 plugin

Postby Basslint » Sun Feb 17, 2019 9:57 am

This stuff is amazing, I've been following Guitarix for a while and I think it deserves more attention.

Are you planning to release it as a standalone program some day? I think it might be very useful even outside of Guitarix.
The community of believers was of one heart and mind, and no one claimed that any of his possessions was his own, but they had everything in common. [Acts 4:32]

User avatar
CrocoDuck
Established Member
Posts: 1052
Joined: Sat May 05, 2012 6:12 pm
Contact:

Re: dkbuilder: from circuit to LV2 plugin

Postby CrocoDuck » Sun Feb 17, 2019 10:25 am

MUST.
TRY.

(Yes, I have been saying that for months...)
Check my Linux audio experiments on my SoundCloud.
Browse my AUR packages.
Fancying a swim in the pond?

User avatar
sadko4u
Established Member
Posts: 692
Joined: Mon Sep 28, 2015 9:03 pm

Re: dkbuilder: from circuit to LV2 plugin

Postby sadko4u » Sun Feb 17, 2019 10:34 am

Very nice solution!
It would be a killer feature if this stuff would be implemented as a plugin that dynamically loads schematics.
LSP (Linux Studio Plugins) Developer and Maintainer.

tramp
Established Member
Posts: 1411
Joined: Mon Jul 01, 2013 8:13 am

Re: dkbuilder: from circuit to LV2 plugin

Postby tramp » Mon Feb 18, 2019 6:55 pm

Basslint wrote:Are you planning to release it as a standalone program some day? I think it might be very useful even outside of Guitarix.


Nope, sorry.
Releasing is one point which may not be so work intensive, but maintaining in the long run is. So I'll keep it as tool in guitarix, were I work with and maintain it anyway.

sadko4u wrote:It would be a killer feature if this stuff would be implemented as a plugin that dynamically loads schematics.


Yes, it would for sure, but that is out of scope for this toolkit.

With the dkbuilder you could easily work on schematic diagrams and generate plugins from them which you could load directly with you host of choice. So, say you have generated a LV2 plug from a series of schematics, and have load it into your host, then you change a condenser value in one of the schematics, for example, you could rebuild and load the new version into your host. Now you've both versions loaded and could compare them, to hear what your changes have done.
Also dkbuilder could do some frequency response plots to see beforehand what properly will happen.
On the road again.

Dominique
Established Member
Posts: 54
Joined: Sat May 26, 2018 10:24 am

Re: dkbuilder: from circuit to LV2 plugin

Postby Dominique » Tue Feb 19, 2019 4:06 pm

Hi Hermann,

Thank you for that software. I am very excited to try it.

When I try to install dkbuilder, I get an error:

Code: Select all

mkvirtualenv -r python_venv guitarix
...
Collecting pkg-resources==0.0.0 (from -r python_venv (line 8))
  Could not find a version that satisfies the requirement pkg-resources==0.0.0 (from -r python_venv (line 8)) (from versions: )
No matching distribution found for pkg-resources==0.0.0 (from -r python_venv (line 8))

and it stop here.

User avatar
SpotlightKid
Established Member
Posts: 105
Joined: Sun Jul 02, 2017 1:24 pm

Re: dkbuilder: from circuit to LV2 plugin

Postby SpotlightKid » Tue Feb 19, 2019 4:16 pm

The 'pkg-resources' package is normally installed as part of the 'setuptools' package, which already gets installed automatically when you create a virtual environment. So 'pkg-resources' should not be listed in a requirements file (the 'python_venv' argument to the '-r' option). Just remove the line from the file.

Dominique
Established Member
Posts: 54
Joined: Sat May 26, 2018 10:24 am

Re: dkbuilder: from circuit to LV2 plugin

Postby Dominique » Tue Feb 19, 2019 10:56 pm

Thank you! It work fine. I can begin to experiment with the dkbuilder.

Dominique
Established Member
Posts: 54
Joined: Sat May 26, 2018 10:24 am

Re: dkbuilder: from circuit to LV2 plugin

Postby Dominique » Wed Feb 20, 2019 9:35 pm

Now I have another issue. build-plug.py was complaining about "OSError: libslicot.so.0: cannot open shared object file: No such file or directory", which does not exist on gentoo. But I managed to install it and it work. But just to be sure, my system is a 64 bits multilib install, and "man dh" doesn't describe what the different sequences are.

Code: Select all

make -f  debian/rules all
dh all --without autoreconf
dh: Unknown sequence all (choose from: binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep)

I added "--without autoreconf" because it doesn't exist on gentoo. With "make -f debian/rules build", the library was build. I copied it to /usr/lib64 and ran ldconfig. Is it the correct sequence, or can I do better?

But now I get

Code: Select all

./build-plug.py -i VoxWahV847.sch --table 2  --build -n VoxWahV847
Traceback (most recent call last):
  File "./build-plug.py", line 28, in <module>
    from analog import *
  File "./analog.py", line 6, in <module>
    import dk_simulator, models, circ, mk_netlist, dk_lib, simu, signals, generate_code
  File "./dk_simulator.py", line 10, in <module>
    import slicot
  File "./slicot.py", line 17, in <module>
    slicot = ct.cdll.LoadLibrary("libslicot.so.0")
  File "/usr/lib64/python2.7/ctypes/__init__.py", line 444, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib64/python2.7/ctypes/__init__.py", line 366, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libgfortran.so.4: cannot open shared object file: No such file or directory

and libgfortran is installed into my system:

Code: Select all

locate libgfortran.so
/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/libgfortran.so
/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/libgfortran.so.5
/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/libgfortran.so.5.0.0
/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/32/libgfortran.so
/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/32/libgfortran.so.5
/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/32/libgfortran.so.5.0.0

gcc is slotted on gentoo, I am installing gcc-7.4.0 and will try again later.

Dominique
Established Member
Posts: 54
Joined: Sat May 26, 2018 10:24 am

Re: dkbuilder: from circuit to LV2 plugin

Postby Dominique » Wed Feb 20, 2019 9:54 pm

I stopped the gcc installation because it look like to be an inconsistency into my system:

Code: Select all

ldd -v libslicot.so.0
   linux-vdso.so.1 (0x00007ffeafdc4000)
   libblas.so.3 => /usr/lib64/libblas.so.3 (0x00007f6399866000)
   liblapack.so.3 => /usr/lib64/liblapack.so.3 (0x00007f6398f7e000)
   libgfortran.so.5 => /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/libgfortran.so.5 (0x00007f6398d0a000)
   libm.so.6 => /lib64/libm.so.6 (0x00007f6398b85000)
   libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/libgcc_s.so.1 (0x00007f6398b6c000)
   libc.so.6 => /lib64/libc.so.6 (0x00007f63989a4000)
   libgfortran.so.4 => not found
   libgfortran.so.4 => not found
   libquadmath.so.0 => /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/libquadmath.so.0 (0x00007f6398961000)
   libz.so.1 => /lib64/libz.so.1 (0x00007f639874a000)
   /lib64/ld-linux-x86-64.so.2 (0x00007f6399e87000)

   Version information:
   ./libslicot.so.0:
      libgcc_s.so.1 (GCC_4.0.0) => /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/libgcc_s.so.1
      libc.so.6 (GLIBC_2.4) => /lib64/libc.so.6
      libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
      libgfortran.so.5 (GFORTRAN_8) => /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/libgfortran.so.5
      libm.so.6 (GLIBC_2.2.5) => /lib64/libm.so.6
   /usr/lib64/libblas.so.3:
      libgfortran.so.4 (GFORTRAN_7) => not found
      libm.so.6 (GLIBC_2.2.5) => /lib64/libm.so.6
      libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
      libc.so.6 (GLIBC_2.4) => /lib64/libc.so.6
   /usr/lib64/liblapack.so.3:
      libc.so.6 (GLIBC_2.4) => /lib64/libc.so.6
      libc.so.6 (GLIBC_2.2.5) => /lib64/libc.so.6
      libgfortran.so.4 (GFORTRAN_7) => not found
      libgcc_s.so.1 (GCC_4.0.0) => /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/libgcc_s.so.1
      libm.so.6 (GLIBC_2.2.5) => /lib64/libm.so.6
snip

I will first reinstall blas and lapack.

tramp
Established Member
Posts: 1411
Joined: Mon Jul 01, 2013 8:13 am

Re: dkbuilder: from circuit to LV2 plugin

Postby tramp » Thu Feb 21, 2019 5:34 am

Hi Dominique

As reference here is my output for ldd -v libslicot.so.0

Code: Select all

   linux-vdso.so.1 (0x00007ffc778e6000)
   libblas.so.3 => /usr/lib/x86_64-linux-gnu/libblas.so.3 (0x00007f0370105000)
   liblapack.so.3 => /usr/lib/x86_64-linux-gnu/liblapack.so.3 (0x00007f036fa37000)
   libgfortran.so.5 => /usr/lib/x86_64-linux-gnu/libgfortran.so.5 (0x00007f036f7ca000)
   libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f036f647000)
   libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f036f62d000)
   libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f036f46c000)
   libatlas.so.3 => /usr/lib/x86_64-linux-gnu/libatlas.so.3 (0x00007f036f0cc000)
   libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f036f08b000)
   libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f036ee6d000)
   /lib64/ld-linux-x86-64.so.2 (0x00007f03707ab000)

   Version information:
   /usr/lib/x86_64-linux-gnu/libslicot.so.0:
      libgcc_s.so.1 (GCC_4.0.0) => /lib/x86_64-linux-gnu/libgcc_s.so.1
      libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
      libgfortran.so.5 (GFORTRAN_8) => /usr/lib/x86_64-linux-gnu/libgfortran.so.5
      libm.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libm.so.6
   /usr/lib/x86_64-linux-gnu/libblas.so.3:
      libm.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libm.so.6
      libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
      libgfortran.so.5 (GFORTRAN_8) => /usr/lib/x86_64-linux-gnu/libgfortran.so.5
   /usr/lib/x86_64-linux-gnu/liblapack.so.3:
      libgcc_s.so.1 (GCC_4.0.0) => /lib/x86_64-linux-gnu/libgcc_s.so.1
      libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
      libgfortran.so.5 (GFORTRAN_8) => /usr/lib/x86_64-linux-gnu/libgfortran.so.5
      libm.so.6 (GLIBC_2.27) => /lib/x86_64-linux-gnu/libm.so.6
      libm.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libm.so.6
   /usr/lib/x86_64-linux-gnu/libgfortran.so.5:
      libquadmath.so.0 (QUADMATH_1.0) => /usr/lib/x86_64-linux-gnu/libquadmath.so.0
      libgcc_s.so.1 (GCC_4.2.0) => /lib/x86_64-linux-gnu/libgcc_s.so.1
      libgcc_s.so.1 (GCC_3.3) => /lib/x86_64-linux-gnu/libgcc_s.so.1
      libgcc_s.so.1 (GCC_3.0) => /lib/x86_64-linux-gnu/libgcc_s.so.1
      libgcc_s.so.1 (GCC_4.3.0) => /lib/x86_64-linux-gnu/libgcc_s.so.1
      libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.7) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.6) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.17) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
      libm.so.6 (GLIBC_2.27) => /lib/x86_64-linux-gnu/libm.so.6
      libm.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libm.so.6
   /lib/x86_64-linux-gnu/libm.so.6:
      ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
      libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_PRIVATE) => /lib/x86_64-linux-gnu/libc.so.6
   /lib/x86_64-linux-gnu/libgcc_s.so.1:
      libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
   /lib/x86_64-linux-gnu/libc.so.6:
      ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
      ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
   /usr/lib/x86_64-linux-gnu/libatlas.so.3:
      libm.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libm.so.6
      libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
   /usr/lib/x86_64-linux-gnu/libquadmath.so.0:
      libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.10) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
      libm.so.6 (GLIBC_2.23) => /lib/x86_64-linux-gnu/libm.so.6
      libm.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libm.so.6
   /lib/x86_64-linux-gnu/libz.so.1:
      libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
      libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6


Maybe libgfortran.so.4 is pulled in by blas and lapack on your system, but, I must admit that I've no idea about how gentoo handle build dependency's.
I mean, how is it possible that you've blas and lapack installed, while they have a missing dependency? libgfortran.so.4

I hope you could solve the issue and have some fun with the dkbuilder, so that at least it was worse the hassle.

A comment to your build command on ./build-plug.py.
The --table option indicate for which circuit in sequence the table should build, as you use just one circuit, the option [2] will be ignored.
But, for a wah, you didn't need a nonlin table anyway,
On the road again.

Dominique
Established Member
Posts: 54
Joined: Sat May 26, 2018 10:24 am

Re: dkbuilder: from circuit to LV2 plugin

Postby Dominique » Thu Feb 21, 2019 6:50 am

Hi tramp,

The update from gcc-7.x to 8.x was not so easy on gentoo. But after reinstalling blas and lapack, it work fine. I an even see the graph with "./build-plug.py -i wahwah.sch --table 1 --build -n wahwah". But it is still another issue:

Code: Select all

build nonlin gx_plugin from: ['wahwah.sch']
ERROR : Unable to open file  stdfaust.lib

"locate stdfaust.lib" find nothing, and it is no mention of it into the faust sources. Which look like to be related to that bug: Version 2-5-10 doesn't install stdfaust.lib. Faust is provided by the proaudio overlay, so I will take a look at it.
Last edited by Dominique on Thu Feb 21, 2019 7:05 am, edited 1 time in total.

tramp
Established Member
Posts: 1411
Joined: Mon Jul 01, 2013 8:13 am

Re: dkbuilder: from circuit to LV2 plugin

Postby tramp » Thu Feb 21, 2019 6:55 am

Dominique wrote: Which look like to be related to that bug: Version 2-5-10 doesn't install stdfaust.lib. Faust is provied by the proaudio overlay, so I will take a look at it.


Dominique, keep in mind, the dkbuilder requires faust version 0.9.90 --> https://github.com/grame-cncm/faust/rel ... ag/v0-9-90
It currently didn't work with faust2.
On the road again.

Dominique
Established Member
Posts: 54
Joined: Sat May 26, 2018 10:24 am

Re: dkbuilder: from circuit to LV2 plugin

Postby Dominique » Thu Feb 21, 2019 7:08 am

tramp, thanks for pointing that out. It is 0.9.67 in the overlay, so hopefully it can be an easy ebuild update.

Dominique
Established Member
Posts: 54
Joined: Sat May 26, 2018 10:24 am

Re: dkbuilder: from circuit to LV2 plugin

Postby Dominique » Thu Feb 21, 2019 9:55 am

It work with faust-0.9.90 and I get some files generated. But it is another issue now:

Code: Select all

build nonlin gx_plugin from: ['wahwah.sch']
dkbuild/wahwah/wahwah.cc:1: désolé, pas implémenté: Les optimisations de boucles Graphite ne peuvent pas être utilisées (isl n'est pas disponible) (-fgraphite, -fgraphite-identity, -floop-nest-optimize, -floop-parallelize-all)
 // generated from file 'dkbuild/wahwah/wahwah.dsp' by dsp2cc:

This mean: sorry, no implemented: The Graphite loop optimisations cannot be used (isl not available). I must reinstall gcc with USE=graphite.


Return to “Developer's Section”

Who is online

Users browsing this forum: No registered users and 1 guest