O1Library Docs
Fall 2023
Docs API

# Sound

o1.sound.sampled.Sound$
See the Sound companion trait
object Sound

This companion object of class `Sound` provides methods for creating new `Sound` objects. It has an alias in the top-level package o1, so it’s accessible to students simply via `import o1.*`.

## Attributes

Companion
  trait
Graph
Supertypes
  class Object
  trait Matchable
  class Any
Self type
  Sound.type

## Members list

### Value members

#### Concrete methods

def apply(id: String, volume: Float): Sound

Loads a sound sample from a URL or a local file. The sound needs to be in one of these formats: WAV, AIFF, AU, AIFC, SND.

Loads a sound sample from a URL or a local file. The sound needs to be in one of these formats: WAV, AIFF, AU, AIFC, SND.

## Parameters

id

  a path or URL that identifies the sound sample; this needs to be a classpath-relative file path or an URL, as specified for the parameter of `o1.util.tryForURL`

volume

  an adjustment to the sound’s volume: a positive number makes it louder, a negative one quieter. Pass in `Mute` to make the sound completely silent. If unspecified, defaults to zero.

## Attributes

Returns

  the sound; if a sound matching `id` could not be located, if the system doesn’t support sound, or if sound support is disabled, returns a silent Sound whose `isDefined` method returns `false`

def apply(url: URL, volume: Float): Sound

Loads a sound sample from the given URL. The sound needs to be in one of these formats: WAV, AIFF, AU, AIFC, SND. Throws an `IOException` if the URL is inaccessible.

Loads a sound sample from the given URL. The sound needs to be in one of these formats: WAV, AIFF, AU, AIFC, SND. Throws an `IOException` if the URL is inaccessible.

## Parameters

url

  a URL to a sound sample

volume

  an adjustment to the sound’s volume: a positive number makes it louder, a negative one quieter. Pass in `Mute` to make the sound completely silent.

## Attributes

Returns

  the sound; if the system doesn’t support sound, or if sound support is disabled, returns a silent Sound whose `isDefined` method returns `false`

### Givens

given derived$CanEqual: CanEqual[Sound, Sound]