Package de.sciss.io
Class AudioFileDescr
- java.lang.Object
-
- de.sciss.io.AudioFileDescr
-
public class AudioFileDescr extends java.lang.ObjectAnAudioFileDescris a data structure that describes the format of anAudioFile. It was public readable fields for common parameters such as sample rate and bitdepth. More specific features such as markers or gain chunks are stored using aMapobject being accessed throught thesetPropertyandgetPropertymethods. A corresponding GUI element, theAudioFileFormatPaneexists which presents the common fields to the user.- See Also:
AudioFile,AudioFileFormatPane
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.StringappCodeapplication (creator) codeintbitsPerSamplebits per sampleintchannelsnumber of channels (interleaved)java.io.FilefileThis denotes a corresponding file on a harddisk.static intFORMAT_FLOATsampleFormat type : pcm floating pointstatic intFORMAT_INTsampleFormat type : linear pcm integerstatic java.lang.StringKEY_APPCODEproperty key : application specific code.static java.lang.StringKEY_COMMENTproperty key : comment text.static java.lang.StringKEY_GAINproperty key : playback gain (multiplier).static java.lang.StringKEY_LOOPproperty key : loop region.static java.lang.StringKEY_MARKERSproperty key : marker list.static java.lang.StringKEY_REGIONSproperty key : region list.longlengthsound file length in sample framesdoubleratesampling rate in hertzintsampleFormatsample number format, FORMAT_INT or FORMAT_FLOATinttypefile format such as TYPE_AIFFstatic intTYPE_AIFFtype value : apple aiff sound file formatstatic intTYPE_IRCAMtype value : ircam sound file formatstatic intTYPE_RAWtype value : raw (headerless) file formatstatic intTYPE_SNDtype value : sun/next file format .au aka .sndstatic intTYPE_UNKNOWNtype value : undefined audio file formatstatic intTYPE_WAVEtype value : wave (riff) sound file formatstatic intTYPE_WAVE64type value : sony wave64 sound file format
-
Constructor Summary
Constructors Constructor Description AudioFileDescr()Construct a newAudioFileDescrwhose fields are all undefinedAudioFileDescr(AudioFileDescr orig)Construct a newAudioFileDescrwhose common fields are copied from a template (type, channels, rate, bitsPerSample, sampleFormat, length, properties).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(java.beans.PropertyChangeListener l)java.lang.StringgetFormat()Create a human readable text string describing the audio file format.static StringItem[]getFormatItems()Gets a list of items suitable to attaching to a PrefComboBox, describing the supported audio file formats.static java.lang.StringgetFormatSuffix(int type)Gets the suffix commonly used for attaching to a file name of the given format.java.lang.ObjectgetProperty(java.lang.Object key)Gets a specific propertyintgetType()Returns the file format typebooleanisPropertySupported(java.lang.String key)Reports if a sound file format can handle a particular property.static doublemillisToSamples(AudioFileDescr afd, double ms)Utility method to convert milliseconds to sample frames according to the given audio file formatvoidremovePropertyChangeListener(java.beans.PropertyChangeListener l)static doublesamplesToMillis(AudioFileDescr afd, long samples)Utility method to convert sample frames to milliseconds according to the given audio file formatvoidsetProperty(java.lang.Object source, java.lang.String key, java.lang.Object value)Sets a specific property and dispatches aPropertyChangeEventto registered listeners synchronization: must be called in the event threadvoidsetProperty(java.lang.String key, java.lang.Object value)Sets a specific property.
-
-
-
Field Detail
-
TYPE_UNKNOWN
public static final int TYPE_UNKNOWN
type value : undefined audio file format- See Also:
- Constant Field Values
-
TYPE_AIFF
public static final int TYPE_AIFF
type value : apple aiff sound file format- See Also:
- Constant Field Values
-
TYPE_SND
public static final int TYPE_SND
type value : sun/next file format .au aka .snd- See Also:
- Constant Field Values
-
TYPE_IRCAM
public static final int TYPE_IRCAM
type value : ircam sound file format- See Also:
- Constant Field Values
-
TYPE_WAVE
public static final int TYPE_WAVE
type value : wave (riff) sound file format- See Also:
- Constant Field Values
-
TYPE_RAW
public static final int TYPE_RAW
type value : raw (headerless) file format- See Also:
- Constant Field Values
-
TYPE_WAVE64
public static final int TYPE_WAVE64
type value : sony wave64 sound file format- See Also:
- Constant Field Values
-
FORMAT_INT
public static final int FORMAT_INT
sampleFormat type : linear pcm integer- See Also:
- Constant Field Values
-
FORMAT_FLOAT
public static final int FORMAT_FLOAT
sampleFormat type : pcm floating point- See Also:
- Constant Field Values
-
file
public java.io.File file
This denotes a corresponding file on a harddisk. It may be null
-
type
public int type
file format such as TYPE_AIFF
-
channels
public int channels
number of channels (interleaved)
-
rate
public double rate
sampling rate in hertz
-
bitsPerSample
public int bitsPerSample
bits per sample
-
sampleFormat
public int sampleFormat
sample number format, FORMAT_INT or FORMAT_FLOAT
-
length
public long length
sound file length in sample frames
-
appCode
public java.lang.String appCode
application (creator) code
-
KEY_LOOP
public static final java.lang.String KEY_LOOP
property key : loop region. value class = Region- See Also:
Region, Constant Field Values
-
KEY_MARKERS
public static final java.lang.String KEY_MARKERS
property key : marker list. value class = (java.util.)List whose elements are of class Marker- See Also:
Marker, Constant Field Values
-
KEY_REGIONS
public static final java.lang.String KEY_REGIONS
property key : region list. value class = (java.util.)List whose elements are of class Region- See Also:
Region, Constant Field Values
-
KEY_GAIN
public static final java.lang.String KEY_GAIN
property key : playback gain (multiplier). value class = Float- See Also:
- Constant Field Values
-
KEY_APPCODE
public static final java.lang.String KEY_APPCODE
property key : application specific code. value class = byte[]; note that AbstractApplication.getApplication().getMacOSCreator() is used to write the app chunk, and when reading anything but app-code from the current application is skipped!- See Also:
- Constant Field Values
-
KEY_COMMENT
public static final java.lang.String KEY_COMMENT
property key : comment text. value class = String;- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AudioFileDescr
public AudioFileDescr()
Construct a newAudioFileDescrwhose fields are all undefined
-
AudioFileDescr
public AudioFileDescr(AudioFileDescr orig)
Construct a newAudioFileDescrwhose common fields are copied from a template (type, channels, rate, bitsPerSample, sampleFormat, length, properties). Warning: things like the marker list are not duplicated, they refer to the same instance- Parameters:
orig- a preexisting description whose values will be copied to the newly constructed description
-
-
Method Detail
-
getType
public int getType()
Returns the file format type- Returns:
- the type of the file, e.g. TYPE_AIFF
-
getProperty
public java.lang.Object getProperty(java.lang.Object key)
Gets a specific property- Parameters:
key- the key of the property to query, such as KEY_MARKERS- Returns:
- the property's value or null if this property doesn't exist. the class of the property varies depending on the property type. see the key's description to find out what kind of object is returned
-
setProperty
public void setProperty(java.lang.String key, java.lang.Object value)Sets a specific property. Use theisPropertySupportedmethod to find out if the chosen file format can store the property.- Parameters:
key- the key of the property to setvalue- the properties value. Note that the value is not checked at all. It is the callers responsibility to ensure the value's class is the one specified for the particular key.- See Also:
isPropertySupported( String )
-
setProperty
public void setProperty(java.lang.Object source, java.lang.String key, java.lang.Object value)Sets a specific property and dispatches aPropertyChangeEventto registered listeners synchronization: must be called in the event thread- Parameters:
key- the key of the property to setvalue- the properties value.- See Also:
addPropertyChangeListener( PropertyChangeListener )
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
-
isPropertySupported
public boolean isPropertySupported(java.lang.String key)
Reports if a sound file format can handle a particular property.- Parameters:
key- the key of the property to check- Returns:
truethe sound file format given bygetType()supports the property.falseif not. Note that if a property is not supported, it is no harm to set it usingsetProperty, it just won't be written to the sound file's header.
-
getFormat
public java.lang.String getFormat()
Create a human readable text string describing the audio file format.- Returns:
- a text string containing information about the file format, resolution and sample rate, channel number. Suitable for copying to a GUI text label.
-
getFormatItems
public static StringItem[] getFormatItems()
Gets a list of items suitable to attaching to a PrefComboBox, describing the supported audio file formats.- Returns:
- a list of items for a PrefComboBox which list all supported audio file formats.
- See Also:
PrefComboBox to learn about the use of StringItems
-
getFormatSuffix
public static java.lang.String getFormatSuffix(int type)
Gets the suffix commonly used for attaching to a file name of the given format.- Parameters:
type- format such as TYPE_AIFF, TYPE_RAW etc.- Returns:
- the suffix string such as "aif", "raw"
or
nullif the type was invalid.
-
millisToSamples
public static double millisToSamples(AudioFileDescr afd, double ms)
Utility method to convert milliseconds to sample frames according to the given audio file format- Parameters:
afd- the audio file description whose rate field is used to do the conversionms- arbitrary offset in milliseconds. note that this doesn't have to be within the range of the current length of the audio file.- Returns:
- the time offset which was specified in milliseconds, converted to sample frames (round to integer value if needed).
-
samplesToMillis
public static double samplesToMillis(AudioFileDescr afd, long samples)
Utility method to convert sample frames to milliseconds according to the given audio file format- Parameters:
afd- the audio file description whose rate field is used to do the conversionsamples- arbitrary offset in sample frames. note that this doesn't have to be within the range of the current length of the audio file.- Returns:
- the time offset which was specified in sample frames, converted to milliseconds (round to integer value if needed).
-
-