add VCA
This commit is contained in:
parent
5647373b8e
commit
7c7a671315
23 changed files with 419 additions and 60 deletions
BIN
proj/block/amplifier_front.ase
Normal file
BIN
proj/block/amplifier_front.ase
Normal file
Binary file not shown.
BIN
proj/block/amplifier_side.ase
Normal file
BIN
proj/block/amplifier_side.ase
Normal file
Binary file not shown.
Binary file not shown.
|
|
@ -1,13 +1,15 @@
|
|||
// 1.19.2 2023-05-01T21:31:37.661214642 Models
|
||||
// 1.19.2 2023-05-02T12:20:58.184760864 Models
|
||||
0812a674d14cfc6fbb7c0e2ac1b473bf2afe1965 assets/dawd3/models/item/brown_patch_cable.json
|
||||
6e01a1aa07f3a36d7950a1b00d1bc6e9045b9995 assets/dawd3/blockstates/knob.json
|
||||
bf0e322e33123cb6873c2da4e8c6ab85688deb4e assets/dawd3/models/item/gray_patch_cable.json
|
||||
215b221d48639e96de11914625a770a389d65b81 assets/dawd3/models/item/green_patch_cable.json
|
||||
6a9fb209d82556f5941422a8d047a0ae2af1dc8f assets/dawd3/models/item/sine_oscillator.json
|
||||
5919f5e0f79620a682f481a8e02995f95724b2ce assets/dawd3/models/block/amplifier.json
|
||||
8ba890b28c5ac57c59f19ccc8c72825caac10677 assets/dawd3/models/item/magenta_patch_cable.json
|
||||
e34001d3c974aecfa347d435beb6bc0b9d325897 assets/dawd3/models/item/cyan_patch_cable.json
|
||||
c3ea3e310d8fe7796b5b055d34db712cb8c7ac5a assets/dawd3/blockstates/triangle_oscillator.json
|
||||
f7b47538f17992177e97e06842c0039ae5096b2b assets/dawd3/blockstates/speaker.json
|
||||
97f0b7f5e19cd8c92915c4dfdedcee0e0b2a4b7f assets/dawd3/models/item/amplifier.json
|
||||
9cf2cff42345ec60a944d7399b5047323aa8e88c assets/dawd3/models/item/red_patch_cable.json
|
||||
0fb5cd695c2a82a2353809529dc8b5086ee2c87d assets/dawd3/blockstates/phase.json
|
||||
8c6f0307320980a66c70622b0b7c72c8cfe78dc3 assets/dawd3/models/item/light_gray_patch_cable.json
|
||||
|
|
@ -17,10 +19,10 @@ a4e8bc89d39021eb8d56ad7735216cb851d67287 assets/dawd3/models/item/light_blue_pat
|
|||
8c4b8147bfea2bdb8c1d348bc332a60d2cd82d68 assets/dawd3/models/item/phase.json
|
||||
aa1a1807d2c46f1f25e3d0c507952fefb5b3cd9f assets/dawd3/models/item/knob.json
|
||||
d65fd7b21da2adf55a0b076103103da7e7bb453a assets/dawd3/models/block/speaker.json
|
||||
df1b924ee7f1a4f9a6496f52a27d74b449ef05fc assets/dawd3/models/block/triangle_oscillator.json
|
||||
fe4987cffd1253462cc8440c90ff2341ac3026a4 assets/dawd3/models/block/triangle_oscillator.json
|
||||
becb814a10bcf2d3e071a6479e9b2289165d0059 assets/dawd3/models/item/modulator.json
|
||||
8aa966337109315240614d5257eb72f959eba5d8 assets/dawd3/models/item/orange_patch_cable.json
|
||||
46e362f3f96c54438c29132f76441e6cddb94564 assets/dawd3/models/block/pulse_oscillator.json
|
||||
4748361fec856c3fe328ac0036ee642a5865fa99 assets/dawd3/models/block/pulse_oscillator.json
|
||||
12c4bfd825b2476955afcd3bb23c1f736ce68caa assets/dawd3/models/item/yellow_patch_cable.json
|
||||
aab1bce7ec4e7c7dccd3d33d4242de12b63a981d assets/dawd3/models/item/white_patch_cable.json
|
||||
6cdda36e539e23acf3db70d761338e88932a6ebb assets/dawd3/models/item/purple_patch_cable.json
|
||||
|
|
@ -28,6 +30,7 @@ e3c6aacd49a6395f37047d3df31f91a18a411267 assets/dawd3/models/item/speaker.json
|
|||
f69a4acfdf715c64f64830ce0a79aa452ad4760a assets/dawd3/models/item/saw_oscillator.json
|
||||
851149820d465dc203cc75e8808a5387e8eb5426 assets/dawd3/models/block/modulator.json
|
||||
32bb0e6e3bf75b9005602e8fb1042ad5d41286ad assets/dawd3/models/item/lime_patch_cable.json
|
||||
b5cc6f4b4af952380a1539489f2e406bc6ebe5fa assets/dawd3/blockstates/amplifier.json
|
||||
1358574aaed0a49a6a4fdaba4ceb330463dcc421 assets/dawd3/models/block/phase.json
|
||||
292685c025f28911bca9252da3e4ac72998b3c7a assets/dawd3/blockstates/pulse_oscillator.json
|
||||
956d8f117df95cf62c8cac375cff853df96840d6 assets/dawd3/models/item/pink_patch_cable.json
|
||||
|
|
|
|||
19
src/main/generated/assets/dawd3/blockstates/amplifier.json
Normal file
19
src/main/generated/assets/dawd3/blockstates/amplifier.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"variants": {
|
||||
"facing=east": {
|
||||
"model": "dawd3:block/amplifier",
|
||||
"y": 90
|
||||
},
|
||||
"facing=north": {
|
||||
"model": "dawd3:block/amplifier"
|
||||
},
|
||||
"facing=south": {
|
||||
"model": "dawd3:block/amplifier",
|
||||
"y": 180
|
||||
},
|
||||
"facing=west": {
|
||||
"model": "dawd3:block/amplifier",
|
||||
"y": 270
|
||||
}
|
||||
}
|
||||
}
|
||||
126
src/main/generated/assets/dawd3/models/block/amplifier.json
Normal file
126
src/main/generated/assets/dawd3/models/block/amplifier.json
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
{
|
||||
"parent": "block/block",
|
||||
"elements": [
|
||||
{
|
||||
"faces": {
|
||||
"down": {
|
||||
"cullface": "down",
|
||||
"texture": "#bottom"
|
||||
},
|
||||
"east": {
|
||||
"cullface": "east",
|
||||
"texture": "#right"
|
||||
},
|
||||
"north": {
|
||||
"cullface": "north",
|
||||
"texture": "#front"
|
||||
},
|
||||
"south": {
|
||||
"cullface": "south",
|
||||
"texture": "#back"
|
||||
},
|
||||
"up": {
|
||||
"cullface": "up",
|
||||
"rotation": 180,
|
||||
"texture": "#top"
|
||||
},
|
||||
"west": {
|
||||
"cullface": "west",
|
||||
"texture": "#left"
|
||||
}
|
||||
},
|
||||
"from": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"to": [
|
||||
16.0,
|
||||
16.0,
|
||||
16.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"faces": {
|
||||
"north": {
|
||||
"cullface": "north",
|
||||
"texture": "#port",
|
||||
"uv": [
|
||||
4.0,
|
||||
0.0,
|
||||
8.0,
|
||||
4.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"from": [
|
||||
3.0,
|
||||
3.0,
|
||||
-0.01
|
||||
],
|
||||
"to": [
|
||||
7.0,
|
||||
7.0,
|
||||
0.01
|
||||
]
|
||||
},
|
||||
{
|
||||
"faces": {
|
||||
"north": {
|
||||
"cullface": "north",
|
||||
"texture": "#port",
|
||||
"uv": [
|
||||
0.0,
|
||||
0.0,
|
||||
4.0,
|
||||
4.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"from": [
|
||||
6.0,
|
||||
9.0,
|
||||
-0.01
|
||||
],
|
||||
"to": [
|
||||
10.0,
|
||||
13.0,
|
||||
0.01
|
||||
]
|
||||
},
|
||||
{
|
||||
"faces": {
|
||||
"north": {
|
||||
"cullface": "north",
|
||||
"texture": "#port",
|
||||
"uv": [
|
||||
0.0,
|
||||
0.0,
|
||||
4.0,
|
||||
4.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"from": [
|
||||
9.0,
|
||||
3.0,
|
||||
-0.01
|
||||
],
|
||||
"to": [
|
||||
13.0,
|
||||
7.0,
|
||||
0.01
|
||||
]
|
||||
}
|
||||
],
|
||||
"textures": {
|
||||
"back": "dawd3:block/amplifier_side",
|
||||
"bottom": "dawd3:block/amplifier_side",
|
||||
"front": "dawd3:block/amplifier_front",
|
||||
"left": "dawd3:block/amplifier_side",
|
||||
"particle": "dawd3:block/amplifier_side",
|
||||
"port": "dawd3:device/port",
|
||||
"right": "dawd3:block/amplifier_side",
|
||||
"top": "dawd3:block/amplifier_side"
|
||||
}
|
||||
}
|
||||
|
|
@ -40,30 +40,6 @@
|
|||
16.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"faces": {
|
||||
"north": {
|
||||
"cullface": "north",
|
||||
"texture": "#port",
|
||||
"uv": [
|
||||
0.0,
|
||||
0.0,
|
||||
4.0,
|
||||
4.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"from": [
|
||||
9.0,
|
||||
3.0,
|
||||
-0.01
|
||||
],
|
||||
"to": [
|
||||
13.0,
|
||||
7.0,
|
||||
0.01
|
||||
]
|
||||
},
|
||||
{
|
||||
"faces": {
|
||||
"north": {
|
||||
|
|
@ -87,6 +63,30 @@
|
|||
7.0,
|
||||
0.01
|
||||
]
|
||||
},
|
||||
{
|
||||
"faces": {
|
||||
"north": {
|
||||
"cullface": "north",
|
||||
"texture": "#port",
|
||||
"uv": [
|
||||
0.0,
|
||||
0.0,
|
||||
4.0,
|
||||
4.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"from": [
|
||||
9.0,
|
||||
3.0,
|
||||
-0.01
|
||||
],
|
||||
"to": [
|
||||
13.0,
|
||||
7.0,
|
||||
0.01
|
||||
]
|
||||
}
|
||||
],
|
||||
"textures": {
|
||||
|
|
|
|||
|
|
@ -40,30 +40,6 @@
|
|||
16.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"faces": {
|
||||
"north": {
|
||||
"cullface": "north",
|
||||
"texture": "#port",
|
||||
"uv": [
|
||||
4.0,
|
||||
0.0,
|
||||
8.0,
|
||||
4.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"from": [
|
||||
3.0,
|
||||
6.0,
|
||||
-0.01
|
||||
],
|
||||
"to": [
|
||||
7.0,
|
||||
10.0,
|
||||
0.01
|
||||
]
|
||||
},
|
||||
{
|
||||
"faces": {
|
||||
"north": {
|
||||
|
|
@ -87,6 +63,30 @@
|
|||
10.0,
|
||||
0.01
|
||||
]
|
||||
},
|
||||
{
|
||||
"faces": {
|
||||
"north": {
|
||||
"cullface": "north",
|
||||
"texture": "#port",
|
||||
"uv": [
|
||||
4.0,
|
||||
0.0,
|
||||
8.0,
|
||||
4.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"from": [
|
||||
3.0,
|
||||
6.0,
|
||||
-0.01
|
||||
],
|
||||
"to": [
|
||||
7.0,
|
||||
10.0,
|
||||
0.01
|
||||
]
|
||||
}
|
||||
],
|
||||
"textures": {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "dawd3:block/amplifier"
|
||||
}
|
||||
25
src/main/java/net/liquidev/dawd3/events/DebugHudEvents.java
Normal file
25
src/main/java/net/liquidev/dawd3/events/DebugHudEvents.java
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package net.liquidev.dawd3.events;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class DebugHudEvents {
|
||||
public static Event<AddDebugInfo> ADD_DEBUG_INFO = EventFactory.createArrayBacked(
|
||||
AddDebugInfo.class,
|
||||
context -> {},
|
||||
callbacks -> paused -> {
|
||||
for (AddDebugInfo callback : callbacks) {
|
||||
callback.addDebugInfo(paused);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public interface AddDebugInfo {
|
||||
void addDebugInfo(List<String> debugInfo);
|
||||
}
|
||||
}
|
||||
18
src/main/java/net/liquidev/dawd3/mixin/DebugHudMixin.java
Normal file
18
src/main/java/net/liquidev/dawd3/mixin/DebugHudMixin.java
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package net.liquidev.dawd3.mixin;
|
||||
|
||||
import net.liquidev.dawd3.events.DebugHudEvents;
|
||||
import net.minecraft.client.gui.hud.DebugHud;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(DebugHud.class)
|
||||
public class DebugHudMixin {
|
||||
@Inject(at = @At("RETURN"), method = "getLeftText")
|
||||
private void getLeftText(CallbackInfoReturnable<List<String>> info) {
|
||||
DebugHudEvents.ADD_DEBUG_INFO.invoker().addDebugInfo(info.getReturnValue());
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import net.liquidev.dawd3.audio.generator.MixGenerator
|
|||
import net.liquidev.dawd3.audio.generator.PausableGenerator
|
||||
import net.liquidev.dawd3.audio.unit.Frequency
|
||||
import net.liquidev.dawd3.events.D3ClientEvents
|
||||
import net.liquidev.dawd3.events.DebugHudEvents
|
||||
|
||||
/** Audio system and common settings. */
|
||||
object Audio {
|
||||
|
|
@ -41,6 +42,10 @@ object Audio {
|
|||
D3ClientEvents.PAUSE.register { isPaused ->
|
||||
pauseAdapter.playing = !isPaused
|
||||
}
|
||||
|
||||
DebugHudEvents.ADD_DEBUG_INFO.register { debugHud ->
|
||||
mixer.appendDebugInfo(debugHud)
|
||||
}
|
||||
}
|
||||
|
||||
fun deinitialize() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
package net.liquidev.dawd3.audio.devices.math
|
||||
|
||||
import net.liquidev.dawd3.Mod
|
||||
import net.liquidev.dawd3.audio.device.*
|
||||
import net.liquidev.dawd3.common.lerp
|
||||
import net.minecraft.util.Identifier
|
||||
|
||||
class AmplifierDevice : Device<AmplifierDevice.Controls> {
|
||||
companion object : DeviceDescriptor {
|
||||
override val id = Identifier(Mod.id, "amplifier")
|
||||
|
||||
val amplitudeControl = ControlDescriptor(id, "amplitude", 1f)
|
||||
val amplitudeCVControl = ControlDescriptor(id, "amplitude_cv", 0f)
|
||||
|
||||
val amplitudeCVPort = InputPortName(id, "amplitude_cv")
|
||||
val inputPort = InputPortName(id, "input")
|
||||
val outputPort = OutputPortName(id, "output")
|
||||
}
|
||||
|
||||
class Controls : ControlSet {
|
||||
val amplitude = Control(amplitudeControl)
|
||||
val amplitudeCV = Control(amplitudeCVControl)
|
||||
|
||||
override fun visitControls(visit: (ControlDescriptor, Control) -> Unit) {
|
||||
visit(amplitudeControl, amplitude)
|
||||
visit(amplitudeCVControl, amplitudeCV)
|
||||
}
|
||||
}
|
||||
|
||||
val amplitudeCV = InputPort()
|
||||
val input = InputPort()
|
||||
val output = OutputPort(bufferCount = 1)
|
||||
|
||||
override fun process(sampleCount: Int, controls: Controls) {
|
||||
val constantAmplitude = controls.amplitude.value
|
||||
val amplitudeCVAmount = controls.amplitudeCV.value
|
||||
|
||||
val amplitudeCVBuffer = amplitudeCV.getConnectedOutputBuffer(0, sampleCount)
|
||||
val inputBuffer = input.getConnectedOutputBuffer(0, sampleCount)
|
||||
val outputBuffer = output.buffers[0].getOrReallocate(sampleCount)
|
||||
|
||||
for (i in 0 until sampleCount) {
|
||||
val cvAmplitude = lerp(1f, amplitudeCVBuffer[i], amplitudeCVAmount)
|
||||
outputBuffer[i] = inputBuffer[i] * constantAmplitude * cvAmplitude
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitInputPorts(visit: (InputPortName, InputPort) -> Unit) {
|
||||
visit(amplitudeCVPort, amplitudeCV)
|
||||
visit(inputPort, input)
|
||||
}
|
||||
|
||||
override fun visitOutputPorts(visit: (OutputPortName, OutputPort) -> Unit) {
|
||||
visit(outputPort, output)
|
||||
}
|
||||
}
|
||||
|
|
@ -4,20 +4,29 @@ import net.liquidev.dawd3.audio.Audio
|
|||
import net.liquidev.dawd3.audio.device.DeviceInstance
|
||||
import net.liquidev.dawd3.audio.device.NoControls
|
||||
import net.liquidev.dawd3.audio.devices.TerminalDevice
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
import kotlin.system.measureNanoTime
|
||||
|
||||
/** Audio generator that evaluates a device graph. */
|
||||
class DeviceGraphGenerator : AudioGenerator() {
|
||||
private val terminalDeviceState = TerminalDevice()
|
||||
val terminalDevice = DeviceInstance.create(terminalDeviceState, NoControls)
|
||||
|
||||
private val internalProfileResult = AtomicLong(0)
|
||||
val profileResult: Long
|
||||
get() = internalProfileResult.get()
|
||||
|
||||
override fun generate(output: FloatArray, sampleCount: Int, channelCount: Int) {
|
||||
// TODO: Maybe passing in the static processingState here is not the cleanest way to go
|
||||
// about things, but I don't see how we could inject that context into this function
|
||||
// without jumping through significant hoops.
|
||||
terminalDevice.process(sampleCount, channelCount, Audio.processingState)
|
||||
val buffer = terminalDeviceState.input.getConnectedOutputBuffer(0, sampleCount)
|
||||
for (i in 0 until sampleCount) {
|
||||
output[i] = buffer[i]
|
||||
val elapsed = measureNanoTime {
|
||||
// TODO: Maybe passing in the static processingState here is not the cleanest way to go
|
||||
// about things, but I don't see how we could inject that context into this function
|
||||
// without jumping through significant hoops.
|
||||
terminalDevice.process(sampleCount, channelCount, Audio.processingState)
|
||||
val buffer = terminalDeviceState.input.getConnectedOutputBuffer(0, sampleCount)
|
||||
for (i in 0 until sampleCount) {
|
||||
output[i] = buffer[i]
|
||||
}
|
||||
}
|
||||
internalProfileResult.set(elapsed)
|
||||
}
|
||||
}
|
||||
|
|
@ -60,6 +60,16 @@ class MixGenerator : AudioGenerator() {
|
|||
}
|
||||
}
|
||||
|
||||
fun appendDebugInfo(outDebugInfo: MutableList<String>) {
|
||||
outDebugInfo.add("[d³] MixGenerator device graph profile:")
|
||||
channels.mapNotNull { it.get() }.forEachIndexed { index, channel ->
|
||||
val generator = channel.generator
|
||||
if (generator is DeviceGraphGenerator) {
|
||||
outDebugInfo.add("[d³] - DeviceGraph #$index: ${generator.profileResult} ns")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Channel<out T : AudioGenerator>(
|
||||
private val taskQueue: TaskQueue<Unit, Unit>,
|
||||
val generator: T,
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import net.liquidev.dawd3.block.device.DeviceBlock
|
|||
import net.liquidev.dawd3.block.device.DeviceBlockEntity
|
||||
import net.liquidev.dawd3.block.device.DeviceBlockEntityRenderer
|
||||
import net.liquidev.dawd3.block.devices.SpeakerBlockDescriptor
|
||||
import net.liquidev.dawd3.block.devices.math.AmplifierBlockDescriptor
|
||||
import net.liquidev.dawd3.block.devices.math.KnobBlockDescriptor
|
||||
import net.liquidev.dawd3.block.devices.math.ModulatorBlockDescriptor
|
||||
import net.liquidev.dawd3.block.devices.oscillator.*
|
||||
|
|
@ -63,6 +64,7 @@ object Blocks {
|
|||
val speaker = registerDeviceBlock(SpeakerBlockDescriptor)
|
||||
|
||||
val knob = registerDeviceBlock(KnobBlockDescriptor)
|
||||
val amplifier = registerDeviceBlock(AmplifierBlockDescriptor)
|
||||
val modulator = registerDeviceBlock(ModulatorBlockDescriptor)
|
||||
|
||||
val phase = registerDeviceBlock(PhaseBlockDescriptor)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,76 @@
|
|||
package net.liquidev.dawd3.block.devices.math
|
||||
|
||||
import net.liquidev.dawd3.Mod
|
||||
import net.liquidev.dawd3.audio.device.DeviceInstance
|
||||
import net.liquidev.dawd3.audio.devices.math.AmplifierDevice
|
||||
import net.liquidev.dawd3.block.device.DeviceBlockDescriptor
|
||||
import net.liquidev.dawd3.block.device.PhysicalPort
|
||||
import net.liquidev.dawd3.ui.widget.Knob
|
||||
import net.liquidev.dawd3.ui.widget.Widget
|
||||
import net.liquidev.dawd3.ui.widget.Window
|
||||
import net.minecraft.client.world.ClientWorld
|
||||
import net.minecraft.text.Text
|
||||
import net.minecraft.util.Identifier
|
||||
import net.minecraft.util.math.Vec2f
|
||||
|
||||
object AmplifierBlockDescriptor : DeviceBlockDescriptor<AmplifierBlockDescriptor.ClientState, AmplifierDevice.Controls> {
|
||||
override val id = Identifier(Mod.id, "amplifier")
|
||||
override val portLayout = PhysicalPort.layout {
|
||||
port(
|
||||
AmplifierDevice.amplitudeCVPort,
|
||||
position = Vec2f(0.5f, 0.25f),
|
||||
PhysicalPort.Side.Front
|
||||
)
|
||||
port(
|
||||
AmplifierDevice.inputPort,
|
||||
position = Vec2f(0.25f, 0.75f),
|
||||
PhysicalPort.Side.Front
|
||||
)
|
||||
port(
|
||||
AmplifierDevice.outputPort,
|
||||
position = Vec2f(0.75f, 0.75f),
|
||||
PhysicalPort.Side.Front
|
||||
)
|
||||
}
|
||||
|
||||
class ClientState(controls: AmplifierDevice.Controls) : DeviceBlockDescriptor.ClientState {
|
||||
override val logicalDevice = DeviceInstance.create(AmplifierDevice(), controls)
|
||||
}
|
||||
|
||||
override fun initControls() = AmplifierDevice.Controls()
|
||||
|
||||
override fun onClientLoad(controls: AmplifierDevice.Controls, world: ClientWorld) =
|
||||
ClientState(controls)
|
||||
|
||||
override val ui = object : DeviceBlockDescriptor.UI<AmplifierDevice.Controls> {
|
||||
override fun open(controls: AmplifierDevice.Controls, x: Int, y: Int): Widget =
|
||||
Window(
|
||||
x,
|
||||
y,
|
||||
width = 78,
|
||||
height = 48,
|
||||
Text.translatable("block.dawd3.amplifier")
|
||||
).apply {
|
||||
children.add(
|
||||
Knob(
|
||||
x = 14,
|
||||
y = 18,
|
||||
control = controls.amplitude,
|
||||
min = 0f,
|
||||
max = 1f,
|
||||
color = Knob.Color.Red,
|
||||
)
|
||||
)
|
||||
children.add(
|
||||
Knob(
|
||||
x = 42,
|
||||
y = 18,
|
||||
control = controls.amplitudeCV,
|
||||
min = -8f,
|
||||
max = 8f,
|
||||
color = Knob.Color.Blue,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ object ModulatorBlockDescriptor : DeviceBlockDescriptor<ModulatorBlockDescriptor
|
|||
|
||||
override val ui = object : DeviceBlockDescriptor.UI<FmaDevice.Controls> {
|
||||
override fun open(controls: FmaDevice.Controls, x: Int, y: Int): Widget =
|
||||
Window(x, y, 74, 48, Text.translatable("block.dawd3.modulator")).apply {
|
||||
Window(x, y, 78, 48, Text.translatable("block.dawd3.modulator")).apply {
|
||||
children.add(
|
||||
Knob(
|
||||
x = 14,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ class Knob(
|
|||
val min: Float,
|
||||
val max: Float,
|
||||
val color: Color,
|
||||
val sensitivity: Float = 0.25f,
|
||||
// Pick a default sensitivity such that for pitch ranges we move by steps of 0.25.
|
||||
val sensitivity: Float = (max - min) * 0.25f / 96f,
|
||||
) : Widget(x, y) {
|
||||
override val width = 20
|
||||
override val height = 20
|
||||
|
|
|
|||
|
|
@ -16,9 +16,14 @@
|
|||
"item.dawd3.green_patch_cable": "Green Patch Cable",
|
||||
"item.dawd3.red_patch_cable": "Red Patch Cable",
|
||||
"item.dawd3.black_patch_cable": "Black Patch Cable",
|
||||
"block.dawd3.amplifier": "Amplifier",
|
||||
"block.dawd3.knob": "Knob",
|
||||
"block.dawd3.modulator": "Modulator",
|
||||
"block.dawd3.phase": "Phase",
|
||||
"block.dawd3.pulse_oscillator": "Pulse Oscillator",
|
||||
"block.dawd3.speaker": "Speaker",
|
||||
"block.dawd3.saw_oscillator": "Saw Oscillator",
|
||||
"block.dawd3.sine_oscillator": "Sine Oscillator",
|
||||
"block.dawd3.triangle_oscillator": "Triangle Oscillator",
|
||||
"screen.dawd3.rack.title": "Rack"
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 318 B |
Binary file not shown.
|
After Width: | Height: | Size: 265 B |
|
|
@ -6,6 +6,7 @@
|
|||
"defaultRequire": 1
|
||||
},
|
||||
"mixins": [
|
||||
"DebugHudMixin",
|
||||
"PauseMixin",
|
||||
"PlayerItemSwitchMixin"
|
||||
]
|
||||
|
|
|
|||
Reference in a new issue