Top Inners Fields Constructors Methods
com.sun.media.jfxmediaimpl

pack-priv final Class NativeAudioClip

extends AudioClip
Class Inheritance
Imports
java.io.IOException, java.net.URI, .URISyntaxException, com.sun.media.jfxmedia.AudioClip, .MediaException, com.sun.media.jfxmedia.locator.Locator

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static NativeAudioClip.NativeAudioClipDisposer
private final Locator
private long
Inherited from com.sun.media.jfxmedia.AudioClip:
clipBalanceclipPanclipPriorityclipRateclipVolumeloopCountSAMPLE_FORMAT_S16BESAMPLE_FORMAT_S16LESAMPLE_FORMAT_S24BESAMPLE_FORMAT_S24LESAMPLE_FORMAT_S8SAMPLE_FORMAT_U16BESAMPLE_FORMAT_U16LESAMPLE_FORMAT_U24BESAMPLE_FORMAT_U24LESAMPLE_FORMAT_U8

Constructor Summary

AccessConstructor and Description
private
private
NativeAudioClip(byte[] data, int dataOffset, int sampleCount, int sampleFormat, int channels, int sampleRate)

Method Summary

Modifier and TypeMethod and Description
public AudioClip
append(AudioClip
The clip to be appended to the current clip.
clip
)

Implements abstract com.sun.media.jfxmedia.AudioClip.append.

Create a new AudioClip by appending the given clip to the current clip.

public static AudioClip
create(byte[]
Raw PCM samples stored in a byte array.
data
,
int
Byte offset into data that the sample data starts.
dataOffset
,
int
Number of LPCM samples stored in data.
sampleCount
,
int
Raw format that the LPCM data is being provided in. This may not be the actual format stored internally.
sampleFormat
,
int
The number of channels. Currently only two channel audio is supported, channels beyond two are simply dropped.
channels
,
int
Audio sample playbackRate of the raw LPCM data.
sampleRate
)

Hides com.sun.media.jfxmedia.AudioClip.create.

Generate a AudioClip from raw LPCM audio data.

public AudioClip
createSegment(double
The start time for the segment
startTime
,
double
The end time of the segment or -1.0 for the remainder of the source clip.
stopTime
)

Implements abstract com.sun.media.jfxmedia.AudioClip.createSegment.

Create a new AudioClip from a segment of an existing AudioClip.

public AudioClip
createSegment(int
The starting audio sample for the segment
startSample
,
int
The ending audio sample of the segment, or -1 for the remainder of the source clip.
endSample
)

Implements abstract com.sun.media.jfxmedia.AudioClip.createSegment.

Create a new AudioClip from a segment of an existing AudioClip.

public AudioClip
flatten()

Implements abstract com.sun.media.jfxmedia.AudioClip.flatten.

Creates a completely independent AudioClip.

pack-priv long
public static synchronized boolean
init()

public boolean
isPlaying()

Implements abstract com.sun.media.jfxmedia.AudioClip.isPlaying.

Test if any AudioClipPlayer has this AudioClip in its effect chain.

public static AudioClip
load(URI
URI to the desired clip.
source
)

Hides com.sun.media.jfxmedia.AudioClip.load.

Load an audio clip from the specified source URI.

private native NativeAudioClip
nacAppend(long handle, long otherClip)

private static native long
nacCreate(byte[] data, int dataOffset, int sampleCount, int sampleFormat, int channels, int sampleRate)

private native NativeAudioClip
nacCreateSegment(long handle, double startTime, double stopTime)

private native NativeAudioClip
nacCreateSegment(long handle, int startSample, int endSample)

private static native boolean
private native boolean
nacIsPlaying(long handle)

private static native long
nacLoad(Locator source)

private native void
nacPlay(long handle, double volume, double balance, double pan, double rate, int loopCount, int priority)

private native NativeAudioClip
nacResample(long handle, int startSample, int endSample, int sampleRate)

private native void
nacStop(long handle)

private static native void
private static native void
nacUnload(long handle)

public void
play()

Implements abstract com.sun.media.jfxmedia.AudioClip.play.

Play this AudioClip with the default parameters.

