Quantcast
Channel: KVR Audio
Viewing all articles
Browse latest Browse all 6096

Controller Scripting • Getting device parameter values for the selected track

$
0
0
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:

    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:

param name track 1 Humanize CONTENTS/TIME Time Rangeparam name track 1 Humanize CONTENTS/VELOCITY Velocity Rangeparam name track 1 Humanize CONTENTS/CHANCE Note Chance...param name track 1 Drum Machine CONTENTS/MASTER_VOLUME Master Volumeparam norm track 1 Drum Machine CONTENTS/MASTER_VOLUME 0.0...param name track 1 EQ-2 CONTENTS/LO_GAIN Lo Gainparam name track 1 EQ-2 CONTENTS/LO_FREQ Lo Freq...param norm track 1 EQ-2 CONTENTS/LO_GAIN 0.3604651162790698param norm track 1 EQ-2 CONTENTS/LO_FREQ 0.2528114845985827...param name track 2 Velocity Curve CONTENTS/X1 Middle Velocity Inputparam name track 2 Velocity Curve CONTENTS/Y0 Minimum Velocity Output...param norm track 2 Velocity Curve CONTENTS/X1 0.6487603305785123param norm track 2 Velocity Curve CONTENTS/Y0 0.49504950495049516...param name Master Peak Limiter CONTENTS/CEILING Ceilingparam name Master Peak Limiter CONTENTS/GAIN Input Gain...param norm Master Peak Limiter CONTENTS/CEILING 0.9916666666666667param 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:

        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:

This can only be called during driver initializationvGz: 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.

Statistics: Posted by BrianEdwards — Wed Jan 24, 2024 11:39 pm — Replies 0 — Views 20



Viewing all articles
Browse latest Browse all 6096

Trending Articles