3 Commits
2 changed files with 20 additions and 11 deletions

No files matched your search

+10
View File
@@ -2,3 +2,13 @@
Draw sound waves with your mouse. Just like you see them in audio editing software.
![Image](https://user-images.githubusercontent.com/38253929/189550857-64f5cdad-f39b-43f6-b103-d4aa472f6788.png)
# How to
## Controls (top)
- Left: change volume
- Right: change length of the looping sound
## DrawBoard (bottom)
- Left-click and drag: draw the sound wave
- Mouse wheel: zoom in and out
- Right-click and drag: move the board around
+10 -11
View File
@@ -219,13 +219,13 @@ public class DrawingBoard extends JPanel {
if (mouseDrag != EnumMouseDrag.MOVE)
return;
int width = getWidth();
float width = getWidth();
int newOff = (int) ((float) (lastPos.x - pos.x) / zoom / ((float) width / data.length));
int newOff = (int) ((float) (lastPos.x - pos.x) / zoom / (width / data.length));
int half = data.length / 2;
int lowerBound = half / zoom - half - centerOff;
int higherBound = data.length - half / zoom - half - centerOff;
float half = data.length / 2f;
int lowerBound = (int) Math.ceil(half / zoom - half - centerOff);
int higherBound = (int) Math.floor(data.length - half / zoom - half - centerOff);
if (newOff < lowerBound) {
newOff = lowerBound;
@@ -239,7 +239,7 @@ public class DrawingBoard extends JPanel {
}
private void fireZoom(Point pos, int wheel) {
int width = getWidth();
float width = getWidth();
int oldZoom = zoom;
@@ -252,14 +252,13 @@ public class DrawingBoard extends JPanel {
if (oldZoom == zoom)
return;
int pseudoMoveOff = (int) ((float) (pos.x - width / 2) / oldZoom / zoom / ((float) width / data.length));
int pseudoMoveOff = (int) ((float) (pos.x - width / 2) / oldZoom / zoom / (width / data.length));
centerOff += wheel < 0 ? pseudoMoveOff : -pseudoMoveOff;
int half = data.length / 2;
int lowerBound = half / zoom - half - centerOff;
int higherBound = data.length - half / zoom - half - centerOff;
float half = data.length / 2f;
int lowerBound = (int) Math.ceil(half / zoom - half - centerOff);
int higherBound = (int) Math.floor(data.length - half / zoom - half - centerOff);
int newOff = 0;
if (lowerBound > 0) {
centerOff += lowerBound;
} else if (higherBound < 0) {