public void
play(double
Volume level to play this effect at. Valid volume range is 0.0 to 1.0, where 0.0 is effectively muted and 1.0 is full volume.
volume
)

Implements abstract com.sun.media.jfxmedia.AudioClip.play.

Play this AudioClip at the given volume level.

public void
play(double
Volume level to play this effect at. Valid volume range is 0.0 to 1.0, where 0.0 is effectively muted and 1.0 is full volume.
volume
,
double
Left/right balance or relative channel volumes for stereo effects.
balance
,
double
Playback rate multiplier. 1.0 will play back at the normal rate while 2.0 will double the rate.
rate
,
double
Left/right shift to be applied to the clip. A pan value of -1.0 means full left channel, 1.0 means full right channel, 0.0 has no effect.
pan
,
int
The number of times to play this clip, specify -1 to loop indefinitely
loopCount
,
int
Audio effect priority. Lower priority effects will be dropped first if too many effects are trying to play simultaneously.
priority
)

Implements abstract com.sun.media.jfxmedia.AudioClip.play.

Play this AudioClip at the given volume level and relative pitch.

public AudioClip
resample(int
starting sample to begin resampling at. The first sample is always zero, negative values are not allowed.
startSample
,
int
The last sample to resample or -1 for the remainder of the source clip.
endSample
,
int
The sample playbackRate to create the new AudioClip at.
newSampleRate
)

Implements abstract com.sun.media.jfxmedia.AudioClip.resample.

Create a new AudioClip from an existing clip by resampling a segment of the source clip to the specified sample playbackRate.

public void
stop()

Implements abstract com.sun.media.jfxmedia.AudioClip.stop.

Stops all playback of this AudioClip.

public static void
stopAllClips()

Hides com.sun.media.jfxmedia.AudioClip.stopAllClips.

Stop all AudioClips that are currently playing.

Inherited from com.sun.media.jfxmedia.AudioClip:
balanceloopCountpanplaybackRateprioritysetBalancesetLoopCountsetPansetPlaybackRatesetPrioritysetVolumevolume

Field Detail

clipDisposerback to summary
private static NativeAudioClip.NativeAudioClipDisposer clipDisposer
mediaSourceback to summary
private final Locator mediaSource
nativeHandleback to summary
private long nativeHandle

Constructor Detail

NativeAudioClipback to summary
private NativeAudioClip(Locator source)
NativeAudioClipback to summary
private NativeAudioClip(byte[] data, int dataOffset, int sampleCount, int sampleFormat, int channels, int sampleRate)

Method Detail

appendback to summary
public AudioClip append(AudioClip clip)

Implements abstract com.sun.media.jfxmedia.AudioClip.append.

Doc from com.sun.media.jfxmedia.AudioClip.append.

Create a new AudioClip by appending the given clip to the current clip. The new clip is independent of the two source clips. If the sample rates are mismatched, the new clip will contain at least one resampled copy of a source clip. Which clip is resampled is implementation dependent.

Parameters
clip:AudioClip

The clip to be appended to the current clip.

Returns:AudioClip

A new AudioClip that contains the concatenation of the two source clips.

Annotations
@Override
createback to summary
public static AudioClip create(byte[] data, int dataOffset, int sampleCount, int sampleFormat, int channels, int sampleRate)

Hides com.sun.media.jfxmedia.AudioClip.create.

Doc from com.sun.media.jfxmedia.AudioClip.create.

Generate a AudioClip from raw LPCM audio data. This can be used to programmatically create sound effects, either generated mathematically or loaded from some arbitrary source. Multiple channels must be interleaved properly, for stereo audio left channel is always first.

Parameters
data:byte[]

Raw PCM samples stored in a byte array.

dataOffset:int

Byte offset into data that the sample data starts.

sampleCount:int

Number of LPCM samples stored in data.

sampleFormat:int

Raw format that the LPCM data is being provided in. This may not be the actual format stored internally.

channels:int

The number of channels. Currently only two channel audio is supported, channels beyond two are simply dropped.

sampleRate:int

Audio sample playbackRate of the raw LPCM data.

Returns:AudioClip

A new AudioClip that can play the given raw LPCM audio data.

createSegmentback to summary
public AudioClip createSegment(double startTime, double stopTime)

