- JavaScript 98.7%
- HTML 0.7%
- CSS 0.6%
orca-lang
Fork of ORCΛ for the browser with collaborative editing (via Yjs) and a pluggable trigger system for custom audio synthesis.
Development
# Install all dependencies
pnpm install
# Build all packages
pnpm build
# Run standalone app
pnpm dev
# Build specific package
pnpm --filter @orca-lang/core build
# Clean all builds
pnpm clean
Packages
NOTE: Packages have not been published to npm yet as this is very much a work in progress!
@orca-lang/core
Core Orca engine - headless, framework-agnostic sequencer runtime.
import { Orca, createLibrary, IO, Clock, Scheduler } from '@orca-lang/core'
@orca-lang/renderer
Canvas-based renderer for Orca.
import { OrcaRenderer, Cursor, Theme } from '@orca-lang/renderer'
@orca-lang/yjs-orca
Yjs collaboration bindings.
import { SharedState, RemoteCursors } from '@orca-lang/yjs-orca'
@orca-lang/standalone
Full-featured standalone web application with built-in WebRTC collaboration.
cd packages/standalone
pnpm signaling
pnpm dev # http://localhost:5173
Usage
Standalone Application
The easiest way to use Orca is via the standalone app:
cd packages/standalone
pnpm dev
Open http://localhost:5173 in your browser.
As Embeddable Library
import { Orca, createLibrary, IO, Clock, Scheduler } from '@orca-lang/core'
import { OrcaRenderer } from '@orca-lang/renderer'
// Create engine
const orca = new Orca(createLibrary(), { w: 256, h: 256 })
const scheduler = new Scheduler(new AudioContext())
const io = new IO(orca, scheduler)
const clock = new Clock(orca, io)
// Create renderer
const canvas = document.getElementById('orca')
const renderer = new OrcaRenderer(canvas, orca)
// Start
await io.start()
clock.start()
// Render loop
setInterval(() => {
orca.run()
renderer.render()
}, 250)
With Collaboration
import { SharedState, RemoteCursors } from '@orca-lang/yjs-orca'
import { WebrtcProvider } from 'y-webrtc'
import * as Y from 'yjs'
const ydoc = new Y.Doc()
const sharedState = new SharedState(orca, ydoc, {
onUpdate: () => renderer.render()
})
const provider = new WebrtcProvider('my-room', ydoc, {
signaling: ['wss://my-server.example']
})
const remoteCursors = new RemoteCursors(provider.awareness, () => {
renderer.render()
})
Features
Trigger System
This fork replaces the ; operator (used for sending UDP messages) for
triggering events in Javascript:
;[index][octave][note][velocity][length][arg1][arg2][arg3]
You can register a handler to receive these events:
client.setTriggerHandler((noteData) => {
console.log('Note:', noteData.note + noteData.octave)
console.log('Velocity:', noteData.velocityInt) // 0-35
console.log('Length:', noteData.lengthInt) // 0-35
console.log('Args:', noteData.arg1Int, noteData.arg2Int, noteData.arg3Int)
// Add your synthesis code here (Tone.js, Web Audio, Superdough, etc.)
})
See TRIGGERS.md for detailed examples.
Contributing
Bug reports and pull requests are welcome on Codeberg at the issues page. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
This project is based on ORCA (MIT License). Original copyright (c) 2017 by Hundredrabbits. Refer to LICENSE-ORCA.txt
Modifications and additions licensed under the GNU AGPLv3. Refer to LICENSE.txt