├── AUTHORS ├── TODO ├── README.md ├── gtkglext-1.0 ├── NEWS ├── ChangeLog ├── gtk │ ├── .gitignore │ ├── gtkgl.h │ ├── gtkglprivate.h │ ├── gtkglversion.c │ ├── gtkglinit.h │ ├── Makefile.am │ ├── gtkglwidget.h │ ├── gtkglversion.h.in │ └── gtkgldebug.h ├── gdk │ ├── glext │ │ ├── README │ │ ├── glxext.h.patch │ │ ├── common-header.h │ │ ├── list-ext.pl │ │ ├── wglext-extra.h │ │ └── glxext-extra.h │ ├── .gitignore │ ├── gtkglenumtypes.h.template │ ├── gtkglenumtypes.c.template │ ├── gdkglinit.h │ ├── gdkglquery.h │ ├── gdkgl.h │ ├── gdkgltypes.h │ ├── gdkgloverlay.h │ ├── gdkgldrawable.c │ ├── gdkgldrawable.h │ ├── gdkglprivate.h │ ├── gdkgldebug.h │ ├── gdkglcontext.h │ ├── gdkglglxext.h │ ├── gdkglpixmap.h │ ├── gdkglwindow.h │ └── gdkglx.h ├── MAINTAINERS ├── gtkglext.pc.in ├── gtkglext-uninstalled.pc.in ├── gdkglext-uninstalled.pc.in ├── .gitignore ├── autogen.sh ├── AUTHORS └── Makefile.am ├── waveform ├── fbo.h ├── actor.h ├── audio.h ├── context.h ├── peakgen.h ├── pixbuf.h ├── private.h ├── promise.h ├── shader.h ├── spp.h ├── ui-utils.h ├── utils.h ├── worker.h ├── grid.h ├── hover.h ├── labels.h ├── ruler.h ├── text.h ├── typedefs.h ├── ui-private.h ├── ui-typedefs.h ├── view_plus.h ├── waveform.h ├── debug_helper.h ├── invalidator.h ├── texture_cache.h ├── transition_behaviour.h └── Makefile.am ├── screenshot.webp ├── ui ├── fbo.h ├── actors │ ├── ruler.h │ ├── frames_ruler.h │ ├── labels.h │ ├── Makefile.am │ ├── hover.h │ ├── grid.h │ ├── text.h │ ├── spp.h │ ├── labels.c │ └── ruler.c ├── debug_helper.h ├── Makefile.am ├── private.h ├── invalidator.h ├── transition_behaviour.h ├── texture_cache.h ├── utils.h ├── typedefs.h ├── renderer │ └── res_lo.c ├── pixbuf.h ├── invalidator.c ├── context.root.c ├── shader.h ├── actor.h ├── view.h └── debug_helper.c ├── NEWS ├── .gitmodules ├── lib ├── Makefile.am ├── test │ ├── Makefile.am │ ├── utils.h │ ├── utils.c │ └── runner.h ├── debug │ ├── Makefile.am │ ├── debug.h │ └── debug.c └── ayyi-utils │ ├── Makefile.am │ ├── utils.h │ └── observable.h ├── wf ├── loaders │ ├── riff.h │ ├── ardour.h │ ├── Makefile.am │ └── ardour.c ├── Makefile.am ├── audio.h ├── debug.h ├── peakgen.h ├── global.c ├── worker.h ├── utils.h ├── promise.h ├── typedefs.h └── utils.c ├── autogen.sh ├── libwaveform.pc.in ├── shaders ├── ass.frag ├── vertical.vert ├── horizontal.vert ├── vertical_peak.vert ├── make_shaders ├── cursor.vert ├── cursor.frag ├── ass.vert ├── lines.vert ├── hires_ng.vert ├── hires.vert ├── peak.vert ├── peak_nonscaling.vert ├── ruler.vert ├── ruler_bottom.vert ├── ruler_frames.vert ├── Makefile.am ├── vertical.frag ├── vertical_peak.frag ├── peak_nonscaling.frag ├── ruler_frames.frag └── ruler_bottom.frag ├── decoder ├── Makefile.am ├── debug.h └── ad.h ├── test ├── gen │ ├── generator.h │ ├── instrument.cc │ ├── thumbnail.c │ ├── cpgrs.h │ └── generator.cc ├── suppressions │ ├── test.supp │ ├── glib.supp │ └── pango.supp ├── valgrind ├── common.c ├── run ├── common.h ├── common2.h └── input.c ├── package └── gentoo │ └── media-libs │ └── libwaveform │ └── libwaveform-0.1.0.ebuild ├── Makefile.am ├── .gitignore └── ChangeLog /AUTHORS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | README -------------------------------------------------------------------------------- /gtkglext-1.0/NEWS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gtkglext-1.0/ChangeLog: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /waveform/fbo.h: -------------------------------------------------------------------------------- 1 | ../ui/fbo.h -------------------------------------------------------------------------------- /waveform/actor.h: -------------------------------------------------------------------------------- 1 | ../ui/actor.h -------------------------------------------------------------------------------- /waveform/audio.h: -------------------------------------------------------------------------------- 1 | ../wf/audio.h -------------------------------------------------------------------------------- /waveform/context.h: -------------------------------------------------------------------------------- 1 | ../ui/context.h -------------------------------------------------------------------------------- /waveform/peakgen.h: -------------------------------------------------------------------------------- 1 | ../wf/peakgen.h -------------------------------------------------------------------------------- /waveform/pixbuf.h: -------------------------------------------------------------------------------- 1 | ../ui/pixbuf.h -------------------------------------------------------------------------------- /waveform/private.h: -------------------------------------------------------------------------------- 1 | ../wf/private.h -------------------------------------------------------------------------------- /waveform/promise.h: -------------------------------------------------------------------------------- 1 | ../wf/promise.h -------------------------------------------------------------------------------- /waveform/shader.h: -------------------------------------------------------------------------------- 1 | ../ui/shader.h -------------------------------------------------------------------------------- /waveform/spp.h: -------------------------------------------------------------------------------- 1 | ../ui/actors/spp.h -------------------------------------------------------------------------------- /waveform/ui-utils.h: -------------------------------------------------------------------------------- 1 | ../ui/utils.h -------------------------------------------------------------------------------- /waveform/utils.h: -------------------------------------------------------------------------------- 1 | ../wf/utils.h -------------------------------------------------------------------------------- /waveform/worker.h: -------------------------------------------------------------------------------- 1 | ../wf/worker.h -------------------------------------------------------------------------------- /waveform/grid.h: -------------------------------------------------------------------------------- 1 | ../ui/actors/grid.h -------------------------------------------------------------------------------- /waveform/hover.h: -------------------------------------------------------------------------------- 1 | ../ui/actors/hover.h -------------------------------------------------------------------------------- /waveform/labels.h: -------------------------------------------------------------------------------- 1 | ../ui/actors/labels.h -------------------------------------------------------------------------------- /waveform/ruler.h: -------------------------------------------------------------------------------- 1 | ../ui/actors/ruler.h -------------------------------------------------------------------------------- /waveform/text.h: -------------------------------------------------------------------------------- 1 | ../ui/actors/text.h -------------------------------------------------------------------------------- /waveform/typedefs.h: -------------------------------------------------------------------------------- 1 | ../wf/typedefs.h -------------------------------------------------------------------------------- /waveform/ui-private.h: -------------------------------------------------------------------------------- 1 | ../ui/private.h -------------------------------------------------------------------------------- /waveform/ui-typedefs.h: -------------------------------------------------------------------------------- 1 | ../ui/typedefs.h -------------------------------------------------------------------------------- /waveform/view_plus.h: -------------------------------------------------------------------------------- 1 | ../ui/view_plus.h -------------------------------------------------------------------------------- /waveform/waveform.h: -------------------------------------------------------------------------------- 1 | ../wf/waveform.h -------------------------------------------------------------------------------- /waveform/debug_helper.h: -------------------------------------------------------------------------------- 1 | ../ui/debug_helper.h -------------------------------------------------------------------------------- /waveform/invalidator.h: -------------------------------------------------------------------------------- 1 | ../ui/invalidator.h -------------------------------------------------------------------------------- /waveform/texture_cache.h: -------------------------------------------------------------------------------- 1 | ../ui/texture_cache.h -------------------------------------------------------------------------------- /waveform/transition_behaviour.h: -------------------------------------------------------------------------------- 1 | ../ui/transition_behaviour.h -------------------------------------------------------------------------------- /screenshot.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayyi/libwaveform/HEAD/screenshot.webp -------------------------------------------------------------------------------- /gtkglext-1.0/gtk/.gitignore: -------------------------------------------------------------------------------- 1 | gtkglversion.h 2 | GtkGLExt-1.0.gir 3 | GtkGLExt-1.0.typelib 4 | -------------------------------------------------------------------------------- /ui/fbo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "agl/fbo.h" 4 | 5 | AGlFBO* fbo_new_test (); 6 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | 20140822 2 | The new gl-2.0 mode is a major improvement in terms of frame rates and number of textures used. 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/agl"] 2 | path = lib/agl 3 | url = https://gitlab.com/ayyi.org/agl.git 4 | ignore = dirty 5 | -------------------------------------------------------------------------------- /lib/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | if ENABLE_SUBMODULES 3 | AGL_SUBDIRS = agl 4 | endif 5 | 6 | SUBDIRS = debug ayyi-utils test $(AGL_SUBDIRS) 7 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/glext/README: -------------------------------------------------------------------------------- 1 | 2 | This directory contains OpenGL extension headers provided by SGI. 3 | 4 | http://oss.sgi.com/projects/ogl-sample/registry/ 5 | 6 | -------------------------------------------------------------------------------- /gtkglext-1.0/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Stéphane Brunet 2 | E-mail: stbru@teksavvy.com 3 | 4 | Ralf Corsépius 5 | E-mail: rcgnome@freenet.de 6 | 7 | Braden McDaniel 8 | E-mail: braden@endoframe.com 9 | -------------------------------------------------------------------------------- /wf/loaders/riff.h: -------------------------------------------------------------------------------- 1 | #ifndef __waveform_loader_riff_h__ 2 | #define __waveform_loader_riff_h__ 3 | 4 | gboolean wf_load_riff_peak(Waveform*, const char*); 5 | 6 | #endif //__waveform_loader_riff_h__ 7 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/.gitignore: -------------------------------------------------------------------------------- 1 | gdkglenumtypes.c 2 | gdkglenumtypes.h 3 | gdkglext-config.h 4 | gdkglversion.h 5 | stamp-gdkglenumtypes-h 6 | stamp-gdkglext-config-h 7 | GdkGLExt-1.0.gir 8 | GdkGLExt-1.0.typelib 9 | -------------------------------------------------------------------------------- /wf/loaders/ardour.h: -------------------------------------------------------------------------------- 1 | #ifndef __waveform_loader_ardour_h__ 2 | #define __waveform_loader_ardour_h__ 3 | 4 | gboolean wf_load_ardour_peak(Waveform*, const char*); 5 | 6 | #endif //__waveform_loader_ardour_h__ 7 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo 'libwaveform: generating build files ...' 4 | libtoolize --automake 5 | aclocal 6 | autoheader -Wall 7 | automake --gnu --add-missing -Wall 8 | autoconf 9 | touch Makefile.in 10 | 11 | cd gtkglext-1.0 && 12 | ./autogen.sh 13 | -------------------------------------------------------------------------------- /lib/test/Makefile.am: -------------------------------------------------------------------------------- 1 | if BUILD_TESTS 2 | 3 | AM_CFLAGS = \ 4 | -DG_LOG_DOMAIN=\"Waveform\" \ 5 | -I$(top_srcdir)/lib \ 6 | $(GLIB_CFLAGS) 7 | 8 | noinst_LTLIBRARIES = libtest.la 9 | 10 | libtest_la_SOURCES = \ 11 | runner.c runner.h \ 12 | utils.c utils.h 13 | 14 | endif 15 | 16 | -------------------------------------------------------------------------------- /lib/debug/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | AM_CFLAGS = \ 3 | -DG_LOG_DOMAIN=\"Debug\" \ 4 | -D_FILE_OFFSET_BITS=64 \ 5 | $(GLIB_CFLAGS) 6 | 7 | lib_LTLIBRARIES = libayyidebug.la 8 | 9 | libayyidebug_la_SOURCES = \ 10 | debug.c debug.h 11 | 12 | BUILT_SOURCES = 13 | CLEANFILES = 14 | EXTRA_DIST = 15 | 16 | -------------------------------------------------------------------------------- /lib/ayyi-utils/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | AM_CFLAGS = \ 3 | -DG_LOG_DOMAIN=\"AyyiUtils\" \ 4 | -D_FILE_OFFSET_BITS=64 \ 5 | -I.. \ 6 | $(GLIB_CFLAGS) 7 | 8 | lib_LTLIBRARIES = libayyiutils.la 9 | 10 | libayyiutils_la_SOURCES = \ 11 | observable.c observable.h 12 | 13 | pkgincludedir=$(includedir)/ayyi-utils 14 | pkginclude_HEADERS = \ 15 | observable.h \ 16 | utils.h 17 | 18 | BUILT_SOURCES = 19 | CLEANFILES = 20 | EXTRA_DIST = \ 21 | utils.h 22 | 23 | -------------------------------------------------------------------------------- /libwaveform.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | ffmpeg_flags=@FFMPEG_LDFLAGS@ 6 | 7 | Name: Libwaveform 8 | Version: @PACKAGE_VERSION@ 9 | Description: Gtk+-2 library for displaying audio waveforms 10 | URL: https://github.com/ayyi/libwaveform 11 | Requires: gtk+-2.0 > 2.10 12 | Libs: -L${libdir} -lwaveformcore -lwaveformui -lgtkglext ${ffmpeg_flags} 13 | Cflags: -I${includedir} -I${includedir}/gtkglext-1.0 14 | -------------------------------------------------------------------------------- /shaders/ass.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D tex2d; 2 | uniform vec4 colour1; 3 | uniform vec4 colour2; 4 | 5 | in vec2 tex_coords; 6 | out vec4 colour; 7 | 8 | void main () 9 | { 10 | float rr = texture2D(tex2d, tex_coords.xy).r; 11 | 12 | float l0 = colour1[0] * rr + colour2[0] * (1.0 - rr); 13 | float l1 = colour1[1] * rr + colour2[1] * (1.0 - rr); 14 | float l2 = colour1[2] * rr + colour2[2] * (1.0 - rr); 15 | 16 | colour = vec4(l0, l1, l2, colour1[3] * texture2D(tex2d, tex_coords).a); 17 | } 18 | -------------------------------------------------------------------------------- /gtkglext-1.0/gtkglext.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | target=@gdktarget@ 7 | api_version=@GTKGLEXT_API_VERSION@ 8 | 9 | multihead=yes 10 | 11 | Name: GtkGLExt 12 | Description: OpenGL Extension to GTK+ (${target} target) 13 | Version: @VERSION@ 14 | Requires: gtk+-2.0 gdkglext-${target}-${api_version} 15 | Libs: -L${libdir} -lgtkglext-${target}-${api_version} 16 | Libs.private: @MATH_LIB@ 17 | Cflags: -I${includedir}/gtkglext-${api_version} 18 | -------------------------------------------------------------------------------- /gtkglext-1.0/gtkglext-uninstalled.pc.in: -------------------------------------------------------------------------------- 1 | target=@gdktarget@ 2 | api_version=@GTKGLEXT_API_VERSION@ 3 | 4 | multihead=yes 5 | 6 | Name: GtkGLExt Uninstalled 7 | Description: OpenGL Extension to GTK+ (${target} target), Not Installed 8 | Version: @VERSION@ 9 | Requires: gtk+-2.0 gdkglext-${target}-${api_version}-uninstalled 10 | Libs: ${pc_top_builddir}${pcfiledir}/gtk/libgtkglext-${target}-${api_version}.la 11 | Libs.private: @MATH_LIB@ 12 | Cflags: -I${pc_top_builddir}${pcfiledir} -I${pc_top_builddir}${pcfiledir}/@srcdir@ 13 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdkglext-uninstalled.pc.in: -------------------------------------------------------------------------------- 1 | target=@gdktarget@ 2 | api_version=@GTKGLEXT_API_VERSION@ 3 | 4 | Name: GdkGLExt Uninstalled 5 | Description: OpenGL Extension to GDK (${target} target), Not Installed 6 | Version: @VERSION@ 7 | Requires: gdk-2.0 pangox 8 | Libs: ${pc_top_builddir}${pcfiledir}/gdk/libgdkglext-${target}-${api_version}.la @GL_LIBS@ @GDKGLEXT_WIN_LIBS@ 9 | Cflags: -I${pc_top_builddir}${pcfiledir} -I${pc_top_builddir}${pcfiledir}/@srcdir@ -I${pc_top_builddir}${pcfiledir}/gdk @GL_CFLAGS@ @GDKGLEXT_WIN_CFLAGS@ 10 | -------------------------------------------------------------------------------- /decoder/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_LTLIBRARIES = libdecoder.la 3 | 4 | AM_CFLAGS = \ 5 | -DG_LOG_DOMAIN=\"Decoder\" \ 6 | -I$(includedir) \ 7 | $(FFMPEG_CFLAGS) \ 8 | $(GLIB_CFLAGS) 9 | 10 | if ENABLE_FFMPEG 11 | FF_SRC = \ 12 | ffmpeg.c 13 | endif 14 | 15 | if ENABLE_SNDFILE 16 | SNDFILE_SRC = \ 17 | sndfile.c 18 | endif 19 | 20 | libdecoder_la_SOURCES = \ 21 | ad.c ad.h \ 22 | $(SNDFILE_SRC) \ 23 | $(FF_SRC) \ 24 | debug.h 25 | 26 | pkgincludedir=$(includedir)/decoder 27 | 28 | pkginclude_HEADERS = \ 29 | ad.h 30 | 31 | -------------------------------------------------------------------------------- /decoder/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef __decoder_debug_h___ 2 | #define __decoder_debug_h___ 3 | 4 | extern int wf_debug; 5 | #define PF0 printf("%s\n", __func__) 6 | #define dbg(A, STR, ...) ({if(A <= wf_debug) printf("%s: "STR"\n", __func__, ##__VA_ARGS__);}) 7 | #define perr(A, ...) g_critical("%s(): "A, __func__, ##__VA_ARGS__) 8 | #ifndef gwarn 9 | #define gwarn(A, ...) g_warning("%s(): "A, __func__, ##__VA_ARGS__) 10 | #endif 11 | #ifndef pwarn 12 | #define pwarn(A, ...) g_warning("%s(): "A, __func__, ##__VA_ARGS__) 13 | #endif 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /gtkglext-1.0/.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.la 3 | *.lo 4 | *.nsi 5 | *.o 6 | *.pc 7 | *.spec 8 | .deps 9 | .libs 10 | ABOUT-NLS 11 | AUTHORS 12 | INSTALL 13 | Makefile 14 | Makefile.in 15 | aclocal.m4 16 | autom4te.cache 17 | compile 18 | configure 19 | config.cache 20 | config.guess 21 | config.h 22 | config.h.in 23 | config.log 24 | config.rpath 25 | config.status 26 | config.sub 27 | cscope.files 28 | cscope.out 29 | depcomp 30 | gtk-doc.make 31 | install-sh 32 | intl 33 | libtool 34 | ltmain.sh 35 | missing 36 | mkinstalldirs 37 | stamp-h1 38 | ylwrap 39 | -------------------------------------------------------------------------------- /test/gen/generator.h: -------------------------------------------------------------------------------- 1 | #ifndef __generator_h__ 2 | #define __generator_h__ 3 | 4 | class Generator 5 | { 6 | public: 7 | virtual void init () = 0; 8 | virtual void compute (int count, double** input, double** output) = 0; 9 | 10 | float on; 11 | }; 12 | 13 | 14 | class Note 15 | { 16 | public: 17 | int length; 18 | Generator* generator; 19 | 20 | Note (Generator* g, int _length); 21 | ~Note (); 22 | 23 | void compute (int count, double** input, double** output); 24 | 25 | private: 26 | int t; 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/glext/glxext.h.patch: -------------------------------------------------------------------------------- 1 | --- glxext.h.orig 2009-09-11 17:06:19.000000000 +0530 2 | +++ glxext.h 2009-09-30 18:47:25.000000000 +0530 3 | @@ -426,7 +426,9 @@ 4 | 5 | /* The next two typedefs are placeholders until NVIDIA clarifies these types */ 6 | #ifndef GLX_NV_video_output 7 | -typedef struct { unsigned int dummy; } *GLXVideoDeviceNV; 8 | +/* GtkGLExt replaced the following typedef: */ 9 | +/* typedef struct { unsigned int dummy; } *GLXVideoDeviceNV; */ 10 | +typedef unsigned int GLXVideoDeviceNV; 11 | #endif 12 | 13 | #ifndef GLX_NV_video_capture 14 | -------------------------------------------------------------------------------- /gtkglext-1.0/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo 'Generating necessary files...' 4 | libtoolize --automake 5 | aclocal 6 | autoheader -Wall 7 | automake --gnu --add-missing -Wall 8 | 9 | # fix dist path issues in ac_config subdirectory 10 | sed -i -e 's/..\/compile/compile/' Makefile.in 11 | sed -i -e 's/..\/config.guess/config.guess/' Makefile.in 12 | sed -i -e 's/..\/config.sub/config.sub/' Makefile.in 13 | sed -i -e 's/..\/install-sh/install-sh/' Makefile.in 14 | sed -i -e 's/..\/ltmain.sh/ltmain.sh/' Makefile.in 15 | sed -i -e 's/..\/missing/missing/' Makefile.in 16 | 17 | autoconf 18 | touch Makefile.in 19 | 20 | -------------------------------------------------------------------------------- /wf/loaders/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_LTLIBRARIES = libloaders.la 3 | 4 | libloaders_la_SOURCES = \ 5 | ardour.c ardour.h \ 6 | riff.c riff.h 7 | 8 | if ENABLE_SYSTEM_GTKGLEXT 9 | else 10 | LOCAL_GTKGLEXT_CFLAGS = \ 11 | -I$(top_srcdir)/gtkglext-1.0 12 | endif 13 | 14 | AM_CFLAGS = \ 15 | -DG_LOG_DOMAIN=\"Waveform\" \ 16 | -D_FILE_OFFSET_BITS=64 \ 17 | -I$(includedir) \ 18 | -I$(top_srcdir) \ 19 | -I$(top_srcdir)/lib \ 20 | $(GTK_CFLAGS) \ 21 | $(SDL_CFLAGS) \ 22 | $(LOCAL_GTKGLEXT_CFLAGS) \ 23 | $(OPENGL_CFLAGS) 24 | 25 | pkgincludedir=$(includedir)/waveform/loaders 26 | pkginclude_HEADERS = \ 27 | ardour.h \ 28 | riff.h 29 | -------------------------------------------------------------------------------- /test/suppressions/test.supp: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Leak 4 | match-leak-kinds: definite 5 | fun:malloc 6 | obj:/bin/bash 7 | obj:/bin/bash 8 | obj:/bin/bash 9 | fun:(below main) 10 | } 11 | { 12 | 13 | Memcheck:Leak 14 | ... 15 | fun:g_thread_new 16 | fun:wf_worker_init 17 | } 18 | { 19 | 20 | Memcheck:Leak 21 | ... 22 | fun:g_thread_new 23 | ... 24 | fun:test_peakgen 25 | } 26 | { 27 | 28 | Memcheck:Leak 29 | ... 30 | fun:g_thread_new 31 | ... 32 | fun:wf_ff_peakgen 33 | } 34 | 35 | -------------------------------------------------------------------------------- /wf/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = loaders 2 | 3 | AM_CFLAGS = \ 4 | -DG_LOG_DOMAIN=\"Waveform\" \ 5 | -D_FILE_OFFSET_BITS=64 \ 6 | -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ 7 | -I$(includedir) \ 8 | -I$(top_srcdir) \ 9 | -I$(top_srcdir)/lib \ 10 | $(FFMPEG_CFLAGS) \ 11 | $(GLIB_CFLAGS) 12 | 13 | noinst_LTLIBRARIES = libwfcore.la 14 | 15 | libwfcore_la_SOURCES = \ 16 | typedefs.h \ 17 | private.h \ 18 | global.c \ 19 | waveform.c waveform.h \ 20 | peakgen.c peakgen.h \ 21 | audio.c audio.h \ 22 | worker.c worker.h \ 23 | promise.c promise.h \ 24 | utils.c utils.h \ 25 | debug.h 26 | 27 | libwfcore_la_LIBADD = \ 28 | loaders/libloaders.la 29 | 30 | EXTRA_DIST = \ 31 | preview.c 32 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gtkglenumtypes.h.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | 3 | /* Generated data (by glib-mkenums) */ 4 | 5 | #ifndef __GDK_GL_ENUM_TYPES_H__ 6 | #define __GDK_GL_ENUM_TYPES_H__ 7 | 8 | #include 9 | 10 | G_BEGIN_DECLS 11 | /*** END file-header ***/ 12 | 13 | /*** BEGIN file-production ***/ 14 | 15 | /* enumerations from "@filename@" */ 16 | /*** END file-production ***/ 17 | 18 | /*** BEGIN value-header ***/ 19 | GType @enum_name@_get_type (void) G_GNUC_CONST; 20 | #define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) 21 | /*** END value-header ***/ 22 | 23 | /*** BEGIN file-tail ***/ 24 | G_END_DECLS 25 | 26 | #endif /* __GDK_GL_ENUM_TYPES_H__ */ 27 | /*** END file-tail ***/ 28 | -------------------------------------------------------------------------------- /ui/actors/ruler.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2013-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #pragma once 14 | 15 | AGlActor* ruler_actor (WaveformActor*); 16 | -------------------------------------------------------------------------------- /ui/actors/frames_ruler.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2013-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #pragma once 14 | 15 | AGlActor* frames_ruler_actor (WaveformActor*); 16 | -------------------------------------------------------------------------------- /gtkglext-1.0/AUTHORS: -------------------------------------------------------------------------------- 1 | Maintainers 2 | =========== 3 | 4 | Stéphane Brunet 5 | 6 | Ralf Corsépius 7 | 8 | Braden McDaniel 9 | 10 | 11 | Original Author 12 | =============== 13 | 14 | Naofumi Yasufuku (安福 尚文) 15 | 16 | 17 | Contributors 18 | ============ 19 | 20 | Alif Wahid 21 | * Port of viewlw, the LightWave 3D object viewer demo, that comes 22 | with the GtkGLArea. The program is originally written by Janne Lof. 23 | * rotating-square.c, coolwave.c, coolwave2.c, template.c and 24 | scribble-gl.c demo programs. 25 | 26 | Igor Fernandez de Bustos 27 | * Documentations. 28 | 29 | -------------------------------------------------------------------------------- /package/gentoo/media-libs/libwaveform/libwaveform-0.1.0.ebuild: -------------------------------------------------------------------------------- 1 | # Copyright 1999-2006 Gentoo Foundation 2 | # Distributed under the terms of the GNU General Public License v2 3 | # $Header: $ 4 | 5 | RESTRICT="nomirror" 6 | DESCRIPTION="Libwaveform provides efficient display of audio waveforms for Gtk applications." 7 | HOMEPAGE="http://ayyi.org/" 8 | SRC_URI="http://ayyi.org/files/${P}.tar.gz" 9 | RESTRICT="nomirror" 10 | IUSE="ffmpeg sndfile" 11 | 12 | LICENSE="GPL-3" 13 | KEYWORDS="amd64 x86" 14 | SLOT="0" 15 | 16 | DEPEND="sndfile? ( >=media-libs/libsndfile-1.0.10 ) 17 | ffmpeg? ( virtual/ffmpeg ) 18 | >=x11-libs/gtk+-2.6 19 | media-libs/graphene" 20 | 21 | src_install() { 22 | make DESTDIR=${D} install || die 23 | dodoc NEWS ChangeLog 24 | } 25 | 26 | -------------------------------------------------------------------------------- /lib/ayyi-utils/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2013-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #pragma once 14 | 15 | #define AYYI_NEW(T, ...) ({T* obj = g_new0(T, 1); *obj = (T){__VA_ARGS__}; obj;}) 16 | -------------------------------------------------------------------------------- /test/valgrind: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd $(dirname "$0") 4 | 5 | PROG=./cache 6 | PROG=./view_plus 7 | PROG="./res_vhi -n" 8 | PROG=./pixbuf 9 | PROG=./resources 10 | PROG=./frame_rate 11 | PROG=./actor_plus 12 | PROG=./promise 13 | PROG=./glx 14 | PROG=./list 15 | PROG=./actor_no_scene 16 | PROG=./waveform 17 | PROG=./overview 18 | 19 | ls -l $PROG 20 | export G_SLICE=always-malloc 21 | export G_DEBUG=gc-friendly 22 | 23 | /usr/bin/valgrind \ 24 | --leak-check=full \ 25 | --suppressions=../lib/agl/test/suppressions/mesa.supp \ 26 | --suppressions=suppressions/pango.supp \ 27 | --suppressions=suppressions/glib.supp \ 28 | --suppressions=suppressions/mesa.supp \ 29 | --suppressions=suppressions/test.supp \ 30 | --gen-suppressions=yes \ 31 | --num-callers=50 \ 32 | $@ $PROG 33 | -------------------------------------------------------------------------------- /lib/test/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. http://ayyi.org | 4 | | copyright (C) 2013-2021 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #pragma once 14 | 15 | bool get_random_boolean (); 16 | int get_random_int (int max); 17 | void create_large_file (char*); 18 | 19 | -------------------------------------------------------------------------------- /ui/actors/labels.h: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of the Ayyi project. http://ayyi.org | 4 | * | copyright (C) 2013-2018 Tim Orford | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | */ 12 | #ifndef __wf_labels_actor_h__ 13 | #define __wf_labels_actor_h__ 14 | 15 | AGlActor* labels_actor(WaveformContext*); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /ui/debug_helper.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2025-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #pragma once 14 | 15 | #include "agl/behaviour.h" 16 | 17 | AGlBehaviourClass* debug_helper_class (); 18 | 19 | AGlBehaviour* debug_helper (); 20 | -------------------------------------------------------------------------------- /test/gen/instrument.cc: -------------------------------------------------------------------------------- 1 | #include "instrument.hh" 2 | 3 | LookupTable::LookupTable() 4 | { 5 | m_Points = NULL; 6 | m_nPoints = 0; 7 | } 8 | 9 | void 10 | LookupTable::set(double* points, int num_points) 11 | { 12 | // Note: Actual array size is 2*num_points 13 | 14 | m_Points = points; 15 | m_nPoints = num_points; 16 | } 17 | 18 | double 19 | LookupTable::getValue(double x) 20 | { 21 | // Note: Assumes points are monotonically increasing in X! 22 | 23 | int i=0; 24 | while (x>m_Points[i*2] && i=m_nPoints) 31 | return m_Points[(m_nPoints-1)*2+1]; 32 | 33 | double ratio = (x - m_Points[(i-1)*2]) / (m_Points[i*2] - m_Points[(i-1)*2]); 34 | 35 | return m_Points[(i-1)*2+1]*(1-ratio) + m_Points[i*2+1]*(ratio); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /gtkglext-1.0/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | SUBDIRS = gdk gtk 3 | 4 | EXTRA_DIST = \ 5 | config.h.in \ 6 | configure \ 7 | gdkglext-uninstalled.pc.in \ 8 | gtkglext-uninstalled.pc.in 9 | 10 | ## Copy .pc files to target-specific names 11 | GDK_TARGET = @gdktarget@ 12 | API_VER = @GTKGLEXT_API_VERSION@ 13 | 14 | pkgconfigdir = $(libdir)/pkgconfig 15 | pkgconfig_DATA = 16 | $(pkgconfig_DATA): $(top_builddir)/config.status 17 | 18 | DISTCLEANFILES = \ 19 | gdkglext-$(GDK_TARGET)-$(API_VER)-uninstalled.pc \ 20 | gdkglext-$(API_VER)-uninstalled.pc \ 21 | gtkglext-$(GDK_TARGET)-$(API_VER)-uninstalled.pc \ 22 | gtkglext-$(API_VER)-uninstalled.pc 23 | 24 | lib_LTLIBRARIES = libgtkglext.la 25 | libgtkglext_la_SOURCES = 26 | libgtkglext_la_LIBADD = \ 27 | gdk/libgdk.la \ 28 | gtk/libgtk.la 29 | 30 | .PHONY: am--refresh 31 | am--refresh: 32 | @: 33 | -------------------------------------------------------------------------------- /waveform/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | pkgincludedir=$(includedir)/waveform 3 | pkginclude_HEADERS = \ 4 | typedefs.h \ 5 | waveform.h \ 6 | peakgen.h \ 7 | promise.h \ 8 | utils.h \ 9 | ui-typedefs.h \ 10 | ui-utils.h \ 11 | view_plus.h \ 12 | actor.h \ 13 | context.h \ 14 | shader.h \ 15 | fbo.h \ 16 | texture_cache.h \ 17 | private.h \ 18 | ui-private.h 19 | 20 | 21 | EXTRA_DIST = \ 22 | actor.h \ 23 | audio.h \ 24 | context.h \ 25 | fbo.h \ 26 | grid.h \ 27 | invalidator.h \ 28 | labels.h \ 29 | hover.h \ 30 | pixbuf.h \ 31 | private.h \ 32 | promise.h \ 33 | ruler.h \ 34 | shader.h \ 35 | spp.h \ 36 | text.h \ 37 | texture_cache.h \ 38 | transition_behaviour.h \ 39 | debug_helper.h \ 40 | typedefs.h \ 41 | ui-private.h \ 42 | ui-typedefs.h \ 43 | ui-utils.h \ 44 | utils.h \ 45 | view_plus.h \ 46 | waveform.h \ 47 | worker.h 48 | -------------------------------------------------------------------------------- /shaders/vertical.vert: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2012 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | varying vec2 MCposition; 19 | 20 | void main() 21 | { 22 | gl_TexCoord[0] = gl_MultiTexCoord0; 23 | gl_Position = ftransform(); 24 | } 25 | -------------------------------------------------------------------------------- /shaders/horizontal.vert: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2012 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | varying vec2 MCposition; 19 | 20 | void main() 21 | { 22 | gl_TexCoord[0] = gl_MultiTexCoord0; 23 | gl_Position = ftransform(); 24 | } 25 | -------------------------------------------------------------------------------- /shaders/vertical_peak.vert: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2012 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | varying vec2 MCposition; 19 | 20 | void main() 21 | { 22 | gl_TexCoord[0] = gl_MultiTexCoord0; 23 | gl_Position = ftransform(); 24 | } 25 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/glext/common-header.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gtkglenumtypes.c.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | /* Generated data (by glib-mkenums) */ 3 | 4 | #include "gdkgl.h" 5 | 6 | /*** END file-header ***/ 7 | 8 | /*** BEGIN file-production ***/ 9 | /* enumerations from "@filename@" */ 10 | /*** END file-production ***/ 11 | 12 | /*** BEGIN value-header ***/ 13 | GType 14 | @enum_name@_get_type (void) 15 | { 16 | static GType etype = 0; 17 | if (G_UNLIKELY(etype == 0)) { 18 | static const G@Type@Value values[] = { 19 | /*** END value-header ***/ 20 | 21 | /*** BEGIN value-production ***/ 22 | { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, 23 | /*** END value-production ***/ 24 | 25 | /*** BEGIN value-tail ***/ 26 | { 0, NULL, NULL } 27 | }; 28 | etype = g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); 29 | } 30 | return etype; 31 | } 32 | 33 | /*** END value-tail ***/ 34 | -------------------------------------------------------------------------------- /wf/audio.h: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of the Ayyi project. http://ayyi.org | 4 | * | copyright (C) 2012-2020 Tim Orford | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | */ 12 | #ifndef __wf_audio_h__ 13 | #define __wf_audio_h__ 14 | 15 | #include "wf/waveform.h" 16 | 17 | #define MAX_TIERS 8 //this is related to WF_PEAK_RATIO: WF_PEAK_RATIO = 2 ^ MAX_TIERS. 18 | 19 | #ifdef __wf_private__ 20 | int wf_audio_cache_get_size(); 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /shaders/make_shaders: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | shaders=(peak peak_nonscaling horizontal vertical hires hires_ng ruler ruler_bottom ruler_frames ass lines cursor); 4 | out=shaders.c 5 | 6 | if [[ -s $out ]]; then 7 | #file already exists, check age 8 | need_regen=false 9 | for s in "${shaders[@]}"; do 10 | if [[ $s.frag -nt $out ]]; then 11 | need_regen=true 12 | fi 13 | if [[ $s.vert -nt $out ]]; then 14 | need_regen=true 15 | fi 16 | done 17 | 18 | if [[ $need_regen == false ]]; then exit; fi; 19 | fi; 20 | 21 | echo "regenerating shaders.c ..." 22 | echo "" > $out 23 | 24 | function a { 25 | echo '' >> $out 26 | echo 'AGlShaderText '$1'_text = {" \' >> $out 27 | cpp -P $1.vert | sed -e "s/$/ \\\/" >> $out 28 | echo '",' >> $out 29 | echo '" \' >> $out 30 | cpp -P $1.frag | sed -e "s/$/ \\\/" >> $out 31 | echo '"' >> $out 32 | echo '};' >> $out 33 | } 34 | 35 | for s in "${shaders[@]}"; do 36 | a $s 37 | done 38 | 39 | -------------------------------------------------------------------------------- /ui/actors/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | if ENABLE_OPENGL 3 | 4 | noinst_LTLIBRARIES = libactors.la 5 | 6 | libactors_la_SOURCES = \ 7 | ruler.c ruler.h \ 8 | frames_ruler.c frames_ruler.h \ 9 | grid.c grid.h \ 10 | labels.c labels.h \ 11 | spp.c spp.h \ 12 | hover.c hover.h \ 13 | text.c text.h 14 | 15 | if ENABLE_SYSTEM_GTKGLEXT 16 | else 17 | LOCAL_GTKGLEXT_CFLAGS = \ 18 | -I$(top_srcdir)/gtkglext-1.0 19 | endif 20 | 21 | AM_CFLAGS = \ 22 | -DG_LOG_DOMAIN=\"Waveform\" \ 23 | -D_FILE_OFFSET_BITS=64 \ 24 | -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ 25 | -I$(includedir) \ 26 | -I$(top_srcdir) \ 27 | -I../../lib/ \ 28 | -I../../lib/agl \ 29 | $(GTK_CFLAGS) \ 30 | $(SDL_CFLAGS) \ 31 | $(LOCAL_GTKGLEXT_CFLAGS) \ 32 | $(OPENGL_CFLAGS) 33 | 34 | endif 35 | 36 | pkgincludedir=$(includedir)/waveform/actors 37 | pkginclude_HEADERS = \ 38 | grid.h \ 39 | labels.h \ 40 | ruler.h \ 41 | frames_ruler.h \ 42 | spp.h \ 43 | hover.h \ 44 | text.h 45 | -------------------------------------------------------------------------------- /shaders/cursor.vert: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of the Ayyi project. https://www.ayyi.org | 4 | * | copyright (C) 2012-2021 Tim Orford | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | */ 12 | 13 | attribute vec4 vertex; 14 | 15 | uniform vec2 modelview; 16 | uniform vec2 translate; 17 | 18 | varying vec2 position; 19 | 20 | void main () 21 | { 22 | position = vertex.xy; 23 | gl_Position = vec4(vec2(1., -1.) * (vertex.xy + translate) / modelview - vec2(1., -1.), 0., 1.); 24 | } 25 | -------------------------------------------------------------------------------- /shaders/cursor.frag: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of the Ayyi project. https://www.ayyi.org | 4 | * | copyright (C) 2012-2021 Tim Orford | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | */ 12 | 13 | uniform vec4 colour; 14 | uniform float width; 15 | 16 | varying vec2 position; 17 | 18 | void main () 19 | { 20 | float a1 = 0.5 + 0.5 * max(position.x + 0.5 - (width - 1.0), 0.0); 21 | 22 | gl_FragColor = vec4( 23 | vec3(colour), 24 | colour.a * a1 * position.x / width 25 | ); 26 | } 27 | -------------------------------------------------------------------------------- /test/suppressions/glib.supp: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Leak 4 | ... 5 | fun:g_type_register_static 6 | } 7 | { 8 | 9 | Memcheck:Leak 10 | ... 11 | fun:g_type_add_interface_static 12 | } 13 | { 14 | 15 | Memcheck:Leak 16 | ... 17 | fun:g_type_register_fundamental 18 | } 19 | { 20 | 21 | Memcheck:Leak 22 | ... 23 | fun:g_option_context_parse 24 | } 25 | { 26 | 27 | Memcheck:Leak 28 | ... 29 | fun:g_type_class_ref 30 | } 31 | { 32 | 33 | Memcheck:Leak 34 | ... 35 | fun:g_get_current_dir 36 | } 37 | { 38 | 39 | Memcheck:Leak 40 | ... 41 | fun:_dl_init 42 | } 43 | { 44 | 45 | Memcheck:Leak 46 | ... 47 | fun:g_main_loop_new 48 | } 49 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | if ENABLE_OPENGL 2 | OPENGL_SUBDIRS = shaders 3 | endif 4 | if ENABLE_GTK 5 | GTK_SUBDIRS = gtkglext-1.0 6 | endif 7 | SUBDIRS = $(GTK_SUBDIRS) lib $(OPENGL_SUBDIRS) wf ui decoder . test waveform 8 | 9 | lib_LTLIBRARIES = libwaveformui.la libwaveformcore.la 10 | 11 | libwaveformcore_la_SOURCES = 12 | libwaveformcore_la_LIBADD = \ 13 | decoder/libdecoder.la \ 14 | wf/libwfcore.la 15 | 16 | libwaveformui_la_SOURCES = 17 | libwaveformui_la_LIBADD = \ 18 | ui/libwf.la 19 | 20 | AM_CFLAGS = \ 21 | -DG_LOG_DOMAIN=\"Waveform\" \ 22 | -D_FILE_OFFSET_BITS=64 \ 23 | -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ 24 | -I$(top_srcdir)/libs \ 25 | $(GTK_CFLAGS) \ 26 | $(OPENGL_CFLAGS) 27 | 28 | EXTRA_DIST = \ 29 | package/gentoo/media-libs/libwaveform/libwaveform-0.1.0.ebuild 30 | 31 | shaderdir = $(datadir)/$(PACKAGE)/shaders 32 | 33 | pkgconfigdir = $(libdir)/pkgconfig 34 | pkgconfig_DATA = libwaveform.pc 35 | 36 | .PHONY: dummy 37 | 38 | CLEANFILES = libwaveform.pc 39 | -------------------------------------------------------------------------------- /wf/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2012-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #ifdef __wf_private__ 14 | 15 | #ifndef __wf_utils_c__ 16 | extern int wf_debug; 17 | #endif 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #ifdef DEBUG 24 | #define IF_WF_DEBUG if(agl->debug) 25 | #else 26 | #define IF_WF_DEBUG if(false) 27 | #endif 28 | 29 | #endif 30 | 31 | #include "debug/debug.h" 32 | -------------------------------------------------------------------------------- /test/gen/thumbnail.c: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of the Ayyi project. http://ayyi.org | 4 | * | copyright (C) 2013-2019 Tim Orford | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | */ 12 | #include "config.h" 13 | #include 14 | #include 15 | 16 | int main(int argc, char* argv[]) 17 | { 18 | GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, 96, 96); 19 | gdk_pixbuf_save(pixbuf, "thumbnail.png", "png", NULL, NULL); 20 | 21 | return EXIT_SUCCESS; 22 | } 23 | -------------------------------------------------------------------------------- /ui/actors/hover.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2025-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | | 11 | | HoverActor displays time and level for the current pointer position. | 12 | | | 13 | +----------------------------------------------------------------------+ 14 | */ 15 | 16 | #pragma once 17 | 18 | #include "waveform/actor.h" 19 | 20 | AGlActor* hover_actor (WaveformActor*); 21 | -------------------------------------------------------------------------------- /shaders/ass.vert: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2012-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #version 330 core 14 | layout(location = 0) in vec2 position; // Location corresponds to the binding in the application 15 | layout(location = 1) in vec2 texcoord; 16 | 17 | uniform vec2 modelview; 18 | uniform vec2 translate; 19 | 20 | out vec2 tex_coords; 21 | 22 | void main () 23 | { 24 | tex_coords = texcoord; 25 | gl_Position = vec4(vec2(1., -1.) * (position + translate) / modelview - vec2(1., -1.), 0., 1.); 26 | } 27 | -------------------------------------------------------------------------------- /gtkglext-1.0/gtk/gtkgl.h: -------------------------------------------------------------------------------- 1 | /* GtkGLExt - OpenGL Extension to GTK+ 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GTK_GL_H__ 20 | #define __GTK_GL_H__ 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /shaders/lines.vert: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2021 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | attribute vec4 vertex; 19 | 20 | uniform vec2 modelview; 21 | uniform vec2 translate; 22 | 23 | varying vec2 tex_coords; 24 | varying vec2 position; 25 | 26 | void main () 27 | { 28 | position = vertex.xy; 29 | tex_coords = vertex.zw; 30 | gl_Position = vec4((vertex.xy + translate) / modelview - vec2(1.0, -1.0), 1.0, 1.0); 31 | } 32 | -------------------------------------------------------------------------------- /wf/peakgen.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2012-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #pragma once 14 | 15 | void waveform_ensure_peakfile (Waveform*, WfPeakfileCallback, gpointer); 16 | char* waveform_ensure_peakfile__sync (Waveform*); 17 | void waveform_peakgen (Waveform*, const char* peakfile, WfCallback3, gpointer); 18 | void waveform_peakgen_cancel (Waveform*); 19 | 20 | #ifdef __wf_private_h__ 21 | bool wf_peakgen__sync (const char* wav, const char* peakfile, WfPreview*, GError**); 22 | #endif 23 | -------------------------------------------------------------------------------- /shaders/hires_ng.vert: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2021 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | attribute vec4 vertex; 19 | 20 | uniform vec2 modelview; 21 | uniform vec2 translate; 22 | 23 | varying vec2 tex_coords; 24 | varying vec2 position; 25 | 26 | void main () 27 | { 28 | tex_coords = vertex.zw; 29 | position = vertex.xy; 30 | gl_Position = vec4(vec2(1., -1.) * (vertex.xy + translate) / modelview - vec2(1.0, -1.0), 1.0, 1.0); 31 | } 32 | -------------------------------------------------------------------------------- /shaders/hires.vert: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2012 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | //varying vec2 MCposition; 19 | 20 | void main() 21 | { 22 | gl_TexCoord[0] = gl_MultiTexCoord1; 23 | gl_TexCoord[1] = gl_MultiTexCoord2; 24 | gl_TexCoord[2] = gl_MultiTexCoord3; 25 | gl_TexCoord[3] = gl_MultiTexCoord4; 26 | //MCposition = gl_Vertex.xy; 27 | //vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex); //TODO 28 | gl_Position = ftransform(); 29 | } 30 | -------------------------------------------------------------------------------- /shaders/peak.vert: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2012 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | //varying vec2 MCposition; 19 | 20 | void main() 21 | { 22 | gl_TexCoord[0] = gl_MultiTexCoord1; 23 | gl_TexCoord[1] = gl_MultiTexCoord2; 24 | gl_TexCoord[2] = gl_MultiTexCoord3; 25 | gl_TexCoord[3] = gl_MultiTexCoord4; 26 | //MCposition = gl_Vertex.xy; 27 | //vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex); //TODO 28 | gl_Position = ftransform(); 29 | } 30 | -------------------------------------------------------------------------------- /shaders/peak_nonscaling.vert: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2012 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | //varying vec2 MCposition; 19 | 20 | void main() 21 | { 22 | gl_TexCoord[0] = gl_MultiTexCoord1; 23 | gl_TexCoord[1] = gl_MultiTexCoord2; 24 | gl_TexCoord[2] = gl_MultiTexCoord3; 25 | gl_TexCoord[3] = gl_MultiTexCoord4; 26 | //MCposition = gl_Vertex.xy; 27 | //vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex); //TODO 28 | gl_Position = ftransform(); 29 | } 30 | -------------------------------------------------------------------------------- /shaders/ruler.vert: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2021 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | attribute vec4 vertex; 19 | 20 | uniform vec2 modelview; 21 | uniform vec2 translate; 22 | 23 | varying vec2 MCposition; 24 | varying vec2 ecPosition; 25 | 26 | void main() 27 | { 28 | MCposition = gl_Vertex.xy; 29 | ecPosition = (gl_ModelViewMatrix * gl_Vertex).xy; 30 | gl_Position = vec4(vec2(1., -1.) * (gl_Vertex.xy + translate) / modelview - vec2(1.0, -1.0), 1.0, 1.0); 31 | } 32 | -------------------------------------------------------------------------------- /shaders/ruler_bottom.vert: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2021 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | attribute vec4 vertex; 19 | 20 | uniform vec2 modelview; 21 | uniform vec2 translate; 22 | 23 | varying vec2 MCposition; 24 | varying vec2 ecPosition; 25 | 26 | void main () 27 | { 28 | MCposition = gl_Vertex.xy; 29 | ecPosition = (gl_ModelViewMatrix * gl_Vertex).xy; 30 | gl_Position = vec4(vec2(1., -1.) * (gl_Vertex.xy + translate) / modelview - vec2(1.0, -1.0), 1.0, 1.0); 31 | } 32 | -------------------------------------------------------------------------------- /shaders/ruler_frames.vert: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2021 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | attribute vec4 vertex; 19 | 20 | uniform vec2 modelview; 21 | uniform vec2 translate; 22 | 23 | varying vec2 MCposition; 24 | varying vec2 ecPosition; 25 | 26 | void main () 27 | { 28 | MCposition = gl_Vertex.xy; 29 | ecPosition = (gl_ModelViewMatrix * gl_Vertex).xy; 30 | gl_Position = vec4(vec2(1., -1.) * (gl_Vertex.xy + translate) / modelview - vec2(1.0, -1.0), 1.0, 1.0); 31 | } 32 | -------------------------------------------------------------------------------- /wf/global.c: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of the Ayyi project. http://ayyi.org | 4 | * | copyright (C) 2012-2020 Tim Orford | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | */ 12 | #define __waveform_peak_c__ 13 | #define __wf_private__ 14 | #include "config.h" 15 | #include "wf/waveform.h" 16 | #include "wf/loaders/riff.h" 17 | 18 | WF* wf = NULL; 19 | 20 | 21 | WF* 22 | wf_get_instance () 23 | { 24 | if(!wf){ 25 | wf = WF_NEW(WF, 26 | .domain = "Libwaveform", 27 | .peak_cache = g_hash_table_new(g_direct_hash, g_direct_equal), 28 | .audio.cache = g_hash_table_new(g_direct_hash, g_direct_equal), 29 | .load_peak = wf_load_riff_peak, //set the default loader 30 | ); 31 | } 32 | return wf; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gdkglinit.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __gdk_gl_init_h__ 20 | #define __gdk_gl_init_h__ 21 | 22 | #include 23 | 24 | G_BEGIN_DECLS 25 | 26 | gboolean gdk_gl_init_check (int *argc, char ***argv); 27 | void gdk_gl_init (int *argc, char ***argv); 28 | 29 | G_END_DECLS 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/glext/list-ext.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | # 3 | # list-ext.pl 4 | # 5 | # list OpenGL extensions. 6 | # 7 | # written by Naofumi Yasufuku 8 | # 9 | 10 | @glext_headers = ("glext.h", "glext-extra.h"); 11 | @glxext_headers = ("glxext.h", "glxext-extra.h"); 12 | @wglext_headers = ("wglext.h", "wglext-extra.h"); 13 | 14 | if (!@ARGV) { 15 | @input_headers = (@glext_headers, @glxext_headers, @wglext_headers); 16 | } elsif ($ARGV[0] eq "--gl") { 17 | @input_headers = @glext_headers; 18 | } elsif ($ARGV[0] eq "--glx") { 19 | @input_headers = @glxext_headers; 20 | } elsif ($ARGV[0] eq "--wgl") { 21 | @input_headers = @wglext_headers; 22 | } 23 | 24 | foreach $in (@input_headers) { 25 | open(IN, $in) || die "cannot open $in"; 26 | while () { 27 | chomp; 28 | if (/#ifndef\s+(GL|GLX|WGL)_[a-zA-Z0-9]+_[a-z0-9_]+/) { 29 | @line = split; 30 | push(@tmp_exts, $line[1]); 31 | } 32 | } 33 | close(IN); 34 | } 35 | 36 | @exts = sort(@tmp_exts); 37 | print "$exts[0]\n"; 38 | for ($i = 1; $i <= $#exts; $i++) { 39 | if ($exts[$i] ne $exts[$i-1]) { 40 | print "$exts[$i]\n"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /gtkglext-1.0/gtk/gtkglprivate.h: -------------------------------------------------------------------------------- 1 | /* GtkGLExt - OpenGL Extension to GTK+ 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GTK_GL_PRIVATE_H__ 20 | #define __GTK_GL_PRIVATE_H__ 21 | 22 | #include 23 | 24 | G_BEGIN_DECLS 25 | 26 | /* Install colormap to top-level window. */ 27 | extern gboolean _gtk_gl_widget_install_toplevel_cmap; 28 | 29 | G_END_DECLS 30 | 31 | #endif /* __GTK_GL_PRIVATE_H__ */ 32 | -------------------------------------------------------------------------------- /shaders/Makefile.am: -------------------------------------------------------------------------------- 1 | all: *.vert *.frag 2 | ../lib/agl/agl/shaders/make_shaders peak peak_nonscaling horizontal vertical hires hires_ng ruler ruler_bottom ruler_frames ass lines cursor 3 | 4 | clean-local: 5 | if [ -f shaders.c ]; then rm shaders.c; fi 6 | 7 | SHADERS = \ 8 | peak.vert \ 9 | peak.frag \ 10 | hires_ng.vert \ 11 | hires_ng.frag \ 12 | vertical.vert \ 13 | vertical.frag \ 14 | horizontal.vert \ 15 | horizontal.frag \ 16 | hires.vert \ 17 | hires.frag \ 18 | peak_nonscaling.vert \ 19 | peak_nonscaling.frag \ 20 | ruler.vert \ 21 | ruler.frag \ 22 | ruler_bottom.vert \ 23 | ruler_bottom.frag \ 24 | ruler_frames.vert \ 25 | ruler_frames.frag \ 26 | lines.vert \ 27 | lines.frag \ 28 | ass.vert \ 29 | ass.frag \ 30 | cursor.vert \ 31 | cursor.frag 32 | 33 | EXTRA_DIST = \ 34 | $(SHADERS) 35 | 36 | ## shaders are now compiled in, so no longer need to be installed 37 | Xinstall-data-local: 38 | @$(NORMAL_INSTALL) 39 | $(mkinstalldirs) $(DESTDIR)$(shaderdir); \ 40 | for shader in shaders/peak.vert shaders/peak.frag shaders/vertical.vert shaders/vertical.frag $(SHADERS); do \ 41 | if test -f $$shader; then \ 42 | $(INSTALL_DATA) $$shader $(DESTDIR)$(shaderdir); \ 43 | fi \ 44 | done; 45 | 46 | -------------------------------------------------------------------------------- /test/gen/cpgrs.h: -------------------------------------------------------------------------------- 1 | #ifndef __cpgrs_h__ 2 | #define __cpgrs_h__ 3 | #include "generator.h" 4 | 5 | class CPGRS : public Generator 6 | { 7 | public: 8 | float gain; // gain 9 | float attack; // interface->addHorizontalSlider("attack", &fslider4, 0.01f, 0.0f, 1.0f, 0.001f); 10 | float sustain; // interface->addHorizontalSlider("sustain", &fslider1, 0.5f, 0.0f, 1.0f, 0.01f); 11 | float release; // interface->addHorizontalSlider("release", &fslider2, 0.2f, 0.0f, 1.0f, 0.001f); 12 | float decay; // interface->addHorizontalSlider("decay", &fslider3, 0.3f, 0.0f, 1.0f, 0.001f); 13 | float freq; // "freq", 4.4e+02f, 2e+01f, 2e+04f, 1.0f 14 | 15 | private: 16 | float fSamplingFreq; 17 | float filter_bandwidth; // 2-filter: addHorizontalSlider("bandwidth (Hz)", &fslider0, 1e+02f, 2e+01f, 2e+04f, 1e+01f); 18 | float fConst0; 19 | float fConst1; 20 | float on_off_button; // gate (on/off) 21 | int iRec1[2]; 22 | float fRec2[2]; 23 | int iRec3[2]; 24 | float fVec0[3]; 25 | float fRec0[3]; 26 | 27 | int t; 28 | 29 | public: 30 | 31 | void init (); 32 | void compute (int count, double** input, double** output); 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /ui/actors/grid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of the Ayyi project. http://ayyi.org | 4 | * | copyright (C) 2013-2021 Tim Orford | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | * +----------------------------------------------------------------------+ 12 | * | WaveformGrid draws timeline markers onto a shared opengl drawable. | 13 | * +----------------------------------------------------------------------+ 14 | * | The scaling is controlled by the sample_rate and samples_per_pixel | 15 | * | properties of the WaveformContext. | 16 | * +----------------------------------------------------------------------+ 17 | */ 18 | 19 | #ifndef __wf_grid_actor_h__ 20 | #define __wf_grid_actor_h__ 21 | 22 | AGlActor* grid_actor (WaveformActor*); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gdkglquery.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GDK_GL_QUERY_H__ 20 | #define __GDK_GL_QUERY_H__ 21 | 22 | #include 23 | 24 | G_BEGIN_DECLS 25 | 26 | #ifndef GDK_MULTIHEAD_SAFE 27 | gboolean gdk_gl_query_extension (void); 28 | #endif 29 | 30 | gboolean gdk_gl_query_gl_extension (const char *extension); 31 | 32 | GdkGLProc gdk_gl_get_proc_address (const char *proc_name); 33 | 34 | G_END_DECLS 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /gtkglext-1.0/gtk/gtkglversion.c: -------------------------------------------------------------------------------- 1 | /* GtkGLExt - OpenGL Extension to GTK+ 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifdef HAVE_CONFIG_H 20 | #include "config.h" 21 | #endif /* HAVE_CONFIG_H */ 22 | 23 | #include "gtkglversion.h" 24 | 25 | const guint gtkglext_major_version = GTKGLEXT_MAJOR_VERSION; 26 | const guint gtkglext_minor_version = GTKGLEXT_MINOR_VERSION; 27 | const guint gtkglext_micro_version = GTKGLEXT_MICRO_VERSION; 28 | const guint gtkglext_interface_age = GTKGLEXT_INTERFACE_AGE; 29 | const guint gtkglext_binary_age = GTKGLEXT_BINARY_AGE; 30 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gdkgl.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GDK_GL_H__ 20 | #define __GDK_GL_H__ 21 | 22 | #ifdef USE_EPOXY 23 | #include 24 | #include 25 | #endif 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /gtkglext-1.0/gtk/gtkglinit.h: -------------------------------------------------------------------------------- 1 | /* GtkGLExt - OpenGL Extension to GTK+ 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GTK_GL_INIT_H__ 20 | #define __GTK_GL_INIT_H__ 21 | 22 | #include 23 | 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | 28 | /* 29 | * Initialization routines. 30 | */ 31 | 32 | gboolean gtk_gl_init_check (int *argc, 33 | char ***argv); 34 | 35 | void gtk_gl_init (int *argc, 36 | char ***argv); 37 | 38 | G_END_DECLS 39 | 40 | #endif /* __GTK_GL_INIT_H__ */ 41 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gdkgltypes.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GDK_GL_TYPES_H__ 20 | #define __GDK_GL_TYPES_H__ 21 | 22 | #include 23 | 24 | G_BEGIN_DECLS 25 | 26 | /* 27 | * Forward declarations of commonly used types 28 | */ 29 | 30 | typedef void (*GdkGLProc)(void); 31 | 32 | typedef struct _GdkGLConfig GdkGLConfig; 33 | typedef struct _GdkGLContext GdkGLContext; 34 | 35 | typedef struct _GdkGLPixmap GdkGLPixmap; 36 | typedef struct _GdkGLWindow GdkGLWindow; 37 | 38 | G_END_DECLS 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /test/gen/generator.cc: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2015 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | 17 | */ 18 | #include "config.h" 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "cpgrs.h" 25 | #include "generator.h" 26 | 27 | 28 | Note::Note (Generator* g, int _length) 29 | { 30 | generator = g; 31 | length = _length; 32 | t = 0; 33 | 34 | generator->init(); 35 | generator->on = true; 36 | } 37 | 38 | 39 | Note::~Note() 40 | { 41 | } 42 | 43 | 44 | void 45 | Note::compute (int count, double** input, double** output) 46 | { 47 | generator->compute(count, input, output); 48 | 49 | if(++t > length) generator->on = false; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /wf/worker.h: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of libwaveform | 4 | * | https://github.com/ayyi/libwaveform | 5 | * | copyright (C) 2012-2020 Tim Orford | 6 | * +----------------------------------------------------------------------+ 7 | * | This program is free software; you can redistribute it and/or modify | 8 | * | it under the terms of the GNU General Public License version 3 | 9 | * | as published by the Free Software Foundation. | 10 | * +----------------------------------------------------------------------+ 11 | * 12 | */ 13 | #ifndef __wf_worker_h__ 14 | #define __wf_worker_h__ 15 | 16 | #include "wf/typedefs.h" 17 | 18 | #ifdef __wf_private__ 19 | 20 | typedef struct _QueueItem QueueItem; 21 | 22 | #ifdef __wf_worker_private__ 23 | struct _QueueItem 24 | { 25 | GWeakRef ref; 26 | WfCallback2 work; 27 | WfCallback3 done; 28 | WfCallback free; 29 | void* user_data; 30 | gboolean cancelled; 31 | }; 32 | #endif 33 | 34 | void wf_worker_init (WfWorker*); 35 | void wf_worker_push_job (WfWorker*, Waveform*, WfCallback2 work, WfCallback3 done, WfCallback free, gpointer); 36 | void wf_worker_cancel_jobs (WfWorker*, Waveform*); 37 | 38 | #endif 39 | #endif 40 | -------------------------------------------------------------------------------- /shaders/vertical.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D tex2d; 2 | uniform vec4 fg_colour; 3 | 4 | const float blurSize = 1.0/256.0; // this size results in every step being one pixel wide if the tex2d texture is of size 256x256 5 | 6 | void main(void) 7 | { 8 | vec4 sum = vec4(0.0); 9 | 10 | //float alpha = texture2D(tex2d, gl_TexCoord[0].xy).a; 11 | //if(alpha > 0.5){ 12 | // gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); 13 | //}else{ 14 | 15 | sum += texture2D(tex2d, vec2(gl_TexCoord[0].x, gl_TexCoord[0].y - 4.0*blurSize)) * 0.05; 16 | sum += texture2D(tex2d, vec2(gl_TexCoord[0].x, gl_TexCoord[0].y - 3.0*blurSize)) * 0.09; 17 | sum += texture2D(tex2d, vec2(gl_TexCoord[0].x, gl_TexCoord[0].y - 2.0*blurSize)) * 0.12; 18 | sum += texture2D(tex2d, vec2(gl_TexCoord[0].x, gl_TexCoord[0].y - 1.0*blurSize)) * 0.15; 19 | sum += texture2D(tex2d, vec2(gl_TexCoord[0].x, gl_TexCoord[0].y )) * 0.16; 20 | sum += texture2D(tex2d, vec2(gl_TexCoord[0].x, gl_TexCoord[0].y + 1.0*blurSize)) * 0.15; 21 | sum += texture2D(tex2d, vec2(gl_TexCoord[0].x, gl_TexCoord[0].y + 2.0*blurSize)) * 0.12; 22 | sum += texture2D(tex2d, vec2(gl_TexCoord[0].x, gl_TexCoord[0].y + 3.0*blurSize)) * 0.09; 23 | sum += texture2D(tex2d, vec2(gl_TexCoord[0].x, gl_TexCoord[0].y + 4.0*blurSize)) * 0.05; 24 | 25 | //sum.g = 0.0; 26 | gl_FragColor = sum * fg_colour; 27 | 28 | //vec3 t1 = texture2D(tex2d, gl_TexCoord[0].xy); 29 | //gl_FragColor = vec4(t1, 1.0); 30 | //gl_FragColor = vec4(1.0, 0.5, 0.25, 1.0); 31 | //} 32 | } 33 | -------------------------------------------------------------------------------- /test/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of libwaveform https://github.com/ayyi/libwaveform | 4 | | copyright (C) 2012-2021 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #define __common_c__ 14 | #define __wf_private__ 15 | 16 | #include "config.h" 17 | #if defined(USE_GTK) || defined(__GTK_H__) 18 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 19 | #include 20 | #pragma GCC diagnostic warning "-Wdeprecated-declarations" 21 | #endif 22 | #include "agl/actor.h" 23 | #include "wf/private.h" 24 | #include "waveform/utils.h" 25 | #include "test/runner.h" 26 | #include "test/common.h" 27 | 28 | extern gpointer tests[]; 29 | 30 | 31 | #if defined(__no_setup__) 32 | int 33 | setup () 34 | { 35 | TEST.n_tests = G_N_ELEMENTS(tests); 36 | 37 | return 0; 38 | } 39 | #endif 40 | 41 | 42 | WfTest* 43 | wf_test_new () 44 | { 45 | static WfTest* t = NULL; 46 | //if(t) g_free0(t); // valgrind says 'invalid free' 47 | 48 | return t = WF_NEW(WfTest, .test_idx = TEST.current.test); 49 | } 50 | -------------------------------------------------------------------------------- /ui/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = actors 2 | 3 | if ENABLE_SYSTEM_GTKGLEXT 4 | else 5 | LOCAL_GTKGLEXT_CFLAGS = \ 6 | -I$(top_srcdir)/gtkglext-1.0 7 | endif 8 | 9 | AM_CFLAGS = \ 10 | -DG_LOG_DOMAIN=\"Waveform\" \ 11 | -D_FILE_OFFSET_BITS=64 \ 12 | -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ 13 | -I$(includedir) \ 14 | -I$(top_srcdir) \ 15 | -I../lib/ \ 16 | -I../lib/agl \ 17 | $(GTK_CFLAGS) \ 18 | $(SDL_CFLAGS) \ 19 | $(LOCAL_GTKGLEXT_CFLAGS) \ 20 | $(OPENGL_CFLAGS) 21 | 22 | noinst_LTLIBRARIES = libwf.la 23 | 24 | if ENABLE_GTK 25 | GTK_SOURCES = \ 26 | view_plus.c view_plus.h 27 | endif 28 | 29 | if ENABLE_OPENGL 30 | OPENGL_SOURCES = \ 31 | $(GTK_SOURCES) \ 32 | context.c context.h \ 33 | context.root.c \ 34 | actor.c actor.h \ 35 | shader.c shader.h \ 36 | texture_cache.c texture_cache.h 37 | OPENGL_LIBADD = \ 38 | actors/libactors.la 39 | endif 40 | 41 | if ENABLE_DEBUG 42 | DEBUG_SOURCES = \ 43 | debug_helper.c debug_helper.h 44 | endif 45 | 46 | libwf_la_SOURCES = \ 47 | typedefs.h \ 48 | private.h \ 49 | $(OPENGL_SOURCES) \ 50 | pixbuf.c pixbuf.h \ 51 | transition_behaviour.c transition_behaviour.h \ 52 | invalidator.c invalidator.h \ 53 | utils.c utils.h \ 54 | $(DEBUG_SOURCES) 55 | 56 | libwf_la_LIBADD = \ 57 | $(OPENGL_LIBADD) 58 | 59 | EXTRA_DIST = \ 60 | renderer/ng.c \ 61 | renderer/res_med.c \ 62 | renderer/res_hi.c \ 63 | renderer/res_v_hi.c \ 64 | renderer/res_lo.c \ 65 | renderer/res_v_low.c \ 66 | renderer/preview.c 67 | 68 | CLEANFILES = 69 | 70 | -------------------------------------------------------------------------------- /ui/private.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of libwaveform https://github.com/ayyi/libwaveform | 4 | | copyright (C) 2012-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #pragma once 14 | 15 | #include "agl/fbo.h" 16 | #include "waveform/ui-typedefs.h" 17 | 18 | //TODO refactor based on _texture_hi (eg reverse order of indirection) 19 | struct _wf_texture_list // WfGlBlock - used at MED and LOW resolutions in gl1 mode. 20 | { 21 | int size; 22 | struct { 23 | unsigned* main; // array of texture id 24 | unsigned* neg; // array of texture id - only used in shader mode. 25 | } peak_texture[WF_MAX_CH]; 26 | AGlFBO** fbo; 27 | #ifdef USE_FX 28 | AGlFBO** fx_fbo; 29 | #endif 30 | #ifdef WF_SHOW_RMS 31 | unsigned* rms_texture; 32 | #endif 33 | }; 34 | 35 | WaveformActor* wf_actor_new (Waveform*, WaveformContext*); 36 | 37 | #ifdef DEBUG 38 | const char* wf_actor_print_mode (WaveformActor*); 39 | #endif 40 | -------------------------------------------------------------------------------- /test/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | COLOR_FAILURE="\\033[1;31m" 6 | COLOR_WARNING="\\033[1;33m" 7 | COLOR_NORMAL="\\033[0;39m" 8 | 9 | dir=`dirname $0` 10 | 11 | $dir/waveform || echo -en ${COLOR_FAILURE}1 FAIL${COLOR_NORMAL}\\n 12 | $dir/promise || echo -en ${COLOR_FAILURE}2 FAIL${COLOR_NORMAL}\\n 13 | $dir/32bit || echo -en ${COLOR_FAILURE}3 FAIL${COLOR_NORMAL}\\n 14 | $dir/cache || echo -en ${COLOR_FAILURE}4 FAIL${COLOR_NORMAL}\\n 15 | $dir/view_plus_test -n || echo -en ${COLOR_FAILURE}5 FAIL${COLOR_NORMAL}\\n 16 | $dir/actor_test -n || echo -en ${COLOR_FAILURE}6 FAIL${COLOR_NORMAL}\\n 17 | $dir/actor_plus -n || echo -en ${COLOR_FAILURE}7 FAIL${COLOR_NORMAL}\\n 18 | $dir/hires -n || echo -en ${COLOR_FAILURE}8 FAIL${COLOR_NORMAL}\\n 19 | $dir/scenegraph -n || echo -en ${COLOR_FAILURE}9 FAIL${COLOR_NORMAL}\\n 20 | $dir/viewport -n || echo -en ${COLOR_FAILURE}10 FAIL${COLOR_NORMAL}\\n 21 | $dir/group -n || echo -en ${COLOR_FAILURE}11 FAIL${COLOR_NORMAL}\\n 22 | $dir/actor_no_scene -n || echo -en ${COLOR_FAILURE}12 FAIL${COLOR_NORMAL}\\n 23 | $dir/multi_scene -n || echo -en ${COLOR_FAILURE}13 FAIL${COLOR_NORMAL}\\n 24 | $dir/frame_rate -n || echo -en ${COLOR_FAILURE}14 FAIL${COLOR_NORMAL}\\n 25 | $dir/glx -n || echo -en ${COLOR_FAILURE}15 FAIL${COLOR_NORMAL}\\n 26 | $dir/list -n || echo -en ${COLOR_FAILURE}16 FAIL${COLOR_NORMAL}\\n 27 | $dir/sdl -n || echo -en ${COLOR_FAILURE}17 FAIL${COLOR_NORMAL}\\n 28 | $dir/ass -n || echo -en ${COLOR_FAILURE}18 FAIL${COLOR_NORMAL}\\n 29 | -------------------------------------------------------------------------------- /gtkglext-1.0/gtk/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | CLEANFILES = 3 | 4 | EXTRA_DIST = 5 | 6 | common_includes = \ 7 | -DG_LOG_DOMAIN=\"GtkGLExt\" \ 8 | -DGTK_GL_COMPILATION \ 9 | -I$(top_srcdir) \ 10 | -I$(top_builddir)/gdk \ 11 | $(GTKGLEXT_DEBUG_FLAGS) \ 12 | $(GTK_CFLAGS) \ 13 | $(GL_CFLAGS) \ 14 | $(GDKGLEXT_WIN_CFLAGS) 15 | 16 | common_ldflags = \ 17 | -version-info $(GTKGLEXT_CURRENT):$(GTKGLEXT_REVISION):$(GTKGLEXT_AGE) \ 18 | -export-dynamic \ 19 | -rpath $(libdir) \ 20 | -no-undefined 21 | 22 | common_libadd = \ 23 | $(top_builddir)/gdk/$(gdkglext_targetlib) \ 24 | $(GTK_LIBS) \ 25 | $(GL_LIBS) \ 26 | $(GDKGLEXT_WIN_LIBS) \ 27 | $(MATH_LIB) 28 | 29 | # 30 | # setup source file variables 31 | # 32 | 33 | gtkglext_public_h_sources = \ 34 | gtkgl.h \ 35 | gtkglinit.h \ 36 | gtkglwidget.h 37 | 38 | gtkglext_private_h_sources = \ 39 | gtkglprivate.h 40 | 41 | gtkglext_c_sources = \ 42 | gtkglinit.c \ 43 | gtkglwidget.c 44 | 45 | gtkglext_headers = \ 46 | $(gtkglext_public_h_sources) \ 47 | gtkgldebug.h 48 | 49 | gtkglext_sources = \ 50 | $(gtkglext_private_h_sources) \ 51 | $(gtkglext_c_sources) 52 | 53 | # 54 | # setup GtkGLExt sources and their dependancies 55 | # 56 | 57 | gtkglextincludedir = $(includedir)/gtkglext-@GTKGLEXT_API_VERSION@/gtk 58 | gtkglextinclude_HEADERS = $(gtkglext_headers) 59 | 60 | AM_CPPFLAGS = $(common_includes) 61 | 62 | #libgtkglext_x11_1_0_la_SOURCES = $(gtkglext_sources) 63 | #libgtkglext_x11_1_0_la_LDFLAGS = $(common_ldflags) 64 | #libgtkglext_x11_1_0_la_LIBADD = $(common_libadd) 65 | 66 | noinst_LTLIBRARIES = libgtk.la 67 | libgtk_la_SOURCES = $(gtkglext_sources) 68 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gdkgloverlay.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GDK_GL_OVERLAY_X11_H__ 20 | #define __GDK_GL_OVERLAY_X11_H__ 21 | 22 | #include 23 | 24 | G_BEGIN_DECLS 25 | 26 | typedef enum 27 | { 28 | GDK_GL_OVERLAY_TRANSPARENT_NONE, 29 | GDK_GL_OVERLAY_TRANSPARENT_PIXEL, 30 | GDK_GL_OVERLAY_TRANSPARENT_MASK 31 | } GdkGLOverlayTransparentType; 32 | 33 | typedef struct _GdkGLOverlayInfo GdkGLOverlayInfo; 34 | 35 | struct _GdkGLOverlayInfo 36 | { 37 | GdkVisual *visual; 38 | GdkGLOverlayTransparentType transparent_type; 39 | guint32 value; 40 | gint32 layer; 41 | }; 42 | 43 | /* private at present... */ 44 | gboolean _gdk_x11_gl_overlay_get_info (GdkVisual*, GdkGLOverlayInfo*); 45 | 46 | G_END_DECLS 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /ui/actors/text.h: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of the Ayyi project. https://www.ayyi.org | 4 | * | copyright (C) 2012-2021 Tim Orford | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | */ 12 | 13 | #ifndef __text_actor_h__ 14 | #define __text_actor_h__ 15 | 16 | #include 17 | 18 | typedef struct { 19 | int width; 20 | int height; 21 | int y_offset; 22 | } Title; 23 | 24 | typedef struct { 25 | AGlActor actor; 26 | 27 | char* title; 28 | Title _title; 29 | char* text; 30 | uint32_t text_colour; 31 | uint32_t title_colour1; 32 | uint32_t title_colour2; 33 | 34 | int baseline; 35 | struct { 36 | GLuint ids[1]; 37 | int width; 38 | int height; 39 | } texture; 40 | 41 | bool title_is_rendered; 42 | } TextActor; 43 | 44 | AGlActorClass* text_actor_get_class (); 45 | AGlActor* text_actor (WaveformActor*); 46 | void text_actor_set_colour (TextActor*, uint32_t, uint32_t); 47 | void text_actor_set_text (TextActor*, char* title, char* text); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /ui/invalidator.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2021-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | | Invalidator behaviour 12 | | --------------------- 13 | | 14 | | Validity of render state can be unset for various aspects, which 15 | | will cause the corresponding resolver functions to be called in 16 | | a synchronised manner so that all updates are made in a single 17 | | render cycle. 18 | | 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "agl/behaviour.h" 24 | 25 | typedef struct _Invalidator Invalidator; 26 | 27 | typedef bool (*InvalidatorResolve) (Invalidator*); 28 | 29 | struct _Invalidator 30 | { 31 | AGlBehaviour behaviour; 32 | int n_types; 33 | int valid; // bitfield, one field for each of the types 34 | void* user_data; 35 | guint recheck_queue; 36 | InvalidatorResolve resolve[]; 37 | }; 38 | 39 | AGlBehaviourClass* 40 | invalidator_get_class (); 41 | 42 | void invalidator_invalidate_item (Invalidator*, int); 43 | void invalidator_queue_check (Invalidator*); 44 | -------------------------------------------------------------------------------- /wf/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2012-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #pragma once 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __wf_private__ 19 | 20 | #ifndef g_free0 21 | #define g_free0(var) ((var == NULL) ? NULL : (var = (g_free(var), NULL))) 22 | #endif 23 | 24 | #ifndef g_list_free0 25 | #define g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL))) 26 | #endif 27 | 28 | #ifndef g_error_free0 29 | #define g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) 30 | #endif 31 | 32 | #ifndef call 33 | #define call(FN, A, ...) if(FN) (FN)(A, ##__VA_ARGS__) 34 | #endif 35 | 36 | #endif // __wf_private__ 37 | 38 | #define WF_NEW(T, ...) ({T* obj = g_new0(T, 1); *obj = (T){__VA_ARGS__}; obj;}) 39 | 40 | #define wf_set_str(P, NAME) ({ if (P) g_free(P); P = NAME; }) 41 | 42 | #ifndef _g_source_remove0 43 | #define _g_source_remove0(S) {if(S) g_source_remove(S); S = 0;} 44 | #endif 45 | 46 | bool wf_get_filename_for_other_channel (const char* filename, char* other, int n_chars); 47 | -------------------------------------------------------------------------------- /ui/actors/spp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of libwaveform | 4 | * | https://github.com/ayyi/libwaveform | 5 | * | copyright (C) 2012-2020 Tim Orford | 6 | * +----------------------------------------------------------------------+ 7 | * | This program is free software; you can redistribute it and/or modify | 8 | * | it under the terms of the GNU General Public License version 3 | 9 | * | as published by the Free Software Foundation. | 10 | * +----------------------------------------------------------------------+ 11 | * | SONG POSITION POINTER (CURSOR) ACTOR | 12 | * | The time position can be set either by calling spp_actor_set_time() | 13 | * | or by middle-clicking on the waveform. | 14 | * +----------------------------------------------------------------------+ 15 | * 16 | */ 17 | 18 | #ifndef __spp_actor_h__ 19 | #define __spp_actor_h__ 20 | 21 | #include "agl/actor.h" 22 | 23 | typedef struct { 24 | AGlActor actor; 25 | WaveformActor* wf_actor; // The WfActor is needed to find positions when the WfContext is in non-scaled mode 26 | uint32_t text_colour; 27 | uint32_t time; // milliseconds (maximum of 1193 hours) 28 | uint32_t play_timeout; 29 | } SppActor; 30 | 31 | AGlActor* wf_spp_actor (WaveformActor*); 32 | void wf_spp_actor_set_time (SppActor*, uint32_t); 33 | 34 | #define WF_SPP_TIME_NONE UINT32_MAX 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /ui/transition_behaviour.h: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of the Ayyi project. http://ayyi.org | 4 | * | copyright (C) 2019-2019 Tim Orford | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | */ 12 | 13 | #ifndef __transition_behaviour_h__ 14 | #define __transition_behaviour_h__ 15 | 16 | #include "agl/behaviour.h" 17 | 18 | typedef struct 19 | { 20 | AGlBehaviour behaviour; 21 | int size; 22 | WfAnimatable animatables[]; 23 | } TransitionBehaviour; 24 | 25 | typedef struct 26 | { 27 | bool active; 28 | UVal value; 29 | } TransitionValue; 30 | 31 | typedef struct 32 | { 33 | bool active; 34 | float value; 35 | } TransitionValuef; 36 | 37 | typedef struct 38 | { 39 | bool active; 40 | int64_t value; 41 | } TransitionValue64; 42 | 43 | 44 | AGlBehaviourClass* transition_behaviour_get_class (); 45 | 46 | WfAnimation* transition_behaviour_set (TransitionBehaviour*, AGlActor*, TransitionValue[], WaveformActorFn, gpointer); 47 | WfAnimation* transition_behaviour_set_f (TransitionBehaviour*, AGlActor*, float, WaveformActorFn, gpointer); 48 | WfAnimation* transition_behaviour_set_i64 (TransitionBehaviour*, AGlActor*, TransitionValue64[], WaveformActorFn, gpointer); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /ui/texture_cache.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of libwaveform https://github.com/ayyi/libwaveform | 4 | | copyright (C) 2012-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | #pragma once 13 | 14 | #include "waveform/waveform.h" 15 | 16 | #ifdef WF_USE_TEXTURE_CACHE 17 | #ifdef __wf_private__ 18 | 19 | #define WF_TEXTURE_CACHE_LORES_MASK (1 << 23) 20 | #define WF_TEXTURE_CACHE_HIRES_MASK (1 << 22) 21 | #define WF_TEXTURE_CACHE_HIRES_NG_MASK (1 << 21) 22 | #define WF_TEXTURE_CACHE_V_LORES_MASK (1 << 20) 23 | 24 | typedef void (*WfOnSteal) (WfTexture*); 25 | 26 | struct _texture_cache 27 | { 28 | GArray* t; // type WfTexture 29 | WfOnSteal on_steal; 30 | }; 31 | 32 | void texture_cache_ref (); 33 | void texture_cache_unref (); 34 | void texture_cache_set_on_steal (WfOnSteal); 35 | int texture_cache_lookup (int tex_type, WaveformBlock); 36 | guint texture_cache_assign_new (int tex_type, WaveformBlock); 37 | void texture_cache_freshen (int tex_type, WaveformBlock); 38 | void texture_cache_remove (int tex_type, Waveform*, int); 39 | void texture_cache_remove_waveform (Waveform*); 40 | 41 | #endif // __wf_private__ 42 | #endif // WF_USE_TEXTURE_CACHE 43 | -------------------------------------------------------------------------------- /wf/promise.h: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of the Ayyi project. http://ayyi.org | 4 | * | copyright (C) 2012-2020 Tim Orford | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | */ 12 | #ifndef __wf_promise_h__ 13 | #define __wf_promise_h__ 14 | 15 | typedef void (*WfPromiseCallback) (gpointer user_data, gpointer); 16 | 17 | typedef union 18 | { 19 | int i; 20 | float f; 21 | char* c; 22 | 23 | } PromiseVal; 24 | 25 | typedef struct { 26 | PromiseVal value; 27 | GList* callbacks; // type WfPromiseCallback 28 | GList* children; // type AMPromise 29 | gpointer user_data; 30 | gboolean is_resolved; 31 | GError* error; 32 | int refcount; 33 | } AMPromise; 34 | 35 | AMPromise* am_promise_new (gpointer); 36 | void am_promise_unref (AMPromise*); 37 | void am_promise_add_callback (AMPromise*, WfPromiseCallback, gpointer); 38 | void am_promise_when (AMPromise*, AMPromise*, ...); 39 | void am_promise_resolve (AMPromise*, PromiseVal*); 40 | void am_promise_fail (AMPromise*, GError*); 41 | 42 | #define am_promise_unref0(var) ((var == NULL) ? NULL : (var = (am_promise_unref(var), NULL))) 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/glext/wglext-extra.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | /* 20 | * Additional WGL extensions. 21 | */ 22 | 23 | #ifndef __wglext_extra_h_ 24 | #define __wglext_extra_h_ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) 31 | #define WIN32_LEAN_AND_MEAN 1 32 | #include 33 | #endif 34 | 35 | #ifndef APIENTRY 36 | #define APIENTRY 37 | #endif 38 | #ifndef GLAPI 39 | #define GLAPI extern 40 | #endif 41 | 42 | /* 43 | * 3DFX 44 | */ 45 | 46 | /* 47 | * ARB 48 | */ 49 | 50 | /* 51 | * ATI 52 | */ 53 | 54 | /* 55 | * 3DFX 56 | */ 57 | 58 | /* 59 | * ARB 60 | */ 61 | 62 | /* 63 | * EXT 64 | */ 65 | 66 | /* 67 | * I3D 68 | */ 69 | 70 | /* 71 | * NV 72 | */ 73 | 74 | /* 75 | * OML 76 | */ 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /* __wglext_extra_h_ */ 83 | -------------------------------------------------------------------------------- /ui/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2012-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #pragma once 14 | 15 | #include "waveform/utils.h" 16 | #include "waveform/context.h" 17 | 18 | #ifndef true 19 | #define true TRUE 20 | #define false FALSE 21 | #endif 22 | 23 | float wf_int2db (short); 24 | 25 | #ifdef __wf_private__ 26 | 27 | #define TIMER_STOP FALSE 28 | 29 | #include "waveform/ui-typedefs.h" 30 | 31 | void wf_deinterleave (float* src, float** dest, uint64_t n_frames); 32 | void wf_deinterleave16 (short* src, short** dest, uint64_t n_frames); 33 | #endif 34 | 35 | #ifdef __GTK_H__ 36 | uint32_t wf_get_gtk_fg_color (GtkWidget*, GtkStateType); 37 | uint32_t wf_get_gtk_text_color (GtkWidget*, GtkStateType); 38 | uint32_t wf_get_gtk_base_color (GtkWidget*, GtkStateType, char alpha); 39 | uint32_t wf_color_gdk_to_rgba (GdkColor*); 40 | #endif 41 | void wf_colour_rgba_to_float (AGlColourFloat*, uint32_t rgba); 42 | bool wf_colour_is_dark_rgba (uint32_t); 43 | 44 | void wf_load_texture_from_alphabuf 45 | (WaveformContext*, int texture_id, AlphaBuf*); 46 | 47 | guint64 wf_get_time (); 48 | -------------------------------------------------------------------------------- /test/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. http://ayyi.org | 4 | | copyright (C) 2013-2021 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | | Common code for automated tests 12 | | (move stuff for non-automated tests to common2.h) 13 | | 14 | */ 15 | 16 | #include "wf/debug.h" 17 | #include "wf/waveform.h" 18 | #include "test/runner.h" 19 | #include "test/common2.h" 20 | 21 | KeyHandler* key_lookup (int keycode); 22 | 23 | #define START_LONG_TEST \ 24 | START_TEST; \ 25 | g_source_remove (TEST.timeout); \ 26 | TEST.timeout = 0; 27 | 28 | #define NEXT_CALLBACK(A, B, C) \ 29 | step++; \ 30 | void (*callback)() = callbacks[step]; \ 31 | callback(A, B, C); 32 | 33 | typedef struct { 34 | int test_idx; 35 | } WfTest; 36 | 37 | #define WF_TEST_FINISH \ 38 | if(c->test_idx != TEST.current.test) return; \ 39 | printf("%s: finish\n", TEST.current.name); \ 40 | TEST.current.finished = true; \ 41 | TEST.passed = true; \ 42 | test_finish(); \ 43 | wf_free(c); \ 44 | return; 45 | 46 | #define WF_TEST_FINISH_TIMER_STOP \ 47 | if(c->test_idx != TEST.current.test) return G_SOURCE_REMOVE; \ 48 | TEST.current.finished = true; \ 49 | TEST.passed = true; \ 50 | test_finish(); \ 51 | wf_free(c); \ 52 | return G_SOURCE_REMOVE; 53 | 54 | #define FAIL_IF_ERROR \ 55 | if(error && *error) FAIL_TEST((*error)->message); 56 | -------------------------------------------------------------------------------- /wf/typedefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2012-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #pragma once 14 | 15 | typedef struct _wf WF; 16 | typedef struct _Waveform Waveform; 17 | typedef struct _WaveformPrivate WaveformPrivate; 18 | typedef struct _WfBuf16 WfBuf16; 19 | typedef struct _WfPeakBuf WfPeakBuf; 20 | typedef struct _Peakbuf Peakbuf; 21 | typedef struct _WfBuf RmsBuf; 22 | typedef struct _WfAudioData WfAudioData; 23 | typedef struct _WfWorker WfWorker; 24 | typedef struct _texture_hi WfTextureHi; 25 | typedef struct _wf_texture_list WfGlBlock; 26 | 27 | typedef void (*WfCallback) (gpointer); 28 | typedef void (*WfCallback2) (Waveform*, gpointer); 29 | typedef void (*WfCallback3) (Waveform*, GError*, gpointer); 30 | typedef void (*WfCallback4) (Waveform*); 31 | typedef void (*WfAudioCallback) (Waveform*, int b, gpointer); 32 | typedef void (*WfPeakfileCallback) (Waveform*, char* peakfile_name, gpointer); 33 | 34 | typedef struct { int64_t start, end; } WfFrRange; 35 | 36 | enum 37 | { 38 | WF_MONO = 1, 39 | WF_STEREO, 40 | }; 41 | 42 | enum 43 | { 44 | WF_LEFT = 0, 45 | WF_RIGHT, 46 | WF_MAX_CH 47 | }; 48 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gdkgldrawable.c: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifdef HAVE_CONFIG_H 20 | #include "config.h" 21 | #endif 22 | 23 | #include 24 | 25 | #include "gdkglprivate.h" 26 | #include "gdkgldrawable.h" 27 | #include "gdkglx.h" 28 | #include "gdkglcontext.h" 29 | 30 | G_DEFINE_TYPE (GdkGLDrawable, gdk_gl_drawable, G_TYPE_OBJECT) 31 | 32 | 33 | static void 34 | gdk_gl_drawable_class_init (GdkGLDrawableClass *klass) 35 | { 36 | } 37 | 38 | static void 39 | gdk_gl_drawable_init (GdkGLDrawable *self) 40 | { 41 | } 42 | 43 | /** 44 | * gdk_gl_drawable_get_current: 45 | * 46 | * Returns the current #GdkGLDrawable. 47 | * 48 | * Return value: (transfer none): the current #GdkGLDrawable or NULL if there is no current drawable. 49 | **/ 50 | GdkGLDrawable* 51 | gdk_gl_drawable_get_current (void) 52 | { 53 | GDK_GL_NOTE_FUNC (); 54 | 55 | GdkGLContext* glcontext = gdk_gl_context_get_current (); 56 | if (!glcontext) 57 | return NULL; 58 | 59 | return gdk_gl_context_get_gl_drawable (glcontext); 60 | } 61 | -------------------------------------------------------------------------------- /gtkglext-1.0/gtk/gtkglwidget.h: -------------------------------------------------------------------------------- 1 | /* GtkGLExt - OpenGL Extension to GTK+ 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GTK_GL_WIDGET_H__ 20 | #define __GTK_GL_WIDGET_H__ 21 | 22 | #include 23 | #include 24 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 25 | #include 26 | #pragma GCC diagnostic warning "-Wdeprecated-declarations" 27 | 28 | G_BEGIN_DECLS 29 | 30 | gboolean gtk_widget_set_gl_capability (GtkWidget*, GdkGLConfig*, GdkGLContext* share_list, gboolean direct, int render_type); 31 | gboolean gtk_widget_is_gl_capable (GtkWidget*); 32 | 33 | 34 | GdkGLConfig* gtk_widget_get_gl_config (GtkWidget*); 35 | GdkGLContext* gtk_widget_create_gl_context (GtkWidget*, GdkGLContext* share_list, gboolean direct, int render_type); 36 | GdkGLContext* gtk_widget_get_gl_context (GtkWidget*); 37 | GdkGLWindow* gtk_widget_get_gl_window (GtkWidget*); 38 | 39 | #define gtk_widget_get_gl_drawable(widget) \ 40 | GDK_GL_DRAWABLE (gtk_widget_get_gl_window (widget)) 41 | 42 | G_END_DECLS 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /lib/ayyi-utils/observable.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2018-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #pragma once 14 | 15 | #include 16 | #include 17 | 18 | typedef union 19 | { 20 | int i; 21 | unsigned u; 22 | float f; 23 | double d; 24 | char* c; 25 | int64_t b; 26 | void* p; 27 | struct { int32_t val, prev; } s; 28 | } AGlVal; 29 | 30 | typedef struct { 31 | AGlVal value; 32 | AGlVal min; 33 | AGlVal max; 34 | GList* subscriptions; 35 | } AGlObservable; 36 | 37 | typedef void (*AGlObservableFn) (AGlObservable*, AGlVal value, gpointer); 38 | 39 | AGlObservable* agl_observable_new (); 40 | void agl_observable_free (AGlObservable*); 41 | void agl_observable_set (AGlObservable*, AGlVal); 42 | bool agl_observable_set_int (AGlObservable*, int); 43 | void agl_observable_set_float (AGlObservable*, float); 44 | void agl_observable_subscribe (AGlObservable*, AGlObservableFn, gpointer); 45 | void agl_observable_subscribe_with_state 46 | (AGlObservable*, AGlObservableFn, gpointer); 47 | void agl_obserable_add_closure(AGlObservable*, GObject*, AGlObservableFn, gpointer); 48 | void agl_observable_unsubscribe 49 | (AGlObservable*, AGlObservableFn, gpointer); 50 | -------------------------------------------------------------------------------- /wf/utils.c: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of the Ayyi project. http://ayyi.org | 4 | * | copyright (C) 2012-2020 Tim Orford | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | */ 12 | #define __wf_utils_c__ 13 | #define __wf_private__ 14 | 15 | #include 16 | #include "wf/debug.h" 17 | #include "wf/utils.h" 18 | 19 | int wf_debug = 0; 20 | 21 | 22 | /* 23 | * Return the filename of the other half of a split stereo pair. 24 | */ 25 | bool 26 | wf_get_filename_for_other_channel (const char* filename, char* other, int n_chars) 27 | { 28 | g_strlcpy(other, filename, n_chars); 29 | 30 | gchar* p = g_strrstr(other, "%L."); 31 | if(p){ 32 | *(p+1) = 'R'; 33 | dbg (3, "pair=%s", other); 34 | return TRUE; 35 | } 36 | 37 | p = g_strrstr(other, "%R."); 38 | if(p){ 39 | *(p+1) = 'L'; 40 | return TRUE; 41 | } 42 | 43 | p = g_strrstr(other, "-L."); 44 | if(p){ 45 | *(p+1) = 'R'; 46 | return TRUE; 47 | } 48 | 49 | p = g_strrstr(other, "-R."); 50 | if(p){ 51 | *(p+1) = 'L'; 52 | return TRUE; 53 | } 54 | 55 | other[0] = '\0'; 56 | return FALSE; 57 | } 58 | 59 | 60 | void 61 | wf_debug_printf (const char* func, int level, const char* format, ...) 62 | { 63 | va_list args; 64 | 65 | va_start(args, format); 66 | if (level <= wf_debug) { 67 | #ifdef SHOW_TIME 68 | fprintf(stderr, "%Lu %s(): ", _get_time(), func); 69 | #else 70 | fprintf(stderr, "%s(): ", func); 71 | #endif 72 | vfprintf(stderr, format, args); 73 | fprintf(stderr, "\n"); 74 | } 75 | va_end(args); 76 | } 77 | 78 | 79 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | COPYING 2 | INSTALL 3 | Makefile 4 | Makefile.in 5 | aclocal.m4 6 | .ccls-cache/ 7 | .cache/ 8 | agl/Makefile 9 | agl/Makefile.in 10 | agl/resources.c 11 | agl/shaders/Makefile 12 | agl/shaders/Makefile.in 13 | agl/shaders/shaders.c 14 | autom4te.cache/ 15 | compile 16 | compile_commands.json 17 | config.guess 18 | config.h 19 | config.h.in 20 | config.log 21 | config.status 22 | config.sub 23 | configure 24 | decoder/Makefile 25 | decoder/Makefile.in 26 | depcomp 27 | install-sh 28 | libtool 29 | libwaveform.pc 30 | ltmain.sh 31 | m4/libtool.m4 32 | m4/ltoptions.m4 33 | m4/ltsugar.m4 34 | m4/ltversion.m4 35 | m4/lt~obsolete.m4 36 | missing 37 | sdl/Makefile 38 | sdl/Makefile.in 39 | shaders/Makefile 40 | shaders/Makefile.in 41 | shaders/shaders.c 42 | test-driver 43 | test/Makefile 44 | test/Makefile.in 45 | test/data/ 46 | test/gen/write_block 47 | test/gen/write_short 48 | test/gen/write_wav 49 | test/32bit 50 | test/32bit.h 51 | test/actor_no_scene 52 | test/actor_plus 53 | test/actor 54 | test/ass 55 | test/cache 56 | test/frame_rate 57 | test/glx 58 | test/group 59 | test/hires 60 | test/input 61 | test/large-files 62 | test/large-files.h 63 | test/list 64 | test/multi_scene 65 | test/preview 66 | test/pixbuf 67 | test/promise 68 | test/promise.h 69 | test/resources 70 | test/res_vhi 71 | test/res_vhi_blocks 72 | test/res_vhi_scrollable 73 | test/scenegraph 74 | test/sdl 75 | test/view_plus 76 | test/view_test 77 | test/viewport 78 | test/waveform.h 79 | test/waveform 80 | test/text 81 | test/unit-actor 82 | test/unit-actor.h 83 | test/gen/write_piano 84 | test/gen/thumbnail 85 | test/gen/every_point_one 86 | transition/Makefile 87 | transition/Makefile.in 88 | waveform/Makefile 89 | waveform/Makefile.in 90 | waveform/actors/Makefile 91 | waveform/actors/Makefile.in 92 | waveform/loaders/Makefile 93 | waveform/loaders/Makefile.in 94 | gtkglext-1.0/m4macros 95 | *.peak 96 | *.gz 97 | *.xz 98 | *.orig 99 | *~ 100 | *.trace 101 | *.log 102 | *.trs 103 | -------------------------------------------------------------------------------- /gtkglext-1.0/gtk/gtkglversion.h.in: -------------------------------------------------------------------------------- 1 | /* GtkGLExt - OpenGL Extension to GTK+ 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GTK_GL_VERSION_H__ 20 | #define __GTK_GL_VERSION_H__ 21 | 22 | #include 23 | 24 | G_BEGIN_DECLS 25 | 26 | /* 27 | * Compile time version. 28 | */ 29 | #define GTKGLEXT_MAJOR_VERSION (@GTKGLEXT_MAJOR_VERSION@) 30 | #define GTKGLEXT_MINOR_VERSION (@GTKGLEXT_MINOR_VERSION@) 31 | #define GTKGLEXT_MICRO_VERSION (@GTKGLEXT_MICRO_VERSION@) 32 | #define GTKGLEXT_INTERFACE_AGE (@GTKGLEXT_INTERFACE_AGE@) 33 | #define GTKGLEXT_BINARY_AGE (@GTKGLEXT_BINARY_AGE@) 34 | 35 | /* 36 | * Check whether a GtkGLExt version equal to or greater than 37 | * major.minor.micro is present. 38 | */ 39 | #define GTKGLEXT_CHECK_VERSION(major, minor, micro) \ 40 | (GTKGLEXT_MAJOR_VERSION > (major) || \ 41 | (GTKGLEXT_MAJOR_VERSION == (major) && GTKGLEXT_MINOR_VERSION > (minor)) || \ 42 | (GTKGLEXT_MAJOR_VERSION == (major) && GTKGLEXT_MINOR_VERSION == (minor) && \ 43 | GTKGLEXT_MICRO_VERSION >= (micro))) 44 | 45 | /* 46 | * Library version. 47 | */ 48 | extern const guint gtkglext_major_version; 49 | extern const guint gtkglext_minor_version; 50 | extern const guint gtkglext_micro_version; 51 | extern const guint gtkglext_interface_age; 52 | extern const guint gtkglext_binary_age; 53 | 54 | G_END_DECLS 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /shaders/vertical_peak.frag: -------------------------------------------------------------------------------- 1 | uniform sampler2D tex2d; 2 | uniform vec4 fg_colour; 3 | uniform float peaks_per_pixel; 4 | 5 | const float h_over_sample = 1.0; 6 | const float v_over_sample = 2.0; // oversampling only needed when rendering tall images. value should adjust to quad size. 7 | const float blur_size = 1.0 / (256.0 * v_over_sample); // this size results in every step being one pixel wide if the tex2d texture is of size 256x256 8 | 9 | void main(void) 10 | { 11 | float d = 1.0 / 256.0; 12 | vec4 sum = vec4(0.0); 13 | 14 | int i; 15 | for(i=0;i | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | */ 12 | #ifndef __waveform_typedefs_h__ 13 | #define __waveform_typedefs_h__ 14 | 15 | #include "glib.h" 16 | #include "agl/typedefs.h" 17 | #include "waveform/typedefs.h" 18 | 19 | typedef struct _alpha_buf AlphaBuf; 20 | typedef struct _WaveformContext WaveformContext; 21 | typedef struct _WaveformContextClass WaveformContextClass; 22 | typedef struct _WaveformActor WaveformActor; 23 | typedef struct _textures_hi WfTexturesHi; 24 | typedef struct _WfViewPort WfViewPort; 25 | typedef struct _WaveformViewPlus WaveformViewPlus; 26 | typedef struct _wf_shaders WfShaders; 27 | typedef struct _ass_shader AssShader; 28 | typedef struct _PeakShader PeakShader; 29 | typedef struct _RulerShader RulerShader; 30 | typedef struct _CursorShader CursorShader; 31 | 32 | #ifdef HAVE_GTK_2_22 33 | #define KEY_Left GDK_KEY_Left 34 | #define KEY_Right GDK_KEY_Right 35 | #define KEY_KP_Left GDK_KEY_KP_Left 36 | #define KEY_KP_Right GDK_KEY_KP_Right 37 | #define KEY_Up GDK_KEY_Up 38 | #define KEY_Down GDK_KEY_Down 39 | #define KEY_KP_Up GDK_KEY_KP_Up 40 | #define KEY_KP_Down GDK_KEY_KP_Down 41 | #define KEY_Home GDK_KEY_KP_Home 42 | #else 43 | #define KEY_Left GDK_Left 44 | #define KEY_Right GDK_Right 45 | #define KEY_KP_Left GDK_KP_Left 46 | #define KEY_KP_Right GDK_KP_Right 47 | #define KEY_Up GDK_Up 48 | #define KEY_Down GDK_Down 49 | #define KEY_KP_Up GDK_KP_Up 50 | #define KEY_KP_Down GDK_KP_Down 51 | #define KEY_Home GDK_KP_Home 52 | #endif 53 | 54 | #endif //__waveform_typedefs_h__ 55 | -------------------------------------------------------------------------------- /gtkglext-1.0/gtk/gtkgldebug.h: -------------------------------------------------------------------------------- 1 | /* GtkGLExt - OpenGL Extension to GTK+ 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GTK_GL_DEBUG_H__ 20 | #define __GTK_GL_DEBUG_H__ 21 | 22 | #include 23 | 24 | G_BEGIN_DECLS 25 | 26 | typedef enum { 27 | GTK_GL_DEBUG_MISC = 1 << 0, 28 | GTK_GL_DEBUG_FUNC = 1 << 1 29 | } GtkGLDebugFlag; 30 | 31 | #ifdef G_ENABLE_DEBUG 32 | 33 | #define GTK_GL_NOTE(type, action) G_STMT_START { \ 34 | if (gtk_gl_debug_flags & GTK_GL_DEBUG_##type) \ 35 | { action; }; } G_STMT_END 36 | 37 | #if __STDC_VERSION__ < 199901L 38 | # if __GNUC__ >= 2 39 | # define __func__ __FUNCTION__ 40 | # else 41 | # define __func__ "" 42 | # endif 43 | #endif 44 | 45 | #define GTK_GL_NOTE_FUNC() G_STMT_START { \ 46 | if (gtk_gl_debug_flags & GTK_GL_DEBUG_FUNC) \ 47 | g_message (" - %s ()", __func__); } G_STMT_END 48 | 49 | #define GTK_GL_NOTE_FUNC_PRIVATE() G_STMT_START { \ 50 | if (gtk_gl_debug_flags & GTK_GL_DEBUG_FUNC) \ 51 | g_message (" -- %s ()", __func__); } G_STMT_END 52 | 53 | #else /* !G_ENABLE_DEBUG */ 54 | 55 | #define GTK_GL_NOTE(type, action) 56 | #define GTK_GL_NOTE_FUNC() 57 | #define GTK_GL_NOTE_FUNC_PRIVATE() 58 | 59 | #endif /* G_ENABLE_DEBUG */ 60 | 61 | extern guint gtk_gl_debug_flags; 62 | 63 | G_END_DECLS 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /lib/test/utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. http://ayyi.org | 4 | | copyright (C) 2013-2021 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #include "config.h" 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "debug/debug.h" 19 | #include "test/runner.h" 20 | 21 | 22 | bool 23 | get_random_boolean () 24 | { 25 | int r = rand(); 26 | int s = RAND_MAX / 2; 27 | int t = r / s; 28 | return t; 29 | } 30 | 31 | 32 | int 33 | get_random_int (int max) 34 | { 35 | if(max > RAND_MAX) pwarn("too high"); 36 | int r = rand(); 37 | int s = RAND_MAX / max; 38 | int t = r / s; 39 | return t; 40 | } 41 | 42 | 43 | void 44 | create_large_file (char* filename) 45 | { 46 | printf(" %s\n", filename); 47 | 48 | int n_channels = 2; 49 | long n_frames = 2048; 50 | double* buffer = (double*) g_malloc0(n_frames * sizeof(double) * n_channels); 51 | 52 | for (int i=0;i 23 | 24 | G_BEGIN_DECLS 25 | 26 | typedef struct _GdkGLDrawable GdkGLDrawable; 27 | typedef struct _GdkGLDrawableClass GdkGLDrawableClass; 28 | 29 | #define GDK_TYPE_GL_DRAWABLE (gdk_gl_drawable_get_type ()) 30 | #define GDK_GL_DRAWABLE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), GDK_TYPE_GL_DRAWABLE, GdkGLDrawable)) 31 | #define GDK_GL_DRAWABLE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GDK_TYPE_GL_DRAWABLE, GdkGLDrawableClass)) 32 | #define GDK_IS_GL_DRAWABLE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), GDK_TYPE_GL_DRAWABLE)) 33 | #define GDK_IS_GL_DRAWABLE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GDK_TYPE_GL_DRAWABLE)) 34 | #define GDK_GL_DRAWABLE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GDK_TYPE_GL_DRAWABLE, GdkGLDrawableClass)) 35 | 36 | struct _GdkGLDrawable 37 | { 38 | GObject parent_instance; 39 | }; 40 | 41 | struct _GdkGLDrawableClass 42 | { 43 | GObjectClass parent_class; 44 | }; 45 | 46 | #define gdk_gl_drawable_make_current gdk_gl_window_make_context_current 47 | #define gdk_gl_drawable_swap_buffers(DRAWABLE) gdk_gl_window_swap_buffers(DRAWABLE) 48 | 49 | GType gdk_gl_drawable_get_type (void); 50 | GdkGLDrawable* gdk_gl_drawable_get_current (void); 51 | 52 | G_END_DECLS 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gdkglprivate.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GDK_GL_PRIVATE_H__ 20 | #define __GDK_GL_PRIVATE_H__ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | G_BEGIN_DECLS 29 | 30 | #define _GDK_GL_CONCAT(x, y) x##y 31 | 32 | #define _GDK_GL_CONFIG_AS_SINGLE_MODE(glconfig) ((glconfig)->as_single_mode) 33 | 34 | void _gdk_gl_pixmap_get_size (GdkGLDrawable *gldrawable, gint *width, gint *height); 35 | 36 | void _gdk_gl_window_destroy (GdkGLWindow *glwindow); 37 | void _gdk_gl_window_get_size (GdkGLDrawable *gldrawable, gint *width, gint *height); 38 | 39 | void _gdk_gl_print_gl_info (void); 40 | 41 | /* Internal globals */ 42 | 43 | extern gboolean _gdk_gl_config_no_standard_colormap; 44 | 45 | extern gboolean _gdk_gl_context_force_indirect; 46 | 47 | 48 | void _gdk_gl_print_glx_info (Display*, int screen_num); 49 | GdkGLContext* _gdk_x11_gl_context_new (GdkGLDrawable*, GdkGLContext *share_list, gboolean direct, int render_type); 50 | void _gdk_gl_context_set_gl_drawable (GdkGLContext*, GdkGLDrawable*); 51 | 52 | 53 | #define GDK_GL_CONTEXT_IS_DESTROYED(glcontext) \ 54 | ( ((GdkGLContextImplX11 *) (glcontext))->is_destroyed ) 55 | 56 | #define GDK_GL_PIXMAP_IS_DESTROYED(glpixmap) \ 57 | ( ((GdkGLPixmapImplX11 *) (glpixmap))->is_destroyed ) 58 | 59 | G_END_DECLS 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /shaders/peak_nonscaling.frag: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2012 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | uniform sampler1D tex1d; 19 | uniform sampler1D tex1d_0neg; 20 | uniform sampler1D tex1d_3; 21 | uniform sampler1D tex1d_4; 22 | uniform int n_channels; 23 | 24 | void main(void) 25 | { 26 | float top = 0.0; 27 | float bottom = 256.0; 28 | float peaks_per_pixel = 1.0; 29 | float object_height = (bottom - top) / 256.0; //transform to texture coords 30 | 31 | float d = 1.0 / 256.0; 32 | 33 | float y = gl_TexCoord[0].t; 34 | float mid = 0.5; //if using texture coords, mid is always 0.5 35 | float mid_rhs = 0.75; 36 | float h = 1.0; 37 | if(n_channels == 2){ 38 | mid = 0.25; 39 | h = 0.5; 40 | } 41 | float alpha_range = 0.5; //not needed - remove 42 | float val = 0.0; 43 | 44 | float peak_pstv; 45 | float peak_negv; 46 | int n = 1;//int(max(1, over_sample)) + 2; 47 | 48 | int c_max = int(min(n_channels, 2)); 49 | int c;for(c=0;c h)){ 52 | //float tx = min(0.9999, gl_TexCoord[0].x + max(0.0, float(-n/2)) * d); 53 | float tx = gl_TexCoord[0].x + max(0.0, float(-n/2)) * d; 54 | float bb = alpha_range; 55 | if (y > mid_) { 56 | peak_pstv = (c == 0) ? texture1D(tex1d, tx).a : texture1D(tex1d_3, tx).a; 57 | if(y - mid_ < peak_pstv * h) val += bb; 58 | } else { 59 | peak_negv = (c == 0) ? texture1D(tex1d_0neg, tx).a : texture1D(tex1d_4, tx).a; 60 | if(-y + mid_ < peak_negv * h) val += bb; 61 | } 62 | } 63 | } 64 | 65 | if(val > 0.0) val += (1.0 - alpha_range); //min value 66 | 67 | gl_FragColor = vec4(min(1.0, val)); 68 | } 69 | 70 | -------------------------------------------------------------------------------- /ui/renderer/res_lo.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2013-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | extern HiResNGShader hires_ng_shader; 14 | 15 | static void 16 | low_new_gl2 (WaveformActor* actor) 17 | { 18 | WaveformPrivate* w = actor->waveform->priv; 19 | 20 | g_return_if_fail(!w->render_data[MODE_LOW]); 21 | 22 | Renderer* renderer = modes[MODE_LOW].renderer; 23 | if(!renderer->shader){ 24 | renderer->shader = &hires_ng_shader.shader; 25 | if(!renderer->shader->program) agl_create_program(&hires_ng_shader.shader); 26 | } 27 | } 28 | 29 | 30 | static void 31 | lo_new_gl1(WaveformActor* actor) 32 | { 33 | Waveform* w = actor->waveform; 34 | WaveformPrivate* _w = w->priv; 35 | 36 | if (!_w->render_data[MODE_LOW]) { 37 | int n_blocks = _w->num_peaks / (WF_PEAK_STD_TO_LO * WF_TEXTURE_VISIBLE_SIZE) + ((_w->num_peaks % (WF_PEAK_STD_TO_LO * WF_TEXTURE_VISIBLE_SIZE)) ? 1 : 0); 38 | 39 | _w->render_data[MODE_LOW] = (WaveformModeRender*)wf_texture_array_new(n_blocks, w->n_channels); 40 | _w->render_data[MODE_LOW]->n_blocks = n_blocks; 41 | } 42 | } 43 | 44 | 45 | Renderer lo_renderer_gl1 = {MODE_LOW, lo_new_gl1, low_allocate_block_gl1, med_lo_pre_render_gl1, med_lo_render_gl1, NULL, med_lo_gl1_free_waveform}; 46 | NGRenderer lo_renderer_gl2 = {{MODE_LOW, low_new_gl2, ng_gl2_load_block, ng_pre_render, ng_gl2_render_block, ng_post_render, ng_free_waveform, 47 | .texture_size = WF_PEAK_TEXTURE_SIZE, 48 | }}; 49 | 50 | 51 | static Renderer* 52 | lo_renderer_init () 53 | { 54 | g_return_val_if_fail(!med_renderer_gl2.ng_data, NULL); 55 | 56 | static Renderer* lo_renderer = (Renderer*)&lo_renderer_gl2; 57 | 58 | lo_renderer_gl2.ng_data = g_hash_table_new_full(g_direct_hash, g_int_equal, NULL, g_free); 59 | 60 | ng_make_lod_levels(&lo_renderer_gl2, lo_renderer->texture_size); 61 | 62 | return (Renderer*)lo_renderer; 63 | } 64 | -------------------------------------------------------------------------------- /lib/debug/debug.h: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of the Ayyi project. http://ayyi.org | 4 | * | copyright (C) 2013-2020 Tim Orford | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | */ 12 | #ifndef __ayyi_debug_h__ 13 | #define __ayyi_debug_h__ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef DEBUG 20 | // note that the level check is now outside the print fn in order to 21 | // prevent functions that return print arguments from being run 22 | # define dbg(A, B, ...) do {if(A <= _debug_) debug_printf(__func__, A, B, ##__VA_ARGS__);} while(FALSE) 23 | 24 | # define PF {if(_debug_) printf("%s()...\n", __func__);} 25 | # define PF0 {printf("%s()...\n", __func__);} 26 | # define PF2 {if(_debug_ > 1) printf("%s...\n", __func__);} 27 | # define PF_DONE {if(_debug_) printf("%s(): done.\n", __func__);} 28 | #else 29 | # define dbg(A, B, ...) 30 | # define PF 31 | # define PF0 32 | # define PF2 33 | # define PF_DONE 34 | #endif 35 | 36 | #define perr(A, ...) g_critical("%s(): "A, __func__, ##__VA_ARGS__) 37 | #define pwarn(A, ...) g_warning("%s(): "A, __func__, ##__VA_ARGS__) 38 | 39 | #ifndef g_object_unref0 40 | #define g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) 41 | #endif 42 | 43 | #ifdef DEBUG 44 | void debug_printf (const char* func, int level, const char* format, ...) __attribute__ ((format (printf, 3, 4))); 45 | #endif 46 | void warnprintf (const char* format, ...) __attribute__ ((format (printf, 1, 2))); 47 | void warnprintf2 (const char* func, char* format, ...); 48 | void errprintf (const char* format, ...); 49 | 50 | void set_log_handlers (); 51 | 52 | extern int _debug_; // debug level. 0=off. 53 | 54 | extern char ayyi_white [12]; 55 | extern char ayyi_grey [16]; 56 | extern char ayyi_bold [12]; 57 | extern char ayyi_warn [32]; 58 | extern char ayyi_err [32]; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /ui/pixbuf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of libwaveform https://github.com/ayyi/libwaveform | 4 | * | copyright (C) 2012-2020 Tim Orford | 5 | * +----------------------------------------------------------------------+ 6 | * | This program is free software; you can redistribute it and/or modify | 7 | * | it under the terms of the GNU General Public License version 3 | 8 | * | as published by the Free Software Foundation. | 9 | * +----------------------------------------------------------------------+ 10 | * 11 | */ 12 | #ifndef __wf_pixbuf_h__ 13 | #define __wf_pixbuf_h__ 14 | 15 | #include "waveform/ui-typedefs.h" 16 | #ifdef USE_GDK_PIXBUF 17 | #include 18 | #include 19 | #endif 20 | 21 | typedef void (WfPixbufCallback)(Waveform*, GdkPixbuf*, gpointer); 22 | 23 | void waveform_peak_to_pixbuf (Waveform*, GdkPixbuf*, WfSampleRegion*, uint32_t colour, uint32_t bg_colour, bool single); 24 | void waveform_peak_to_pixbuf_async (Waveform*, GdkPixbuf*, WfSampleRegion*, uint32_t colour, uint32_t bg_colour, WfPixbufCallback, gpointer); 25 | void waveform_peak_to_pixbuf_full (Waveform*, GdkPixbuf*, uint32_t src_inset, int* start, int* end, double samples_per_px, uint32_t colour, uint32_t bg_colour, float gain, bool single); 26 | void waveform_rms_to_pixbuf (Waveform*, GdkPixbuf*, uint32_t src_inset, int* start, int* end, double samples_per_px, uint32_t colour, uint32_t bg_colour, float gain); 27 | 28 | struct _alpha_buf { 29 | int width; 30 | int height; 31 | guchar* buf; 32 | int buf_size; 33 | }; 34 | 35 | AlphaBuf* wf_alphabuf_new (Waveform*, int blocknum, int scale, bool is_rms, int border); 36 | AlphaBuf* wf_alphabuf_new_hi (Waveform*, int blocknum, int scale, bool is_rms, int border); 37 | void wf_alphabuf_free (AlphaBuf*); 38 | #ifdef USE_GDK_PIXBUF 39 | GdkPixbuf* wf_alphabuf_to_pixbuf (AlphaBuf*); 40 | #endif 41 | 42 | void waveform_peak_to_alphabuf (Waveform*, AlphaBuf*, int scale, int* start, int* end, GdkColor*); 43 | void waveform_peak_to_alphabuf_hi (Waveform*, AlphaBuf*, int block, WfSampleRegion, GdkColor*); 44 | void waveform_rms_to_alphabuf (Waveform*, AlphaBuf*, int* start, int* end, double samples_per_px, GdkColor*, uint32_t colour_bg); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gdkgldebug.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GDK_GL_DEBUG_H__ 20 | #define __GDK_GL_DEBUG_H__ 21 | 22 | #include 23 | 24 | G_BEGIN_DECLS 25 | 26 | typedef enum { 27 | GDK_GL_DEBUG_MISC = 1 << 0, 28 | GDK_GL_DEBUG_FUNC = 1 << 1, 29 | GDK_GL_DEBUG_IMPL = 1 << 2 30 | } GdkGLDebugFlag; 31 | 32 | #ifdef G_ENABLE_DEBUG 33 | 34 | #define GDK_GL_NOTE(type, action) G_STMT_START { \ 35 | if (gdk_gl_debug_flags & GDK_GL_DEBUG_##type) \ 36 | { action; }; } G_STMT_END 37 | 38 | #if __STDC_VERSION__ < 199901L 39 | # if __GNUC__ >= 2 40 | # define __func__ __FUNCTION__ 41 | # else 42 | # define __func__ "" 43 | # endif 44 | #endif 45 | 46 | #define GDK_GL_NOTE_FUNC() G_STMT_START { \ 47 | if (gdk_gl_debug_flags & GDK_GL_DEBUG_FUNC) \ 48 | g_message (" - %s ()", __func__); } G_STMT_END 49 | 50 | #define GDK_GL_NOTE_FUNC_PRIVATE() G_STMT_START { \ 51 | if (gdk_gl_debug_flags & GDK_GL_DEBUG_FUNC) \ 52 | g_message (" -- %s ()", __func__); } G_STMT_END 53 | 54 | #define GDK_GL_NOTE_FUNC_IMPL(func) G_STMT_START { \ 55 | if (gdk_gl_debug_flags & GDK_GL_DEBUG_IMPL) \ 56 | g_message (" ** %s ()", (func)); } G_STMT_END 57 | 58 | #else /* !G_ENABLE_DEBUG */ 59 | 60 | #define GDK_GL_NOTE(type, action) 61 | #define GDK_GL_NOTE_FUNC() 62 | #define GDK_GL_NOTE_FUNC_PRIVATE() 63 | #define GDK_GL_NOTE_FUNC_IMPL(func) 64 | 65 | #endif /* G_ENABLE_DEBUG */ 66 | 67 | extern guint gdk_gl_debug_flags; 68 | 69 | G_END_DECLS 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /ui/invalidator.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2021-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #include "config.h" 14 | #include "transition/transition.h" 15 | #include "wf/debug.h" 16 | #include "waveform/actor.h" 17 | #include "waveform/invalidator.h" 18 | 19 | static void invalidator_init (AGlBehaviour*, AGlActor*); 20 | static void invalidator_free (AGlBehaviour*); 21 | 22 | typedef struct 23 | { 24 | AGlBehaviourClass class; 25 | } InvalidatorClass; 26 | 27 | static InvalidatorClass klass = { 28 | .class = { 29 | .init = invalidator_init, 30 | .free = invalidator_free, 31 | } 32 | }; 33 | 34 | 35 | AGlBehaviourClass* 36 | invalidator_get_class () 37 | { 38 | return (AGlBehaviourClass*)&klass; 39 | } 40 | 41 | 42 | void 43 | invalidator_invalidate_item (Invalidator* invalidator, int item) 44 | { 45 | invalidator->valid &= ~(1 << item); 46 | invalidator_queue_check (invalidator); 47 | } 48 | 49 | 50 | void 51 | invalidator_queue_check (Invalidator* invalidator) 52 | { 53 | gboolean invalidator_check (void* _invalidator) 54 | { 55 | Invalidator* invalidator = _invalidator; 56 | 57 | for (int i=0;in_types;i++) { 58 | int bit = 1 << i; 59 | int valid = invalidator->valid & bit; 60 | if (!valid) { 61 | if (invalidator->resolve[i](invalidator)) { 62 | invalidator->valid |= bit; 63 | } else { 64 | break; 65 | } 66 | } 67 | } 68 | 69 | invalidator->recheck_queue = 0; 70 | return G_SOURCE_REMOVE; 71 | } 72 | 73 | if (!invalidator->recheck_queue) { 74 | invalidator->recheck_queue = g_idle_add_full (G_PRIORITY_HIGH_IDLE, invalidator_check, invalidator, NULL); 75 | } 76 | } 77 | 78 | 79 | static void 80 | invalidator_init (AGlBehaviour* behaviour, AGlActor* actor) 81 | { 82 | } 83 | 84 | 85 | static void 86 | invalidator_free (AGlBehaviour* behaviour) 87 | { 88 | Invalidator* invalidator = (Invalidator*)behaviour; 89 | 90 | if (invalidator->recheck_queue) g_source_remove(invalidator->recheck_queue); 91 | 92 | g_free(invalidator); 93 | } 94 | -------------------------------------------------------------------------------- /test/common2.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * +----------------------------------------------------------------------+ 4 | * | This file is part of the Ayyi project. http://ayyi.org | 5 | * | copyright (C) 2013-2020 Tim Orford | 6 | * +----------------------------------------------------------------------+ 7 | * | This program is free software; you can redistribute it and/or modify | 8 | * | it under the terms of the GNU General Public License version 3 | 9 | * | as published by the Free Software Foundation. | 10 | * +----------------------------------------------------------------------+ 11 | * 12 | */ 13 | 14 | #define __wf_private__ 15 | #include "wf/debug.h" 16 | #include "agl/actor.h" 17 | 18 | /* 19 | * Common code for all tests 20 | */ 21 | 22 | void set_log_handlers (); 23 | char* find_wav (const char*); 24 | const char* find_data_dir(); 25 | 26 | typedef void (KeyHandler)(gpointer); 27 | 28 | typedef struct 29 | { 30 | int key; 31 | KeyHandler* handler; 32 | } Key; 33 | 34 | typedef struct 35 | { 36 | guint timer; 37 | KeyHandler* handler; 38 | } KeyHold; 39 | 40 | #ifdef __common2_c__ 41 | char grey [16] = "\x1b[2;39m"; // 2 = dim 42 | char yellow [16] = "\x1b[1;33m"; 43 | char yellow_r [16] = "\x1b[30;43m"; 44 | char white__r [16] = "\x1b[30;47m"; 45 | char cyan___r [16] = "\x1b[30;46m"; 46 | char magent_r [16] = "\x1b[30;45m"; 47 | char blue_r [16] = "\x1b[30;44m"; 48 | char red [10] = "\x1b[1;31m"; 49 | char red_r [16] = "\x1b[30;41m"; 50 | char green [10] = "\x1b[1;32m"; 51 | char green_r [16] = "\x1b[30;42m"; 52 | char go_rhs [32] = "\x1b[A\x1b[50C"; //go up one line, then goto column 60 53 | char ok [32] = " [ \x1b[1;32mok\x1b[0;39m ]"; 54 | char fail [32] = " [\x1b[1;31mFAIL\x1b[0;39m]"; 55 | #else 56 | extern char grey [16]; 57 | extern char yellow [16]; 58 | extern char yellow_r [16]; 59 | extern char white__r [16]; 60 | extern char cyan___r [16]; 61 | extern char magent_r [16]; 62 | extern char blue_r [16]; 63 | extern char red [10]; 64 | extern char red_r [16]; 65 | extern char green [10]; 66 | extern char green_r [16]; 67 | extern char ayyi_warn[32]; 68 | extern char ayyi_err [32]; 69 | extern char go_rhs [32]; 70 | extern char ok []; 71 | extern char fail []; 72 | #endif 73 | 74 | void add_key_handlers (Key keys[]); 75 | #ifdef __GTK_H__ 76 | void add_key_handlers_gtk (GtkWindow*, gpointer, Key keys[]); 77 | 78 | #ifdef __GDK_GL_CONFIG_H__ 79 | typedef void (*WindowFn) (GtkWindow*, GdkGLConfig*); 80 | 81 | int gtk_window (Key keys[], WindowFn); 82 | #endif 83 | #endif 84 | 85 | #define g_source_remove0(S) {if(S) g_source_remove(S); S = 0;} 86 | 87 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gdkglcontext.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GDK_GL_CONTEXT_X11_H__ 20 | #define __GDK_GL_CONTEXT_X11_H__ 21 | 22 | #include 23 | #include 24 | 25 | G_BEGIN_DECLS 26 | 27 | typedef struct _GdkGLContext GdkGLContextImplX11; 28 | typedef struct _GdkGLContextClass GdkGLContextImplX11Class; 29 | 30 | #define GDK_TYPE_GL_CONTEXT_IMPL_X11 (gdk_gl_context_impl_x11_get_type ()) 31 | #define GDK_GL_CONTEXT_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GL_CONTEXT_IMPL_X11, GdkGLContextImplX11)) 32 | #define GDK_GL_CONTEXT_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_CONTEXT_IMPL_X11, GdkGLContextImplX11Class)) 33 | #define GDK_IS_GL_CONTEXT_IMPL_X11(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GL_CONTEXT_IMPL_X11)) 34 | #define GDK_IS_GL_CONTEXT_IMPL_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_CONTEXT_IMPL_X11)) 35 | #define GDK_GL_CONTEXT_IMPL_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_CONTEXT_IMPL_X11, GdkGLContextImplX11Class)) 36 | 37 | struct _GdkGLContext 38 | { 39 | GObject parent_instance; 40 | 41 | GLXContext glxcontext; 42 | GdkGLContext *share_list; 43 | gboolean is_direct; 44 | int render_type; 45 | 46 | GdkGLConfig *glconfig; 47 | 48 | GdkGLDrawable *gldrawable; 49 | GdkGLDrawable *gldrawable_read; /* currently unused. */ 50 | 51 | guint is_destroyed : 1; 52 | guint is_foreign : 1; 53 | }; 54 | 55 | struct _GdkGLContextClass 56 | { 57 | GObjectClass parent_class; 58 | }; 59 | 60 | GType gdk_gl_context_impl_x11_get_type (void); 61 | 62 | GdkGLContext* gdk_gl_context_new (GdkGLDrawable*, GdkGLContext* share_list, gboolean direct, int render_type); 63 | GdkGLContext* gdk_gl_context_get_current (); 64 | GdkGLDrawable* gdk_gl_context_get_gl_drawable (GdkGLContext*); 65 | 66 | G_END_DECLS 67 | 68 | #endif /* __GDK_GL_CONTEXT_X11_H__ */ 69 | -------------------------------------------------------------------------------- /test/input.c: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of libwaveform | 4 | * | https://github.com/ayyi/libwaveform | 5 | * | copyright (C) 2020-2020 Tim Orford | 6 | * +----------------------------------------------------------------------+ 7 | * | This program is free software; you can redistribute it and/or modify | 8 | * | it under the terms of the GNU General Public License version 3 | 9 | * | as published by the Free Software Foundation. | 10 | * +----------------------------------------------------------------------+ 11 | */ 12 | #include "config.h" 13 | #include 14 | #include "gdk/gdk.h" 15 | #include "agl/ext.h" 16 | #include "agl/x11.h" 17 | #include "agl/debug.h" 18 | #include "agl/behaviours/key.h" 19 | #include "agl/text/text_input.h" 20 | #define __glx_test__ 21 | #include "test/common2.h" 22 | 23 | static AGlRootActor* scene = NULL; 24 | 25 | struct { 26 | AGlActor* input; 27 | } layers = {0,}; 28 | 29 | static ActorKeyHandler 30 | quit; 31 | 32 | ActorKey keys[] = { 33 | {XK_q, quit}, 34 | {XK_Escape, quit}, 35 | }; 36 | 37 | static const struct option long_options[] = { 38 | { "non-interactive", 0, NULL, 'n' }, 39 | }; 40 | 41 | static const char* const short_options = "n"; 42 | 43 | 44 | int 45 | main (int argc, char *argv[]) 46 | { 47 | wf_debug = 0; 48 | 49 | const int width = 400, height = 200; 50 | 51 | int opt; 52 | while((opt = getopt_long (argc, argv, short_options, long_options, NULL)) != -1) { 53 | switch(opt) { 54 | case 'n': 55 | g_timeout_add(3000, (gpointer)exit, NULL); 56 | break; 57 | } 58 | } 59 | 60 | AGlWindow* window = agl_window("Text test", 0, 0, width, height, 0); 61 | XMapWindow(dpy, window->window); 62 | scene = window->scene; 63 | 64 | agl_actor__add_child((AGlActor*)scene, layers.input = text_input(NULL)); 65 | layers.input->region = (AGlfRegion){15, 15, .x2 = 380, .y2 = 120}; 66 | #if 0 67 | text_input_set_text((TextInput*)layers.input, g_strdup("Hello world")); 68 | #else 69 | text_input_set_placeholder((TextInput*)layers.input, "Search"); 70 | #endif 71 | agl_observable_set_int (((TextInput*)layers.input)->font, 32); 72 | 73 | scene->selected = layers.input; 74 | 75 | #define KEYS(A) ((KeyBehaviour*)((AGlActor*)A)->behaviours[0]) 76 | 77 | ((AGlActor*)scene)->behaviours[0] = key_behaviour(); 78 | KEYS(scene)->keys = &keys; 79 | key_behaviour_init(((AGlActor*)scene)->behaviours[0], (AGlActor*)scene); 80 | 81 | g_main_loop_run(agl_main_loop_new()); 82 | 83 | agl_window_destroy(&window); 84 | XCloseDisplay(dpy); 85 | 86 | return 0; 87 | } 88 | 89 | 90 | static bool 91 | quit (AGlActor* user_data, GdkModifierType modifiers) 92 | { 93 | return AGL_HANDLED; 94 | } 95 | -------------------------------------------------------------------------------- /ui/context.root.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2012-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | | This handles some legacy gl initialisation common to all WfActor 12 | | instances. 13 | | The preferred place for this would be in a renderer object. 14 | | 15 | */ 16 | 17 | #include "config.h" 18 | #include "debug/debug.h" 19 | #include "agl/utils.h" 20 | #include "agl/actor.h" 21 | #include "context.h" 22 | 23 | #ifdef USE_GTK 24 | #define WAVEFORM_START_DRAW(wfc) \ 25 | if (actor_not_is_gtk(wfc->root->root) || gdk_gl_drawable_make_current (wfc->root->root->gl.gdk.drawable, wfc->root->root->gl.gdk.context)) 26 | #else 27 | #define WAVEFORM_START_DRAW(wfc) \ 28 | ; 29 | #endif 30 | 31 | #define WAVEFORM_END_DRAW(wa) \ 32 | ; 33 | 34 | 35 | static void 36 | wf_context_init_gl (WaveformContext* wfc) 37 | { 38 | PF; 39 | 40 | AGl* agl = agl_get_instance(); 41 | 42 | if (!agl->pref_use_shaders) { 43 | wfc->use_1d_textures = false; 44 | return; 45 | } 46 | 47 | WAVEFORM_START_DRAW(wfc) { 48 | 49 | if (!wfc->root) { 50 | agl_gl_init(); 51 | } 52 | 53 | if (!agl->use_shaders) { 54 | agl_use_program(NULL); 55 | wfc->use_1d_textures = false; 56 | } 57 | 58 | } WAVEFORM_END_DRAW(wfc); 59 | } 60 | 61 | 62 | AGlBehaviour* init_hook (); 63 | void init_hook_init (AGlBehaviour*, AGlActor*); 64 | 65 | typedef struct { 66 | AGlBehaviour behaviour; 67 | WaveformContext* wfc; 68 | } InitHookBehaviour; 69 | 70 | static AGlBehaviourClass klass = { 71 | .new = init_hook, 72 | .init = init_hook_init, 73 | }; 74 | 75 | 76 | AGlBehaviour* 77 | init_hook () 78 | { 79 | return (AGlBehaviour*)AGL_NEW(InitHookBehaviour, 80 | .behaviour = { 81 | .klass = &klass, 82 | } 83 | ); 84 | } 85 | 86 | 87 | AGlBehaviour* 88 | init_hook_new (WaveformContext* wfc) 89 | { 90 | AGlBehaviour* hook = init_hook(); 91 | ((InitHookBehaviour*)hook)->wfc = wfc; 92 | 93 | return hook; 94 | } 95 | 96 | 97 | void 98 | init_hook_init (AGlBehaviour* behaviour, AGlActor* actor) 99 | { 100 | InitHookBehaviour* hook = (InitHookBehaviour*)behaviour; 101 | AGlScene* scene = actor->root; 102 | AGl* agl = agl_get_instance(); 103 | 104 | wf_context_init_gl(hook->wfc); 105 | 106 | if (scene->draw) wf_context_queue_redraw(hook->wfc); 107 | hook->wfc->use_1d_textures = agl->use_shaders; 108 | } 109 | 110 | 111 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gdkglglxext.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GDK_GL_GLXEXT_H__ 20 | #define __GDK_GL_GLXEXT_H__ 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | G_BEGIN_DECLS 32 | 33 | #ifndef GLX_VERSION_1_3 34 | typedef struct __GLXFBConfigRec *GLXFBConfig; 35 | typedef XID GLXFBConfigID; 36 | typedef XID GLXContextID; 37 | typedef XID GLXWindow; 38 | typedef XID GLXPbuffer; 39 | #endif 40 | 41 | #undef __glxext_h_ 42 | #undef GLX_GLXEXT_VERSION 43 | #include 44 | #include 45 | 46 | /* 47 | * GLX_MESA_pixmap_colormap 48 | */ 49 | 50 | /* glXCreateGLXPixmapMESA */ 51 | typedef GLXPixmap ( * GdkGLProc_glXCreateGLXPixmapMESA) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); 52 | GdkGLProc gdk_gl_get_glXCreateGLXPixmapMESA (void); 53 | #define gdk_gl_glXCreateGLXPixmapMESA(proc, dpy, visual, pixmap, cmap) \ 54 | ( ((GdkGLProc_glXCreateGLXPixmapMESA) (proc)) (dpy, visual, pixmap, cmap) ) 55 | 56 | /* proc struct */ 57 | 58 | typedef struct _GdkGL_GLX_MESA_pixmap_colormap GdkGL_GLX_MESA_pixmap_colormap; 59 | 60 | struct _GdkGL_GLX_MESA_pixmap_colormap 61 | { 62 | GdkGLProc_glXCreateGLXPixmapMESA glXCreateGLXPixmapMESA; 63 | }; 64 | 65 | GdkGL_GLX_MESA_pixmap_colormap *gdk_gl_get_GLX_MESA_pixmap_colormap (GdkGLConfig *glconfig); 66 | 67 | /* 68 | * GLX_MESA_release_buffers 69 | */ 70 | 71 | /* glXReleaseBuffersMESA */ 72 | typedef Bool ( * GdkGLProc_glXReleaseBuffersMESA) (Display *dpy, GLXDrawable drawable); 73 | GdkGLProc gdk_gl_get_glXReleaseBuffersMESA (void); 74 | #define gdk_gl_glXReleaseBuffersMESA(proc, dpy, drawable) \ 75 | ( ((GdkGLProc_glXReleaseBuffersMESA) (proc)) (dpy, drawable) ) 76 | 77 | /* proc struct */ 78 | 79 | typedef struct _GdkGL_GLX_MESA_release_buffers GdkGL_GLX_MESA_release_buffers; 80 | 81 | struct _GdkGL_GLX_MESA_release_buffers 82 | { 83 | GdkGLProc_glXReleaseBuffersMESA glXReleaseBuffersMESA; 84 | }; 85 | 86 | GdkGL_GLX_MESA_release_buffers *gdk_gl_get_GLX_MESA_release_buffers (GdkGLConfig *glconfig); 87 | 88 | G_END_DECLS 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gdkglpixmap.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GDK_GL_PIXMAP_H__ 20 | #define __GDK_GL_PIXMAP_H__ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | 28 | typedef struct _GdkGLPixmapClass GdkGLPixmapClass; 29 | 30 | #define GDK_TYPE_GL_PIXMAP (gdk_gl_pixmap_get_type ()) 31 | #define GDK_GL_PIXMAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GL_PIXMAP, GdkGLPixmap)) 32 | #define GDK_GL_PIXMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_PIXMAP, GdkGLPixmapClass)) 33 | #define GDK_IS_GL_PIXMAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GL_PIXMAP)) 34 | #define GDK_IS_GL_PIXMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_PIXMAP)) 35 | #define GDK_GL_PIXMAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_PIXMAP, GdkGLPixmapClass)) 36 | 37 | struct _GdkGLPixmap 38 | { 39 | GdkDrawable parent_instance; 40 | 41 | GdkDrawable *drawable; /* Associated GdkPixmap */ 42 | 43 | GdkGLConfig *glconfig; 44 | 45 | GLXPixmap glxpixmap; 46 | 47 | guint is_destroyed : 1; 48 | }; 49 | 50 | struct _GdkGLPixmapClass 51 | { 52 | GdkDrawableClass parent_class; 53 | }; 54 | 55 | GType gdk_gl_pixmap_get_type (void); 56 | 57 | /* 58 | * attrib_list is currently unused. This must be set to NULL or empty 59 | * (first attribute of None). See GLX 1.3 spec. 60 | */ 61 | GdkGLPixmap* gdk_gl_pixmap_new (GdkGLConfig*, GdkPixmap*, const int* attrib_list); 62 | GdkPixmap* gdk_gl_pixmap_get_pixmap (GdkGLPixmap*); 63 | 64 | /* 65 | * OpenGL extension to GdkPixmap 66 | */ 67 | 68 | GdkGLPixmap* gdk_pixmap_set_gl_capability (GdkPixmap*, GdkGLConfig*, const int* attrib_list); 69 | void gdk_pixmap_unset_gl_capability (GdkPixmap*); 70 | gboolean gdk_pixmap_is_gl_capable (GdkPixmap*); 71 | GdkGLPixmap* gdk_pixmap_get_gl_pixmap (GdkPixmap*); 72 | 73 | #define gdk_pixmap_get_gl_drawable(pixmap) \ 74 | GDK_GL_DRAWABLE (gdk_pixmap_get_gl_pixmap (pixmap)) 75 | 76 | GdkGLConfig* gdk_gl_pixmap_get_gl_config (GdkGLDrawable*); 77 | gboolean gdk_gl_pixmap_make_context_current (GdkGLDrawable*, GdkGLContext*); 78 | 79 | G_END_DECLS 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /ui/shader.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of libwaveform | 4 | | https://github.com/ayyi/libwaveform | 5 | | copyright (C) 2012-2025 Tim Orford | 6 | +----------------------------------------------------------------------+ 7 | | This program is free software; you can redistribute it and/or modify | 8 | | it under the terms of the GNU General Public License version 3 | 9 | | as published by the Free Software Foundation. | 10 | +----------------------------------------------------------------------+ 11 | | 12 | */ 13 | 14 | #pragma once 15 | 16 | #include "agl/typedefs.h" 17 | #ifdef __gl_h_ 18 | #include "agl/shader.h" 19 | #include "waveform/ui-typedefs.h" 20 | 21 | struct _PeakShader { 22 | AGlShader shader; 23 | void (*set_uniforms)(float peaks_per_pixel, float top, float bottom, uint32_t _fg_colour, int n_channels); 24 | struct { 25 | float peaks_per_pixel; 26 | float fg_colour[4]; 27 | int n_channels; 28 | } uniform; 29 | }; 30 | 31 | typedef struct { 32 | AGlShader shader; 33 | struct U { 34 | uint32_t fg_colour; 35 | float top; 36 | float bottom; 37 | int n_channels; 38 | float peaks_per_pixel; 39 | } uniform; 40 | } HiResShader; 41 | 42 | typedef struct { 43 | AGlShader shader; 44 | struct { 45 | uint32_t fg_colour; 46 | float top; 47 | float bottom; 48 | int n_channels; 49 | float v_gain; 50 | float tex_width; 51 | float tex_height; 52 | int mm_level; 53 | } uniform; 54 | } HiResNGShader; 55 | 56 | typedef struct { 57 | AGlShader shader; 58 | struct { 59 | uint32_t fg_colour; 60 | float peaks_per_pixel; 61 | } uniform; 62 | } BloomShader; 63 | 64 | struct _RulerShader { 65 | AGlShader shader; 66 | struct { 67 | uint32_t fg_colour; 68 | float beats_per_pixel; 69 | float samples_per_pixel; 70 | float viewport_left; 71 | int markers[10]; 72 | } uniform; 73 | }; 74 | 75 | typedef struct { 76 | AGlShader shader; 77 | struct { 78 | uint32_t fg_colour; 79 | float samples_per_pixel; 80 | float pixels_per_unit; 81 | float n_subs; 82 | float viewport_left; 83 | int markers[10]; 84 | } uniform; 85 | } RulerFramesShader; 86 | 87 | #ifdef MULTILINE_SHADER 88 | typedef struct { 89 | AGlShader shader; 90 | struct { 91 | uint32_t colour; 92 | int n_channels; 93 | int texture_width; 94 | } uniform; 95 | } LinesShader; 96 | #endif 97 | 98 | struct _ass_shader { 99 | AGlShader shader; 100 | struct { 101 | uint32_t colour1; 102 | uint32_t colour2; 103 | } uniform; 104 | }; 105 | 106 | struct _CursorShader { 107 | AGlShader shader; 108 | struct { 109 | float width; 110 | } uniform; 111 | }; 112 | #ifndef __wf_shader_c__ 113 | extern CursorShader cursor; 114 | #endif 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /ui/actor.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2013-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #pragma once 14 | 15 | #include "transition/transition.h" 16 | #include "agl/actor.h" 17 | #include "waveform/waveform.h" 18 | #include "waveform/context.h" 19 | 20 | typedef struct _WfActorPriv WfActorPriv; 21 | typedef void (*WaveformActorFn) (WaveformActor*, gpointer); 22 | 23 | #ifdef DEBUG 24 | typedef enum { 25 | RENDER_RESULT_OK = 0, 26 | RENDER_RESULT_LOADING, 27 | RENDER_RESULT_SIZE, 28 | RENDER_RESULT_NO_BLOCKS, 29 | RENDER_RESULT_NO_REGION, 30 | RENDER_RESULT_BLOCK_RANGE, 31 | RENDER_RESULT_NO_AUDIO_DATA, 32 | RENDER_RESULT_NO_PROGRAM, 33 | RENDER_RESULT_BAD 34 | } RenderResult; 35 | #endif 36 | 37 | struct _WaveformActor { 38 | AGlActor actor; 39 | WaveformContext* context; 40 | Waveform* waveform; 41 | WfSampleRegion region; 42 | float vzoom; // vertical zoom. default 1.0 43 | float z; // render position on z-axis. 44 | 45 | WfActorPriv* priv; 46 | #ifdef DEBUG 47 | RenderResult render_result; 48 | #endif 49 | }; 50 | 51 | AGlActorClass* wf_actor_get_class (); 52 | 53 | void wf_actor_set_waveform (WaveformActor*, Waveform*, WaveformActorFn, gpointer); 54 | void wf_actor_set_waveform_sync (WaveformActor*, Waveform*); 55 | void wf_actor_set_region (WaveformActor*, WfSampleRegion*); 56 | void wf_actor_set_rect (WaveformActor*, WfRectangle*); 57 | void wf_actor_set_colour (WaveformActor*, uint32_t fg_colour); 58 | void wf_actor_set_full (WaveformActor*, WfSampleRegion*, WfRectangle*, int time, WaveformActorFn, gpointer); 59 | void wf_actor_fade_out (WaveformActor*, WaveformActorFn, gpointer); 60 | void wf_actor_fade_in (WaveformActor*, float, WaveformActorFn, gpointer); 61 | void wf_actor_set_vzoom (WaveformActor*, float); 62 | void wf_actor_scroll_to (WaveformActor*, int); 63 | WfAnimatable* wf_actor_get_z (WaveformActor*); 64 | void wf_actor_set_z (WaveformActor*, float, WaveformActorFn, gpointer); 65 | float wf_actor_frame_to_x (WaveformActor*, uint64_t); 66 | void wf_actor_clear (WaveformActor*); 67 | 68 | #define WF_ACTOR_PX_PER_FRAME(A) (agl_actor__width((AGlActor*)A) / A->region.len) 69 | 70 | struct _WfViewPort { double left, top, right, bottom; }; 71 | 72 | _GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS (WaveformActor, AGlActor, agl_actor__free) 73 | -------------------------------------------------------------------------------- /ui/view.h: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2012-2017 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | 17 | --------------------------------------------------------------- 18 | 19 | WaveformView is a Gtk widget based on GtkDrawingArea. 20 | It displays an audio waveform derived from a peak file. 21 | 22 | */ 23 | #ifndef __waveform_view_h__ 24 | #define __waveform_view_h__ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include "wf/waveform.h" 31 | #include "waveform/ui-typedefs.h" 32 | 33 | G_BEGIN_DECLS 34 | 35 | #define TYPE_WAVEFORM_VIEW (waveform_view_get_type ()) 36 | #define WAVEFORM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_WAVEFORM_VIEW, WaveformView)) 37 | #define WAVEFORM_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_WAVEFORM_VIEW, WaveformViewClass)) 38 | #define IS_WAVEFORM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_WAVEFORM_VIEW)) 39 | #define IS_WAVEFORM_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_WAVEFORM_VIEW)) 40 | #define WAVEFORM_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_WAVEFORM_VIEW, WaveformViewClass)) 41 | 42 | typedef struct _WaveformViewClass WaveformViewClass; 43 | typedef struct _WaveformViewPrivate WaveformViewPrivate; 44 | 45 | struct _WaveformView { 46 | GtkDrawingArea parent_instance; 47 | Waveform* waveform; 48 | float zoom; 49 | uint64_t start_frame; 50 | WaveformViewPrivate* priv; 51 | }; 52 | 53 | struct _WaveformViewClass { 54 | GtkDrawingAreaClass parent_class; 55 | }; 56 | 57 | 58 | GType waveform_view_get_type () G_GNUC_CONST; 59 | void waveform_view_set_gl (GdkGLContext*); 60 | 61 | WaveformView* waveform_view_new (Waveform*); 62 | void waveform_view_load_file (WaveformView*, const char*); //be careful, it force loads, even if already loaded. 63 | void waveform_view_set_waveform (WaveformView*, Waveform*); 64 | void waveform_view_set_zoom (WaveformView*, float); 65 | void waveform_view_set_start (WaveformView*, int64_t); 66 | void waveform_view_set_region (WaveformView*, int64_t, int64_t); 67 | void waveform_view_set_colour (WaveformView*, uint32_t fg, uint32_t bg); 68 | void waveform_view_set_show_rms (WaveformView*, gboolean); 69 | 70 | WaveformContext* waveform_view_get_canvas (WaveformView*); 71 | 72 | 73 | G_END_DECLS 74 | 75 | #endif //__waveform_view_h__ 76 | -------------------------------------------------------------------------------- /shaders/ruler_frames.frag: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2012-2025 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | uniform float samples_per_pixel; 19 | uniform float pixels_per_unit; 20 | uniform float n_subs; 21 | uniform float viewport_left; 22 | uniform vec4 fg_colour; 23 | uniform int markers[10]; 24 | 25 | varying vec2 MCposition; 26 | varying vec2 ecPosition; 27 | 28 | /* 29 | * This ruler version is intended to be positioned at the bottom of the window. 30 | * Actor height is expected to be 20px. 31 | * It works with frames, not beats and bars. 32 | * The uniforms are compatible with the other ruler shaders. 33 | * For coordinate calculations to work the quad must be positioned using glTranslatef(), with x1=0, y1=0. 34 | */ 35 | void main(void) 36 | { 37 | vec4 marker_colours[10]; 38 | marker_colours[0] = vec4(0.5, 0.8, 0.5, 1.0); 39 | marker_colours[1] = vec4(0.5, 0.6, 0.8, 1.0); 40 | marker_colours[2] = vec4(0.5, 0.6, 0.8, 1.0); 41 | marker_colours[3] = vec4(0.5, 0.6, 0.8, 1.0); 42 | marker_colours[4] = vec4(0.5, 0.6, 0.8, 1.0); 43 | marker_colours[5] = vec4(0.5, 0.6, 0.8, 1.0); 44 | marker_colours[6] = vec4(0.5, 0.6, 0.8, 1.0); 45 | marker_colours[7] = vec4(0.5, 0.6, 0.8, 1.0); 46 | marker_colours[8] = vec4(0.5, 0.6, 0.8, 1.0); 47 | marker_colours[9] = vec4(0.8, 0.6, 0.5, 1.0); 48 | 49 | vec4 c = vec4(1.0) * fg_colour; 50 | float alpha = c[3]; 51 | c[3] = 0.0; 52 | 53 | if (MCposition.y > 20.0) { 54 | for (int i=0;i<10;i++) { 55 | float locator_x = float(markers[i]) / samples_per_pixel - viewport_left; 56 | 57 | if (MCposition.x > locator_x - 0.05 && MCposition.x < locator_x + 8.0) { 58 | gl_FragColor = marker_colours[i]; 59 | return; 60 | } 61 | } 62 | } 63 | 64 | float interval = 0.0; 65 | if (MCposition.y > 17.0) { 66 | // smallest 67 | interval = pixels_per_unit / (10.0 * n_subs); 68 | } else if (MCposition.y > 14.0) { 69 | interval = pixels_per_unit / (5.0 * n_subs); 70 | } else if (MCposition.y > 10.0) { 71 | interval = pixels_per_unit / n_subs; 72 | } else { 73 | // full size lines 74 | interval = pixels_per_unit; 75 | } 76 | 77 | float m = floor(mod((MCposition.x + viewport_left), interval)); 78 | //m is now an integer value between: 0...interval 79 | //-quantising the value means that the lines are of consistent width and brightness, at the expense of even spacing. 80 | //float val = smoothstep(0.0, 1.0, m); 81 | //val = 1.0 - val * smoothstep(interval, interval - 1.0, m); 82 | float val = m < 1.0 ? 1.0 : 0.0; 83 | c[3] = alpha * val; 84 | 85 | gl_FragColor = c; 86 | } 87 | 88 | -------------------------------------------------------------------------------- /ui/debug_helper.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2012-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | Debug Helper | 11 | | ------------ | 12 | | | 13 | +----------------------------------------------------------------------+ 14 | | 15 | */ 16 | 17 | #include "config.h" 18 | #include "transition/transition.h" 19 | #include "wf/debug.h" 20 | #include "wf/private.h" 21 | #include "waveform/ui-private.h" 22 | #include "waveform/actor.h" 23 | #include "waveform/debug_helper.h" 24 | 25 | typedef struct 26 | { 27 | AGlBehaviour behaviour; 28 | RenderResult previous_result; 29 | } DebugHelper; 30 | 31 | typedef struct 32 | { 33 | AGlBehaviourClass class; 34 | } DebugHelperClass; 35 | 36 | bool debug_helper_draw (AGlBehaviour*, AGlActor*, AGlActorPaint); 37 | 38 | static DebugHelperClass klass = { 39 | .class = { 40 | .draw = debug_helper_draw 41 | } 42 | }; 43 | 44 | 45 | AGlBehaviourClass* 46 | debug_helper_class () 47 | { 48 | return (AGlBehaviourClass*)&klass; 49 | } 50 | 51 | 52 | AGlBehaviour* 53 | debug_helper () 54 | { 55 | return (AGlBehaviour*)AGL_NEW (DebugHelper, 56 | .behaviour= { 57 | .klass = &klass.class, 58 | } 59 | ); 60 | } 61 | 62 | 63 | bool 64 | debug_helper_draw (AGlBehaviour* behaviour, AGlActor* actor, AGlActorPaint wrapped) 65 | { 66 | WaveformActor* wf_actor = (WaveformActor*)actor; 67 | WaveformContext* wfc = wf_actor->context; 68 | 69 | bool result = wrapped (actor); 70 | 71 | if (wf_actor->render_result == ((DebugHelper*)behaviour)->previous_result) return result; 72 | 73 | double spp = wfc->scaled 74 | ? wfc->zoom->value.f / wfc->samples_per_pixel 75 | : agl_actor__width(actor) / wf_actor->region.len; 76 | 77 | switch (wf_actor->render_result) { 78 | case RENDER_RESULT_LOADING: 79 | printf("RENDER_RESULT_LOADING\n"); 80 | break; 81 | case RENDER_RESULT_NO_PROGRAM: 82 | printf("RENDER_RESULT_NO_PROGRAM\n"); 83 | break; 84 | case RENDER_RESULT_NO_AUDIO_DATA: 85 | printf("RENDER_RESULT_NO_AUDIO_DATA\n"); 86 | break; 87 | default: 88 | dbg(0, "%s %s result=%i zoom=%.2f spp=%.04f", result ? "ok" : "failed", wf_actor_print_mode(wf_actor), wf_actor->render_result, wfc->zoom->value.f, spp); 89 | } 90 | 91 | if (!result) { 92 | void agl_actor__print_tree (AGlActor*); 93 | agl_actor__print_tree(actor->parent); 94 | } 95 | 96 | ((DebugHelper*)behaviour)->previous_result = wf_actor->render_result; 97 | 98 | return result; 99 | } 100 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/glext/glxext-extra.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | /* 20 | * Additional GLX extensions. 21 | */ 22 | 23 | #ifndef __glxext_extra_h_ 24 | #define __glxext_extra_h_ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) 31 | #define WIN32_LEAN_AND_MEAN 1 32 | #include 33 | #endif 34 | 35 | #ifndef APIENTRY 36 | #define APIENTRY 37 | #endif 38 | #ifndef GLAPI 39 | #define GLAPI extern 40 | #endif 41 | 42 | /* 43 | * 3DFX 44 | */ 45 | 46 | /* 47 | * ARB 48 | */ 49 | 50 | /* 51 | * EXT 52 | */ 53 | 54 | /* unknown */ 55 | #ifndef GLX_EXT_scene_marker 56 | /* 57 | #define GLX_SCENE_REQUIRED_EXT 0 58 | */ 59 | #endif 60 | 61 | /* unknown */ 62 | #ifndef GLX_EXT_scene_marker 63 | /* #define GLX_EXT_scene_marker 1 */ 64 | #endif 65 | 66 | /* 67 | * MESA 68 | */ 69 | 70 | /* 71 | * NV 72 | */ 73 | 74 | #ifndef GLX_NV_vertex_array_range 75 | #define GLX_NV_vertex_array_range 1 76 | #ifdef GLX_GLXEXT_PROTOTYPES 77 | extern void *glXAllocateMemoryNV (GLsizei, GLfloat, GLfloat, GLfloat); 78 | extern void glXFreeMemoryNV (void *); 79 | #endif /* GLX_GLXEXT_PROTOTYPES */ 80 | typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); 81 | typedef void ( * PFNGLXFREEMEMORYNVPROC) (void *pointer); 82 | #endif 83 | 84 | /* 85 | * OML 86 | */ 87 | 88 | /* 89 | * SGI 90 | */ 91 | 92 | /* 93 | * SGIS 94 | */ 95 | 96 | /* unknown */ 97 | #ifndef GLX_SGIS_color_range 98 | /* 99 | #define GLX_EXTENDED_RANGE_SGIS 0 100 | #define GLX_MIN_RED_SGIS 0 101 | #define GLX_MAX_RED_SGIS 0 102 | #define GLX_MIN_GREEN_SGIS 0 103 | #define GLX_MAX_GREEN_SGIS 0 104 | #define GLX_MIN_BLUE_SGIS 0 105 | #define GLX_MAX_BLUE_SGIS 0 106 | #define GLX_MIN_ALPHA_SGIS 0 107 | #define GLX_MAX_ALPHA_SGIS 0 108 | */ 109 | #endif 110 | 111 | /* unknown */ 112 | #ifndef GLX_SGIS_color_range 113 | /* #define GLX_SGIS_color_range 1 */ 114 | #endif 115 | 116 | /* 117 | * SGIX 118 | */ 119 | 120 | /* 121 | * SUN 122 | */ 123 | 124 | #ifdef __cplusplus 125 | } 126 | #endif 127 | 128 | #endif /* __glxext_extra_h_ */ 129 | -------------------------------------------------------------------------------- /test/suppressions/pango.supp: -------------------------------------------------------------------------------- 1 | # The below suppressions suppress just about every entry that pango 2 | # libraries could have contributed to. This is likely excessive... ;) 3 | # 4 | # We make good use of the wildcarding features of Valgrind. By using 5 | # wildcarded library object filenames we can hope this source is 6 | # portable to more systems. 7 | 8 | # On one tested system (Ubuntu 14.04), these libraries are: 9 | # /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0.3600.3 10 | # /usr/lib/x86_64-linux-gnu/libpangoxft-1.0.so.0.3600.3 11 | # /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0.3600.3 12 | # /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0.3600.3 13 | 14 | # On the tested system (Fedora 20), these libraries are: 15 | # /usr/lib64/libpango-1.0.so.0.3600.1 16 | # /usr/lib64/libpangocairo-1.0.so.0.3600.1 17 | # /usr/lib64/libpangoft2-1.0.so.0.3600.1 18 | # /usr/lib64/libpangoxft-1.0.so.0.3600.1 19 | 20 | # "4.4. Writing suppression files" 21 | # http://valgrind.org/docs/manual/mc-manual.html#mc-manual.suppfiles 22 | # match-leak-kinds: definite,possible 23 | # definite indirect possible reachable all none 24 | 25 | { 26 | ff_pango_leak_calloc_lib_global 27 | Memcheck:Leak 28 | match-leak-kinds: definite,possible 29 | fun:calloc 30 | ... 31 | obj:*/libpango* 32 | } 33 | { 34 | ff_pango_leak_malloc_lib_global 35 | Memcheck:Leak 36 | match-leak-kinds: definite,possible 37 | fun:malloc 38 | ... 39 | obj:*/libpango* 40 | } 41 | { 42 | ff_pango_leak_realloc_lib_global 43 | Memcheck:Leak 44 | match-leak-kinds: definite,possible 45 | fun:realloc 46 | ... 47 | obj:*/libpango* 48 | } 49 | 50 | # On Ubuntu 51 | # 3 ff_pango_leak_calloc_lib_global valgrind_ff_pango.supp:40 suppressed: 143 bytes in 3 blocks 52 | # 10 ff_pango_leak_malloc_lib_global valgrind_ff_pango.supp:48 suppressed: 336 bytes in 10 blocks 53 | # 14 ff_pango_leak_realloc_lib_global valgrind_ff_pango.supp:56 suppressed: 85,576 bytes in 24 blocks 54 | # 27 55 | 56 | # 4 ff_pango_leak_calloc_lib_global valgrind_ff_pango.supp:47 suppressed: 175 bytes in 4 blocks 57 | # 22 ff_pango_leak_malloc_lib_global valgrind_ff_pango.supp:55 suppressed: 837 bytes in 34 blocks 58 | # 14 ff_pango_leak_realloc_lib_global valgrind_ff_pango.supp:63 suppressed: 84,784 bytes in 24 blocks 59 | # 40 60 | 61 | # On Fedora 62 | # 4 ff_pango_leak_calloc_lib_global valgrind_ff_pango.supp:18 suppressed: 175 bytes in 4 blocks 63 | # 11 ff_pango_leak_malloc_lib_global valgrind_ff_pango.supp:26 suppressed: 344 bytes in 11 blocks 64 | # 12 ff_pango_leak_realloc_lib_global valgrind_ff_pango.supp:34 suppressed: 85,145 bytes in 24 blocks 65 | # 27 66 | 67 | { 68 | 69 | Memcheck:Leak 70 | match-leak-kinds: possible 71 | fun:malloc 72 | fun:strdup 73 | fun:FcValueSave 74 | obj:*/libfontconfig.* 75 | } 76 | { 77 | 78 | Memcheck:Leak 79 | match-leak-kinds: definite 80 | ... 81 | fun:FcPatternDuplicate 82 | } 83 | { 84 | 85 | Memcheck:Leak 86 | match-leak-kinds: possible 87 | fun:malloc 88 | obj:*/libfontconfig.so.* 89 | } 90 | -------------------------------------------------------------------------------- /decoder/ad.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2016-2025 Tim Orford | 5 | | copyright (C) 2011 Robin Gareus | 6 | +----------------------------------------------------------------------+ 7 | | This program is free software; you can redistribute it and/or modify | 8 | | it under the terms of the GNU General Public License version 3 | 9 | | as published by the Free Software Foundation. | 10 | +----------------------------------------------------------------------+ 11 | | 12 | */ 13 | 14 | #pragma once 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include "wf/typedefs.h" 21 | 22 | typedef struct 23 | { 24 | uint32_t sample_rate; 25 | uint16_t channels; 26 | int64_t length; // milliseconds 27 | int64_t frames; // total number of frames (eg a frame for 16bit stereo is 4 bytes). 28 | int32_t bit_rate; 29 | int16_t bit_depth; 30 | GPtrArray* meta_data; 31 | } WfAudioInfo; 32 | 33 | typedef struct _AdPlugin AdPlugin; 34 | 35 | typedef struct 36 | { 37 | WfAudioInfo info; 38 | const AdPlugin* b; // impl 39 | void* d; // private impl data 40 | } WfDecoder; 41 | 42 | struct _AdPlugin 43 | { 44 | int (*eval) (const char*); 45 | bool (*open) (WfDecoder*, const char*); 46 | int (*close) (WfDecoder*); 47 | int (*info) (WfDecoder*); 48 | int64_t (*seek) (WfDecoder*, int64_t); 49 | ssize_t (*read) (WfDecoder*, float*, size_t); 50 | ssize_t (*read_short) (WfDecoder*, WfBuf16*); 51 | ssize_t (*read_s32) (WfDecoder*, int32_t*, size_t); 52 | }; 53 | 54 | 55 | typedef struct 56 | { 57 | int width; 58 | int height; 59 | int row_stride; 60 | uint8_t* data; 61 | } AdPicture; 62 | 63 | /* low level API */ 64 | bool ad_open (WfDecoder*, const char*); 65 | int ad_close (WfDecoder*); 66 | void ad_clear (WfDecoder*); 67 | int64_t ad_seek (WfDecoder*, int64_t); 68 | ssize_t ad_read (WfDecoder*, float*, size_t); 69 | ssize_t ad_read_short (WfDecoder*, WfBuf16*); 70 | ssize_t ad_read_s32 (WfDecoder*, int32_t*, size_t); 71 | int ad_info (WfDecoder*); 72 | 73 | bool ad_finfo (const char*, WfAudioInfo*); 74 | void ad_clear_nfo (WfAudioInfo*); 75 | void ad_free_nfo (WfAudioInfo*); 76 | void ad_print_nfo (int dbglvl, WfAudioInfo*); 77 | 78 | void ad_thumbnail (WfDecoder*, AdPicture*); 79 | void ad_thumbnail_free(WfDecoder*, AdPicture*); 80 | 81 | ssize_t ad_read_mono_dbl (WfDecoder*, double*, size_t); 82 | 83 | /* hardcoded backends */ 84 | #ifdef USE_SNDFILE 85 | const AdPlugin* get_sndfile (); 86 | #endif 87 | #ifdef USE_FFMPEG 88 | const AdPlugin* get_ffmpeg (); 89 | #endif 90 | 91 | #define ad_is_open(D) (D.d != NULL) 92 | 93 | #define AD_FLOAT_TO_SHORT(A) round(A * 32767.f); // SHRT_MAX 94 | 95 | G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(WfDecoder, ad_clear) 96 | -------------------------------------------------------------------------------- /lib/debug/debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2013-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #define __debug_c__ 14 | 15 | #include "config.h" 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "debug.h" 22 | 23 | int _debug_ = 0; 24 | 25 | char ayyi_warn [32] = "\x1b[1;33mwarning:\x1b[0;39m"; 26 | char ayyi_err [32] = "\x1b[1;31merror\x1b[0;39m"; 27 | char ayyi_white [12] = "\x1b[0;39m"; 28 | char ayyi_bold [12] = "\x1b[1;39m"; 29 | 30 | #undef SHOW_TIME 31 | #ifdef SHOW_TIME 32 | static uint64_t 33 | _get_time () 34 | { 35 | struct timeval start; 36 | gettimeofday(&start, NULL); 37 | return start.tv_sec * 1000 + start.tv_usec / 1000; 38 | } 39 | #endif 40 | 41 | 42 | #if DEBUG 43 | void 44 | debug_printf (const char* func, int level, const char* format, ...) 45 | { 46 | va_list args; 47 | va_start(args, format); 48 | if (level <= _debug_) { 49 | #ifdef SHOW_TIME 50 | fprintf(stderr, "%Lu %s(): ", _get_time(), func); 51 | #else 52 | fprintf(stderr, "%s(): ", func); 53 | #endif 54 | vfprintf(stderr, format, args); 55 | fprintf(stderr, "\n"); 56 | } 57 | va_end(args); 58 | } 59 | #endif 60 | 61 | 62 | /* 63 | * Print a warning string, then pass arguments on to vprintf. 64 | */ 65 | void 66 | warnprintf (const char* format, ...) 67 | { 68 | printf("%s ", ayyi_warn); 69 | 70 | va_list argp; 71 | va_start(argp, format); 72 | vprintf(format, argp); 73 | va_end(argp); 74 | } 75 | 76 | 77 | void 78 | warnprintf2 (const char* func, char* format, ...) 79 | { 80 | printf("%s %s(): ", ayyi_warn, func); 81 | 82 | va_list argp; 83 | va_start(argp, format); 84 | vprintf(format, argp); 85 | va_end(argp); 86 | } 87 | 88 | 89 | /* 90 | * Print an error string, then pass arguments on to vprintf. 91 | */ 92 | void 93 | errprintf (const char* format, ...) 94 | { 95 | printf("%s ", ayyi_err); 96 | 97 | va_list argp; 98 | va_start(argp, format); 99 | vprintf(format, argp); 100 | va_end(argp); 101 | } 102 | 103 | 104 | static void 105 | log_handler (const gchar* log_domain, GLogLevelFlags log_level, const gchar* message, gpointer user_data) 106 | { 107 | switch(log_level){ 108 | case G_LOG_LEVEL_CRITICAL: 109 | printf("%s %s\n", ayyi_err, message); 110 | break; 111 | case G_LOG_LEVEL_WARNING: 112 | printf("%s %s\n", ayyi_warn, message); 113 | break; 114 | default: 115 | if(_debug_) printf("log_handler(): level=%i %s\n", log_level, message); 116 | break; 117 | } 118 | } 119 | 120 | 121 | void 122 | set_log_handlers () 123 | { 124 | g_log_set_default_handler(log_handler, NULL); 125 | } 126 | -------------------------------------------------------------------------------- /wf/loaders/ardour.c: -------------------------------------------------------------------------------- 1 | /** 2 | * +----------------------------------------------------------------------+ 3 | * | This file is part of libwaveform | 4 | * | https://github.com/ayyi/libwaveform | 5 | * | copyright (C) 2012-2020 Tim Orford | 6 | * +----------------------------------------------------------------------+ 7 | * | This program is free software; you can redistribute it and/or modify | 8 | * | it under the terms of the GNU General Public License version 3 | 9 | * | as published by the Free Software Foundation. | 10 | * +----------------------------------------------------------------------+ 11 | * 12 | */ 13 | #define _XOPEN_SOURCE 500 14 | #define ENABLE_CHECKS 15 | #define __wf_private__ 16 | #include "config.h" 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "debug/debug.h" 27 | #include "wf/waveform.h" 28 | 29 | static int peak_byte_depth = 4; //ardour peak files use floats. 30 | 31 | static size_t get_n_words(Waveform*, const char* peakfile); 32 | 33 | 34 | /* 35 | * load the contents of a peak file from an Ardour project. 36 | */ 37 | int 38 | wf_load_ardour_peak (Waveform* wv, const char* peak_file) 39 | { 40 | g_return_val_if_fail(wv, 0); 41 | 42 | int fp = open(peak_file, O_RDONLY); 43 | if(!fp){ pwarn ("file open failure."); goto out; } 44 | dbg(2, "%s", peak_file); 45 | 46 | size_t n_frames = get_n_words(wv, peak_file); 47 | 48 | uint32_t bytes = n_frames * peak_byte_depth * WF_PEAK_VALUES_PER_SAMPLE; 49 | 50 | // read the whole peak file into memory 51 | float* read_buf = g_malloc(bytes); 52 | if(read(fp, read_buf, bytes) != bytes) perr ("read error. couldnt read %i bytes from %s", bytes, peak_file); 53 | close(fp); 54 | 55 | // convert from float to short 56 | short* buf = waveform_peakbuf_malloc(wv, WF_LEFT, n_frames * WF_PEAK_VALUES_PER_SAMPLE); 57 | int i; for(i=0;ipriv->peak.buf[WF_LEFT] ? 1 : 0; //this makes too many assumptions. better to pass explicitly as argument. 66 | wv->priv->peak.buf[ch_num] = buf; 67 | 68 | #ifdef ENABLE_CHECKS 69 | int k; for(k=0;kpriv->peak.buf[0][2*k + 0] < 0.0){ pwarn("positive peak not positive"); break; } 71 | if(wv->priv->peak.buf[0][2*k + 1] > 0.0){ pwarn("negative peak not negative"); break; } 72 | } 73 | #endif 74 | out: 75 | 76 | return 1; 77 | } 78 | 79 | 80 | static size_t 81 | get_n_words (Waveform* wv, const char* peakfile) 82 | { 83 | // ardour peak files are oversized. To get the useable size, we need to refer to the original file. 84 | 85 | int64_t n_frames = waveform_get_n_frames(wv); 86 | 87 | dbg(3, "n_frames=%"PRIi64" n_peaks=%zu", n_frames, (size_t)(ceil(((float)n_frames) / WF_PEAK_RATIO))); 88 | 89 | return ceil(((float)n_frames) / WF_PEAK_RATIO); 90 | } 91 | 92 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gdkglwindow.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __gdk_gl_window_h__ 20 | #define __gdk_gl_window_h__ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | G_BEGIN_DECLS 28 | 29 | typedef struct _GdkGLWindow GdkGLWindow; 30 | typedef struct _GdkGLWindowClass GdkGLWindowClass; 31 | 32 | #define GDK_TYPE_GL_WINDOW (gdk_gl_window_get_type ()) 33 | #define GDK_GL_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GL_WINDOW, GdkGLWindow)) 34 | #define GDK_GL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_WINDOW, GdkGLWindowClass)) 35 | #define GDK_IS_GL_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GL_WINDOW)) 36 | #define GDK_IS_GL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_WINDOW)) 37 | #define GDK_GL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_WINDOW, GdkGLWindowClass)) 38 | 39 | struct _GdkGLWindow 40 | { 41 | GdkDrawable parent_instance; 42 | 43 | GdkDrawable* drawable; /* Associated GdkWindow */ 44 | 45 | /* GLXWindow glxwindow; */ 46 | Window glxwindow; 47 | 48 | GdkGLConfig *glconfig; 49 | 50 | guint is_destroyed : 1; 51 | }; 52 | 53 | struct _GdkGLWindowClass 54 | { 55 | GdkDrawableClass parent_class; 56 | }; 57 | 58 | GType gdk_gl_window_get_type (void); 59 | 60 | /* 61 | * attrib_list is currently unused. This must be set to NULL or empty 62 | * (first attribute of None). See GLX 1.3 spec. 63 | */ 64 | GdkGLWindow* gdk_gl_window_new (GdkGLConfig*, GdkWindow*, const int* attrib_list); 65 | GdkWindow* gdk_gl_window_get_window (GdkGLWindow*); 66 | 67 | /* 68 | * OpenGL extension to GdkWindow 69 | */ 70 | 71 | GdkGLWindow* gdk_window_set_gl_capability (GdkWindow*, GdkGLConfig*, const int* attrib_list); 72 | void gdk_window_unset_gl_capability (GdkWindow*); 73 | gboolean gdk_window_is_gl_capable (GdkWindow*); 74 | GdkGLWindow* gdk_window_get_gl_window (GdkWindow*); 75 | 76 | #define gdk_window_get_gl_drawable(window) \ 77 | GDK_GL_DRAWABLE (gdk_window_get_gl_window (window)) 78 | 79 | GdkGLConfig* gdk_gl_window_get_gl_config (GdkGLDrawable*); 80 | void gdk_gl_window_swap_buffers (GdkGLDrawable*); 81 | gboolean gdk_gl_window_make_context_current (GdkGLDrawable*, GdkGLContext*); 82 | 83 | G_END_DECLS 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /gtkglext-1.0/gdk/gdkglx.h: -------------------------------------------------------------------------------- 1 | /* GdkGLExt - OpenGL Extension to GDK 2 | * Copyright (C) 2002-2004 Naofumi Yasufuku 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 | */ 18 | 19 | #ifndef __GDK_GL_X_H__ 20 | #define __GDK_GL_X_H__ 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | gboolean gdk_x11_gl_query_glx_extension (GdkGLConfig*, const char *extension); 35 | 36 | #ifndef GDK_MULTIHEAD_SAFE 37 | GdkGLConfig *gdk_x11_gl_config_new_from_visualid (VisualID); 38 | #endif /* GDK_MULTIHEAD_SAFE */ 39 | GdkGLConfig *gdk_x11_gl_config_new_from_visualid_for_screen (GdkScreen *screen, VisualID xvisualid); 40 | 41 | Display *gdk_x11_gl_config_get_xdisplay (GdkGLConfig *glconfig); 42 | XVisualInfo *gdk_x11_gl_config_get_xvinfo (GdkGLConfig *glconfig); 43 | gboolean gdk_x11_gl_config_is_mesa_glx (GdkGLConfig *glconfig); 44 | 45 | GdkGLContext *gdk_x11_gl_context_foreign_new (GdkGLConfig *glconfig, GdkGLContext *share_list, GLXContext); 46 | 47 | GLXContext gdk_x11_gl_context_get_glxcontext (GdkGLContext *glcontext); 48 | 49 | GLXPixmap gdk_x11_gl_pixmap_get_glxpixmap (GdkGLPixmap *glpixmap); 50 | 51 | Window gdk_x11_gl_window_get_glxwindow (GdkGLWindow *glwindow); 52 | 53 | #ifdef INSIDE_GDK_GL_X11 54 | 55 | #define GDK_GL_CONFIG_XDISPLAY(glconfig) (glconfig->xdisplay) 56 | #define GDK_GL_CONFIG_SCREEN_XNUMBER(glconfig) (glconfig->screen_num) 57 | #define GDK_GL_CONFIG_XVINFO(glconfig) (glconfig->xvinfo) 58 | #define GDK_GL_CONFIG_XCOLORMAP(glconfig) (GDK_COLORMAP_XCOLORMAP (glconfig->colormap)) 59 | #define GDK_GL_CONTEXT_GLXCONTEXT(glcontext) (GDK_GL_CONTEXT_IMPL_X11 (glcontext)->glxcontext) 60 | #define GDK_GL_PIXMAP_GLXPIXMAP(glpixmap) (GDK_GL_PIXMAP_IMPL_X11 (glpixmap)->glxpixmap) 61 | #define GDK_GL_WINDOW_GLXWINDOW(glwindow) (GDK_GL_WINDOW_IMPL_X11 (glwindow)->glxwindow) 62 | 63 | #else 64 | 65 | #define GDK_GL_CONFIG_XDISPLAY(glconfig) (gdk_x11_gl_config_get_xdisplay (glconfig)) 66 | #define GDK_GL_CONFIG_XVINFO(glconfig) (gdk_x11_gl_config_get_xvinfo (glconfig)) 67 | #define GDK_GL_CONFIG_XCOLORMAP(glconfig) (GDK_COLORMAP_XCOLORMAP (gdk_gl_config_get_colormap (glconfig))) 68 | #define GDK_GL_CONTEXT_GLXCONTEXT(glcontext) (gdk_x11_gl_context_get_glxcontext (glcontext)) 69 | #define GDK_GL_PIXMAP_GLXPIXMAP(glpixmap) (gdk_x11_gl_pixmap_get_glxpixmap (glpixmap)) 70 | #define GDK_GL_WINDOW_GLXWINDOW(glwindow) (gdk_x11_gl_window_get_glxwindow (glwindow)) 71 | 72 | #endif 73 | 74 | G_END_DECLS 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /shaders/ruler_bottom.frag: -------------------------------------------------------------------------------- 1 | /* 2 | copyright (C) 2012-2025 Tim Orford 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License version 3 6 | as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 | */ 17 | 18 | uniform float samples_per_pixel; 19 | uniform float beats_per_pixel; 20 | uniform float viewport_left; 21 | uniform vec4 fg_colour; 22 | uniform int markers[10]; 23 | 24 | varying vec2 MCposition; 25 | varying vec2 ecPosition; 26 | 27 | /* 28 | * This ruler version is intended to be positioned at the bottom of the window. 29 | * Actor height is expected to be 20px. 30 | * It works with frames, not beats and bars. 31 | * The uniforms are compatible with the other ruler shaders. 32 | * For coordinate calculations to work the quad must be positioned using glTranslatef(), with x1=0, y1=0. 33 | */ 34 | void main(void) 35 | { 36 | vec4 marker_colours[10]; 37 | marker_colours[0] = vec4(0.5, 0.8, 0.5, 1.0); 38 | marker_colours[1] = vec4(0.5, 0.6, 0.8, 1.0); 39 | marker_colours[2] = vec4(0.5, 0.6, 0.8, 1.0); 40 | marker_colours[3] = vec4(0.5, 0.6, 0.8, 1.0); 41 | marker_colours[4] = vec4(0.5, 0.6, 0.8, 1.0); 42 | marker_colours[5] = vec4(0.5, 0.6, 0.8, 1.0); 43 | marker_colours[6] = vec4(0.5, 0.6, 0.8, 1.0); 44 | marker_colours[7] = vec4(0.5, 0.6, 0.8, 1.0); 45 | marker_colours[8] = vec4(0.5, 0.6, 0.8, 1.0); 46 | marker_colours[9] = vec4(0.8, 0.6, 0.5, 1.0); 47 | 48 | vec4 c = vec4(1.0) * fg_colour; 49 | float alpha = c[3]; 50 | c[3] = 0.0; 51 | 52 | float pixels_per_beat = 1.0 / beats_per_pixel; 53 | float pixels_per_sec = 2.0 / beats_per_pixel; 54 | float pixels_per_bar = pixels_per_beat * 4.0; 55 | 56 | if (MCposition.y > 20.0) { 57 | for (int i=0;i<10;i++) { 58 | float locator_x = float(markers[i]) / samples_per_pixel - viewport_left; 59 | 60 | if(MCposition.x > locator_x - 0.05 && MCposition.x < locator_x + 8.0){ 61 | gl_FragColor = marker_colours[i]; 62 | return; 63 | } 64 | } 65 | } 66 | 67 | float interval = 0.0; 68 | if (MCposition.y > 17.0) { 69 | // smallest 70 | interval = pixels_per_sec * 9.6 / float(int(1.9 * pixels_per_beat) + 1); 71 | } else if (MCposition.y > 14.0) { 72 | interval = pixels_per_sec * 48.0 / float(int(1.9 * pixels_per_beat) + 1); 73 | } else if (MCposition.y > 10.0) { 74 | interval = pixels_per_sec * 240.0 / float(int(1.9 * pixels_per_beat) + 1); 75 | } else { 76 | // full size lines 77 | interval = pixels_per_sec * 480.0 / float(int(1.9 * pixels_per_beat) + 1); 78 | } 79 | 80 | float m = floor(mod((MCposition.x + viewport_left), interval)); 81 | //m is now an integer value between: 0...interval 82 | //-quantising the value means that the lines are of consistent width and brightness, at the expense of even spacing. 83 | //float val = smoothstep(0.0, 1.0, m); 84 | //val = 1.0 - val * smoothstep(interval, interval - 1.0, m); 85 | float val = m < 1.0 ? 1.0 : 0.0; 86 | c[3] = alpha * val; 87 | 88 | gl_FragColor = c; 89 | } 90 | 91 | -------------------------------------------------------------------------------- /lib/test/runner.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2012-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | 11 | */ 12 | 13 | #pragma once 14 | 15 | #include 16 | 17 | typedef void (*Test) (); 18 | typedef void (TestFn) (); 19 | typedef int (SetupFn) (); 20 | typedef void (TeardownFn) (); 21 | 22 | typedef bool (*ReadyTest) (gpointer); 23 | typedef void (*WaitCallback) (gpointer); 24 | 25 | typedef struct { 26 | int n_tests; 27 | int n_passed; 28 | int n_failed; 29 | int n_skipped; 30 | int timeout; 31 | bool passed; 32 | bool is_gtk; 33 | struct { 34 | int test; 35 | char name[64]; 36 | bool skipped; 37 | bool finished; // current test has finished. Go onto the next test. 38 | GList* timers; 39 | } current; 40 | } Runner; 41 | 42 | #ifdef __runner_c__ 43 | Runner TEST = {.current = {-1}}; 44 | #else 45 | extern Runner TEST; 46 | #endif 47 | 48 | void test_finish (); 49 | void test_reset_timeout (int ms); 50 | void test_errprintf (char*, ...); 51 | void wait_for (ReadyTest, WaitCallback, gpointer); 52 | 53 | #ifndef red 54 | #define RED "\x1b[1;31m" 55 | #define GREEN "\x1b[1;32m" 56 | #define YELLOW "\x1b[1;33m" 57 | #endif 58 | 59 | #define START_TEST \ 60 | static int step = 0; \ 61 | static int __test_idx; \ 62 | __test_idx = TEST.current.test; \ 63 | if(!step){ \ 64 | g_strlcpy(TEST.current.name, __func__, 64); \ 65 | printf("%srunning %i of %i: %s%s ...\n", ayyi_bold, TEST.current.test + 1, TEST.n_tests, __func__, ayyi_white); \ 66 | } \ 67 | if(TEST.current.finished) return; 68 | 69 | #define FINISH_TEST \ 70 | if(__test_idx != TEST.current.test) return; \ 71 | printf("%s: finish\n", TEST.current.name); \ 72 | TEST.passed = true; \ 73 | test_finish(); \ 74 | return; 75 | 76 | #define FINISH_TEST_TIMER_STOP \ 77 | if(__test_idx != TEST.current.test) return G_SOURCE_REMOVE; \ 78 | TEST.passed = true; \ 79 | test_finish(); \ 80 | return G_SOURCE_REMOVE; 81 | 82 | #define FAIL_TEST(msg, ...) \ 83 | { \ 84 | TEST.passed = false; \ 85 | printf("%s: ", TEST.current.name); \ 86 | test_errprintf(msg, ##__VA_ARGS__); \ 87 | test_finish(); \ 88 | return; } 89 | 90 | #define FAIL_TEST_TIMER(msg) \ 91 | { \ 92 | TEST.passed = false; \ 93 | printf("%s: ", TEST.current.name); \ 94 | printf("%s%s%s\n", RED, msg, ayyi_white); \ 95 | test_finish(); \ 96 | return G_SOURCE_REMOVE;} 97 | 98 | #define SKIP_TEST \ 99 | TEST.current.skipped = true; \ 100 | test_finish(); \ 101 | return; 102 | 103 | #define assert(A, B, ...) \ 104 | {bool __ok_ = ((A) != 0); \ 105 | {if(!__ok_) printf("line %i: ", __LINE__); } \ 106 | {if(!__ok_) perr(B, ##__VA_ARGS__); } \ 107 | {if(!__ok_) FAIL_TEST("assertion failed") }} 108 | 109 | #define assert_and_stop(A, B, ...) \ 110 | {bool __ok_ = ((A) != 0); \ 111 | {if(!__ok_) perr(B, ##__VA_ARGS__); } \ 112 | {if(!__ok_) FAIL_TEST_TIMER("assertion failed") }} 113 | -------------------------------------------------------------------------------- /ui/actors/labels.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2013-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | | 11 | | WaveformLabels draws text over the ruler showing minutes and seconds | 12 | | | 13 | +----------------------------------------------------------------------+ 14 | | 15 | */ 16 | 17 | #include "config.h" 18 | #include "agl/behaviours/cache.h" 19 | #include "waveform/actor.h" 20 | #include "waveform/labels.h" 21 | 22 | typedef struct { 23 | AGlActor actor; 24 | WaveformContext* context; 25 | } LabelsActor; 26 | 27 | static AGl* agl = NULL; 28 | 29 | static bool labels_actor_paint (AGlActor*); 30 | 31 | 32 | static void 33 | labels_actor_init (AGlActor* actor) 34 | { 35 | } 36 | 37 | 38 | static void 39 | labels_actor_size (AGlActor* actor) 40 | { 41 | } 42 | 43 | 44 | AGlActor* 45 | labels_actor (WaveformContext* context) 46 | { 47 | g_return_val_if_fail(context, NULL); 48 | 49 | agl = agl_get_instance(); 50 | 51 | LabelsActor* labels = AGL_NEW(LabelsActor, 52 | .actor = { 53 | .name = "labels", 54 | .init = labels_actor_init, 55 | .paint = labels_actor_paint, 56 | .set_size = labels_actor_size, 57 | .behaviours = { 58 | cache_behaviour(), 59 | } 60 | }, 61 | .context = context, 62 | ); 63 | 64 | return (AGlActor*)labels; 65 | } 66 | 67 | 68 | static bool 69 | labels_actor_paint (AGlActor* actor) 70 | { 71 | #ifdef USE_CANVAS_SCALING 72 | LabelsActor* labels = (LabelsActor*)actor; 73 | WaveformContext* context = labels->context; 74 | 75 | g_return_val_if_fail(context, false); 76 | if(!context->sample_rate) return false; // eg if file not loaded 77 | 78 | float zoom = 0; // pixels per sample 79 | float _zoom = wf_context_get_zoom(context); 80 | if (_zoom > 0.0) { 81 | zoom = _zoom / context->samples_per_pixel; 82 | } else { 83 | zoom = 1.0 / context->samples_per_pixel; 84 | } 85 | 86 | int interval = context->sample_rate * (zoom > 0.0002 ? 1 : zoom > 0.0001 ? 5 : zoom > 0.00001 ? 48 : 480); 87 | const int64_t region_end = context->scaled 88 | ? context->start_time->value.b + agl_actor__width(actor) * context->samples_per_pixel * context->zoom->value.f 89 | : context->start_time->value.b + agl_actor__width(actor) * context->samples_per_pixel; 90 | 91 | int i = 0; 92 | uint64_t f = ((int)(context->start_time->value.b / interval)) * interval; 93 | 94 | agl_set_font_string("Roboto 7"); 95 | char s[16] = {0,}; 96 | int x_ = 0; 97 | for (; (f < region_end) && (i < 0xff); f += interval, i++) { 98 | int x = wf_context_frame_to_x(context, f) + 3; 99 | if (x - x_ > 60) { 100 | uint64_t mins = f / (60 * context->sample_rate); 101 | snprintf(s, 15, "%"PRIi64":%.1f", mins, ((float)f) / context->sample_rate - 60 * mins); 102 | agl_print(x, 0, 0, actor->colour, s); 103 | x_ = x; 104 | } 105 | } 106 | agl_set_font_string("Roboto 10"); 107 | #endif 108 | return true; 109 | } 110 | -------------------------------------------------------------------------------- /ui/actors/ruler.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | This file is part of the Ayyi project. https://www.ayyi.org | 4 | | copyright (C) 2013-2025 Tim Orford | 5 | +----------------------------------------------------------------------+ 6 | | This program is free software; you can redistribute it and/or modify | 7 | | it under the terms of the GNU General Public License version 3 | 8 | | as published by the Free Software Foundation. | 9 | +----------------------------------------------------------------------+ 10 | | | 11 | | WaveformGrid draws timeline markers onto a shared opengl drawable. | 12 | | | 13 | +----------------------------------------------------------------------+ 14 | | 15 | */ 16 | 17 | #include "config.h" 18 | #include "agl/behaviours/cache.h" 19 | #include "wf/waveform.h" 20 | #include "waveform/actor.h" 21 | #include "waveform/context.h" 22 | #include "waveform/grid.h" 23 | 24 | extern RulerShader ruler; 25 | 26 | typedef struct { 27 | AGlActor actor; 28 | WaveformContext* context; 29 | } RulerActor; 30 | 31 | static AGl* agl = NULL; 32 | 33 | static bool ruler_actor_paint (AGlActor*); 34 | 35 | 36 | static void 37 | ruler_actor_size (AGlActor* actor) 38 | { 39 | actor->region.x2 = agl_actor__width(actor->parent); 40 | } 41 | 42 | 43 | static void 44 | ruler_set_state (AGlActor* actor) 45 | { 46 | if (!agl->use_shaders) return; 47 | 48 | #define samples_per_beat(C) (C->sample_rate / (C->bpm / 60.0)) 49 | 50 | RulerShader* shader = &ruler; 51 | RulerActor* ruler = (RulerActor*)actor; 52 | WaveformContext* context = ruler->context; 53 | 54 | shader->uniform.fg_colour = 0xffffff7f; 55 | shader->uniform.beats_per_pixel = context->samples_per_pixel / (samples_per_beat(context) * context->zoom->value.f); 56 | shader->uniform.samples_per_pixel = context->samples_per_pixel; 57 | shader->uniform.viewport_left = -wf_context_frame_to_x(context, 0); 58 | } 59 | 60 | 61 | AGlActor* 62 | ruler_actor (WaveformActor* wf_actor) 63 | { 64 | g_return_val_if_fail(wf_actor, NULL); 65 | 66 | agl = agl_get_instance(); 67 | 68 | return (AGlActor*)AGL_NEW(RulerActor, 69 | .actor = { 70 | .name = strdup("ruler"), 71 | .program = (AGlShader*)&ruler, 72 | .set_state = ruler_set_state, 73 | .paint = ruler_actor_paint, 74 | .set_size = ruler_actor_size, 75 | .behaviours = { 76 | cache_behaviour(), 77 | } 78 | }, 79 | .context = wf_actor->context 80 | ); 81 | } 82 | 83 | 84 | static bool 85 | ruler_actor_paint (AGlActor* actor) 86 | { 87 | if (!agl->use_shaders) return false; 88 | 89 | #if 0 // shader debugging 90 | { 91 | float smoothstep(float edge0, float edge1, float x) 92 | { 93 | float t = CLAMP((x - edge0) / (edge1 - edge0), 0.0, 1.0); 94 | return t * t * (3.0 - 2.0 * t); 95 | } 96 | 97 | float pixels_per_beat = 1.0 / wfc->priv->shaders.ruler->uniform.beats_per_pixel; 98 | dbg(0, "ppb=%.2f", pixels_per_beat); 99 | int x; for(x=0;x<30;x++){ 100 | float m = (x * 100) % ((int)pixels_per_beat * 100); 101 | float m_ = x - pixels_per_beat * floor(x / pixels_per_beat); 102 | printf(" %.2f %.2f %.2f\n", m / 100, m_, smoothstep(0.0, 0.5, m_)); 103 | } 104 | } 105 | #endif 106 | 107 | agl_quad (-actor->scrollable.x1, 0., actor->region.x2, agl_actor__height(actor)); 108 | 109 | return true; 110 | } 111 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 20120309 2 | -added Low Res mode with blocks covering 16 times the length of standard res. 3 | -set Viewport in actor_test to speed up drawing at high zoom. 4 | 20120318 5 | -added support for asynchronous GdkPixbuf rendering. 6 | -improvements to hi res mode handling. 7 | -bugfixes for XDG cache directory settings. 8 | 20120320 9 | -fixed position of first block at hi res with inset. 10 | -added pkgconfig file. 11 | 20120401 12 | -improved shader texture sampling: added pseudo window fn and 2x oversampling. 13 | 20120407 14 | -added impulse section to test wav. 15 | -initial support for texture overlapping. 16 | -added initial support for rendering to frame buffer objects. 17 | -added additional test program actor_plus to demonstrate more complex display. 18 | [...] 19 | 20130111 20 | -improved support for decorative text 21 | -added gtkwidget that includes support for text labels 22 | -made fbo's variable size 23 | -moved some functions from libwaveform to libagl 24 | 20130329 25 | -added support for non-square fbo's 26 | -added support for stencil buffer masks in fbo's. 27 | -expanded api for font setting. 28 | 20130504 29 | -fixes for non-shader non-texture hi-res mode. 30 | -added incomplete support for non-shader hi-res textures. 31 | -added test program showing a list of regions similar to a wav editor. 32 | -added fn to set gain for the canvas. 33 | -added gain controls to actor_test 34 | -fixed segfault in animation cancelling 35 | -fixed opacity and colour issues with non-shader rendering. 36 | 20130505 37 | -fixed upside down shader rendering 38 | -added plain colour shader 39 | 20130520 40 | -made WaveformCanvas a GObject 41 | 20130608 42 | -better handling of unrealizing of the WaveformView widget 43 | 20130721 44 | -added anti-aliased drawing at very high zoom. 45 | 20130809 46 | -refactored the transition animator so that it can be used as an independent library. 47 | 20130907 48 | -added support for 32 bit float wavs. 49 | 20130920 50 | -fix for missing redraw following file load at v hi zoom. 51 | 20131001 52 | -fix for gdk keysyms for gtk < 2.22 53 | 20140510 54 | -actor render geometry is now cached to improve drawing speed. 55 | -canvas now emits dimensions-changed and use-shaders-changed signals. 56 | 20140802 57 | -reworking of hi-res mode rendering for opengl2. 58 | 20140809 59 | -separated texture caches for 1D and 2D textures to fix reallocation issues. 60 | 20140822 61 | -extended use of the new rendering method to med-res. 62 | 20140904 63 | -fix gl1 hi-res regression, pkgconfig and make-dist fixes. 64 | 20140912 65 | -introduce new "very low res" mode reduce resource usage for files over one hour in length. 66 | 20140915 67 | -build fixes for missing header files 68 | 20141008 69 | -add support for syncing redraws to screen refresh 70 | 20141101 71 | -primitive support for SDL 72 | 20141105 73 | -rename wf_actor_allocate to wf_actor_set_rect 74 | 20150103 75 | -removed all references to glu and glut 76 | -added transition support with sdl 77 | -added SDL_framerate library 78 | 20150110 79 | -added ability to generate peakfiles using ffmpeg. 80 | -allow display of innaccessible files using only the peakfile. 81 | 20150110 82 | -write peaks to temporary file while writing to fix issues with interrupted writes. 83 | 20150118 84 | -added support for a playback counter to the WaveformViewPlus widget. 85 | 20150122 86 | -added scene graph object. 87 | 20150210 88 | -added labelling of time axis in WaveformViewPlus widget. 89 | -added play-cursor to WaveformViewPlus widget. 90 | -support rendering to offscreen buffer for caching. 91 | 20150610 92 | -added asynchronous generation and loading of peakfiles. 93 | 20150704 94 | -fixes for hi-res rendering to pixbuf. 95 | 20160204 96 | -fixed broken background colour support. 97 | -bugfixes for mouse event handling. 98 | -added support for horizontally scrollable fbo caches. 99 | --------------------------------------------------------------------------------