saw oscillator
also adding a bunch files that are missing LOL
BIN
proj/block/knob_front.ase
Normal file
BIN
proj/block/knob_side.ase
Normal file
BIN
proj/block/phase_front.ase
Normal file
BIN
proj/block/phase_side.ase
Normal file
BIN
proj/block/saw_oscillator_front.ase
Normal file
BIN
proj/block/saw_oscillator_side.ase
Normal file
BIN
proj/block/template/controller_device_side.ase
Normal file
BIN
proj/block/template/controller_device_side.png
Normal file
|
After Width: | Height: | Size: 185 B |
BIN
proj/screen/rack.ase
Normal file
|
|
@ -1,18 +1,19 @@
|
|||
// 1.19.2 2023-05-01T14:06:55.653907421 Models
|
||||
// 1.19.2 2023-05-01T17:37:15.245979043 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
|
||||
6a9fb209d82556f5941422a8d047a0ae2af1dc8f assets/dawd3/models/item/sine_oscillator.json
|
||||
215b221d48639e96de11914625a770a389d65b81 assets/dawd3/models/item/green_patch_cable.json
|
||||
e34001d3c974aecfa347d435beb6bc0b9d325897 assets/dawd3/models/item/cyan_patch_cable.json
|
||||
6a9fb209d82556f5941422a8d047a0ae2af1dc8f assets/dawd3/models/item/sine_oscillator.json
|
||||
8ba890b28c5ac57c59f19ccc8c72825caac10677 assets/dawd3/models/item/magenta_patch_cable.json
|
||||
e34001d3c974aecfa347d435beb6bc0b9d325897 assets/dawd3/models/item/cyan_patch_cable.json
|
||||
f7b47538f17992177e97e06842c0039ae5096b2b assets/dawd3/blockstates/speaker.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
|
||||
5ed33e9ec3c70e8cc027eea6425951d51487437f assets/dawd3/models/item/blue_patch_cable.json
|
||||
8c4b8147bfea2bdb8c1d348bc332a60d2cd82d68 assets/dawd3/models/item/phase.json
|
||||
0d899dc2bd693c95d582231a00faf40bf1d67a47 assets/dawd3/blockstates/saw_oscillator.json
|
||||
a4e8bc89d39021eb8d56ad7735216cb851d67287 assets/dawd3/models/item/light_blue_patch_cable.json
|
||||
8c4b8147bfea2bdb8c1d348bc332a60d2cd82d68 assets/dawd3/models/item/phase.json
|
||||
aa1a1807d2c46f1f25e3d0c507952fefb5b3cd9f assets/dawd3/models/item/knob.json
|
||||
d65fd7b21da2adf55a0b076103103da7e7bb453a assets/dawd3/models/block/speaker.json
|
||||
8aa966337109315240614d5257eb72f959eba5d8 assets/dawd3/models/item/orange_patch_cable.json
|
||||
|
|
@ -20,10 +21,12 @@ d65fd7b21da2adf55a0b076103103da7e7bb453a assets/dawd3/models/block/speaker.json
|
|||
aab1bce7ec4e7c7dccd3d33d4242de12b63a981d assets/dawd3/models/item/white_patch_cable.json
|
||||
6cdda36e539e23acf3db70d761338e88932a6ebb assets/dawd3/models/item/purple_patch_cable.json
|
||||
e3c6aacd49a6395f37047d3df31f91a18a411267 assets/dawd3/models/item/speaker.json
|
||||
f69a4acfdf715c64f64830ce0a79aa452ad4760a assets/dawd3/models/item/saw_oscillator.json
|
||||
32bb0e6e3bf75b9005602e8fb1042ad5d41286ad assets/dawd3/models/item/lime_patch_cable.json
|
||||
c5998d4ae85e7a16010e66b4b165ddd6b7f0f3ac assets/dawd3/models/block/phase.json
|
||||
1358574aaed0a49a6a4fdaba4ceb330463dcc421 assets/dawd3/models/block/phase.json
|
||||
956d8f117df95cf62c8cac375cff853df96840d6 assets/dawd3/models/item/pink_patch_cable.json
|
||||
3b1811bab3ba394ba03b67ac2efc72cb35316dc8 assets/dawd3/blockstates/sine_oscillator.json
|
||||
9c18a8292a0c9990cd23bebf5c6191c2114ccc6d assets/dawd3/models/item/black_patch_cable.json
|
||||
8688de3eadb6579cac89522683c394f18733e614 assets/dawd3/models/block/knob.json
|
||||
0afd7ba8d87444961a33cb87bba122fca5ebef8e assets/dawd3/models/block/saw_oscillator.json
|
||||
50023b9cff64844a4001e3e78d3f0ac828f2724a assets/dawd3/models/block/sine_oscillator.json
|
||||
|
|
|
|||
19
src/main/generated/assets/dawd3/blockstates/knob.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"variants": {
|
||||
"facing=east": {
|
||||
"model": "dawd3:block/knob",
|
||||
"y": 90
|
||||
},
|
||||
"facing=north": {
|
||||
"model": "dawd3:block/knob"
|
||||
},
|
||||
"facing=south": {
|
||||
"model": "dawd3:block/knob",
|
||||
"y": 180
|
||||
},
|
||||
"facing=west": {
|
||||
"model": "dawd3:block/knob",
|
||||
"y": 270
|
||||
}
|
||||
}
|
||||
}
|
||||
19
src/main/generated/assets/dawd3/blockstates/phase.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"variants": {
|
||||
"facing=east": {
|
||||
"model": "dawd3:block/phase",
|
||||
"y": 90
|
||||
},
|
||||
"facing=north": {
|
||||
"model": "dawd3:block/phase"
|
||||
},
|
||||
"facing=south": {
|
||||
"model": "dawd3:block/phase",
|
||||
"y": 180
|
||||
},
|
||||
"facing=west": {
|
||||
"model": "dawd3:block/phase",
|
||||
"y": 270
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"variants": {
|
||||
"facing=east": {
|
||||
"model": "dawd3:block/saw_oscillator",
|
||||
"y": 90
|
||||
},
|
||||
"facing=north": {
|
||||
"model": "dawd3:block/saw_oscillator"
|
||||
},
|
||||
"facing=south": {
|
||||
"model": "dawd3:block/saw_oscillator",
|
||||
"y": 180
|
||||
},
|
||||
"facing=west": {
|
||||
"model": "dawd3:block/saw_oscillator",
|
||||
"y": 270
|
||||
}
|
||||
}
|
||||
}
|
||||
78
src/main/generated/assets/dawd3/models/block/knob.json
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
{
|
||||
"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": [
|
||||
6.0,
|
||||
2.25,
|
||||
-0.01
|
||||
],
|
||||
"to": [
|
||||
10.0,
|
||||
6.25,
|
||||
0.01
|
||||
]
|
||||
}
|
||||
],
|
||||
"textures": {
|
||||
"back": "dawd3:block/knob_side",
|
||||
"bottom": "dawd3:block/knob_side",
|
||||
"front": "dawd3:block/knob_front",
|
||||
"left": "dawd3:block/knob_side",
|
||||
"particle": "dawd3:block/knob_side",
|
||||
"port": "dawd3:device/port",
|
||||
"right": "dawd3:block/knob_side",
|
||||
"top": "dawd3:block/knob_side"
|
||||
}
|
||||
}
|
||||
102
src/main/generated/assets/dawd3/models/block/phase.json
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
{
|
||||
"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,
|
||||
6.0,
|
||||
-0.01
|
||||
],
|
||||
"to": [
|
||||
7.0,
|
||||
10.0,
|
||||
0.01
|
||||
]
|
||||
},
|
||||
{
|
||||
"faces": {
|
||||
"north": {
|
||||
"cullface": "north",
|
||||
"texture": "#port",
|
||||
"uv": [
|
||||
0.0,
|
||||
0.0,
|
||||
4.0,
|
||||
4.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"from": [
|
||||
9.0,
|
||||
6.0,
|
||||
-0.01
|
||||
],
|
||||
"to": [
|
||||
13.0,
|
||||
10.0,
|
||||
0.01
|
||||
]
|
||||
}
|
||||
],
|
||||
"textures": {
|
||||
"back": "dawd3:block/phase_side",
|
||||
"bottom": "dawd3:block/phase_side",
|
||||
"front": "dawd3:block/phase_front",
|
||||
"left": "dawd3:block/phase_side",
|
||||
"particle": "dawd3:block/phase_side",
|
||||
"port": "dawd3:device/port",
|
||||
"right": "dawd3:block/phase_side",
|
||||
"top": "dawd3:block/phase_side"
|
||||
}
|
||||
}
|
||||
102
src/main/generated/assets/dawd3/models/block/saw_oscillator.json
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
{
|
||||
"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": [
|
||||
0.0,
|
||||
0.0,
|
||||
4.0,
|
||||
4.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"from": [
|
||||
9.0,
|
||||
6.0,
|
||||
-0.01
|
||||
],
|
||||
"to": [
|
||||
13.0,
|
||||
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": {
|
||||
"back": "dawd3:block/saw_oscillator_side",
|
||||
"bottom": "dawd3:block/saw_oscillator_side",
|
||||
"front": "dawd3:block/saw_oscillator_front",
|
||||
"left": "dawd3:block/saw_oscillator_side",
|
||||
"particle": "dawd3:block/saw_oscillator_side",
|
||||
"port": "dawd3:device/port",
|
||||
"right": "dawd3:block/saw_oscillator_side",
|
||||
"top": "dawd3:block/saw_oscillator_side"
|
||||
}
|
||||
}
|
||||
3
src/main/generated/assets/dawd3/models/item/knob.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "dawd3:block/knob"
|
||||
}
|
||||
3
src/main/generated/assets/dawd3/models/item/phase.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "dawd3:block/phase"
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "dawd3:block/saw_oscillator"
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ package net.liquidev.dawd3.audio.device
|
|||
|
||||
/** Device that can process audio. */
|
||||
interface Device<C : ControlSet> {
|
||||
fun process(sampleCount: Int, channels: Int, controls: C)
|
||||
fun process(sampleCount: Int, controls: C)
|
||||
|
||||
fun visitInputPorts(visit: (InputPortName, InputPort) -> Unit) {}
|
||||
fun visitOutputPorts(visit: (OutputPortName, OutputPort) -> Unit) {}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class DeviceInstance private constructor(val state: Device<ControlSet>, val cont
|
|||
for ((_, port) in inputPortsByName) {
|
||||
port.connectedOutput?.owningDevice?.process(sampleCount, channels, processingState)
|
||||
}
|
||||
state.process(sampleCount, channels, controls)
|
||||
state.process(sampleCount, controls)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class ConstantDevice : Device<ConstantDevice.Controls> {
|
|||
|
||||
val output = OutputPort(bufferCount = 1)
|
||||
|
||||
override fun process(sampleCount: Int, channels: Int, controls: Controls) {
|
||||
override fun process(sampleCount: Int, controls: Controls) {
|
||||
val outputBuffer = output.buffers[0].getOrReallocate(sampleCount)
|
||||
for (i in 0 until sampleCount) {
|
||||
outputBuffer[i] = controls.value.value
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class TerminalDevice : Device<NoControls> {
|
|||
|
||||
val input = InputPort()
|
||||
|
||||
override fun process(sampleCount: Int, channels: Int, controls: NoControls) {
|
||||
override fun process(sampleCount: Int, controls: NoControls) {
|
||||
// Terminals don't do any audio processing.
|
||||
// The output port connected to `input` is instead used by terminal block entities like
|
||||
// speakers.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package net.liquidev.dawd3.audio.devices
|
||||
package net.liquidev.dawd3.audio.devices.oscillator
|
||||
|
||||
import net.liquidev.dawd3.Mod
|
||||
import net.liquidev.dawd3.audio.Audio
|
||||
|
|
@ -20,7 +20,7 @@ class PhaseDevice : Device<NoControls> {
|
|||
private val frequencyBuffer = AudioBuffer()
|
||||
private var phase = 0.0f
|
||||
|
||||
override fun process(sampleCount: Int, channels: Int, controls: NoControls) {
|
||||
override fun process(sampleCount: Int, controls: NoControls) {
|
||||
val voctBuffer = frequencyCV.getConnectedOutputBuffer(0, sampleCount)
|
||||
val frequencyBuffer = frequencyBuffer.getOrReallocate(sampleCount)
|
||||
for (i in 0 until sampleCount) {
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package net.liquidev.dawd3.audio.devices.oscillator
|
||||
|
||||
import net.liquidev.dawd3.Mod
|
||||
import net.liquidev.dawd3.audio.device.*
|
||||
import net.minecraft.util.Identifier
|
||||
import kotlin.math.abs
|
||||
|
||||
class SawOscillatorDevice : Device<NoControls> {
|
||||
companion object : DeviceDescriptor {
|
||||
override val id = Identifier(Mod.id, "saw_oscillator")
|
||||
val phasePort = InputPortName(id, "phase")
|
||||
val outputPort = OutputPortName(id, "output")
|
||||
|
||||
// TODO: Make this into a couple controls and put it into a nice UI
|
||||
const val usePolyBLEP = true
|
||||
const val oversampling = 4
|
||||
}
|
||||
|
||||
|
||||
private val phase = InputPort()
|
||||
private val output = OutputPort(bufferCount = 1)
|
||||
|
||||
private var previousPhase = 0f
|
||||
private var previousDeltaPhase = 0f
|
||||
|
||||
override fun process(sampleCount: Int, controls: NoControls) {
|
||||
val phaseBuffer = phase.getConnectedOutputBuffer(0, sampleCount)
|
||||
|
||||
val outputBuffer = output.buffers[0].getOrReallocate(sampleCount)
|
||||
for (i in 0 until sampleCount) {
|
||||
val phase = phaseBuffer[i]
|
||||
val deltaPhase = phase - previousPhase
|
||||
|
||||
// Smooth out the delta phase at spikes, as then our PolyBLEP dt is no longer accurate.
|
||||
val smoothDeltaPhase = if (abs(deltaPhase) > 0.999) previousDeltaPhase else deltaPhase
|
||||
|
||||
previousPhase = phase
|
||||
previousDeltaPhase = deltaPhase
|
||||
|
||||
var accumulator = 0f
|
||||
for (sample in 0 until oversampling) {
|
||||
val t = sample.toFloat() / oversampling.toFloat()
|
||||
accumulator += saw(
|
||||
phase + smoothDeltaPhase * t,
|
||||
smoothDeltaPhase
|
||||
)
|
||||
}
|
||||
outputBuffer[i] = accumulator / oversampling
|
||||
}
|
||||
}
|
||||
|
||||
private fun saw(t: Float, dt: Float): Float {
|
||||
val naiveSaw = t * 2f - 1f
|
||||
return if (usePolyBLEP) {
|
||||
naiveSaw - polyBLEP(t, dt)
|
||||
} else {
|
||||
naiveSaw
|
||||
}
|
||||
}
|
||||
|
||||
private fun polyBLEP(t: Float, dt: Float) =
|
||||
if (t < dt) {
|
||||
val tt = t / dt
|
||||
tt + tt - tt * tt - 1f
|
||||
} else if (t > 1f - dt) {
|
||||
val tt = (t - 1f) / dt
|
||||
tt * tt + tt + tt + 1f
|
||||
} else {
|
||||
0f
|
||||
}
|
||||
|
||||
override fun visitInputPorts(visit: (InputPortName, InputPort) -> Unit) {
|
||||
visit(phasePort, phase)
|
||||
}
|
||||
|
||||
override fun visitOutputPorts(visit: (OutputPortName, OutputPort) -> Unit) {
|
||||
visit(outputPort, output)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package net.liquidev.dawd3.audio.devices
|
||||
package net.liquidev.dawd3.audio.devices.oscillator
|
||||
|
||||
import net.liquidev.dawd3.Mod
|
||||
import net.liquidev.dawd3.audio.device.*
|
||||
|
|
@ -17,7 +17,7 @@ class SineOscillatorDevice : Device<NoControls> {
|
|||
private val phase = InputPort()
|
||||
private val output = OutputPort(bufferCount = 1)
|
||||
|
||||
override fun process(sampleCount: Int, channels: Int, controls: NoControls) {
|
||||
override fun process(sampleCount: Int, controls: NoControls) {
|
||||
val phase = phase.getConnectedOutputBuffer(0, sampleCount)
|
||||
val outputBuffer = output.buffers[0].getOrReallocate(sampleCount)
|
||||
for (i in 0 until sampleCount) {
|
||||
|
|
@ -10,10 +10,7 @@ import net.liquidev.dawd3.block.device.AnyDeviceBlockDescriptor
|
|||
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.KnobBlockDescriptor
|
||||
import net.liquidev.dawd3.block.devices.PhaseBlockDescriptor
|
||||
import net.liquidev.dawd3.block.devices.SineOscillatorBlockDescriptor
|
||||
import net.liquidev.dawd3.block.devices.SpeakerBlockDescriptor
|
||||
import net.liquidev.dawd3.block.devices.*
|
||||
import net.liquidev.dawd3.item.Items
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.Material
|
||||
|
|
@ -61,9 +58,12 @@ object Blocks {
|
|||
|
||||
// Device blocks
|
||||
val speaker = registerDeviceBlock(SpeakerBlockDescriptor)
|
||||
|
||||
val knob = registerDeviceBlock(KnobBlockDescriptor)
|
||||
|
||||
val phase = registerDeviceBlock(PhaseBlockDescriptor)
|
||||
val sineOscillator = registerDeviceBlock(SineOscillatorBlockDescriptor)
|
||||
val sawOscillator = registerDeviceBlock(SawOscillatorBlockDescriptor)
|
||||
|
||||
fun initialize() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -236,12 +236,16 @@ class DeviceBlockEntity(
|
|||
inputBlockEntity.inputConnections[inputPort] =
|
||||
InputConnection(outputBlockEntity.pos, outputPort, cableColor)
|
||||
outputBlockEntity.outputConnections[outputPort] = inputBlockEntity.pos
|
||||
Devices.makeConnection(
|
||||
outputDevice,
|
||||
outputPort.resolveInstance(),
|
||||
inputDevice,
|
||||
inputPort
|
||||
)
|
||||
try {
|
||||
Devices.makeConnection(
|
||||
outputDevice,
|
||||
outputPort.resolveInstance(),
|
||||
inputDevice,
|
||||
inputPort
|
||||
)
|
||||
} catch (noSuchPort: NoSuchPortException) {
|
||||
logger.error("NoSuchPortException caught: $noSuchPort")
|
||||
}
|
||||
}
|
||||
|
||||
fun connectPhysicalDevices(
|
||||
|
|
|
|||
|
|
@ -209,21 +209,24 @@ class DeviceBlockEntityRenderer(context: BlockEntityRendererFactory.Context) : B
|
|||
HorizontalDirection.fromDirection(outputBlockState[Properties.HORIZONTAL_FACING])!!
|
||||
val outputBlockEntity =
|
||||
world.getBlockEntity(connection.blockPosition) as DeviceBlockEntity
|
||||
val outputPort = outputBlockEntity.descriptor.portLayout[connection.outputPortName]!!
|
||||
val outputPort = outputBlockEntity.descriptor.portLayout[connection.outputPortName]
|
||||
|
||||
val start = inputPort.blockCablePosition(facing, cableProtrusionAmount)
|
||||
val end = outputPort.blockCablePosition(outputBlockFacing, cableProtrusionAmount)
|
||||
val delta = (endAbsolute - startAbsolute).toVec3f() + end
|
||||
// The output port can be null if we find a port that doesn't exist on this device.
|
||||
if (outputPort != null) {
|
||||
val start = inputPort.blockCablePosition(facing, cableProtrusionAmount)
|
||||
val end = outputPort.blockCablePosition(outputBlockFacing, cableProtrusionAmount)
|
||||
val delta = (endAbsolute - startAbsolute).toVec3f() + end
|
||||
|
||||
renderCable(
|
||||
world,
|
||||
matrixStack,
|
||||
vertexConsumers,
|
||||
worldFrom = blockEntity.pos.toVec3d(),
|
||||
start,
|
||||
delta,
|
||||
connection.color.toFloat()
|
||||
)
|
||||
renderCable(
|
||||
world,
|
||||
matrixStack,
|
||||
vertexConsumers,
|
||||
worldFrom = blockEntity.pos.toVec3d(),
|
||||
start,
|
||||
delta,
|
||||
connection.color.toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package net.liquidev.dawd3.block.devices
|
|||
import net.liquidev.dawd3.Mod
|
||||
import net.liquidev.dawd3.audio.device.DeviceInstance
|
||||
import net.liquidev.dawd3.audio.device.NoControls
|
||||
import net.liquidev.dawd3.audio.devices.PhaseDevice
|
||||
import net.liquidev.dawd3.audio.devices.oscillator.PhaseDevice
|
||||
import net.liquidev.dawd3.block.device.DeviceBlockDescriptor
|
||||
import net.liquidev.dawd3.block.device.PhysicalPort
|
||||
import net.liquidev.dawd3.block.device.descriptor.FaceTextures
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
package net.liquidev.dawd3.block.devices
|
||||
|
||||
import net.liquidev.dawd3.Mod
|
||||
import net.liquidev.dawd3.audio.device.DeviceInstance
|
||||
import net.liquidev.dawd3.audio.device.NoControls
|
||||
import net.liquidev.dawd3.audio.devices.oscillator.SawOscillatorDevice
|
||||
import net.liquidev.dawd3.block.device.DeviceBlockDescriptor
|
||||
import net.liquidev.dawd3.block.device.PhysicalPort
|
||||
import net.minecraft.client.world.ClientWorld
|
||||
import net.minecraft.util.Identifier
|
||||
import net.minecraft.util.math.Vec2f
|
||||
|
||||
object SawOscillatorBlockDescriptor : DeviceBlockDescriptor<SawOscillatorBlockDescriptor.ClientState, NoControls> {
|
||||
override val id = Identifier(Mod.id, "saw_oscillator")
|
||||
|
||||
override val portLayout = PhysicalPort.layout {
|
||||
port(
|
||||
SawOscillatorDevice.phasePort,
|
||||
position = Vec2f(0.25f, 0.5f),
|
||||
side = PhysicalPort.Side.Front,
|
||||
)
|
||||
port(
|
||||
SawOscillatorDevice.outputPort,
|
||||
position = Vec2f(0.75f, 0.5f),
|
||||
side = PhysicalPort.Side.Front
|
||||
)
|
||||
}
|
||||
|
||||
class ClientState(controls: NoControls) : DeviceBlockDescriptor.ClientState {
|
||||
override val logicalDevice = DeviceInstance.create(SawOscillatorDevice(), controls)
|
||||
}
|
||||
|
||||
override fun initControls() = NoControls
|
||||
|
||||
override fun onClientLoad(controls: NoControls, world: ClientWorld) = ClientState(controls)
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package net.liquidev.dawd3.block.devices
|
|||
import net.liquidev.dawd3.Mod
|
||||
import net.liquidev.dawd3.audio.device.DeviceInstance
|
||||
import net.liquidev.dawd3.audio.device.NoControls
|
||||
import net.liquidev.dawd3.audio.devices.SineOscillatorDevice
|
||||
import net.liquidev.dawd3.audio.devices.oscillator.SineOscillatorDevice
|
||||
import net.liquidev.dawd3.block.device.DeviceBlockDescriptor
|
||||
import net.liquidev.dawd3.block.device.PhysicalPort
|
||||
import net.minecraft.client.world.ClientWorld
|
||||
|
|
|
|||
BIN
src/main/resources/assets/dawd3/textures/block/knob_front.png
Normal file
|
After Width: | Height: | Size: 185 B |
BIN
src/main/resources/assets/dawd3/textures/block/knob_side.png
Normal file
|
After Width: | Height: | Size: 185 B |
BIN
src/main/resources/assets/dawd3/textures/block/phase_front.png
Normal file
|
After Width: | Height: | Size: 300 B |
BIN
src/main/resources/assets/dawd3/textures/block/phase_side.png
Normal file
|
After Width: | Height: | Size: 269 B |
|
After Width: | Height: | Size: 298 B |
|
After Width: | Height: | Size: 199 B |
BIN
src/main/resources/assets/dawd3/textures/ui/rack.png
Normal file
|
After Width: | Height: | Size: 341 B |