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

Print this page


   1 /*
   2  * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 514                 }
 515             } else {
 516                 if (format.equals("dlid")) {
 517                     instrument.guid = new byte[16];
 518                     chunk.readFully(instrument.guid);
 519                 }
 520                 if (format.equals("insh")) {
 521                     chunk.readUnsignedInt(); // Read Region Count - ignored
 522 
 523                     int bank = chunk.read();             // LSB
 524                     bank += (chunk.read() & 127) << 7;   // MSB
 525                     chunk.read(); // Read Reserved byte
 526                     int drumins = chunk.read();          // Drum Instrument
 527 
 528                     int id = chunk.read() & 127; // Read only first 7 bits
 529                     chunk.read(); // Read Reserved byte
 530                     chunk.read(); // Read Reserved byte
 531                     chunk.read(); // Read Reserved byte
 532 
 533                     instrument.bank = bank;
 534                     instrument.preset = (int) id;
 535                     instrument.druminstrument = (drumins & 128) > 0;
 536                     //System.out.println("bank="+bank+" drumkit="+drumkit
 537                     //        +" id="+id);
 538                 }
 539 
 540             }
 541         }
 542         instruments.add(instrument);
 543     }
 544 
 545     private void readArt1Chunk(List<DLSModulator> modulators, RIFFReader riff)
 546             throws IOException {
 547         long size = riff.readUnsignedInt();
 548         long count = riff.readUnsignedInt();
 549 
 550         if (size - 8 != 0)
 551             riff.skipBytes(size - 8);
 552 
 553         for (int i = 0; i < count; i++) {
 554             DLSModulator modulator = new DLSModulator();


   1 /*
   2  * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 514                 }
 515             } else {
 516                 if (format.equals("dlid")) {
 517                     instrument.guid = new byte[16];
 518                     chunk.readFully(instrument.guid);
 519                 }
 520                 if (format.equals("insh")) {
 521                     chunk.readUnsignedInt(); // Read Region Count - ignored
 522 
 523                     int bank = chunk.read();             // LSB
 524                     bank += (chunk.read() & 127) << 7;   // MSB
 525                     chunk.read(); // Read Reserved byte
 526                     int drumins = chunk.read();          // Drum Instrument
 527 
 528                     int id = chunk.read() & 127; // Read only first 7 bits
 529                     chunk.read(); // Read Reserved byte
 530                     chunk.read(); // Read Reserved byte
 531                     chunk.read(); // Read Reserved byte
 532 
 533                     instrument.bank = bank;
 534                     instrument.preset = id;
 535                     instrument.druminstrument = (drumins & 128) > 0;
 536                     //System.out.println("bank="+bank+" drumkit="+drumkit
 537                     //        +" id="+id);
 538                 }
 539 
 540             }
 541         }
 542         instruments.add(instrument);
 543     }
 544 
 545     private void readArt1Chunk(List<DLSModulator> modulators, RIFFReader riff)
 546             throws IOException {
 547         long size = riff.readUnsignedInt();
 548         long count = riff.readUnsignedInt();
 549 
 550         if (size - 8 != 0)
 551             riff.skipBytes(size - 8);
 552 
 553         for (int i = 0; i < count; i++) {
 554             DLSModulator modulator = new DLSModulator();