Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lDEVinux
GitHub Repository: lDEVinux/eaglercraft
Path: blob/main/src/lwjgl/java/paulscode/sound/ICodec.java
8644 views
1
package paulscode.sound;
2
3
import java.net.URL;
4
import javax.sound.sampled.AudioFormat;
5
6
/**
7
* The ICodec interface provides a common interface for SoundSystem to use
8
* for accessing external codec libraries.
9
*<br><br>
10
*<b><i> SoundSystem License:</b></i><br><b><br>
11
* You are free to use this library for any purpose, commercial or otherwise.
12
* You may modify this library or source code, and distribute it any way you
13
* like, provided the following conditions are met:
14
*<br>
15
* 1) You may not falsely claim to be the author of this library or any
16
* unmodified portion of it.
17
*<br>
18
* 2) You may not copyright this library or a modified version of it and then
19
* sue me for copyright infringement.
20
*<br>
21
* 3) If you modify the source code, you must clearly document the changes
22
* made before redistributing the modified source code, so other users know
23
* it is not the original code.
24
*<br>
25
* 4) You are not required to give me credit for this library in any derived
26
* work, but if you do, you must also mention my website:
27
* http://www.paulscode.com
28
*<br>
29
* 5) I the author will not be responsible for any damages (physical,
30
* financial, or otherwise) caused by the use if this library or any part
31
* of it.
32
*<br>
33
* 6) I the author do not guarantee, warrant, or make any representations,
34
* either expressed or implied, regarding the use of this library or any
35
* part of it.
36
* <br><br>
37
* Author: Paul Lamb
38
* <br>
39
* http://www.paulscode.com
40
* </b>
41
*/
42
public interface ICodec
43
{
44
/**
45
* Should tell derived classes when they may need to reverse the byte order of
46
* the data before returning it in the read() and readAll() methods. The
47
* reason for the reversBytOrder method is because some external codec
48
* libraries produce audio data in a format that some external audio libraries
49
* require to be reversed. Derivatives of the Library and Source classes for
50
* audio libraries which require this type of data to be reversed should call
51
* the reverseByteOrder() method for all instances of ICodec that they use.
52
* Derivatives of the ICodec interface for codec libraries which which produce
53
* this type of data should use the reverseByteOrder() method to know when the
54
* data needs to be reversed before returning it in the read() and readAll()
55
* methods. If a particular codec library does not produce this type of data,
56
* its derived ICodec class may disregard any calls to the reverseByteOrder()
57
* method.
58
* @param b True if the calling audio library requires byte-reversal by some codec libraries.
59
*/
60
public void reverseByteOrder( boolean b );
61
62
/**
63
* Should make any preperations required before reading from the audio stream.
64
* If another stream is already opened, it should be closed and a new audio
65
* stream opened in its place. This method is used internally by SoundSystem
66
* not only to initialize a stream, but also to rewind streams and to switch
67
* stream sources on the fly.
68
* @return False if an error occurred or if end of stream was reached.
69
*/
70
public boolean initialize( URL url );
71
72
/**
73
* Should return false if the stream is busy initializing. To prevent bad
74
* data from being returned by this method, derived classes should internally
75
* synchronize with any elements used by both the initialized() and initialize()
76
* methods.
77
* @return True if steam is initialized.
78
*/
79
public boolean initialized();
80
81
/**
82
* Should read in one stream buffer worth of audio data. See
83
* {@link paulscode.sound.SoundSystemConfig SoundSystemConfig} for more
84
* information about accessing and changing default settings.
85
* @return The audio data wrapped into a SoundBuffer context.
86
*/
87
public SoundBuffer read();
88
89
/**
90
* Should read in all the audio data from the stream (up to the default
91
* "maximum file size". See
92
* {@link paulscode.sound.SoundSystemConfig SoundSystemConfig} for more
93
* information about accessing and changing default settings.
94
* @return the audio data wrapped into a SoundBuffer context.
95
*/
96
public SoundBuffer readAll();
97
98
/**
99
* Should return false if there is still more data available to be read in. To
100
* prevent bad data from being returned by this method, derived classes should
101
* internally synchronize with any elements used in both the endOfStream() and
102
* the read() or readAll() methods.
103
* @return True if end of stream was reached.
104
*/
105
public boolean endOfStream();
106
107
/**
108
* Should close any open streams and remove references to all instantiated
109
* objects.
110
*/
111
public void cleanup();
112
113
/**
114
* Should return the audio format of the data being returned by the read() and
115
* readAll() methods.
116
* @return Information wrapped into an AudioFormat context.
117
*/
118
public AudioFormat getAudioFormat();
119
}
120
121