You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 30, 2023. It is now read-only.
> **Note:** Don't miss the `-g` flag here as this installs the package globally, adding the the `taktil` command to your path.
26
25
27
-
28
-
If you'd rather use Taktil without the CLI, you can install it locally into an existing project like so:
26
+
If you'd rather use Taktil without the CLI, you can manually install it locally into an existing project like so:
29
27
30
28
```bash
31
29
$ npm install taktil
@@ -49,7 +47,7 @@ Display Name: Getting Started
49
47
Vendor/Category: Custom
50
48
Version (1.0.0):
51
49
Author: Joseph Larson
52
-
API Version (2): 4
50
+
API Version (4):
53
51
[taktil] project initialization complete.
54
52
```
55
53
@@ -179,7 +177,7 @@ With that, we've defined our controls.
179
177
180
178
## Creating Components
181
179
182
-
Now that we've defined our controls, we'll move on to building some reusable components. Components, in Taktil, are the state and business logic containers for non-hardware-specific functionality. They receive and react to standardized `ControlInput` messages (through the `onControlInput` method) as well as Bitwig API events. They also decide when a connected `Control` should be updated by calling its `setState` method, usually in reaction to on of the above mentioned messages or events.
180
+
Now that we've defined our controls, we'll move on to building some components. Components, in Taktil, are the state and business logic containers for non-hardware-specific functionality. They receive and react to standardized `ControlInput` messages (through the `onControlInput` method) as well as Bitwig API events. They also decide when a connected `Control` should be updated by calling its `setState` method, usually in reaction to on of the above mentioned messages or events.
183
181
184
182
Controls convert Midi input messages into standardized `ControlInput` messages. These messages are sent on to a connected component through the component's `onControlInput` method. In this way, each component definition is able to uniquely define how this input will be handled and when and how a control's state will be modified.
185
183
@@ -320,9 +318,17 @@ export const daw = new Daw();
320
318
```
321
319
322
320
323
-
## Constructing Views
321
+
## Assembling the Views
322
+
323
+
Now that we've defined our controls and and components, it's time to assemble them into views. I their simplest form, views are just a mapping of components to controls. When a view is active, the view's components will receive control input and generate control output. An inactive view's components, on the other hand, will not be sent control input messages, and will not generate any control output, but they will continue to maintain their internal state in preparation for being activated.
324
+
325
+
View components are also registered to a specific view "mode" and will only be considered active if both the view and the mode are active. Taktil maintains the array of active mode strings globally. These modes are kept in the order they were activated such that a component registered to the same control but a different mode can override the another, with the most recently activated mode taking precedence. This allows a view to configure itself differently based on the global mode list. This is useful, for instance, when implementing a shift button, where having all views know our script is in "shift mode" will allow us to define secondary actions across multiple disconnected views.
326
+
327
+
Views are defined by extending Taktil's View class or by stacking previously defined views using the ViewStack function. The ViewStack function accepts a list of view classes and returns a new View class definition where, in order, each of the provided views' component/control mappings override any subsequent view's mapping involving the same control (it's just simple inheritance where the the control portion of each mapping is the thing being overridden). This pattern makes it possible to define reusable chunks of view logic which can be combined together in different ways to create more complex views.
324
328
325
-
Components are instantiated as members of a `View` definition providing a corresponding control and a params object.
329
+
In a simple project, a single view making use of view modes may be enough handle your needs. The value of view stacks will become apparent when developing more complex projects.
330
+
331
+
As shown below, the component/control mappings are defined as instance properties. Valid instance property types consist of a component instance, an array of component instances, or a function that returns either of the previous. Component constructors take a control instance and a params object. The params object consists of an optional mode property—for defining which mode the component should be registered to—as well as whatever else the individual component needs to operate. This is generally where we will pass in objects retrieved or created through Bitwig's API as the view instance code will not be run until after the init phase.
// export the view name to view class mapping so that we can register these views to
359
+
// the session to be activated by name
346
360
exportconstviews= {
347
361
BASE: BaseView,
362
+
// by stacking these views, all components in MixerView that are connected to an active mode
363
+
// will be active and any components in BaseView that are connected to an active mode will
364
+
// be active as long as their connected controls do not conflict with any active component
365
+
// in the MixerView.
348
366
MIXER:ViewStack(MixerView, BaseView),
349
367
};
350
368
```
351
369
352
370
353
-
## Assembling the Session
371
+
## Initializing the Session
372
+
373
+
At this point we've defined our control layer, created some components, and assembled those controls and components into views. Now all that's left is to create our controller script's entry point where we will initialize our session.
354
374
355
375
```js
376
+
// src/index.js
377
+
356
378
importtaktilfrom'taktil';
357
379
358
380
import { controls } from'./controls';
359
381
import { views } from'./views';
360
382
361
383
// 1. set bitwig api version
362
-
host.loadAPI(3);
384
+
host.loadAPI(4);
363
385
364
386
// 2. define controller script
365
387
host.defineController(
@@ -385,5 +407,4 @@ taktil.registerViews(views);
385
407
386
408
// 6. on init, activate view to trigger initial render
0 commit comments