/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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.
*/
//$$fb this class is buggy. Should be replaced in future.
/**
* WAVE file writer.
*
* @author Jan Borgersen
*/
// magic numbers
// encodings
/**
* Constructs a new WaveFileWriter object.
*/
public WaveFileWriter() {
}
// METHODS TO IMPLEMENT AudioFileWriter
// make sure we can write this stream
return filetypes;
}
}
public int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException {
//$$fb the following check must come first ! Otherwise
// the next frame length check may throw an IOException and
// interrupt iterating File Writers. (see bug 4351296)
// throws IllegalArgumentException if not supported
//$$fb when we got this far, we are committed to write this file
// we must know the total data length to calculate the file length
throw new IOException("stream length not specified");
}
return bytesWritten;
}
public int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException {
// throws IllegalArgumentException if not supported
// first write the file without worrying about length fields
// now, if length fields were not specified, calculate them,
// open as a random access file, write the appropriate fields,
// close again....
// skip RIFF magic
// skip WAVE magic, fmt_ magic, fmt_ length, fmt_ chunk, data magic
// that's all
}
return bytesWritten;
}
//--------------------------------------------------------------------
/**
* Returns the AudioFileFormat describing the file that will be written from this AudioInputStream.
* Throws IllegalArgumentException if not supported.
*/
float sampleRate;
int sampleSizeInBits;
int channels;
int frameSize;
float frameRate;
int fileSize;
}
} else {
}
} else {
}
false); // WAVE is little endian
} else {
}
(int)stream.getFrameLength() );
return fileFormat;
}
private int writeWaveFile(InputStream in, WaveFileFormat waveFileFormat, OutputStream out) throws IOException {
int bytesRead = 0;
int bytesWritten = 0;
byte buffer[] = new byte[bisBufferSize];
if (maxLength>0) {
} else {
maxLength = 0;
break;
}
} else {
}
}
return bytesWritten;
}
private InputStream getFileStream(WaveFileFormat waveFileFormat, InputStream audioStream) throws IOException {
// private method ... assumes audioFileFormat is a supported file type
// WAVE header fields
// if audioStream is an AudioInputStream and we need to convert, do it here...
if(audioStream instanceof AudioInputStream) {
if( sampleSizeInBits==8 ) {
// plug in the transcoder to convert from PCM_SIGNED to PCM_UNSIGNED
false),
}
}
if( sampleSizeInBits!=8) {
// plug in the transcoder to convert to PCM_SIGNED_LITTLE_ENDIAN
false),
}
}
}
// Now push the header into a stream, concat, and return the new SequenceInputStream
baos = new ByteArrayOutputStream();
// we write in littleendian...
//$$fb 2002-04-16: Fix for 4636355: RIFF audio headers could be _more_ spec compliant
// add length 0 for "codec specific data length"
}
return (InputStream)waveStream;
}
}