diff options
author | waker <wakeroid@gmail.com> | 2012-04-12 20:22:53 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2012-04-12 20:22:53 +0200 |
commit | 1d06cdb31bc39106ab50999a2b4f0b9acf8ffc19 (patch) | |
tree | 3e102ec245afb3ee77d4d0e0450dc3ca5e27adf7 | |
parent | 7420ed88b753badcdf51e9c9b731765658bde2c4 (diff) |
vis buffer is now always float/mono
-rw-r--r-- | deadbeef.h | 5 | ||||
-rw-r--r-- | plugins/gtkui/widgets.c | 133 | ||||
-rw-r--r-- | plugins/supereq/Fftsg_fl.c (renamed from plugins/supereq/Fftsg_fl.cpp) | 3 | ||||
-rw-r--r-- | plugins/supereq/Makefile.am | 43 | ||||
-rw-r--r-- | streamer.c | 35 | ||||
-rw-r--r-- | streamer.h | 4 |
6 files changed, 83 insertions, 140 deletions
@@ -309,7 +309,6 @@ enum ddb_sort_order_t { // audio memory constants #define DDB_AUDIO_MEMORY_FRAMES 1000 -#define DDB_AUDIO_MEMORY_BUFFER_SIZE (DDB_AUDIO_MEMORY_FRAMES*4*20) // typecasting macros #define DB_PLUGIN(x) ((DB_plugin_t *)(x)) @@ -765,8 +764,8 @@ typedef struct { // access real-time audio data (e.g. for visualization) // returns data size in bytes // fmt and data will be filled with last bytes that came to the output plugin - // data size must be at least DDB_AUDIO_MEMORY_BUFFER_SIZE - int (*audio_get_waveform_data) (ddb_waveformat_t *fmt, char *data); + // data size must be float[DDB_AUDIO_MEMORY_FRAMES] + void (*audio_get_waveform_data) (float *data); } DB_functions_t; // NOTE: an item placement must be selected like this diff --git a/plugins/gtkui/widgets.c b/plugins/gtkui/widgets.c index dbdbd50b..afe6c5fa 100644 --- a/plugins/gtkui/widgets.c +++ b/plugins/gtkui/widgets.c @@ -1717,25 +1717,21 @@ w_scope_draw_cb (void *data) { gboolean scope_draw (GtkWidget *widget, cairo_t *cr, gpointer user_data) { ddb_waveformat_t fmt; - char data[DDB_AUDIO_MEMORY_BUFFER_SIZE]; - int size = deadbeef->audio_get_waveform_data (&fmt, data); - if (fmt.channels && size > 0) { - cairo_set_source_rgb (cr, 0, 0, 0); - cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); - cairo_set_line_width (cr, 1); - GtkAllocation a; - gtk_widget_get_allocation (widget, &a); - short *samples = (short *)data; - - int nframes = size / (fmt.bps/8*fmt.channels); - float incr = nframes / (float)a.width; - float pos = 0; - for (int x = 0; x < a.width; x++, pos += incr) { - short s = max (samples[(int)pos*2], samples[(int)pos*2+1]); - cairo_line_to (cr, x, s * a.height/2 / 0x7fff + a.height/2); - } - cairo_stroke (cr); + float data[DDB_AUDIO_MEMORY_FRAMES]; + deadbeef->audio_get_waveform_data (data); + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); + cairo_set_line_width (cr, 1); + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); + + float incr = (float)DDB_AUDIO_MEMORY_FRAMES / a.width; + float pos = 0; + for (int x = 0; x < a.width; x++, pos += incr) { + float s = data[(int)pos]; + cairo_line_to (cr, x, s * a.height/2 / 0x7fff + a.height/2); } + cairo_stroke (cr); return FALSE; } @@ -1743,71 +1739,60 @@ scope_draw (GtkWidget *widget, cairo_t *cr, gpointer user_data) { gboolean scope_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { w_scope_t *w = user_data; - ddb_waveformat_t fmt; - char data[DDB_AUDIO_MEMORY_BUFFER_SIZE]; - int size = deadbeef->audio_get_waveform_data (&fmt, data); - if (fmt.channels && size > 0) { - GtkAllocation a; - gtk_widget_get_allocation (widget, &a); + float data[DDB_AUDIO_MEMORY_FRAMES]; + deadbeef->audio_get_waveform_data (data); + GtkAllocation a; + gtk_widget_get_allocation (widget, &a); - GdkGLDrawable *d = gtk_widget_get_gl_drawable (widget); - gdk_gl_drawable_gl_begin (d, w->glcontext); -// if (glXSwapIntervalSGI) { -// glXSwapIntervalSGI (1); -// } + GdkGLDrawable *d = gtk_widget_get_gl_drawable (widget); + gdk_gl_drawable_gl_begin (d, w->glcontext); + // if (glXSwapIntervalSGI) { + // glXSwapIntervalSGI (1); + // } - glClear (GL_COLOR_BUFFER_BIT); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - gluOrtho2D(0,a.width,a.height,0); - glMatrixMode (GL_MODELVIEW); - glViewport (0, 0, a.width, a.height); + glClear (GL_COLOR_BUFFER_BIT); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + gluOrtho2D(0,a.width,a.height,0); + glMatrixMode (GL_MODELVIEW); + glViewport (0, 0, a.width, a.height); #if 0 - // vsync test - static int box = 0; - static int speed = 5; - if (box > a.width-50) { - box = a.width-50; - speed = -5; - } - else if (box < 0) { - box = 0; - speed = 5; - } - box += speed; - - glBegin (GL_QUADS); - glVertex2f (box, 0); - glVertex2f (box+50, 0); - glVertex2f (box+50, 50); - glVertex2f (box, 50); - glEnd (); + // vsync test + static int box = 0; + static int speed = 5; + if (box > a.width-50) { + box = a.width-50; + speed = -5; + } + else if (box < 0) { + box = 0; + speed = 5; + } + box += speed; + + glBegin (GL_QUADS); + glVertex2f (box, 0); + glVertex2f (box+50, 0); + glVertex2f (box+50, 50); + glVertex2f (box, 50); + glEnd (); #endif - glBegin (GL_LINE_STRIP); + glBegin (GL_LINE_STRIP); - short *samples = (short *)data; + short *samples = (short *)data; - int nframes = size / (fmt.bps/8*fmt.channels); - float incr = nframes / (float)a.width; - float pos = 0; - for (int x = 0; x < a.width; x++, pos += incr) { - short s = max (samples[(int)pos*2], samples[(int)pos*2+1]); - glVertex2f (x, s * a.height/2 / 0x7fff + a.height/2); - } + float incr = (float)DDB_AUDIO_MEMORY_FRAMES / a.width; + float pos = 0; + for (int x = 0; x < a.width; x++, pos += incr) { + float s = data[(int)pos]; + glVertex2f (x, s * a.height/2 + a.height/2); + } - glEnd(); - gdk_gl_drawable_swap_buffers (d); + glEnd(); + gdk_gl_drawable_swap_buffers (d); - gdk_gl_drawable_gl_end (d); - } - else { - GdkGLDrawable *d = gtk_widget_get_gl_drawable (widget); - gdk_gl_drawable_gl_begin (d, w->glcontext); - glClear (GL_COLOR_BUFFER_BIT); - gdk_gl_drawable_swap_buffers (d); - gdk_gl_drawable_gl_end (d); - } + gdk_gl_drawable_gl_end (d); return FALSE; diff --git a/plugins/supereq/Fftsg_fl.cpp b/plugins/supereq/Fftsg_fl.c index 636f8b8a..d66ae896 100644 --- a/plugins/supereq/Fftsg_fl.cpp +++ b/plugins/supereq/Fftsg_fl.c @@ -285,8 +285,6 @@ Appendix : w[] and ip[] are compatible with all routines.
*/
-extern "C" {
-
void cdft(int n, int isgn, REAL *a, int *ip, REAL *w)
{
void makewt(int nw, int *ip, REAL *w);
@@ -2650,4 +2648,3 @@ void dstsub(int n, REAL *a, int nc, REAL *c) }
a[m] *= c[0];
}
-}
diff --git a/plugins/supereq/Makefile.am b/plugins/supereq/Makefile.am index 4ce19ee5..0096e4ab 100644 --- a/plugins/supereq/Makefile.am +++ b/plugins/supereq/Makefile.am @@ -1,48 +1,7 @@ if HAVE_SUPEREQ supereqdir = $(libdir)/$(PACKAGE) pkglib_LTLIBRARIES = supereq.la -supereq_la_SOURCES = supereq.c Equ.cpp Equ.h Fftsg_fl.cpp paramlist.hpp - -#nsfft-1.00/simd/SIMDBaseUndiff.c\ -#nsfft-1.00/simd/SIMDBase.c\ -#nsfft-1.00/dft/DFT.c\ -#nsfft-1.00/dft/DFTUndiff.c\ -#nsfft-1.00/simd/SIMDBase.h\ -#nsfft-1.00/simd/SIMDBaseUndiff.h\ -#nsfft-1.00/dft/DFTUndiff.h\ -#nsfft-1.00/dft/DFT.h\ -#shibatch_rdft.c - -#ffmpeg_fft/libavutil/mem.c\ -#ffmpeg_fft/libavutil/mathematics.c\ -#ffmpeg_fft/libavutil/rational.c\ -#ffmpeg_fft/libavutil/intfloat_readwrite.c\ -#ffmpeg_fft/libavcodec/dct.c\ -#ffmpeg_fft/libavcodec/avfft.c\ -#ffmpeg_fft/libavcodec/fft.c\ -#ffmpeg_fft/libavcodec/dct32.c\ -#ffmpeg_fft/libavcodec/rdft.c\ -#ffmpeg_fft/libavutil/intfloat_readwrite.h\ -#ffmpeg_fft/libavutil/avutil.h\ -#ffmpeg_fft/libavutil/common.h\ -#ffmpeg_fft/libavutil/attributes.h\ -#ffmpeg_fft/libavutil/mem.h\ -#ffmpeg_fft/libavutil/avconfig.h\ -#ffmpeg_fft/libavutil/mathematics.h\ -#ffmpeg_fft/libavutil/rational.h\ -#ffmpeg_fft/publik.h\ -#ffmpeg_fft/ffmpeg_fft.h\ -#ffmpeg_fft/libavcodec/dct32.h\ -#ffmpeg_fft/libavcodec/fft.h\ -#ffmpeg_fft/libavcodec/avfft.h\ -#ffmpeg_fft/config.h\ -#ff_rdft.c - -#AM_CFLAGS = $(CFLAGS) -I ffmpeg_fft -I ffmpeg_fft/libavcodec -I ffmpeg_fft/libavutil -std=c99 -#AM_CPPFLAGS = $(CXXFLAGS) -fno-exceptions -fno-rtti -nostdlib -fno-unwind-tables -I ffmpeg_fft -I ffmpeg_fft/libavcodec -I ffmpeg_fft/libavutil - -#AM_CFLAGS = $(CFLAGS) -I nsfft-1.00/dft -I nsfft-1.00/simd -std=c99 -msse -DENABLE_SSE_FLOAT -DUSE_SHIBATCH -#AM_CPPFLAGS = $(CXXFLAGS) -fno-exceptions -fno-rtti -nostdlib -fno-unwind-tables -I nsfft-1.00/dft -I nsfft-1.00/simd -msse -DENABLE_SSE_FLOAT -DUSE_SHIBATCH +supereq_la_SOURCES = supereq.c Equ.cpp Equ.h Fftsg_fl.c paramlist.hpp AM_CFLAGS = $(CFLAGS) -std=c99 -DUSE_OOURA AM_CPPFLAGS = $(CXXFLAGS) -fno-exceptions -fno-rtti -nostdlib -fno-unwind-tables -DUSE_OOURA @@ -121,8 +121,7 @@ static int streamer_buffering; static DB_FILE *streamer_file; // for vis plugins -static char audio_data[DDB_AUDIO_MEMORY_BUFFER_SIZE]; -static ddb_waveformat_t audio_fmt; +static float audio_data[DDB_AUDIO_MEMORY_FRAMES]; #if DETECT_PL_LOCK_RC volatile pthread_t streamer_lock_tid = 0; @@ -1961,7 +1960,6 @@ streamer_read (char *bytes, int size) { if (formatchanged && bytes_until_next_song <= 0) { streamer_set_output_format (); formatchanged = 0; - memset (audio_data, 0, sizeof (audio_data)); } streamer_lock (); int sz = min (size, streamer_ringbuf.remaining); @@ -2012,15 +2010,23 @@ streamer_read (char *bytes, int size) { #endif mutex_lock (audio_mem_mutex); - int mem_size = DDB_AUDIO_MEMORY_FRAMES * (output->fmt.bps >> 3) * output->fmt.channels; - if (sz < mem_size) { - memmove (audio_data, audio_data + sz, mem_size-sz); - memcpy (audio_data + mem_size - sz, bytes, sz); + int in_frame_size = (output->fmt.bps >> 3) * output->fmt.channels; + int in_frames = sz / in_frame_size; + ddb_waveformat_t out_fmt = { + .bps = 32, + .channels = 1, + .samplerate = output->fmt.samplerate, + .channelmask = DDB_SPEAKER_FRONT_LEFT, + .is_float = 1, + .is_bigendian = 0 + }; + if (in_frames < DDB_AUDIO_MEMORY_FRAMES) { + memmove (audio_data, audio_data + in_frames, (DDB_AUDIO_MEMORY_FRAMES-in_frames)*sizeof (float)); + pcm_convert (&output->fmt, bytes, &out_fmt, (char *)(audio_data + DDB_AUDIO_MEMORY_FRAMES - in_frames), sz); } else { - memcpy (audio_data, bytes + sz - mem_size, mem_size); + pcm_convert (&output->fmt, bytes + sz - DDB_AUDIO_MEMORY_FRAMES * in_frame_size, &out_fmt, (char *)audio_data, DDB_AUDIO_MEMORY_FRAMES * in_frame_size); } - memcpy (&audio_fmt, &output->fmt, sizeof (ddb_waveformat_t)); mutex_unlock (audio_mem_mutex); if (!output->has_volume) { @@ -2273,15 +2279,12 @@ streamer_notify_order_changed (int prev_order, int new_order) { } } -int -audio_get_waveform_data (ddb_waveformat_t *fmt, char *data) { +void +audio_get_waveform_data (float *data) { if (!audio_mem_mutex) { - return -1; + return; } mutex_lock (audio_mem_mutex); - memcpy (fmt, &audio_fmt, sizeof (ddb_waveformat_t)); - int mem_size = DDB_AUDIO_MEMORY_FRAMES * (audio_fmt.bps >> 3) * audio_fmt.channels; - memcpy (data, audio_data, mem_size); + memcpy (data, audio_data, sizeof (audio_data)); mutex_unlock (audio_mem_mutex); - return mem_size; } @@ -130,7 +130,7 @@ streamer_dsp_chain_save (void); void streamer_notify_order_changed (int prev_order, int new_order); -int -audio_get_waveform_data (ddb_waveformat_t *fmt, char *data); +void +audio_get_waveform_data (float *data); #endif // __STREAMER_H |