Renamed 'ljud' to 'miniaudio' to better represent what engine it is.
This commit is contained in:
@@ -2,7 +2,7 @@ package engine
|
||||
|
||||
import "core:log"
|
||||
|
||||
import "ljud"
|
||||
import "miniaudio"
|
||||
|
||||
Bus :: struct {
|
||||
backend: ^Bus_Backend,
|
||||
@@ -13,8 +13,8 @@ create_bus :: proc(engine: ^Engine) -> (Bus, bool) {
|
||||
|
||||
bus: Bus
|
||||
|
||||
when AUDIO_ENGINE_LJUD {
|
||||
backend, ok := ljud.create_bus(&engine.backend)
|
||||
when AUDIO_ENGINE_MINIAUDIO {
|
||||
backend, ok := miniaudio.create_bus(&engine.backend)
|
||||
if !ok {
|
||||
return {}, false
|
||||
}
|
||||
@@ -37,8 +37,8 @@ destroy_bus :: proc(engine: ^Engine, bus: ^Bus) {
|
||||
assert(bus != nil)
|
||||
assert(bus.backend != nil)
|
||||
|
||||
when AUDIO_ENGINE_LJUD {
|
||||
ljud.destroy_bus(&engine.backend, bus.backend)
|
||||
when AUDIO_ENGINE_MINIAUDIO {
|
||||
miniaudio.destroy_bus(&engine.backend, bus.backend)
|
||||
}
|
||||
else {
|
||||
#assert("TODO: SS - Implement for Audio Engine backend")
|
||||
|
||||
@@ -4,17 +4,17 @@ import "core:container/queue"
|
||||
import "core:log"
|
||||
import "core:math/linalg"
|
||||
|
||||
AUDIO_ENGINE_LJUD :: #config(AUDIO_ENGINE_LJUD, false)
|
||||
AUDIO_ENGINE_FMOD :: #config(AUDIO_ENGINE_FMOD, false)
|
||||
AUDIO_ENGINE_WWISE :: #config(AUDIO_ENGINE_WWISE, false)
|
||||
AUDIO_ENGINE_MINIAUDIO :: #config(AUDIO_ENGINE_MINIAUDIO, false)
|
||||
AUDIO_ENGINE_FMOD :: #config(AUDIO_ENGINE_FMOD, false)
|
||||
AUDIO_ENGINE_WWISE :: #config(AUDIO_ENGINE_WWISE, false)
|
||||
|
||||
import "ljud"
|
||||
import "miniaudio"
|
||||
|
||||
when AUDIO_ENGINE_LJUD {
|
||||
Engine_Backend :: ljud.Engine
|
||||
Sound_Backend :: ljud.Sound
|
||||
Sound_Instance_Backend :: ljud.Sound_Instance
|
||||
Bus_Backend :: ljud.Bus
|
||||
when AUDIO_ENGINE_MINIAUDIO {
|
||||
Engine_Backend :: miniaudio.Engine
|
||||
Sound_Backend :: miniaudio.Sound
|
||||
Sound_Instance_Backend :: miniaudio.Sound_Instance
|
||||
Bus_Backend :: miniaudio.Bus
|
||||
}
|
||||
else when AUDIO_ENGINE_FMOD {
|
||||
|
||||
@@ -34,29 +34,29 @@ init :: proc(engine: ^Engine, max_sound_instances: u32) -> bool {
|
||||
assert(engine != nil)
|
||||
assert(max_sound_instances > 0)
|
||||
|
||||
when AUDIO_ENGINE_LJUD {
|
||||
// engine.§ new(ljud.Engine)
|
||||
when AUDIO_ENGINE_MINIAUDIO {
|
||||
// engine.§ new(miniaudio.Engine)
|
||||
// if engine.data != nil {
|
||||
// v := transmute(^ljud.Engine)(engine.data)
|
||||
// if !ljud.init(v) {
|
||||
// v := transmute(^miniaudio.Engine)(engine.data)
|
||||
// if !miniaudio.init(v) {
|
||||
// free(engine.data)
|
||||
// engine.data = nil
|
||||
|
||||
// log.errorf("Failed to initialize audio-engine LJUD.")
|
||||
// log.errorf("Failed to initialize audio-engine MINIAUDIO.")
|
||||
// return false
|
||||
// }
|
||||
// }
|
||||
|
||||
if !ljud.init(&engine.backend) {
|
||||
if !miniaudio.init(&engine.backend) {
|
||||
// free(engine.data)
|
||||
// engine.data = nil
|
||||
|
||||
log.errorf("Failed to initialize audio-engine LJUD.")
|
||||
log.errorf("Failed to initialize audio-engine MINIAUDIO.")
|
||||
return false
|
||||
}
|
||||
}
|
||||
else {
|
||||
#assert("No audio-engine defined. '-define:AUDIO_ENGINE_X=true' where X is the audio-engine; 'LJUD', 'FMOD', 'WWISE'.")
|
||||
#assert("No audio-engine defined. '-define:AUDIO_ENGINE_X=true' where X is the audio-engine; 'MINIAUDIO', 'FMOD', 'WWISE'.")
|
||||
}
|
||||
|
||||
{ // Initialize sound-instances.
|
||||
@@ -86,8 +86,8 @@ init :: proc(engine: ^Engine, max_sound_instances: u32) -> bool {
|
||||
}
|
||||
|
||||
tick :: proc(engine: ^Engine) {
|
||||
when AUDIO_ENGINE_LJUD {
|
||||
ljud.tick(&engine.backend)
|
||||
when AUDIO_ENGINE_MINIAUDIO {
|
||||
miniaudio.tick(&engine.backend)
|
||||
}
|
||||
else {
|
||||
#assert("TODO: SS - Implement for Audio Engine backend")
|
||||
@@ -100,8 +100,8 @@ tick :: proc(engine: ^Engine) {
|
||||
}
|
||||
|
||||
|
||||
when AUDIO_ENGINE_LJUD {
|
||||
ljud.tick_listener(
|
||||
when AUDIO_ENGINE_MINIAUDIO {
|
||||
miniaudio.tick_listener(
|
||||
&engine.backend,
|
||||
u8(listener.id),
|
||||
listener.enabled,
|
||||
@@ -117,8 +117,8 @@ tick :: proc(engine: ^Engine) {
|
||||
shutdown :: proc(engine: ^Engine) {
|
||||
assert(engine != nil)
|
||||
|
||||
when AUDIO_ENGINE_LJUD {
|
||||
ljud.shutdown(&engine.backend)
|
||||
when AUDIO_ENGINE_MINIAUDIO {
|
||||
miniaudio.shutdown(&engine.backend)
|
||||
}
|
||||
else {
|
||||
#assert("TODO: SS - Implement for Audio Engine backend")
|
||||
|
||||
@@ -3,8 +3,7 @@ package engine
|
||||
import "core:log"
|
||||
import "core:container/queue"
|
||||
|
||||
import "ljud"
|
||||
|
||||
import "miniaudio"
|
||||
|
||||
MAX_LISTENERS :: 4
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ljud
|
||||
package miniaudio_wrapper
|
||||
|
||||
import "core:log"
|
||||
import "core:strings"
|
||||
@@ -1,4 +1,4 @@
|
||||
package ljud
|
||||
package miniaudio_wrapper
|
||||
|
||||
import "core:container/queue"
|
||||
import "core:log"
|
||||
@@ -12,7 +12,7 @@ Engine :: struct {
|
||||
|
||||
init :: proc(engine: ^Engine) -> bool {
|
||||
assert(engine != nil)
|
||||
log.infof("Initializing LJUD Engine")
|
||||
log.infof("Initializing Miniaudio Engine")
|
||||
|
||||
engine_config := ma.engine_config_init()
|
||||
engine_config.channels = 0
|
||||
@@ -1,4 +1,4 @@
|
||||
package ljud
|
||||
package miniaudio_wrapper
|
||||
|
||||
import "core:sys/orca"
|
||||
import "base:runtime"
|
||||
@@ -119,26 +119,27 @@ init_sound_instance :: proc(engine: ^Engine, bus: ^Bus, sound: ^Sound, sound_ins
|
||||
return true
|
||||
}
|
||||
|
||||
Play_Sound_Instance_Spec :: struct {
|
||||
play_sound_instance :: proc(
|
||||
engine: ^Engine,
|
||||
sound_instance: ^Sound_Instance,
|
||||
spatialized: bool,
|
||||
loop: bool,
|
||||
volume: f32,
|
||||
|
||||
position: [3]f32,
|
||||
distance: struct { min, max: f32, }
|
||||
}
|
||||
|
||||
play_sound_instance :: proc(engine: ^Engine, sound_instance: ^Sound_Instance, spec: Play_Sound_Instance_Spec) -> bool {
|
||||
min_distance, max_distance: f32,
|
||||
) -> bool {
|
||||
assert(engine != nil)
|
||||
assert(sound_instance != nil)
|
||||
|
||||
ma.sound_set_spatialization_enabled(sound_instance, b32(spec.spatialized))
|
||||
ma.sound_set_volume(sound_instance, spec.volume)
|
||||
ma.sound_set_position(sound_instance, expand_values(spec.position))
|
||||
ma.sound_set_min_distance(sound_instance, spec.distance.min)
|
||||
ma.sound_set_max_distance(sound_instance, spec.distance.max)
|
||||
ma.sound_set_spatialization_enabled(sound_instance, b32(spatialized))
|
||||
ma.sound_set_looping(sound_instance, b32(loop))
|
||||
ma.sound_set_volume(sound_instance, volume)
|
||||
ma.sound_set_position(sound_instance, expand_values(position))
|
||||
ma.sound_set_min_distance(sound_instance, min_distance)
|
||||
ma.sound_set_max_distance(sound_instance, max_distance)
|
||||
|
||||
// TODO: SS - So many cool thingss available! Expose them.
|
||||
// 'ma.sound_set_looping', 'ma.sound_set_pitch' etc.
|
||||
// 'ma.sound_set_pitch' etc.
|
||||
|
||||
seek_result := ma.sound_seek_to_pcm_frame(sound_instance, 0)
|
||||
if seek_result != .SUCCESS {
|
||||
@@ -152,6 +153,5 @@ play_sound_instance :: proc(engine: ^Engine, sound_instance: ^Sound_Instance, sp
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import os "core:os/os2"
|
||||
import "core:container/queue"
|
||||
import "core:log"
|
||||
|
||||
import "ljud"
|
||||
import "miniaudio"
|
||||
|
||||
Sound :: struct {
|
||||
path: string, // Where I was loaded from.
|
||||
@@ -17,6 +17,7 @@ Sound_Instance :: struct {
|
||||
backend: Sound_Instance_Backend, // Backend-representation.
|
||||
|
||||
spatialized: bool,
|
||||
loop: bool,
|
||||
volume: f32, // 0..1
|
||||
position: [3]f32,
|
||||
min_distance, max_distance: f32,
|
||||
@@ -48,8 +49,8 @@ load_sound_from_path :: proc(engine: ^Engine, path: string) -> (Sound, bool) {
|
||||
return {}, false
|
||||
}
|
||||
|
||||
when AUDIO_ENGINE_LJUD {
|
||||
backend, ok := ljud.load_sound_from_data(&engine.backend, data, ext)
|
||||
when AUDIO_ENGINE_MINIAUDIO {
|
||||
backend, ok := miniaudio.load_sound_from_data(&engine.backend, data, ext)
|
||||
if !ok {
|
||||
return {}, false
|
||||
}
|
||||
@@ -80,8 +81,8 @@ unload_sound :: proc(engine: ^Engine, sound: ^Sound) {
|
||||
assert(sound != nil)
|
||||
assert(sound.data != nil)
|
||||
|
||||
when AUDIO_ENGINE_LJUD {
|
||||
ljud.unload_sound(&engine.backend, sound.backend)
|
||||
when AUDIO_ENGINE_MINIAUDIO {
|
||||
miniaudio.unload_sound(&engine.backend, sound.backend)
|
||||
}
|
||||
else when AUDIO_ENGINE_FMOD {
|
||||
|
||||
@@ -116,8 +117,8 @@ create_sound_instance :: proc(engine: ^Engine, sound: ^Sound, bus: ^Bus) -> (^So
|
||||
sound_instance.backend = {}
|
||||
|
||||
instance_ok: bool
|
||||
when AUDIO_ENGINE_LJUD {
|
||||
instance_ok = ljud.init_sound_instance(&engine.backend, bus != nil ? bus.backend : nil, sound.backend, &sound_instance.backend)
|
||||
when AUDIO_ENGINE_MINIAUDIO {
|
||||
instance_ok = miniaudio.init_sound_instance(&engine.backend, bus != nil ? bus.backend : nil, sound.backend, &sound_instance.backend)
|
||||
}
|
||||
else when AUDIO_ENGINE_FMOD {
|
||||
|
||||
@@ -138,18 +139,17 @@ play_sound_instance :: proc(engine: ^Engine, sound_instance: ^Sound_Instance) ->
|
||||
assert(engine != nil)
|
||||
assert(sound_instance != nil)
|
||||
|
||||
when AUDIO_ENGINE_LJUD {
|
||||
spec := ljud.Play_Sound_Instance_Spec {
|
||||
spatialized = sound_instance.spatialized,
|
||||
volume = sound_instance.volume,
|
||||
|
||||
position = sound_instance.position,
|
||||
distance = {
|
||||
min = sound_instance.min_distance,
|
||||
max = sound_instance.max_distance,
|
||||
},
|
||||
}
|
||||
return ljud.play_sound_instance(&engine.backend, &sound_instance.backend, spec)
|
||||
when AUDIO_ENGINE_MINIAUDIO {
|
||||
return miniaudio.play_sound_instance(
|
||||
&engine.backend,
|
||||
&sound_instance.backend,
|
||||
sound_instance.spatialized,
|
||||
sound_instance.loop,
|
||||
sound_instance.volume,
|
||||
sound_instance.position,
|
||||
sound_instance.min_distance,
|
||||
sound_instance.max_distance,
|
||||
)
|
||||
}
|
||||
else when AUDIO_ENGINE_FMOD {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user