Implements abstract com.sun.media.jfxmedia.AudioClip.createSegment.

Doc from com.sun.media.jfxmedia.AudioClip.createSegment.

Create a new AudioClip from a segment of an existing AudioClip. The new clip may copy or simply reference this existing clip, so be aware that this operation may have a severe memory usage impact for long segments. The default parameters are copied to the new clip. This variant specifies the start and end times of the segment. Specifying an end time beyond the duration of the clip will crop the new AudioClip to the end of the source clip. Specifying a start time less than zero or greater than end time is undefined and will return null.

Parameters
startTime:double

The start time for the segment

stopTime:double

The end time of the segment or -1.0 for the remainder of the source clip.

Returns:AudioClip

A new AudioClip instance containing only the specified segment of the source clip

Annotations
@Override
createSegmentback to summary
public AudioClip createSegment(int startSample, int endSample)

Implements abstract com.sun.media.jfxmedia.AudioClip.createSegment.

Doc from com.sun.media.jfxmedia.AudioClip.createSegment.

Create a new AudioClip from a segment of an existing AudioClip. The new clip may copy or simply reference this existing clip, so be aware that this operation may have a severe memory usage impact for long segments. The default parameters are copied to the new clip. This variant specifies the exact sample offsets of the segment, starting at sample zero. If endSample is greater than the number of samples in the source clip, it will be cropped to the last sample. Specifying a start sample less than zero or higher than endSample is undefined and will return null.

Parameters
startSample:int

The starting audio sample for the segment

endSample:int

The ending audio sample of the segment, or -1 for the remainder of the source clip.

Returns:AudioClip

A new AudioClip instance containing only the specified segment of the source clip

Annotations
@Override
flattenback to summary
public AudioClip flatten()

Implements abstract com.sun.media.jfxmedia.AudioClip.flatten.

Doc from com.sun.media.jfxmedia.AudioClip.flatten.

Creates a completely independent AudioClip. Any references contained will be copied and the references removed. The result will be a single AudioEffect containing all the audio data required to produce the effect. If the effect is already independent, then this will simply return the same AudioClip.

Returns:AudioClip

A new AudioClip that is independent of all other clips.

Annotations
@Override
getNativeHandleback to summary
pack-priv long getNativeHandle()
initback to summary
public static synchronized boolean init()
isPlayingback to summary
public boolean isPlaying()

Implements abstract com.sun.media.jfxmedia.AudioClip.isPlaying.

Doc from com.sun.media.jfxmedia.AudioClip.isPlaying.

Test if any AudioClipPlayer has this AudioClip in its effect chain.

Returns:boolean

true if at least one AudioClipPlayer is playing or has this AudioClip enqueued.

Annotations
@Override
loadback to summary
public static AudioClip load(URI source)

Hides com.sun.media.jfxmedia.AudioClip.load.

Doc from com.sun.media.jfxmedia.AudioClip.load.

Load an audio clip from the specified source URI. Currently supported formats are AIFF and WAV files. Audio data in the file must be raw PCM, loading compressed files is not supported at this time.

Parameters
source:URI

URI to the desired clip.

Returns:AudioClip

AudioClip ready to play.

nacAppendback to summary
private native NativeAudioClip nacAppend(long handle, long otherClip)
nacCreateback to summary
private static native long nacCreate(byte[] data, int dataOffset, int sampleCount, int sampleFormat, int channels, int sampleRate)
nacCreateSegmentback to summary
private native NativeAudioClip nacCreateSegment(long handle, double startTime, double stopTime)
nacCreateSegmentback to summary
private native NativeAudioClip nacCreateSegment(long handle, int startSample, int endSample)
nacInitback to summary
private static native boolean nacInit()
nacIsPlayingback to summary
private native boolean nacIsPlaying(long handle)
nacLoadback to summary
private static native long nacLoad(Locator source)
nacPlayback to summary
private native void nacPlay(long handle, double volume, double balance, double pan, double rate, int loopCount, int priority)
nacResampleback to summary
private native NativeAudioClip nacResample(long handle, int startSample, int endSample, int sampleRate)
nacStopback to summary
private native void nacStop(long handle)
nacStopAllback to summary
private static native void nacStopAll()
nacUnloadback to summary
private static native void nacUnload(long handle)
playback to summary
public void play()

