o1.sound.midi

package o1.sound.midi

Members list

Type members

Classlikes

enum Accidental(val shift: Int, val symbol: String)

An adjustment to the frequency of a Pitch: a Flat, a Sharp, or a Natural.

An adjustment to the frequency of a Pitch: a Flat, a Sharp, or a Natural.

Parameters

shift

the shift from the base frequency caused by the accidental (in semitones). A positive number means a higher frequency, a negative number a lower one.

symbol

a symbol describing the accidental: "#", "♭", or the empty string

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class Chord(notes: Seq[MusicElem]) extends MusicElem

Each instance of this class represents a combination of simultaneous Notes or other MusicElems.

Each instance of this class represents a combination of simultaneous Notes or other MusicElems.

Parameters

notes

the MusicElems that play simultanously in this chord

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait MusicElem
class Object
trait Matchable
class Any
Show all
object Chord

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Chord.type
case class Instrument(number: Int) extends MusicElem

A MusicElem that sets the instrument for the upcoming notes. The 128 main instruments of the standard MIDI list are supported. The companion object of this class provides constants that match those instruments.

A MusicElem that sets the instrument for the upcoming notes. The 128 main instruments of the standard MIDI list are supported. The companion object of this class provides constants that match those instruments.

Parameters

number

the number of a MIDI instrument between 0 and 127, inclusive

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait MusicElem
class Object
trait Matchable
class Any
Show all
object Instrument

This object provides a selection of constants that correspond to the 128 main instruments of the standard MIDI list. They are grouped in nested objects (Piano, Strings, etc.). The object PercussionChannel contains constants that correspond to the special sounds available on the MIDI percussion channel.

This object provides a selection of constants that correspond to the 128 main instruments of the standard MIDI list. They are grouped in nested objects (Piano, Strings, etc.). The object PercussionChannel contains constants that correspond to the special sounds available on the MIDI percussion channel.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Instrument.type

An error type that signals the underlying Java MIDI toolkit is unavailable.

An error type that signals the underlying Java MIDI toolkit is unavailable.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Music

This companion object of class Music provides additional options for creating Music objects.

This companion object of class Music provides additional options for creating Music objects.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Music.type
final case class Music(tempoSetting: Option[Int], voices: Seq[Voice])

Represents a piece of music that may consist of multiple Voices, which in turn consist of MusicElems such as notes.

Represents a piece of music that may consist of multiple Voices, which in turn consist of MusicElems such as notes.

Instead of using the constructor, you can use the companion object to construct a Music object from a string: e.g., Music("cdefg&>gfedc").

Parameters

tempoSetting

a tempo setting (in beats per minute) for the music, if there is one

voices

the voices that, played simultaneously, make up the piece of music; no more than MaxVoices plus a possible percussion track

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait MusicElem

A MusicElem is an element describes an aspect of MIDI music: a note, a chord, a pause, or a meta directive such as the change of an instrument. MusicElems put together make a Voice; voices put together compose a piece of Music.

A MusicElem is an element describes an aspect of MIDI music: a note, a chord, a pause, or a meta directive such as the change of an instrument. MusicElems put together make a Voice; voices put together compose a piece of Music.

Each MusicElem has a length that represents how long it takes to play it. The duration of the shortest audible sound playable with o1.sound.midi is one; other durations are linearly relative to that.

Attributes

See also
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Chord
class Instrument
class Note
class OctaveShift
object Pause
final case class Note(pitch: Pitch, length: Int, isStaccato: Boolean) extends MusicElem

Each instance of this class represents a single musical note at a set pitch.

Each instance of this class represents a single musical note at a set pitch.

Parameters

isStaccato

whether the note should be played staccato so that sound is shorter than its duration

length

the duration of the note: how long it takes to play it

pitch

the pitch of the note

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait MusicElem
class Object
trait Matchable
class Any
Show all
final case class OctaveShift(shift: Int) extends MusicElem

Each instance of this class is a directive that instructs the subsequent notes to play one octave higher or lower.

