Page 1 of 2

Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Thu Aug 29, 2013 3:20 am
by GraysonPeddie
Hey Falk, could you take a look at my attachment and find out what is wrong with my plugin? The error message is "Failed to find the requested plugin in the LV2 Bundle."
Bass_Redirection_5_1.tar.gz
(7.44 KiB) Downloaded 67 times
j_e_f_f_g created an LV2 creator program which is very handy. All I did is write some DSP code that downmixes all the signals to be routed to my subwoofer while leaving all 5 channels passing through.

Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Thu Aug 29, 2013 2:34 pm
by GraysonPeddie
Okay, thanks. I did not modify the generated ttl file, but I will take a look at it and modify it.

Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Thu Aug 29, 2013 3:55 pm
by GraysonPeddie
Okay, at least I got it to work. Pay no attention to dspRun() function, as I have written my own DSP code. The only thing to concern about is the TTL file and the URI changed in both TTL files and Bass_Redirection_5_1.h file.

Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Thu Aug 29, 2013 6:02 pm
by tramp
from http://www.linuxmusicians.com/viewtopic ... 0&start=15
NilsGey wrote:What is the difference to FAUST?
GraysonPeddie wrote:Hi, it's nice that you have created an LV2 creator program, but it would be nice if I could name audio inputs and outputs to be more descriptive as I'm creating a bass redirection plugin. What it does is for right now, it passes 5 channels along intact but for the last audio output, I took 6 audio inputs, divide it by 6, and then send that signal to the subwoofer output. I do intend to create a low pass filter for that particular output but I intend to test the plugin as it is.
To get what you wont you can try the faust online compiler here:
http://faust.grame.fr/index.php/online-examples

Code: Select all

declare name 	"Bass_Redirection";
declare version 	"1.0";
declare license 	"BSD";

//-----------------------------------------------
// Audio Matrix : 5 inputs, 5 outputs + mixdown to lowpass
//-----------------------------------------------

import("filter.lib");


freq    = hslider("freq [unit:Hz][style:knob]", 1000, 20, 20000, 0.1);
gain    = hslider("gain [unit:dB][style:knob]", 0, -20, 20, 0.1): db2linear : smooth(0.999);
process = par(in,5, _) <: ((_,_,_,_,_),( (_,_,_,_,_) :> lowpass(3,freq) : *(gain))) ;


drop it into the "Faust Code", select Linux and LV2 ( or make a jackqt stand alone, if you wish, or, . . ), and go to Exec File.
You can download your Lv2 bundle as name.tgz2

On of the nice features in faust is that you can build block diagrams from your code, the code above do the following:
Image

Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Thu Aug 29, 2013 8:17 pm
by GraysonPeddie
I will have a look at faust. I'm having trouble getting my low pass filter to work in subwoofer:

Based on: http://www.musicdsp.org/showone.php?id=38

Code: Select all

const float PI = 3.14159265358979323846f;
const float r = 1; // or 0 -- whatever; r = resonance, which I don't care for.
// Typical home theater receivers do not have a resonance knob
// for setting a crossover point! :)

