Learn Working with TypeScript

Getting Started

Welcome to RNBO

Quickstart

RNBO Basics

Key Differences

Why We Made RNBO

Coding Resources

Fundamentals

Audio IO

Messages to rnbo~

Using Parameters

MIDI in RNBO

Messages and Ports

Polyphony and Voice Control

Audio Files in RNBO

Using Buffers

Using the FFT

Export Targets

Export Targets Overview

VST/AudioUnit
Max External Target
Raspberry Pi Target
The Web Export Target
The C++ Source Code Target

Code Export

Working with JavaScript
Working with C++

Special Topics

Sample Accurate Patching
Scala and Custom Tuning

RNBO and Max for Live

RNBO Raspberry Pi OSCQuery Runner

Metadata

Export Description

Raspberry Pi GPIO

Updating the RNBO Package

Working with TypeScript

The @rnbo/js library includes TypeScript types, and integrates smoothly with TypeScript projects.

If you're working with TypeScript, @rnbo/js includes type definitions to support integration with TypeScript tools. After installing the @rnbo/js package with npm install @rnbo/js, there are no extra steps to get the RNBO TypeScript definitions. The rnbo.webaudio.d.ts file contains TypeScript definitions for @rnbo/js.

working-with-typescript-01.png

Using TypeScript allows you to use import to include the @rnbo/js package. It also allows you to explore the structure of objects in @rnbo/js through autocomplete tools that leverage TypeScript definition files.

import { createDevice, IPatcher, MessageEvent } from "@rnbo/js";

let patcher: IPatcher;
let context: AudioContext;

context = new AudioContext();

// Somehow initialize your patcher

const device = await createDevice({
    patcher: patcher,
    context: context
});

The TypeScript definitions for @rnbo/js also include type definitions for the exported patcher itself as an IPatcher type. If you enable the tsconfig option resolveJsonModule, then you can import an exported patcher JSON directly. Its structure will be available to autocomplete and other typescript tools.

working-with-typescript-02.png