From 2ebb8da275da1aa67d148d8ea4ddc1a3e94bd019 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sun, 4 Aug 2019 16:51:50 -0400 Subject: Mikmod plugin improvements - Improved sound quality (use 44.1KHz) - Conventional mixer is now used - Playback is performed in a separate thread - Speech feedback in menus Patch by Igor Poretsky Change-Id: I13baa224cefd67aefe6d62b988971bfbd421757d --- apps/lang/english.lang | 114 ++++++++++++++++++++++++++++++++++++++ apps/lang/russian.lang | 100 +++++++++++++++++++++++++++++++++ apps/plugins/mikmod/mikmod.c | 57 ++++++++++--------- apps/plugins/mikmod/mikmod_supp.h | 8 --- 4 files changed, 246 insertions(+), 33 deletions(-) diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 075272ef09..b77ae0afb7 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -15919,3 +15919,117 @@ id: VOICE_BAT_BENCH_KEYS *: "Failed to gather information" + + id: LANG_SWAP_CHANNELS + desc: in sound_settings + user: core + + *: "Swap Channels" + + + *: "Swap Channels" + + + *: "Swap Channels" + + + + id: LANG_PANNING_SEPARATION + desc: in mikmod settings menu + user: core + + *: none + swcodec: "Panning Separation" + lowmem: none + + + *: none + swcodec: "Panning Separation" + lowmem: none + + + *: none + swcodec: "Panning Separation" + lowmem: none + + + + id: LANG_REVERBERATION + desc: in mikmod settings menu + user: core + + *: none + swcodec: "Reverberation" + lowmem: none + + + *: none + swcodec: "Reverberation" + lowmem: none + + + *: none + swcodec: "Reverberation" + lowmem: none + + + + id: LANG_INTERPOLATION + desc: in mikmod settings menu + user: core + + *: none + swcodec: "Interpolation" + lowmem: none + + + *: none + swcodec: "Interpolation" + lowmem: none + + + *: none + swcodec: "Interpolation" + lowmem: none + + + + id: LANG_MIKMOD_SURROUND + desc: in mikmod settings menu + user: core + + *: none + swcodec: "Surround" + lowmem: none + + + *: none + swcodec: "Surround" + lowmem: none + + + *: none + swcodec: "Surround" + lowmem: none + + + + id: LANG_CPU_BOOST + desc: in mikmod settings menu + user: core + + *: none + swcodec: "CPU Boost" + lowmem: none + + + *: none + swcodec: "CPU Boost" + lowmem: none + + + *: none + swcodec: "CPU Boost" + lowmem: none + + diff --git a/apps/lang/russian.lang b/apps/lang/russian.lang index 9d289580b5..7b7384a8c7 100644 --- a/apps/lang/russian.lang +++ b/apps/lang/russian.lang @@ -13784,3 +13784,103 @@ *: "" + + id: LANG_PANNING_SEPARATION + desc: in mikmod settings menu + user: core + + *: none + swcodec: "Panning Separation" + lowmem: none + + + *: none + swcodec: "Панорама" + lowmem: none + + + *: none + swcodec: "Панорама" + lowmem: none + + + + id: LANG_REVERBERATION + desc: in mikmod settings menu + user: core + + *: none + swcodec: "Reverberation" + lowmem: none + + + *: none + swcodec: "Реверберация" + lowmem: none + + + *: none + swcodec: "Реверберация" + lowmem: none + + + + id: LANG_INTERPOLATION + desc: in mikmod settings menu + user: core + + *: none + swcodec: "Interpolation" + lowmem: none + + + *: none + swcodec: "Интерполяция" + lowmem: none + + + *: none + swcodec: "Интерполяция" + lowmem: none + + + + id: LANG_MIKMOD_SURROUND + desc: in mikmod settings menu + user: core + + *: none + swcodec: "Surround" + lowmem: none + + + *: none + swcodec: "Окружение" + lowmem: none + + + *: none + swcodec: "Окружение" + lowmem: none + + + + id: LANG_CPU_BOOST + desc: in mikmod settings menu + user: core + + *: none + swcodec: "CPU Boost" + lowmem: none + + + *: none + swcodec: "Разгон процессора" + lowmem: none + + + *: none + swcodec: "Разгон процессора" + lowmem: none + + diff --git a/apps/plugins/mikmod/mikmod.c b/apps/plugins/mikmod/mikmod.c index 3302fc306a..688baed56c 100644 --- a/apps/plugins/mikmod/mikmod.c +++ b/apps/plugins/mikmod/mikmod.c @@ -8,7 +8,7 @@ #undef SYNC #ifdef SIMULATOR #define SYNC -#elif NUM_CORES > 1 +#else #define USETHREADS #endif @@ -525,10 +525,14 @@ static int settings_menu(void) { int selection = 0; - MENUITEM_STRINGLIST(settings_menu, "Mikmod Settings", NULL, "Panning Separation", - "Reverberation", "Interpolation", "Reverse Channels", "Surround", + MENUITEM_STRINGLIST(settings_menu, "Mikmod Settings", NULL, + ID2P(LANG_PANNING_SEPARATION), + ID2P(LANG_REVERBERATION), + ID2P(LANG_INTERPOLATION), + ID2P(LANG_SWAP_CHANNELS), + ID2P(LANG_MIKMOD_SURROUND), #ifdef HAVE_ADJUSTABLE_CPU_FREQ - "CPU Boost" + ID2P(LANG_CPU_BOOST) #endif ); @@ -538,36 +542,36 @@ static int settings_menu(void) switch(selection) { case 0: - rb->set_int("Panning Separation", "", 1, + rb->set_int(rb->str(LANG_PANNING_SEPARATION), "", 1, &(settings.pansep), NULL, 8, 0, 128, NULL ); applysettings(); break; case 1: - rb->set_int("Reverberation", "", 1, + rb->set_int(rb->str(LANG_REVERBERATION), "", 1, &(settings.reverb), NULL, 1, 0, 15, NULL ); applysettings(); break; case 2: - rb->set_bool("Interpolation", &(settings.interp)); + rb->set_bool(rb->str(LANG_INTERPOLATION), &(settings.interp)); applysettings(); break; case 3: - rb->set_bool("Reverse Channels", &(settings.reverse)); + rb->set_bool(rb->str(LANG_SWAP_CHANNELS), &(settings.reverse)); applysettings(); break; case 4: - rb->set_bool("Surround", &(settings.surround)); + rb->set_bool(rb->str(LANG_MIKMOD_SURROUND), &(settings.surround)); applysettings(); break; case 5: - rb->set_bool("CPU Boost", &(settings.boost)); + rb->set_bool(rb->str(LANG_CPU_BOOST), &(settings.boost)); applysettings(); break; @@ -587,7 +591,9 @@ static int main_menu(void) int result; MENUITEM_STRINGLIST(main_menu,"Mikmod Main Menu",NULL, - "Settings", "Return", "Quit"); + ID2P(LANG_SETTINGS), + ID2P(LANG_RETURN), + ID2P(LANG_MENU_QUIT)); while (1) { switch (rb->do_menu(&main_menu,&selection, NULL, false)) @@ -620,8 +626,12 @@ static void thread(void) while (1) { - synthbuf(); - rb->queue_wait_w_tmo(&thread_q, &ev, HZ/20); + if (rb->queue_empty(&thread_q)) + { + synthbuf(); + rb->yield(); + } + else rb->queue_wait(&thread_q, &ev); switch (ev.id) { case EV_EXIT: return; @@ -660,7 +670,8 @@ static int playfile(char* filename) { display = DISPLAY_INFO; Player_Start(module); - rb->pcm_play_data(&get_more, NULL, NULL, 0); + rb->pcmbuf_fade(false, true); + rb->mixer_channel_play_data(PCM_MIXER_CHAN_PLAYBACK, get_more, NULL, 0); } #ifdef HAVE_ADJUSTABLE_CPU_FREQ @@ -798,14 +809,7 @@ static int playfile(char* filename) break; case ACTION_WPS_PLAY: - if(!Player_Paused()) - { - rb->pcm_play_stop(); - } - else - { - rb->pcm_play_data(&get_more, NULL, NULL, 0); - } + rb->mixer_channel_play_pause(PCM_MIXER_CHAN_PLAYBACK, Player_Paused()); Player_TogglePause(); break; @@ -870,6 +874,7 @@ static int playfile(char* filename) enum plugin_status plugin_start(const void* parameter) { enum plugin_status retval; + int orig_samplerate = rb->mixer_get_frequency(); if (parameter == NULL) { @@ -879,13 +884,14 @@ enum plugin_status plugin_start(const void* parameter) rb->lcd_setfont(FONT_SYSFIXED); + rb->talk_force_shutup(); rb->pcm_play_stop(); #if INPUT_SRC_CAPS != 0 /* Select playback */ rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); rb->audio_set_output_source(AUDIO_SRC_PLAYBACK); #endif - rb->pcm_set_frequency(SAMPLE_RATE); + rb->mixer_set_frequency(SAMPLE_RATE); audio_buffer = rb->plugin_get_audio_buffer((size_t *)&audio_buffer_free); @@ -922,8 +928,9 @@ enum plugin_status plugin_start(const void* parameter) MikMod_Exit(); - rb->pcm_play_stop(); - rb->pcm_set_frequency(HW_SAMPR_DEFAULT); + rb->pcmbuf_fade(false, false); + rb->mixer_channel_stop(PCM_MIXER_CHAN_PLAYBACK); + rb->mixer_set_frequency(orig_samplerate); if (retval == PLUGIN_OK) { diff --git a/apps/plugins/mikmod/mikmod_supp.h b/apps/plugins/mikmod/mikmod_supp.h index c76c283b92..29fa7ebf35 100644 --- a/apps/plugins/mikmod/mikmod_supp.h +++ b/apps/plugins/mikmod/mikmod_supp.h @@ -64,15 +64,7 @@ int mmsupp_sprintf(char *buf, const char *fmt, ... ); extern const struct plugin_api * rb; -#ifdef SIMULATOR -#define SAMPLE_RATE SAMPR_44 /* Simulator requires 44100Hz */ -#else -#if (HW_SAMPR_CAPS & SAMPR_CAP_22) /* use 22050Hz if we can */ -#define SAMPLE_RATE SAMPR_22 /* 22050 */ -#else #define SAMPLE_RATE SAMPR_44 /* 44100 */ -#endif -#endif #define BUF_SIZE 4096*8 #define NBUF 2 -- cgit v1.2.3