void dspRun(BASS_REDIRECTION_5_1 * plugin)
{
    while (plugin->Host.Begin < plugin->Host.End)
    {
        // Crossover Frequency
        float f = 80.0f;
        // Low Pass
        float c = 1.0f / tan(PI * f / plugin->Host.SampleRate);
        float a1 = 1.0f / (1.0f + r * c + c * c);
        float a2l = 2.0f * a1; // low-pass filter
//        float a2h = -2.0f * a1; // high-pass filter
        float a3 = a1;
        float b1l = 2.0f * (1.0f - c * c) * a1; // low-pass filter
//        float b1h = 2.0f * (c * c - 1.0f) * a1; // high-pass filter
        float b2 = ( 1.0f - r * c + c * c) * a1;

        uint32_t n = plugin->Host.Begin;

        // Front Left
        *(plugin->Host.AudioOut[0] + n) =
            *(plugin->Host.AudioIn[0] + n);
        // Front Right
        *(plugin->Host.AudioOut[1] + n) =
            *(plugin->Host.AudioIn[1] + n);
        // Rear Left
        *(plugin->Host.AudioOut[2] + n) =
            *(plugin->Host.AudioIn[2] + n);
        // Rear Right
        *(plugin->Host.AudioOut[3] + n) =
            *(plugin->Host.AudioIn[3] + n);
        // Center
        *(plugin->Host.AudioOut[4] + n) =
            *(plugin->Host.AudioIn[4] + n);
        // Mix All 5 channels above and combine a subwoofer input
        // to be routed to the subwoofer output.
        *(plugin->Host.AudioOut[5] + n) =
            ( *(plugin->Host.AudioIn[0] + n) +
              *(plugin->Host.AudioIn[1] + n) +
              *(plugin->Host.AudioIn[2] + n) +
              *(plugin->Host.AudioIn[3] + n) +
              *(plugin->Host.AudioIn[4] + n) +
              *(plugin->Host.AudioIn[5] + n) ) / 6;
        float sub_out = *plugin->Host.AudioOut[5];
        *(plugin->Host.AudioOut[5] + n) =
            a1 * sub_out + a2l * sub_out * (n - 1) + a3 *
            sub_out * (n - 2) - b1l * sub_out * (n - 1) -
            b2 * sub_out * (n - 2);

        ++plugin->Host.Begin;
    }
}
I really, really want to know how a low pass filter works behind the scenes, not a dully-plain-old English like "it filters out high frequencies so that only lows can pass." :)

Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Fri Aug 30, 2013 12:06 pm
by j_e_f_f_g
falkTX wrote:different users will endup with different URIs depending on where you installed the plugin.
What?? The host shoudn't be changing that URI.

Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Fri Aug 30, 2013 2:12 pm
by tramp
GraysonPeddie wrote: I really, really want to know how a low pass filter works behind the scenes, . . .
To understand how lowpass (and other) filters work, you need to know some basics about Digital Audio Signals in general.
Here is a (free) DSP introduction online course, which may help you to make some steps:
http://www.bores.com/courses/intro/index.htm

Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Fri Aug 30, 2013 4:33 pm
by GraysonPeddie
I'm trying out Faust.

Could you please explain how this line of code works?

Code: Select all

process = par(in,5, _) <: ((_,_,_,_,_),( (_,_,_,_,_) :> lowpass(3,freq) : *(gain))) ;
Right now, what I have is:

Code: Select all

crossoverfreq = hslider("Crossover [Unit:Hz][Style:Knob]", 80, 40, 200, 20);
...as I follow the first tutorial.

I want to do something like this:

Code: Select all

submix = (in[0] + in[1] + in[2] + in[3] + in[4] + in[5]) / 6;
crossoverfreq = hslider("Crossover [Unit:Hz][Style:Knob]", 80, 40, 200, 20);
out[0] = highpass(3,crossoverfreq) from in[0];
out[1] = highpass(3,crossoverfreq) from in[1];
out[2] = highpass(3,crossoverfreq) from in[2];
out[3] = highpass(3,crossoverfreq) from in[3];
out[4] = highpass(3,crossoverfreq) from in[4];
out[5] = lowpass(3,crossoverfreq) from submix;
process = out[0] ... out[4] and submix;
How this works is this: Adjust the crossover point to 120Hz and all 5 speakers will not produce below 120Hz while the subwoofer will not produce above 120Hz. Turn the crossover point to 40Hz and the subwoofer can only produce the sound up to 40Hz, but the speakers can produce frequencies down to 40Hz. Does that make sense?

Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Sat Aug 31, 2013 4:57 am
by tramp
GraysonPeddie wrote:I'm trying out Faust.

Could you please explain how this line of code works?

Code: Select all

 process = par(in,5, _) <: ((_,_,_,_,_),( (_,_,_,_,_) :> lowpass(3,freq) : *(gain))) ;
well, par(in,5, _) create 5 parallel lines, here Input Ports, as it is the first expression in the process , <: splits the previous sequence, here in splits the 5 lines into 10 lines, so it double the lines. (_,_,_,_,_) this creates as well 5 parallel lines, :> merge the lines of the previous sequence, lowpass(3,freq) well, create a 3order lowpass with cutoff frequency freq, *(gain), multiply with "gain".

