Class WaveFileBase

java.lang.Object
   |
   +----WaveFileBase

public class WaveFileBase
extends Object
Class representing an audiofile = wavefile.
Basically, a wavefile is defined by these parameters:

This class is made to always be one instance: When you want to clear, or initialize with new arrays, call initWave(...). Nonetheless you may create your own instances in a module.


Variable Index

 o ERROR_OPENING_S
 o ERROR_SAVING_S
 o IS_CORRUPT_S
 o NEITHER_WAV_AU_S
 o NOT_CREATE
 o NOT_SUPPORTED_S
 o Wave
Helper array for simple module type: SimpleModule.

Constructor Index

 o WaveFileBase()
Initializes a Wavefile.

Method Index

 o createNew()
Creates an empty wavefile.
 o createNew(int, short[])
Creates a new mono wavefile with given frequency.
 o createNew(int, short[], short[])
Creates a new stereo wavefile with given frequency.
 o extractFileName()
Returns current name without path.
 o extractFilePath()
Returns path of current name.
 o getChanged()
Returns whether this wavefile was changed after latest call to save().
 o getChannelCount()
Returns number of channels (1:mono, 2:stereo).
 o getCoding()
Returns extension of this wavefile.
 o getDescription()
Returns the description string.
 o getFrequency()
Returns frequency (samples per second) of this wavefile.
 o getLeftWave()
returns array of left wave-data.
 o getName()
Returns the filename of this wavefile.
 o getResolution()
Returns resolution (8 or 16 bit).
 o getRightWave()
returns array of right wave data.
 o getSize()
returns number of samples in this wavefile.
 o isEmpty()
Returns whether this wavefile is empty.
 o isMono()
Returns whether this wavefile is internally mono.
 o isStereo()
returns whether this wavefile is internally stereo.
 o load(String)
