Path: blob/main/src/lwjgl/java/paulscode/sound/ICodec.java
8644 views
package paulscode.sound;12import java.net.URL;3import javax.sound.sampled.AudioFormat;45/**6* The ICodec interface provides a common interface for SoundSystem to use7* for accessing external codec libraries.8*<br><br>9*<b><i> SoundSystem License:</b></i><br><b><br>10* You are free to use this library for any purpose, commercial or otherwise.11* You may modify this library or source code, and distribute it any way you12* like, provided the following conditions are met:13*<br>14* 1) You may not falsely claim to be the author of this library or any15* unmodified portion of it.16*<br>17* 2) You may not copyright this library or a modified version of it and then18* sue me for copyright infringement.19*<br>20* 3) If you modify the source code, you must clearly document the changes21* made before redistributing the modified source code, so other users know22* it is not the original code.23*<br>24* 4) You are not required to give me credit for this library in any derived25* work, but if you do, you must also mention my website:26* http://www.paulscode.com27*<br>28* 5) I the author will not be responsible for any damages (physical,29* financial, or otherwise) caused by the use if this library or any part30* of it.31*<br>32* 6) I the author do not guarantee, warrant, or make any representations,33* either expressed or implied, regarding the use of this library or any34* part of it.35* <br><br>36* Author: Paul Lamb37* <br>38* http://www.paulscode.com39* </b>40*/41public interface ICodec42{43/**44* Should tell derived classes when they may need to reverse the byte order of45* the data before returning it in the read() and readAll() methods. The46* reason for the reversBytOrder method is because some external codec47* libraries produce audio data in a format that some external audio libraries48* require to be reversed. Derivatives of the Library and Source classes for49* audio libraries which require this type of data to be reversed should call50* the reverseByteOrder() method for all instances of ICodec that they use.51* Derivatives of the ICodec interface for codec libraries which which produce52* this type of data should use the reverseByteOrder() method to know when the53* data needs to be reversed before returning it in the read() and readAll()54* methods. If a particular codec library does not produce this type of data,55* its derived ICodec class may disregard any calls to the reverseByteOrder()56* method.57* @param b True if the calling audio library requires byte-reversal by some codec libraries.58*/59public void reverseByteOrder( boolean b );6061/**62* Should make any preperations required before reading from the audio stream.63* If another stream is already opened, it should be closed and a new audio64* stream opened in its place. This method is used internally by SoundSystem65* not only to initialize a stream, but also to rewind streams and to switch66* stream sources on the fly.67* @return False if an error occurred or if end of stream was reached.68*/69public boolean initialize( URL url );7071/**72* Should return false if the stream is busy initializing. To prevent bad73* data from being returned by this method, derived classes should internally74* synchronize with any elements used by both the initialized() and initialize()75* methods.76* @return True if steam is initialized.77*/78public boolean initialized();7980/**81* Should read in one stream buffer worth of audio data. See82* {@link paulscode.sound.SoundSystemConfig SoundSystemConfig} for more83* information about accessing and changing default settings.84* @return The audio data wrapped into a SoundBuffer context.85*/86public SoundBuffer read();8788/**89* Should read in all the audio data from the stream (up to the default90* "maximum file size". See91* {@link paulscode.sound.SoundSystemConfig SoundSystemConfig} for more92* information about accessing and changing default settings.93* @return the audio data wrapped into a SoundBuffer context.94*/95public SoundBuffer readAll();9697/**98* Should return false if there is still more data available to be read in. To99* prevent bad data from being returned by this method, derived classes should100* internally synchronize with any elements used in both the endOfStream() and101* the read() or readAll() methods.102* @return True if end of stream was reached.103*/104public boolean endOfStream();105106/**107* Should close any open streams and remove references to all instantiated108* objects.109*/110public void cleanup();111112/**113* Should return the audio format of the data being returned by the read() and114* readAll() methods.115* @return Information wrapped into an AudioFormat context.116*/117public AudioFormat getAudioFormat();118}119120121