try {\r
AudioFormat format = new AudioFormat(samplingRate, 16, isMono ? 1 : 2, true, false);\r
line = AudioSystem.getSourceDataLine(format);\r
- line.open(format, Math.min(2048, samplingRate / 5) * 2);\r
+ line.open(format, 2048 * 10);// Math.min(2048*10, samplingRate / 5) * 2);\r
line.start();\r
} catch (Exception ex) {\r
throw new GdxRuntimeException("Error creating JavaSoundAudioDevice.", ex);\r
}\r
}\r
\r
- protected int read (byte[] buffer) {\r
+ public int read (byte[] buffer) {\r
try {\r
boolean setup = bitstream == null;\r
if (setup) {\r
}\r
}\r
\r
- protected void reset () {\r
+ public void reset () {\r
if (bitstream == null) return;\r
try {\r
bitstream.close();\r
setup(input.getChannels(), input.getSampleRate());\r
}\r
\r
- protected int read (byte[] buffer) {\r
+ public int read (byte[] buffer) {\r
if (input == null) {\r
input = new OggInputStream(file.read());\r
setup(input.getChannels(), input.getSampleRate());\r
return input.read(buffer);\r
}\r
\r
- protected void reset () {\r
+ public void reset () {\r
if (input == null) return;\r
input.close();\r
input = null;\r
this.audio = audio;\r
this.file = file;\r
\r
- audio.music.add(this);\r
+ if(audio != null) audio.music.add(this);\r
}\r
\r
protected void setup (int channels, int sampleRate) {\r
\r
/** Fills as much of the buffer as possible and returns the number of bytes filled. Returns <= 0 to indicate the end of the\r
* stream. */\r
- abstract protected int read (byte[] buffer);\r
+ abstract public int read (byte[] buffer);\r
\r
/** Resets the stream to the beginning. */\r
- abstract protected void reset ();\r
+ abstract public void reset ();\r
+ \r
+ public int getChannels() {\r
+ return format == AL_FORMAT_STEREO16?2:1;\r
+ }\r
+ \r
+ public int getRate() {\r
+ return sampleRate;\r
+ }\r
\r
public void update () {\r
if (sourceID == -1) return;\r
setup(input.channels, input.sampleRate);\r
}\r
\r
- protected int read (byte[] buffer) {\r
+ public int read (byte[] buffer) {\r
if (input == null) {\r
input = new WavInputStream(file);\r
setup(input.channels, input.sampleRate);\r
}\r
}\r
\r
- protected void reset () {\r
+ public void reset () {\r
if (input == null) return;\r
try {\r
input.close();\r