kopia lustrzana https://github.com/jameshball/osci-render
Add bulge effect
rodzic
0d087316fc
commit
dd5f498409
|
@ -0,0 +1,24 @@
|
|||
package sh.ball.audio.effect;
|
||||
|
||||
import sh.ball.shapes.Vector2;
|
||||
|
||||
public class BulgeEffect implements SettableEffect {
|
||||
|
||||
private double bulge = 0.1;
|
||||
|
||||
@Override
|
||||
public Vector2 apply(int count, Vector2 vector) {
|
||||
double translatedBulge = -bulge + 1;
|
||||
|
||||
double r = vector.magnitude();
|
||||
double theta = Math.atan2(vector.y, vector.x);
|
||||
double rn = Math.pow(r, translatedBulge);
|
||||
|
||||
return new Vector2(rn * Math.cos(theta), rn * Math.sin(theta));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(double value) {
|
||||
this.bulge = value;
|
||||
}
|
||||
}
|
|
@ -31,7 +31,8 @@ public enum EffectType {
|
|||
LUA_D(-1),
|
||||
LUA_E(-1),
|
||||
DELAY_DECAY(101),
|
||||
DELAY_ECHO_LENGTH(-1),;
|
||||
DELAY_ECHO_LENGTH(-1),
|
||||
BULGE(53);
|
||||
|
||||
public final int precedence;
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import sh.ball.parser.lua.LuaExecutor;
|
|||
import sh.ball.shapes.Shape;
|
||||
import sh.ball.shapes.Vector2;
|
||||
|
||||
import java.awt.*;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
@ -94,6 +93,8 @@ public class EffectsController implements Initializable, SubController {
|
|||
@FXML
|
||||
private EffectComponentGroup delayDecay;
|
||||
@FXML
|
||||
private EffectComponentGroup bulge;
|
||||
@FXML
|
||||
private TextField translationXTextField;
|
||||
@FXML
|
||||
private TextField translationYTextField;
|
||||
|
@ -204,6 +205,7 @@ public class EffectsController implements Initializable, SubController {
|
|||
backingMidi.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new ConsumerEffect(audioPlayer::setBackingMidiVolume)));
|
||||
delayDecay.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, delayEffect));
|
||||
delayEchoLength.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new ConsumerEffect((value) -> delayEffect.setEchoLength(value))));
|
||||
bulge.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new BulgeEffect()));
|
||||
|
||||
effects().forEach(effect -> {
|
||||
effect.setEffectUpdater(this::updateEffect);
|
||||
|
@ -298,7 +300,8 @@ public class EffectsController implements Initializable, SubController {
|
|||
rotateSpeed,
|
||||
backingMidi,
|
||||
delayDecay,
|
||||
delayEchoLength
|
||||
delayEchoLength,
|
||||
bulge
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -113,4 +113,8 @@ public final class Vector2 extends Shape {
|
|||
", y=" + y +
|
||||
'}';
|
||||
}
|
||||
|
||||
public double magnitude() {
|
||||
return Math.sqrt(x * x + y * y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<?import javafx.scene.shape.SVGPath?>
|
||||
<?import sh.ball.gui.components.EffectComponentGroup?>
|
||||
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" prefHeight="1168.0" prefWidth="605.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sh.ball.gui.controller.EffectsController">
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" prefHeight="1214.0" prefWidth="605.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sh.ball.gui.controller.EffectsController">
|
||||
<content>
|
||||
<FlowPane prefHeight="1094.0" prefWidth="605.0" prefWrapLength="100.0" rowValignment="BASELINE">
|
||||
<children>
|
||||
|
@ -135,11 +135,12 @@
|
|||
</AnchorPane>
|
||||
<EffectComponentGroup fx:id="traceMax" increment="0.005" label="traceMax" majorTickUnit="0.1" max="1.0" min="0.0" name="Trace max" type="TRACE_MAX" value="0.5" />
|
||||
<EffectComponentGroup fx:id="traceMin" increment="0.005" label="traceMin" majorTickUnit="0.1" max="1.0" min="0.0" name="Trace min" type="TRACE_MIN" value="0.5" />
|
||||
<EffectComponentGroup fx:id="bulge" increment="0.005" label="bulge" majorTickUnit="0.1" max="1.0" min="0.0" name="Bulge" type="BULGE" value="0.1" />
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox>
|
||||
<children>
|
||||
<Label alignment="CENTER" prefWidth="601.0" text="Output" textAlignment="JUSTIFY">
|
||||
<Label alignment="CENTER" prefWidth="601.0" text="Delay" textAlignment="JUSTIFY">
|
||||
<padding>
|
||||
<Insets bottom="5.0" />
|
||||
</padding>
|
||||
|
|
Ładowanie…
Reference in New Issue