6321N/A * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A//$$fb this class is buggy. Should be replaced in future. 0N/A * @author Jan Borgersen 0N/A * Constructs a new AiffFileWriter object. 0N/A // METHODS TO IMPLEMENT AudioFileWriter 0N/A // make sure we can write this stream 0N/A //$$fb the following check must come first ! Otherwise 0N/A // the next frame length check may throw an IOException and 0N/A // interrupt iterating File Writers. (see bug 4351296) 0N/A // throws IllegalArgumentException if not supported 0N/A // we must know the total data length to calculate the file length 0N/A // throws IllegalArgumentException if not supported 0N/A // first write the file without worrying about length fields 0N/A // now, if length fields were not specified, calculate them, 0N/A // open as a random access file, write the appropriate fields, 0N/A // $$kk: 10.22.99: jan: please either implement this or throw an exception! 0N/A // $$fb: 2001-07-13: done. Fixes Bug 4479981 0N/A // skip aiff2 magic, fver chunk, comm magic, comm size, channel count, 0N/A // write frame count 0N/A // skip sample size, samplerate, SSND magic 0N/A // ----------------------------------------------------------------------- 0N/A * Returns the AudioFileFormat describing the file that will be written from this AudioInputStream. 0N/A * Throws IllegalArgumentException if not supported. 0N/A // can't convert non-8-bit ALAW,ULAW 0N/A true);
// AIFF is big endian 0N/A // private method ... assumes aiffFileFormat is a supported file format 0N/A //$$fb a little bit nicer handling of constants 0N/A //int headerSize = 54; 0N/A //int fverChunkSize = 0; 0N/A //int commChunkSize = 26; 0N/A //int ssndOffset = headerSize - 16; 0N/A // if we need to do any format conversion, do it here.... 0N/A // $$jb: Note that AIFF samples are ALWAYS signed 0N/A // plug in the transcoder to convert to PCM_SIGNED. big endian 0N/A //$$fb 2001-07-13: this is probably not what we want: 0N/A // writing PCM when ULAW/ALAW is requested. AIFC is able to write ULAW ! 0N/A // plug in the transcoder to convert to PCM_SIGNED_BIG_ENDIAN 0N/A // Now create an AIFF stream header... 0N/A // Write the outer FORM chunk 0N/A // Write a FVER chunk - only for AIFC 0N/A //dos.writeInt(FVER_MAGIC); 0N/A //dos.writeInt( (fverChunkSize-8) ); 0N/A //dos.writeInt(FVER_TIMESTAMP); 0N/A // Write a COMM chunk 0N/A //dos.writeInt(compCode); 0N/A //dos.writeInt(compCode); 0N/A //dos.writeShort(0); 0N/A // Write the SSND chunk header 0N/A // ssndOffset and ssndBlockSize set to 0 upon 0N/A // recommendation in "Sound Manager" chapter in 0N/A // "Inside Macintosh Sound", pp 2-87 (from Babu) 0N/A // Concat this with the audioStream and return it 0N/A * Extended precision IEEE floating-point conversion routine. 0N/A * @argument DataOutputStream 0N/A * @exception IOException 0N/A /* The special cases NaN, Infinity and Zero are ignored, since 0N/A they do not represent useful sample rates anyway. 0N/A Denormalized number aren't handled, too. Below, there is a cast 0N/A from float to double. We hope that in this conversion, 0N/A numbers are normalized. Numbers that cannot be normalized are 0N/A ignored, too, as they, too, do not represent useful sample rates. */