< prev index next >

src/java.desktop/share/classes/com/sun/media/sound/DLSSoundbank.java

Print this page

        

@@ -20,10 +20,11 @@
  *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * 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.FileInputStream;
 import java.io.IOException;

@@ -40,13 +41,13 @@
 import javax.sound.midi.Instrument;
 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).
  *
  * @author Karl Helgason

@@ -98,14 +99,16 @@
             d.x7 = riff.readUnsignedByte();
             d.x8 = riff.readUnsignedByte();
             return d;
         }
 
+        @Override
         public int hashCode() {
             return (int)i1;
         }
 
+        @Override
         public boolean equals(Object obj) {
             if (!(obj instanceof DLSID)) {
                 return false;
             }
             DLSID t = (DLSID) obj;

@@ -174,12 +177,12 @@
     private long major = -1;
     private long minor = -1;
 
     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;
 
     public DLSSoundbank() {

@@ -298,11 +301,11 @@
     private boolean readCdlChunk(RIFFReader riff) throws IOException {
 
         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();
             switch (opcode) {
             case DLS_CDL_AND:

@@ -480,11 +483,11 @@
                             }
                         }
                     }
                 }
                 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 ")) {
                             if (!readCdlChunk(chunk)) {
                                 modlist.clear();

@@ -496,11 +499,11 @@
                     }
                     instrument.getModulators().addAll(modlist);
                 }
                 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 ")) {
                             if (!readCdlChunk(chunk)) {
                                 modlist.clear();

@@ -580,20 +583,20 @@
             modulator.scale = riff.readInt();
             modulators.add(modulator);
         }
     }
 
-    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 {
         while (riff.hasNextChunk()) {
             RIFFReader chunk = riff.nextChunk();
             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 ")) {
                             if (!readCdlChunk(chunk)) {
                                 modlist.clear();

@@ -605,11 +608,11 @@
                     }
                     split.getModulators().addAll(modlist);
                 }
                 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 ")) {
                             if (!readCdlChunk(chunk)) {
                                 modlist.clear();

@@ -900,11 +903,11 @@
         for (int i = 0; i < samples.size(); i++)
             ptbl.writeUnsignedInt(0);
 
         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);
         }
 

@@ -1177,22 +1180,26 @@
 
     public DLSInfo getInfo() {
         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;
     }
 
     public void setName(String s) {

@@ -1205,18 +1212,20 @@
 
     public void setDescription(String s) {
         info.comments = s;
     }
 
+    @Override
     public SoundbankResource[] getResources() {
         SoundbankResource[] resources = new SoundbankResource[samples.size()];
         int j = 0;
         for (int i = 0; i < samples.size(); i++)
             resources[j++] = samples.get(i);
         return resources;
     }
 
+    @Override
     public DLSInstrument[] getInstruments() {
         DLSInstrument[] inslist_array =
                 instruments.toArray(new DLSInstrument[instruments.size()]);
         Arrays.sort(inslist_array, new ModelInstrumentComparator());
         return inslist_array;

@@ -1224,10 +1233,11 @@
 
     public DLSSample[] getSamples() {
         return samples.toArray(new DLSSample[samples.size()]);
     }
 
+    @Override
     public Instrument getInstrument(Patch patch) {
         int program = patch.getProgram();
         int bank = patch.getBank();
         boolean percussion = false;
         if (patch instanceof ModelPatch)

@@ -1254,13 +1264,13 @@
             samples.add((DLSSample) resource);
     }
 
     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) {
         instruments.add(resource);
     }
< prev index next >