[RELEASE] u22-v04
This version is submitted for U22 final presentation. (squashed 158 commits)
This commit is contained in:
@@ -6,6 +6,10 @@ add_library(loresource
|
||||
sound.c
|
||||
text.c
|
||||
)
|
||||
target_benum_sources(loresource
|
||||
music.h
|
||||
sound.h
|
||||
)
|
||||
target_any_sources(loresource
|
||||
font/sans.woff
|
||||
font/serif.woff
|
||||
@@ -36,5 +40,4 @@ target_link_libraries(loresource
|
||||
glyphas
|
||||
jukebox
|
||||
math
|
||||
memory
|
||||
)
|
||||
|
@@ -7,8 +7,8 @@
|
||||
#include "util/glyphas/face.h"
|
||||
|
||||
/* resources */
|
||||
#include "anysrc/font/sans.woff.h"
|
||||
#include "anysrc/font/serif.woff.h"
|
||||
#include "core/loresource/anysrc/font/sans.woff.h"
|
||||
#include "core/loresource/anysrc/font/serif.woff.h"
|
||||
|
||||
void loresource_font_initialize(loresource_font_t* font) {
|
||||
assert(font != NULL);
|
||||
|
@@ -2,100 +2,90 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "util/jukebox/amp.h"
|
||||
#include "util/jukebox/composite.h"
|
||||
#include "util/jukebox/decoder.h"
|
||||
#include "util/jukebox/format.h"
|
||||
#include "util/jukebox/mixer.h"
|
||||
#include "util/math/rational.h"
|
||||
|
||||
/* resources */
|
||||
#include "anysrc/music/biome_boss.mp3.h"
|
||||
#include "anysrc/music/biome_cavias_camp.mp3.h"
|
||||
#include "anysrc/music/biome_laboratory.mp3.h"
|
||||
#include "anysrc/music/biome_metaphysical_gate.mp3.h"
|
||||
#include "anysrc/music/boss_big_warder.mp3.h"
|
||||
#include "anysrc/music/boss_greedy_scientist.mp3.h"
|
||||
#include "anysrc/music/boss_theists_child.mp3.h"
|
||||
#include "anysrc/music/boss_theists_child.mp3.h"
|
||||
#include "anysrc/music/title.mp3.h"
|
||||
#include "core/loresource/anysrc/music/biome_boss.mp3.h"
|
||||
#include "core/loresource/anysrc/music/biome_cavias_camp.mp3.h"
|
||||
#include "core/loresource/anysrc/music/biome_laboratory.mp3.h"
|
||||
#include "core/loresource/anysrc/music/biome_metaphysical_gate.mp3.h"
|
||||
#include "core/loresource/anysrc/music/boss_big_warder.mp3.h"
|
||||
#include "core/loresource/anysrc/music/boss_greedy_scientist.mp3.h"
|
||||
#include "core/loresource/anysrc/music/boss_theists_child.mp3.h"
|
||||
#include "core/loresource/anysrc/music/boss_theists_child.mp3.h"
|
||||
#include "core/loresource/anysrc/music/title.mp3.h"
|
||||
|
||||
#define LORESOURCE_MUSIC_EACH_(PROC) do { \
|
||||
PROC(biome_boss); \
|
||||
PROC(biome_cavias_camp); \
|
||||
PROC(biome_laboratory); \
|
||||
PROC(biome_metaphysical_gate); \
|
||||
PROC(boss_big_warder); \
|
||||
PROC(boss_greedy_scientist); \
|
||||
PROC(boss_theists_child); \
|
||||
PROC(title); \
|
||||
} while (0)
|
||||
|
||||
static void loresource_music_player_initialize_(
|
||||
loresource_music_player_t* p,
|
||||
const jukebox_format_t* format,
|
||||
const void* buf,
|
||||
size_t len) {
|
||||
assert(p != NULL);
|
||||
static void loresource_music_initialize_(
|
||||
loresource_music_t* m,
|
||||
const jukebox_format_t* format,
|
||||
const void* buf,
|
||||
size_t len) {
|
||||
assert(m != NULL);
|
||||
assert(jukebox_format_valid(format));
|
||||
assert(buf != NULL || len == 0);
|
||||
|
||||
*p = (typeof(*p)) {
|
||||
*m = (typeof(*m)) {
|
||||
.decoder = jukebox_decoder_new_from_memory_mp3(format, buf, len),
|
||||
.compo = jukebox_composite_new(format, 2),
|
||||
};
|
||||
jukebox_amp_initialize(&p->amp, format);
|
||||
jukebox_amp_initialize(&m->amp, format);
|
||||
|
||||
jukebox_composite_add_effect(p->compo, (jukebox_effect_t*) p->decoder);
|
||||
jukebox_composite_add_effect(p->compo, (jukebox_effect_t*) &p->amp);
|
||||
jukebox_composite_play(p->compo);
|
||||
jukebox_composite_add_effect(m->compo, (jukebox_effect_t*) m->decoder);
|
||||
jukebox_composite_add_effect(m->compo, (jukebox_effect_t*) &m->amp);
|
||||
jukebox_composite_play(m->compo);
|
||||
}
|
||||
static void loresource_music_deinitialize_(loresource_music_t* m) {
|
||||
assert(m != NULL);
|
||||
|
||||
jukebox_composite_delete(m->compo);
|
||||
jukebox_amp_deinitialize(&m->amp);
|
||||
jukebox_decoder_delete(m->decoder);
|
||||
}
|
||||
|
||||
static void loresource_music_player_deinitialize_(
|
||||
loresource_music_player_t* p) {
|
||||
assert(p != NULL);
|
||||
|
||||
jukebox_composite_delete(p->compo);
|
||||
jukebox_amp_deinitialize(&p->amp);
|
||||
jukebox_decoder_delete(p->decoder);
|
||||
}
|
||||
|
||||
void loresource_music_initialize(
|
||||
loresource_music_t* music,
|
||||
void loresource_music_set_initialize(
|
||||
loresource_music_set_t* set,
|
||||
jukebox_mixer_t* mixer,
|
||||
const jukebox_format_t* format) {
|
||||
assert(music != NULL);
|
||||
assert(set != NULL);
|
||||
assert(mixer != NULL);
|
||||
assert(jukebox_format_valid(format));
|
||||
|
||||
*music = (typeof(*music)) {0};
|
||||
*set = (typeof(*set)) {0};
|
||||
|
||||
# define each_(n) do { \
|
||||
loresource_music_player_initialize_( \
|
||||
&music->n, \
|
||||
# define each_(N, n) do { \
|
||||
loresource_music_t* p = \
|
||||
&set->items[LORESOURCE_MUSIC_ID_##N]; \
|
||||
*p = (typeof(*p)) { \
|
||||
.id = LORESOURCE_MUSIC_ID_##N, \
|
||||
.name = #N, \
|
||||
}; \
|
||||
loresource_music_initialize_( \
|
||||
p, \
|
||||
format, \
|
||||
loresource_music_##n##_mp3_, \
|
||||
sizeof(loresource_music_##n##_mp3_)); \
|
||||
jukebox_mixer_add_effect(mixer, (jukebox_effect_t*) music->n.compo); \
|
||||
jukebox_mixer_add_effect(mixer, (jukebox_effect_t*) p->compo); \
|
||||
} while (0)
|
||||
|
||||
LORESOURCE_MUSIC_EACH_(each_);
|
||||
|
||||
LORESOURCE_MUSIC_ID_EACH(each_);
|
||||
# undef each_
|
||||
}
|
||||
|
||||
void loresource_music_deinitialize(loresource_music_t* music) {
|
||||
assert(music != NULL);
|
||||
void loresource_music_set_deinitialize(loresource_music_set_t* set) {
|
||||
assert(set != NULL);
|
||||
|
||||
# define each_(n) do { \
|
||||
loresource_music_player_deinitialize_(&music->n); \
|
||||
} while (0)
|
||||
|
||||
LORESOURCE_MUSIC_EACH_(each_);
|
||||
|
||||
# undef each_
|
||||
for (size_t i = 0; i < LORESOURCE_MUSIC_ID_COUNT; ++i) {
|
||||
loresource_music_deinitialize_(&set->items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
loresource_music_t* loresource_music_set_get(
|
||||
loresource_music_set_t* set, loresource_music_id_t id) {
|
||||
assert(set != NULL);
|
||||
|
||||
return &set->items[id];
|
||||
}
|
||||
|
@@ -4,35 +4,49 @@
|
||||
#include "util/jukebox/composite.h"
|
||||
#include "util/jukebox/decoder.h"
|
||||
#include "util/jukebox/mixer.h"
|
||||
#include "util/math/rational.h"
|
||||
|
||||
typedef enum {
|
||||
/* BENUM BEGIN loresource_music_id */
|
||||
LORESOURCE_MUSIC_ID_BIOME_BOSS,
|
||||
LORESOURCE_MUSIC_ID_BIOME_CAVIAS_CAMP,
|
||||
LORESOURCE_MUSIC_ID_BIOME_METAPHYSICAL_GATE,
|
||||
LORESOURCE_MUSIC_ID_BIOME_LABORATORY,
|
||||
LORESOURCE_MUSIC_ID_BOSS_BIG_WARDER,
|
||||
LORESOURCE_MUSIC_ID_BOSS_GREEDY_SCIENTIST,
|
||||
LORESOURCE_MUSIC_ID_BOSS_THEISTS_CHILD,
|
||||
LORESOURCE_MUSIC_ID_TITLE,
|
||||
/* BENUM END */
|
||||
} loresource_music_id_t;
|
||||
|
||||
#include "core/loresource/benum/music.h"
|
||||
|
||||
typedef struct {
|
||||
loresource_music_id_t id;
|
||||
const char* name;
|
||||
|
||||
jukebox_decoder_t* decoder;
|
||||
jukebox_amp_t amp;
|
||||
jukebox_composite_t* compo;
|
||||
} loresource_music_player_t;
|
||||
|
||||
struct loresource_music_t;
|
||||
typedef struct {
|
||||
loresource_music_player_t
|
||||
biome_boss,
|
||||
biome_cavias_camp,
|
||||
biome_metaphysical_gate,
|
||||
biome_laboratory,
|
||||
boss_big_warder,
|
||||
boss_greedy_scientist,
|
||||
boss_theists_child,
|
||||
title;
|
||||
} loresource_music_t;
|
||||
|
||||
typedef struct {
|
||||
loresource_music_t items[LORESOURCE_MUSIC_ID_COUNT];
|
||||
} loresource_music_set_t;
|
||||
|
||||
void
|
||||
loresource_music_initialize(
|
||||
loresource_music_t* music,
|
||||
loresource_music_set_initialize(
|
||||
loresource_music_set_t* set,
|
||||
jukebox_mixer_t* mixer,
|
||||
const jukebox_format_t* format
|
||||
);
|
||||
|
||||
void
|
||||
loresource_music_deinitialize(
|
||||
loresource_music_t* music
|
||||
loresource_music_set_deinitialize(
|
||||
loresource_music_set_t* set
|
||||
);
|
||||
|
||||
loresource_music_t*
|
||||
loresource_music_set_get(
|
||||
loresource_music_set_t* set,
|
||||
loresource_music_id_t id
|
||||
);
|
||||
|
@@ -21,10 +21,10 @@ void loresource_set_initialize(
|
||||
assert(mixer != NULL);
|
||||
assert(jukebox_format_valid(format));
|
||||
|
||||
*res = (typeof(*res)) {
|
||||
.sound = loresource_sound_new(mixer, format),
|
||||
};
|
||||
loresource_music_initialize(&res->music, mixer, format);
|
||||
*res = (typeof(*res)) {0};
|
||||
|
||||
loresource_sound_set_initialize(&res->sound, mixer, format);
|
||||
loresource_music_set_initialize(&res->music, mixer, format);
|
||||
loresource_font_initialize(&res->font);
|
||||
loresource_set_change_language(res, lang);
|
||||
}
|
||||
@@ -33,8 +33,8 @@ void loresource_set_deinitialize(loresource_set_t* res) {
|
||||
assert(res != NULL);
|
||||
|
||||
loresource_font_deinitialize(&res->font);
|
||||
loresource_sound_delete(res->sound);
|
||||
loresource_music_deinitialize(&res->music);
|
||||
loresource_music_set_deinitialize(&res->music);
|
||||
loresource_sound_set_deinitialize(&res->sound);
|
||||
}
|
||||
|
||||
void loresource_set_change_language(
|
||||
|
@@ -9,9 +9,9 @@
|
||||
#include "./sound.h"
|
||||
|
||||
typedef struct {
|
||||
loresource_sound_t* sound;
|
||||
loresource_music_t music;
|
||||
loresource_font_t font;
|
||||
loresource_sound_set_t sound;
|
||||
loresource_music_set_t music;
|
||||
loresource_font_t font;
|
||||
|
||||
loresource_language_t lang;
|
||||
} loresource_set_t;
|
||||
|
@@ -12,252 +12,201 @@
|
||||
#include "util/jukebox/sound.h"
|
||||
#include "util/math/algorithm.h"
|
||||
#include "util/math/rational.h"
|
||||
#include "util/memory/memory.h"
|
||||
|
||||
/* resources */
|
||||
#include "anysrc/sound/bomb.mp3.h"
|
||||
#include "anysrc/sound/enemy_shoot.mp3.h"
|
||||
#include "anysrc/sound/enemy_trigger.mp3.h"
|
||||
#include "anysrc/sound/damage.mp3.h"
|
||||
#include "anysrc/sound/dodge.mp3.h"
|
||||
#include "anysrc/sound/dying.mp3.h"
|
||||
#include "anysrc/sound/guard.mp3.h"
|
||||
#include "anysrc/sound/player_shoot.mp3.h"
|
||||
#include "anysrc/sound/player_trigger.mp3.h"
|
||||
#include "anysrc/sound/reflection.mp3.h"
|
||||
#include "anysrc/sound/touch_gate.mp3.h"
|
||||
#include "core/loresource/anysrc/sound/bomb.mp3.h"
|
||||
#include "core/loresource/anysrc/sound/enemy_shoot.mp3.h"
|
||||
#include "core/loresource/anysrc/sound/enemy_trigger.mp3.h"
|
||||
#include "core/loresource/anysrc/sound/damage.mp3.h"
|
||||
#include "core/loresource/anysrc/sound/dodge.mp3.h"
|
||||
#include "core/loresource/anysrc/sound/dying.mp3.h"
|
||||
#include "core/loresource/anysrc/sound/guard.mp3.h"
|
||||
#include "core/loresource/anysrc/sound/player_shoot.mp3.h"
|
||||
#include "core/loresource/anysrc/sound/player_trigger.mp3.h"
|
||||
#include "core/loresource/anysrc/sound/reflection.mp3.h"
|
||||
#include "core/loresource/anysrc/sound/touch_gate.mp3.h"
|
||||
|
||||
#define LORESOURCE_SOUND_DECL_(PROC) \
|
||||
PROC(bomb); \
|
||||
PROC(enemy_shoot); \
|
||||
PROC(enemy_trigger); \
|
||||
PROC(damage); \
|
||||
PROC(dodge); \
|
||||
PROC(dying); \
|
||||
PROC(guard); \
|
||||
PROC(player_shoot); \
|
||||
PROC(player_trigger); \
|
||||
PROC(reflection); \
|
||||
PROC(touch_gate);
|
||||
#define MAX_CONCURRENT_PLAYS_ 32
|
||||
|
||||
#define LORESOURCE_SOUND_EACH_(PROC) do { \
|
||||
LORESOURCE_SOUND_DECL_(PROC) \
|
||||
} while (0)
|
||||
|
||||
struct loresource_sound_t {
|
||||
struct {
|
||||
# define each_(n) \
|
||||
jukebox_sound_buffer_t* n
|
||||
|
||||
LORESOURCE_SOUND_DECL_(each_);
|
||||
|
||||
# undef each_
|
||||
} buffers;
|
||||
|
||||
struct {
|
||||
# define each_(n) \
|
||||
jukebox_sound_t* n
|
||||
|
||||
LORESOURCE_SOUND_DECL_(each_);
|
||||
|
||||
# undef each_
|
||||
} sounds;
|
||||
|
||||
struct {
|
||||
jukebox_delay_t* delay;
|
||||
jukebox_composite_t* compo;
|
||||
} combat;
|
||||
struct {
|
||||
jukebox_delay_t* delay;
|
||||
jukebox_composite_t* compo;
|
||||
} env;
|
||||
struct {
|
||||
jukebox_composite_t* compo;
|
||||
} direction;
|
||||
|
||||
struct {
|
||||
jukebox_amp_t amp;
|
||||
jukebox_composite_t* compo;
|
||||
} root;
|
||||
};
|
||||
|
||||
#define LORESOURCE_SOUND_MAX_CONCURRENT_PLAY 32
|
||||
|
||||
static void loresource_sound_initialize_combat_(
|
||||
loresource_sound_t* sound,
|
||||
static void loresource_sound_set_initialize_combat_(
|
||||
loresource_sound_set_t* set,
|
||||
jukebox_mixer_t* mixer,
|
||||
const jukebox_format_t* format) {
|
||||
assert(sound != NULL);
|
||||
assert(set != NULL);
|
||||
assert(mixer != NULL);
|
||||
assert(jukebox_format_valid(format));
|
||||
|
||||
typeof(sound->sounds)* s = &sound->sounds;
|
||||
typeof(sound->combat)* c = &sound->combat;
|
||||
typeof(set->combat)* c = &set->combat;
|
||||
|
||||
c->delay = jukebox_delay_new(format, &rational(5, 100), .1f, .4f);
|
||||
|
||||
c->compo = jukebox_composite_new(format, 7);
|
||||
jukebox_composite_add_effect(c->compo, (jukebox_effect_t*) s->damage);
|
||||
jukebox_composite_add_effect(c->compo, (jukebox_effect_t*) s->dodge);
|
||||
jukebox_composite_add_effect(c->compo, (jukebox_effect_t*) s->guard);
|
||||
jukebox_composite_add_effect(c->compo, (jukebox_effect_t*) s->player_shoot);
|
||||
jukebox_composite_add_effect(c->compo, (jukebox_effect_t*) s->player_trigger);
|
||||
jukebox_composite_add_effect(c->compo, (jukebox_effect_t*) s->reflection);
|
||||
jukebox_composite_add_effect(c->compo, (jukebox_effect_t*) c->delay);
|
||||
# define add_(NAME) \
|
||||
jukebox_composite_add_effect( \
|
||||
c->compo, \
|
||||
(jukebox_effect_t*) set->items[LORESOURCE_SOUND_ID_##NAME].sound)
|
||||
add_(DAMAGE);
|
||||
add_(DODGE);
|
||||
add_(GUARD);
|
||||
add_(PLAYER_SHOOT);
|
||||
add_(PLAYER_TRIGGER);
|
||||
add_(REFLECTION);
|
||||
# undef add_
|
||||
|
||||
jukebox_composite_add_effect(c->compo, (jukebox_effect_t*) c->delay);
|
||||
jukebox_composite_play(c->compo);
|
||||
}
|
||||
static void loresource_sound_deinitialize_combat_(loresource_sound_t* sound) {
|
||||
assert(sound != NULL);
|
||||
static void loresource_sound_set_deinitialize_combat_(
|
||||
loresource_sound_set_t* set) {
|
||||
assert(set != NULL);
|
||||
|
||||
typeof(sound->combat)* c = &sound->combat;
|
||||
typeof(set->combat)* c = &set->combat;
|
||||
|
||||
jukebox_composite_delete(c->compo);
|
||||
jukebox_delay_delete(c->delay);
|
||||
}
|
||||
|
||||
static void loresource_sound_initialize_env_(
|
||||
loresource_sound_t* sound,
|
||||
static void loresource_sound_set_initialize_env_(
|
||||
loresource_sound_set_t* set,
|
||||
jukebox_mixer_t* mixer,
|
||||
const jukebox_format_t* format) {
|
||||
assert(sound != NULL);
|
||||
assert(set != NULL);
|
||||
assert(mixer != NULL);
|
||||
assert(jukebox_format_valid(format));
|
||||
|
||||
typeof(sound->sounds)* s = &sound->sounds;
|
||||
typeof(sound->env)* e = &sound->env;
|
||||
typeof(set->env)* e = &set->env;
|
||||
|
||||
e->delay = jukebox_delay_new(format, &rational(1, 10), .3f, .4f);
|
||||
|
||||
e->compo = jukebox_composite_new(format, 5);
|
||||
jukebox_composite_add_effect(e->compo, (jukebox_effect_t*) s->bomb);
|
||||
jukebox_composite_add_effect(e->compo, (jukebox_effect_t*) s->enemy_shoot);
|
||||
jukebox_composite_add_effect(e->compo, (jukebox_effect_t*) s->enemy_trigger);
|
||||
jukebox_composite_add_effect(e->compo, (jukebox_effect_t*) s->touch_gate);
|
||||
jukebox_composite_add_effect(e->compo, (jukebox_effect_t*) e->delay);
|
||||
# define add_(NAME) \
|
||||
jukebox_composite_add_effect( \
|
||||
e->compo, \
|
||||
(jukebox_effect_t*) set->items[LORESOURCE_SOUND_ID_##NAME].sound)
|
||||
add_(BOMB);
|
||||
add_(ENEMY_SHOOT);
|
||||
add_(ENEMY_TRIGGER);
|
||||
add_(TOUCH_GATE);
|
||||
# undef add_
|
||||
|
||||
jukebox_composite_add_effect(e->compo, (jukebox_effect_t*) e->delay);
|
||||
jukebox_composite_play(e->compo);
|
||||
}
|
||||
static void loresource_sound_deinitialize_env_(loresource_sound_t* sound) {
|
||||
assert(sound != NULL);
|
||||
static void loresource_sound_set_deinitialize_env_(
|
||||
loresource_sound_set_t* set) {
|
||||
assert(set != NULL);
|
||||
|
||||
typeof(sound->env)* e = &sound->env;
|
||||
typeof(set->env)* e = &set->env;
|
||||
|
||||
jukebox_composite_delete(e->compo);
|
||||
jukebox_delay_delete(e->delay);
|
||||
}
|
||||
|
||||
static void loresource_sound_initialize_direction_(
|
||||
loresource_sound_t* sound,
|
||||
static void loresource_sound_set_initialize_direction_(
|
||||
loresource_sound_set_t* set,
|
||||
jukebox_mixer_t* mixer,
|
||||
const jukebox_format_t* format) {
|
||||
assert(sound != NULL);
|
||||
assert(set != NULL);
|
||||
assert(mixer != NULL);
|
||||
assert(jukebox_format_valid(format));
|
||||
|
||||
typeof(sound->sounds)* s = &sound->sounds;
|
||||
typeof(sound->direction)* d = &sound->direction;
|
||||
typeof(set->direction)* d = &set->direction;
|
||||
|
||||
d->compo = jukebox_composite_new(format, 1);
|
||||
jukebox_composite_add_effect(d->compo, (jukebox_effect_t*) s->dying);
|
||||
|
||||
# define add_(NAME) \
|
||||
jukebox_composite_add_effect( \
|
||||
d->compo, \
|
||||
(jukebox_effect_t*) set->items[LORESOURCE_SOUND_ID_##NAME].sound)
|
||||
add_(DYING);
|
||||
# undef add_
|
||||
|
||||
jukebox_composite_play(d->compo);
|
||||
}
|
||||
static void loresource_sound_deinitialize_direction_(loresource_sound_t* sound) {
|
||||
assert(sound != NULL);
|
||||
static void loresource_sound_set_deinitialize_direction_(
|
||||
loresource_sound_set_t* set) {
|
||||
assert(set != NULL);
|
||||
|
||||
typeof(sound->direction)* d = &sound->direction;
|
||||
typeof(set->direction)* d = &set->direction;
|
||||
|
||||
jukebox_composite_delete(d->compo);
|
||||
}
|
||||
|
||||
loresource_sound_t* loresource_sound_new(
|
||||
jukebox_mixer_t* mixer, const jukebox_format_t* format) {
|
||||
void loresource_sound_set_initialize(
|
||||
loresource_sound_set_t* set,
|
||||
jukebox_mixer_t* mixer,
|
||||
const jukebox_format_t* format) {
|
||||
assert(set != NULL);
|
||||
assert(mixer != NULL);
|
||||
assert(jukebox_format_valid(format));
|
||||
|
||||
loresource_sound_t* sound = memory_new(sizeof(*sound));
|
||||
*sound = (typeof(*sound)) {0};
|
||||
*set = (typeof(*set)) {0};
|
||||
|
||||
# define each_(n) do { \
|
||||
sound->buffers.n = jukebox_sound_buffer_new_from_memory_mp3( \
|
||||
# define each_(NAME, name) do { \
|
||||
jukebox_sound_buffer_t* buf = jukebox_sound_buffer_new_from_memory_mp3( \
|
||||
format, \
|
||||
loresource_sound_##n##_mp3_, \
|
||||
sizeof(loresource_sound_##n##_mp3_)); \
|
||||
sound->sounds.n = jukebox_sound_new( \
|
||||
sound->buffers.n, LORESOURCE_SOUND_MAX_CONCURRENT_PLAY); \
|
||||
loresource_sound_##name##_mp3_, \
|
||||
sizeof(loresource_sound_##name##_mp3_)); \
|
||||
jukebox_sound_t* snd = jukebox_sound_new(buf, MAX_CONCURRENT_PLAYS_); \
|
||||
set->items[LORESOURCE_SOUND_ID_##NAME] = (loresource_sound_t) { \
|
||||
.buffer = buf, \
|
||||
.sound = snd, \
|
||||
}; \
|
||||
} while (0)
|
||||
|
||||
LORESOURCE_SOUND_EACH_(each_);
|
||||
|
||||
LORESOURCE_SOUND_ID_EACH(each_);
|
||||
# undef each_
|
||||
|
||||
sound->root.compo = jukebox_composite_new(format, 4);
|
||||
set->root.compo = jukebox_composite_new(format, 4);
|
||||
|
||||
loresource_sound_initialize_combat_(sound, mixer, format);
|
||||
loresource_sound_set_initialize_combat_(set, mixer, format);
|
||||
jukebox_composite_add_effect(
|
||||
sound->root.compo, (jukebox_effect_t*) sound->combat.compo);
|
||||
set->root.compo, (jukebox_effect_t*) set->combat.compo);
|
||||
|
||||
loresource_sound_initialize_env_(sound, mixer, format);
|
||||
loresource_sound_set_initialize_env_(set, mixer, format);
|
||||
jukebox_composite_add_effect(
|
||||
sound->root.compo, (jukebox_effect_t*) sound->env.compo);
|
||||
set->root.compo, (jukebox_effect_t*) set->env.compo);
|
||||
|
||||
loresource_sound_initialize_direction_(sound, mixer, format);
|
||||
loresource_sound_set_initialize_direction_(set, mixer, format);
|
||||
jukebox_composite_add_effect(
|
||||
sound->root.compo, (jukebox_effect_t*) sound->direction.compo);
|
||||
set->root.compo, (jukebox_effect_t*) set->direction.compo);
|
||||
|
||||
jukebox_amp_initialize(&sound->root.amp, format);
|
||||
jukebox_composite_add_effect(sound->root.compo, &sound->root.amp.super);
|
||||
jukebox_amp_initialize(&set->root.amp, format);
|
||||
jukebox_composite_add_effect(set->root.compo, &set->root.amp.super);
|
||||
|
||||
jukebox_amp_change_volume(&sound->root.amp, 1, &rational(1, 1));
|
||||
jukebox_composite_play(sound->root.compo);
|
||||
jukebox_amp_change_volume(&set->root.amp, 1, &rational(1, 1));
|
||||
jukebox_composite_play(set->root.compo);
|
||||
|
||||
jukebox_mixer_add_effect(mixer, (jukebox_effect_t*) sound->root.compo);
|
||||
return sound;
|
||||
jukebox_mixer_add_effect(mixer, (jukebox_effect_t*) set->root.compo);
|
||||
}
|
||||
|
||||
void loresource_sound_delete(loresource_sound_t* sound) {
|
||||
if (sound == NULL) return;
|
||||
void loresource_sound_set_deinitialize(loresource_sound_set_t* set) {
|
||||
assert(set != NULL);
|
||||
|
||||
jukebox_composite_delete(sound->root.compo);
|
||||
jukebox_amp_deinitialize(&sound->root.amp);
|
||||
jukebox_composite_delete(set->root.compo);
|
||||
jukebox_amp_deinitialize(&set->root.amp);
|
||||
|
||||
loresource_sound_deinitialize_combat_(sound);
|
||||
loresource_sound_deinitialize_env_(sound);
|
||||
loresource_sound_deinitialize_direction_(sound);
|
||||
loresource_sound_set_deinitialize_combat_(set);
|
||||
loresource_sound_set_deinitialize_env_(set);
|
||||
loresource_sound_set_deinitialize_direction_(set);
|
||||
|
||||
# define each_(n) do { \
|
||||
jukebox_sound_delete(sound->sounds.n); \
|
||||
jukebox_sound_buffer_delete(sound->buffers.n); \
|
||||
} while (0)
|
||||
|
||||
LORESOURCE_SOUND_EACH_(each_);
|
||||
|
||||
# undef each_
|
||||
|
||||
memory_delete(sound);
|
||||
for (size_t i = 0; i < LORESOURCE_SOUND_ID_COUNT; ++i) {
|
||||
jukebox_sound_delete(set->items[i].sound);
|
||||
jukebox_sound_buffer_delete(set->items[i].buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void loresource_sound_play(loresource_sound_t* sound, const char* name) {
|
||||
assert(sound != NULL);
|
||||
void loresource_sound_set_play(
|
||||
loresource_sound_set_t* set, loresource_sound_id_t id) {
|
||||
assert(set != NULL);
|
||||
|
||||
# define each_(n) do { \
|
||||
if (strcmp(name, #n) == 0) { \
|
||||
jukebox_sound_play(sound->sounds.n); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
LORESOURCE_SOUND_EACH_(each_);
|
||||
|
||||
# undef each_
|
||||
jukebox_sound_play(set->items[id].sound);
|
||||
}
|
||||
|
||||
void loresource_sound_change_master_volume(
|
||||
loresource_sound_t* sound, float v, const rational_t* duration) {
|
||||
assert(sound != NULL);
|
||||
void loresource_sound_set_change_master_volume(
|
||||
loresource_sound_set_t* set, float v, const rational_t* duration) {
|
||||
assert(set != NULL);
|
||||
assert(MATH_FLOAT_VALID(v));
|
||||
assert(rational_valid(duration));
|
||||
|
||||
jukebox_amp_change_volume(&sound->root.amp, v, duration);
|
||||
jukebox_amp_change_volume(&set->root.amp, v, duration);
|
||||
}
|
||||
|
@@ -2,33 +2,79 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "util/jukebox/amp.h"
|
||||
#include "util/jukebox/composite.h"
|
||||
#include "util/jukebox/delay.h"
|
||||
#include "util/jukebox/format.h"
|
||||
#include "util/jukebox/mixer.h"
|
||||
#include "util/jukebox/sound.h"
|
||||
#include "util/math/rational.h"
|
||||
|
||||
struct loresource_sound_t;
|
||||
typedef struct loresource_sound_t loresource_sound_t;
|
||||
typedef enum {
|
||||
/* BENUM BEGIN loresource_sound_id */
|
||||
LORESOURCE_SOUND_ID_BOMB,
|
||||
LORESOURCE_SOUND_ID_DAMAGE,
|
||||
LORESOURCE_SOUND_ID_DODGE,
|
||||
LORESOURCE_SOUND_ID_DYING,
|
||||
LORESOURCE_SOUND_ID_ENEMY_SHOOT,
|
||||
LORESOURCE_SOUND_ID_ENEMY_TRIGGER,
|
||||
LORESOURCE_SOUND_ID_GUARD,
|
||||
LORESOURCE_SOUND_ID_PLAYER_SHOOT,
|
||||
LORESOURCE_SOUND_ID_PLAYER_TRIGGER,
|
||||
LORESOURCE_SOUND_ID_REFLECTION,
|
||||
LORESOURCE_SOUND_ID_TOUCH_GATE,
|
||||
/* BENUM END */
|
||||
} loresource_sound_id_t;
|
||||
|
||||
loresource_sound_t* /* OWNERSHIP */
|
||||
loresource_sound_new(
|
||||
#include "core/loresource/benum/sound.h"
|
||||
|
||||
typedef struct {
|
||||
jukebox_sound_buffer_t* buffer;
|
||||
jukebox_sound_t* sound;
|
||||
} loresource_sound_t;
|
||||
|
||||
typedef struct {
|
||||
loresource_sound_t items[LORESOURCE_SOUND_ID_COUNT];
|
||||
|
||||
struct {
|
||||
jukebox_delay_t* delay;
|
||||
jukebox_composite_t* compo;
|
||||
} combat;
|
||||
struct {
|
||||
jukebox_delay_t* delay;
|
||||
jukebox_composite_t* compo;
|
||||
} env;
|
||||
struct {
|
||||
jukebox_composite_t* compo;
|
||||
} direction;
|
||||
|
||||
struct {
|
||||
jukebox_amp_t amp;
|
||||
jukebox_composite_t* compo;
|
||||
} root;
|
||||
} loresource_sound_set_t;
|
||||
|
||||
void
|
||||
loresource_sound_set_initialize(
|
||||
loresource_sound_set_t* set,
|
||||
jukebox_mixer_t* mixer,
|
||||
const jukebox_format_t* format
|
||||
);
|
||||
|
||||
void
|
||||
loresource_sound_delete(
|
||||
loresource_sound_t* sound /* OWNERSHIP */
|
||||
loresource_sound_set_deinitialize(
|
||||
loresource_sound_set_t* set
|
||||
);
|
||||
|
||||
void
|
||||
loresource_sound_play(
|
||||
loresource_sound_t* sound,
|
||||
const char* name
|
||||
loresource_sound_set_play(
|
||||
loresource_sound_set_t* set,
|
||||
loresource_sound_id_t id
|
||||
);
|
||||
|
||||
void
|
||||
loresource_sound_change_master_volume(
|
||||
loresource_sound_t* sound,
|
||||
float v,
|
||||
const rational_t* duration
|
||||
loresource_sound_set_change_master_volume(
|
||||
loresource_sound_set_t* set,
|
||||
float v,
|
||||
const rational_t* duration
|
||||
);
|
||||
|
@@ -15,20 +15,30 @@ static dictres_item_t loresource_text_jp_[] = {
|
||||
{"biome_boss_big_warder", u8"巨頭の看守"},
|
||||
{"biome_boss_greedy_scientist", u8"貪欲な科学者"},
|
||||
|
||||
{"boss_big_warder_line0", u8"知能すら持たぬ家畜に踏み殺された仲間たちへの哀れみは"},
|
||||
{"boss_big_warder_line1", u8"いまや羨望へとその形を変えた"},
|
||||
{"boss_big_warder_line0", u8"知能すら持たぬ家畜に踏み殺された仲間たちへの哀れみは"},
|
||||
{"boss_big_warder_line1", u8"いまや羨望へとその形を変えた"},
|
||||
{"boss_big_warder_kill_line", u8"私はまだ待たなければならいのか"},
|
||||
|
||||
{"boss_greedy_scientist_line0", u8"その選択はお前自身のものか?"},
|
||||
{"boss_greedy_scientist_line1", u8"胸を張ってそうだと,私達の前で言えるのか?"},
|
||||
|
||||
{"boss_theists_child_line0", u8"全ては計画通りだった"},
|
||||
{"boss_theists_child_line1", u8"しかし空論は未だ宙に浮いたまま"},
|
||||
{"boss_theists_child_line2", u8"それが\"創造主\"の意志だというのか"},
|
||||
{"boss_theists_child_line0", u8"全ては計画通りだった"},
|
||||
{"boss_theists_child_line1", u8"しかし空論は未だ宙に浮いたまま"},
|
||||
{"boss_theists_child_line2", u8"それが\"創造主\"の意志だというのか"},
|
||||
{"boss_theists_child_dead_line", u8"またか,また,私は失敗したのか"},
|
||||
{"boss_theists_child_kill_line0", u8"私の邪魔をしないでくれ"},
|
||||
{"boss_theists_child_kill_line1", u8"承けた使命を果たさなきゃならない"},
|
||||
|
||||
{"effect_curse", u8"呪縛"},
|
||||
{"effect_amnesia", u8"忘却"},
|
||||
{"effect_lost", u8"喪失"},
|
||||
|
||||
{"popup_new_stance_head", u8"NEW STANCE FOUND"},
|
||||
|
||||
{"stance_unknown_name", u8"???"},
|
||||
{"stance_unknown_desc", u8"???"},
|
||||
{"stance_unknown_note", u8"???"},
|
||||
|
||||
{"stance_missionary_name", u8"宣教師"},
|
||||
{"stance_missionary_desc",
|
||||
u8" あなたは自らの使命を果たすために歩き続ける.\n\n"
|
||||
@@ -57,12 +67,15 @@ static dictres_item_t loresource_text_jp_[] = {
|
||||
{"stance_unfinisher_name", u8"未完走者"},
|
||||
{"stance_unfinisher_desc",
|
||||
u8" 幾度締め上げようと再生する細胞は永遠への敬遠と共に能力をもたらす.\n\n"
|
||||
u8" - 信仰が50%以上残っている場合にあなたの狂気は徐々に回復する.\n"
|
||||
u8" - 信仰をすべて失ったとき,狂気の減少速度が増加する."},
|
||||
u8" - 信仰が50%以上残っている場合にあなたの狂気は徐々に回復する."},
|
||||
{"stance_unfinisher_note",
|
||||
u8"「忌々しい奴らに殺された仲間たちを,昔は気の毒だと思っていたよ."
|
||||
u8"今は妬みしか感じない.」"},
|
||||
|
||||
{"stance_betrayer_name", u8"背信者"},
|
||||
{"stance_betrayer_desc", u8"NOT IMPLEMENTED"},
|
||||
{"stance_betrayer_note", u8"NOT IMPLEMENTED"},
|
||||
|
||||
{"menu_exit", "EXIT"},
|
||||
|
||||
{"title_authors", u8"catfoot"},
|
||||
|
Reference in New Issue
Block a user