Voyager computer beeps

2026-10-17

I wanted some custom sounds for my Home Assistant's voice assistant beeps, and Star Trek Voyager's computer has a good set of simple beeps for announcements, acknowledgements and other interactions. Using a sample reference, I built a small synthesiser to render beep sequences on demand.

Sourcing

I started by downloading some samples from TrekCore.com. I download "VOY Door Chime 1" and used Audacity to cut a single 10 ms slice out of the beep.

Playing it as an instrument

GarageBand's AU Sampler turns the looping slice into a MIDI instrument with pitch control. Because the slice loops, the envelope needs only three settings:

  • Attack: 0.015 s. Fades each beep in so it doesn't start with a click.
  • Hold: 60 s. Keeps the beep at full volume for as long as the note plays.
  • Release: 0.4 s. Fades each beep out after the note ends instead of cutting it off.

From here I can render short sequences and export them as .wav files for Home Assistant. But each one is a manual process, based on the imported sample.

Regenerating from source

Running a frequency analysis on the sample reveals that there are two sine waves, about a semitone and a half apart:

Pitch Frequency Volume
The note 1136 Hz Full
11/12 of the note 1041 Hz About half

Every note is those two tones played together: the note itself, plus a quieter tone slightly below it. Together they give the beep its slight wobble.

The sample's main tone sits a little sharp of C#6 (1109 Hz), so the synthesiser below tunes it to C#6 and uses standard note names.

The exported phrases also give away their timing. Every note starts and ends on a 62.5 ms grid, which is a 1/32 note at 120 bpm.

Beep sequencer

With those numbers, we no longer need the sample. This beep sequencer replicates the two sine waves, a 15 ms fade-in and a 0.4 s fade-out to closely match the GarageBand exports.

Pick a preset to hear one of my Home Assistant beeps, or draw your own. Click an empty cell to add a note, drag right to lengthen it, and click a note to remove it.

  1. C#7
  2. A#6
  3. G#6
  4. F#6
  5. D#6
  6. C#6
  7. A#5
  8. G#5
  9. F#5
  10. D#5
  11. C#5

A peek at the code

Behind the beep synthesiser component is the "voyager beep synth", purpose-built to generate beep sequences based on a string of notes.

typescript
export const SAMPLE_RATE = 44100
export const STEP_SECONDS = 0.0625
export const STEP_COUNT = 16

const ATTACK_SECONDS = 0.015
const RELEASE_TAU_SECONDS = 0.06
const RELEASE_SECONDS = 0.4

interface Partial {
  ratio: number
  level: number
}

const PARTIALS: Partial[] = [
  { ratio: 1, level: 1 },
  { ratio: 11 / 12, level: 0.5 },
]

interface Row {
  label: string
  midi: number
}

const NOTE_NAMES = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']

const PENTATONIC = [1, 3, 6, 8, 10]

export const ROWS: Row[] = Array.from({ length: 25 }, (_: unknown, i: number): number => 97 - i)
  .filter((midi: number): boolean => PENTATONIC.includes(midi % 12))
  .map(
    (midi: number): Row => ({
      label: `${NOTE_NAMES[midi % 12]}${Math.floor(midi / 12) - 1}`,
      midi,
    }),
  )

export interface Note {
  row: number
  start: number
  length: number
}

export interface Preset {
  name: string
  notes: Note[]
}

function notes(...entries: [string, number, number][]): Note[] {
  return entries.map(
    ([label, start, length]): Note => ({
      row: ROWS.findIndex((row: Row): boolean => row.label === label),
      start,
      length,
    }),
  )
}

