com.sun.media.sound
Class SoftSynthesizer

java.lang.Object
  extended by com.sun.media.sound.SoftSynthesizer
All Implemented Interfaces:
AudioSynthesizer, com.sun.media.sound.ReferenceCountingDevice, javax.sound.midi.MidiDevice, javax.sound.midi.Synthesizer

public class SoftSynthesizer
extends java.lang.Object
implements AudioSynthesizer, com.sun.media.sound.ReferenceCountingDevice

The software synthesizer class.

Author:
Karl Helgason

Nested Class Summary
protected static class SoftSynthesizer.WeakAudioStream
           
 
Field Summary
protected  boolean agc_on
           
protected  SoftChannel[] channels
           
protected  boolean chorus_on
           
protected  java.lang.Object control_mutex
           
protected  SoftChannelProxy[] external_channels
           
protected static javax.sound.midi.MidiDevice.Info info
           
protected static java.lang.String INFO_DESCRIPTION
           
protected static java.lang.String INFO_NAME
           
protected static java.lang.String INFO_VENDOR
           
protected static java.lang.String INFO_VERSION
           
protected  boolean reverb_on
           
protected  int voice_allocation_mode
           
protected  int voiceIDCounter
           
protected  SoftSynthesizer.WeakAudioStream weakstream
           
 
Constructor Summary
SoftSynthesizer()
           
 
Method Summary
 void close()
           
protected  SoftInstrument findInstrument(int program, int bank, int channel)
           
 javax.sound.midi.Instrument[] getAvailableInstruments()
           
 javax.sound.midi.MidiChannel[] getChannels()
           
protected  float getControlRate()
           
 javax.sound.midi.Soundbank getDefaultSoundbank()
           
protected  int getDeviceID()
           
 javax.sound.midi.MidiDevice.Info getDeviceInfo()
           
 javax.sound.sampled.AudioFormat getFormat()
          Obtains the current format (encoding, sample rate, number of channels, etc.) of the synthesizer audio data.
protected  int getGeneralMidiMode()
           
 long getLatency()
           
 javax.sound.midi.Instrument[] getLoadedInstruments()
           
protected  SoftMainMixer getMainMixer()
           
 int getMaxPolyphony()
           
 int getMaxReceivers()
           
 int getMaxTransmitters()
           
 long getMicrosecondPosition()
           
 AudioSynthesizerPropertyInfo[] getPropertyInfo(java.util.Map<java.lang.String,java.lang.Object> info)
          Gets information about the possible properties for the synthesizer.
 javax.sound.midi.Receiver getReceiver()
           
 javax.sound.midi.Receiver getReceiverReferenceCounting()
           
 java.util.List<javax.sound.midi.Receiver> getReceivers()
           
 javax.sound.midi.Transmitter getTransmitter()
           
 javax.sound.midi.Transmitter getTransmitterReferenceCounting()
           
 java.util.List<javax.sound.midi.Transmitter> getTransmitters()
           
protected  SoftTuning getTuning(javax.sound.midi.Patch patch)
           
protected  int getVoiceAllocationMode()
           
protected  SoftVoice[] getVoices()
           
 javax.sound.midi.VoiceStatus[] getVoiceStatus()
           
 boolean isOpen()
           
 boolean isSoundbankSupported(javax.sound.midi.Soundbank soundbank)
           
 boolean loadAllInstruments(javax.sound.midi.Soundbank soundbank)
           
 boolean loadInstrument(javax.sound.midi.Instrument instrument)
           
 boolean loadInstruments(javax.sound.midi.Soundbank soundbank, javax.sound.midi.Patch[] patchList)
           
 void open()
           
 void open(javax.sound.sampled.SourceDataLine line, java.util.Map<java.lang.String,java.lang.Object> info)
          Opens the synthesizer and starts rendering audio into SourceDataLine.
 javax.sound.sampled.AudioInputStream openStream(javax.sound.sampled.AudioFormat targetFormat, java.util.Map<java.lang.String,java.lang.Object> info)
          Opens the synthesizer and renders audio into returned AudioInputStream.
 boolean remapInstrument(javax.sound.midi.Instrument from, javax.sound.midi.Instrument to)
           
protected  void removeReceiver(javax.sound.midi.Receiver recv)
           
protected  void setGeneralMidiMode(int gmmode)
           
 void unloadAllInstruments(javax.sound.midi.Soundbank soundbank)
           
 void unloadInstrument(javax.sound.midi.Instrument instrument)
           
 void unloadInstruments(javax.sound.midi.Soundbank soundbank, javax.sound.midi.Patch[] patchList)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFO_NAME

protected static final java.lang.String INFO_NAME
See Also:
Constant Field Values

INFO_VENDOR

protected static final java.lang.String INFO_VENDOR
See Also:
Constant Field Values

INFO_DESCRIPTION

