Package voltage.core

# Class VoltageSound

java.lang.Object
voltage.core.VoltageComponent
voltage.core.VoltageSound

Direct Known Subclasses:
  `VoltageSoundView`

public class VoltageSound extends VoltageComponent
A sound class

- ## Field Summary

  ### Fields inherited from class voltage.core.VoltageComponent

  `componentName, displayName`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VoltageSound(String name, String displayName, VoltageModule module)`
  Constructor Sounds will default to be resampled to the internal sample rate of 48kHz.
  `VoltageSound(String name, VoltageModule module)`
  Constructor Sounds will default to be resampled to the internal sample rate of 48kHz.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `CurrentOffset()`
  Get the current offset.
  `String`
  `GetMetaDataValue(String key)`
  Reads a meta data value in a file.
  `boolean`
  `IsPlaying()`
  Is it currently playing?
  `boolean`
  `IsStereo()`
  Is the sound stereo?
  `boolean`
  `LoadAudioData(float[] leftSamples, float[] rightSamples, int numSamples, int sampleRate)`
  Load a sound from audio data.
  `boolean`
  `LoadFromFile(String filePath)`
  Load a sound from a file.
  `boolean`
  `LoadFromMemory(byte[] data)`
  Load a sound from memory.
  `boolean`
  `LoadFromResource(String resourceName)`
  Load a sound from the module's resources.
  `boolean`
  `Looping()`
  Is the sound looping?
  `int`
  `NumSamples()`
  Returns the number of samples in the sound.
  `void`
  `Play()`
  Plays the sound.
  `void`
  `Play(boolean bDeleteWhenDone)`
  Play the sound and optionally delete it when done.
  `int`
  `ReadSamples(int numSamples, float[] leftSamples, float[] rightSamples)`
  Read samples from the sound.
  `double`
  `SampleRate()`
  `boolean`
  `SeekTo(int sampleOffset)`
  Seek to a sample offset.
  `boolean`
  `SeekToStart()`
  Seek to the beginning of the sound.
  `void`
  `SetLooping(boolean bLoop)`
  Set the sound to loop.
  `void`
  `SetResampling(boolean bResample)`
  Sets the samples to be resampled to the internal Voltage Modular sample rate of 48,000 Hz.
  `void`
  `Stop()`
  Stops a sound.

  ### Methods inherited from class voltage.core.VoltageComponent

  `AddChildComponent, GetComponentID, GetDisplayName, GetHeight, GetMaxValue, GetMinValue, GetRect, GetSkin, GetTooltipText, GetTransparency, GetUserProperty, GetValue, GetWidth, GetX, GetY, IsEnabled, IsVisible, RemoveChildComponent, SetCanBeAutomated, SetEnabled, SetPosition, SetRect, SetRect, SetSize, SetSkin, SetTransparency, SetUnits, SetUserProperty, SetValue, SetValue, SetValueNoNotification, SetVisible, SetWantsMouseNotifications, SetZOrder, SkewNormalizedValue, UpdateGUIValue, WantsMouseNotifications`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### VoltageSound

    public VoltageSound(String name, String displayName, VoltageModule module)
    Constructor Sounds will default to be resampled to the internal sample rate of 48kHz.
    Parameters:
      `name` - internal name of the control
      `displayName` - display name of the control.
      `module` - the module this belongs to.

  - ### VoltageSound

    public VoltageSound(String name, VoltageModule module)
    Constructor Sounds will default to be resampled to the internal sample rate of 48kHz.
    Parameters:
      `name` - internal name of the control
      `module` - the module this belongs to.

- ## Method Details

  - ### Play

    public void Play()
    Plays the sound. This actually plays the sound through the I/O Panel.

  - ### SeekToStart

    public boolean SeekToStart()
    Seek to the beginning of the sound.
    Returns:
      true if seeks to the beginning.

  - ### LoadFromMemory

    public boolean LoadFromMemory(byte[] data)
    Load a sound from memory.
    Parameters:
      `data` - a buffer of a sound file, not audio data. The formats supported are OGG, MP3, WAV and AIFF.
    Returns:
      true if successful.

  - ### LoadFromFile

    public boolean LoadFromFile(String filePath)
    Load a sound from a file.
    Parameters:
      `filePath` - the location of the file. The formats supported are OGG, MP3, WAV and AIFF.
    Returns:
      true if successful.

  - ### LoadFromResource

    public boolean LoadFromResource(String resourceName)
    Load a sound from the module's resources.
    Parameters:
      `resourceName` - the location of the file. The formats supported are OGG, MP3, WAV and AIFF. Embed a sound file as a resource using Module Designer.
    Returns:
      true if successful.

  - ### LoadAudioData

    public boolean LoadAudioData(float[] leftSamples, float[] rightSamples, int numSamples, int sampleRate)
    Load a sound from audio data.
    Parameters:
      `leftSamples` - a buffer of samples representing the left channel.
      `rightSamples` - a buffer of samples representing the right channel.
      `numSamples` - the number of samples that the buffers hold.
      `sampleRate` - the sample rate of the data.
    Returns:
      true if successful.

  - ### GetMetaDataValue

    public String GetMetaDataValue(String key)
    Reads a meta data value in a file.
    Parameters:
      `key` - can be a special chunk in the file. It depends on the file format. Some valid keys include: ENCODER, TITLE, ARTIST, ALBUM, COMMENT, DATE, GENRE, TRACKNUMBER,NumCuePoints, NumCueNotes, NumCueLabels, Cue(N)Identifier, Cue(N)Offset, CueLabel(N)Identifier, CueLabel(N)Text, CueNote(N)TimeStamp, CueNote(N)Identifier, CueNote(N)Text where (N) is the a number. INST, basc, cate
    Returns:
      the value meta data if it exists.

  - ### ReadSamples

    public int ReadSamples(int numSamples, float[] leftSamples, float[] rightSamples)
    Read samples from the sound.
    Parameters:
      `numSamples` - the number of samples to read.
      `leftSamples` - a buffer to receive the left channel samples.
      `rightSamples` - a buffer to receive the right channel samples.
    Returns:
      the number of samples read.

  - ### NumSamples

    public int NumSamples()
    Returns the number of samples in the sound.
    Returns:
      the number of samples.

  - ### SampleRate

    public double SampleRate()

  - ### SetResampling

    public void SetResampling(boolean bResample)
    Sets the samples to be resampled to the internal Voltage Modular sample rate of 48,000 Hz.
    Parameters:
      `bResample` - set to true to turn on resampling.

  - ### IsStereo

    public boolean IsStereo()
    Is the sound stereo?
    Returns:
      true if it's successful.

  - ### CurrentOffset

    public int CurrentOffset()
    Get the current offset.
    Returns:
      the current offset of the sound.

  - ### SeekTo

    public boolean SeekTo(int sampleOffset)
    Seek to a sample offset.
    Parameters:
      `sampleOffset` - the offset to seek to.
    Returns:
      true if successful.

  - ### Looping

    public boolean Looping()
    Is the sound looping?
    Returns:
      true if looping.

  - ### SetLooping

    public void SetLooping(boolean bLoop)
    Set the sound to loop.
    Parameters:
      `bLoop` - set to true to loop the sound.

  - ### IsPlaying

    public boolean IsPlaying()
    Is it currently playing?
    Returns:
      true if playing now.

  - ### Play

    public void Play(boolean bDeleteWhenDone)
    Play the sound and optionally delete it when done.
    Parameters:
      `bDeleteWhenDone` - set to true to have the sound deleted upon completion. Use to play it and forget about it.

  - ### Stop

    public void Stop()
    Stops a sound.