diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bank.c | 18 | ||||
-rw-r--r-- | src/object.c | 9 | ||||
-rw-r--r-- | src/synth.c | 15 | ||||
-rw-r--r-- | src/vox.c | 19 |
4 files changed, 48 insertions, 13 deletions
@@ -125,6 +125,9 @@ xas_bank_player *xas_bank_player_new(xas_bank *bank) { goto error_malloc_player; } + player->obj.start = (xas_object_start_callback)xas_bank_player_start; + player->obj.stop = (xas_object_stop_callback)xas_bank_player_stop; + player->bank = bank; player->status = XAS_BANK_PLAYER_STOPPED; player->gain = 0.0f; @@ -141,16 +144,21 @@ void xas_bank_player_destroy(xas_bank_player *player) { free(player); } -int xas_bank_player_start(xas_bank_player *player, - size_t entry, - float gain) { +int xas_bank_player_select(xas_bank_player *player, + size_t entry, + float gain) { + player->entry = entry; + player->gain = gain; + + return 0; +} + +int xas_bank_player_start(xas_bank_player *player) { if (player->status == XAS_BANK_PLAYER_PLAYING) { return 0; } player->status = XAS_BANK_PLAYER_PLAYING; - player->gain = gain; - player->entry = entry; player->index = 0; return 0; diff --git a/src/object.c b/src/object.c new file mode 100644 index 0000000..55ea4af --- /dev/null +++ b/src/object.c @@ -0,0 +1,9 @@ +#include <xas/object.h> + +int xas_object_start(xas_object *object) { + object->start(object); +} + +int xas_object_stop(xas_object *object) { + object->stop(object); +} diff --git a/src/synth.c b/src/synth.c index 86990e8..fddd2a0 100644 --- a/src/synth.c +++ b/src/synth.c @@ -99,6 +99,18 @@ static ssize_t synth_fill(xas_synth *synth, return count; } +static int synth_start(xas_synth *synth) { + xas_synth_start(synth); + + return 0; +} + +static int synth_stop(xas_synth *synth) { + xas_synth_stop(synth); + + return 0; +} + xas_synth *xas_synth_new(xas_audio_format format, size_t buffer_size, enum xas_synth_type type) { @@ -108,6 +120,9 @@ xas_synth *xas_synth_new(xas_audio_format format, goto error_malloc_synth; } + synth->obj.start = (xas_object_start_callback)synth_start; + synth->obj.stop = (xas_object_stop_callback)synth_stop; + synth->type = type; synth->state = XAS_SYNTH_IDLE; synth->phase = 0.0f; @@ -275,6 +275,9 @@ xas_vox *xas_vox_new_args(xas_audio_format format, goto error_malloc_vox; } + vox->obj.start = (xas_object_start_callback)xas_vox_generate; + vox->obj.stop = (xas_object_stop_callback)xas_vox_stop; + vox->text2wave_path = text2wave_path; vox->format.channels = XAS_AUDIO_MONO; @@ -394,14 +397,6 @@ int xas_vox_set_parameter_int(xas_vox *vox, return set_parameter_va(vox, name, "%d", value); } -int xas_vox_stop(xas_vox *vox) { - if (vox->state == XAS_VOX_ACTIVE) { - return vox_stop(vox); - } - - return 0; -} - int xas_vox_active(xas_vox *vox) { return vox->state == XAS_VOX_ACTIVE; } @@ -435,6 +430,14 @@ error_riff_open_fd: return -1; } +int xas_vox_stop(xas_vox *vox) { + if (vox->state == XAS_VOX_ACTIVE) { + return vox_stop(vox); + } + + return 0; +} + int xas_vox_vsayf(xas_vox *vox, const char *format, va_list args) { if (vox->state == XAS_VOX_IDLE && vox_start(vox) < 0) { goto error_vox_start; |