I've connected a trill hub to the Bela using the grove to grove and grove to pin cables - I have a total two trill bar and two trill hex connected.

while fairly new to the c++ environment, what function / addresses would need to be added to access each sensor on the trill hub in the render.cpp file, in order of addressing rnbo parameters to the various indices of each of them?

1) the x,y axes and touch size of trill hex 1 and 2 (on J5/J6)
2) the position and location of one or more fingers on both trill bar 1 and 2 (on J3/J4).

thanks.

First off as you are using more than one sensor of the same type, you need to change the address on at least one of each pair. This is done by bridging some of the solder pads, as explained here.

Then in terms of support in rnbo, use the trill-twod branch. Note that there is no support for multiple touches per device at the moment. In the provided render.cpp, you need to uncomment this line:

//#define BELA_RNBO_USE_TRILL // uncomment to use Trill

then edit these lines

static std::vector<Trill*> trills {
	// add/edit more Trills here
	new Trill(1, Trill::BAR),
};

so that you add all the Trills you have with the correct address, e.g.: if you have one stock bar at 0x20 and one modified bar at 0x21, one stock hex at 0x40 and one modified hex at 0x41, you'd have:

static std::vector<Trill*> trills {
	// add/edit more Trills here
	new Trill(1, Trill::BAR, 0x20),
	new Trill(1, Trill::BAR, 0x21),
	new Trill(1, Trill::HEX, 0x40),
	new Trill(1, Trill::HEX, 0x41),
};

Then we need to set what parameters we want to control. The lines

// same but for mapping Trill location to parameters.
static std::vector<unsigned int> parametersFromTrillLocation = {};
// same but for mapping Trill horizontal location to parameters.
static std::vector<unsigned int> parametersFromTrillHorizontalLocation = {};
// same but for mapping Trill size to parameters.
static std::vector<unsigned int> parametersFromTrillSize = {};

need to be modified for that purpose. The example below should make you control the parameters as follows:

  • Bar 0x20 location -> parameter 0
  • Bar 0x21 location -> parameter 1
  • Hex 0x40 location-y -> parameter 2
  • Hex 0x40 location-x -> parameter 3
  • Hex 0x41 location-y -> parameter 4
  • Hex 0x41 location-x -> parameter 5
// same but for mapping Trill location to parameters.
static std::vector<unsigned int> parametersFromTrillLocation = {0, 1, 2, 4};
// same but for mapping Trill horizontal location to parameters.
static std::vector<unsigned int> parametersFromTrillHorizontalLocation = {3, 5};
// same but for mapping Trill size to parameters.
static std::vector<unsigned int> parametersFromTrillSize = {};

Give that a try.

Thanks a lot! Everything seems to be working, but the x axis (parametersFromTrillHorizontalLocation) of the trill hex isn't giving me anything (the mapped rnbo parameters are active with the y axis though). Has this something to do with the trill-twod branch?

Moreover, what functions would I need to use in order to lock/remember the last position value for each of the sensors?

I think I got it wrong. Try this instead:

static std::vector<unsigned int> parametersFromTrillHorizontalLocation = {kNoParam, kNoParam, 3, 5};

the "kNoParam" tells it to skip one device, so

BAR 0x20 horizontal touch (doesn't exist) -> kNoParam
BAR 0x21 horizontal touch (doesn't exist) -> kNoParam
HEX 0x40 horizontal touch (exists) -> parameter 3
HEX 0x41 horizontal touch (exists) -> parameter 5

    can you print the summary of the mappings that gets printed when the project starts?

    Available parameters: 13
    [0] bpm
    [1] hex_left
    [2] switch_hex - controlled by digital in 14
    [3] 1_led_clock - controlling digital out 0
    [4] hex_right
    [5] 2_led_duff - controlling digital out 1
    [6] 3_led_kps - controlling digital out 2
    [7] 4_led_bw - controlling digital out 3
    [8] switch_slide - controlled by digital in 15
    [9] 5_led_gain - controlling digital out 4
    [10] 6_led_skip - controlling digital out 5
    [11] 7_led_eshp - controlling digital out 6
    [12] 8_led_elght - controlling digital out 7

    parameter 1 (hex_left) and 4 (hex_right) are mapped to the x axis of both trill hex respectively
    -->
    static std::vector<unsigned int> parametersFromTrillHorizontalLocation = {kNoParam, kNoParam, 1, 4};

    and what about the static std::vector<Trill*> trills variable?

    static std::vector<Trill*> trills {

    new Trill(1, Trill::BAR, 0x20),
    new Trill(1, Trill::BAR, 0x21),
    new Trill(1, Trill::HEX, 0x40),
    new Trill(1, Trill::HEX, 0x41),

    };

    Are you actually using the trill-twod branch?

    hmm not sure, how do I go about using it? I've followed all of the steps above.

    giuliomoro sorry about that! - I thought I was already up to date with the latest rnbo dev-1.2.6 branch -
    it works as it should now, thanks Giulio

    could I also trouble you with some guidance for a function to hold the last value of the indexes of each trill?

    that's sort of complicated. There are three ways of doing it, in increasing order of complexity:

    • only send the location value if it's different from zero.
    • only send the location value if the touch size is different from zero
    • remember past location values and return a recent one - but not the last one - when the touch size goes to zero.

    The first and second one share a drawback: the position will change slightly when you release your finger (as the shape of the fingertip on the sensor changes), so that the value that is held will be slightly different from the one that you meant to hold.

    The first has the additional drawback of not being able to detect the touch location when the touch is right on the edge of the sensor (i.e.: the finger touching only one of the sensing pads). This is often just a minor inconvenience, but if you expect your values to go to actual zero, it should be taken into account.

    The third one has none of these disadvantages but it's significantly more complicated to implement. Would the first one work for your use case?

      5 days later

      The second one is now tentatively implemented in the trill-twod branch (untested). Update the code on your board and see if it works. You need to set trillHold = true for this functionality to be enabled (besides the usual change to the #define BELA_RNBO_USE_TRILL and adding your trills to the vectors as explained above.

      I did that internally in my rnbo patch by setting a conditional statement of latching all location values when the touch size is below a certain value, which works reasonably well.

      but will try this iteration 🙂

      if I wanted to use two trill bars in the following fashion:

      1) as a multi-touch 'keyboard' segmented into 4 areas (on each bar), where the touch/location of one or more fingers would be used as trigger, and touch size of each area would be used to control parameters such as envelop shape or velocity
      2) as an expressive cross-fader/amplitude modulation device between 8 outputs - with 4 assigned on each bar (where location dictates the channel output and touch size the levels) - I could ultimately do this in rnbo by setting up 4 different 'windows' from the sensor readings (0.-0.25. ; 0.25-0.5; 0.5-0.75;0.75-1.00), and assign each of them to a channel with some smooth interpolation

      both of these examples do require the same indices - and multi touch could ultimately be used in both cases.

      I also did notice the LEDs for position feedback example does exactly that https://github.com/BelaPlatform/Bela/blob/master/examples/Trill/bar-led/render.cpp

      so my question is the following, what would I need to do in order to retrieve the touch (and respective size) of one or more fingers located on defined areas of two trill bars new Trill(1, Trill::BAR, 0x20),
      new Trill(1, Trill::BAR, 0x21),
      and thereafter map these indices to rnbo parameters - in the render.cpp file