diff options
author | Takamichi Horikawa <takamichiho@gmail.com> | 2017-04-15 01:00:20 +0900 |
---|---|---|
committer | Takamichi Horikawa <takamichiho@gmail.com> | 2017-04-15 01:00:20 +0900 |
commit | 680ab52d9e151676b8f90d105b23d2d0d89b0471 (patch) | |
tree | 5a05e82900393d2e1ecdf034cf1735d4ebfaec98 /gtk | |
parent | 428126ee4c8802a4b5f9c9ee491d54013857741b (diff) |
add fmdsp fft analyzer
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/Makefile.am | 4 | ||||
-rw-r--r-- | gtk/fmplayer.xpm | 2 | ||||
-rw-r--r-- | gtk/fmplayer32.xpm | 2 | ||||
-rw-r--r-- | gtk/main.c | 23 |
4 files changed, 26 insertions, 5 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am index fb06655..8777418 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -16,7 +16,8 @@ FMDRIVER_SRC=../fmdriver/fmdriver_fmp.c \ FMDSP_SRC=../fmdsp/fmdsp.c \ ../fmdsp/fmdsp-vramlookup-c.c \ ../fmdsp/font_rom.c \ - ../fmdsp/font_fmdsp_small.c + ../fmdsp/font_fmdsp_small.c \ + ../fmdsp/fmdsp_platform_unix.c #fmplayer_CFLAGS=$(CFLAGS) #CFLAGS= @@ -48,6 +49,7 @@ fmplayer_SOURCES=main.c \ ../common/fmplayer_file_gio.c \ ../common/fmplayer_work_opna.c \ ../common/fmplayer_drumrom_unix.c \ + ../fft/fft.c \ $(LIBOPNA_SRC) \ $(FMDRIVER_SRC) \ $(FMDSP_SRC) diff --git a/gtk/fmplayer.xpm b/gtk/fmplayer.xpm index d52d9f4..87ae7a6 100644 --- a/gtk/fmplayer.xpm +++ b/gtk/fmplayer.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char *fmplayer_xpm_16[] = { +static const char *fmplayer_xpm_16[] = { /* columns rows colors chars-per-pixel */ "16 16 4 1 ", " c #40A040", diff --git a/gtk/fmplayer32.xpm b/gtk/fmplayer32.xpm index 062d12e..a97a327 100644 --- a/gtk/fmplayer32.xpm +++ b/gtk/fmplayer32.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char *fmplayer_xpm_32[] = { +static const char *fmplayer_xpm_32[] = { /* columns rows colors chars-per-pixel */ "32 32 8 1 ", " c gray25", @@ -19,6 +19,7 @@ #include "oscilloview.h" #include "wavesave.h" #include "common/fmplayer_common.h" +#include "fft/fft.h" #include "fmplayer.xpm" #include "fmplayer32.xpm" @@ -58,8 +59,12 @@ static struct { const char *current_uri; bool oscillo_should_update; struct oscillodata oscillodata_audiothread[LIBOPNA_OSCILLO_TRACK_COUNT]; + atomic_flag at_fftdata_flag; + struct fmplayer_fft_data at_fftdata; + struct fmplayer_fft_input_data fftdata; } g = { - .oscillo_should_update = true + .oscillo_should_update = true, + .at_fftdata_flag = ATOMIC_FLAG_INIT, }; static void quit(void) { @@ -140,6 +145,11 @@ static int pastream_cb(const void *inptr, void *outptr, unsigned long frames, atomic_flag_clear_explicit(&oscilloview_g.flag, memory_order_release); } } + if (!atomic_flag_test_and_set_explicit( + &g.at_fftdata_flag, memory_order_acquire)) { + fft_write(&g.at_fftdata, buf, frames); + atomic_flag_clear_explicit(&g.at_fftdata_flag, memory_order_release); + } return paContinue; } @@ -228,6 +238,7 @@ static bool openfile(const char *uri) { fmdsp_vram_init(&g.fmdsp, &g.work, g.vram); Pa_StartStream(g.pastream); g.pa_paused = false; + g.work.paused = false; { const char *turi = strdup(uri); free((void *)g.current_uri); @@ -282,7 +293,12 @@ static gboolean draw_cb(GtkWidget *w, gpointer p) { (void)w; (void)p; - fmdsp_update(&g.fmdsp, &g.work, &g.opna, g.vram); + if (!atomic_flag_test_and_set_explicit( + &g.at_fftdata_flag, memory_order_acquire)) { + memcpy(&g.fftdata.fdata, &g.at_fftdata, sizeof(g.fftdata)); + atomic_flag_clear_explicit(&g.at_fftdata_flag, memory_order_release); + } + fmdsp_update(&g.fmdsp, &g.work, &g.opna, g.vram, &g.fftdata); fmdsp_vrampalette(&g.fmdsp, g.vram, g.vram32, g.vram32_stride); cairo_surface_t *s = cairo_image_surface_create_for_data( g.vram32, CAIRO_FORMAT_RGB24, PC98_W, PC98_H, g.vram32_stride); @@ -391,9 +407,11 @@ static gboolean key_press_cb(GtkWidget *w, if (g.pa_paused) { Pa_StartStream(g.pastream); g.pa_paused = false; + g.work.paused = false; } else { Pa_StopStream(g.pastream); g.pa_paused = true; + g.work.paused = true; } break; case GDK_KEY_F11: @@ -481,6 +499,7 @@ int main(int argc, char **argv) { if (__builtin_cpu_supports("sse2")) opna_ssg_sinc_calc_func = opna_ssg_sinc_calc_sse2; if (__builtin_cpu_supports("ssse3")) fmdsp_vramlookup_func = fmdsp_vramlookup_ssse3; #endif + fft_init_table(); load_fontrom(); gtk_init(&argc, &argv); { |