Implements abstract com.sun.media.jfxmedia.AudioClip.play.

Doc from com.sun.media.jfxmedia.AudioClip.play.

Play this AudioClip with the default parameters. This is a fire and forget method, the clip will play exactly once using the default parameters.

Annotations
@Override
playback to summary
public void play(double volume)

Implements abstract com.sun.media.jfxmedia.AudioClip.play.

Doc from com.sun.media.jfxmedia.AudioClip.play.

Play this AudioClip at the given volume level. This is a fire and forget method, the clip will play exactly once using the given volume and default pitch and pan.

Parameters
volume:double

Volume level to play this effect at. Valid volume range is 0.0 to 1.0, where 0.0 is effectively muted and 1.0 is full volume.

Annotations
@Override
playback to summary
public void play(double volume, double balance, double rate, double pan, int loopCount, int priority)

Implements abstract com.sun.media.jfxmedia.AudioClip.play.

Doc from com.sun.media.jfxmedia.AudioClip.play.

Play this AudioClip at the given volume level and relative pitch. This is a fire and forget method, the clip will play exactly once using the given parameters.

Parameters
volume:double

Volume level to play this effect at. Valid volume range is 0.0 to 1.0, where 0.0 is effectively muted and 1.0 is full volume.

balance:double

Left/right balance or relative channel volumes for stereo effects.

rate:double

Playback rate multiplier. 1.0 will play back at the normal rate while 2.0 will double the rate.

pan:double

Left/right shift to be applied to the clip. A pan value of -1.0 means full left channel, 1.0 means full right channel, 0.0 has no effect.

loopCount:int

The number of times to play this clip, specify -1 to loop indefinitely

priority:int

Audio effect priority. Lower priority effects will be dropped first if too many effects are trying to play simultaneously.

Annotations
@Override
resampleback to summary
public AudioClip resample(int startSample, int endSample, int newSampleRate)

Implements abstract com.sun.media.jfxmedia.AudioClip.resample.

Doc from com.sun.media.jfxmedia.AudioClip.resample.

Create a new AudioClip from an existing clip by resampling a segment of the source clip to the specified sample playbackRate.

Parameters
startSample:int

starting sample to begin resampling at. The first sample is always zero, negative values are not allowed.

endSample:int

The last sample to resample or -1 for the remainder of the source clip.

newSampleRate:int

The sample playbackRate to create the new AudioClip at.

Returns:AudioClip

A new AudioClip that contains a copy of the source AudioClip resampled to the new sample playbackRate.

Annotations
@Override
stopback to summary
public void stop()

Implements abstract com.sun.media.jfxmedia.AudioClip.stop.

Doc from com.sun.media.jfxmedia.AudioClip.stop.

Stops all playback of this AudioClip.

Annotations
@Override
stopAllClipsback to summary
public static void stopAllClips()

Hides com.sun.media.jfxmedia.AudioClip.stopAllClips.

Doc from com.sun.media.jfxmedia.AudioClip.stopAllClips.

Stop all AudioClips that are currently playing.

com.sun.media.jfxmediaimpl back to summary

private Class NativeAudioClip.NativeAudioClipDisposer

extends Object
implements ResourceDisposer
Class Inheritance
  • java.lang.Object
  • com.sun.media.jfxmediaimpl.NativeAudioClip.NativeAudioClipDisposer
All Implemented Interfaces
com.sun.media.jfxmediaimpl.MediaDisposer.ResourceDisposer

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
disposeResource(Object
the resource that needs to be disposed of.
resource
)

Implements com.sun.media.jfxmediaimpl.MediaDisposer.ResourceDisposer.disposeResource.

Dispose the provided resource.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NativeAudioClipDisposerback to summary
private NativeAudioClipDisposer()

Method Detail

disposeResourceback to summary
public void disposeResource(Object resource)

Implements com.sun.media.jfxmediaimpl.MediaDisposer.ResourceDisposer.disposeResource.

Doc from com.sun.media.jfxmediaimpl.MediaDisposer.ResourceDisposer.disposeResource.

Dispose the provided resource.

Parameters
resource:Object

the resource that needs to be disposed of.

Annotations
@Override