mirror of
https://gitlab.com/cc-ru/ocelot/ocelot-desktop.git
synced 2025-12-20 02:59:19 +01:00
Downmix SDC SFX sounds to mono to allow positioning to work
Closes #174.
This commit is contained in:
parent
09277887a6
commit
9192d7fc48
Binary file not shown.
Binary file not shown.
@ -21,7 +21,7 @@ object AL10W extends Logging {
|
|||||||
val exc = OpenAlException(func, errName, err)
|
val exc = OpenAlException(func, errName, err)
|
||||||
|
|
||||||
if (Settings.get.logAudioErrorStacktrace) {
|
if (Settings.get.logAudioErrorStacktrace) {
|
||||||
logger.error(exc)
|
logger.error(exc.getMessage, exc)
|
||||||
} else {
|
} else {
|
||||||
logger.error(exc.getMessage)
|
logger.error(exc.getMessage)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,15 +34,15 @@ class SoundSource(
|
|||||||
Audio.getSourceStatus(this)
|
Audio.getSourceStatus(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
def isPlaying: Boolean = {
|
def playing: Boolean = {
|
||||||
status == SoundSource.Status.Playing
|
status == SoundSource.Status.Playing
|
||||||
}
|
}
|
||||||
|
|
||||||
def isPaused: Boolean = {
|
def paused: Boolean = {
|
||||||
status == SoundSource.Status.Paused
|
status == SoundSource.Status.Paused
|
||||||
}
|
}
|
||||||
|
|
||||||
def isStopped: Boolean = {
|
def stopped: Boolean = {
|
||||||
status == SoundSource.Status.Stopped
|
status == SoundSource.Status.Stopped
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,15 +124,9 @@ object SoundSource {
|
|||||||
SoundSource.fromBuffer(SoundBuffers.MinecraftClickRelease, SoundCategory.Interface)
|
SoundSource.fromBuffer(SoundBuffers.MinecraftClickRelease, SoundCategory.Interface)
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy val MinecraftExplosion: SoundSource =
|
|
||||||
SoundSource.fromBuffer(SoundBuffers.MinecraftExplosion, SoundCategory.Environment)
|
|
||||||
|
|
||||||
lazy val MachineFloppyInsert: SoundSource =
|
lazy val MachineFloppyInsert: SoundSource =
|
||||||
SoundSource.fromBuffer(SoundBuffers.MachineFloppyInsert, SoundCategory.Environment)
|
SoundSource.fromBuffer(SoundBuffers.MachineFloppyInsert, SoundCategory.Environment)
|
||||||
|
|
||||||
lazy val MachineFloppyEject: SoundSource =
|
lazy val MachineFloppyEject: SoundSource =
|
||||||
SoundSource.fromBuffer(SoundBuffers.MachineFloppyEject, SoundCategory.Environment)
|
SoundSource.fromBuffer(SoundBuffers.MachineFloppyEject, SoundCategory.Environment)
|
||||||
|
|
||||||
lazy val SelfDestructingCardCountdownBeep: SoundSource =
|
|
||||||
SoundSource.fromBuffer(SoundBuffers.SelfDestructingCardCountdownBeep, SoundCategory.Environment)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -152,7 +152,7 @@ class OpenFMRadio extends Entity with Environment with DeviceInfo with Logging {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def isPlaying: Boolean =
|
def isPlaying: Boolean =
|
||||||
playbackSoundSource.isDefined && playbackSoundSource.get.isPlaying || playbackThread.isDefined
|
playbackSoundSource.isDefined && playbackSoundSource.get.playing || playbackThread.isDefined
|
||||||
|
|
||||||
@Callback()
|
@Callback()
|
||||||
def start(context: Context, args: Arguments): Array[AnyRef] =
|
def start(context: Context, args: Arguments): Array[AnyRef] =
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package ocelot.desktop.node
|
package ocelot.desktop.node
|
||||||
|
|
||||||
import ocelot.desktop.audio.SoundSource
|
import ocelot.desktop.audio.{SoundBuffers, SoundCategory, SoundSource}
|
||||||
import ocelot.desktop.color.Color
|
import ocelot.desktop.color.Color
|
||||||
import ocelot.desktop.geometry.FloatUtils.ExtendedFloat
|
import ocelot.desktop.geometry.FloatUtils.ExtendedFloat
|
||||||
import ocelot.desktop.graphics.{Graphics, IconSource}
|
import ocelot.desktop.graphics.{Graphics, IconSource}
|
||||||
@ -14,15 +14,23 @@ import totoro.ocelot.brain.event.SelfDestructingCardBoomEvent
|
|||||||
trait BoomCardFxHandler extends Node with PositionalSoundSourcesNode with SmokeParticleNode {
|
trait BoomCardFxHandler extends Node with PositionalSoundSourcesNode with SmokeParticleNode {
|
||||||
private var boomPhase: Float = -1
|
private var boomPhase: Float = -1
|
||||||
|
|
||||||
|
private lazy val explosionSound = {
|
||||||
|
SoundSource.fromBuffer(SoundBuffers.MinecraftExplosion, SoundCategory.Environment)
|
||||||
|
}
|
||||||
|
|
||||||
|
private lazy val countdownBeepSound = {
|
||||||
|
SoundSource.fromBuffer(SoundBuffers.SelfDestructingCardCountdownBeep, SoundCategory.Environment)
|
||||||
|
}
|
||||||
|
|
||||||
override def soundSources: Seq[SoundSource] = super.soundSources ++ Seq(
|
override def soundSources: Seq[SoundSource] = super.soundSources ++ Seq(
|
||||||
SoundSource.MinecraftExplosion,
|
explosionSound,
|
||||||
SoundSource.SelfDestructingCardCountdownBeep,
|
countdownBeepSound,
|
||||||
)
|
)
|
||||||
|
|
||||||
eventHandlers += {
|
eventHandlers += {
|
||||||
case BrainEvent(_: SelfDestructingCardBoomEvent) =>
|
case BrainEvent(_: SelfDestructingCardBoomEvent) =>
|
||||||
OcelotDesktop.updateThreadTasks.add(() => {
|
OcelotDesktop.updateThreadTasks.add(() => {
|
||||||
SoundSource.MinecraftExplosion.play()
|
explosionSound.play()
|
||||||
emitSmoke()
|
emitSmoke()
|
||||||
destroy()
|
destroy()
|
||||||
})
|
})
|
||||||
@ -44,7 +52,7 @@ trait BoomCardFxHandler extends Node with PositionalSoundSourcesNode with SmokeP
|
|||||||
boomPhase = boomPhase.max(1 - item.card.time.toFloat / item.card.initialTime)
|
boomPhase = boomPhase.max(1 - item.card.time.toFloat / item.card.initialTime)
|
||||||
|
|
||||||
if (item.card.lastBeepTime < 0 || item.card.lastBeepTime - item.card.time >= 20) {
|
if (item.card.lastBeepTime < 0 || item.card.lastBeepTime - item.card.time >= 20) {
|
||||||
SoundSource.SelfDestructingCardCountdownBeep.play()
|
countdownBeepSound.play()
|
||||||
item.card.lastBeepTime = item.card.time
|
item.card.lastBeepTime = item.card.time
|
||||||
flickerPhase = FlickerDuty
|
flickerPhase = FlickerDuty
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,12 @@ import ocelot.desktop.audio.SoundSource
|
|||||||
import ocelot.desktop.geometry.Vector3D
|
import ocelot.desktop.geometry.Vector3D
|
||||||
import ocelot.desktop.{OcelotDesktop, Settings}
|
import ocelot.desktop.{OcelotDesktop, Settings}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates sound sources' position depending on where the camera is.
|
||||||
|
*
|
||||||
|
* @note OpenAL only applies positioning to mono sources!
|
||||||
|
* If your source is stereo, this trait will have no audible effect.
|
||||||
|
*/
|
||||||
trait PositionalSoundSourcesNode extends Node {
|
trait PositionalSoundSourcesNode extends Node {
|
||||||
// Every node can have multiple sound sources playing at the same time
|
// Every node can have multiple sound sources playing at the same time
|
||||||
def soundSources: Seq[SoundSource] = Seq()
|
def soundSources: Seq[SoundSource] = Seq()
|
||||||
|
|||||||
@ -57,9 +57,9 @@ class TapeDriveNode(val tapeDrive: TapeDrive)
|
|||||||
val isRewinding =
|
val isRewinding =
|
||||||
tapeDrive.state.state == TapeDriveState.State.Rewinding || tapeDrive.state.state == TapeDriveState.State.Forwarding
|
tapeDrive.state.state == TapeDriveState.State.Rewinding || tapeDrive.state.state == TapeDriveState.State.Forwarding
|
||||||
|
|
||||||
if (!isRewinding && soundTapeRewind.isPlaying) {
|
if (!isRewinding && soundTapeRewind.playing) {
|
||||||
soundTapeRewind.stop()
|
soundTapeRewind.stop()
|
||||||
} else if (isRewinding && !soundTapeRewind.isPlaying && !Audio.isDisabled) {
|
} else if (isRewinding && !soundTapeRewind.playing && !Audio.isDisabled) {
|
||||||
soundTapeRewind.play()
|
soundTapeRewind.play()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,9 +10,9 @@ trait AudibleComputerAware extends ComputerAware {
|
|||||||
)
|
)
|
||||||
|
|
||||||
def updateRunningSound(): Unit = {
|
def updateRunningSound(): Unit = {
|
||||||
if (!computer.machine.isRunning && soundComputerRunning.isPlaying) {
|
if (!computer.machine.isRunning && soundComputerRunning.playing) {
|
||||||
soundComputerRunning.stop()
|
soundComputerRunning.stop()
|
||||||
} else if (computer.machine.isRunning && !soundComputerRunning.isPlaying && !Audio.isDisabled) {
|
} else if (computer.machine.isRunning && !soundComputerRunning.playing && !Audio.isDisabled) {
|
||||||
soundComputerRunning.play()
|
soundComputerRunning.play()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user