diff --git a/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java b/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java index 2dfcd35..c74b225 100755 --- a/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java +++ b/core/src/zero1hd/rhythmbullet/audio/Mp3Manager.java @@ -5,8 +5,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; -import java.util.logging.Level; -import java.util.logging.Logger; import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; import org.jaudiotagger.audio.exceptions.ReadOnlyFileException; @@ -135,11 +133,11 @@ public class Mp3Manager implements MusicManager { if (currentByteSet != null) { samples[sid] += (workset[1] << 8) + (workset[0] & 0x00ff); if (channels > 1) { - samples[sid] += (workset[3] << 8) + (workset[2] & 0x00ff); - samples[sid] /= 2; + short altChan = (short) ((workset[3] << 8) + (workset[2] & 0x00ff)); + + samples[sid] = altChan > samples[sid] ? altChan : samples[sid]; } framesRead ++; - samples[sid] /= Short.MAX_VALUE+1; } } diff --git a/core/src/zero1hd/rhythmbullet/audio/wavedecoder/WavDecoder.java b/core/src/zero1hd/rhythmbullet/audio/wavedecoder/WavDecoder.java index b545457..88d82ec 100755 --- a/core/src/zero1hd/rhythmbullet/audio/wavedecoder/WavDecoder.java +++ b/core/src/zero1hd/rhythmbullet/audio/wavedecoder/WavDecoder.java @@ -64,11 +64,10 @@ public class WavDecoder { if (audioInputStream.read(buffer) > 0) { samples[sampleID] += (buffer[1] << 8) + (buffer[0] & 0x00ff); if (audioInputStream.getFormat().getChannels() > 1) { - samples[sampleID] += (buffer[3] << 8) + (buffer[2] & 0x00ff); - samples[sampleID] /= 2; + short altChan = (short) ((buffer[3] << 8) + (buffer[2] & 0x00ff)); + samples[sampleID] = altChan > samples[sampleID] ? altChan : samples[sampleID]; } framesRead ++; - samples[sampleID] /= Short.MAX_VALUE+1; } diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java b/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java index 5f52350..d78fc9b 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/components/MusicSelectable.java @@ -35,11 +35,12 @@ public class MusicSelectable extends WidgetGroup implements Disposable { private VerticalGroup vGroup; + private MusicSelectionPage msp; public MusicSelectable(FileHandle musicFile, Preferences musicAnnotation, Skin skin, Texture defaultAlbumC, MusicSelectionPage msp) { table = new Table(skin); table.setBackground("holo-pane"); vGroup = new VerticalGroup(); - + this.msp = msp; setName(musicFile.name()); table.defaults().pad(10f); @@ -131,6 +132,7 @@ public class MusicSelectable extends WidgetGroup implements Disposable { public void select() { table.setBackground("holo-pane-down"); selected = true; + msp.setCurrentlySelected(this); } public void deselect() { diff --git a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java index b3b994d..b85799a 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java +++ b/core/src/zero1hd/rhythmbullet/graphics/ui/pages/MusicSelectionPage.java @@ -112,19 +112,20 @@ public class MusicSelectionPage extends Page { addListener(new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode) { - Gdx.app.debug("MusicSelectionPage", "Scrolling"); int index; if (keycode == Keys.DOWN) { - if ((index = (songTable.getChildren().indexOf(currentlySelected, true) - 1)) < 0) { - index = songTable.getChildren().size; + if ((index = (songTable.getChildren().indexOf(currentlySelected, true) + 1)) == songTable.getChildren().size) { + index = 0; } deselectAll(); ((MusicSelectable)songTable.getChildren().get(index)).select(); scrollbar.scrollTo(currentlySelected.getX(), currentlySelected.getY(), currentlySelected.getWidth(), currentlySelected.getHeight()); } if (keycode == Keys.UP) { - if ((index = (songTable.getChildren().indexOf(currentlySelected, true) + 1)) < songTable.getChildren().size -1) { - index = 0; + if ((index = (songTable.getChildren().indexOf(currentlySelected, true) - 1)) < 0) { + + index = songTable.getChildren().size-1; + } deselectAll(); ((MusicSelectable)songTable.getChildren().get(index)).select();