|
Java example source code file (AudioFileFormat.java)
The AudioFileFormat.java Java example source code
/*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package javax.sound.sampled;
import java.io.File;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* An instance of the <code>AudioFileFormat class describes
* an audio file, including the file type, the file's length in bytes,
* the length in sample frames of the audio data contained in the file,
* and the format of the audio data.
* <p>
* The <code>{@link AudioSystem} class includes methods for determining the format
* of an audio file, obtaining an audio input stream from an audio file, and
* writing an audio file from an audio input stream.
*
* <p>An |
* <td>{@link java.lang.Long Long}
* <td>playback duration of the file in microseconds
* </tr>
* <tr>
* <td>"author"
* <td>{@link java.lang.String String}
* <td>name of the author of this file
* </tr>
* <tr>
* <td>"title"
* <td>{@link java.lang.String String}
* <td>title of this file
* </tr>
* <tr>
* <td>"copyright"
* <td>{@link java.lang.String String}
* <td>copyright message
* </tr>
* <tr>
* <td>"date"
* <td>{@link java.util.Date Date}
* <td>date of the recording or release
* </tr>
* <tr>
* <td>"comment"
* <td>{@link java.lang.String String}
* <td>an arbitrary text
* </tr>
* </table>
*
*
* @author David Rivas
* @author Kara Kytle
* @author Florian Bomers
* @see AudioInputStream
* @since 1.3
*/
public class AudioFileFormat {
// INSTANCE VARIABLES
/**
* File type.
*/
private Type type;
/**
* File length in bytes
*/
private int byteLength;
/**
* Format of the audio data contained in the file.
*/
private AudioFormat format;
/**
* Audio data length in sample frames
*/
private int frameLength;
/** The set of properties */
private HashMap<String, Object> properties;
/**
* Constructs an audio file format object.
* This protected constructor is intended for use by providers of file-reading
* services when returning information about an audio file or about supported audio file
* formats.
* @param type the type of the audio file
* @param byteLength the length of the file in bytes, or <code>AudioSystem.NOT_SPECIFIED
* @param format the format of the audio data contained in the file
* @param frameLength the audio data length in sample frames, or <code>AudioSystem.NOT_SPECIFIED
*
* @see #getType
*/
protected AudioFileFormat(Type type, int byteLength, AudioFormat format, int frameLength) {
this.type = type;
this.byteLength = byteLength;
this.format = format;
this.frameLength = frameLength;
this.properties = null;
}
/**
* Constructs an audio file format object.
* This public constructor may be used by applications to describe the
* properties of a requested audio file.
* @param type the type of the audio file
* @param format the format of the audio data contained in the file
* @param frameLength the audio data length in sample frames, or <code>AudioSystem.NOT_SPECIFIED
*/
public AudioFileFormat(Type type, AudioFormat format, int frameLength) {
this(type,AudioSystem.NOT_SPECIFIED,format,frameLength);
}
/**
* Construct an audio file format object with a set of
* defined properties.
* This public constructor may be used by applications to describe the
* properties of a requested audio file. The properties map
* will be copied to prevent any changes to it.
*
* @param type the type of the audio file
* @param format the format of the audio data contained in the file
* @param frameLength the audio data length in sample frames, or
* <code>AudioSystem.NOT_SPECIFIED
* @param properties a <code>Map<String,Object> object
* with properties
*
* @since 1.5
*/
public AudioFileFormat(Type type, AudioFormat format,
int frameLength, Map<String, Object> properties) {
this(type,AudioSystem.NOT_SPECIFIED,format,frameLength);
this.properties = new HashMap<String, Object>(properties);
}
/**
* Obtains the audio file type, such as <code>WAVE or
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.