-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Final
- Loading branch information
Showing
19 changed files
with
301 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,4 @@ language: java | |
# blocklist | ||
branches: | ||
except: | ||
- develop | ||
- unitTesting | ||
- develop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.redomar.game.audio; | ||
|
||
import javax.sound.sampled.*; | ||
|
||
/** | ||
* For uncompressed files like .wav | ||
*/ | ||
public class AudioEffect{ | ||
|
||
private Clip clip; | ||
private boolean active = false; | ||
|
||
public AudioEffect(String path){ | ||
try{ | ||
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(getClass().getResourceAsStream(path)); | ||
AudioFormat baseformat = audioInputStream.getFormat(); | ||
AudioInputStream decodedAudioInputStream = AudioSystem.getAudioInputStream( | ||
baseformat, audioInputStream); | ||
clip = AudioSystem.getClip(); | ||
clip.open(decodedAudioInputStream); | ||
} catch (Exception e){ | ||
System.err.println(e.getStackTrace()); | ||
} | ||
} | ||
|
||
public void play(){ | ||
if(clip == null) return; | ||
stop(); | ||
clip.setFramePosition(0); | ||
clip.start(); | ||
active = true; | ||
} | ||
|
||
public void setVolume(float velocity){ | ||
FloatControl volume = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); | ||
volume.setValue(velocity); | ||
|
||
} | ||
|
||
public void stop() { | ||
if (clip.isRunning()) clip.stop(); | ||
active = false; | ||
} | ||
|
||
public void close(){ | ||
stop(); | ||
clip.close(); | ||
} | ||
|
||
public boolean getActive(){ | ||
return this.active; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.redomar.game.audio; | ||
|
||
import javax.sound.sampled.*; | ||
|
||
|
||
public class AudioHandler { | ||
|
||
private Clip clip; | ||
private boolean active = false; | ||
|
||
public AudioHandler(String path){ | ||
try{ | ||
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(getClass().getResourceAsStream(path)); | ||
AudioFormat baseformat = audioInputStream.getFormat(); | ||
AudioFormat decodeFormat = new AudioFormat( | ||
AudioFormat.Encoding.PCM_SIGNED, | ||
baseformat.getSampleRate(), 16, | ||
baseformat.getChannels(), | ||
baseformat.getChannels() * 2, | ||
baseformat.getSampleRate(), | ||
false | ||
); | ||
AudioInputStream decodedAudioInputStream = AudioSystem.getAudioInputStream( | ||
decodeFormat, audioInputStream); | ||
clip = AudioSystem.getClip(); | ||
clip.open(decodedAudioInputStream); | ||
} catch (Exception e){ | ||
System.err.println(e.getStackTrace()); | ||
} | ||
} | ||
|
||
public void play(){ | ||
if(clip == null) return; | ||
stop(); | ||
clip.setFramePosition(0); | ||
clip.start(); | ||
active = true; | ||
} | ||
|
||
public void setVolume(float velocity){ | ||
FloatControl volume = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); | ||
volume.setValue(velocity); | ||
|
||
} | ||
|
||
public void stop() { | ||
if (clip.isRunning()) clip.stop(); | ||
active = false; | ||
} | ||
|
||
public void close(){ | ||
stop(); | ||
clip.close(); | ||
} | ||
|
||
public boolean getActive(){ | ||
return this.active; | ||
} | ||
|
||
} |
Oops, something went wrong.