Skip to content

Commit 297a414

Browse files
committedMay 4, 2016
This was easy.
1 parent 4336f08 commit 297a414

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed
 

Diff for: ‎src/main/java/pl/asie/computronics/util/sound/Audio.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package pl.asie.computronics.util.sound;
22

33
import com.google.common.base.Throwables;
4-
import com.google.common.collect.Interner;
5-
import com.google.common.collect.Interners;
64
import cpw.mods.fml.common.FMLCommonHandler;
75
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
86
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
@@ -329,8 +327,6 @@ public static Audio instance() {
329327
return INSTANCE;
330328
}
331329

332-
private static final Interner<Byte> interner = Interners.newStrongInterner();
333-
334330
public void play(float x, float y, float z, Queue<Instruction> instructions) {
335331
Minecraft mc = Minecraft.getMinecraft();
336332
float distanceBasedGain = ((float) Math.max(0, 1 - mc.thePlayer.getDistance(x, y, z) / maxDistance));
@@ -348,7 +344,7 @@ public void play(float x, float y, float z, Queue<Instruction> instructions) {
348344
for(int sample = 0; sample < sampleCount; ++sample) {
349345
for(AudioUtil.State state : process.states) {
350346
int value = ((byte) (state.gate.getValue(process, state) * amplitude)) ^ 0x80;
351-
state.data.add(interner.intern((byte) value));
347+
state.data.write((byte) value);
352348
}
353349
}
354350
process.delay = 0;
@@ -366,7 +362,7 @@ public void play(float x, float y, float z, Queue<Instruction> instructions) {
366362
synchronized(sources) {
367363
for(AudioUtil.State state : process.states) {
368364
ByteBuffer buf = BufferUtils.createByteBuffer(state.data.size());
369-
for(Byte aByte : state.data) {
365+
for(byte aByte : state.data.toByteArray()) {
370366
buf.put(aByte);
371367
}
372368
sources.add(new Source(x, y, z, buf, gain));

Diff for: ‎src/main/java/pl/asie/computronics/util/sound/AudioUtil.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.google.common.collect.ImmutableList;
44
import pl.asie.computronics.reference.Config;
55

6+
import java.io.ByteArrayOutputStream;
67
import java.util.ArrayList;
7-
import java.util.List;
88

99
/**
1010
* @author Vexatos
@@ -177,7 +177,7 @@ public static class State {
177177
public ADSR envelope;
178178

179179
public boolean isFreqMod, isAmpMod;
180-
public final List<Byte> data = new ArrayList<Byte>();
180+
public final ByteArrayOutputStream data = new ByteArrayOutputStream();
181181

182182
public State(int channelIndex) {
183183
this.wave = new Wave();

0 commit comments

Comments
 (0)
Please sign in to comment.