O1Library Docs
Fall 2026
Docs API

# Synthesizer

o1.sound.midi.Synthesizer
object Synthesizer

This object is an interface to the underlying MIDI synthesizer. It is a thin Scala wrapper around the synthesizer in the Java MIDI API. Uses the piano sound.

## Attributes

Graph
Supertypes
  class Object
  trait Matchable
  class Any
Self type
  Synthesizer.type

## Members list

### Value members

#### Concrete methods

def close(): Unit

Frees up resources associated with the synthesizer’s Java peer.

Frees up resources associated with the synthesizer’s Java peer.

## Attributes

def noteOff(note: Pitch): Unit

Terminates the playing of an ongoing note played with noteOn.

Terminates the playing of an ongoing note played with noteOn.

This method throws a `MidiUnavailableException` if no MIDI channels are available.

## Parameters

note

  the note to terminate.

## Attributes

def noteOn(note: Pitch, volume: Int): Unit

Plays a single note on the synthesized piano. The sound will fade away eventually or may be cut off using noteOff.

Plays a single note on the synthesized piano. The sound will fade away eventually or may be cut off using noteOff.

You must call open once before playing any music with this method, or no sound will play. The method throws a `MidiUnavailableException` if no MIDI channels are available.

## Parameters

note

  the note to play on the piano

volume

  the volume to play it at (between 0 and 127; if you pass in zero, this will work like noteOff)

## Attributes

def open(): Unit

Prepares the synthesizer for use. This method needs to be called before calling noteOn for the first time.

Prepares the synthesizer for use. This method needs to be called before calling noteOn for the first time.

## Attributes

#### Concrete fields

lazy val channels: Array[MidiChannel]

The channels available in the underlying MIDI synthesizer

The channels available in the underlying MIDI synthesizer

## Attributes

lazy val defaultChannel: MidiChannel

The first channel available in the underlying MIDI synthesizer. Accessing this value throws a `MidiUnavailableException` if no channels are available.

The first channel available in the underlying MIDI synthesizer. Accessing this value throws a `MidiUnavailableException` if no channels are available.

## Attributes

lazy val latency: Long

The latench of the underlying MIDI synthesizer, in milliseconds.

The latench of the underlying MIDI synthesizer, in milliseconds.

## Attributes

lazy val peer: Synthesizer

the underlying Java MIDI synthesizer

the underlying Java MIDI synthesizer

## Attributes