Update SoundEffect

-replace wav to mp3
-converted the mp3 files to have smaller size
This commit is contained in:
Anthony Calosa
2021-02-04 22:49:03 +08:00
parent 233bd2a1c8
commit 3f66e67eea
69 changed files with 75 additions and 60 deletions

View File

@@ -203,6 +203,11 @@
<version>1.27</version> <version>1.27</version>
<type>jar</type> <type>jar</type>
</dependency> </dependency>
<dependency>
<groupId>com.sipgate</groupId>
<artifactId>mp3-wav</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies> </dependencies>
<profiles> <profiles>

View File

@@ -20,10 +20,14 @@ package forge.sound;
import javax.sound.sampled.*; import javax.sound.sampled.*;
import com.google.common.io.Files;
import com.sipgate.mp3wav.Converter;
import forge.properties.ForgeConstants; import forge.properties.ForgeConstants;
import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.MissingResourceException; import java.util.MissingResourceException;
@@ -178,9 +182,15 @@ public class AudioClip implements IAudioClip {
if (!fSound.exists()) { if (!fSound.exists()) {
throw new IllegalArgumentException("Sound file " + fSound.toString() + " does not exist, cannot make a clip of it"); throw new IllegalArgumentException("Sound file " + fSound.toString() + " does not exist, cannot make a clip of it");
} }
InputStream inputStream = null;
try { try {
AudioInputStream stream = AudioSystem.getAudioInputStream(fSound); inputStream = Files.asByteSource(fSound).openStream();
} catch (IOException e) {
e.printStackTrace();
}
try {
ByteArrayInputStream bis = new ByteArrayInputStream(Converter.convertFrom(inputStream).toByteArray());
AudioInputStream stream = AudioSystem.getAudioInputStream(bis);
AudioFormat format = stream.getFormat(); AudioFormat format = stream.getFormat();
DataLine.Info info = new DataLine.Info(Clip.class, stream.getFormat(), ((int) stream.getFrameLength() * format.getFrameSize())); DataLine.Info info = new DataLine.Info(Clip.class, stream.getFormat(), ((int) stream.getFrameLength() * format.getFrameSize()));
Clip clip = (Clip) AudioSystem.getLine(info); Clip clip = (Clip) AudioSystem.getLine(info);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
forge-gui/res/sound/tap.mp3 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -36,65 +36,65 @@ package forge.sound;
public enum SoundEffectType { public enum SoundEffectType {
// Sounds must be listed in alphabetic order. // Sounds must be listed in alphabetic order.
AddCounter("add_counter.wav", true), AddCounter("add_counter.mp3", true),
Artifact("artifact.wav", false), Artifact("artifact.mp3", false),
ArtifactCreature("artifact_creature.wav", false), ArtifactCreature("artifact_creature.mp3", false),
BlackLand("black_land.wav", false), BlackLand("black_land.mp3", false),
BlackRedGreenLand("black_red_green_land.wav", false), BlackRedGreenLand("black_red_green_land.mp3", false),
BlackRedLand("black_red_land.wav", false), BlackRedLand("black_red_land.mp3", false),
BlackWhiteGreenLand("black_white_green_land.wav", false), BlackWhiteGreenLand("black_white_green_land.mp3", false),
BlackWhiteLand("black_white_land.wav", false), BlackWhiteLand("black_white_land.mp3", false),
Block("block.wav", false), Block("block.mp3", false),
BlueBlackLand("blue_black_land.wav", false), BlueBlackLand("blue_black_land.mp3", false),
BlueBlackRedLand("blue_black_red_land.wav", false), BlueBlackRedLand("blue_black_red_land.mp3", false),
BlueLand("blue_land.wav", false), BlueLand("blue_land.mp3", false),
Creature("creature.wav", false), Creature("creature.mp3", false),
Damage("damage.wav", true), Damage("damage.mp3", true),
Destroy("destroy.wav", true), Destroy("destroy.mp3", true),
Discard("discard.wav", false), Discard("discard.mp3", false),
Draw("draw.wav", false), Draw("draw.mp3", false),
Enchantment("enchant.wav", false), Enchantment("enchant.mp3", false),
EndOfTurn("end_of_turn.wav", false), EndOfTurn("end_of_turn.mp3", false),
Equip("equip.wav", false), Equip("equip.mp3", false),
Exile("exile.wav", false), Exile("exile.mp3", false),
FlipCoin("flip_coin.wav", false), FlipCoin("flip_coin.mp3", false),
GreenBlackBlueLand("green_black_blue_land.wav", false), GreenBlackBlueLand("green_black_blue_land.mp3", false),
GreenBlackLand("green_black_land.wav", false), GreenBlackLand("green_black_land.mp3", false),
GreenBlueLand("green_blue_land.wav", false), GreenBlueLand("green_blue_land.mp3", false),
GreenBlueRedLand("green_blue_red_land.wav", false), GreenBlueRedLand("green_blue_red_land.mp3", false),
GreenLand("green_land.wav", false), GreenLand("green_land.mp3", false),
GreenRedLand("green_red_land.wav", false), GreenRedLand("green_red_land.mp3", false),
GreenRedWhiteLand("green_red_white_land.wav", false), GreenRedWhiteLand("green_red_white_land.mp3", false),
Instant("instant.wav", false), Instant("instant.mp3", false),
LifeGain("life_gain.wav", true), LifeGain("life_gain.mp3", true),
LifeLoss("life_loss.wav", true), LifeLoss("life_loss.mp3", true),
LoseDuel("lose_duel.wav", false), LoseDuel("lose_duel.mp3", false),
ManaBurn("mana_burn.wav", false), ManaBurn("mana_burn.mp3", false),
OtherLand("other_land.wav", false), OtherLand("other_land.mp3", false),
Phasing("phasing.wav", true), Phasing("phasing.mp3", true),
Planeswalker("planeswalker.wav", false), Planeswalker("planeswalker.mp3", false),
Poison("poison.wav", true), Poison("poison.mp3", true),
RedBlueLand("red_blue_land.wav", false), RedBlueLand("red_blue_land.mp3", false),
RedBlueWhiteLand("red_blue_white_land.wav", false), RedBlueWhiteLand("red_blue_white_land.mp3", false),
RedLand("red_land.wav", false), RedLand("red_land.mp3", false),
Regen("regeneration.wav", false), Regen("regeneration.mp3", false),
RemoveCounter("remove_counter.wav", true), RemoveCounter("remove_counter.mp3", true),
Sacrifice("sacrifice.wav", true), Sacrifice("sacrifice.mp3", true),
ScriptedEffect("", false), // Plays the effect defined by SVar:SoundEffect ScriptedEffect("", false), // Plays the effect defined by SVar:SoundEffect
Shuffle("shuffle.wav", false), Shuffle("shuffle.mp3", false),
Sorcery("sorcery.wav", false), Sorcery("sorcery.mp3", false),
StartDuel("start_duel.wav",false), StartDuel("start_duel.mp3",false),
Tap("tap.wav", false), Tap("tap.mp3", false),
Token("token.wav", true), Token("token.mp3", true),
Untap("untap.wav", true), Untap("untap.mp3", true),
WhiteBlueBlackLand("white_blue_black_land.wav", false), WhiteBlueBlackLand("white_blue_black_land.mp3", false),
WhiteBlueLand("white_blue_land.wav", false), WhiteBlueLand("white_blue_land.mp3", false),
WhiteGreenBlueLand("white_green_blue_land.wav", false), WhiteGreenBlueLand("white_green_blue_land.mp3", false),
WhiteGreenLand("white_green_land.wav", false), WhiteGreenLand("white_green_land.mp3", false),
WhiteLand("white_land.wav", false), WhiteLand("white_land.mp3", false),
WhiteRedBlackLand("white_red_black_land.wav", false), WhiteRedBlackLand("white_red_black_land.mp3", false),
WhiteRedLand("white_red_land.wav", false), WhiteRedLand("white_red_land.mp3", false),
WinDuel("win_duel.wav", false); WinDuel("win_duel.mp3", false);
private final String resourceFileName; private final String resourceFileName;
private final boolean isSync; private final boolean isSync;