mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 20:44:05 +09:00
reloading the engine will copy track states from the old instance, obsoleting audioMixerRenewHooks
This commit is contained in:
@@ -506,6 +506,7 @@ class AudioMixer(val bufferSize: Int): Disposable {
|
||||
// feeder.stop()
|
||||
// feedingThread.join()
|
||||
tracks.forEach { it.tryDispose() }
|
||||
dynamicTracks.forEach { it.tryDispose() }
|
||||
masterTrack.tryDispose()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,23 @@ class TerrarumAudioMixerTrack(
|
||||
|
||||
var trackingTarget: Actor? = null
|
||||
|
||||
var playStartedTime = 0L; private set
|
||||
internal var streamPlaying = false
|
||||
var playStartedTime = 0L; internal set
|
||||
|
||||
|
||||
fun copyStatusFrom(other: TerrarumAudioMixerTrack) {
|
||||
other.pullNextTrack = this.pullNextTrack
|
||||
other.currentTrack = this.currentTrack
|
||||
other.nextTrack = this.nextTrack
|
||||
other.volume = this.volume
|
||||
other.trackingTarget = this.trackingTarget
|
||||
other.streamPlaying = this.streamPlaying
|
||||
other.playStartedTime = this.playStartedTime
|
||||
filters.indices.forEach { i ->
|
||||
other.filters[i].copyParamsFrom(this.filters[i])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline fun <reified T> getFilter() = filters.filterIsInstance<T>().first()!!
|
||||
inline fun <reified T> getFilterOrNull() = filters.filterIsInstance<T>().firstOrNull()
|
||||
@@ -119,7 +135,6 @@ class TerrarumAudioMixerTrack(
|
||||
}
|
||||
|
||||
|
||||
internal var streamPlaying = false
|
||||
fun play() {
|
||||
playStartedTime = System.nanoTime()
|
||||
streamPlaying = true
|
||||
|
||||
@@ -140,4 +140,11 @@ class BinoPan(var pan: Float, var earDist: Float = EARDIST_DEFAULT): TerrarumAud
|
||||
}
|
||||
|
||||
override val debugViewHeight = 32
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
if (other is BinoPan) {
|
||||
this.pan = other.pan
|
||||
this.earDist = other.earDist
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,4 +35,11 @@ class Bitcrush(var steps: Int, var inputGain: Float = 1f): TerrarumAudioFilter()
|
||||
}
|
||||
|
||||
override val debugViewHeight = 16
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
if (other is Bitcrush) {
|
||||
this.steps = other.steps
|
||||
this.inputGain = other.inputGain
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,4 +19,7 @@ object Buffer : TerrarumAudioFilter() {
|
||||
}
|
||||
|
||||
override val debugViewHeight = 16
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
}
|
||||
}
|
||||
@@ -155,4 +155,7 @@ class Convolv(ir: File, val crossfeed: Float, gain: Float = 1f / 256f): Terrarum
|
||||
}
|
||||
|
||||
override val debugViewHeight = 32
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,10 @@ class Gain(var gain: Float): TerrarumAudioFilter() {
|
||||
}
|
||||
|
||||
override val debugViewHeight = 16
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
if (other is Gain) {
|
||||
this.gain = other.gain
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,4 +67,10 @@ class Highpass(cutoff0: Float): TerrarumAudioFilter() {
|
||||
}
|
||||
|
||||
override val debugViewHeight = 16
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
if (other is Highpass) {
|
||||
setCutoff(other.cutoff)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,4 +67,10 @@ class Lowpass(cutoff0: Float): TerrarumAudioFilter() {
|
||||
}
|
||||
|
||||
override val debugViewHeight = 16
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
if (other is Lowpass) {
|
||||
setCutoff(other.cutoff)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,4 +13,7 @@ object NullFilter : TerrarumAudioFilter() {
|
||||
}
|
||||
|
||||
override val debugViewHeight = 0
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
}
|
||||
}
|
||||
@@ -53,4 +53,7 @@ class Reverb(val delayMS: Float = 36f, var feedback: Float = 0.92f, var lowpass:
|
||||
}
|
||||
|
||||
override val debugViewHeight = 0
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
}
|
||||
}
|
||||
@@ -56,4 +56,7 @@ object SoftClp : TerrarumAudioFilter() {
|
||||
}
|
||||
|
||||
override val debugViewHeight = 0
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import net.torvald.terrarum.ui.BasicDebugInfoWindow.Companion.STRIP_W
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import kotlin.math.*
|
||||
|
||||
class Spectro(val gain: Float = 1f) : TerrarumAudioFilter() {
|
||||
class Spectro(var gain: Float = 1f) : TerrarumAudioFilter() {
|
||||
private val FFTSIZE = 1024
|
||||
private val inBuf = Array(2) { FloatArray(FFTSIZE) }
|
||||
|
||||
@@ -91,10 +91,16 @@ class Spectro(val gain: Float = 1f) : TerrarumAudioFilter() {
|
||||
}
|
||||
|
||||
override val debugViewHeight = STRIP_W
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
if (other is Spectro) {
|
||||
this.gain = other.gain
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Vecto(val gain: Float = 1f) : TerrarumAudioFilter() {
|
||||
class Vecto(var gain: Float = 1f) : TerrarumAudioFilter() {
|
||||
var backbufL = Array((6144f / App.audioBufferSize).roundToInt().coerceAtLeast(1)) {
|
||||
FloatArray(App.audioBufferSize)
|
||||
}
|
||||
@@ -154,4 +160,10 @@ class Vecto(val gain: Float = 1f) : TerrarumAudioFilter() {
|
||||
}
|
||||
|
||||
override val debugViewHeight = STRIP_W
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
if (other is Vecto) {
|
||||
this.gain = other.gain
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ abstract class TerrarumAudioFilter {
|
||||
}
|
||||
abstract fun drawDebugView(batch: SpriteBatch, x: Int, y: Int)
|
||||
abstract val debugViewHeight: Int
|
||||
abstract fun copyParamsFrom(other: TerrarumAudioFilter)
|
||||
}
|
||||
|
||||
fun FloatArray.applyGain(gain: Float = 1f) = this.map { it * gain }.toFloatArray()
|
||||
|
||||
@@ -19,6 +19,9 @@ object XYtoMS: TerrarumAudioFilter() {
|
||||
}
|
||||
|
||||
override val debugViewHeight = 0
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
}
|
||||
}
|
||||
|
||||
object MStoXY: TerrarumAudioFilter() {
|
||||
@@ -37,4 +40,7 @@ object MStoXY: TerrarumAudioFilter() {
|
||||
}
|
||||
|
||||
override val debugViewHeight = 0
|
||||
|
||||
override fun copyParamsFrom(other: TerrarumAudioFilter) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user