Each instance of this class is a directive that instructs the subsequent notes to play one octave higher or lower.

Parameters

shift

the direction of the shift: +1 means one octave higher, -1 one lower

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait MusicElem
class Object
trait Matchable
class Any
Show all
object Pause extends MusicElem

This object is a MusicElem that represents a short pause in the music.

This object is a MusicElem that represents a short pause in the music.

Attributes

Supertypes
trait MusicElem
class Object
trait Matchable
class Any
Self type
Pause.type
object Pitch

A companion for class Pitch.

A companion for class Pitch.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Pitch.type
final case class Pitch(name: Char, accidental: Accidental, octave: Option[Int])

A Pitch is a frequency for a note to be played at.

A Pitch is a frequency for a note to be played at.

Parameters

accidental

an adjustment to the base frequency

name

the name of the corresponding note, which provides the base frequency; one of "cdefgah" or their upper-case equivalents

octave

the number of the octave relative to DefaultOctave; e.g., -2 means two octaves lower than the default; passing in None has the same effect as passing in zero

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Sequencer

This object is an interface to the underlying MIDI sequencer. It is a thin Scala wrapper around the sequencer in the Java MIDI API.

This object is an interface to the underlying MIDI sequencer. It is a thin Scala wrapper around the sequencer in the Java MIDI API.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Sequencer.type
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.

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

Supertypes
class Object
trait Matchable
class Any
Self type
final case class Voice(notes: Seq[MusicElem], isPercussion: Boolean)

Represents a single voice within a piece of Music. A voice consists of MusicElems, primarily notes, in order.

Represents a single voice within a piece of Music. A voice consists of MusicElems, primarily notes, in order.

Parameters

isPercussion

whether the notes should not be interpresed as regular notes but as the special sounds defined for the MIDI standard’s percussion channel

notes

the notes (and possible other MusicElems) that compose this voice

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Types

An error type that signals the underlying Java MIDI toolkit is unavailable.

An error type that signals the underlying Java MIDI toolkit is unavailable.

Attributes

Value members

Concrete methods

Parses the given musical String and returns the result as a Music object. The String must be formatted as described in the package overview. Throws an IllegalArgumentException in case the String was invalid.

Parses the given musical String and returns the result as a Music object. The String must be formatted as described in the package overview. Throws an IllegalArgumentException in case the String was invalid.

Attributes

Parses the given musical String and plays the music that it describes on the MIDI synthesizer. The String must be formatted as described in the package overview. Prints out an error message in case the String was invalid.

Parses the given musical String and plays the music that it describes on the MIDI synthesizer. The String must be formatted as described in the package overview. Prints out an error message in case the String was invalid.

Attributes

def play(music: Music): Unit

Plays the music described by the given Music object on the MIDI synthesizer.

Plays the music described by the given Music object on the MIDI synthesizer.

Attributes

Concrete fields

The number (5) of the default octave to play notes from.

The number (5) of the default octave to play notes from.

Attributes

The default tempo (120 beats per minute). This is used by various methods in with this package when playing music, unless otherwise specified.

The default tempo (120 beats per minute). This is used by various methods in with this package when playing music, unless otherwise specified.

Attributes

A number (127) that corresponds to the highest possible volume setting available to this MIDI package. (The lowest is zero.)

A number (127) that corresponds to the highest possible volume setting available to this MIDI package. (The lowest is zero.)

Attributes

val MaxVoices: Int

the maximum number of simultaneous Voices supported by this library. This number doesn’t include the additional percussion track.

the maximum number of simultaneous Voices supported by this library. This number doesn’t include the additional percussion track.

Attributes

A number (80) that corresponds to a “medium” volume on the scale from 0 to 127 that is available via MIDI.

A number (80) that corresponds to a “medium” volume on the scale from 0 to 127 that is available via MIDI.

Attributes

Extensions

Extensions

extension (noteData: StringContext)

Enables the creation of Music objects via literals such as music"cdefg".

Enables the creation of Music objects via literals such as music"cdefg".

Attributes