@audiotool/nexus - v0.0.10
    Preparing search index...

    @audiotool/nexus - v0.0.10

    A JS/TS package to interact with multiplayer projects of the Audiotool DAW in real time. Read more at Overview.


    Known supported platforms:

    * The Auth2 Login flow will be a bit more work for these platforms. We're working on making that easier.

    Note

    The Nexus Platform and this package are under heavy development, and as a result might still break when we make changes to the backend.

    Join our Discord Server to receive updates, submit bug reports, ask questions, show what you've done!

    Install the package from npm like this:

    npm install @audiotool/nexus
    

    Create an application on developer.audiotool.com/applications and enter details below:

    import { getLoginStatus } from "@audiotool/nexus"

    // check if current tab is logged in for some user
    const status = await getLoginStatus({
    clientId: "<client-id of your app>",
    redirectUrl: "http://127.0.0.1:5173/",
    scope: "project:write",
    })

    // if user isn't logged in, create a login button and wait
    if (!status.loggedIn) {
    const button = document.createElement("button")
    button.innerHTML = "Login"
    button.addEventListener("click", () => status.login())
    document.body.appendChild(button)
    await new Promise(() => {}) // wait forever
    }

    For more detailed instructions on authorization, see Getting Started or Managing User Login.

    import { createAudiotoolClient } from "@audiotool/nexus"

    // Create an audiotool client authorized with the current user
    const client = await createAudiotoolClient({
    authorization: status,
    })

    // Connect to an existing project you created on beta.audiotool.com
    const nexus = await client.createSyncedDocument({
    mode: "online",
    // Open the project, copy the URL, paste here
    project: "https://beta.audiotool.com/studio?project=your-project-id",
    })

    // Set up event listeners
    nexus.events.onCreate("tonematrix", (tm) => {
    console.log("New tonematrix created!", tm.fields.patternIndex.value)
    })

    // Start syncing
    await nexus.start()

    // Create a tonematrix
    await nexus.modify((t) =>
    t.create("tonematrix", {
    displayName: "My first device!",
    positionX: 100,
    positionY: 200,
    }),
    )

    // stop the syncing process
    await nexus.stop()
    • Overview - to see what this is all about
    • Getting Started - an in-depth getting started for beginners
    • API - other audiotool APis
    • Login - setup your app for others to use
    // Create a delay effect
    const delay = t.create("stompboxDelay", {
    feedbackFactor: 0.3,
    mix: 0.3,
    stepLengthIndex: 2,
    })

    // Create audio connection
    t.create("desktopAudioCable", {
    fromSocket: sourceDevice.fields.audioOutput.location,
    toSocket: delay.fields.audioInput.location,
    })
    // Create a note track
    const noteTrack = t.create("noteTrack", {
    orderAmongTracks: 0,
    player: heisenberg.location,
    })

    // Add a note region
    const noteRegion = t.create("noteRegion", {
    track: noteTrack.location,
    region: {
    positionTicks: Ticks.SemiBreve, // one whole note in a bar (4/4 time signature)
    durationTicks: Ticks.SemiBreve * 4,
    },
    })

    See utils.Ticks for constants representing musical time divisions.

    // Find all delay effects
    const delays = nexus.queryEntities.ofTypes("stompboxDelay").get()

    // Find connected devices
    const connected = nexus.queryEntities.pointedToBy
    .types("desktopAudioCable")
    .get()

    Ready? Start with our Getting Started guide!