The par keyword leads to the needed effect in the sequence, for example if you put a split (<:) behind a sequence like this (_,_) , the result will look like this (1,2)<:(1,1,2,2). If you use par you will get par(2,_)<:(1,2,1,2).
So in the above code you get
par(in,5, _) <: (1,2,3,4,5),(1,2,3,4,5)
now we have ( (_,_,_,_,_) :> lowpass(3,freq) : *(gain)) which makes it "one sequence, were 5 lines merged into one lowpass, and we have par(in,5, _) <: ((_,_,_,_,_),( (_,_,_,_,_) :> lowpass(3,freq) : *(gain))), makes it one sequence. The result be 6 outputs, were 5 be simple lines (copy input to output) and the 6't be 5 merged lines into one lowpass. This cover the line par(in,5, _) <: (1,2,3,4,5),(1,2,3,4,5).

now, you like to use 6 inputs, use par(in,6, _) <: (1,2,3,4,5,6),(1,2,3,4,5,6). But you wouldn't use the 6't output in the first expression, therfore you can use a dead end, par(in,6, _) <: ((_,_,_,_,_,!),( (_,_,_,_,_,_) :> lowpass(3,freq)

So to get what you want, you can replace the lines in the first expression with you highpasses.
par(in,6, _) <:(hp1,hp2,hp3,hp4,hp5,!),(_,_,_,_,_,_):> /(6) : lp;

Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Sat Aug 31, 2013 10:20 am
by tramp
So, if it is this what you want:
Image

you could use this code:

Code: Select all

declare name 		"5.1 subworfer";

import("filter.lib");


freq    = hslider("freq [unit:Hz][style:knob]", 80, 20, 200, 10);
gain    = hslider("gain [unit:dB][style:knob]", 0, -60, 4, 0.1): db2linear : smooth(0.999);
hp      = highpass(3,freq);
lp      = lowpass(3,freq);
process = par(in,6, _) <: (par(out,5,hp),!, ( (par(out,6,_)) :> /(6) :lp : *(gain))) ;


Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Sat Aug 31, 2013 4:27 pm
by GraysonPeddie
Okay, so I've taken the time to write the code:

Code: Select all

declare name "BassRedirection";
declare version "0.1";
declare license "GPL";

import("filter.lib");

crossoverfreq = hslider("Crossover [unit:Hz]", 80, 40, 200, 20);

process = par(in,6, _) <: (
  highpass(3,crossoverfreq),
  highpass(3,crossoverfreq),
  highpass(3,crossoverfreq),
  highpass(3,crossoverfreq),
  highpass(3,crossoverfreq),
  !),
  ((_,_,_,_,_,_) :> /(6) : lowpass(3,crossoverfreq));
...compiled it as 64-Bit LV2, and when I execute carla-discovery-native, I get this:

Code: Select all

lv2_rdf_new("http://faust-lv2.googlecode.com/BassRedirection") - got unknown unit type '1genid2'
And now I am stuck.

(Forum being so slow lately...?)

Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Sat Aug 31, 2013 5:15 pm
by GraysonPeddie
BassRedirection.ttl:

Code: Select all

@prefix doap: <http://usefulinc.com/ns/doap#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix lv2:  <http://lv2plug.in/ns/lv2core#> .
@prefix epp:  <http://lv2plug.in/ns/ext/port-props#> .
@prefix ev:   <http://lv2plug.in/ns/ext/event#> .
@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix units: <http://lv2plug.in/ns/extensions/units#> .
<http://faust-lv2.googlecode.com/BassRedirection>
       a lv2:Plugin ;
       doap:name "BassRedirection" ;
       lv2:binary <BassRedirection.so> ;
       lv2:optionalFeature epp:supportsStrictBounds ;
       lv2:optionalFeature lv2:hardRtCapable ;
       doap:license "GPL" ;
    lv2:port [
	a lv2:ControlPort ;
	a lv2:InputPort ;
	lv2:index 0 ;
	lv2:symbol "Crossover" ;
	lv2:name "Crossover" ;
	lv2:default 80 ;
	lv2:minimum 40 ;
	lv2:maximum 200 ;
	units:unit [
            a            units:Unit ;
            units:name   "Hz" ;
            units:symbol "Hz" ;
            units:render "%f Hz"
	] ;
    ] , [
	a lv2:AudioPort ;
	a lv2:InputPort ;
	lv2:index 1 ;
	lv2:symbol "in0" ;
	lv2:name "in0" ;
    ] , [
	a lv2:AudioPort ;
	a lv2:InputPort ;
	lv2:index 2 ;
	lv2:symbol "in1" ;
	lv2:name "in1" ;
    ] , [
	a lv2:AudioPort ;
	a lv2:InputPort ;
	lv2:index 3 ;
	lv2:symbol "in2" ;
	lv2:name "in2" ;
    ] , [
	a lv2:AudioPort ;
	a lv2:InputPort ;
	lv2:index 4 ;
	lv2:symbol "in3" ;
	lv2:name "in3" ;
    ] , [
	a lv2:AudioPort ;
	a lv2:InputPort ;
	lv2:index 5 ;
	lv2:symbol "in4" ;
	lv2:name "in4" ;
    ] , [
	a lv2:AudioPort ;
	a lv2:InputPort ;
	lv2:index 6 ;
	lv2:symbol "in5" ;
	lv2:name "in5" ;
    ] , [
	a lv2:AudioPort ;
	a lv2:OutputPort ;
	lv2:index 7 ;
	lv2:symbol "out0" ;
	lv2:name "out0" ;
    ] , [
	a lv2:AudioPort ;
	a lv2:OutputPort ;
	lv2:index 8 ;
	lv2:symbol "out1" ;
	lv2:name "out1" ;
    ] , [
	a lv2:AudioPort ;
	a lv2:OutputPort ;
	lv2:index 9 ;
	lv2:symbol "out2" ;
	lv2:name "out2" ;
    ] , [
	a lv2:AudioPort ;
	a lv2:OutputPort ;
	lv2:index 10 ;
	lv2:symbol "out3" ;
	lv2:name "out3" ;
    ] , [
	a lv2:AudioPort ;
	a lv2:OutputPort ;
	lv2:index 11 ;
	lv2:symbol "out4" ;
	lv2:name "out4" ;
    ] , [
	a lv2:AudioPort ;
	a lv2:OutputPort ;
	lv2:index 12 ;
	lv2:symbol "out5" ;
	lv2:name "out5" ;
    ]
.
manifest.ttl:

Code: Select all

########## http://faust-lv2.googlecode.com/BassRedirection ##########

@prefix doap: <http://usefulinc.com/ns/doap#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix lv2:  <http://lv2plug.in/ns/lv2core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<http://faust-lv2.googlecode.com/BassRedirection>
    a lv2:Plugin ;
    lv2:binary <BassRedirection.so> ;
    rdfs:seeAlso <BassRedirection.ttl> .

# Here's how you can declare the category of the plugin. (For lv2synth.cpp
# instances, the lv2:InstrumentPlugin type will be added automatically.) See
# http://lv2plug.in/ns/lv2core/ for a list of known plugin classes.

# <http://faust-lv2.googlecode.com/BassRedirection> a lv2:FilterPlugin .

# You might also want to set the license and author information below.
# NOTE: This isn't normally necessary if you declared the corresponding
# information as metadata in the Faust source of the plugin. The standard
# author, license and description fields in the Faust source are automagically
# included in the generated LV2 manifest.

# <http://faust-lv2.googlecode.com/BassRedirection>
#     doap:license <http://opensource.org/licenses/isc> ;
#     doap:maintainer [
#         foaf:name "Your Name Here" ;
#         foaf:homepage <http://somewhere.org/> ;
#         foaf:mbox <mailto:your@mail.here> ;
#     ] .
This is what FAUST generated.

Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Sat Aug 31, 2013 6:33 pm
by tramp
This looks correct to me, but maybe I oversee a error?
However, you could try it without the [unit:Hz] metadata (which seems to be the culprit here), you could load it into jalv.gtk or jalv.qt (it works in both) or you could build a jack standalone app (which makes properly most sense for such a unit).

Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Sat Aug 31, 2013 7:42 pm
by GraysonPeddie
Carla-Discover-Native did not complain when I remove the code:

Code: Select all

units:unit [
    a            units:Unit ;
    units:name   "Hz" ;
    units:symbol "Hz" ;
    units:render "%f Hz"
] ;
But in Carla, it told me it can't find a plugin bundle. Removing [unit:Hz] didn't help.

Re: Carla and Bass Redirection LV2 Plugin: LV2 Bundle

Posted: Sat Aug 31, 2013 8:41 pm
by GraysonPeddie
Well, I got it to work! Adding new folders does not seem to be the problem, but I had to restart Carla after I add a new plugin to /usr/local/lib/lv2, no matter how many times I tried to refresh the plugins list.