diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2023-09-05 03:41:01 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2023-09-05 23:39:23 +0300 |
commit | 8cdcf6f747cd85ebc1425acfd9d8a9ebfa84e752 (patch) | |
tree | e4c6307c3b93e9fb3160702dd3f83b739be974e8 | |
parent | 8ac5f63d63b298bb729dedde02e8c50d0efb17f4 (diff) | |
download | applause2-8cdcf6f747cd85ebc1425acfd9d8a9ebfa84e752.tar.gz |
moved common definitions into applause.h
-rw-r--r-- | applause.c | 8 | ||||
-rw-r--r-- | applause.h | 11 | ||||
-rw-r--r-- | applause.lua | 25 |
3 files changed, 17 insertions, 27 deletions
@@ -33,6 +33,7 @@ #include <jack/midiport.h> #include <jack/ringbuffer.h> +#include "applause.h" #include "midi.h" #define LUA_MODULE "applause.lua" @@ -391,13 +392,6 @@ init_audio(int buffer_size) return 0; } -enum applause_audio_state { - APPLAUSE_AUDIO_OK = 0, - APPLAUSE_AUDIO_INTERRUPTED, - APPLAUSE_AUDIO_XRUN, - APPLAUSE_AUDIO_INVALID_PORT -}; - /** * Push one Jack sample into the ring buffer. * diff --git a/applause.h b/applause.h new file mode 100644 index 0000000..c4d9d87 --- /dev/null +++ b/applause.h @@ -0,0 +1,11 @@ +/* This header is included from C and LuaJIT. */ + +enum applause_audio_state { + APPLAUSE_AUDIO_OK = 0, + APPLAUSE_AUDIO_INTERRUPTED, + APPLAUSE_AUDIO_XRUN, + APPLAUSE_AUDIO_INVALID_PORT +}; + +enum applause_audio_state applause_push_sample(int output_port_id, + double sample_double); diff --git a/applause.lua b/applause.lua index 342264c..e80f6c0 100644 --- a/applause.lua +++ b/applause.lua @@ -24,6 +24,8 @@ function cdef_include(file) hnd:close() end +cdef_include "applause.h" + -- -- Define C functions for benchmarking (POSIX libc) -- @@ -47,6 +49,9 @@ typedef enum { } clockid_t; int clock_gettime(clockid_t clk_id, struct timespec *tp); + +// Useful in various situations +void free(void *ptr); ]] -- Measure time required to execute fnc() @@ -73,26 +78,6 @@ function benchmark(fnc) print("Elapsed CPU time: "..tonumber(t2_ms - t1_ms).."ms") end --- --- Define the Lua FFI part of Applause's C core. --- These functions and types are defined in applause.c --- FIXME: Could be read from a common file. --- -cdef_safe[[ -enum applause_audio_state { - APPLAUSE_AUDIO_OK = 0, - APPLAUSE_AUDIO_INTERRUPTED, - APPLAUSE_AUDIO_XRUN, - APPLAUSE_AUDIO_INVALID_PORT -}; - -enum applause_audio_state applause_push_sample(int output_port_id, - double sample_double); - -// Useful in various situations -void free(void *ptr); -]] - -- Sample rate -- This is overwritten by the C core samplerate = 44100 |