protected static final java.lang.String INFO_DESCRIPTION
See Also:
Constant Field Values

INFO_VERSION

protected static final java.lang.String INFO_VERSION
See Also:
Constant Field Values

info

protected static final javax.sound.midi.MidiDevice.Info info

weakstream

protected SoftSynthesizer.WeakAudioStream weakstream

control_mutex

protected java.lang.Object control_mutex

voiceIDCounter

protected int voiceIDCounter

voice_allocation_mode

protected int voice_allocation_mode

reverb_on

protected boolean reverb_on

chorus_on

protected boolean chorus_on

agc_on

protected boolean agc_on

channels

protected SoftChannel[] channels

external_channels

protected SoftChannelProxy[] external_channels
Constructor Detail

SoftSynthesizer

public SoftSynthesizer()
Method Detail

removeReceiver

protected void removeReceiver(javax.sound.midi.Receiver recv)

getMainMixer

protected SoftMainMixer getMainMixer()

findInstrument

protected SoftInstrument findInstrument(int program,
                                        int bank,
                                        int channel)

getVoiceAllocationMode

protected int getVoiceAllocationMode()

getGeneralMidiMode

protected int getGeneralMidiMode()

setGeneralMidiMode

protected void setGeneralMidiMode(int gmmode)

getDeviceID

protected int getDeviceID()

getControlRate

protected float getControlRate()

getVoices

protected SoftVoice[] getVoices()

getTuning

protected SoftTuning getTuning(javax.sound.midi.Patch patch)

getLatency

public long getLatency()
Specified by:
getLatency in interface javax.sound.midi.Synthesizer

getFormat

public javax.sound.sampled.AudioFormat getFormat()
Description copied from interface: AudioSynthesizer
Obtains the current format (encoding, sample rate, number of channels, etc.) of the synthesizer audio data.

If the synthesizer is not open and has never been opened, it returns the default format.

Specified by:
getFormat in interface AudioSynthesizer
Returns:
current audio data format
See Also:
AudioFormat

getMaxPolyphony

public int getMaxPolyphony()
Specified by:
getMaxPolyphony in interface javax.sound.midi.Synthesizer

getChannels

public javax.sound.midi.MidiChannel[] getChannels()
Specified by:
getChannels in interface javax.sound.midi.Synthesizer

getVoiceStatus

public javax.sound.midi.VoiceStatus[] getVoiceStatus()
Specified by:
getVoiceStatus in interface javax.sound.midi.Synthesizer

isSoundbankSupported

public boolean isSoundbankSupported(javax.sound.midi.Soundbank soundbank)
Specified by:
isSoundbankSupported in interface javax.sound.midi.Synthesizer

loadInstrument

public boolean loadInstrument(javax.sound.midi.Instrument instrument)
Specified by:
loadInstrument in interface javax.sound.midi.Synthesizer

unloadInstrument

public void unloadInstrument(javax.sound.midi.Instrument instrument)
Specified by:
unloadInstrument in interface javax.sound.midi.Synthesizer

remapInstrument

public boolean remapInstrument(javax.sound.midi.Instrument from,
                               javax.sound.midi.Instrument to)
Specified by:
remapInstrument in interface javax.sound.midi.Synthesizer

getDefaultSoundbank

public javax.sound.midi.Soundbank getDefaultSoundbank()
Specified by:
getDefaultSoundbank in interface javax.sound.midi.Synthesizer

getAvailableInstruments

public javax.sound.midi.Instrument[] getAvailableInstruments()
Specified by:
getAvailableInstruments in interface javax.sound.midi.Synthesizer

getLoadedInstruments

public javax.sound.midi.Instrument[] getLoadedInstruments()
Specified by:
getLoadedInstruments in interface javax.sound.midi.Synthesizer

loadAllInstruments

public boolean loadAllInstruments(javax.sound.midi.Soundbank soundbank)
Specified by:
loadAllInstruments in interface javax.sound.midi.Synthesizer

unloadAllInstruments

public void unloadAllInstruments(javax.sound.midi.Soundbank soundbank)
Specified by:
unloadAllInstruments in interface javax.sound.midi.Synthesizer

loadInstruments

public boolean loadInstruments(javax.sound.midi.Soundbank soundbank,
                               javax.sound.midi.Patch[] patchList)
Specified by:
loadInstruments in interface javax.sound.midi.Synthesizer

unloadInstruments

public void unloadInstruments(javax.sound.midi.Soundbank soundbank,
                              javax.sound.midi.Patch[] patchList)
Specified by:
unloadInstruments in interface javax.sound.midi.Synthesizer

getDeviceInfo

public javax.sound.midi.MidiDevice.Info getDeviceInfo()
Specified by:
getDeviceInfo in interface javax.sound.midi.MidiDevice

getPropertyInfo

public AudioSynthesizerPropertyInfo[] getPropertyInfo(java.util.Map<java.lang.String,java.lang.Object> info)
Description copied from interface: AudioSynthesizer
Gets information about the possible properties for the synthesizer.