export const PRESETS: Preset[] = [
  { name: 'Announce', notes: notes(['F#5', 0, 2], ['F#5', 3, 4], ['C#6', 8, 2]) },
  { name: 'Ack, Todo', notes: notes(['G#5', 0, 4], ['D#6', 5, 1], ['D#6', 7, 1]) },
  { name: 'Ack, Doing', notes: notes(['G#5', 0, 4], ['D#6', 5, 1], ['G#5', 7, 3]) },
  { name: 'Ack, Done', notes: notes(['D#6', 0, 1], ['D#6', 2, 2], ['G#5', 5, 4]) },
  { name: 'Ack, Failure', notes: notes(['D#6', 0, 1], ['D#6', 2, 2], ['C#5', 5, 6]) },
  { name: 'Res, Positive', notes: notes(['D#6', 0, 1], ['D#6', 2, 3]) },
  { name: 'Res, Negative', notes: notes(['C#5', 0, 1], ['C#5', 2, 4]) },
]

function envelopeAt(t: number, hold: number): number {
  if (t < hold) {
    return Math.min(t / ATTACK_SECONDS, 1)
  }
  return Math.exp(-(t - hold) / RELEASE_TAU_SECONDS)
}

function addNote(buffer: Float32Array, midi: number, start: number, hold: number): void {
  const frequency = 440 * 2 ** ((midi - 69) / 12)
  const first = Math.floor(start * SAMPLE_RATE)
  const length = Math.floor((hold + RELEASE_SECONDS) * SAMPLE_RATE)
  for (let n = 0; n < length && first + n < buffer.length; n++) {
    const t = n / SAMPLE_RATE
    let sample = 0
    for (const { ratio, level } of PARTIALS) {
      sample += level * Math.sin(2 * Math.PI * frequency * ratio * t)
    }
    buffer[first + n]! += sample * envelopeAt(t, hold)
  }
}

export function render(sequence: Note[]): Float32Array<ArrayBuffer> {
  const endStep = Math.max(0, ...sequence.map((note: Note): number => note.start + note.length))
  const buffer = new Float32Array(
    Math.ceil((endStep * STEP_SECONDS + RELEASE_SECONDS) * SAMPLE_RATE),
  )
  for (const note of sequence) {
    addNote(buffer, ROWS[note.row]!.midi, note.start * STEP_SECONDS, note.length * STEP_SECONDS)
  }
  const peak = buffer.reduce((max: number, s: number): number => Math.max(max, Math.abs(s)), 0)
  if (peak > 0) {
    buffer.forEach((s: number, i: number): void => {
      buffer[i] = (s * 0.95) / peak
    })
  }
  return buffer
}

export function encodeWav(samples: Float32Array): Blob {
  const view = new DataView(new ArrayBuffer(44 + samples.length * 2))
  const writeText = (offset: number, text: string): void => {
    for (let i = 0; i < text.length; i++) {
      view.setUint8(offset + i, text.charCodeAt(i))
    }
  }
  writeText(0, 'RIFF')
  view.setUint32(4, 36 + samples.length * 2, true)
  writeText(8, 'WAVE')
  writeText(12, 'fmt ')
  view.setUint32(16, 16, true)
  view.setUint16(20, 1, true)
  view.setUint16(22, 1, true)
  view.setUint32(24, SAMPLE_RATE, true)
  view.setUint32(28, SAMPLE_RATE * 2, true)
  view.setUint16(32, 2, true)
  view.setUint16(34, 16, true)
  writeText(36, 'data')
  view.setUint32(40, samples.length * 2, true)
  samples.forEach((s: number, i: number): void => {
    view.setInt16(44 + i * 2, Math.round(s * 32767), true)
  })
  return new Blob([view], { type: 'audio/wav' })
}

Overlapping notes add together, as they do on the sampler. The code scales the result to peak just below full volume, then plays it through the Web Audio API or writes it out as a 16-bit WAV file.


If you have feedback or questions about this article, let's catch up via Mastodon, LinkedIn, or email.

Now (2026-11-27)Data management lifecycle architectureLLM-assisted prompt optimisationDrawing diagrams with LLMsShare tokens instead of IDsSmartifying your devices