Getting device parameter values for the selected track

Post Reply New Topic
RELATED
PRODUCTS

Post

AUTO-ADMIN: Non-MP3, WAV, OGG, SoundCloud, YouTube, Vimeo, Twitter and Facebook links in this post have been protected automatically. Once the member reaches 5 posts the links will function as normal.
I'm just starting out. I'm interested in getting device parameter settings for
a track. I'm wrapping my head around how to do this with the async nature,
four callbacks per parameter, and the limitation of having to call
markInterested or add...Observer in the init() method. I don't understand how
to get a handle on let's say a track the user hasn't created yet.

I have had success following around the user's mouse clicks, track/device
selections, and parameter settings with this...

Code: Select all (#)

    public void init() {
        final ControllerHost host = getHost();
        final CursorTrack track = host.createCursorTrack("track", "track", 0, 0, true);
        final PinnableCursorDevice device = track.createCursorDevice("device", "device", 0, CursorDeviceFollowMode.FOLLOW_SELECTION);
        track.name().markInterested();
        device.name().markInterested();
        device.addDirectParameterIdObserver(ids -> {});

        device.addDirectParameterNameObserver(2048, (id, name) -> {
            host.println(
                    String.format("param name %s %s %s %s", track.name().get(),
                            device.name().get(), id, name));
        });

        device.addDirectParameterNormalizedValueObserver((id, value) -> {
            host.println(
                    String.format("param norm %s %s %s %s", track.name().get(),
                            device.name().get(), id, value));
        });
    }
That works pretty well.

Code: Select all (#)

param name track 1 Humanize CONTENTS/TIME Time Range
param name track 1 Humanize CONTENTS/VELOCITY Velocity Range
param name track 1 Humanize CONTENTS/CHANCE Note Chance
...
param name track 1 Drum Machine CONTENTS/MASTER_VOLUME Master Volume
param norm track 1 Drum Machine CONTENTS/MASTER_VOLUME 0.0
...
param name track 1 EQ-2 CONTENTS/LO_GAIN Lo Gain
param name track 1 EQ-2 CONTENTS/LO_FREQ Lo Freq
...
param norm track 1 EQ-2 CONTENTS/LO_GAIN 0.3604651162790698
param norm track 1 EQ-2 CONTENTS/LO_FREQ 0.2528114845985827
...
param name track 2 Velocity Curve CONTENTS/X1 Middle Velocity Input
param name track 2 Velocity Curve CONTENTS/Y0 Minimum Velocity Output
...
param norm track 2 Velocity Curve CONTENTS/X1 0.6487603305785123
param norm track 2 Velocity Curve CONTENTS/Y0 0.49504950495049516
...
param name Master Peak Limiter CONTENTS/CEILING Ceiling
param name Master Peak Limiter CONTENTS/GAIN Input Gain
...
param norm Master Peak Limiter CONTENTS/CEILING 0.9916666666666667
param norm Master Peak Limiter CONTENTS/GAIN 0.5
...
One naive attempt I have made at getting the sibling devices of the one
the user clicks is this...

Code: Select all (#)

        final DeviceBank bank = track.createDeviceBank(2048);
        bank.itemCount().markInterested();

        track.name().addValueObserver(name -> {
            for (int i = 0; i < bank.itemCount().get(); i++) {
                final Device d = bank.getItemAt(i);
                d.addDirectParameterNormalizedValueObserver((id, value) -> {
                    host.println(String.format("(bank) param norm %s %s %s %s",
                            track.name().get(), device.name().get(), id, value));
                });
            }
        });
But that gives me the error...

Code: Select all (#)

This can only be called during driver initialization
vGz: This can only be called during driver initialization
    at XCG.eg(SourceFile:396)
    at com.bitwig.flt.control_surface.proxy.ControlSurfaceObject.checkIsInitializingDriver(SourceFile:295)
    at com.bitwig.flt.control_surface.proxy.DeviceProxy.addDirectParameterNormalizedValueObserver(SourceFile:1751)
    at com.jalopymusic.println.PrintlnExtension.lambda$init$1(PrintlnExtension.java:29)
What is a way that I can use the context of the track/device the user has
selected, but get parameter names and values for all devices on the track.

Post

AUTO-ADMIN: Non-MP3, WAV, OGG, SoundCloud, YouTube, Vimeo, Twitter and Facebook links in this post have been protected automatically. Once the member reaches 5 posts the links will function as normal.
I am starting to think that it isn't possible to get all-params for all devices on the current track. For example, DrivenByMoss OSC extension is very thorough and it is limited to the notion of the currently selected device and the primary device on the selected track...

Code: Select all (#)

/track/param/1/exists                      1
/track/param/1/name                        Cover
/track/param/1/valueStr                    22.2 %
/track/param/1/value                       28
/track/param/1/modulatedValue              28
/track/param/2/exists                      1
/track/param/2/name                        Grunt
/track/param/2/valueStr                    0.00 %
/track/param/2/value                       0
/track/param/2/modulatedValue              0
/track/param/3/exists                      1
/track/param/3/name                        Ghastly
/track/param/3/valueStr                    0.00 %
/track/param/3/value                       0
/track/param/3/modulatedValue              0
/track/param/4/exists                      1
/track/param/4/name                        Release
/track/param/4/valueStr                    0.00 %
/track/param/4/value                       0
/track/param/4/modulatedValue              0
/track/param/5/exists                      1
/track/param/5/name                        Wobble
/track/param/5/valueStr                    0.00 %
/track/param/5/value                       0
/track/param/5/modulatedValue              0
/track/param/6/exists                      1

/device/param/1/exists                     1
/device/param/1/name                       Freq
/device/param/1/valueStr                   2.22 kHz
/device/param/1/value                      86
/device/param/1/modulatedValue             86
/device/param/2/exists                     1
/device/param/2/name                       Reso
/device/param/2/valueStr                   26.3 %
/device/param/2/value                      33
/device/param/2/modulatedValue             33
/device/param/3/exists                     1
/device/param/3/name                       Mode
/device/param/3/valueStr                   High-pass (2-pole)
/device/param/3/value                      73
/device/param/3/modulatedValue             73
/device/param/4/exists                     0
/device/param/4/name                       empty

/primary/exists                            1
/primary/name                              Polysynth
/primary/bypass                            0
/primary/expand                            0
/primary/parameters                        1
/primary/window                            0
/primary/param/1/exists                    1
/primary/param/1/name                      Cover
/primary/param/1/valueStr                  22.2 %
/primary/param/1/value                     28
/primary/param/1/modulatedValue            28
/primary/param/2/exists                    1
/primary/param/2/name                      Grunt

Post

Sure, you can do it but it might cause quite a performance impact.
You need to set a large page size and then monitor all of the parameters for all the devices of the page (to be created via several loops).

Post Reply

Return to “Controller Scripting”