Specified by:
getPropertyInfo in interface AudioSynthesizer
Parameters:
info - a proposed list of tag/value pairs that will be sent on open.
Returns:
an array of AudioSynthesizerPropertyInfo objects describing possible properties. This array may be an empty array if no properties are required.

open

public void open()
          throws javax.sound.midi.MidiUnavailableException
Specified by:
open in interface javax.sound.midi.MidiDevice
Throws:
javax.sound.midi.MidiUnavailableException

open

public void open(javax.sound.sampled.SourceDataLine line,
                 java.util.Map<java.lang.String,java.lang.Object> info)
          throws javax.sound.midi.MidiUnavailableException
Description copied from interface: AudioSynthesizer
Opens the synthesizer and starts rendering audio into SourceDataLine.

An application opening a synthesizer explicitly with this call has to close the synthesizer by calling MidiDevice.close(). This is necessary to release system resources and allow applications to exit cleanly.

Note that some synthesizers, once closed, cannot be reopened. Attempts to reopen such a synthesizer will always result in a MidiUnavailableException.

Specified by:
open in interface AudioSynthesizer
Parameters:
line - which AudioSynthesizer writes output audio into. If line is null, then line from system default mixer is used.
info - a Map object containing properties for additional configuration supported by synthesizer. If info is null then default settings are used.
Throws:
javax.sound.midi.MidiUnavailableException - thrown if the synthesizer cannot be opened due to resource restrictions.
See Also:
MidiDevice.close(), MidiDevice.isOpen()

openStream

public javax.sound.sampled.AudioInputStream openStream(javax.sound.sampled.AudioFormat targetFormat,
                                                       java.util.Map<java.lang.String,java.lang.Object> info)
                                                throws javax.sound.midi.MidiUnavailableException
Description copied from interface: AudioSynthesizer
Opens the synthesizer and renders audio into returned AudioInputStream.

An application opening a synthesizer explicitly with this call has to close the synthesizer by calling MidiDevice.close(). This is necessary to release system resources and allow applications to exit cleanly.

Note that some synthesizers, once closed, cannot be reopened. Attempts to reopen such a synthesizer will always result in a MidiUnavailableException.

Specified by:
openStream in interface AudioSynthesizer
Parameters:
targetFormat - specifies the AudioFormat used in returned AudioInputStream.
info - a Map object containing properties for additional configuration supported by synthesizer. If info is null then default settings are used.
Throws:
javax.sound.midi.MidiUnavailableException - thrown if the synthesizer cannot be opened due to resource restrictions.
See Also:
MidiDevice.close(), MidiDevice.isOpen()

close

public void close()
Specified by:
close in interface javax.sound.midi.MidiDevice

isOpen

public boolean isOpen()
Specified by:
isOpen in interface javax.sound.midi.MidiDevice

getMicrosecondPosition

public long getMicrosecondPosition()
Specified by:
getMicrosecondPosition in interface javax.sound.midi.MidiDevice

getMaxReceivers

public int getMaxReceivers()
Specified by:
getMaxReceivers in interface javax.sound.midi.MidiDevice

getMaxTransmitters

public int getMaxTransmitters()
Specified by:
getMaxTransmitters in interface javax.sound.midi.MidiDevice

getReceiver

public javax.sound.midi.Receiver getReceiver()
                                      throws javax.sound.midi.MidiUnavailableException
Specified by:
getReceiver in interface javax.sound.midi.MidiDevice
Throws:
javax.sound.midi.MidiUnavailableException

getReceivers

public java.util.List<javax.sound.midi.Receiver> getReceivers()
Specified by:
getReceivers in interface javax.sound.midi.MidiDevice

getTransmitter

public javax.sound.midi.Transmitter getTransmitter()
                                            throws javax.sound.midi.MidiUnavailableException
Specified by:
getTransmitter in interface javax.sound.midi.MidiDevice
Throws:
javax.sound.midi.MidiUnavailableException

getTransmitters

public java.util.List<javax.sound.midi.Transmitter> getTransmitters()
Specified by:
getTransmitters in interface javax.sound.midi.MidiDevice

getReceiverReferenceCounting

public javax.sound.midi.Receiver getReceiverReferenceCounting()
                                                       throws javax.sound.midi.MidiUnavailableException
Specified by:
getReceiverReferenceCounting in interface com.sun.media.sound.ReferenceCountingDevice
Throws:
javax.sound.midi.MidiUnavailableException

getTransmitterReferenceCounting

public javax.sound.midi.Transmitter getTransmitterReferenceCounting()
                                                             throws javax.sound.midi.MidiUnavailableException
Specified by:
getTransmitterReferenceCounting in interface com.sun.media.sound.ReferenceCountingDevice
Throws:
javax.sound.midi.MidiUnavailableException