Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0643bc6f5d | ||
|
|
efca31dc79 | ||
|
|
03f0a3680f |
No files matched your search
@@ -2,3 +2,13 @@
|
|||||||
Draw sound waves with your mouse. Just like you see them in audio editing software.
|
Draw sound waves with your mouse. Just like you see them in audio editing software.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
# 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
|
||||||
@@ -219,13 +219,13 @@ public class DrawingBoard extends JPanel {
|
|||||||
if (mouseDrag != EnumMouseDrag.MOVE)
|
if (mouseDrag != EnumMouseDrag.MOVE)
|
||||||
return;
|
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;
|
float half = data.length / 2f;
|
||||||
int lowerBound = half / zoom - half - centerOff;
|
int lowerBound = (int) Math.ceil(half / zoom - half - centerOff);
|
||||||
int higherBound = data.length - half / zoom - half - centerOff;
|
int higherBound = (int) Math.floor(data.length - half / zoom - half - centerOff);
|
||||||
|
|
||||||
if (newOff < lowerBound) {
|
if (newOff < lowerBound) {
|
||||||
newOff = lowerBound;
|
newOff = lowerBound;
|
||||||
@@ -239,7 +239,7 @@ public class DrawingBoard extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fireZoom(Point pos, int wheel) {
|
private void fireZoom(Point pos, int wheel) {
|
||||||
int width = getWidth();
|
float width = getWidth();
|
||||||
|
|
||||||
int oldZoom = zoom;
|
int oldZoom = zoom;
|
||||||
|
|
||||||
@@ -252,14 +252,13 @@ public class DrawingBoard extends JPanel {
|
|||||||
if (oldZoom == zoom)
|
if (oldZoom == zoom)
|
||||||
return;
|
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;
|
centerOff += wheel < 0 ? pseudoMoveOff : -pseudoMoveOff;
|
||||||
|
|
||||||
int half = data.length / 2;
|
float half = data.length / 2f;
|
||||||
int lowerBound = half / zoom - half - centerOff;
|
int lowerBound = (int) Math.ceil(half / zoom - half - centerOff);
|
||||||
int higherBound = data.length - half / zoom - half - centerOff;
|
int higherBound = (int) Math.floor(data.length - half / zoom - half - centerOff);
|
||||||
|
|
||||||
int newOff = 0;
|
|
||||||
if (lowerBound > 0) {
|
if (lowerBound > 0) {
|
||||||
centerOff += lowerBound;
|
centerOff += lowerBound;
|
||||||
} else if (higherBound < 0) {
|
} else if (higherBound < 0) {
|
||||||
|
|||||||
Reference in new issue
Block a user