Drawing the Instrument tab with your own UI
StrudelBassTab draws its buttons, select, sliders, checkbox and instrument picker with the editor's own
components. A host with a UI kit of its own passes the ones it wants in the ui prop, and
anything left out keeps the editor's. The tab is compact by default; add advanced for the whole
tab (see Embedding the Strudel editor).

What each component receives
Each one is a component with the editor's own props and events, so a wrapper maps them onto your
kit. The type is StrudelBassTabUi.
| Key | Props it receives | Events and slots | Used for |
|---|---|---|---|
Button | variant (default or outline), size (sm), disabled, title, aria-pressed | click, a default slot with the label | The calibration notes, export and import |
IconButton | title, aria-label, active, size, variant | click, a default slot with an icon | Play and the tuner |
Select | modelValue (a string), options ({ value, label }), disabled | update:modelValue | The audio input |
Slider | modelValue (a list of one number), min, max, step, label | update:modelValue with a list | The gate, Monitor, Synth and the string guess delay |
Checkbox | modelValue (a boolean) | update:modelValue | All frets and MIDI, in the advanced tab |
SoundPicker | label, modelValue (a sound name), groups ({ label, samples: { value, label }[] }[]) | update:modelValue with a sound name | The synth instrument; the editor passes its sounds as voiceGroups |
Turning parts off
The Instrument tab's props, beside ui and advanced:
| Prop | Default | Meaning |
|---|---|---|
instrument | none | bass or guitar; the tab follows it. Without it, the player's last pick, else the bass |
demo | false | Plays synthetic notes instead of an audio input, to try the tab without an instrument |
instrumentPicker | true | Shows the instrument dropdown. update:instrument reports each pick |
monitor | true | Offers Monitor, the raw bass through the speakers. false neither shows nor plays it |
synth | true | Offers Synth, each note played on a Strudel sound. false neither shows nor plays it |
soundPicker | true | Shows the synth's instrument picker. Turn it off when the host chooses the sound |
synthSound | none | The sound the synth plays, chosen by the host, such as gm_acoustic_grand_piano |
voiceGroups | none | The sounds the picker lists, under headings; useStrudelSounds() from the helpers gives them |
autoStart | false | Starts listening as soon as the tab is shown, without waiting for its start button |
defaultMonitorPercent | 100 | Monitor's volume until the player moves it, 0 to 200 |
defaultSynthPercent | 0 | Synth's volume until the player moves it, 0 to 200 |
With autoStart there may have been no tap yet, and a phone then keeps the sound off. The first
tap anywhere on the page turns it on.
Fonts
The tab reads two CSS custom properties, so a host sets its own type without reaching into the tab's classes:
| Property | Used for | Default |
|---|---|---|
--strudel-bass-note-font | The note heard, the tuner and the fretboard's string names | the mono font |
--strudel-bass-label-font | The slider labels, such as Gate, Monitor and Synth, and notes | inherited |
.my-bass-panel {
--strudel-bass-note-font: 'My Game Font', sans-serif;
--strudel-bass-label-font: 'My Game Font', sans-serif;
}
The text colours come from the editor's theme tokens, --color-foreground and
--color-muted-foreground, which a host can set on the same element.
The example
The files are in documentation/examples/bass-tab-ui:
one small wrapper per component and the tab that uses them. This is the tab:
<script setup lang="ts">
import { StrudelBassTab } from '@webgamekit/strudel-editor'
import type { StrudelBassTabUi } from '@webgamekit/strudel-editor'
import ExampleButton from './ExampleButton.vue'
import ExampleCheckbox from './ExampleCheckbox.vue'
import ExampleIconButton from './ExampleIconButton.vue'
import ExampleSelect from './ExampleSelect.vue'
import ExampleSlider from './ExampleSlider.vue'
import ExampleSoundPicker from './ExampleSoundPicker.vue'
defineProps<{ advanced?: boolean }>()
// Anything left out keeps the editor's own component.
const ui: StrudelBassTabUi = {
Button: ExampleButton,
IconButton: ExampleIconButton,
Select: ExampleSelect,
Slider: ExampleSlider,
Checkbox: ExampleCheckbox,
SoundPicker: ExampleSoundPicker
}
</script>
<template>
<StrudelBassTab :ui="ui" :advanced="advanced" />
</template>
A wrapper only turns the props above into your kit's. The slider is the one that needs a little translation, because the tab speaks in lists of one number:
<script setup lang="ts">
defineProps<{ modelValue?: number[]; min?: number; max?: number; step?: number; label?: string }>()
const emit = defineEmits<{ 'update:modelValue': [value: number[]] }>()
</script>
<template>
<input
type="range"
:value="modelValue?.[0]"
:min="min"
:max="max"
:step="step"
:aria-label="label"
@input="emit('update:modelValue', [Number(($event.target as HTMLInputElement).value)])"
/>
</template>
The advanced tab, and the moving picture
With advanced the checkboxes, the export and import buttons and the delay slider use your
components too. The animation below ticks All frets and MIDI and drags the delay slider.


In a game
games-lobby does the same with its LobbyUI components: a Button wrapper over LobbyUIButton, a
Slider wrapper over LobbyUISlider and so on, so the Bass section under the Rhythm controls
looks like the rest of the lobby.
Playing the bass during a round
The tab stops listening when it is closed, so a game that reads the bass during a round opens
its own input with createBassMidi. These helpers let the round sound as the tab did:
| Helper | Gives |
|---|---|
readBassPlayback(defaults?) | The Monitor gain and Synth level the player set; defaults apply until a slider moves |
createBassSynthPlayer(options) | The tab's own note by note synth: prepare() from a click, then noteOn and noteOff |
playStrudelSong(code, { mutedSounds }) | The song live with some sounds unheard, named as its MIDI tracks |
preloadStrudelSong(code, onProgress) | Fetches the song's recordings ahead, so it sounds from its first note |
import { createBassMidi } from '@webgamekit/bass-midi'
import {
createBassSynthPlayer,
playStrudelSong,
readBassPlayback
} from '@webgamekit/strudel-editor/helpers'
const { monitorVolume, synthVolume } = readBassPlayback({ monitorPercent: 0, synthPercent: 100 })
const synth = createBassSynthPlayer({
readSound: () => 'gm_electric_bass_finger',
readVolume: () => synthVolume,
onError: console.error
})
synth.prepare()
// The player's bass replaces the song's own when it can be heard; otherwise the song plays whole.
const isHeard = monitorVolume > 0 || synthVolume > 0
await playStrudelSong(songCode, { mutedSounds: isHeard ? [bassTrackName] : [] })
await createBassMidi({
monitorVolume,
onNoteOn: ({ midi, velocity }) => synth.noteOn(midi, velocity),
onNoteOff: () => synth.noteOff()
})
bassTrackName is the track's name in the MIDI from renderStrudelCodeToNotes: the sound it
plays, such as gm_electric_bass_finger. Drums share one drums track and cannot be muted this
way.