This commit is contained in:
David Dehaven 2016-08-19 08:47:12 -07:00
commit 9c8bd63007
321 changed files with 12839 additions and 8489 deletions

View File

@ -124,7 +124,9 @@ public class AquaProgressBarUI extends ProgressBarUI implements ChangeListener,
if (!progressBar.isIndeterminate()) return;
stopAnimationTimer();
// start the animation thread
startAnimationTimer();
if (progressBar.isDisplayable()) {
startAnimationTimer();
}
}
if ("JProgressBar.style".equals(prop)) {
@ -141,7 +143,9 @@ public class AquaProgressBarUI extends ProgressBarUI implements ChangeListener,
public void ancestorAdded(final AncestorEvent e) {
if (!progressBar.isIndeterminate()) return;
startAnimationTimer();
if (progressBar.isDisplayable()) {
startAnimationTimer();
}
}
public void ancestorMoved(final AncestorEvent e) { }

View File

@ -807,6 +807,18 @@ AWT_ASSERT_APPKIT_THREAD;
- (void)sendEvent:(NSEvent *)event {
if ([event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown) {
// Move parent windows to front and make sure that a child window is displayed
// in front of its nearest parent.
if (self.ownerWindow != nil) {
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
if (platformWindow != NULL) {
static JNF_MEMBER_CACHE(jm_orderAboveSiblings, jc_CPlatformWindow, "orderAboveSiblings", "()V");
JNFCallVoidMethod(env,platformWindow, jm_orderAboveSiblings);
(*env)->DeleteLocalRef(env, platformWindow);
}
}
[self orderChildWindows:YES];
NSPoint p = [NSEvent mouseLocation];
NSRect frame = [self.nsWindow frame];
@ -1159,6 +1171,16 @@ JNF_COCOA_ENTER(env);
NSWindow *nsWindow = OBJC(windowPtr);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[nsWindow orderBack:nil];
// Order parent windows
AWTWindow *awtWindow = (AWTWindow*)[nsWindow delegate];
while (awtWindow.ownerWindow != nil) {
awtWindow = awtWindow.ownerWindow;
if ([AWTWindow isJavaPlatformWindowVisible:awtWindow.nsWindow]) {
[awtWindow.nsWindow orderBack:nil];
}
}
// Order child windows
[(AWTWindow*)[nsWindow delegate] orderChildWindows:NO];
}];
JNF_COCOA_EXIT(env);

View File

@ -47,7 +47,7 @@ public abstract class TIFFColorConverter {
* @throws NullPointerException if {@code result} is
* {@code null}.
* @throws ArrayIndexOutOfBoundsException if
* {@code result.length < 3}.
* {@code result.length < 3}.
*/
public abstract void fromRGB(float r, float g, float b, float[] result);
@ -63,7 +63,7 @@ public abstract class TIFFColorConverter {
* @throws NullPointerException if {@code rgb} is
* {@code null}.
* @throws ArrayIndexOutOfBoundsException if
* {@code rgb.length&nbsp;&lt;&nbsp;3}.
* {@code rgb.length < 3}.
*/
public abstract void toRGB(float x0, float x1, float x2, float[] rgb);
}

View File

@ -353,7 +353,7 @@ public abstract class TIFFDecompressor {
* <p> The pixels in the source region to be copied are
* those with X coordinates of the form {@code activeSrcMinX +
* k*subsampleX}, where {@code k} is an integer such
* that {@code 0 &le; k &lt; dstWidth}.
* that {@code 0 <= k < dstWidth}.
*/
protected int activeSrcMinX;
@ -365,7 +365,7 @@ public abstract class TIFFDecompressor {
* <p> The pixels in the source region to be copied are
* those with Y coordinates of the form {@code activeSrcMinY +
* k*subsampleY}, where {@code k} is an integer such
* that {@code 0 &le; k &lt; dstHeight}.
* that {@code 0 <= k < dstHeight}.
*/
protected int activeSrcMinY;

View File

@ -49,6 +49,45 @@ public class TIFFIFD extends TIFFDirectory {
private long stripOrTileOffsetsPosition = -1;
private long lastPosition = -1;
/**
* Converts a {@code TIFFDirectory} to a {@code TIFFIFD}.
*/
public static TIFFIFD getDirectoryAsIFD(TIFFDirectory dir) {
if(dir instanceof TIFFIFD) {
return (TIFFIFD)dir;
}
TIFFIFD ifd = new TIFFIFD(Arrays.asList(dir.getTagSets()),
dir.getParentTag());
TIFFField[] fields = dir.getTIFFFields();
int numFields = fields.length;
for(int i = 0; i < numFields; i++) {
TIFFField f = fields[i];
TIFFTag tag = f.getTag();
if(tag.isIFDPointer()) {
TIFFDirectory subDir = null;
if (f.hasDirectory()) {
subDir = f.getDirectory();
} else if (f.getData() instanceof TIFFDirectory) {
subDir = (TIFFDirectory)f.getData();
}
if (subDir != null) {
TIFFDirectory subIFD = getDirectoryAsIFD(subDir);
f = new TIFFField(tag, f.getType(), (long)f.getCount(),
subIFD);
} else {
f = null;
}
}
if (f != null) {
ifd.addTIFFField(f);
}
}
return ifd;
}
public static TIFFTag getTag(int tagNumber, List<TIFFTagSet> tagSets) {
Iterator<TIFFTagSet> iter = tagSets.iterator();
while (iter.hasNext()) {
@ -704,7 +743,7 @@ public class TIFFIFD extends TIFFDirectory {
pos = nextSpace;
if (tag.isIFDPointer() && f.hasDirectory()) {
TIFFIFD subIFD = (TIFFIFD)f.getDirectory();
TIFFIFD subIFD = getDirectoryAsIFD(f.getDirectory());
subIFD.writeToStream(stream);
nextSpace = subIFD.lastPosition;
} else {

View File

@ -132,7 +132,7 @@ public class TIFFImageMetadata extends IIOMetadata {
if (tag == null) {
node = f.getAsNativeNode();
} else if (tag.isIFDPointer() && f.hasDirectory()) {
TIFFIFD subIFD = (TIFFIFD)f.getDirectory();
TIFFIFD subIFD = TIFFIFD.getDirectoryAsIFD(f.getDirectory());
// Recurse
node = getIFDAsTree(subIFD, tag.getName(), tag.getNumber());
@ -1465,8 +1465,14 @@ public class TIFFImageMetadata extends IIOMetadata {
String className = st.nextToken();
Object o = null;
Class<?> setClass = null;
try {
Class<?> setClass = Class.forName(className);
ClassLoader cl = TIFFImageMetadata.class.getClassLoader();
setClass = Class.forName(className, false, cl);
if (!TIFFTagSet.class.isAssignableFrom(setClass)) {
fatal(node, "TagSets in IFD must be subset of"
+ " TIFFTagSet class");
}
Method getInstanceMethod =
setClass.getMethod("getInstance", (Class[])null);
o = getInstanceMethod.invoke(null, (Object[])null);

View File

@ -35,6 +35,7 @@ import java.awt.image.ComponentColorModel;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.awt.image.SampleModel;
import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteOrder;
import java.util.ArrayList;
@ -189,8 +190,8 @@ public class TIFFImageReader extends ImageReader {
// Seek to start of first IFD
long offset = stream.readUnsignedInt();
imageStartPosition.add(Long.valueOf(offset));
stream.seek(offset);
imageStartPosition.add(Long.valueOf(offset));
} catch (IOException e) {
throw new IIOException("I/O error reading header!", e);
}
@ -201,10 +202,10 @@ public class TIFFImageReader extends ImageReader {
private int locateImage(int imageIndex) throws IIOException {
readHeader();
try {
// Find closest known index
int index = Math.min(imageIndex, imageStartPosition.size() - 1);
// Find closest known index
int index = Math.min(imageIndex, imageStartPosition.size() - 1);
try {
// Seek to that position
Long l = imageStartPosition.get(index);
stream.seek(l.longValue());
@ -212,6 +213,11 @@ public class TIFFImageReader extends ImageReader {
// Skip IFDs until at desired index or last image found
while (index < imageIndex) {
int count = stream.readUnsignedShort();
// If zero-entry IFD, decrement the index and exit the loop
if (count == 0) {
imageIndex = index > 0 ? index - 1 : 0;
break;
}
stream.skipBytes(12 * count);
long offset = stream.readUnsignedInt();
@ -219,12 +225,17 @@ public class TIFFImageReader extends ImageReader {
return index;
}
imageStartPosition.add(Long.valueOf(offset));
stream.seek(offset);
imageStartPosition.add(Long.valueOf(offset));
++index;
}
} catch (IOException e) {
throw new IIOException("Couldn't seek!", e);
} catch (EOFException eofe) {
forwardWarningMessage("Ignored " + eofe);
// Ran off the end of stream: decrement index
imageIndex = index > 0 ? index - 1 : 0;
} catch (IOException ioe) {
throw new IIOException("Couldn't seek!", ioe);
}
if (currIndex != imageIndex) {

View File

@ -1478,7 +1478,7 @@ public class TIFFImageWriter extends ImageWriter {
(ExifParentTIFFTagSet.TAG_EXIF_IFD_POINTER);
if(f != null && f.hasDirectory()) {
// Retrieve the Exif IFD.
exifIFD = (TIFFIFD)f.getDirectory();
exifIFD = TIFFIFD.getDirectoryAsIFD(f.getDirectory());
} else if(isPrimaryIFD) {
// Create the Exif IFD.
List<TIFFTagSet> exifTagSets = new ArrayList<TIFFTagSet>(1);
@ -3622,6 +3622,8 @@ public class TIFFImageWriter extends ImageWriter {
streamMetadata = null;
imageMetadata = null;
isRescaling = false;
isWritingSequence = false;
isWritingEmpty = false;
isInsertingEmpty = false;

View File

@ -49,7 +49,8 @@ public abstract class TIFFMetadataFormat implements IIOMetadataFormat {
}
try {
ResourceBundle bundle =
ResourceBundle.getBundle(resourceBaseName, locale);
ResourceBundle.getBundle(resourceBaseName, locale,
this.getClass().getModule());
return bundle.getString(key);
} catch (MissingResourceException e) {
return null;

View File

@ -657,7 +657,6 @@ class XPStyle {
protected void paintToImage(Component c, Image image, Graphics g,
int w, int h, Object[] args) {
boolean accEnabled = false;
Skin skin = (Skin)args[0];
Part part = skin.part;
State state = (State)args[1];
@ -668,6 +667,8 @@ class XPStyle {
c = skin.component;
}
BufferedImage bi = (BufferedImage)image;
w = bi.getWidth();
h = bi.getHeight();
WritableRaster raster = bi.getRaster();
DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer();

View File

@ -32,7 +32,6 @@ import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineUnavailableException;
/**
* AbstractDataLine
*
@ -147,36 +146,35 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
}
}
public final void open(AudioFormat format) throws LineUnavailableException {
open(format, AudioSystem.NOT_SPECIFIED);
}
/**
* This implementation always returns 0.
*/
@Override
public int available() {
return 0;
}
/**
* This implementation does nothing.
*/
@Override
public void drain() {
if (Printer.trace) Printer.trace("AbstractDataLine: drain");
}
/**
* This implementation does nothing.
*/
@Override
public void flush() {
if (Printer.trace) Printer.trace("AbstractDataLine: flush");
}
@Override
public final void start() {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized(mixer) {
@ -200,7 +198,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
if (Printer.trace) Printer.trace("< "+getClass().getName()+".start() - AbstractDataLine");
}
@Override
public final void stop() {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
@ -245,15 +243,17 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
// in MixerSourceLine and MixerClip, and I want to touch as little
// code as possible to change isStarted() back to isRunning().
@Override
public final boolean isRunning() {
return started;
}
@Override
public final boolean isActive() {
return active;
}
@Override
public final long getMicrosecondPosition() {
long microseconds = getLongFramePosition();
@ -263,12 +263,12 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
return microseconds;
}
@Override
public final AudioFormat getFormat() {
return format;
}
@Override
public final int getBufferSize() {
return bufferSize;
}
@ -283,11 +283,11 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
/**
* This implementation returns AudioSystem.NOT_SPECIFIED.
*/
@Override
public final float getLevel() {
return (float)AudioSystem.NOT_SPECIFIED;
}
// HELPER METHODS
/**
@ -317,19 +317,12 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
synchronized (this) {
//if (Printer.debug) Printer.debug(" AbstractDataLine: setActive: this.active: " + this.active);
//if (Printer.debug) Printer.debug(" active: " + active);
if (this.active != active) {
this.active = active;
//sendEvents = true;
}
}
//if (Printer.debug) Printer.debug(" this.active: " + this.active);
//if (Printer.debug) Printer.debug(" sendEvents: " + sendEvents);
// $$kk: 11.19.99: take ACTIVE / INACTIVE / EOM events out;
// putting them in is technically an API change.
// do not generate ACTIVE / INACTIVE events for now
@ -356,18 +349,12 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
synchronized (this) {
//if (Printer.debug) Printer.debug(" AbstractDataLine: setStarted: this.started: " + this.started);
//if (Printer.debug) Printer.debug(" started: " + started);
if (this.started != started) {
this.started = started;
sendEvents = true;
}
}
//if (Printer.debug) Printer.debug(" this.started: " + this.started);
//if (Printer.debug) Printer.debug(" sendEvents: " + sendEvents);
if (sendEvents) {
if (started) {
@ -379,7 +366,6 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
if (Printer.trace) Printer.trace("< AbstractDataLine: setStarted completed");
}
/**
* This method generates a STOP event and sets the started state to false.
* It is here for historic reasons when an EOM event existed.
@ -393,9 +379,6 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
if (Printer.trace) Printer.trace("< AbstractDataLine: setEOM() completed");
}
// OVERRIDES OF ABSTRACT LINE METHODS
/**
@ -404,6 +387,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
* line is open, this should return quietly because the values
* requested will match the current ones.
*/
@Override
public final void open() throws LineUnavailableException {
if (Printer.trace) Printer.trace("> "+getClass().getName()+".open() - AbstractDataLine");
@ -413,11 +397,11 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
if (Printer.trace) Printer.trace("< "+getClass().getName()+".open() - AbstractDataLine");
}
/**
* This should also stop the line. The closed line should not be running or active.
* After we close the line, we reset the format and buffer size to the defaults.
*/
@Override
public final void close() {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized (mixer) {
@ -445,12 +429,6 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine {
if (Printer.trace) Printer.trace("< "+getClass().getName()+".close() - in AbstractDataLine");
}
// IMPLEMENTATIONS OF ABSTRACT LINE ABSTRACE METHODS
// ABSTRACT METHODS
abstract void implOpen(AudioFormat format, int bufferSize) throws LineUnavailableException;
abstract void implClose();

View File

@ -36,7 +36,6 @@ import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
import javax.sound.sampled.LineUnavailableException;
/**
* AbstractLine
*
@ -72,19 +71,19 @@ abstract class AbstractLine implements Line {
this.controls = controls;
}
// LINE METHODS
@Override
public final Line.Info getLineInfo() {
return info;
}
@Override
public final boolean isOpen() {
return open;
}
@Override
public final void addLineListener(LineListener listener) {
synchronized(listeners) {
if ( ! (listeners.contains(listener)) ) {
@ -93,22 +92,22 @@ abstract class AbstractLine implements Line {
}
}
/**
* Removes an audio listener.
* @param listener listener to remove
*/
@Override
public final void removeLineListener(LineListener listener) {
listeners.removeElement(listener);
}
/**
* Obtains the set of controls supported by the
* line. If no controls are supported, returns an
* array of length 0.
* @return control set
*/
@Override
public final Control[] getControls() {
Control[] returnedArray = new Control[controls.length];
@ -119,7 +118,7 @@ abstract class AbstractLine implements Line {
return returnedArray;
}
@Override
public final boolean isControlSupported(Control.Type controlType) {
// protect against a NullPointerException
if (controlType == null) {
@ -135,7 +134,7 @@ abstract class AbstractLine implements Line {
return false;
}
@Override
public final Control getControl(Control.Type controlType) {
// protect against a NullPointerException
if (controlType != null) {
@ -150,10 +149,8 @@ abstract class AbstractLine implements Line {
throw new IllegalArgumentException("Unsupported control type: " + controlType);
}
// HELPER METHODS
/**
* This method sets the open state and generates
* events if it changes.
@ -182,7 +179,6 @@ abstract class AbstractLine implements Line {
if (Printer.trace) Printer.trace("< "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open);
}
/**
* Send line events.
*/
@ -190,7 +186,6 @@ abstract class AbstractLine implements Line {
getEventDispatcher().sendAudioEvents(event, listeners);
}
/**
* This is an error in the API: getFramePosition
* should return a long value. At CD quality,
@ -200,7 +195,6 @@ abstract class AbstractLine implements Line {
return (int) getLongFramePosition();
}
/**
* Return the frame position in a long value
* This implementation returns AudioSystem.NOT_SPECIFIED.
@ -209,7 +203,6 @@ abstract class AbstractLine implements Line {
return AudioSystem.NOT_SPECIFIED;
}
// $$kk: 06.03.99: returns the mixer used in construction.
// this is a hold-over from when there was a public method like
// this on line and should be fixed!!
@ -232,8 +225,8 @@ abstract class AbstractLine implements Line {
}
}
// ABSTRACT METHODS
@Override
public abstract void open() throws LineUnavailableException;
@Override
public abstract void close();
}

View File

@ -26,10 +26,17 @@
package com.sun.media.sound;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
import java.util.List;
import javax.sound.midi.*;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiDeviceReceiver;
import javax.sound.midi.MidiDeviceTransmitter;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Receiver;
import javax.sound.midi.Transmitter;
/**
@ -43,11 +50,8 @@ import javax.sound.midi.*;
*/
abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice {
// STATIC VARIABLES
private static final boolean TRACE_TRANSMITTER = false;
// INSTANCE VARIABLES
private ArrayList<Receiver> receiverList;
private TransmitterList transmitterList;
@ -62,7 +66,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
private final MidiDevice.Info info;
// DEVICE STATE
private volatile boolean open;
@ -73,15 +76,10 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
private List<Object> openKeepingObjects;
/**
* This is the device handle returned from native code
* This is the device handle returned from native code.
*/
protected volatile long id;
// CONSTRUCTOR
/**
* Constructs an AbstractMidiDevice with the specified info object.
* @param info the description of the device
@ -99,9 +97,9 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if(Printer.trace) Printer.trace("<< AbstractMidiDevice CONSTRUCTOR completed");
}
// MIDI DEVICE METHODS
@Override
public final MidiDevice.Info getDeviceInfo() {
return info;
}
@ -111,6 +109,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
* opened the device implicitly from closing it. The only way to close the device after
* this call is a call to close().
*/
@Override
public final void open() throws MidiUnavailableException {
if (Printer.trace) Printer.trace("> AbstractMidiDevice: open()");
synchronized(this) {
@ -120,8 +119,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if (Printer.trace) Printer.trace("< AbstractMidiDevice: open() completed");
}
/** Open the device implicitly.
* This method is intended to be used by AbstractReceiver
* and BasicTransmitter. Actually, it is called by getReceiverReferenceCounting() and
@ -146,7 +143,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if (Printer.trace) Printer.trace("< AbstractMidiDevice: openInternal() completed");
}
private void doOpen() throws MidiUnavailableException {
if (Printer.trace) Printer.trace("> AbstractMidiDevice: doOpen()");
synchronized(this) {
@ -158,7 +154,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if (Printer.trace) Printer.trace("< AbstractMidiDevice: doOpen() completed");
}
@Override
public final void close() {
if (Printer.trace) Printer.trace("> AbstractMidiDevice: close()");
synchronized (this) {
@ -168,7 +164,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if (Printer.trace) Printer.trace("< AbstractMidiDevice: close() completed");
}
/** Close the device for an object that implicitely opened it.
* This method is intended to be used by Transmitter.close() and Receiver.close().
* Those methods should pass this for the object parameter. Since Transmitters or Receivers
@ -196,7 +191,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if (Printer.trace) Printer.trace("< AbstractMidiDevice: closeInternal() completed");
}
public final void doClose() {
if (Printer.trace) Printer.trace("> AbstractMidiDevice: doClose()");
synchronized(this) {
@ -208,12 +202,11 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
if (Printer.trace) Printer.trace("< AbstractMidiDevice: doClose() completed");
}
@Override
public final boolean isOpen() {
return open;
}
protected void implClose() {
synchronized (traRecLock) {
if (receiverList != null) {
@ -230,21 +223,21 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
/**
* This implementation always returns -1.
* Devices that actually provide this should over-ride
* this method.
*/
@Override
public long getMicrosecondPosition() {
return -1;
}
/** Return the maximum number of Receivers supported by this device.
Depending on the return value of hasReceivers(), this method returns either 0 or -1.
Subclasses should rather override hasReceivers() than override this method.
*/
@Override
public final int getMaxReceivers() {
if (hasReceivers()) {
return -1;
@ -253,11 +246,11 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
/** Return the maximum number of Transmitters supported by this device.
Depending on the return value of hasTransmitters(), this method returns either 0 or -1.
Subclasses should override hasTransmitters().
*/
@Override
public final int getMaxTransmitters() {
if (hasTransmitters()) {
return -1;
@ -266,7 +259,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
/** Retrieve a Receiver for this device.
This method returns the value returned by createReceiver(), if it doesn't throw
an exception. Subclasses should rather override createReceiver() than override
@ -274,6 +266,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
If createReceiver returns a Receiver, it is added to the internal list
of Receivers (see getReceiversList)
*/
@Override
public final Receiver getReceiver() throws MidiUnavailableException {
Receiver receiver;
synchronized (traRecLock) {
@ -283,7 +276,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return receiver;
}
@Override
@SuppressWarnings("unchecked") // Cast of result of clone
public final List<Receiver> getReceivers() {
List<Receiver> recs;
@ -298,12 +291,12 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return recs;
}
/**
* This implementation uses createTransmitter, which may throw an exception.
* If a transmitter is returned in createTransmitter, it is added to the internal
* TransmitterList
*/
@Override
public final Transmitter getTransmitter() throws MidiUnavailableException {
Transmitter transmitter;
synchronized (traRecLock) {
@ -313,7 +306,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return transmitter;
}
@Override
@SuppressWarnings("unchecked") // Cast of result of clone
public final List<Transmitter> getTransmitters() {
List<Transmitter> tras;
@ -328,19 +321,16 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return tras;
}
// HELPER METHODS
final long getId() {
return id;
}
// REFERENCE COUNTING
/** Retrieve a Receiver and open the device implicitly.
This method is called by MidiSystem.getReceiver().
*/
@Override
public final Receiver getReceiverReferenceCounting()
throws MidiUnavailableException {
/* Keep this order of commands! If getReceiver() throws an exception,
@ -354,10 +344,10 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return receiver;
}
/** Retrieve a Transmitter and open the device implicitly.
This method is called by MidiSystem.getTransmitter().
*/
@Override
public final Transmitter getTransmitterReferenceCounting()
throws MidiUnavailableException {
/* Keep this order of commands! If getTransmitter() throws an exception,
@ -371,7 +361,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return transmitter;
}
/** Return the list of objects that have opened the device implicitely.
*/
private synchronized List<Object> getOpenKeepingObjects() {
@ -381,23 +370,19 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return openKeepingObjects;
}
// RECEIVER HANDLING METHODS
/** Return the internal list of Receivers, possibly creating it first.
*/
private List<Receiver> getReceiverList() {
synchronized (traRecLock) {
if (receiverList == null) {
receiverList = new ArrayList<Receiver>();
receiverList = new ArrayList<>();
}
}
return receiverList;
}
/** Returns if this device supports Receivers.
Subclasses that use Receivers should override this method to
return true. They also should override createReceiver().
@ -408,7 +393,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return false;
}
/** Create a Receiver object.
throwing an exception here means that Receivers aren't enabled.
Subclasses that use Receivers should override this method with
@ -420,8 +404,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
throw new MidiUnavailableException("MIDI IN receiver not available");
}
// TRANSMITTER HANDLING
/** Return the internal list of Transmitters, possibly creating it first.
@ -435,7 +417,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return transmitterList;
}
/** Returns if this device supports Transmitters.
Subclasses that use Transmitters should override this method to
return true. They also should override createTransmitter().
@ -446,7 +427,6 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
return false;
}
/** Create a Transmitter object.
throwing an exception here means that Transmitters aren't enabled.
Subclasses that use Transmitters should override this method with
@ -458,20 +438,16 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
throw new MidiUnavailableException("MIDI OUT transmitter not available");
}
// ABSTRACT METHODS
protected abstract void implOpen() throws MidiUnavailableException;
/**
* close this device if discarded by the garbage collector
* close this device if discarded by the garbage collector.
*/
@Override
protected final void finalize() {
close();
}
// INNER CLASSES
/** Base class for Receivers.
Subclasses that use Receivers must use this base class, since it
contains magic necessary to manage implicit closing the device.
@ -550,6 +526,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
this.tlist = tlist;
}
@Override
public final void setReceiver(Receiver receiver) {
if (tlist != null && this.receiver != receiver) {
if (Printer.debug) Printer.debug("Transmitter "+toString()+": set receiver "+receiver);
@ -558,16 +535,17 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
@Override
public final Receiver getReceiver() {
return receiver;
}
/** Close the Transmitter.
* Here, the call to the magic method closeInternal() takes place.
* Therefore, subclasses that override this method must call
* 'super.close()'.
*/
@Override
public final void close() {
AbstractMidiDevice.this.closeInternal(this);
if (tlist != null) {
@ -577,19 +555,19 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
@Override
public final MidiDevice getMidiDevice() {
return AbstractMidiDevice.this;
}
} // class BasicTransmitter
/**
* a class to manage a list of transmitters
* a class to manage a list of transmitters.
*/
final class TransmitterList {
private final ArrayList<Transmitter> transmitters = new ArrayList<Transmitter>();
private final ArrayList<Transmitter> transmitters = new ArrayList<>();
private MidiOutDevice.MidiOutReceiver midiOutReceiver;
// how many transmitters must be present for optimized
@ -712,9 +690,8 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
/**
* Send this message to all transmitters
* Send this message to all transmitters.
*/
void sendMessage(MidiMessage message, long timeStamp) {
if (message instanceof FastShortMessage) {
@ -746,8 +723,5 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
}
}
} // TransmitterList
}

View File

@ -52,7 +52,6 @@ public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider {
// also for memory's sake, do not initialize the arrays here
}
final synchronized void readDeviceInfos() {
Info[] infos = getInfoCache();
MidiDevice[] devices = getDeviceCache();
@ -148,10 +147,6 @@ public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider {
throw MidiUtils.unsupportedDevice(info);
}
// INNER CLASSES
/**
* Info class for MidiDevices. Adds an index value for
* making native references to a particular device.
@ -182,9 +177,6 @@ public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider {
} // class Info
// ABSTRACT METHODS
abstract int getNumDevices();
abstract MidiDevice[] getDeviceCache();
abstract void setDeviceCache(MidiDevice[] devices);

View File

@ -28,9 +28,9 @@ package com.sun.media.sound;
import java.util.Vector;
import javax.sound.sampled.Control;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
/**
* Abstract Mixer. Implements Mixer (with abstract methods) and specifies
@ -76,29 +76,18 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
*/
private boolean manuallyOpened = false;
/**
* Supported formats for the mixer.
*/
//$$fb DELETE
//protected Vector formats = new Vector();
// STATE VARIABLES
/**
* Source lines (ports) currently open
* Source lines (ports) currently open.
*/
private final Vector<Line> sourceLines = new Vector<>();
/**
* Target lines currently open.
*/
private final Vector<Line> targetLines = new Vector<>();
/**
* Constructs a new AbstractMixer.
* @param mixer the mixer with which this line is associated
@ -124,30 +113,28 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
this.targetLineInfo = targetLineInfo;
}
// MIXER METHODS
@Override
public final Mixer.Info getMixerInfo() {
return mixerInfo;
}
@Override
public final Line.Info[] getSourceLineInfo() {
Line.Info[] localArray = new Line.Info[sourceLineInfo.length];
System.arraycopy(sourceLineInfo, 0, localArray, 0, sourceLineInfo.length);
return localArray;
}
@Override
public final Line.Info[] getTargetLineInfo() {
Line.Info[] localArray = new Line.Info[targetLineInfo.length];
System.arraycopy(targetLineInfo, 0, localArray, 0, targetLineInfo.length);
return localArray;
}
@Override
public final Line.Info[] getSourceLineInfo(Line.Info info) {
int i;
@ -168,7 +155,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return returnedArray;
}
@Override
public final Line.Info[] getTargetLineInfo(Line.Info info) {
int i;
@ -189,7 +176,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return returnedArray;
}
@Override
public final boolean isLineSupported(Line.Info info) {
int i;
@ -211,9 +198,10 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return false;
}
@Override
public abstract Line getLine(Line.Info info) throws LineUnavailableException;
@Override
public abstract int getMaxLines(Line.Info info);
protected abstract void implOpen() throws LineUnavailableException;
@ -221,7 +209,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
protected abstract void implStop();
protected abstract void implClose();
@Override
public final Line[] getSourceLines() {
Line[] localLines;
@ -238,7 +226,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return localLines;
}
@Override
public final Line[] getTargetLines() {
Line[] localLines;
@ -255,37 +243,37 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return localLines;
}
/**
* Default implementation always throws an exception.
*/
@Override
public final void synchronize(Line[] lines, boolean maintainSync) {
throw new IllegalArgumentException("Synchronization not supported by this mixer.");
}
/**
* Default implementation always throws an exception.
*/
@Override
public final void unsynchronize(Line[] lines) {
throw new IllegalArgumentException("Synchronization not supported by this mixer.");
}
/**
* Default implementation always returns false.
*/
@Override
public final boolean isSynchronizationSupported(Line[] lines,
boolean maintainSync) {
return false;
}
// OVERRIDES OF ABSTRACT DATA LINE METHODS
/**
* This implementation tries to open the mixer with its current format and buffer size settings.
*/
@Override
public final synchronized void open() throws LineUnavailableException {
open(true);
}
@ -307,10 +295,8 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
if (Printer.trace) Printer.trace("<< AbstractMixer: open() succeeded");
}
// METHOD FOR INTERNAL IMPLEMENTATION USE
/**
* The default implementation of this method just determines whether
* this line is a source or target line, calls open(no-arg) on the
@ -357,7 +343,6 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
if (Printer.trace) Printer.trace("<< AbstractMixer: open(" + line + ") completed");
}
/**
* Removes this line from the list of open source lines and
* open target lines, if it exists in either.
@ -388,10 +373,10 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
if (Printer.trace) Printer.trace("<< AbstractMixer: close(" + line + ") succeeded");
}
/**
* Close all lines and then close this mixer.
*/
@Override
public final synchronized void close() {
if (Printer.trace) Printer.trace(">> AbstractMixer: close()");
if (isOpen()) {
@ -439,7 +424,6 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
if (Printer.trace) Printer.trace("<< AbstractMixer: start(" + line + ") succeeded");
}
/**
* Stops the mixer if this was the last running line.
*/
@ -492,8 +476,6 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
if (Printer.trace) Printer.trace("<< AbstractMixer: stop(" + line + ") succeeded");
}
/**
* Determines whether this is a source line for this mixer.
* Right now this just checks whether it's supported, but should
@ -510,7 +492,6 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return false;
}
/**
* Determines whether this is a target line for this mixer.
* Right now this just checks whether it's supported, but should
@ -527,7 +508,6 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return false;
}
/**
* Returns the first complete Line.Info object it finds that
* matches the one specified, or null if no matching Line.Info
@ -551,8 +531,6 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return targetLineInfo[i];
}
}
return null;
}
}

View File

@ -87,5 +87,4 @@ final class AiffFileFormat extends StandardFileFormat {
int getSsndChunkOffset() {
return getHeaderSize()-16;
}
}

View File

@ -29,7 +29,6 @@ import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFileFormat.Type;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;

View File

@ -33,7 +33,6 @@ import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
/**
* A-law encodes linear data, and decodes a-law data to linear data.
*
@ -52,7 +51,7 @@ public final class AlawCodec extends SunCodec {
0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};
/**
* Initializes the decode tables
* Initializes the decode tables.
*/
static {
for (int i=0;i<256;i++) {
@ -83,10 +82,7 @@ public final class AlawCodec extends SunCodec {
super(alawEncodings, alawEncodings);
}
// NEW CODE
/**
*/
@Override
public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat){
if( sourceFormat.getEncoding().equals( AudioFormat.Encoding.PCM_SIGNED )) {
@ -117,8 +113,7 @@ public final class AlawCodec extends SunCodec {
}
}
/**
*/
@Override
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
Objects.requireNonNull(sourceFormat);
if( (targetEncoding.equals( AudioFormat.Encoding.PCM_SIGNED ) && sourceFormat.getEncoding().equals( AudioFormat.Encoding.ALAW)) ||
@ -129,8 +124,7 @@ public final class AlawCodec extends SunCodec {
}
}
/**
*/
@Override
public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream){
AudioFormat sourceFormat = sourceStream.getFormat();
AudioFormat.Encoding sourceEncoding = sourceFormat.getEncoding();
@ -169,9 +163,7 @@ public final class AlawCodec extends SunCodec {
return getConvertedStream(targetFormat, sourceStream);
}
/**
* use old code...
*/
@Override
public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream){
if (!isConversionSupported(targetFormat, sourceStream.getFormat()))
throw new IllegalArgumentException("Unsupported conversion: "
@ -180,10 +172,6 @@ public final class AlawCodec extends SunCodec {
return getConvertedStream( targetFormat, sourceStream );
}
// OLD CODE
/**
* Opens the codec with the specified parameters.
* @param stream stream from which data to be processed should be read
@ -192,7 +180,6 @@ public final class AlawCodec extends SunCodec {
* @throws IllegalArgumentException if the format combination supplied is
* not supported.
*/
/* public AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) { */
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {
AudioInputStream cs = null;
@ -201,7 +188,7 @@ public final class AlawCodec extends SunCodec {
if( inputFormat.matches(outputFormat) ) {
cs = stream;
} else {
cs = (AudioInputStream) (new AlawCodecStream(stream, outputFormat));
cs = new AlawCodecStream(stream, outputFormat);
}
return cs;
@ -214,7 +201,6 @@ public final class AlawCodec extends SunCodec {
* returns an array of length 0.
* @return array of supported output formats.
*/
/* public AudioFormat[] getOutputFormats(AudioFormat inputFormat) { */
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
@ -343,18 +329,20 @@ public final class AlawCodec extends SunCodec {
* Note that this won't actually read anything; must read in
* two-byte units.
*/
@Override
public int read() throws IOException {
byte[] b = new byte[1];
return read(b, 0, b.length);
}
@Override
public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
// don't read fractional frames

View File

@ -45,6 +45,7 @@ import javax.sound.sampled.UnsupportedAudioFileException;
*/
public final class AudioFileSoundbankReader extends SoundbankReader {
@Override
public Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException {
try {
@ -59,6 +60,7 @@ public final class AudioFileSoundbankReader extends SoundbankReader {
}
}
@Override
public Soundbank getSoundbank(InputStream stream)
throws InvalidMidiDataException, IOException {
stream.mark(512);
@ -108,6 +110,7 @@ public final class AudioFileSoundbankReader extends SoundbankReader {
}
}
@Override
public Soundbank getSoundbank(File file)
throws InvalidMidiDataException, IOException {
try {

View File

@ -89,8 +89,9 @@ public abstract class AudioFloatConverter {
mask = (byte) 0xFF;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
byte[] ret = converter.toByteArray(in_buff, in_offset, in_len,
out_buff, out_offset);
@ -102,8 +103,9 @@ public abstract class AudioFloatConverter {
return ret;
}
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
if (mask_buffer == null || mask_buffer.length < in_buff.length)
mask_buffer = new byte[in_buff.length];
System.arraycopy(in_buff, 0, mask_buffer, 0, in_buff.length);
@ -132,8 +134,9 @@ public abstract class AudioFloatConverter {
double[] double_buff = null;
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int in_len = out_len * 8;
if (bytebuffer == null || bytebuffer.capacity() < in_len) {
bytebuffer = ByteBuffer.allocate(in_len).order(
@ -154,8 +157,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int out_len = in_len * 8;
if (bytebuffer == null || bytebuffer.capacity() < out_len) {
bytebuffer = ByteBuffer.allocate(out_len).order(
@ -184,8 +188,9 @@ public abstract class AudioFloatConverter {
double[] double_buff = null;
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int in_len = out_len * 8;
if (bytebuffer == null || bytebuffer.capacity() < in_len) {
bytebuffer = ByteBuffer.allocate(in_len).order(
@ -206,8 +211,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int out_len = in_len * 8;
if (bytebuffer == null || bytebuffer.capacity() < out_len) {
bytebuffer = ByteBuffer.allocate(out_len).order(
@ -240,8 +246,9 @@ public abstract class AudioFloatConverter {
FloatBuffer floatbuffer = null;
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int in_len = out_len * 4;
if (bytebuffer == null || bytebuffer.capacity() < in_len) {
bytebuffer = ByteBuffer.allocate(in_len).order(
@ -255,8 +262,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int out_len = in_len * 4;
if (bytebuffer == null || bytebuffer.capacity() < out_len) {
bytebuffer = ByteBuffer.allocate(out_len).order(
@ -277,8 +285,9 @@ public abstract class AudioFloatConverter {
FloatBuffer floatbuffer = null;
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int in_len = out_len * 4;
if (bytebuffer == null || bytebuffer.capacity() < in_len) {
bytebuffer = ByteBuffer.allocate(in_len).order(
@ -292,8 +301,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int out_len = in_len * 4;
if (bytebuffer == null || bytebuffer.capacity() < out_len) {
bytebuffer = ByteBuffer.allocate(out_len).order(
@ -316,8 +326,9 @@ public abstract class AudioFloatConverter {
// PCM 8 bit, signed
private static class AudioFloatConversion8S extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -327,8 +338,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -341,8 +353,9 @@ public abstract class AudioFloatConverter {
// PCM 8 bit, unsigned
private static class AudioFloatConversion8U extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -352,8 +365,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -372,8 +386,9 @@ public abstract class AudioFloatConverter {
// PCM 16 bit, signed, little-endian
private static class AudioFloatConversion16SL extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int len = out_offset + out_len;
for (int ox = out_offset; ox < len; ox++) {
@ -383,8 +398,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ox = out_offset;
int len = in_offset + in_len;
for (int ix = in_offset; ix < len; ix++) {
@ -399,8 +415,9 @@ public abstract class AudioFloatConverter {
// PCM 16 bit, signed, big-endian
private static class AudioFloatConversion16SB extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -410,8 +427,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -426,8 +444,9 @@ public abstract class AudioFloatConverter {
// PCM 16 bit, unsigned, little-endian
private static class AudioFloatConversion16UL extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -438,8 +457,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -454,8 +474,9 @@ public abstract class AudioFloatConverter {
// PCM 16 bit, unsigned, big-endian
private static class AudioFloatConversion16UB extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -466,8 +487,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -488,8 +510,9 @@ public abstract class AudioFloatConverter {
// PCM 24 bit, signed, little-endian
private static class AudioFloatConversion24SL extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -502,8 +525,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -521,8 +545,9 @@ public abstract class AudioFloatConverter {
// PCM 24 bit, signed, big-endian
private static class AudioFloatConversion24SB extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -535,8 +560,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -554,8 +580,9 @@ public abstract class AudioFloatConverter {
// PCM 24 bit, unsigned, little-endian
private static class AudioFloatConversion24UL extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -567,8 +594,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -585,8 +613,9 @@ public abstract class AudioFloatConverter {
// PCM 24 bit, unsigned, big-endian
private static class AudioFloatConversion24UB extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -598,8 +627,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -622,8 +652,9 @@ public abstract class AudioFloatConverter {
// PCM 32 bit, signed, little-endian
private static class AudioFloatConversion32SL extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -635,8 +666,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -652,8 +684,9 @@ public abstract class AudioFloatConverter {
// PCM 32 bit, signed, big-endian
private static class AudioFloatConversion32SB extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -665,8 +698,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -682,8 +716,9 @@ public abstract class AudioFloatConverter {
// PCM 32 bit, unsigned, little-endian
private static class AudioFloatConversion32UL extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -696,8 +731,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -715,8 +751,9 @@ public abstract class AudioFloatConverter {
// PCM 32 bit, unsigned, big-endian
private static class AudioFloatConversion32UB extends AudioFloatConverter {
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -729,8 +766,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -760,8 +798,9 @@ public abstract class AudioFloatConverter {
this.xbytes = xbytes;
}
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -774,8 +813,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -801,8 +841,9 @@ public abstract class AudioFloatConverter {
this.xbytes = xbytes;
}
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -816,8 +857,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -843,8 +885,9 @@ public abstract class AudioFloatConverter {
this.xbytes = xbytes;
}
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -858,8 +901,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
@ -886,8 +930,9 @@ public abstract class AudioFloatConverter {
this.xbytes = xbytes;
}
@Override
public float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len) {
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
@ -901,8 +946,9 @@ public abstract class AudioFloatConverter {
return out_buff;
}
@Override
public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
byte[] out_buff, int out_offset) {
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {

View File

@ -32,9 +32,9 @@ import java.util.Arrays;
import java.util.Objects;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.spi.FormatConversionProvider;
/**
@ -63,6 +63,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
fsize = ((targetFormat.getSampleSizeInBits() + 7) / 8);
}
@Override
public int read() throws IOException {
byte[] b = new byte[1];
int ret = read(b);
@ -71,6 +72,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return b[0] & 0xFF;
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
int flen = len / fsize;
@ -83,6 +85,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return ret * fsize;
}
@Override
public int available() throws IOException {
int ret = stream.available();
if (ret < 0)
@ -90,22 +93,27 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return ret * fsize;
}
@Override
public void close() throws IOException {
stream.close();
}
@Override
public synchronized void mark(int readlimit) {
stream.mark(readlimit * fsize);
}
@Override
public boolean markSupported() {
return stream.markSupported();
}
@Override
public synchronized void reset() throws IOException {
stream.reset();
}
@Override
public long skip(long n) throws IOException {
long ret = stream.skip(n / fsize);
if (ret < 0)
@ -141,30 +149,37 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
.isBigEndian());
}
@Override
public int available() throws IOException {
return (ais.available() / sourceChannels) * targetChannels;
}
@Override
public void close() throws IOException {
ais.close();
}
@Override
public AudioFormat getFormat() {
return targetFormat;
}
@Override
public long getFrameLength() {
return ais.getFrameLength();
}
@Override
public void mark(int readlimit) {
ais.mark((readlimit / targetChannels) * sourceChannels);
}
@Override
public boolean markSupported() {
return ais.markSupported();
}
@Override
public int read(float[] b, int off, int len) throws IOException {
int len2 = (len / targetChannels) * sourceChannels;
if (conversion_buffer == null || conversion_buffer.length < len2)
@ -212,10 +227,12 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return (ret / sourceChannels) * targetChannels;
}
@Override
public void reset() throws IOException {
ais.reset();
}
@Override
public long skip(long len) throws IOException {
long ret = ais.skip((len / targetChannels) * sourceChannels);
if (ret < 0)
@ -305,22 +322,27 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
ibuffer_len = buffer_len;
}
@Override
public int available() throws IOException {
return 0;
}
@Override
public void close() throws IOException {
ais.close();
}
@Override
public AudioFormat getFormat() {
return targetFormat;
}
@Override
public long getFrameLength() {
return AudioSystem.NOT_SPECIFIED; // ais.getFrameLength();
}
@Override
public void mark(int readlimit) {
ais.mark((int) (readlimit * pitch[0]));
mark_ibuffer_index = ibuffer_index;
@ -337,6 +359,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
}
}
@Override
public boolean markSupported() {
return ais.markSupported();
}
@ -381,6 +404,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
}
@Override
public int read(float[] b, int off, int len) throws IOException {
if (cbuffer == null || cbuffer[0].length < len / nrofchannels) {
@ -431,6 +455,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return len - remain * nrofchannels;
}
@Override
public void reset() throws IOException {
ais.reset();
if (mark_ibuffer == null)
@ -447,6 +472,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
}
@Override
public long skip(long len) throws IOException {
if (len < 0)
return 0;
@ -474,8 +500,9 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
Encoding.PCM_UNSIGNED,
Encoding.PCM_FLOAT};
@Override
public AudioInputStream getAudioInputStream(Encoding targetEncoding,
AudioInputStream sourceStream) {
AudioInputStream sourceStream) {
if (!isConversionSupported(targetEncoding, sourceStream.getFormat())) {
throw new IllegalArgumentException(
"Unsupported conversion: " + sourceStream.getFormat()
@ -496,8 +523,9 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return getAudioInputStream(targetFormat, sourceStream);
}
@Override
public AudioInputStream getAudioInputStream(AudioFormat targetFormat,
AudioInputStream sourceStream) {
AudioInputStream sourceStream) {
if (!isConversionSupported(targetFormat, sourceStream.getFormat()))
throw new IllegalArgumentException("Unsupported conversion: "
+ sourceStream.getFormat().toString() + " to "
@ -526,16 +554,19 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
.getFrameLength());
}
@Override
public Encoding[] getSourceEncodings() {
return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
Encoding.PCM_FLOAT };
}
@Override
public Encoding[] getTargetEncodings() {
return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
Encoding.PCM_FLOAT };
}
@Override
public Encoding[] getTargetEncodings(AudioFormat sourceFormat) {
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return new Encoding[0];
@ -543,14 +574,15 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
Encoding.PCM_FLOAT };
}
@Override
public AudioFormat[] getTargetFormats(Encoding targetEncoding,
AudioFormat sourceFormat) {
AudioFormat sourceFormat) {
Objects.requireNonNull(targetEncoding);
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return new AudioFormat[0];
int channels = sourceFormat.getChannels();
ArrayList<AudioFormat> formats = new ArrayList<AudioFormat>();
ArrayList<AudioFormat> formats = new ArrayList<>();
if (targetEncoding.equals(Encoding.PCM_SIGNED))
formats.add(new AudioFormat(Encoding.PCM_SIGNED,
@ -598,8 +630,9 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return formats.toArray(new AudioFormat[formats.size()]);
}
@Override
public boolean isConversionSupported(AudioFormat targetFormat,
AudioFormat sourceFormat) {
AudioFormat sourceFormat) {
Objects.requireNonNull(targetFormat);
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return false;
@ -612,8 +645,9 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
return true;
}
@Override
public boolean isConversionSupported(Encoding targetEncoding,
AudioFormat sourceFormat) {
AudioFormat sourceFormat) {
Objects.requireNonNull(targetEncoding);
if (AudioFloatConverter.getConverter(sourceFormat) == null)
return false;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.ByteArrayInputStream;
@ -66,14 +67,17 @@ public abstract class AudioFloatInputStream {
}
@Override
public AudioFormat getFormat() {
return format;
}
@Override
public long getFrameLength() {
return buffer_len;// / format.getFrameSize();
}
@Override
public int read(float[] b, int off, int len) throws IOException {
if (b == null)
throw new NullPointerException();
@ -91,6 +95,7 @@ public abstract class AudioFloatInputStream {
return len;
}
@Override
public long skip(long len) throws IOException {
if (pos >= buffer_len)
return -1;
@ -102,21 +107,26 @@ public abstract class AudioFloatInputStream {
return len;
}
@Override
public int available() throws IOException {
return buffer_len - pos;
}
@Override
public void close() throws IOException {
}
@Override
public void mark(int readlimit) {
markpos = pos;
}
@Override
public boolean markSupported() {
return true;
}
@Override
public void reset() throws IOException {
pos = markpos;
}
@ -163,14 +173,17 @@ public abstract class AudioFloatInputStream {
this.stream = stream;
}
@Override
public AudioFormat getFormat() {
return stream.getFormat();
}
@Override
public long getFrameLength() {
return stream.getFrameLength();
}
@Override
public int read(float[] b, int off, int len) throws IOException {
int b_len = len * framesize_pc;
if (buffer == null || buffer.length < b_len)
@ -182,6 +195,7 @@ public abstract class AudioFloatInputStream {
return ret / framesize_pc;
}
@Override
public long skip(long len) throws IOException {
long b_len = len * framesize_pc;
long ret = stream.skip(b_len);
@ -190,22 +204,27 @@ public abstract class AudioFloatInputStream {
return ret / framesize_pc;
}
@Override
public int available() throws IOException {
return stream.available() / framesize_pc;
}
@Override
public void close() throws IOException {
stream.close();
}
@Override
public void mark(int readlimit) {
stream.mark(readlimit * framesize_pc);
}
@Override
public boolean markSupported() {
return stream.markSupported();
}
@Override
public void reset() throws IOException {
stream.reset();
}

View File

@ -22,9 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.Map;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Synthesizer;
import javax.sound.sampled.AudioFormat;
@ -53,7 +55,7 @@ public interface AudioSynthesizer extends Synthesizer {
* @return current audio data format
* @see AudioFormat
*/
public AudioFormat getFormat();
AudioFormat getFormat();
/**
* Gets information about the possible properties for the synthesizer.
@ -63,8 +65,7 @@ public interface AudioSynthesizer extends Synthesizer {
* describing possible properties. This array may be an empty array if
* no properties are required.
*/
public AudioSynthesizerPropertyInfo[] getPropertyInfo(
Map<String, Object> info);
AudioSynthesizerPropertyInfo[] getPropertyInfo(Map<String, Object> info);
/**
* Opens the synthesizer and starts rendering audio into
@ -93,7 +94,7 @@ public interface AudioSynthesizer extends Synthesizer {
* @see #close
* @see #isOpen
*/
public void open(SourceDataLine line, Map<String, Object> info)
void open(SourceDataLine line, Map<String, Object> info)
throws MidiUnavailableException;
/**
@ -123,6 +124,7 @@ public interface AudioSynthesizer extends Synthesizer {
* @see #close
* @see #isOpen
*/
public AudioInputStream openStream(AudioFormat targetFormat,
Map<String, Object> info) throws MidiUnavailableException;
AudioInputStream openStream(AudioFormat targetFormat,
Map<String, Object> info)
throws MidiUnavailableException;
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -28,7 +28,7 @@ package com.sun.media.sound;
import javax.sound.sampled.Clip;
/**
* Interface for Clip objects that close themselves automatically
* Interface for Clip objects that close themselves automatically.
*
* @author Florian Bomers
*/

View File

@ -41,6 +41,5 @@ public interface AutoConnectSequencer {
* needs to re-connect itself to a suitable
* device in open().
*/
public void setAutoConnect(Receiver autoConnectReceiver);
void setAutoConnect(Receiver autoConnectReceiver);
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.ArrayList;
@ -47,8 +48,8 @@ public final class DLSInstrument extends ModelInstrument {
boolean druminstrument = false;
byte[] guid = null;
DLSInfo info = new DLSInfo();
List<DLSRegion> regions = new ArrayList<DLSRegion>();
List<DLSModulator> modulators = new ArrayList<DLSModulator>();
List<DLSRegion> regions = new ArrayList<>();
List<DLSModulator> modulators = new ArrayList<>();
public DLSInstrument() {
super(null, null, null, null);
@ -62,6 +63,7 @@ public final class DLSInstrument extends ModelInstrument {
return info;
}
@Override
public String getName() {
return info.name;
}
@ -70,6 +72,7 @@ public final class DLSInstrument extends ModelInstrument {
info.name = name;
}
@Override
public ModelPatch getPatch() {
return new ModelPatch(bank, preset, druminstrument);
}
@ -86,6 +89,7 @@ public final class DLSInstrument extends ModelInstrument {
}
}
@Override
public Object getData() {
return null;
}
@ -98,6 +102,7 @@ public final class DLSInstrument extends ModelInstrument {
return modulators;
}
@Override
public String toString() {
if (druminstrument)
return "Drumkit: " + info.name
@ -362,17 +367,17 @@ public final class DLSInstrument extends ModelInstrument {
return null;
}
@Override
public ModelPerformer[] getPerformers() {
List<ModelPerformer> performers = new ArrayList<ModelPerformer>();
List<ModelPerformer> performers = new ArrayList<>();
Map<String, DLSModulator> modmap = new HashMap<String, DLSModulator>();
Map<String, DLSModulator> modmap = new HashMap<>();
for (DLSModulator mod: getModulators()) {
modmap.put(mod.getSource() + "x" + mod.getControl() + "=" +
mod.getDestination(), mod);
}
Map<String, DLSModulator> insmodmap =
new HashMap<String, DLSModulator>();
Map<String, DLSModulator> insmodmap = new HashMap<>();
for (DLSRegion zone: regions) {
ModelPerformer performer = new ModelPerformer();

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.ArrayList;
@ -39,7 +40,7 @@ import java.util.List;
public final class DLSRegion {
public static final int OPTION_SELFNONEXCLUSIVE = 0x0001;
List<DLSModulator> modulators = new ArrayList<DLSModulator>();
List<DLSModulator> modulators = new ArrayList<>();
int keyfrom;
int keyto;
int velfrom;

View File

@ -22,10 +22,12 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.InputStream;
import java.util.Arrays;
import javax.sound.midi.Soundbank;
import javax.sound.midi.SoundbankResource;
import javax.sound.sampled.AudioFormat;
@ -60,6 +62,7 @@ public final class DLSSample extends SoundbankResource {
return info;
}
@Override
public Object getData() {
AudioFormat format = getFormat();
@ -93,6 +96,7 @@ public final class DLSSample extends SoundbankResource {
this.data = new ModelByteBuffer(data, offset, length);
}
@Override
public String getName() {
return info.name;
}
@ -109,6 +113,7 @@ public final class DLSSample extends SoundbankResource {
this.sampleoptions = sampleOptions;
}
@Override
public String toString() {
return "Sample: " + info.name;
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.ArrayList;
@ -40,7 +41,7 @@ public final class DLSSampleOptions {
short finetune;
int attenuation;
long options;
List<DLSSampleLoop> loops = new ArrayList<DLSSampleLoop>();
List<DLSSampleLoop> loops = new ArrayList<>();
public int getAttenuation() {
return attenuation;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.File;
@ -42,9 +43,9 @@ import javax.sound.midi.Patch;
import javax.sound.midi.Soundbank;
import javax.sound.midi.SoundbankResource;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioFormat.Encoding;
/**
* A DLS Level 1 and Level 2 soundbank reader (from files/url/streams).
@ -100,10 +101,12 @@ public final class DLSSoundbank implements Soundbank {
return d;
}
@Override
public int hashCode() {
return (int)i1;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof DLSID)) {
return false;
@ -176,8 +179,8 @@ public final class DLSSoundbank implements Soundbank {
private final DLSInfo info = new DLSInfo();
private final List<DLSInstrument> instruments = new ArrayList<DLSInstrument>();
private final List<DLSSample> samples = new ArrayList<DLSSample>();
private final List<DLSInstrument> instruments = new ArrayList<>();
private final List<DLSSample> samples = new ArrayList<>();
private boolean largeFormat = false;
private File sampleFile;
@ -300,7 +303,7 @@ public final class DLSSoundbank implements Soundbank {
DLSID uuid;
long x;
long y;
Stack<Long> stack = new Stack<Long>();
Stack<Long> stack = new Stack<>();
while (riff.available() != 0) {
int opcode = riff.readUnsignedShort();
@ -482,7 +485,7 @@ public final class DLSSoundbank implements Soundbank {
}
}
if (chunk.getType().equals("lart")) {
List<DLSModulator> modlist = new ArrayList<DLSModulator>();
List<DLSModulator> modlist = new ArrayList<>();
while (chunk.hasNextChunk()) {
RIFFReader subchunk = chunk.nextChunk();
if (chunk.getFormat().equals("cdl ")) {
@ -498,7 +501,7 @@ public final class DLSSoundbank implements Soundbank {
}
if (chunk.getType().equals("lar2")) {
// support for DLS level 2 ART
List<DLSModulator> modlist = new ArrayList<DLSModulator>();
List<DLSModulator> modlist = new ArrayList<>();
while (chunk.hasNextChunk()) {
RIFFReader subchunk = chunk.nextChunk();
if (chunk.getFormat().equals("cdl ")) {
@ -582,7 +585,7 @@ public final class DLSSoundbank implements Soundbank {
}
}
private Map<DLSRegion, Long> temp_rgnassign = new HashMap<DLSRegion, Long>();
private Map<DLSRegion, Long> temp_rgnassign = new HashMap<>();
private boolean readRgnChunk(DLSRegion split, RIFFReader riff)
throws IOException {
@ -591,7 +594,7 @@ public final class DLSSoundbank implements Soundbank {
String format = chunk.getFormat();
if (format.equals("LIST")) {
if (chunk.getType().equals("lart")) {
List<DLSModulator> modlist = new ArrayList<DLSModulator>();
List<DLSModulator> modlist = new ArrayList<>();
while (chunk.hasNextChunk()) {
RIFFReader subchunk = chunk.nextChunk();
if (chunk.getFormat().equals("cdl ")) {
@ -607,7 +610,7 @@ public final class DLSSoundbank implements Soundbank {
}
if (chunk.getType().equals("lar2")) {
// support for DLS level 2 ART
List<DLSModulator> modlist = new ArrayList<DLSModulator>();
List<DLSModulator> modlist = new ArrayList<>();
while (chunk.hasNextChunk()) {
RIFFReader subchunk = chunk.nextChunk();
if (chunk.getFormat().equals("cdl ")) {
@ -902,7 +905,7 @@ public final class DLSSoundbank implements Soundbank {
RIFFWriter wvpl = writer.writeList("wvpl");
long off = wvpl.getFilePointer();
List<Long> offsettable = new ArrayList<Long>();
List<Long> offsettable = new ArrayList<>();
for (DLSSample sample : samples) {
offsettable.add(Long.valueOf(wvpl.getFilePointer() - off));
writeSample(wvpl.writeList("wave"), sample);
@ -1179,18 +1182,22 @@ public final class DLSSoundbank implements Soundbank {
return info;
}
@Override
public String getName() {
return info.name;
}
@Override
public String getVersion() {
return major + "." + minor;
}
@Override
public String getVendor() {
return info.engineers;
}
@Override
public String getDescription() {
return info.comments;
}
@ -1207,6 +1214,7 @@ public final class DLSSoundbank implements Soundbank {
info.comments = s;
}
@Override
public SoundbankResource[] getResources() {
SoundbankResource[] resources = new SoundbankResource[samples.size()];
int j = 0;
@ -1215,6 +1223,7 @@ public final class DLSSoundbank implements Soundbank {
return resources;
}
@Override
public DLSInstrument[] getInstruments() {
DLSInstrument[] inslist_array =
instruments.toArray(new DLSInstrument[instruments.size()]);
@ -1226,6 +1235,7 @@ public final class DLSSoundbank implements Soundbank {
return samples.toArray(new DLSSample[samples.size()]);
}
@Override
public Instrument getInstrument(Patch patch) {
int program = patch.getProgram();
int bank = patch.getBank();
@ -1256,9 +1266,9 @@ public final class DLSSoundbank implements Soundbank {
public void removeResource(SoundbankResource resource) {
if (resource instanceof DLSInstrument)
instruments.remove((DLSInstrument) resource);
instruments.remove(resource);
if (resource instanceof DLSSample)
samples.remove((DLSSample) resource);
samples.remove(resource);
}
public void addInstrument(DLSInstrument resource) {

View File

@ -29,6 +29,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.Soundbank;
import javax.sound.midi.spi.SoundbankReader;
@ -41,6 +42,7 @@ import javax.sound.midi.spi.SoundbankReader;
*/
public final class DLSSoundbankReader extends SoundbankReader {
@Override
public Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException {
try {
@ -52,6 +54,7 @@ public final class DLSSoundbankReader extends SoundbankReader {
}
}
@Override
public Soundbank getSoundbank(InputStream stream)
throws InvalidMidiDataException, IOException {
try {
@ -63,6 +66,7 @@ public final class DLSSoundbankReader extends SoundbankReader {
}
}
@Override
public Soundbank getSoundbank(File file)
throws InvalidMidiDataException, IOException {
try {

View File

@ -27,7 +27,9 @@ package com.sun.media.sound;
import java.util.Arrays;
import javax.sound.sampled.*;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.SourceDataLine;
/**
* Class to write an AudioInputStream to a SourceDataLine.
@ -125,7 +127,6 @@ public final class DataPusher implements Runnable {
if (DEBUG || Printer.debug) Printer.debug("< DataPusher.start(loop="+loop+")");
}
public synchronized void stop() {
if (DEBUG || Printer.debug) Printer.debug("> DataPusher.stop()");
if (threadState == STATE_STOPPING
@ -161,6 +162,7 @@ public final class DataPusher implements Runnable {
/**
* Write data to the source data line.
*/
@Override
public void run() {
byte[] buffer = null;
boolean useStream = (ais != null);
@ -242,5 +244,4 @@ public final class DataPusher implements Runnable {
}
if (DEBUG || Printer.debug)Printer.debug("DataPusher:end of thread");
}
} // class DataPusher

View File

@ -29,35 +29,35 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Vector;
import javax.sound.sampled.*;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.BooleanControl;
import javax.sound.sampled.Clip;
import javax.sound.sampled.Control;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.TargetDataLine;
// IDEA:
// Use java.util.concurrent.Semaphore,
// java.util.concurrent.locks.ReentrantLock and other new classes/methods
// to improve this class's thread safety.
/**
* A Mixer which provides direct access to audio devices
* A Mixer which provides direct access to audio devices.
*
* @author Florian Bomers
*/
final class DirectAudioDevice extends AbstractMixer {
// CONSTANTS
private static final int CLIP_BUFFER_TIME = 1000; // in milliseconds
private static final int DEFAULT_LINE_BUFFER_TIME = 500; // in milliseconds
// INSTANCE VARIABLES
/** number of opened lines */
private int deviceCountOpened = 0;
/** number of started lines */
private int deviceCountStarted = 0;
// CONSTRUCTOR
DirectAudioDevice(DirectAudioDeviceProvider.DirectAudioDeviceInfo portMixerInfo) {
// pass in Line.Info, mixer, controls
super(portMixerInfo, // Mixer.Info
@ -168,6 +168,7 @@ final class DirectAudioDevice extends AbstractMixer {
// ABSTRACT MIXER: ABSTRACT METHOD IMPLEMENTATIONS
@Override
public Line getLine(Line.Info info) throws LineUnavailableException {
Line.Info fullInfo = getLineInfo(info);
if (fullInfo == null) {
@ -216,7 +217,7 @@ final class DirectAudioDevice extends AbstractMixer {
throw new IllegalArgumentException("Line unsupported: " + info);
}
@Override
public int getMaxLines(Line.Info info) {
Line.Info fullInfo = getLineInfo(info);
@ -233,26 +234,26 @@ final class DirectAudioDevice extends AbstractMixer {
return 0;
}
@Override
protected void implOpen() throws LineUnavailableException {
if (Printer.trace) Printer.trace("DirectAudioDevice: implOpen - void method");
}
@Override
protected void implClose() {
if (Printer.trace) Printer.trace("DirectAudioDevice: implClose - void method");
}
@Override
protected void implStart() {
if (Printer.trace) Printer.trace("DirectAudioDevice: implStart - void method");
}
@Override
protected void implStop() {
if (Printer.trace) Printer.trace("DirectAudioDevice: implStop - void method");
}
// IMPLEMENTATION HELPERS
int getMixerIndex() {
return ((DirectAudioDeviceProvider.DirectAudioDeviceInfo) getMixerInfo()).getIndex();
}
@ -319,12 +320,6 @@ final class DirectAudioDevice extends AbstractMixer {
return null;
}
// INNER CLASSES
/**
* Private inner class for the DataLine.Info objects
* adds a little magic for the isFormatSupported so
@ -367,7 +362,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
/**
* Private inner class as base class for direct lines
* Private inner class as base class for direct lines.
*/
private static class DirectDL extends AbstractDataLine implements EventDispatcher.LineMonitor {
protected final int mixerIndex;
@ -397,7 +392,6 @@ final class DirectAudioDevice extends AbstractMixer {
// Guards all native calls.
protected final Object lockNative = new Object();
// CONSTRUCTOR
protected DirectDL(DataLine.Info info,
DirectAudioDevice mixer,
AudioFormat format,
@ -414,11 +408,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
// ABSTRACT METHOD IMPLEMENTATIONS
// ABSTRACT LINE / DATALINE
@Override
void implOpen(AudioFormat format, int bufferSize) throws LineUnavailableException {
if (Printer.trace) Printer.trace(">> DirectDL: implOpen("+format+", "+bufferSize+" bytes)");
@ -538,7 +528,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("<< DirectDL: implOpen() succeeded");
}
@Override
void implStart() {
if (Printer.trace) Printer.trace(" >> DirectDL: implStart()");
@ -570,6 +560,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("<< DirectDL: implStart() succeeded");
}
@Override
void implStop() {
if (Printer.trace) Printer.trace(">> DirectDL: implStop()");
@ -600,6 +591,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace(" << DirectDL: implStop() succeeded");
}
@Override
void implClose() {
if (Printer.trace) Printer.trace(">> DirectDL: implClose()");
@ -625,8 +617,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("<< DirectDL: implClose() succeeded");
}
// METHOD OVERRIDES
@Override
public int available() {
if (id == 0) {
return 0;
@ -638,7 +629,7 @@ final class DirectAudioDevice extends AbstractMixer {
return a;
}
@Override
public void drain() {
noService = true;
// additional safeguard against draining forever
@ -681,6 +672,7 @@ final class DirectAudioDevice extends AbstractMixer {
noService = false;
}
@Override
public void flush() {
if (id != 0) {
// first stop ongoing read/write method
@ -699,6 +691,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
// replacement for getFramePosition (see AbstractDataLine)
@Override
public long getLongFramePosition() {
long pos;
synchronized (lockNative) {
@ -713,7 +706,6 @@ final class DirectAudioDevice extends AbstractMixer {
return (pos / getFormat().getFrameSize());
}
/*
* write() belongs into SourceDataLine and Clip,
* so define it here and make it accessible by
@ -786,6 +778,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
// called from event dispatcher for lines that need servicing
@Override
public void checkLine() {
synchronized (lockNative) {
if (monitoring
@ -826,7 +819,6 @@ final class DirectAudioDevice extends AbstractMixer {
}
}
/////////////////// CONTROLS /////////////////////////////
protected final class Gain extends FloatControl {
@ -844,6 +836,7 @@ final class DirectAudioDevice extends AbstractMixer {
"dB", "Minimum", "", "Maximum");
}
@Override
public void setValue(float newValue) {
// adjust value within range ?? spec says IllegalArgumentException
//newValue = Math.min(newValue, getMaximum());
@ -861,13 +854,13 @@ final class DirectAudioDevice extends AbstractMixer {
}
} // class Gain
private final class Mute extends BooleanControl {
private Mute() {
super(BooleanControl.Type.MUTE, false, "True", "False");
}
@Override
public void setValue(boolean newValue) {
super.setValue(newValue);
calcVolume();
@ -881,6 +874,7 @@ final class DirectAudioDevice extends AbstractMixer {
"", "Left", "Center", "Right");
}
@Override
public void setValue(float newValue) {
setValueImpl(newValue);
panControl.setValueImpl(newValue);
@ -900,6 +894,7 @@ final class DirectAudioDevice extends AbstractMixer {
"", "Left", "Center", "Right");
}
@Override
public void setValue(float newValue) {
setValueImpl(newValue);
balanceControl.setValueImpl(newValue);
@ -909,19 +904,14 @@ final class DirectAudioDevice extends AbstractMixer {
super.setValue(newValue);
}
} // class Pan
} // class DirectDL
/**
* Private inner class representing a SourceDataLine
* Private inner class representing a SourceDataLine.
*/
private static final class DirectSDL extends DirectDL
implements SourceDataLine {
// CONSTRUCTOR
private DirectSDL(DataLine.Info info,
AudioFormat format,
int bufferSize,
@ -933,12 +923,11 @@ final class DirectAudioDevice extends AbstractMixer {
}
/**
* Private inner class representing a TargetDataLine
* Private inner class representing a TargetDataLine.
*/
private static final class DirectTDL extends DirectDL
implements TargetDataLine {
// CONSTRUCTOR
private DirectTDL(DataLine.Info info,
AudioFormat format,
int bufferSize,
@ -947,8 +936,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("DirectTDL CONSTRUCTOR: completed");
}
// METHOD OVERRIDES
@Override
public int read(byte[] b, int off, int len) {
flushing = false;
if (len == 0) {
@ -1030,7 +1018,6 @@ final class DirectAudioDevice extends AbstractMixer {
// auto closing clip support
private boolean autoclosing = false;
// CONSTRUCTOR
private DirectClip(DataLine.Info info,
AudioFormat format,
int bufferSize,
@ -1041,6 +1028,7 @@ final class DirectAudioDevice extends AbstractMixer {
// CLIP METHODS
@Override
public void open(AudioFormat format, byte[] data, int offset, int bufferSize)
throws LineUnavailableException {
@ -1111,7 +1099,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("< DirectClip.open completed");
}
@Override
public void open(AudioInputStream stream) throws LineUnavailableException, IOException {
// $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
@ -1178,17 +1166,17 @@ final class DirectAudioDevice extends AbstractMixer {
} // synchronized
}
@Override
public int getFrameLength() {
return m_lengthInFrames;
}
@Override
public long getMicrosecondLength() {
return Toolkit.frames2micros(getFormat(), getFrameLength());
}
@Override
public void setFramePosition(int frames) {
if (Printer.trace) Printer.trace("> DirectClip: setFramePosition: " + frames);
@ -1229,6 +1217,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
// replacement for getFramePosition (see AbstractDataLine)
@Override
public long getLongFramePosition() {
/* $$fb
* this would be intuitive, but the definition of getFramePosition
@ -1243,7 +1232,7 @@ final class DirectAudioDevice extends AbstractMixer {
return super.getLongFramePosition();
}
@Override
public synchronized void setMicrosecondPosition(long microseconds) {
if (Printer.trace) Printer.trace("> DirectClip: setMicrosecondPosition: " + microseconds);
@ -1253,6 +1242,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("< DirectClip: setMicrosecondPosition succeeded");
}
@Override
public void setLoopPoints(int start, int end) {
if (Printer.trace) Printer.trace("> DirectClip: setLoopPoints: start: " + start + " end: " + end);
@ -1283,7 +1273,7 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("< DirectClip: setLoopPoints completed");
}
@Override
public void loop(int count) {
// note: when count reaches 0, it means that the entire clip
// will be played, i.e. it will play past the loop end point
@ -1291,10 +1281,7 @@ final class DirectAudioDevice extends AbstractMixer {
start();
}
// ABSTRACT METHOD IMPLEMENTATIONS
// ABSTRACT LINE
@Override
void implOpen(AudioFormat format, int bufferSize) throws LineUnavailableException {
// only if audioData wasn't set in a calling open(format, byte[], frameSize)
// this call is allowed.
@ -1304,6 +1291,7 @@ final class DirectAudioDevice extends AbstractMixer {
super.implOpen(format, bufferSize);
}
@Override
void implClose() {
if (Printer.trace) Printer.trace(">> DirectClip: implClose()");
@ -1333,13 +1321,14 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("<< DirectClip: implClose() succeeded");
}
@Override
void implStart() {
if (Printer.trace) Printer.trace("> DirectClip: implStart()");
super.implStart();
if (Printer.trace) Printer.trace("< DirectClip: implStart() succeeded");
}
@Override
void implStop() {
if (Printer.trace) Printer.trace(">> DirectClip: implStop()");
@ -1351,8 +1340,8 @@ final class DirectAudioDevice extends AbstractMixer {
if (Printer.trace) Printer.trace("<< DirectClip: implStop() succeeded");
}
// main playback loop
@Override
public void run() {
if (Printer.trace) Printer.trace(">>> DirectClip: run() threadID="+Thread.currentThread().getId());
while (thread != null) {
@ -1418,10 +1407,12 @@ final class DirectAudioDevice extends AbstractMixer {
MixerClip. They should be moved to a base class, together
with the instance variable 'autoclosing'. */
@Override
public boolean isAutoClosing() {
return autoclosing;
}
@Override
public void setAutoClosing(boolean value) {
if (value != autoclosing) {
if (isOpen()) {
@ -1435,6 +1426,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
}
@Override
protected boolean requiresServicing() {
// no need for servicing for Clips
return false;
@ -1488,5 +1480,4 @@ final class DirectAudioDevice extends AbstractMixer {
private static native boolean nRequiresServicing(long id, boolean isSource);
// called in irregular intervals
private static native void nService(long id, boolean isSource);
}

View File

@ -28,7 +28,6 @@ package com.sun.media.sound;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.spi.MixerProvider;
/**
* DirectAudioDevice provider.
*
@ -36,8 +35,6 @@ import javax.sound.sampled.spi.MixerProvider;
*/
public final class DirectAudioDeviceProvider extends MixerProvider {
// STATIC VARIABLES
/**
* Set of info objects for all port input devices on the system.
*/
@ -48,18 +45,11 @@ public final class DirectAudioDeviceProvider extends MixerProvider {
*/
private static DirectAudioDevice[] devices;
// STATIC
static {
// initialize
Platform.initialize();
}
// CONSTRUCTOR
/**
* Required public no-arg constructor.
*/
@ -92,6 +82,7 @@ public final class DirectAudioDeviceProvider extends MixerProvider {
}
}
@Override
public Mixer.Info[] getMixerInfo() {
synchronized (DirectAudioDeviceProvider.class) {
Mixer.Info[] localArray = new Mixer.Info[infos.length];
@ -100,7 +91,7 @@ public final class DirectAudioDeviceProvider extends MixerProvider {
}
}
@Override
public Mixer getMixer(Mixer.Info info) {
synchronized (DirectAudioDeviceProvider.class) {
// if the default device is asked, we provide the mixer
@ -125,7 +116,6 @@ public final class DirectAudioDeviceProvider extends MixerProvider {
String.format("Mixer %s not supported by this provider", info));
}
private static Mixer getDevice(DirectAudioDeviceInfo info) {
int index = info.getIndex();
if (devices[index] == null) {
@ -134,9 +124,6 @@ public final class DirectAudioDeviceProvider extends MixerProvider {
return devices[index];
}
// INNER CLASSES
/**
* Info class for DirectAudioDevices. Adds an index value and a string for
* making native references to a particular device.
@ -171,7 +158,6 @@ public final class DirectAudioDeviceProvider extends MixerProvider {
}
} // class DirectAudioDeviceInfo
// NATIVE METHODS
private static native int nGetNumDevices();
// index: [0..nGetNumDevices()-1]
private static native DirectAudioDeviceInfo nNewDirectAudioDeviceInfo(int deviceIndex);

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.Random;

View File

@ -35,8 +35,6 @@ import javax.sound.midi.ShortMessage;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
/**
* EventDispatcher. Used by various classes in the Java Sound implementation
* to send events.
@ -49,39 +47,35 @@ final class EventDispatcher implements Runnable {
/**
* time of inactivity until the auto closing clips
* are closed
* are closed.
*/
private static final int AUTO_CLOSE_TIME = 5000;
/**
* List of events
* List of events.
*/
private final ArrayList<EventInfo> eventQueue = new ArrayList<>();
/**
* Thread object for this EventDispatcher instance
* Thread object for this EventDispatcher instance.
*/
private Thread thread = null;
/*
* support for auto-closing Clips
*/
private final ArrayList<ClipInfo> autoClosingClips = new ArrayList<ClipInfo>();
private final ArrayList<ClipInfo> autoClosingClips = new ArrayList<>();
/*
* support for monitoring data lines
*/
private final ArrayList<LineMonitor> lineMonitors = new ArrayList<LineMonitor>();
private final ArrayList<LineMonitor> lineMonitors = new ArrayList<>();
/**
* Approximate interval between calls to LineMonitor.checkLine
*/
static final int LINE_MONITOR_TIME = 400;
/**
* This start() method starts an event thread if one is not already active.
*/
@ -96,7 +90,6 @@ final class EventDispatcher implements Runnable {
}
}
/**
* Invoked when there is at least one event in the queue.
* Implement this as a callback to process one event.
@ -153,7 +146,6 @@ final class EventDispatcher implements Runnable {
Printer.err("Unknown event type: " + eventInfo.getEvent());
}
/**
* Wait until there is something in the event queue to process. Then
* dispatch the event to the listeners.The entire method does not
@ -202,7 +194,6 @@ final class EventDispatcher implements Runnable {
}
}
/**
* Queue the given event in the event queue.
*/
@ -211,10 +202,10 @@ final class EventDispatcher implements Runnable {
notifyAll();
}
/**
* A loop to dispatch events.
*/
@Override
public void run() {
while (true) {
@ -226,7 +217,6 @@ final class EventDispatcher implements Runnable {
}
}
/**
* Send audio and MIDI events.
*/
@ -243,7 +233,6 @@ final class EventDispatcher implements Runnable {
postEvent(eventInfo);
}
/*
* go through the list of registered auto-closing
* Clip instances and close them, if appropriate
@ -291,7 +280,7 @@ final class EventDispatcher implements Runnable {
}
/**
* called from auto-closing clips when one of their open() method is called
* called from auto-closing clips when one of their open() method is called.
*/
void autoClosingClipOpened(AutoClosingClip clip) {
if (Printer.debug)Printer.debug("> EventDispatcher.autoClosingClipOpened ");
@ -316,7 +305,7 @@ final class EventDispatcher implements Runnable {
}
/**
* called from auto-closing clips when their closed() method is called
* called from auto-closing clips when their closed() method is called.
*/
void autoClosingClipClosed(AutoClosingClip clip) {
// nothing to do -- is removed from arraylist above
@ -340,9 +329,8 @@ final class EventDispatcher implements Runnable {
if (Printer.debug)Printer.debug("< EventDispatcher.monitorLines("+lineMonitors.size()+" monitors)");
}
/**
* Add this LineMonitor instance to the list of monitors
* Add this LineMonitor instance to the list of monitors.
*/
void addLineMonitor(LineMonitor lm) {
if (Printer.trace)Printer.trace("> EventDispatcher.addLineMonitor("+lm+")");
@ -362,7 +350,7 @@ final class EventDispatcher implements Runnable {
}
/**
* Remove this LineMonitor instance from the list of monitors
* Remove this LineMonitor instance from the list of monitors.
*/
void removeLineMonitor(LineMonitor lm) {
if (Printer.trace)Printer.trace("> EventDispatcher.removeLineMonitor("+lm+")");
@ -377,8 +365,6 @@ final class EventDispatcher implements Runnable {
if (Printer.debug)Printer.debug("< EventDispatcher.removeLineMonitor finished -- now ("+lineMonitors.size()+" monitors)");
}
// /////////////////////////////////// INNER CLASSES ////////////////////////////////////////// //
/**
* Container for an event and a set of listeners to deliver it to.
*/
@ -413,7 +399,7 @@ final class EventDispatcher implements Runnable {
/**
* Container for a clip with its expiration time
* Container for a clip with its expiration time.
*/
private class ClipInfo {
@ -421,7 +407,7 @@ final class EventDispatcher implements Runnable {
private final long expiration;
/**
* Create a new instance of this clip Info class
* Create a new instance of this clip Info class.
*/
ClipInfo(AutoClosingClip clip) {
this.clip = clip;
@ -440,13 +426,13 @@ final class EventDispatcher implements Runnable {
/**
* Interface that a class that wants to get regular
* line monitor events implements
* line monitor events implements.
*/
interface LineMonitor {
/**
* Called by event dispatcher in regular intervals
* Called by event dispatcher in regular intervals.
*/
public void checkLine();
void checkLine();
}
} // class EventDispatcher

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -588,7 +589,6 @@ public final class FFT {
i += jmax << 1;
}
}
// Perform Factor-4 Decomposition with 3 * complex operators and 8 +/-
@ -682,7 +682,6 @@ public final class FFT {
i += jmax << 1;
}
}
private void bitreversal(double[] data) {
@ -743,6 +742,5 @@ public final class FFT {
data[n] = data[m];
data[m] = tempi;
}
}
}

View File

@ -25,10 +25,11 @@
package com.sun.media.sound;
import javax.sound.midi.*;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.ShortMessage;
/**
* an optimized ShortMessage that does not need an array
* an optimized ShortMessage that does not need an array.
*
* @author Florian Bomers
*/
@ -51,6 +52,7 @@ final class FastShortMessage extends ShortMessage {
return packedMsg;
}
@Override
public byte[] getMessage() {
int length = 0;
try {
@ -73,6 +75,7 @@ final class FastShortMessage extends ShortMessage {
return returnedArray;
}
@Override
public int getLength() {
try {
return getDataLength(packedMsg & 0xFF) + 1;
@ -82,6 +85,7 @@ final class FastShortMessage extends ShortMessage {
return 0;
}
@Override
public void setMessage(int status) throws InvalidMidiDataException {
// check for valid values
int dataLength = getDataLength(status); // can throw InvalidMidiDataException
@ -91,35 +95,39 @@ final class FastShortMessage extends ShortMessage {
packedMsg = (packedMsg & 0xFFFF00) | (status & 0xFF);
}
@Override
public void setMessage(int status, int data1, int data2) throws InvalidMidiDataException {
getDataLength(status); // can throw InvalidMidiDataException
packedMsg = (status & 0xFF) | ((data1 & 0xFF) << 8) | ((data2 & 0xFF) << 16);
}
@Override
public void setMessage(int command, int channel, int data1, int data2) throws InvalidMidiDataException {
getDataLength(command); // can throw InvalidMidiDataException
packedMsg = (command & 0xF0) | (channel & 0x0F) | ((data1 & 0xFF) << 8) | ((data2 & 0xFF) << 16);
}
@Override
public int getChannel() {
return packedMsg & 0x0F;
}
@Override
public int getCommand() {
return packedMsg & 0xF0;
}
@Override
public int getData1() {
return (packedMsg & 0xFF00) >> 8;
}
@Override
public int getData2() {
return (packedMsg & 0xFF0000) >> 16;
}
@Override
public int getStatus() {
return packedMsg & 0xFF;
}
@ -129,6 +137,7 @@ final class FastShortMessage extends ShortMessage {
* as this object.
* @return a clone of this instance.
*/
@Override
public Object clone() {
try {
return new FastShortMessage(packedMsg);

View File

@ -25,10 +25,11 @@
package com.sun.media.sound;
import javax.sound.midi.*;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.SysexMessage;
/**
* optimized FastSysexMessage that doesn't copy the array upon instantiation
* optimized FastSysexMessage that doesn't copy the array upon instantiation.
*
* @author Florian Bomers
*/
@ -51,6 +52,7 @@ final class FastSysexMessage extends SysexMessage {
// overwrite this method so that the original data array,
// which is shared among all transmitters, cannot be modified
@Override
public void setMessage(byte[] data, int length) throws InvalidMidiDataException {
if ((data.length == 0) || (((data[0] & 0xFF) != 0xF0) && ((data[0] & 0xFF) != 0xF7))) {
super.setMessage(data, data.length); // will throw Exception

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.IOException;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -69,11 +69,12 @@ public final class JARSoundbankReader extends SoundbankReader {
return ok;
}
@Override
public Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException {
if (!isZIP(url))
return null;
ArrayList<Soundbank> soundbanks = new ArrayList<Soundbank>();
ArrayList<Soundbank> soundbanks = new ArrayList<>();
URLClassLoader ucl = URLClassLoader.newInstance(new URL[]{url});
InputStream stream = ucl.getResourceAsStream(
"META-INF/services/javax.sound.midi.Soundbank");
@ -114,12 +115,14 @@ public final class JARSoundbankReader extends SoundbankReader {
return sbk;
}
@Override
public Soundbank getSoundbank(InputStream stream)
throws InvalidMidiDataException, IOException {
Objects.requireNonNull(stream);
return null;
}
@Override
public Soundbank getSoundbank(File file)
throws InvalidMidiDataException, IOException {
return getSoundbank(file.toURI().toURL());

View File

@ -136,7 +136,6 @@ public final class JDK13Services {
return value;
}
/** Obtain the instance name part of a default provider property.
@param typeClass The type of the default provider property. This
should be one of Receiver.class, Transmitter.class, Sequencer.class,
@ -158,7 +157,6 @@ public final class JDK13Services {
return value;
}
/** Obtain the value of a default provider property.
@param typeClass The type of the default provider property. This
should be one of Receiver.class, Transmitter.class, Sequencer.class,
@ -190,7 +188,6 @@ public final class JDK13Services {
return value;
}
/** Obtain a properties bundle containing property values from the
properties file. If the properties file could not be loaded,
the properties bundle is empty.

View File

@ -26,19 +26,17 @@
package com.sun.media.sound;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.ServiceLoader;
import java.security.AccessController;
import java.security.PrivilegedAction;
import javax.sound.sampled.AudioPermission;
/** Managing security in the Java Sound implementation.
@ -64,7 +62,6 @@ final class JSSecurityManager {
return (System.getSecurityManager() != null);
}
static void checkRecordPermission() throws SecurityException {
if(Printer.trace) Printer.trace("JSSecurityManager.checkRecordPermission()");
SecurityManager sm = System.getSecurityManager();
@ -90,6 +87,7 @@ final class JSSecurityManager {
try {
// invoke the privileged action using 1.2 security
PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
@Override
public Void run() {
loadPropertiesImpl(properties, filename);
return null;
@ -108,7 +106,6 @@ final class JSSecurityManager {
}
}
private static void loadPropertiesImpl(Properties properties,
String filename) {
if(Printer.trace)Printer.trace(">> JSSecurityManager: loadPropertiesImpl()");
@ -176,6 +173,7 @@ final class JSSecurityManager {
// the iterator's hasNext() method looks through classpath for
// the provider class names, so it requires read permissions
PrivilegedAction<Boolean> hasNextAction = new PrivilegedAction<Boolean>() {
@Override
public Boolean run() {
return ps.hasNext();
}

View File

@ -25,30 +25,29 @@
package com.sun.media.sound;
import java.io.IOException;
import java.io.InputStream;
import java.applet.AudioClip;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.applet.AudioClip;
import java.io.IOException;
import java.io.InputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiFileFormat;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MetaEventListener;
import javax.sound.midi.MetaMessage;
import javax.sound.midi.MidiFileFormat;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.MetaEventListener;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException;
/**
* Java Sound audio clip;
@ -56,7 +55,6 @@ import javax.sound.midi.MetaEventListener;
* @author Arthur van Hoff, Kara Kytle, Jan Borgersen
* @author Florian Bomers
*/
public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, LineListener {
private static final boolean DEBUG = false;
@ -126,12 +124,12 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
}
}
@Override
public synchronized void play() {
startImpl(false);
}
@Override
public synchronized void loop() {
startImpl(true);
}
@ -205,6 +203,7 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
}
}
@Override
public synchronized void stop() {
if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip->stop()");
@ -248,13 +247,15 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
// Event handlers (for debugging)
@Override
public synchronized void update(LineEvent event) {
if (DEBUG || Printer.debug) Printer.debug("line event received: "+event);
}
// handle MIDI track end meta events for looping
public synchronized void meta( MetaMessage message ) {
@Override
public synchronized void meta(MetaMessage message) {
if (DEBUG || Printer.debug)Printer.debug("META EVENT RECEIVED!!!!! ");
@ -269,12 +270,12 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
}
}
@Override
public String toString() {
return getClass().toString();
}
@Override
protected void finalize() {
if (clip != null) {
@ -326,8 +327,6 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
return true;
}
private void readStream(AudioInputStream as, long byteLen) throws IOException {
// arrays "only" max. 2GB
int intLen;
@ -371,7 +370,6 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
loadedAudioByteLength = totalBytesRead;
}
// METHODS FOR CREATING THE DEVICE
private boolean createClip() {
@ -464,7 +462,6 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
return true;
}
/*
* private inner class representing a ByteArrayOutputStream
* which allows retrieval of the internal array
@ -479,5 +476,4 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
}
} // class DirectBAOS
}

View File

@ -22,10 +22,13 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import javax.sound.midi.*;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiDeviceReceiver;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.Receiver;
/**
* Helper class which allows to convert {@code Receiver}
@ -55,15 +58,18 @@ public final class MidiDeviceReceiverEnvelope implements MidiDeviceReceiver {
}
// Receiver implementation
@Override
public void close() {
receiver.close();
}
@Override
public void send(MidiMessage message, long timeStamp) {
receiver.send(message, timeStamp);
}
// MidiDeviceReceiver implementation
@Override
public MidiDevice getMidiDevice() {
return device;
}

View File

@ -22,10 +22,13 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import javax.sound.midi.*;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiDeviceTransmitter;
import javax.sound.midi.Receiver;
import javax.sound.midi.Transmitter;
/**
* Helper class which allows to convert {@code Transmitter}
@ -55,20 +58,23 @@ public final class MidiDeviceTransmitterEnvelope implements MidiDeviceTransmitte
}
// Transmitter implementation
@Override
public void setReceiver(Receiver receiver) {
transmitter.setReceiver(receiver);
}
@Override
public Receiver getReceiver() {
return transmitter.getReceiver();
}
@Override
public void close() {
transmitter.close();
}
// MidiDeviceReceiver implementation
@Override
public MidiDevice getMidiDevice() {
return device;
}

View File

@ -25,9 +25,8 @@
package com.sun.media.sound;
import javax.sound.midi.*;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Transmitter;
/**
* MidiInDevice class representing functionality of MidiIn devices.
@ -40,18 +39,14 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
private volatile Thread midiInThread;
// CONSTRUCTOR
MidiInDevice(AbstractMidiDeviceProvider.Info info) {
super(info);
if(Printer.trace) Printer.trace("MidiInDevice CONSTRUCTOR");
}
// IMPLEMENTATION OF ABSTRACT MIDI DEVICE METHODS
// $$kk: 06.24.99: i have this both opening and starting the midi in device.
// may want to separate these??
@Override
protected synchronized void implOpen() throws MidiUnavailableException {
if (Printer.trace) Printer.trace("> MidiInDevice: implOpen()");
@ -75,9 +70,9 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
if (Printer.trace) Printer.trace("< MidiInDevice: implOpen() completed");
}
// $$kk: 06.24.99: i have this both stopping and closing the midi in device.
// may want to separate these??
@Override
protected synchronized void implClose() {
if (Printer.trace) Printer.trace("> MidiInDevice: implClose()");
long oldId = id;
@ -98,7 +93,7 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
if (Printer.trace) Printer.trace("< MidiInDevice: implClose() completed");
}
@Override
public long getMicrosecondPosition() {
long timestamp = -1;
if (isOpen()) {
@ -107,22 +102,21 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
return timestamp;
}
// OVERRIDES OF ABSTRACT MIDI DEVICE METHODS
@Override
protected boolean hasTransmitters() {
return true;
}
@Override
protected Transmitter createTransmitter() {
return new MidiInTransmitter();
}
/**
* An own class to distinguish the class name from
* the transmitter of other devices
* the transmitter of other devices.
*/
private final class MidiInTransmitter extends BasicTransmitter {
private MidiInTransmitter() {
@ -130,8 +124,7 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
}
}
// RUNNABLE METHOD
@Override
public void run() {
// while the device is started, keep trying to get messages.
// this thread returns from native code whenever stop() or close() is called
@ -149,9 +142,6 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
midiInThread = null;
}
// CALLBACKS FROM NATIVE
/**
* Callback from native code when a short MIDI event is received from hardware.
* @param packedMsg: status | data1 << 8 | data2 << 8
@ -179,8 +169,6 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
getTransmitterList().sendMessage(data, timeStamp);
}
// NATIVE METHODS
private native long nOpen(int index) throws MidiUnavailableException;
private native void nClose(long id);
@ -190,6 +178,4 @@ final class MidiInDevice extends AbstractMidiDevice implements Runnable {
// go into native code and get messages. May be blocking
private native void nGetMessages(long id);
}

View File

@ -27,7 +27,6 @@ package com.sun.media.sound;
import javax.sound.midi.MidiDevice;
/**
* MIDI input device provider.
*
@ -44,16 +43,12 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
private static final boolean enabled;
// STATIC
static {
// initialize
Platform.initialize();
enabled = Platform.isMidiIOEnabled();
}
// CONSTRUCTOR
/**
* Required public no-arg constructor.
*/
@ -63,6 +58,7 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
// implementation of abstract methods in AbstractMidiDeviceProvider
@Override
AbstractMidiDeviceProvider.Info createInfo(int index) {
if (!enabled) {
return null;
@ -70,6 +66,7 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
return new MidiInDeviceInfo(index, MidiInDeviceProvider.class);
}
@Override
MidiDevice createDevice(AbstractMidiDeviceProvider.Info info) {
if (enabled && (info instanceof MidiInDeviceInfo)) {
return new MidiInDevice(info);
@ -77,6 +74,7 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
return null;
}
@Override
int getNumDevices() {
if (!enabled) {
if (Printer.debug)Printer.debug("MidiInDevice not enabled, returning 0 devices");
@ -87,14 +85,15 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
return numDevices;
}
@Override
MidiDevice[] getDeviceCache() { return devices; }
@Override
void setDeviceCache(MidiDevice[] devices) { MidiInDeviceProvider.devices = devices; }
@Override
Info[] getInfoCache() { return infos; }
@Override
void setInfoCache(Info[] infos) { MidiInDeviceProvider.infos = infos; }
// INNER CLASSES
/**
* Info class for MidiInDevices. Adds the
* provider's Class to keep the provider class from being
@ -115,9 +114,6 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
} // class MidiInDeviceInfo
// NATIVE METHODS
private static native int nGetNumDevices();
private static native String nGetName(int index);
private static native String nGetVendor(int index);

View File

@ -25,9 +25,10 @@
package com.sun.media.sound;
import javax.sound.midi.*;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Receiver;
import javax.sound.midi.ShortMessage;
/**
* MidiOutDevice class representing functionality of MidiOut devices.
@ -38,16 +39,12 @@ import javax.sound.midi.*;
*/
final class MidiOutDevice extends AbstractMidiDevice {
// CONSTRUCTOR
MidiOutDevice(AbstractMidiDeviceProvider.Info info) {
super(info);
if(Printer.trace) Printer.trace("MidiOutDevice CONSTRUCTOR");
}
// IMPLEMENTATION OF ABSTRACT MIDI DEVICE METHODS
@Override
protected synchronized void implOpen() throws MidiUnavailableException {
if (Printer.trace) Printer.trace("> MidiOutDevice: implOpen()");
int index = ((AbstractMidiDeviceProvider.Info)getDeviceInfo()).getIndex();
@ -58,7 +55,7 @@ final class MidiOutDevice extends AbstractMidiDevice {
if (Printer.trace) Printer.trace("< MidiOutDevice: implOpen(): completed.");
}
@Override
protected synchronized void implClose() {
if (Printer.trace) Printer.trace("> MidiOutDevice: implClose()");
// prevent further action
@ -72,7 +69,7 @@ final class MidiOutDevice extends AbstractMidiDevice {
if (Printer.trace) Printer.trace("< MidiOutDevice: implClose(): completed");
}
@Override
public long getMicrosecondPosition() {
long timestamp = -1;
if (isOpen()) {
@ -81,28 +78,23 @@ final class MidiOutDevice extends AbstractMidiDevice {
return timestamp;
}
// OVERRIDES OF ABSTRACT MIDI DEVICE METHODS
/** Returns if this device supports Receivers.
This implementation always returns true.
@return true, if the device supports Receivers, false otherwise.
*/
@Override
protected boolean hasReceivers() {
return true;
}
@Override
protected Receiver createReceiver() {
return new MidiOutReceiver();
}
// INNER CLASSES
final class MidiOutReceiver extends AbstractReceiver {
@Override
void implSend(final MidiMessage message, final long timeStamp) {
final int length = message.getLength();
final int status = message.getStatus();
@ -159,13 +151,8 @@ final class MidiOutDevice extends AbstractMidiDevice {
nSendShortMessage(id, packedMsg, timeStamp);
}
}
} // class MidiOutReceiver
// NATIVE METHODS
private native long nOpen(int index) throws MidiUnavailableException;
private native void nClose(long id);

View File

@ -27,7 +27,6 @@ package com.sun.media.sound;
import javax.sound.midi.MidiDevice;
/**
* MIDI output device provider.
*
@ -44,16 +43,12 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
private static final boolean enabled;
// STATIC
static {
// initialize
Platform.initialize();
enabled = Platform.isMidiIOEnabled();
}
// CONSTRUCTOR
/**
* Required public no-arg constructor.
*/
@ -61,8 +56,7 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
if (Printer.trace) Printer.trace("MidiOutDeviceProvider: constructor");
}
// implementation of abstract methods in AbstractMidiDeviceProvider
@Override
AbstractMidiDeviceProvider.Info createInfo(int index) {
if (!enabled) {
return null;
@ -70,6 +64,7 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
return new MidiOutDeviceInfo(index, MidiOutDeviceProvider.class);
}
@Override
MidiDevice createDevice(AbstractMidiDeviceProvider.Info info) {
if (enabled && (info instanceof MidiOutDeviceInfo)) {
return new MidiOutDevice(info);
@ -77,6 +72,7 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
return null;
}
@Override
int getNumDevices() {
if (!enabled) {
if (Printer.debug)Printer.debug("MidiOutDevice not enabled, returning 0 devices");
@ -85,14 +81,15 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
return nGetNumDevices();
}
@Override
MidiDevice[] getDeviceCache() { return devices; }
@Override
void setDeviceCache(MidiDevice[] devices) { MidiOutDeviceProvider.devices = devices; }
@Override
Info[] getInfoCache() { return infos; }
@Override
void setInfoCache(Info[] infos) { MidiOutDeviceProvider.infos = infos; }
// INNER CLASSES
/**
* Info class for MidiOutDevices. Adds the
* provider's Class to keep the provider class from being
@ -113,9 +110,6 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
} // class MidiOutDeviceInfo
// NATIVE METHODS
private static native int nGetNumDevices();
private static native String nGetName(int index);
private static native String nGetVendor(int index);

View File

@ -77,7 +77,6 @@ public final class MidiUtils {
return ((msg[1] & 0xFF) == META_END_OF_TRACK_TYPE) && (msg[2] == 0);
}
/** return if the given message is a meta tempo message */
public static boolean isMetaTempo(MidiMessage midiMsg) {
// first check if it is a META message at all
@ -91,7 +90,6 @@ public final class MidiUtils {
return ((msg[1] & 0xFF) == META_TEMPO_TYPE) && (msg[2] == 3);
}
/** parses this message for a META tempo message and returns
* the tempo in MPQ, or -1 if this isn't a tempo message
*/
@ -111,7 +109,6 @@ public final class MidiUtils {
return tempo;
}
/**
* converts<br>
* 1 - MPQ-Tempo to BPM tempo<br>
@ -124,7 +121,6 @@ public final class MidiUtils {
return ((double) 60000000l) / tempo;
}
/**
* convert tick to microsecond with given tempo.
* Does not take tempo changes into account.
@ -145,7 +141,6 @@ public final class MidiUtils {
return (long) ((((double)us) * resolution) / tempoMPQ);
}
/**
* Given a tick, convert to microsecond
* @param cache tempo info and current tempo
@ -246,7 +241,6 @@ public final class MidiUtils {
return tick;
}
/**
* Binary search for the event indexes of the track
*
@ -283,7 +277,6 @@ public final class MidiUtils {
return ret;
}
public static final class TempoCache {
long[] ticks;
int[] tempos; // in MPQ
@ -310,7 +303,6 @@ public final class MidiUtils {
refresh(seq);
}
public synchronized void refresh(Sequence seq) {
ArrayList<MidiEvent> list = new ArrayList<>();
Track[] tracks = seq.getTracks();
@ -373,6 +365,5 @@ public final class MidiUtils {
}
return tempos[tempos.length - 1];
}
}
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -32,95 +33,123 @@ package com.sun.media.sound;
*/
public abstract class ModelAbstractChannelMixer implements ModelChannelMixer {
@Override
public abstract boolean process(float[][] buffer, int offset, int len);
@Override
public abstract void stop();
@Override
public void allNotesOff() {
}
@Override
public void allSoundOff() {
}
@Override
public void controlChange(int controller, int value) {
}
@Override
public int getChannelPressure() {
return 0;
}
@Override
public int getController(int controller) {
return 0;
}
@Override
public boolean getMono() {
return false;
}
@Override
public boolean getMute() {
return false;
}
@Override
public boolean getOmni() {
return false;
}
@Override
public int getPitchBend() {
return 0;
}
@Override
public int getPolyPressure(int noteNumber) {
return 0;
}
@Override
public int getProgram() {
return 0;
}
@Override
public boolean getSolo() {
return false;
}
@Override
public boolean localControl(boolean on) {
return false;
}
@Override
public void noteOff(int noteNumber) {
}
@Override
public void noteOff(int noteNumber, int velocity) {
}
@Override
public void noteOn(int noteNumber, int velocity) {
}
@Override
public void programChange(int program) {
}
@Override
public void programChange(int bank, int program) {
}
@Override
public void resetAllControllers() {
}
@Override
public void setChannelPressure(int pressure) {
}
@Override
public void setMono(boolean on) {
}
@Override
public void setMute(boolean mute) {
}
@Override
public void setOmni(boolean on) {
}
@Override
public void setPitchBend(int bend) {
}
@Override
public void setPolyPressure(int noteNumber, int pressure) {
}
@Override
public void setSolo(boolean soloState) {
}
}

View File

@ -22,9 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.IOException;
import javax.sound.midi.Instrument;
import javax.sound.midi.MidiChannel;
import javax.sound.midi.Patch;
@ -51,15 +53,18 @@ public abstract class ModelAbstractOscillator
public void init() {
}
@Override
public void close() throws IOException {
}
@Override
public void noteOff(int velocity) {
on = false;
}
@Override
public void noteOn(MidiChannel channel, VoiceStatus voice, int noteNumber,
int velocity) {
int velocity) {
this.channel = channel;
this.voice = voice;
this.noteNumber = noteNumber;
@ -67,6 +72,7 @@ public abstract class ModelAbstractOscillator
on = true;
}
@Override
public int read(float[][] buffer, int offset, int len) throws IOException {
return -1;
}
@ -91,6 +97,7 @@ public abstract class ModelAbstractOscillator
return on;
}
@Override
public void setPitch(float pitch) {
this.pitch = pitch;
}
@ -107,14 +114,17 @@ public abstract class ModelAbstractOscillator
return samplerate;
}
@Override
public float getAttenuation() {
return 0;
}
@Override
public int getChannels() {
return 1;
}
@Override
public String getName() {
return getClass().getName();
}
@ -123,6 +133,7 @@ public abstract class ModelAbstractOscillator
return new Patch(0, 0);
}
@Override
public ModelOscillatorStream open(float samplerate) {
ModelAbstractOscillator oscs;
try {
@ -162,10 +173,12 @@ public abstract class ModelAbstractOscillator
return sbk;
}
@Override
public String getDescription() {
return getName();
}
@Override
public Instrument getInstrument(Patch patch) {
Instrument ins = getInstrument();
Patch p = ins.getPatch();
@ -182,18 +195,22 @@ public abstract class ModelAbstractOscillator
return ins;
}
@Override
public Instrument[] getInstruments() {
return new Instrument[]{getInstrument()};
}
@Override
public SoundbankResource[] getResources() {
return new SoundbankResource[0];
}
@Override
public String getVendor() {
return null;
}
@Override
public String getVersion() {
return null;
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.ByteArrayInputStream;
@ -60,12 +61,14 @@ public final class ModelByteBuffer {
left = capacity();
}
@Override
public int available() throws IOException {
if (left > Integer.MAX_VALUE)
return Integer.MAX_VALUE;
return (int)left;
}
@Override
public synchronized void mark(int readlimit) {
try {
mark = raf.getFilePointer();
@ -75,15 +78,18 @@ public final class ModelByteBuffer {
}
}
@Override
public boolean markSupported() {
return true;
}
@Override
public synchronized void reset() throws IOException {
raf.seek(mark);
left = markleft;
}
@Override
public long skip(long n) throws IOException {
if( n < 0)
return 0;
@ -95,6 +101,7 @@ public final class ModelByteBuffer {
return n;
}
@Override
public int read(byte b[], int off, int len) throws IOException {
if (len > left)
len = (int)left;
@ -107,6 +114,7 @@ public final class ModelByteBuffer {
return len;
}
@Override
public int read(byte[] b) throws IOException {
int len = b.length;
if (len > left)
@ -120,6 +128,7 @@ public final class ModelByteBuffer {
return len;
}
@Override
public int read() throws IOException {
if (left == 0)
return -1;
@ -130,6 +139,7 @@ public final class ModelByteBuffer {
return b;
}
@Override
public void close() throws IOException {
raf.close();
}

View File

@ -22,14 +22,16 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.IOException;
import java.io.InputStream;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioFormat.Encoding;
/**
* Wavetable oscillator for pre-loaded data.
@ -52,6 +54,7 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
bigendian = format.isBigEndian();
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
int avail = available();
if (avail <= 0)
@ -82,6 +85,7 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
return len;
}
@Override
public long skip(long n) throws IOException {
int avail = available();
if (avail <= 0)
@ -93,10 +97,12 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
return super.skip(n);
}
@Override
public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
@Override
public int read() throws IOException {
byte[] b = new byte[1];
int ret = read(b, 0, 1);
@ -105,19 +111,23 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
return 0 & 0xFF;
}
@Override
public boolean markSupported() {
return true;
}
@Override
public int available() throws IOException {
return (int)buffer.capacity() + (int)buffer8.capacity() - pos - pos2;
}
@Override
public synchronized void mark(int readlimit) {
markpos = pos;
markpos2 = pos2;
}
@Override
public synchronized void reset() throws IOException {
pos = markpos;
pos2 = markpos2;
@ -189,6 +199,7 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
return format;
}
@Override
public AudioFloatInputStream openStream() {
if (buffer == null)
return null;
@ -230,16 +241,19 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
(int)buffer.arrayOffset(), (int)buffer.capacity());
}
@Override
public int getChannels() {
return getFormat().getChannels();
}
@Override
public ModelOscillatorStream open(float samplerate) {
// ModelWavetableOscillator doesn't support ModelOscillatorStream
return null;
}
// attenuation is in cB
@Override
public float getAttenuation() {
return attenuation;
}
@ -248,6 +262,7 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
this.attenuation = attenuation;
}
@Override
public float getLoopLength() {
return loopLength;
}
@ -256,6 +271,7 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
this.loopLength = loopLength;
}
@Override
public float getLoopStart() {
return loopStart;
}
@ -268,10 +284,12 @@ public final class ModelByteBufferWavetable implements ModelWavetable {
this.loopType = loopType;
}
@Override
public int getLoopType() {
return loopType;
}
@Override
public float getPitchcorrection() {
return pitchcorrection;
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import javax.sound.midi.MidiChannel;
@ -42,9 +43,9 @@ import javax.sound.midi.MidiChannel;
public interface ModelChannelMixer extends MidiChannel {
// Used to process input audio from voices mix.
public boolean process(float[][] buffer, int offset, int len);
boolean process(float[][] buffer, int offset, int len);
// Is used to trigger that this mixer is not be used
// and it should fade out.
public void stop();
void stop();
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.Arrays;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -32,5 +33,5 @@ package com.sun.media.sound;
*/
public interface ModelDirectedPlayer {
public void play(int performerIndex, ModelConnectionBlock[] connectionBlocks);
void play(int performerIndex, ModelConnectionBlock[] connectionBlocks);
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -38,9 +39,9 @@ package com.sun.media.sound;
*/
public interface ModelDirector {
public void noteOn(int noteNumber, int velocity);
void noteOn(int noteNumber, int velocity);
public void noteOff(int noteNumber, int velocity);
void noteOff(int noteNumber, int velocity);
public void close();
void close();
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -134,6 +135,7 @@ public final class ModelIdentifier {
this.variable = variable;
}
@Override
public int hashCode() {
int hashcode = instance;
if(object != null) hashcode |= object.hashCode();
@ -141,6 +143,7 @@ public final class ModelIdentifier {
return hashcode;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ModelIdentifier))
return false;
@ -159,6 +162,7 @@ public final class ModelIdentifier {
return true;
}
@Override
public String toString() {
if (variable == null) {
return object + "[" + instance + "]";

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import javax.sound.midi.Instrument;

View File

@ -22,9 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.Comparator;
import javax.sound.midi.Instrument;
import javax.sound.midi.Patch;
@ -36,6 +38,7 @@ import javax.sound.midi.Patch;
*/
public final class ModelInstrumentComparator implements Comparator<Instrument> {
@Override
public int compare(Instrument arg0, Instrument arg1) {
Patch p0 = arg0.getPatch();
Patch p1 = arg1.getPatch();

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import javax.sound.midi.MidiChannel;
@ -42,21 +43,25 @@ public final class ModelMappedInstrument extends ModelInstrument {
this.ins = ins;
}
@Override
public Object getData() {
return ins.getData();
}
@Override
public ModelPerformer[] getPerformers() {
return ins.getPerformers();
}
@Override
public ModelDirector getDirector(ModelPerformer[] performers,
MidiChannel channel, ModelDirectedPlayer player) {
MidiChannel channel, ModelDirectedPlayer player) {
return ins.getDirector(performers, channel, player);
}
@Override
public ModelChannelMixer getChannelMixer(MidiChannel channel,
AudioFormat format) {
AudioFormat format) {
return ins.getChannelMixer(channel, format);
}
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -32,13 +33,13 @@ package com.sun.media.sound;
*/
public interface ModelOscillator {
public int getChannels();
int getChannels();
/**
* Attenuation is in cB.
* @return
*/
public float getAttenuation();
float getAttenuation();
public ModelOscillatorStream open(float samplerate);
ModelOscillatorStream open(float samplerate);
}

View File

@ -22,9 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.IOException;
import javax.sound.midi.MidiChannel;
import javax.sound.midi.VoiceStatus;
@ -35,14 +37,14 @@ import javax.sound.midi.VoiceStatus;
*/
public interface ModelOscillatorStream {
public void setPitch(float pitch); // Pitch is in cents!
void setPitch(float pitch); // Pitch is in cents!
public void noteOn(MidiChannel channel, VoiceStatus voice, int noteNumber,
int velocity);
void noteOn(MidiChannel channel, VoiceStatus voice, int noteNumber,
int velocity);
public void noteOff(int velocity);
void noteOff(int velocity);
public int read(float[][] buffer, int offset, int len) throws IOException;
int read(float[][] buffer, int offset, int len) throws IOException;
public void close() throws IOException;
void close() throws IOException;
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import javax.sound.midi.Patch;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.ArrayList;
@ -35,9 +36,9 @@ import java.util.List;
*/
public final class ModelPerformer {
private final List<ModelOscillator> oscillators = new ArrayList<ModelOscillator>();
private List<ModelConnectionBlock> connectionBlocks
= new ArrayList<ModelConnectionBlock>();
private final List<ModelOscillator> oscillators = new ArrayList<>();
private List<ModelConnectionBlock> connectionBlocks = new ArrayList<>();
private int keyFrom = 0;
private int keyTo = 127;
private int velFrom = 0;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.Arrays;
@ -52,9 +53,11 @@ public final class ModelStandardDirector implements ModelDirector {
}
}
@Override
public void close() {
}
@Override
public void noteOff(int noteNumber, int velocity) {
if (!noteOffUsed)
return;
@ -70,6 +73,7 @@ public final class ModelStandardDirector implements ModelDirector {
}
}
@Override
public void noteOn(int noteNumber, int velocity) {
if (!noteOnUsed)
return;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.Arrays;
@ -156,9 +157,11 @@ public final class ModelStandardIndexedDirector implements ModelDirector {
}
}
@Override
public void close() {
}
@Override
public void noteOff(int noteNumber, int velocity) {
if (!noteOffUsed)
return;
@ -172,6 +175,7 @@ public final class ModelStandardIndexedDirector implements ModelDirector {
}
}
@Override
public void noteOn(int noteNumber, int velocity) {
if (!noteOnUsed)
return;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -73,6 +74,7 @@ public final class ModelStandardTransform implements ModelTransform {
this.transform = transform;
}
@Override
public double transform(double value) {
double s;
double a;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -31,5 +32,5 @@ package com.sun.media.sound;
*/
public interface ModelTransform {
public abstract double transform(double value);
double transform(double value);
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**
@ -31,19 +32,19 @@ package com.sun.media.sound;
*/
public interface ModelWavetable extends ModelOscillator {
public static final int LOOP_TYPE_OFF = 0;
public static final int LOOP_TYPE_FORWARD = 1;
public static final int LOOP_TYPE_RELEASE = 2;
public static final int LOOP_TYPE_PINGPONG = 4;
public static final int LOOP_TYPE_REVERSE = 8;
int LOOP_TYPE_OFF = 0;
int LOOP_TYPE_FORWARD = 1;
int LOOP_TYPE_RELEASE = 2;
int LOOP_TYPE_PINGPONG = 4;
int LOOP_TYPE_REVERSE = 8;
public AudioFloatInputStream openStream();
AudioFloatInputStream openStream();
public float getLoopLength();
float getLoopLength();
public float getLoopStart();
float getLoopStart();
public int getLoopType();
int getLoopType();
public float getPitchcorrection();
float getPitchcorrection();
}

View File

@ -40,7 +40,6 @@ import javax.sound.sampled.AudioSystem;
*/
public final class PCMtoPCMCodec extends SunCodec {
private static final AudioFormat.Encoding[] inputEncodings = {
AudioFormat.Encoding.PCM_SIGNED,
AudioFormat.Encoding.PCM_UNSIGNED,
@ -59,8 +58,7 @@ public final class PCMtoPCMCodec extends SunCodec {
super( inputEncodings, outputEncodings);
}
// NEW CODE
@Override
public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat) {
final int sampleSize = sourceFormat.getSampleSizeInBits();
@ -88,9 +86,7 @@ public final class PCMtoPCMCodec extends SunCodec {
return new AudioFormat.Encoding[0];
}
/**
*/
@Override
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
Objects.requireNonNull(targetEncoding);
@ -113,9 +109,7 @@ public final class PCMtoPCMCodec extends SunCodec {
return formatArray;
}
/**
*/
@Override
public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream) {
if( isConversionSupported(targetEncoding, sourceStream.getFormat()) ) {
@ -136,9 +130,8 @@ public final class PCMtoPCMCodec extends SunCodec {
}
}
/**
* use old code
*/
@Override
public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream){
if (!isConversionSupported(targetFormat, sourceStream.getFormat()))
throw new IllegalArgumentException("Unsupported conversion: "
@ -147,11 +140,6 @@ public final class PCMtoPCMCodec extends SunCodec {
return getConvertedStream( targetFormat, sourceStream );
}
// OLD CODE
/**
* Opens the codec with the specified parameters.
* @param stream stream from which data to be processed should be read
@ -160,7 +148,6 @@ public final class PCMtoPCMCodec extends SunCodec {
* @throws IllegalArgumentException if the format combination supplied is
* not supported.
*/
/* public AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {*/
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {
AudioInputStream cs = null;
@ -172,13 +159,11 @@ public final class PCMtoPCMCodec extends SunCodec {
cs = stream;
} else {
cs = (AudioInputStream) (new PCMtoPCMCodecStream(stream, outputFormat));
cs = new PCMtoPCMCodecStream(stream, outputFormat);
}
return cs;
}
/**
* Obtains the set of output formats supported by the codec
* given a particular input format.
@ -186,7 +171,6 @@ public final class PCMtoPCMCodec extends SunCodec {
* returns an array of length 0.
* @return array of supported output formats.
*/
/* public AudioFormat[] getOutputFormats(AudioFormat inputFormat) { */
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
Vector<AudioFormat> formats = new Vector<>();
@ -350,7 +334,6 @@ public final class PCMtoPCMCodec extends SunCodec {
return formatArray;
}
class PCMtoPCMCodecStream extends AudioInputStream {
private final int PCM_SWITCH_SIGNED_8BIT = 1;
@ -460,7 +443,7 @@ public final class PCMtoPCMCodec extends SunCodec {
* Note that this only works for sign conversions.
* Other conversions require a read of at least 2 bytes.
*/
@Override
public int read() throws IOException {
// $$jb: do we want to implement this function?
@ -489,12 +472,13 @@ public final class PCMtoPCMCodec extends SunCodec {
}
}
@Override
public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
@ -589,9 +573,5 @@ public final class PCMtoPCMCodec extends SunCodec {
}
}
}
} // end class PCMtoPCMCodecStream
} // end class PCMtoPCMCodec

View File

@ -29,8 +29,6 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.StringTokenizer;
/**
* Audio configuration class for exposing attributes specific to the platform or system.
*
@ -39,9 +37,6 @@ import java.util.StringTokenizer;
*/
final class Platform {
// STATIC FINAL CHARACTERISTICS
// native library we need to load
private static final String libNameMain = "jsound";
private static final String libNameALSA = "jsoundalsa";
@ -74,37 +69,26 @@ final class Platform {
readProperties();
}
/**
* Private constructor.
*/
private Platform() {
}
// METHODS FOR INTERNAL IMPLEMENTATION USE
/**
* Dummy method for forcing initialization.
*/
static void initialize() {
if(Printer.trace)Printer.trace("Platform: initialize()");
}
/**
* Determine whether the system is big-endian.
*/
static boolean isBigEndian() {
return bigEndian;
}
// PRIVATE METHODS
/**
* Load the native library or libraries.
*/
@ -147,7 +131,6 @@ final class Platform {
}
}
static boolean isMidiIOEnabled() {
return isFeatureLibLoaded(FEATURE_MIDIIO);
}

View File

@ -27,14 +27,13 @@ package com.sun.media.sound;
import java.util.Vector;
import javax.sound.sampled.BooleanControl;
import javax.sound.sampled.CompoundControl;
import javax.sound.sampled.Control;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Port;
import javax.sound.sampled.BooleanControl;
import javax.sound.sampled.CompoundControl;
import javax.sound.sampled.FloatControl;
/**
* A Mixer which only provides Ports.
@ -43,7 +42,6 @@ import javax.sound.sampled.FloatControl;
*/
final class PortMixer extends AbstractMixer {
// CONSTANTS
private static final int SRC_UNKNOWN = 0x01;
private static final int SRC_MICROPHONE = 0x02;
private static final int SRC_LINE_IN = 0x03;
@ -56,15 +54,13 @@ final class PortMixer extends AbstractMixer {
private static final int DST_LINE_OUT = 0x0400;
private static final int DST_MASK = 0xFF00;
// INSTANCE VARIABLES
private Port.Info[] portInfos;
private final Port.Info[] portInfos;
// cache of instantiated ports
private PortMixerPort[] ports;
// instance ID of the native implementation
private long id = 0;
// CONSTRUCTOR
PortMixer(PortMixerProvider.PortMixerInfo portMixerInfo) {
// pass in Line.Info, mixer, controls
super(portMixerInfo, // Mixer.Info
@ -121,9 +117,7 @@ final class PortMixer extends AbstractMixer {
if (Printer.trace) Printer.trace("<< PortMixer: constructor completed");
}
// ABSTRACT MIXER: ABSTRACT METHOD IMPLEMENTATIONS
@Override
public Line getLine(Line.Info info) throws LineUnavailableException {
Line.Info fullInfo = getLineInfo(info);
@ -137,7 +131,7 @@ final class PortMixer extends AbstractMixer {
throw new IllegalArgumentException("Line unsupported: " + info);
}
@Override
public int getMaxLines(Line.Info info) {
Line.Info fullInfo = getLineInfo(info);
@ -153,7 +147,7 @@ final class PortMixer extends AbstractMixer {
return 0;
}
@Override
protected void implOpen() throws LineUnavailableException {
if (Printer.trace) Printer.trace(">> PortMixer: implOpen (id="+id+")");
@ -163,6 +157,7 @@ final class PortMixer extends AbstractMixer {
if (Printer.trace) Printer.trace("<< PortMixer: implOpen succeeded.");
}
@Override
protected void implClose() {
if (Printer.trace) Printer.trace(">> PortMixer: implClose");
@ -181,11 +176,11 @@ final class PortMixer extends AbstractMixer {
if (Printer.trace) Printer.trace("<< PortMixer: implClose succeeded");
}
@Override
protected void implStart() {}
@Override
protected void implStop() {}
// IMPLEMENTATION HELPERS
private Port.Info getPortInfo(int portIndex, int type) {
switch (type) {
case SRC_UNKNOWN: return new PortInfo(nGetPortName(getID(), portIndex), true);
@ -223,8 +218,6 @@ final class PortMixer extends AbstractMixer {
return id;
}
// INNER CLASSES
/**
* Private inner class representing a Port for the PortMixer.
*/
@ -234,7 +227,6 @@ final class PortMixer extends AbstractMixer {
private final int portIndex;
private long id;
// CONSTRUCTOR
private PortMixerPort(Port.Info info,
PortMixer mixer,
int portIndex) {
@ -243,11 +235,6 @@ final class PortMixer extends AbstractMixer {
this.portIndex = portIndex;
}
// ABSTRACT METHOD IMPLEMENTATIONS
// ABSTRACT LINE
void implOpen() throws LineUnavailableException {
if (Printer.trace) Printer.trace(">> PortMixerPort: implOpen().");
long newID = ((PortMixer) mixer).getID();
@ -286,7 +273,6 @@ final class PortMixer extends AbstractMixer {
controls = new Control[0];
}
void implClose() {
if (Printer.trace) Printer.trace(">> PortMixerPort: implClose()");
// get rid of controls
@ -294,9 +280,8 @@ final class PortMixer extends AbstractMixer {
if (Printer.trace) Printer.trace("<< PortMixerPort: implClose() succeeded");
}
// METHOD OVERRIDES
// this is very similar to open(AudioFormat, int) in AbstractDataLine...
@Override
public void open() throws LineUnavailableException {
synchronized (mixer) {
// if the line is not currently open, try to open it with this format and buffer size
@ -321,6 +306,7 @@ final class PortMixer extends AbstractMixer {
}
// this is very similar to close() in AbstractDataLine...
@Override
public void close() {
synchronized (mixer) {
if (isOpen()) {
@ -342,7 +328,7 @@ final class PortMixer extends AbstractMixer {
} // class PortMixerPort
/**
* Private inner class representing a BooleanControl for PortMixerPort
* Private inner class representing a BooleanControl for PortMixerPort.
*/
private static final class BoolCtrl extends BooleanControl {
// the handle to the native control function
@ -360,7 +346,6 @@ final class PortMixer extends AbstractMixer {
return new BCT(name);
}
private BoolCtrl(long controlID, String name) {
this(controlID, createType(name));
}
@ -370,12 +355,14 @@ final class PortMixer extends AbstractMixer {
this.controlID = controlID;
}
@Override
public void setValue(boolean value) {
if (!closed) {
nControlSetIntValue(controlID, value?1:0);
}
}
@Override
public boolean getValue() {
if (!closed) {
// never use any cached values
@ -386,7 +373,7 @@ final class PortMixer extends AbstractMixer {
}
/**
* inner class for custom types
* inner class for custom types.
*/
private static final class BCT extends BooleanControl.Type {
private BCT(String name) {
@ -396,7 +383,7 @@ final class PortMixer extends AbstractMixer {
}
/**
* Private inner class representing a CompoundControl for PortMixerPort
* Private inner class representing a CompoundControl for PortMixerPort.
*/
private static final class CompCtrl extends CompoundControl {
private CompCtrl(String name, Control[] controls) {
@ -404,7 +391,7 @@ final class PortMixer extends AbstractMixer {
}
/**
* inner class for custom compound control types
* inner class for custom compound control types.
*/
private static final class CCT extends CompoundControl.Type {
private CCT(String name) {
@ -414,7 +401,7 @@ final class PortMixer extends AbstractMixer {
}
/**
* Private inner class representing a BooleanControl for PortMixerPort
* Private inner class representing a BooleanControl for PortMixerPort.
*/
private static final class FloatCtrl extends FloatControl {
// the handle to the native control function
@ -446,12 +433,14 @@ final class PortMixer extends AbstractMixer {
this.controlID = controlID;
}
@Override
public void setValue(float value) {
if (!closed) {
nControlSetFloatValue(controlID, value);
}
}
@Override
public float getValue() {
if (!closed) {
// never use any cached values
@ -462,7 +451,7 @@ final class PortMixer extends AbstractMixer {
}
/**
* inner class for custom types
* inner class for custom types.
*/
private static final class FCT extends FloatControl.Type {
private FCT(String name) {
@ -472,7 +461,7 @@ final class PortMixer extends AbstractMixer {
}
/**
* Private inner class representing a port info
* Private inner class representing a port info.
*/
private static final class PortInfo extends Port.Info {
private PortInfo(String name, boolean isSource) {

View File

@ -28,7 +28,6 @@ package com.sun.media.sound;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.spi.MixerProvider;
/**
* Port provider.
*
@ -36,8 +35,6 @@ import javax.sound.sampled.spi.MixerProvider;
*/
public final class PortMixerProvider extends MixerProvider {
// STATIC VARIABLES
/**
* Set of info objects for all port input devices on the system.
*/
@ -48,18 +45,11 @@ public final class PortMixerProvider extends MixerProvider {
*/
private static PortMixer[] devices;
// STATIC
static {
// initialize
Platform.initialize();
}
// CONSTRUCTOR
/**
* Required public no-arg constructor.
*/
@ -93,6 +83,7 @@ public final class PortMixerProvider extends MixerProvider {
}
}
@Override
public Mixer.Info[] getMixerInfo() {
synchronized (PortMixerProvider.class) {
Mixer.Info[] localArray = new Mixer.Info[infos.length];
@ -101,6 +92,7 @@ public final class PortMixerProvider extends MixerProvider {
}
}
@Override
public Mixer getMixer(Mixer.Info info) {
synchronized (PortMixerProvider.class) {
for (int i = 0; i < infos.length; i++) {
@ -113,7 +105,6 @@ public final class PortMixerProvider extends MixerProvider {
String.format("Mixer %s not supported by this provider", info));
}
private static Mixer getDevice(PortMixerInfo info) {
int index = info.getIndex();
if (devices[index] == null) {
@ -122,9 +113,6 @@ public final class PortMixerProvider extends MixerProvider {
return devices[index];
}
// INNER CLASSES
/**
* Info class for PortMixers. Adds an index value for
* making native references to a particular device.
@ -144,7 +132,6 @@ public final class PortMixerProvider extends MixerProvider {
} // class PortMixerInfo
// NATIVE METHODS
private static native int nGetNumDevices();
private static native PortMixerInfo nNewPortMixerInfo(int mixerIndex);
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.EOFException;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.File;
@ -39,21 +40,21 @@ public final class RIFFWriter extends OutputStream {
private interface RandomAccessWriter {
public void seek(long chunksizepointer) throws IOException;
void seek(long chunksizepointer) throws IOException;
public long getPointer() throws IOException;
long getPointer() throws IOException;
public void close() throws IOException;
void close() throws IOException;
public void write(int b) throws IOException;
void write(int b) throws IOException;
public void write(byte[] b, int off, int len) throws IOException;
void write(byte[] b, int off, int len) throws IOException;
public void write(byte[] bytes) throws IOException;
void write(byte[] bytes) throws IOException;
public long length() throws IOException;
long length() throws IOException;
public void setLength(long i) throws IOException;
void setLength(long i) throws IOException;
}
private static class RandomAccessFileWriter implements RandomAccessWriter {
@ -68,34 +69,42 @@ public final class RIFFWriter extends OutputStream {
this.raf = new RandomAccessFile(name, "rw");
}
@Override
public void seek(long chunksizepointer) throws IOException {
raf.seek(chunksizepointer);
}
@Override
public long getPointer() throws IOException {
return raf.getFilePointer();
}
@Override
public void close() throws IOException {
raf.close();
}
@Override
public void write(int b) throws IOException {
raf.write(b);
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
raf.write(b, off, len);
}
@Override
public void write(byte[] bytes) throws IOException {
raf.write(bytes);
}
@Override
public long length() throws IOException {
return raf.length();
}
@Override
public void setLength(long i) throws IOException {
raf.setLength(i);
}
@ -113,19 +122,23 @@ public final class RIFFWriter extends OutputStream {
this.stream = stream;
}
@Override
public void seek(long chunksizepointer) throws IOException {
pos = (int) chunksizepointer;
}
@Override
public long getPointer() throws IOException {
return pos;
}
@Override
public void close() throws IOException {
stream.write(buff, 0, length);
stream.close();
}
@Override
public void write(int b) throws IOException {
if (s == null)
s = new byte[1];
@ -133,6 +146,7 @@ public final class RIFFWriter extends OutputStream {
write(s, 0, 1);
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
int newsize = pos + len;
if (newsize > length)
@ -143,14 +157,17 @@ public final class RIFFWriter extends OutputStream {
}
}
@Override
public void write(byte[] bytes) throws IOException {
write(bytes, 0, bytes.length);
}
@Override
public long length() throws IOException {
return length;
}
@Override
public void setLength(long i) throws IOException {
length = (int) i;
if (length > buff.length) {
@ -223,6 +240,7 @@ public final class RIFFWriter extends OutputStream {
return writeoverride;
}
@Override
public void close() throws IOException {
if (!open)
return;
@ -245,6 +263,7 @@ public final class RIFFWriter extends OutputStream {
raf = null;
}
@Override
public void write(int b) throws IOException {
if (!writeoverride) {
if (chunktype != 2) {
@ -259,6 +278,7 @@ public final class RIFFWriter extends OutputStream {
raf.write(b);
}
@Override
public void write(byte b[], int off, int len) throws IOException {
if (!writeoverride) {
if (chunktype != 2) {

View File

@ -27,14 +27,27 @@ package com.sun.media.sound;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import javax.sound.midi.*;
import javax.sound.midi.ControllerEventListener;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MetaEventListener;
import javax.sound.midi.MetaMessage;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiEvent;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Receiver;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;
import javax.sound.midi.ShortMessage;
import javax.sound.midi.Synthesizer;
import javax.sound.midi.Track;
import javax.sound.midi.Transmitter;
/**
* A Real Time Sequencer
@ -48,8 +61,6 @@ import javax.sound.midi.*;
final class RealTimeSequencer extends AbstractMidiDevice
implements Sequencer, AutoConnectSequencer {
// STATIC VARIABLES
/** debugging flags */
private static final boolean DEBUG_PUMP = false;
private static final boolean DEBUG_PUMP_ALL = false;
@ -73,7 +84,6 @@ final class RealTimeSequencer extends AbstractMidiDevice
private static final Sequencer.SyncMode masterSyncMode = Sequencer.SyncMode.INTERNAL_CLOCK;
private static final Sequencer.SyncMode slaveSyncMode = Sequencer.SyncMode.NO_SYNC;
/**
* Sequence on which this sequencer is operating.
*/
@ -87,14 +97,12 @@ final class RealTimeSequencer extends AbstractMidiDevice
*/
private double cacheTempoMPQ = -1;
/**
* cache value for tempo factor until sequence is set
* -1 means not set.
*/
private float cacheTempoFactor = -1;
/** if a particular track is muted */
private boolean[] trackMuted = null;
/** if a particular track is solo */
@ -108,47 +116,48 @@ final class RealTimeSequencer extends AbstractMidiDevice
*/
private volatile boolean running;
/** the thread for pushing out the MIDI messages */
/**
* the thread for pushing out the MIDI messages.
*/
private PlayThread playThread;
/**
* True if we are recording
* True if we are recording.
*/
private volatile boolean recording;
/**
* List of tracks to which we're recording
* List of tracks to which we're recording.
*/
private final List<RecordingTrack> recordingTracks = new ArrayList<>();
private long loopStart = 0;
private long loopEnd = -1;
private int loopCount = 0;
/**
* Meta event listeners
* Meta event listeners.
*/
private final ArrayList<Object> metaEventListeners = new ArrayList<>();
/**
* Control change listeners
* Control change listeners.
*/
private final ArrayList<ControllerListElement> controllerEventListeners = new ArrayList<>();
/** automatic connection support */
/**
* automatic connection support.
*/
private boolean autoConnect = false;
/** if we need to autoconnect at next open */
/**
* if we need to autoconnect at next open.
*/
private boolean doAutoConnectAtNextOpen = false;
/** the receiver that this device is auto-connected to */
/**
* the receiver that this device is auto-connected to.
*/
Receiver autoConnectedReceiver = null;
@ -161,9 +170,9 @@ final class RealTimeSequencer extends AbstractMidiDevice
if (Printer.trace) Printer.trace("<< RealTimeSequencer CONSTRUCTOR completed");
}
/* ****************************** SEQUENCER METHODS ******************** */
@Override
public synchronized void setSequence(Sequence sequence)
throws InvalidMidiDataException {
@ -211,7 +220,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
if (Printer.trace) Printer.trace("<< RealTimeSequencer: setSequence(" + sequence +") completed");
}
@Override
public synchronized void setSequence(InputStream stream) throws IOException, InvalidMidiDataException {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: setSequence(" + stream +")");
@ -229,12 +238,12 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
@Override
public Sequence getSequence() {
return sequence;
}
@Override
public synchronized void start() {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: start()");
@ -259,7 +268,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
if (Printer.trace) Printer.trace("<< RealTimeSequencer: start() completed");
}
@Override
public synchronized void stop() {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: stop()");
@ -280,12 +289,12 @@ final class RealTimeSequencer extends AbstractMidiDevice
if (Printer.trace) Printer.trace("<< RealTimeSequencer: stop() completed");
}
@Override
public boolean isRunning() {
return running;
}
@Override
public void startRecording() {
if (!isOpen()) {
throw new IllegalStateException("Sequencer not open");
@ -295,7 +304,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
recording = true;
}
@Override
public void stopRecording() {
if (!isOpen()) {
throw new IllegalStateException("Sequencer not open");
@ -303,12 +312,12 @@ final class RealTimeSequencer extends AbstractMidiDevice
recording = false;
}
@Override
public boolean isRecording() {
return recording;
}
@Override
public void recordEnable(Track track, int channel) {
if (!findTrack(track)) {
throw new IllegalArgumentException("Track does not exist in the current sequence");
@ -325,7 +334,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
@Override
public void recordDisable(Track track) {
synchronized(recordingTracks) {
RecordingTrack rc = RecordingTrack.get(recordingTracks, track);
@ -336,7 +345,6 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
private boolean findTrack(Track track) {
boolean found = false;
if (sequence != null) {
@ -351,14 +359,14 @@ final class RealTimeSequencer extends AbstractMidiDevice
return found;
}
@Override
public float getTempoInBPM() {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: getTempoInBPM() ");
return (float) MidiUtils.convertTempo(getTempoInMPQ());
}
@Override
public void setTempoInBPM(float bpm) {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: setTempoInBPM() ");
if (bpm <= 0) {
@ -369,7 +377,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
setTempoInMPQ((float) MidiUtils.convertTempo((double) bpm));
}
@Override
public float getTempoInMPQ() {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: getTempoInMPQ() ");
@ -389,7 +397,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
return getDataPump().getTempoMPQ();
}
@Override
public void setTempoInMPQ(float mpq) {
if (mpq <= 0) {
// should throw IllegalArgumentException
@ -410,7 +418,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
@Override
public void setTempoFactor(float factor) {
if (factor <= 0) {
// should throw IllegalArgumentException
@ -428,7 +436,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
@Override
public float getTempoFactor() {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: getTempoFactor() ");
@ -441,7 +449,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
return getDataPump().getTempoFactor();
}
@Override
public long getTickLength() {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: getTickLength() ");
@ -452,7 +460,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
return sequence.getTickLength();
}
@Override
public synchronized long getTickPosition() {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: getTickPosition() ");
@ -463,7 +471,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
return getDataPump().getTickPos();
}
@Override
public synchronized void setTickPosition(long tick) {
if (tick < 0) {
// should throw IllegalArgumentException
@ -486,7 +494,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
@Override
public long getMicrosecondLength() {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: getMicrosecondLength() ");
@ -497,7 +505,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
return sequence.getMicrosecondLength();
}
@Override
public long getMicrosecondPosition() {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: getMicrosecondPosition() ");
@ -509,7 +517,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
@Override
public void setMicrosecondPosition(long microseconds) {
if (microseconds < 0) {
// should throw IllegalArgumentException
@ -534,34 +542,34 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
@Override
public void setMasterSyncMode(Sequencer.SyncMode sync) {
// not supported
}
@Override
public Sequencer.SyncMode getMasterSyncMode() {
return masterSyncMode;
}
@Override
public Sequencer.SyncMode[] getMasterSyncModes() {
Sequencer.SyncMode[] returnedModes = new Sequencer.SyncMode[masterSyncModes.length];
System.arraycopy(masterSyncModes, 0, returnedModes, 0, masterSyncModes.length);
return returnedModes;
}
@Override
public void setSlaveSyncMode(Sequencer.SyncMode sync) {
// not supported
}
@Override
public Sequencer.SyncMode getSlaveSyncMode() {
return slaveSyncMode;
}
@Override
public Sequencer.SyncMode[] getSlaveSyncModes() {
Sequencer.SyncMode[] returnedModes = new Sequencer.SyncMode[slaveSyncModes.length];
System.arraycopy(slaveSyncModes, 0, returnedModes, 0, slaveSyncModes.length);
@ -577,8 +585,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
return 0;
}
@Override
public synchronized void setTrackMute(int track, boolean mute) {
int trackCount = getTrackCount();
if (track < 0 || track >= getTrackCount()) return;
@ -589,14 +596,14 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
@Override
public synchronized boolean getTrackMute(int track) {
if (track < 0 || track >= getTrackCount()) return false;
if (trackMuted == null || trackMuted.length <= track) return false;
return trackMuted[track];
}
@Override
public synchronized void setTrackSolo(int track, boolean solo) {
int trackCount = getTrackCount();
if (track < 0 || track >= getTrackCount()) return;
@ -607,14 +614,14 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
@Override
public synchronized boolean getTrackSolo(int track) {
if (track < 0 || track >= getTrackCount()) return false;
if (trackSolo == null || trackSolo.length <= track) return false;
return trackSolo[track];
}
@Override
public boolean addMetaEventListener(MetaEventListener listener) {
synchronized(metaEventListeners) {
if (! metaEventListeners.contains(listener)) {
@ -625,7 +632,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
@Override
public void removeMetaEventListener(MetaEventListener listener) {
synchronized(metaEventListeners) {
int index = metaEventListeners.indexOf(listener);
@ -635,7 +642,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
@Override
public int[] addControllerEventListener(ControllerEventListener listener, int[] controllers) {
synchronized(controllerEventListeners) {
@ -663,7 +670,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
@Override
public int[] removeControllerEventListener(ControllerEventListener listener, int[] controllers) {
synchronized(controllerEventListeners) {
ControllerListElement cve = null;
@ -690,9 +697,9 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
////////////////// LOOPING (added in 1.5) ///////////////////////
@Override
public void setLoopStartPoint(long tick) {
if ((tick > getTickLength())
|| ((loopEnd != -1) && (tick > loopEnd))
@ -702,10 +709,12 @@ final class RealTimeSequencer extends AbstractMidiDevice
loopStart = tick;
}
@Override
public long getLoopStartPoint() {
return loopStart;
}
@Override
public void setLoopEndPoint(long tick) {
if ((tick > getTickLength())
|| ((loopStart > tick) && (tick != -1))
@ -715,10 +724,12 @@ final class RealTimeSequencer extends AbstractMidiDevice
loopEnd = tick;
}
@Override
public long getLoopEndPoint() {
return loopEnd;
}
@Override
public void setLoopCount(int count) {
if (count != LOOP_CONTINUOUSLY
&& count < 0) {
@ -730,15 +741,14 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
@Override
public int getLoopCount() {
return loopCount;
}
/* *********************************** play control ************************* */
/*
*/
@Override
protected void implOpen() throws MidiUnavailableException {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: implOpen()");
@ -820,14 +830,15 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
/** populate the caches with the current values */
/**
* populate the caches with the current values.
*/
private synchronized void setCaches() {
cacheTempoFactor = getTempoFactor();
cacheTempoMPQ = getTempoInMPQ();
}
@Override
protected synchronized void implClose() {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: implClose() ");
@ -882,7 +893,6 @@ final class RealTimeSequencer extends AbstractMidiDevice
if (Printer.trace) Printer.trace("<< RealTimeSequencer: implStart() completed");
}
void implStop() {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: implStop()");
@ -953,8 +963,6 @@ final class RealTimeSequencer extends AbstractMidiDevice
getEventDispatcher().sendAudioEvents(message, sendToListeners);
}
private boolean needCaching() {
return !isOpen() || (sequence == null) || (playThread == null);
}
@ -988,42 +996,39 @@ final class RealTimeSequencer extends AbstractMidiDevice
return array;
}
// OVERRIDES OF ABSTRACT MIDI DEVICE METHODS
@Override
protected boolean hasReceivers() {
return true;
}
// for recording
@Override
protected Receiver createReceiver() throws MidiUnavailableException {
return new SequencerReceiver();
}
@Override
protected boolean hasTransmitters() {
return true;
}
@Override
protected Transmitter createTransmitter() throws MidiUnavailableException {
return new SequencerTransmitter();
}
// interface AutoConnectSequencer
@Override
public void setAutoConnect(Receiver autoConnectedReceiver) {
this.autoConnect = (autoConnectedReceiver != null);
this.autoConnectedReceiver = autoConnectedReceiver;
}
// INNER CLASSES
/**
* An own class to distinguish the class name from
* the transmitter of other devices
* the transmitter of other devices.
*/
private class SequencerTransmitter extends BasicTransmitter {
private SequencerTransmitter() {
@ -1031,9 +1036,9 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
final class SequencerReceiver extends AbstractReceiver {
@Override
void implSend(MidiMessage message, long timeStamp) {
if (recording) {
long tickPos = 0;
@ -1080,7 +1085,6 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
private static class RealTimeSequencerInfo extends MidiDevice.Info {
private static final String name = "Real Time Sequencer";
@ -1093,7 +1097,6 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
} // class Info
private class ControllerListElement {
// $$jb: using an array for controllers b/c its
@ -1202,7 +1205,6 @@ final class RealTimeSequencer extends AbstractMidiDevice
} // class ControllerListElement
static class RecordingTrack {
private final Track track;
@ -1244,7 +1246,6 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
final class PlayThread implements Runnable {
private Thread thread;
private final Object lock = new Object();
@ -1351,13 +1352,13 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
/**
* Main process loop driving the media flow.
*
* Make sure to NOT synchronize on RealTimeSequencer
* anywhere here (even implicit). That is a sure deadlock!
*/
@Override
public void run() {
while (!interrupted) {
@ -1409,10 +1410,9 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
}
/**
* class that does the actual dispatching of events,
* used to be in native in MMAPI
* used to be in native in MMAPI.
*/
private class DataPump {
private float currTempo; // MPQ tempo
@ -1434,7 +1434,6 @@ final class RealTimeSequencer extends AbstractMidiDevice
//private sun.misc.Perf perf = sun.misc.Perf.getPerf();
//private long perfFreq = perf.highResFrequency();
DataPump() {
init();
}
@ -1516,8 +1515,6 @@ final class RealTimeSequencer extends AbstractMidiDevice
trackDisabled = newDisabled;
}
synchronized void setSequence(Sequence seq) {
if (seq == null) {
init();
@ -1568,7 +1565,6 @@ final class RealTimeSequencer extends AbstractMidiDevice
if (DEBUG_PUMP) Printer.println(" noteOff: sent "+done+" messages.");
}
private boolean[] makeDisabledArray() {
if (tracks == null) {
return null;
@ -1656,11 +1652,10 @@ final class RealTimeSequencer extends AbstractMidiDevice
if (DEBUG_PUMP) Printer.println(" sendNoteOffIfOn: sent "+done+" messages.");
}
/**
* Runtime application of mute/solo:
* if a track is muted that was previously playing, send
* note off events for all currently playing notes
* note off events for all currently playing notes.
*/
private void applyDisabledTracks(boolean[] oldDisabled, boolean[] newDisabled) {
byte[][] tempArray = null;
@ -1781,8 +1776,9 @@ final class RealTimeSequencer extends AbstractMidiDevice
if (DEBUG_PUMP) Printer.println(" chaseTrackEvents track "+trackNum+": sent "+numControllersSent+" controllers.");
}
/** chase controllers and program for all tracks */
/**
* chase controllers and program for all tracks.
*/
synchronized void chaseEvents(long startTick, long endTick) {
if (DEBUG_PUMP) Printer.println(">> chaseEvents from tick "+startTick+".."+(endTick-1));
byte[][] tempArray = new byte[128][16];
@ -1797,7 +1793,6 @@ final class RealTimeSequencer extends AbstractMidiDevice
if (DEBUG_PUMP) Printer.println("<< chaseEvents");
}
// playback related methods (pumping)
private long getCurrentTimeMillis() {
@ -1900,7 +1895,6 @@ final class RealTimeSequencer extends AbstractMidiDevice
return changesPending;
}
/** the main pump method
* @return true if end of sequence is reached
*/
@ -2078,7 +2072,5 @@ final class RealTimeSequencer extends AbstractMidiDevice
return EOM;
}
} // class DataPump
}

View File

@ -29,8 +29,6 @@ import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Receiver;
import javax.sound.midi.Transmitter;
/** MidiDevice that can use reference counting for open/close.
* This interface is intended to be used by MidiSystem.getTransmitter() and
* MidiSystem.getReceiver().
@ -42,11 +40,11 @@ public interface ReferenceCountingDevice {
* This method is similar to MidiDevice.getReceiver(). However, by calling this one,
* the device is opened implicitly. This is needed by MidiSystem.getReceiver().
*/
public Receiver getReceiverReferenceCounting() throws MidiUnavailableException;
Receiver getReceiverReferenceCounting() throws MidiUnavailableException;
/** Retrieve a Transmitter that opens the device implicitly.
* This method is similar to MidiDevice.getTransmitter(). However, by calling this one,
* the device is opened implicitly. This is needed by MidiSystem.getTransmitter().
*/
public Transmitter getTransmitterReferenceCounting() throws MidiUnavailableException;
Transmitter getTransmitterReferenceCounting() throws MidiUnavailableException;
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.ArrayList;
@ -45,8 +46,7 @@ public final class SF2Instrument extends ModelInstrument {
long genre = 0;
long morphology = 0;
SF2GlobalRegion globalregion = null;
List<SF2InstrumentRegion> regions
= new ArrayList<SF2InstrumentRegion>();
List<SF2InstrumentRegion> regions = new ArrayList<>();
public SF2Instrument() {
super(null, null, null, null);
@ -56,6 +56,7 @@ public final class SF2Instrument extends ModelInstrument {
super(soundbank, null, null, null);
}
@Override
public String getName() {
return name;
}
@ -64,6 +65,7 @@ public final class SF2Instrument extends ModelInstrument {
this.name = name;
}
@Override
public Patch getPatch() {
if (bank == 128)
return new ModelPatch(0, preset, true);
@ -81,6 +83,7 @@ public final class SF2Instrument extends ModelInstrument {
}
}
@Override
public Object getData() {
return null;
}
@ -121,6 +124,7 @@ public final class SF2Instrument extends ModelInstrument {
globalregion = zone;
}
@Override
public String toString() {
if (bank == 128)
return "Drumkit: " + name + " preset #" + preset;
@ -129,6 +133,7 @@ public final class SF2Instrument extends ModelInstrument {
+ " preset #" + preset;
}
@Override
public ModelPerformer[] getPerformers() {
int performercount = 0;
for (SF2InstrumentRegion presetzone : regions)
@ -138,7 +143,7 @@ public final class SF2Instrument extends ModelInstrument {
SF2GlobalRegion presetglobal = globalregion;
for (SF2InstrumentRegion presetzone : regions) {
Map<Integer, Short> pgenerators = new HashMap<Integer, Short>();
Map<Integer, Short> pgenerators = new HashMap<>();
pgenerators.putAll(presetzone.getGenerators());
if (presetglobal != null)
pgenerators.putAll(presetglobal.getGenerators());
@ -267,7 +272,7 @@ public final class SF2Instrument extends ModelInstrument {
if (buff24 != null)
osc.set8BitExtensionBuffer(buff24);
Map<Integer, Short> generators = new HashMap<Integer, Short>();
Map<Integer, Short> generators = new HashMap<>();
if (layerglobal != null)
generators.putAll(layerglobal.getGenerators());
generators.putAll(layerzone.getGenerators());
@ -608,6 +613,7 @@ public final class SF2Instrument extends ModelInstrument {
new ModelConnectionBlock(
new ModelSource(ModelSource.SOURCE_NOTEON_VELOCITY,
new ModelTransform() {
@Override
public double transform(double value) {
if (value < 0.5)
return 1 - value * 2;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -38,7 +38,7 @@ public final class SF2Layer extends SoundbankResource {
String name = "";
SF2GlobalRegion globalregion = null;
List<SF2LayerRegion> regions = new ArrayList<SF2LayerRegion>();
List<SF2LayerRegion> regions = new ArrayList<>();
public SF2Layer(SF2Soundbank soundBank) {
super(soundBank, null, null);
@ -48,10 +48,12 @@ public final class SF2Layer extends SoundbankResource {
super(null, null, null);
}
@Override
public Object getData() {
return null;
}
@Override
public String getName() {
return name;
}
@ -72,6 +74,7 @@ public final class SF2Layer extends SoundbankResource {
globalregion = zone;
}
@Override
public String toString() {
return "Layer: " + name;
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
/**

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.ArrayList;
@ -97,8 +98,8 @@ public class SF2Region {
public static final int GENERATOR_OVERRIDINGROOTKEY = 58;
public static final int GENERATOR_UNUSED5 = 59;
public static final int GENERATOR_ENDOPR = 60;
protected Map<Integer, Short> generators = new HashMap<Integer, Short>();
protected List<SF2Modulator> modulators = new ArrayList<SF2Modulator>();
protected Map<Integer, Short> generators = new HashMap<>();
protected List<SF2Modulator> modulators = new ArrayList<>();
public Map<Integer, Short> getGenerators() {
return generators;

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.InputStream;
@ -57,6 +58,7 @@ public final class SF2Sample extends SoundbankResource {
super(null, null, AudioInputStream.class);
}
@Override
public Object getData() {
AudioFormat format = getFormat();
@ -146,6 +148,7 @@ public final class SF2Sample extends SoundbankResource {
}
*/
@Override
public String getName() {
return name;
}
@ -210,6 +213,7 @@ public final class SF2Sample extends SoundbankResource {
this.startLoop = startLoop;
}
@Override
public String toString() {
return "Sample: " + name;
}

View File

@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.File;
@ -81,9 +82,9 @@ public final class SF2Soundbank implements Soundbank {
private ModelByteBuffer sampleData24 = null;
private File sampleFile = null;
private boolean largeFormat = false;
private final List<SF2Instrument> instruments = new ArrayList<SF2Instrument>();
private final List<SF2Layer> layers = new ArrayList<SF2Layer>();
private final List<SF2Sample> samples = new ArrayList<SF2Sample>();
private final List<SF2Instrument> instruments = new ArrayList<>();
private final List<SF2Layer> layers = new ArrayList<>();
private final List<SF2Sample> samples = new ArrayList<>();
public SF2Soundbank() {
}
@ -224,19 +225,15 @@ public final class SF2Soundbank implements Soundbank {
private void readPdtaChunk(RIFFReader riff) throws IOException {
List<SF2Instrument> presets = new ArrayList<SF2Instrument>();
List<Integer> presets_bagNdx = new ArrayList<Integer>();
List<SF2InstrumentRegion> presets_splits_gen
= new ArrayList<SF2InstrumentRegion>();
List<SF2InstrumentRegion> presets_splits_mod
= new ArrayList<SF2InstrumentRegion>();
List<SF2Instrument> presets = new ArrayList<>();
List<Integer> presets_bagNdx = new ArrayList<>();
List<SF2InstrumentRegion> presets_splits_gen = new ArrayList<>();
List<SF2InstrumentRegion> presets_splits_mod = new ArrayList<>();
List<SF2Layer> instruments = new ArrayList<SF2Layer>();
List<Integer> instruments_bagNdx = new ArrayList<Integer>();
List<SF2LayerRegion> instruments_splits_gen
= new ArrayList<SF2LayerRegion>();
List<SF2LayerRegion> instruments_splits_mod
= new ArrayList<SF2LayerRegion>();
List<SF2Layer> instruments = new ArrayList<>();
List<Integer> instruments_bagNdx = new ArrayList<>();
List<SF2LayerRegion> instruments_splits_gen = new ArrayList<>();
List<SF2LayerRegion> instruments_splits_mod = new ArrayList<>();
while (riff.hasNextChunk()) {
RIFFReader chunk = riff.nextChunk();
@ -830,18 +827,22 @@ public final class SF2Soundbank implements Soundbank {
}
@Override
public String getName() {
return name;
}
@Override
public String getVersion() {
return major + "." + minor;
}
@Override
public String getVendor() {
return engineers;
}
@Override
public String getDescription() {
return comments;
}
@ -858,6 +859,7 @@ public final class SF2Soundbank implements Soundbank {
comments = s;
}
@Override
public SoundbankResource[] getResources() {
SoundbankResource[] resources
= new SoundbankResource[layers.size() + samples.size()];
@ -869,6 +871,7 @@ public final class SF2Soundbank implements Soundbank {
return resources;
}
@Override
public SF2Instrument[] getInstruments() {
SF2Instrument[] inslist_array
= instruments.toArray(new SF2Instrument[instruments.size()]);
@ -884,6 +887,7 @@ public final class SF2Soundbank implements Soundbank {
return samples.toArray(new SF2Sample[samples.size()]);
}
@Override
public Instrument getInstrument(Patch patch) {
int program = patch.getProgram();
int bank = patch.getBank();
@ -972,11 +976,11 @@ public final class SF2Soundbank implements Soundbank {
public void removeResource(SoundbankResource resource) {
if (resource instanceof SF2Instrument)
instruments.remove((SF2Instrument)resource);
instruments.remove(resource);
if (resource instanceof SF2Layer)
layers.remove((SF2Layer)resource);
layers.remove(resource);
if (resource instanceof SF2Sample)
samples.remove((SF2Sample)resource);
samples.remove(resource);
}
public void addInstrument(SF2Instrument resource) {

View File

@ -22,12 +22,14 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.Soundbank;
import javax.sound.midi.spi.SoundbankReader;
@ -40,6 +42,7 @@ import javax.sound.midi.spi.SoundbankReader;
*/
public final class SF2SoundbankReader extends SoundbankReader {
@Override
public Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException {
try {
@ -51,6 +54,7 @@ public final class SF2SoundbankReader extends SoundbankReader {
}
}
@Override
public Soundbank getSoundbank(InputStream stream)
throws InvalidMidiDataException, IOException {
try {
@ -62,6 +66,7 @@ public final class SF2SoundbankReader extends SoundbankReader {
}
}
@Override
public Soundbank getSoundbank(File file)
throws InvalidMidiDataException, IOException {
try {

View File

@ -22,10 +22,12 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.media.sound;
import java.util.ArrayList;
import java.util.List;
import javax.sound.midi.Patch;
/**
@ -48,8 +50,7 @@ public class SimpleInstrument extends ModelInstrument {
protected int bank = 0;
protected boolean percussion = false;
protected String name = "";
protected List<SimpleInstrumentPart> parts
= new ArrayList<SimpleInstrumentPart>();
protected List<SimpleInstrumentPart> parts = new ArrayList<>();
public SimpleInstrument() {
super(null, null, null, null);
@ -121,6 +122,7 @@ public class SimpleInstrument extends ModelInstrument {
add(ins.getPerformers());
}
@Override
public ModelPerformer[] getPerformers() {
int percount = 0;
@ -166,10 +168,12 @@ public class SimpleInstrument extends ModelInstrument {
return performers;
}
@Override
public Object getData() {
return null;
}
@Override
public String getName() {
return this.name;
}
@ -178,6 +182,7 @@ public class SimpleInstrument extends ModelInstrument {
this.name = name;
}
@Override
public ModelPatch getPatch() {
return new ModelPatch(bank, preset, percussion);
}

Some files were not shown because too many files have changed in this diff Show More