Skip to content

Commit

Permalink
Merge pull request #355 from JacobSeto/ben-audiodebugging
Browse files Browse the repository at this point in the history
RHuipfyhr
  • Loading branch information
caitlynjin committed May 18, 2024
2 parents 4e8a69b + efe0f64 commit dcccef7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
11 changes: 10 additions & 1 deletion core/src/edu/cornell/gdiac/rabbeat/GameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,13 @@ public void gatherAssets(AssetDirectory directory) {
* @param directory Reference to global asset manager.
*/
public void setSoundtrack(AssetDirectory directory) {
soundController.USE_INSTANT_SWITCH = false;
if (synthSoundtrack != null) {
synthSoundtrack.dispose();
}
if (jazzSoundtrack != null) {
jazzSoundtrack.dispose();
}
synthSoundtrack = directory.getEntry(
objectController.defaultConstants.get("music").get(getCurrentLevel())
.getString("synth"), Music.class);
Expand Down Expand Up @@ -688,6 +695,7 @@ public void initialize() {
worldHeight = DEFAULT_HEIGHT * objectController.levelBackground.getRegionHeight()
/ getCanvas().getHeight();
world.setContactListener(this);
//soundController.pauseMusic();
soundController.resetMusic();
soundController.playMusic(genre);
syncController.initializeSync();
Expand Down Expand Up @@ -951,6 +959,7 @@ public void beginContact(Contact contact) {
if ((bd1 == objectController.player && bd2 == objectController.goalDoor) ||
(bd1 == objectController.goalDoor && bd2 == objectController.player)) {
setComplete(true);
soundController.USE_INSTANT_SWITCH = true;
}

// Bullet and Bee Collision checks
Expand Down Expand Up @@ -1489,6 +1498,7 @@ public void pause () {
*/
public void resume () {
soundController.setGlobalMusicVolumeImmediate(musicVolume / 10f);

soundController.setGlobalSFXVolume(SFXVolume / 10f);

// soundController.resumeMusic();
Expand Down Expand Up @@ -1618,7 +1628,6 @@ public int getNumberOfLevels () {

/** Called when the game screen needs to be exited out of */
public void exitScreen ( int exitCode){
soundController.pauseMusic();
listener.exitScreen(this, exitCode);
}

Expand Down
18 changes: 16 additions & 2 deletions core/src/edu/cornell/gdiac/rabbeat/SoundController.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class SoundController {
* Set this to true to make genre switches instantaneous / in one frame.
* Set this to false to make genre switches gradual / over several frames.
*/
private static final boolean USE_INSTANT_SWITCH = false;
public static boolean USE_INSTANT_SWITCH = false;

/** What percentage of volume should be kept when pausing.
* A value of 0.4 means the track will be 40% as loud as it normally would be.
Expand Down Expand Up @@ -57,6 +57,8 @@ public SoundController() {
public void playMusic() {
synthTrack.setLooping(true);
jazzTrack.setLooping(true);
currentlyUpdating = false;
currentUpdateFrame = 0;
synthTrack.play();
jazzTrack.play();
}
Expand Down Expand Up @@ -103,6 +105,19 @@ public void setGlobalMusicVolumeImmediate(float vol, boolean paused) {
jazzTrack.setVolume(vol * (paused ? PAUSE_VOL : 1));
synthTrack.setVolume(0);
}
if (synthTrack.getVolume() > 1) {
synthTrack.setVolume(1);
}
if (jazzTrack.getVolume() > 1) {
jazzTrack.setVolume(1);
}

if (synthTrack.getVolume() < 0) {
synthTrack.setVolume(0);
}
if (jazzTrack.getVolume() < 0) {
jazzTrack.setVolume(0);
}
}

public void resetMusic() {
Expand All @@ -113,7 +128,6 @@ public void resetMusic() {
currentlyUpdating = false;
currentUpdateFrame = 0;
}

public void pauseMusic() {
/*savedJazzVolume = jazzTrack.getVolume();
savedSynthVolume = synthTrack.getVolume();
Expand Down

0 comments on commit dcccef7

Please sign in to comment.