gpojani

instrument · Bastl Kastle 2 · the real firmware, in the browser

Castello

The Kastle 2 is a small synthesizer and effects box by Bastl Instruments, from Brno. Its firmware is open source. This page runs that firmware: the same C++ that goes onto the module's RP2040 chip, compiled to WebAssembly, with the chip's pins, ADC, EEPROM, LEDs and second core rebuilt in software. Nothing here imitates the Kastle; the knobs feed its own code.

Ptractable
firmwareinout

off · press the power switch on the panel

The patchbay

Drag from an output pin to an input pin, or click one and then the other. Click a cable to pull it. Or choose here, where hand gives the jack a voltage you set.

Playing it

      notice

      What runs here. The source isbastl-instruments/kastle2, MIT licensed, © Bastl Instruments, Václav Mach and Marek Mach. Every file of the shared core is compiled as it is: the hardware layer that reads the knobs through an 8-way multiplexer, the base that runs the LFO, the envelope, the clock and the pattern generator, the MIDI handler, the EEPROM store, the DSP library, and the three apps. Emscripten turns it into a WebAssembly module of under 300 KB per firmware, with no imports at all.

      What is rebuilt. Where the firmware talks to the RP2040, it now talks to memory the page drives: the Pico SDK headers it includes are replaced by about two hundred lines that answer for the pins, the ADC and its interrupt, the I²C bus (the AT24C02 EEPROM and the NAU88C22 codec answer on it), the PWM outputs, the LED chain and the FIFO between the two cores. The I²S driver hands the audio callback the same 48-frame blocks of 16-bit samples at 44 kHz. The second core does its share of each block the moment the first core asks for it. Four lines of the firmware are edited: where the user data lives, the RAM section for fast code, and two friend declarations so the second core can be driven message by message. The build script, the shims and the patch are in this site's repository, under tools/kastle2-wasm.

      The patchbay. On the module, the 2×3 pin headers carry voltages between its own outputs and inputs. Here the LFO, the envelope and the pattern's CV are read from the PWM levels the firmware sets, the gate, sync and pulse from its output pins, and a cable puts that voltage, through the inverse of the firmware's own calibration, onto the ADC channel of the input. The pattern feeds G, R and C read three states, as on the module: open, + and −.

      Wave Bard's sounds. Bastl's factory samples are all rights reserved, so they are not here. The banks are synthesised when the page asks for them: drums, metal, voices with formants, Karplus–Strong strings, keys and dust, the tonal ones on C so the quantiser lands on notes. Your own files stay in your browser.

      Memory. The module keeps its settings in a 256-byte EEPROM; so does this page, in your browser's storage, one per firmware. Hold the two buttons for the settings layer, as on the module.

      esc

      ↑↓ move · ↵ open~ terminal · ? shortcuts

      gsh — gianni@gpojani

      manual · keyboard

      Shortcuts

      / ⌘K
      search & jump
      ~
      terminal
      C
      live channel (chat)
      J K
      next / previous transmission
      G then HZLANUXDSVW
      home · zoo · lab · atlas · network · unveiled · logic · drums · synth · vocoder · a world made of letters
      ?
      this sheet
      P
      pause / run the colony
      R
      reseed
      1–4
      Conway · HighLife · Day & Night · Anneal
      M
      listen to the colony
      ⟲ in the HUD
      homeostat: the colony matches your input variety
      click · shift-click · drag
      glider · glider gun · paint
      ↑↑↓↓←→←→BA
      first contact