fixed: crash from invalid buffer positioning, error from shutting thread
down before instantiation; removed old code;
This commit is contained in:
parent
b84a3d6280
commit
97afc449b2
@ -33,12 +33,6 @@ public class MP3Metadata implements AudioMetadata {
|
|||||||
try {
|
try {
|
||||||
MP3File mp3file = (MP3File) AudioFileIO.read(fileHandle.file());
|
MP3File mp3file = (MP3File) AudioFileIO.read(fileHandle.file());
|
||||||
ID3v23Tag tag;
|
ID3v23Tag tag;
|
||||||
if (mp3file.hasID3v1Tag()) {
|
|
||||||
mp3file.setID3v2Tag(mp3file.getID3v1Tag());
|
|
||||||
mp3file.setID3v1Tag(null);
|
|
||||||
mp3file.commit();
|
|
||||||
tag = (ID3v23Tag) mp3file.getTagAndConvertOrCreateAndSetDefault();
|
|
||||||
}
|
|
||||||
tag = (ID3v23Tag) mp3file.getTagAndConvertOrCreateAndSetDefault();
|
tag = (ID3v23Tag) mp3file.getTagAndConvertOrCreateAndSetDefault();
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +47,7 @@ public class MP3Metadata implements AudioMetadata {
|
|||||||
if (title.isEmpty()) {
|
if (title.isEmpty()) {
|
||||||
title = fileHandle.nameWithoutExtension().replace('_', ' ');
|
title = fileHandle.nameWithoutExtension().replace('_', ' ');
|
||||||
}
|
}
|
||||||
} catch (IOException | CannotWriteException | CannotReadException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
|
} catch (IOException | CannotReadException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
|
||||||
Gdx.app.error("MP3Metadata", "Failed to read metadata of file: " + fileHandle.name());
|
Gdx.app.error("MP3Metadata", "Failed to read metadata of file: " + fileHandle.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,8 @@ public class DoubleHorizontalVisualizer implements Disposable {
|
|||||||
private float barChangeRate = 6.5f;
|
private float barChangeRate = 6.5f;
|
||||||
private int smoothRange = 2;
|
private int smoothRange = 2;
|
||||||
private int binsToInclude = 120;
|
private int binsToInclude = 120;
|
||||||
private Color color = new Color(0.5f, 0.6f, 0.8f, 0.46f);
|
private Color colorBegin = new Color(0.5f, 0.6f, 0.8f, 0.46f);
|
||||||
|
private Color colorEnd = new Color();
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param barCount amount of bars this visualizer should have.
|
* @param barCount amount of bars this visualizer should have.
|
||||||
@ -98,7 +99,6 @@ public class DoubleHorizontalVisualizer implements Disposable {
|
|||||||
|
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
batch.end();
|
batch.end();
|
||||||
|
|
||||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||||
shapeRenderer.begin(ShapeType.Filled);
|
shapeRenderer.begin(ShapeType.Filled);
|
||||||
shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix());
|
shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix());
|
||||||
@ -109,7 +109,7 @@ public class DoubleHorizontalVisualizer implements Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int bar = 0; bar < barCount; bar++) {
|
for (int bar = 0; bar < barCount; bar++) {
|
||||||
shapeRenderer.setColor(color);
|
shapeRenderer.setColor(colorBegin);
|
||||||
shapeRenderer.rect(offset + (spaceBetweenBars+barWidth)*bar, y+height, barWidth, barHeights[bar]);
|
shapeRenderer.rect(offset + (spaceBetweenBars+barWidth)*bar, y+height, barWidth, barHeights[bar]);
|
||||||
shapeRenderer.rect(offset + (spaceBetweenBars+barWidth)*bar, y, barWidth, -barHeights[barHeights.length - 1 - bar]);
|
shapeRenderer.rect(offset + (spaceBetweenBars+barWidth)*bar, y, barWidth, -barHeights[barHeights.length - 1 - bar]);
|
||||||
}
|
}
|
||||||
|
@ -110,9 +110,9 @@ public class PCMObtainer implements Observer, PCMSystem {
|
|||||||
|
|
||||||
private boolean synchronizeBufferWithPlayback() {
|
private boolean synchronizeBufferWithPlayback() {
|
||||||
int bufferPos = calcBufferPosition();
|
int bufferPos = calcBufferPosition();
|
||||||
if (bufferPos <= playingBuffer.limit()) {
|
if (bufferPos < playingBuffer.limit() || bufferPos >= 0) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
playingBuffer.position(calcBufferPosition());
|
playingBuffer.position(bufferPos);
|
||||||
windowsRead = (int) ((mc.getCurrentPosition() * sampleRate) / windowSize);
|
windowsRead = (int) ((mc.getCurrentPosition() * sampleRate) / windowSize);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import com.badlogic.gdx.Gdx;
|
|||||||
import com.badlogic.gdx.assets.AssetManager;
|
import com.badlogic.gdx.assets.AssetManager;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
|
import com.badlogic.gdx.math.Vector3;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||||
@ -121,6 +122,12 @@ public class MainPage extends Page implements Observer {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCameraPositionToPage(Vector3 cameraPosition) {
|
||||||
|
getStage().setScrollFocus(null);
|
||||||
|
super.setCameraPositionToPage(cameraPosition);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
if (o == mc) {
|
if (o == mc) {
|
||||||
|
@ -49,7 +49,6 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
|
|
||||||
private Batch screenBatch;
|
private Batch screenBatch;
|
||||||
|
|
||||||
private float targetDelta;
|
|
||||||
public MainScreen(RhythmBullet core) {
|
public MainScreen(RhythmBullet core) {
|
||||||
this.rhythmBullet = core;
|
this.rhythmBullet = core;
|
||||||
stage = new Stage(new ScreenViewport());
|
stage = new Stage(new ScreenViewport());
|
||||||
@ -63,7 +62,6 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
|
|
||||||
listeners = new Listeners();
|
listeners = new Listeners();
|
||||||
screenBatch = new SpriteBatch();
|
screenBatch = new SpriteBatch();
|
||||||
targetDelta = 1f/core.getScreenConfiguration().getTargetFramesPerSecond();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -80,7 +78,7 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (stage.getCamera().position.x != cameraPosition.x || stage.getCamera().position.y != cameraPosition.y) {
|
if (stage.getCamera().position.x != cameraPosition.x || stage.getCamera().position.y != cameraPosition.y) {
|
||||||
stage.getCamera().position.lerp(cameraPosition, targetDelta*lerpAlpha);
|
stage.getCamera().position.lerp(cameraPosition, 0.15f);
|
||||||
stage.getViewport().apply();
|
stage.getViewport().apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +142,6 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
Gdx.input.setInputProcessor(stage);
|
Gdx.input.setInputProcessor(stage);
|
||||||
calcLerpAlpha(Gdx.graphics.getWidth());
|
|
||||||
super.show();
|
super.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +164,6 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
stage.getViewport().update(width, height, false);
|
stage.getViewport().update(width, height, false);
|
||||||
cameraPosition.x = width/2;
|
cameraPosition.x = width/2;
|
||||||
cameraPosition.y = height/2;
|
cameraPosition.y = height/2;
|
||||||
calcLerpAlpha(width);
|
|
||||||
super.resize(width, height);
|
super.resize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,14 +176,6 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calcLerpAlpha(int width) {
|
|
||||||
if (width <= 3835) {
|
|
||||||
lerpAlpha = 5.0f;
|
|
||||||
} else {
|
|
||||||
lerpAlpha = 5.5f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDisplayedPage(Page page) {
|
public void setDisplayedPage(Page page) {
|
||||||
page.setCameraPositionToPage(cameraPosition);
|
page.setCameraPositionToPage(cameraPosition);
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
|
|
||||||
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
|
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
|
||||||
private float musicSelectDelay;
|
private float musicSelectDelay;
|
||||||
|
|
||||||
public MusicSelectionPage(AssetManager assetManager, Skin skin, MusicController musicController, AudioMetadataController musicMetadataController, ChangeListener backButtonListener, ChangeListener beginButtonListener) {
|
public MusicSelectionPage(AssetManager assetManager, Skin skin, MusicController musicController, AudioMetadataController musicMetadataController, ChangeListener backButtonListener, ChangeListener beginButtonListener) {
|
||||||
super(1, 0);
|
super(1, 0);
|
||||||
this.assets = assetManager;
|
this.assets = assetManager;
|
||||||
@ -289,7 +290,9 @@ public class MusicSelectionPage extends Page implements Observer {
|
|||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
clear();
|
clear();
|
||||||
|
if (thread != null) {
|
||||||
thread.interrupt();
|
thread.interrupt();
|
||||||
|
}
|
||||||
work = false;
|
work = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user