Loads "file".
The format (Sun muLaw (".au") or Microsoft PCM (".wav") is recognized automatically.
 o msToSamples(long)
Returns the sample position when "ms" milliseconds are elapsed.
 o samplesToMs(int)
Returns time elapsed after "Sample" samples in ms.
 o save()
Saves current wave.
 o setChanged(boolean)
Sets state of "changed".
 o setChannelCount(short)
Sets number of channels (1:mono, 2:stereo).
 o setCoding(String)
Sets the format, "au" or "wav".
 o setDescription(String)
Sets description string.
 o setFrequency(int)
Sets frequency of this wavefile.
 o setName(String)
Sets the filename of this wavefile.
 o setResolution(short)
sets resolution of this wavefile.
 o setWaves(short[], short[])
Sets arrays of left and right data.

Variables

 o NOT_SUPPORTED_S
 public static String NOT_SUPPORTED_S
 o IS_CORRUPT_S
 public static String IS_CORRUPT_S
 o ERROR_OPENING_S
 public static String ERROR_OPENING_S
 o ERROR_SAVING_S
 public static String ERROR_SAVING_S
 o NOT_CREATE
 public static String NOT_CREATE
 o NEITHER_WAV_AU_S
 public static String NEITHER_WAV_AU_S
 o Wave
 public short Wave[]
Helper array for simple module type: SimpleModule. This array is only valid for this type of modules. It cannot be used outside a simple Module. donnees du vieux type. pour les simple modules: SimpleModule

Constructors

 o WaveFileBase
 public WaveFileBase()
Initializes a Wavefile. It is initially empty. That means, the format is set to 8000Hz, 8bit, mono, the arrays of the waves are initialized with length=0. The name defaults to "new.au".

Methods

 o createNew
 public void createNew(int freq,
                       short mono[])
Creates a new mono wavefile with given frequency.
cree un fichier Wave avec freq et data[] mono. c'est pour instancier une instance avec des donnees en mono

 o createNew
 public void createNew(int freq,
                       short left[],
                       short right[])
Creates a new stereo wavefile with given frequency.
cree Wave avec freq et donnees left[] et right[].

 o createNew
 public void createNew()
Creates an empty wavefile.
cree Wave sans donnees.

 o load
 public void load(String file) throws WaveFileException
Loads "file".
The format (Sun muLaw (".au") or Microsoft PCM (".wav") is recognized automatically. Frequency, resolution, channelCount, description and name are set to values found in the file.
Charge le fichier "file".
reconnait automatiquement, si le fichier est Sun muLaw (".au") ou Microsoft PCM (".wav")

Throws: WaveFileException
when "file" doesn't exist, a read error occured or the file has a unrecognized format.
Throws: WaveFileException
quand le fichier "file" n'existe pas, un erreur d'ecriture ou le fichier a un format non supporte.
 o save
 public void save() throws WaveFileException
Saves current wave. The name may be set with setName(), but is normally set when you called load() before. The format (.au or .wav) is derived from the extension of filename
Sauve le fichier actuel. (nom: name).
Si le nom est *.au, le format est Sun muLaw, si le nom est *.wav, le format et Microsoft PCM

Throws: WaveFileException
when a writing error occurs.
Throws: WaveFileException
quand un error d'ecriture se passe
 o getLeftWave
 public short[] getLeftWave()
returns array of left wave-data.
retourne le tableau des donnees de gauche.

 o getRightWave
 public short[] getRightWave()
returns array of right wave data.
retourne le tableau des donnees de right.

 o setWaves
 public synchronized void setWaves(short left[],
                                   short right[])
Sets arrays of left and right data. This method should be called at the end of any treatment.
Note: both arrays have to have the same length.
change les tableaux de right et left.

 o getSize
 public int getSize()
returns number of samples in this wavefile. This equals the size of the arrays leftwave and rightwave.
retourne la taille en echantillons du WaveFile.

 o getFrequency
 public int getFrequency()
Returns frequency (samples per second) of this wavefile.
retourne la frequence (cvd echantillons par seconde) du WaveFile.

 o setFrequency
 public int setFrequency(int freq)
Sets frequency of this wavefile. Returns the new frequency.
change la frequence. Utilisable surtout dans les modules. retourne la nouvelle frequence

 o getCoding
 public String getCoding()
Returns extension of this wavefile. Currently supported: "wav" or "au".
Note: The name of this function will be changed !
retourne le format actuelle comme String. format est egal au extension du nom du ficher (name) du WaveFile acteullement supporte : "wav" ,"au" null si aucune extensin existe.

 o setCoding
 public void setCoding(String exten)
Sets the format, "au" or "wav". Effectively this method will only change the extension of the filename, but this is taken into consideration when calling save().
definit le format actuelle. format est egal au extension du nom du ficher (name) du WaveFile acteullement supporte : "wav" ,"au"

 o isEmpty
 public boolean isEmpty()
Returns whether this wavefile is empty.
Empty means: either filename is null or "", the arrays leftwave and rightwave are null or zero-length.
retourne true, si WaveFile ne contien pas de donnees.

 o getResolution
 public short getResolution()
Returns resolution (8 or 16 bit).
retourne la resolution (8 ou 16 bit) du fichier wave.

 o setResolution
 public short setResolution(short res)
sets resolution of this wavefile. Only values of 8 or 16 are supported.
returns the new resolution.
pour changer la resolution (8 ou 16 bit). retourne la nouvelle resolution

 o getChannelCount
 public short getChannelCount()
Returns number of channels (1:mono, 2:stereo).
Note, that wavefiles are always treated as stereo in JaWavedit. That means, a mono wavefile means only, that it will be saved as a mono file, which is done by mixing left and right side.

retourne le nb de channels (1=>mono, 2=>stereo).

 o setChannelCount
 public short setChannelCount(short channels)
Sets number of channels (1:mono, 2:stereo).
Note, that wavefiles are always treated as stereo in JaWavedit. That means, a mono wavefile means only, that it will be saved as a mono file, which is done by mixing left and right side.

change le nb de channels (1=>mono, 2=>stereo). retourne le nouvel nb de channels

 o isMono
 public boolean isMono()
Returns whether this wavefile is internally mono.
retourne true, si WaveFile est interne en format mono.

 o isStereo
 public boolean isStereo()
returns whether this wavefile is internally stereo.
retourne true, si WaveFile est interne en format stereo.

 o getName
 public String getName()
Returns the filename of this wavefile.
retourne le nom de fichier du WaveFile.

 o setName
 public void setName(String fileName)
Sets the filename of this wavefile.
change le nom du WaveFile.

 o getDescription
 public String getDescription()
Returns the description string.
This is only for information purposes, it is included in wav and au files.
retourne le string de description. il est inclu dans les fichiers .wav ou .au

 o setDescription
 public void setDescription(String newDescr)
Sets description string.
This is only for information purposes, it is included in wav and au files.*
change le string de description. il est inclu dans les fichiers .wav ou .au

 o getChanged
 public boolean getChanged()
Returns whether this wavefile was changed after latest call to save().
When changed is true, an asterisk is displayed in the title of the main window of JaWavedit.
retourne true, si le WaveFile est different compare au fichier sur la disque.

 o setChanged
 public void setChanged(boolean c)
Sets state of "changed".
You shouldn't use this, as it is updated automatically.
change l'etat de "changed".

 o samplesToMs
 public long samplesToMs(int Sample)
Returns time elapsed after "Sample" samples in ms. This takes into consideration the current frequency.
retourne la position "Sample" (en echantillons) en ms.
peut etre utilise dans les modules.

 o msToSamples
 public int msToSamples(long ms)
Returns the sample position when "ms" milliseconds are elapsed. It takes into consideration current frequency.
retourne la position "ms" en echantillons.
peut etre utilise dans les modules.

 o extractFileName
 public String extractFileName()
Returns current name without path.
retourne le nom de fichier Wavefile sans le chemin.

 o extractFilePath
 public String extractFilePath()
Returns path of current name.
retourne le chemin de fichier Wavefile.