├── autogen.sh ├── replacement ├── Makefile.am └── strndup.h ├── BUGS ├── libambix ├── tests │ ├── data │ │ ├── foo.wav │ │ ├── file1.caf.org │ │ ├── Makefile.am │ │ └── foo.pd │ ├── fail.c │ ├── skip.c │ ├── basic2extended_identity4x4_float32__i16.c │ ├── ambix_readf_int16.c │ ├── basic2extended_identity4x4_float32__f64.c │ ├── basic2extended_identity4x4_float32__i32.c │ ├── fail_if0.c │ ├── pass_if0.c │ ├── skip_if0.c │ ├── fail_if1.c │ ├── pass_if1.c │ ├── skip_if1.c │ ├── basic_pcm32.c │ ├── basic_float32.c │ ├── basic_float64.c │ ├── basic_pcm16.c │ ├── extended_float32_0.c │ ├── extended_float64_0.c │ ├── extended_pcm32_0.c │ ├── extended_float32_1024.c │ ├── extended_float64_1024.c │ ├── extended_pcm16_0.c │ ├── extended_pcm32_1024.c │ ├── extended_pcm16_1024.c │ ├── ambix_close.c │ ├── ambix_seek.c │ ├── runtest.sh │ ├── basic2extended_FUMA4x4_pcm16.c │ ├── basic2extended_FUMA4x4_pcm32.c │ ├── basic2extended_N3D4x4_pcm16.c │ ├── basic2extended_N3D4x4_pcm32.c │ ├── basic2extended_SID4x4_float32.c │ ├── basic2extended_SID4x4_float64.c │ ├── basic2extended_SID4x4_pcm16.c │ ├── basic2extended_SID4x4_pcm32.c │ ├── basic2extended_FUMA4x4_float32.c │ ├── basic2extended_FUMA4x4_float64.c │ ├── basic2extended_N3D4x4_float32.c │ ├── basic2extended_N3D4x4_float64.c │ ├── basic2extended_identity4x4_float64.c │ ├── basic2extended_identity4x4_pcm16.c │ ├── basic2extended_identity4x4_pcm32.c │ ├── basic2extended_FUMA4x4_3extra_pcm16.c │ ├── basic2extended_FUMA4x4_3extra_pcm32.c │ ├── basic2extended_N3D4x4_3extra_float32.c │ ├── basic2extended_N3D4x4_3extra_float64.c │ ├── basic2extended_N3D4x4_3extra_pcm16.c │ ├── basic2extended_N3D4x4_3extra_pcm32.c │ ├── basic2extended_SID4x4_3extra_float32.c │ ├── basic2extended_SID4x4_3extra_float64.c │ ├── basic2extended_SID4x4_3extra_pcm16.c │ ├── basic2extended_SID4x4_3extra_pcm32.c │ ├── basic2extended_FUMA4x4_3extra_float32.c │ ├── basic2extended_FUMA4x4_3extra_float64.c │ ├── basic2extended_identity4x4_3extra_float32.c │ ├── basic2extended_identity4x4_3extra_float64.c │ ├── basic2extended_identity4x4_3extra_pcm16.c │ ├── basic2extended_identity4x4_3extra_pcm32.c │ ├── ambix_get_sndfile.c │ ├── debug_utils.c │ ├── ambix_writef_int16.c │ ├── ambix_open.c │ ├── ambix_seek_read.c │ ├── basic2extended_identity4x4_float32.c │ ├── pass.c │ ├── basic2extended_rand4x7_pcm16.c │ ├── basic2extended_rand4x7_pcm32.c │ ├── basic2extended_rand4x7_3extra_pcm16.c │ ├── basic2extended_rand4x7_3extra_pcm32.c │ ├── basic2extended_rand4x7_float32.c │ ├── basic2extended_rand4x7_float64.c │ ├── basic2extended_rand4x7_3extra_float32.c │ ├── basic2extended_rand4x7_3extra_float64.c │ ├── basic2extended_rand4x9_pcm16.c │ ├── basic2extended_rand4x9_pcm32.c │ ├── basic2extended_rand4x9_float32.c │ ├── basic2extended_rand4x9_float64.c │ ├── basic2extended_rand4x9_3extra_pcm16.c │ ├── basic2extended_rand4x9_3extra_pcm32.c │ ├── basic2extended_rand4x9_3extra_float32.c │ ├── basic2extended_rand4x9_3extra_float64.c │ ├── data.h │ ├── none_float32.c │ ├── none_float64.c │ ├── common_basic2extended.h │ ├── datatest.c │ ├── common_none.c │ ├── common_basic.c │ ├── markers_regions.c │ ├── common.h │ └── common_extended.c ├── Makefile.am ├── libambix.pc.in ├── src │ ├── adaptor_acn.c │ ├── null.c │ ├── Makefile.am │ ├── utils.c │ └── uuid_chunk.c └── ambix │ └── exportdefs.h ├── samples ├── Makefile.am └── pd │ ├── ambix-meta.pd.in │ ├── winhacks.c │ ├── winhacks.h │ ├── ambix_info-help.pd │ ├── ambix_write~-help.pd │ ├── Makefile.am │ ├── ambix_read~-help.pd │ ├── ambix_readX~-help.pd │ └── ambix_info.c ├── AUTHORS ├── Makefile.am ├── utils ├── jcommon │ ├── observe-signal.h │ ├── Makefile.am │ ├── jack-ringbuffer.h │ ├── jack-ringbuffer.c │ ├── common.h │ ├── observe-signal.c │ └── common.c ├── Makefile.am ├── README.txt ├── ambix-matrix.c └── ambix-info.c ├── doc └── Makefile.am ├── TODO ├── coverage.sh ├── m4 ├── iem_relativerpath.m4 ├── iem_operatingsystem.m4 ├── iem_check_framework.m4 ├── iem_rte.m4 └── pkg.m4 ├── NEWS ├── .deploy-documentation.sh ├── .travis.yml ├── release.sh ├── README.md ├── CONTRIBUTING.md └── configure.ac /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | autoreconf -fiv 4 | -------------------------------------------------------------------------------- /replacement/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_HEADERS = strndup.h 2 | -------------------------------------------------------------------------------- /BUGS: -------------------------------------------------------------------------------- 1 | ambix-interleave: 2 | fails to re-interleave ambix files 3 | 4 | -------------------------------------------------------------------------------- /libambix/tests/data/foo.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/umlaeute/ambix/HEAD/libambix/tests/data/foo.wav -------------------------------------------------------------------------------- /libambix/tests/data/file1.caf.org: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/umlaeute/ambix/HEAD/libambix/tests/data/file1.caf.org -------------------------------------------------------------------------------- /libambix/tests/fail.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | int main(int argc, char**argv) { 4 | return fail(); 5 | } 6 | -------------------------------------------------------------------------------- /libambix/tests/skip.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | int main(int argc, char**argv) { 4 | return skip(); 5 | } 6 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_identity4x4_float32__i16.c: -------------------------------------------------------------------------------- 1 | #define FMT INT16 2 | #include "basic2extended_identity4x4_float32.c" 3 | -------------------------------------------------------------------------------- /samples/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | SUBDIRS= 3 | 4 | if HAVE_PUREDATA 5 | SUBDIRS+=pd 6 | endif HAVE_PUREDATA 7 | 8 | -------------------------------------------------------------------------------- /libambix/tests/ambix_readf_int16.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | int main () 4 | { 5 | /* FIXXME: no test yet */ 6 | return skip(); 7 | } 8 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_identity4x4_float32__f64.c: -------------------------------------------------------------------------------- 1 | #define FMT FLOAT64 2 | #define EPS 2e-8 3 | #include "basic2extended_identity4x4_float32.c" 4 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_identity4x4_float32__i32.c: -------------------------------------------------------------------------------- 1 | #define FMT INT32 2 | #define EPS 1e-8 3 | 4 | #include "basic2extended_identity4x4_float32.c" 5 | -------------------------------------------------------------------------------- /libambix/tests/fail_if0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | int main(int argc, char**argv) { 4 | return fail_if(0, __LINE__, "should %s fail", "NOT"); 5 | } 6 | -------------------------------------------------------------------------------- /libambix/tests/pass_if0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | int main(int argc, char**argv) { 4 | return pass_if(0, __LINE__, "should %s pass", "NOT"); 5 | } 6 | -------------------------------------------------------------------------------- /libambix/tests/skip_if0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | int main(int argc, char**argv) { 4 | return skip_if(0, __LINE__, "should %s skip", "NOT"); 5 | } 6 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | © 2012-2022, Institute of Electronic Music and Acoustics 2 | © 2012, ivana 3 | © 2012-2022, IOhannes m zmölnig 4 | © 2016, Matthias Kronlachner 5 | -------------------------------------------------------------------------------- /libambix/tests/fail_if1.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | int main(int argc, char**argv) { 4 | return fail_if(1, __LINE__, "should %s fail", "indeed"); 5 | } 6 | -------------------------------------------------------------------------------- /libambix/tests/pass_if1.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | int main(int argc, char**argv) { 4 | return pass_if(1, __LINE__, "should %s pass", "indeed"); 5 | } 6 | -------------------------------------------------------------------------------- /libambix/tests/skip_if1.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | int main(int argc, char**argv) { 4 | return skip_if(1, __LINE__, "should %s skip", "indeed"); 5 | } 6 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | ACLOCAL_AMFLAGS = -I m4 3 | 4 | SUBDIRS=libambix \ 5 | replacement \ 6 | utils \ 7 | doc 8 | 9 | SUBDIRS+=samples 10 | 11 | SUBDIRS+=build 12 | -------------------------------------------------------------------------------- /libambix/tests/data/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | EXTRA_DIST = file1.caf.org 4 | noinst_DATA=$(EXTRA_DIST:%.org=%) 5 | 6 | % :: %.org 7 | cp $< $@ 8 | 9 | clean-local: 10 | rm -rf $(noinst_DATA) 11 | -------------------------------------------------------------------------------- /utils/jcommon/observe-signal.h: -------------------------------------------------------------------------------- 1 | #ifndef JCOMMON_OBSERVE_SIGNAL_H 2 | #define JCOMMON_OBSERVE_SIGNAL_H 3 | 4 | #include 5 | 6 | int observe_signals(void); 7 | bool observe_end_of_process(void); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /libambix/tests/basic_pcm32.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | void check_create_simple(const char*path, ambix_sampleformat_t format, float32_t eps); 3 | 4 | int main(int argc, char**argv) { 5 | check_create_simple(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 1e-5); 6 | return pass(); 7 | } 8 | -------------------------------------------------------------------------------- /libambix/tests/basic_float32.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | void check_create_simple(const char*path, ambix_sampleformat_t format, float32_t eps); 3 | 4 | int main(int argc, char**argv) { 5 | check_create_simple(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32, 1e-7); 6 | return pass(); 7 | } 8 | -------------------------------------------------------------------------------- /libambix/tests/basic_float64.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | void check_create_simple(const char*path, ambix_sampleformat_t format, float32_t eps); 3 | 4 | int main(int argc, char**argv) { 5 | check_create_simple(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64, 1e-7); 6 | return pass(); 7 | } 8 | -------------------------------------------------------------------------------- /libambix/tests/basic_pcm16.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | void check_create_simple(const char*path, ambix_sampleformat_t format, float32_t eps); 3 | 4 | int main(int argc, char**argv) { 5 | check_create_simple(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 1./20000.); 6 | return pass(); 7 | } 8 | -------------------------------------------------------------------------------- /libambix/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS=src 2 | 3 | #run tests at the end 4 | SUBDIRS+=tests 5 | 6 | EXTRA_DIST=libambix.pc.in 7 | 8 | pkgconfigdir = $(libdir)/pkgconfig 9 | pkgconfig_DATA = libambix.pc 10 | 11 | 12 | nobase_include_HEADERS = \ 13 | ambix/exportdefs.h \ 14 | ambix/ambix.h 15 | -------------------------------------------------------------------------------- /libambix/libambix.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: sndfile 7 | Description: A library for reading and writing AMBIsonics eXchange files 8 | Requires: 9 | Version: @VERSION@ 10 | Libs: -L${libdir} -lambix 11 | Libs.private: @SNDFILE_LIBS@ 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /samples/pd/ambix-meta.pd.in: -------------------------------------------------------------------------------- 1 | #N canvas 118 49 745 103 10; 2 | #N canvas 500 278 380 146 META 0; 3 | #X text 10 50 AUTHOR IOhannes m zmölnig; 4 | #X text 10 10 NAME ambix; 5 | #X text 10 30 VERSION @VERSION@; 6 | #X text 10 70 LICENSE LGPL-2.1; 7 | #X text 10 90 DESCRIPTION objects for reading/writing of AMBIsonics 8 | eXchange files; 9 | #X restore 313 37 pd META; 10 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST=libambix.doxy \ 2 | libambix.incl 3 | 4 | html_DATA= 5 | if HAVE_DOXYGEN 6 | html_DATA+=apiref/* 7 | endif 8 | 9 | DOXYFILE=$(srcdir)/libambix.doxy 10 | 11 | apiref/*: all-local 12 | 13 | all-local: 14 | $(DOXYGEN) $(DOXYFILE) 15 | 16 | clean-local: 17 | -rm -rf apiref 18 | 19 | uninstall-local: 20 | -rm -rf "$(DESTDIR)$(docdir)/apiref" 21 | -------------------------------------------------------------------------------- /libambix/tests/extended_float32_0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | #include 4 | 5 | 6 | void check_create_extended(const char*path, ambix_sampleformat_t format, uint32_t chunksize, float32_t eps); 7 | 8 | int main(int argc, char**argv) { 9 | check_create_extended(FILENAME_FILE,AMBIX_SAMPLEFORMAT_FLOAT32, 0, 1e-7); 10 | 11 | return pass(); 12 | } 13 | -------------------------------------------------------------------------------- /libambix/tests/extended_float64_0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | #include 4 | 5 | 6 | void check_create_extended(const char*path, ambix_sampleformat_t format, uint32_t chunksize, float32_t eps); 7 | 8 | int main(int argc, char**argv) { 9 | check_create_extended(FILENAME_FILE,AMBIX_SAMPLEFORMAT_FLOAT64, 0, 1e-7); 10 | 11 | return pass(); 12 | } 13 | -------------------------------------------------------------------------------- /libambix/tests/extended_pcm32_0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | #include 4 | 5 | 6 | void check_create_extended(const char*path, ambix_sampleformat_t format, uint32_t chunksize, float32_t eps); 7 | 8 | int main(int argc, char**argv) { 9 | check_create_extended(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 0, 1e-5); 10 | 11 | return pass(); 12 | } 13 | -------------------------------------------------------------------------------- /libambix/tests/extended_float32_1024.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | #include 4 | 5 | 6 | void check_create_extended(const char*path, ambix_sampleformat_t format, uint32_t chunksize, float32_t eps); 7 | 8 | int main(int argc, char**argv) { 9 | check_create_extended(FILENAME_FILE,AMBIX_SAMPLEFORMAT_FLOAT32, 1024, 1e-7); 10 | 11 | return pass(); 12 | } 13 | -------------------------------------------------------------------------------- /libambix/tests/extended_float64_1024.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | #include 4 | 5 | 6 | void check_create_extended(const char*path, ambix_sampleformat_t format, uint32_t chunksize, float32_t eps); 7 | 8 | int main(int argc, char**argv) { 9 | check_create_extended(FILENAME_FILE,AMBIX_SAMPLEFORMAT_FLOAT64, 1024, 1e-7); 10 | 11 | return pass(); 12 | } 13 | -------------------------------------------------------------------------------- /libambix/tests/extended_pcm16_0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | #include 4 | 5 | 6 | void check_create_extended(const char*path, ambix_sampleformat_t format, uint32_t chunksize, float32_t eps); 7 | 8 | int main(int argc, char**argv) { 9 | check_create_extended(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 1024, 1./20000.); 10 | 11 | return pass(); 12 | } 13 | -------------------------------------------------------------------------------- /libambix/tests/extended_pcm32_1024.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | #include 4 | 5 | 6 | void check_create_extended(const char*path, ambix_sampleformat_t format, uint32_t chunksize, float32_t eps); 7 | 8 | int main(int argc, char**argv) { 9 | check_create_extended(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 1024, 1e-5); 10 | 11 | return pass(); 12 | } 13 | -------------------------------------------------------------------------------- /libambix/tests/extended_pcm16_1024.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | #include 4 | 5 | 6 | void check_create_extended(const char*path, ambix_sampleformat_t format, uint32_t chunksize, float32_t eps); 7 | 8 | int main(int argc, char**argv) { 9 | check_create_extended(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 1024, 1./20000.); 10 | 11 | return pass(); 12 | } 13 | -------------------------------------------------------------------------------- /libambix/tests/ambix_close.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "data.h" 3 | 4 | int main() 5 | { 6 | 7 | ambix_t *ambix = NULL; 8 | ambix_info_t *info= calloc(1, sizeof(ambix_info_t)); 9 | ambix=ambix_open(AMBIXTEST_FILE1, AMBIX_READ, info); 10 | skip_if (NULL==ambix, __LINE__, "ambix_open(%s, AMBIX_READ, info)", AMBIXTEST_FILE1); 11 | 12 | fail_if (ambix_close(ambix)!=AMBIX_ERR_SUCCESS, __LINE__, "File was not closed properly"); 13 | 14 | free(info); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | FILE-FORMAT 2 | =========== 3 | ??? 4 | 5 | DEPENDENCIES 6 | ============ 7 | (optionally) getting rid of libsndfile 8 | - create our own minimal CAF-reader/writer 9 | - on OSX/iOS, use CoreAudio 10 | e.g. http://www.modejong.com/iOS/ExtAudioFileDemo.tar.bz2 11 | 12 | helper-library 13 | ============== 14 | library for matrix operations related to libambix 15 | - find a good name for it 16 | - analysis of existing matrices 17 | - (basic matrix operations and construction is now in libambix) 18 | 19 | -------------------------------------------------------------------------------- /utils/jcommon/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libjcommon.la 2 | 3 | libjcommon_la_CFLAGS = 4 | libjcommon_la_LIBADD = 5 | 6 | libjcommon_la_CFLAGS += \ 7 | @SAMPLERATE_CFLAGS@ @PTHREAD_CFLAGS@ \ 8 | @JACK_CFLAGS@ 9 | 10 | libjcommon_la_LIBADD += $(top_builddir)/libambix/src/libambix.la \ 11 | @SAMPLERATE_LIBS@ @PTHREAD_LIBS@ \ 12 | @JACK_LIBS@ 13 | 14 | libjcommon_la_SOURCES = \ 15 | common.c \ 16 | common.h \ 17 | jack-ringbuffer.c \ 18 | jack-ringbuffer.h \ 19 | observe-signal.c \ 20 | observe-signal.h 21 | -------------------------------------------------------------------------------- /libambix/tests/ambix_seek.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "data.h" 3 | 4 | int main() 5 | { 6 | int result=0; 7 | 8 | ambix_t *ambix = NULL; 9 | ambix_info_t *info= calloc(1, sizeof(ambix_info_t)); 10 | 11 | ambix=ambix_open(AMBIXTEST_FILE1, AMBIX_READ, info); 12 | skip_if(NULL==ambix, __LINE__, "ambix_open(%s, AMBIX_READ, info)", AMBIXTEST_FILE1); 13 | 14 | result= ambix_seek (ambix, 100, SEEK_CUR); 15 | fail_if (result!=100, __LINE__, "File failed to seek correct data"); 16 | 17 | ambix_close(ambix); 18 | 19 | free(info); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /utils/jcommon/jack-ringbuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef JCOMMON_JACK_RINGBUFFER_H 2 | #define JCOMMON_JACK_RINGBUFFER_H 3 | 4 | #include 5 | #include 6 | 7 | void jack_ringbuffer_print_debug(const jack_ringbuffer_t *r, const char *s); 8 | int jack_ringbuffer_wait_for_read(const jack_ringbuffer_t *r, int nbytes, int fd); 9 | int jack_ringbuffer_wait_for_write(jack_ringbuffer_t *r, int nbytes, int fd); 10 | void jack_ringbuffer_read_exactly(jack_ringbuffer_t *r, char *buf, int n); 11 | void jack_ringbuffer_write_exactly(jack_ringbuffer_t *r, const char *buf, int n); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /libambix/tests/runtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | APP=$1 4 | 5 | _TESTTYPE=$2 6 | TESTTYPE=${TESTTYPE:-$_TESTTYPE} 7 | 8 | ################################## 9 | 10 | VALGRIND="libtool --mode=execute valgrind --error-exitcode=1 -q" 11 | 12 | if which valgrind > /dev/null 13 | then 14 | MEMGRIND="${VALGRIND} --leak-check=full" 15 | DRDGRIND="${VALGRIND} --tool=drd" 16 | HELGRIND="${VALGRIND} --tool=helgrind" 17 | else 18 | MEMGRIND= 19 | DRDGRIND= 20 | HELGRIND= 21 | fi 22 | 23 | get_runtest() { 24 | case "$1" in 25 | mem*|MEM*) 26 | echo ${MEMGRIND} 27 | ;; 28 | DRD|drd) 29 | echo ${DRDGRIND} 30 | ;; 31 | HEL*|hel*) 32 | echo ${HELGRIND} 33 | ;; 34 | *) 35 | ;; 36 | esac 37 | } 38 | 39 | 40 | $(get_runtest $TESTTYPE) ${APP} 41 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_FUMA4x4_pcm16.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("FuMa[f]" , 5, 4, AMBIX_MATRIX_FUMA , 0, 1024, 4e-5); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_FUMA4x4_pcm32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("FuMa[f]" , 4, 4, AMBIX_MATRIX_FUMA , 0, 1024, 6e-8); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_N3D4x4_pcm16.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("N3D" , 4, 4, AMBIX_MATRIX_N3D , 0, 1024, 4e-5); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_N3D4x4_pcm32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("N3D" , 4, 4, AMBIX_MATRIX_N3D , 0, 1024, 3e-8); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_SID4x4_float32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("SID" , 4, 4, AMBIX_MATRIX_SID , 0, 1024, 0); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_SID4x4_float64.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("SID" , 4, 4, AMBIX_MATRIX_SID , 0, 1024, 0); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_SID4x4_pcm16.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("SID" , 4, 4, AMBIX_MATRIX_SID , 0, 1024, 4e-5); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_SID4x4_pcm32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("SID" , 4, 4, AMBIX_MATRIX_SID , 0, 1024, 1e-9); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_FUMA4x4_float32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("FuMa[f]" , 4, 4, AMBIX_MATRIX_FUMA , 0, 1024, 6e-8); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_FUMA4x4_float64.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("FuMa[f]" , 4, 4, AMBIX_MATRIX_FUMA , 0, 1024, 6e-8); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_N3D4x4_float32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("N3D" , 4, 4, AMBIX_MATRIX_N3D , 0, 1024, 3e-8); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_N3D4x4_float64.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("N3D" , 4, 4, AMBIX_MATRIX_N3D , 0, 1024, 3e-8); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_identity4x4_float64.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("IDENTITY", 4, 4, AMBIX_MATRIX_IDENTITY, 0, 1024, 0); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_identity4x4_pcm16.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("IDENTITY", 4, 4, AMBIX_MATRIX_IDENTITY, 0, 1024, 4e-5); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_identity4x4_pcm32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("IDENTITY", 4, 4, AMBIX_MATRIX_IDENTITY, 0, 1024, 1e-9); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_FUMA4x4_3extra_pcm16.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("FuMa[f]" , 4, 4, AMBIX_MATRIX_FUMA , 3, 1024, 4e-5); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_FUMA4x4_3extra_pcm32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("FuMa[f]" , 4, 4, AMBIX_MATRIX_FUMA , 3, 1024, 6e-8); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_N3D4x4_3extra_float32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("N3D" , 4, 4, AMBIX_MATRIX_N3D , 3, 1024, 3e-8); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_N3D4x4_3extra_float64.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("N3D" , 4, 4, AMBIX_MATRIX_N3D , 3, 1024, 3e-8); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_N3D4x4_3extra_pcm16.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("N3D" , 4, 4, AMBIX_MATRIX_N3D , 3, 1024, 4e-5); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_N3D4x4_3extra_pcm32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("N3D" , 4, 4, AMBIX_MATRIX_N3D , 3, 1024, 3e-8); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_SID4x4_3extra_float32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("SID" , 4, 4, AMBIX_MATRIX_SID , 3, 1024, 0); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_SID4x4_3extra_float64.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("SID" , 4, 4, AMBIX_MATRIX_SID , 3, 1024, 0); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_SID4x4_3extra_pcm16.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("SID" , 4, 4, AMBIX_MATRIX_SID , 3, 1024, 4e-5); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_SID4x4_3extra_pcm32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("SID" , 4, 4, AMBIX_MATRIX_SID , 3, 1024, 1e-9); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_FUMA4x4_3extra_float32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("FuMa[f]" , 4, 4, AMBIX_MATRIX_FUMA , 3, 1024, 6e-8); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_FUMA4x4_3extra_float64.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("FuMa[f]" , 4, 4, AMBIX_MATRIX_FUMA , 3, 1024, 6e-8); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_identity4x4_3extra_float32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("IDENTITY", 4, 4, AMBIX_MATRIX_IDENTITY, 3, 1024, 0); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_identity4x4_3extra_float64.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("IDENTITY", 4, 4, AMBIX_MATRIX_IDENTITY, 3, 1024, 0); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_identity4x4_3extra_pcm16.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("IDENTITY", 4, 4, AMBIX_MATRIX_IDENTITY, 3, 1024, 4e-5); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_identity4x4_3extra_pcm32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 4 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 5 | int result=0; 6 | ambix_matrix_t*mtx=0; 7 | STARTTEST("%s\n", name); 8 | mtx=ambix_matrix_init(rows,cols,mtx); 9 | if(!mtx)return 1; 10 | ambix_matrix_fill(mtx, mtyp); 11 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 12 | mtx,xtrachannels, 13 | chunksize, FLOAT32, eps); 14 | ambix_matrix_destroy(mtx); 15 | return result; 16 | } 17 | 18 | int main(int argc, char**argv) { 19 | int err=0; 20 | err+=test_defaultmatrix("IDENTITY", 4, 4, AMBIX_MATRIX_IDENTITY, 3, 1024, 1e-9); 21 | return pass(); 22 | } 23 | -------------------------------------------------------------------------------- /coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## this assumes that libambix has been compiled with gcov support (--coverage) 4 | 5 | INFOFILE="libambix.info" 6 | OUTDIR=coverage/ 7 | 8 | MAKE=make 9 | 10 | # Generate html report 11 | 12 | lcov --base-directory . --directory . --zerocounters -q || exit 1 13 | ${MAKE} check || exit 1 14 | lcov --base-directory libambix/src --directory libambix/src -c -o ${INFOFILE} || exit 1 15 | lcov --base-directory libambix/tests --directory libambix/tests -c -o tests_${INFOFILE} || exit 1 16 | 17 | # remove output for external libraries 18 | lcov --remove ${INFOFILE} "/usr*" -o ${INFOFILE} || exit 1 19 | lcov --remove tests_${INFOFILE} "/usr*" -o tests_${INFOFILE} || exit 1 20 | 21 | rm -rf "${OUTDIR}" 22 | genhtml -o "${OUTDIR}" -t "libambix test coverage" --num-spaces 4 ${INFOFILE} tests_${INFOFILE} 23 | -------------------------------------------------------------------------------- /libambix/tests/ambix_get_sndfile.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "data.h" 3 | 4 | int main() 5 | { 6 | ambix_t*ambix = NULL; 7 | struct SNDFILE_tag *sndfile = NULL; 8 | ambix_info_t *info= calloc(1, sizeof(ambix_info_t)); 9 | 10 | ambix=ambix_open(AMBIXTEST_FILE1, AMBIX_READ, info); 11 | 12 | fail_if(NULL==ambix, __LINE__, "File was not open"); 13 | sndfile = ambix_get_sndfile (ambix); 14 | 15 | #ifdef HAVE_SNDFILE 16 | #warning LATER: skip, once we have multiple (working) backends 17 | /* there is no need to use libsndfile even if libsndfile is present */ 18 | fail_if(NULL==sndfile, __LINE__, "no sndfile handle despite using libsndfile"); 19 | #else 20 | fail_if(NULL!=sndfile, __LINE__, "got sndfile handle without libsndfile!"); 21 | #endif 22 | 23 | ambix_close (ambix); 24 | free(info); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /libambix/tests/debug_utils.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "data.h" 3 | 4 | /* libambix's private header */ 5 | #include "private.h" 6 | 7 | int main(int argc, char**argv) { 8 | ambix_info_t*info=NULL; 9 | ambix_matrix_t*mtx=NULL; 10 | ambix_t*ambix=NULL; 11 | _ambix_print_info(info); 12 | _ambix_print_matrix(mtx); 13 | _ambix_print_ambix(ambix); 14 | 15 | info= calloc(1, sizeof(ambix_info_t)); 16 | ambix=ambix_open(AMBIXTEST_FILE1, AMBIX_READ, info); 17 | fail_if(NULL==ambix, __LINE__, "File was not open"); 18 | 19 | _ambix_print_info(info); 20 | _ambix_print_ambix(ambix); 21 | 22 | ambix_close(ambix); 23 | free(info); 24 | 25 | mtx=ambix_matrix_init(4, 5, mtx); 26 | _ambix_print_matrix(mtx); 27 | mtx=ambix_matrix_fill(mtx, AMBIX_MATRIX_ONE); 28 | _ambix_print_matrix(mtx); 29 | ambix_matrix_destroy(mtx); 30 | 31 | return pass(); 32 | } 33 | -------------------------------------------------------------------------------- /libambix/tests/ambix_writef_int16.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "data.h" 3 | 4 | int main () 5 | { 6 | ambix_t *ambix = NULL; 7 | ambix_info_t *info= calloc(1, sizeof(ambix_info_t)); 8 | int16_t *ambidata= 0; 9 | int16_t *otherdata=0; 10 | int16_t frames= 10; 11 | 12 | 13 | ambix=ambix_open(AMBIXTEST_FILE1, AMBIX_READ, info); 14 | int16_t result=0; 15 | 16 | /* ambix_writef_int16 (ambix_t *ambix, const int16_t *ambidata, const int16_t *otherdata, int64_t frames) 17 | Write (16bit signed integer) samples to the ambix file. 18 | Returns: 19 | the number of sample frames successfully written 20 | */ 21 | 22 | // UNCOMMENT WHEN FIXED 23 | /*result=ambix_writef_int16 (ambix,ambidata,otherdata,frames); 24 | fail_if (frames!=result, __LINE__, "Files were not written successfully"); 25 | */ 26 | 27 | ambix_close(ambix); 28 | free(info); 29 | 30 | /* FIXXME: no test yet */ 31 | return skip(); 32 | } 33 | -------------------------------------------------------------------------------- /m4/iem_relativerpath.m4: -------------------------------------------------------------------------------- 1 | dnl Copyright (C) 2011 IOhannes m zmölnig 2 | dnl This file is free software; IOhannes m zmölnig 3 | dnl gives unlimited permission to copy and/or distribute it, 4 | dnl with or without modifications, as long as this notice is preserved. 5 | 6 | ## useage: add the @RELATIVERPATH_FLAGS@ to the LDFLAGS of your external 7 | 8 | ## TODO: add other platforms 9 | ## on OSX we have to add "-install_name @loader_path/$NAME" when linking the _library_ 10 | ## on W32 this should no be needed at all (but is it?) 11 | 12 | AC_DEFUN([IEM_RELATIVERPATH], 13 | [ 14 | originrpath_org_CFLAGS=$CFLAGS 15 | IEM_CHECK_CFLAGS([-Wl,-enable-new-dtags -Wl,-rpath,"\$ORIGIN"], 16 | [have_originrpath="yes"], [have_originrpath="no"]) 17 | CFLAGS=$originrpath_org_CFLAGS 18 | RELATIVERPATH_FLAGS="" 19 | if test "x$have_originrpath" = "xyes"; then 20 | RELATIVERPATH_FLAGS="-Wl,-enable-new-dtags -Wl,-rpath,\"\\\$\$ORIGIN\"" 21 | fi 22 | 23 | 24 | AC_SUBST([RELATIVERPATH_FLAGS]) 25 | ])# IEM_RELATIVERPATH 26 | -------------------------------------------------------------------------------- /libambix/tests/ambix_open.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "data.h" 3 | 4 | int main() 5 | { 6 | ambix_t*ambix = NULL; 7 | 8 | ambix_info_t *info= calloc(1, sizeof(ambix_info_t)); 9 | 10 | ambix=ambix_open(AMBIXTEST_FILE1, AMBIX_READ, info); 11 | 12 | fail_if(NULL==ambix, __LINE__, "File was not open"); 13 | 14 | fail_if (info->frames != 44100, __LINE__, "Frames are not correct"); 15 | fail_if (info->samplerate != 44100, __LINE__, "Samplerate is not correct"); 16 | fail_if (info->sampleformat != AMBIX_SAMPLEFORMAT_FLOAT32, __LINE__, "Sampleformat is not correct"); 17 | fail_if (info->fileformat != AMBIX_BASIC, __LINE__, "Fileformat is not correct"); 18 | fail_if (info->ambichannels != 9, __LINE__, "Ambichannels are not correct"); 19 | fail_if (info->extrachannels != 0, __LINE__, "Non-ambichannels are not correct"); 20 | fail_if (NULL!=ambix_get_adaptormatrix(ambix), __LINE__, "Error, there is reconstruction matrix"); 21 | 22 | ambix_close (ambix); 23 | free(info); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /libambix/tests/ambix_seek_read.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "data.h" 3 | 4 | int main() 5 | { 6 | 7 | ambix_t *ambix = NULL; 8 | ambix_info_t *info= calloc(1, sizeof(ambix_info_t)); 9 | int32_t ambidata[100]; 10 | int32_t *otherdata= 0; 11 | 12 | int result=0; 13 | int cmp=0; 14 | 15 | ambix=ambix_open(AMBIXTEST_FILE1, AMBIX_READ, info); 16 | //ambix_readf_int32 (ambix_t *ambix, int32_t *ambidata, int32_t *otherdata, int64_t frames) 17 | //Read samples (as 32bit signed integer values) from the ambix file. 18 | 19 | 20 | //UNCOMMENT WHEN FIXED 21 | /*cmp= ambix_readf_int32(ambix, *ambidata, otherdata, 100); 22 | printf("rezultat readf-a je %d\n", cmp); 23 | result= ambix_seek (ambix, 100, SEEK_CUR); 24 | 25 | if (cmp!=result) 26 | { 27 | printf ("Greska u potrazi\n"); 28 | } 29 | else 30 | fail_if (result!=100, __LINE__, "File failed to seek correct data");*/ 31 | 32 | ambix_close(ambix); 33 | free(info); 34 | 35 | /* FIXXXME: this test is not working yet */ 36 | return skip(); 37 | } 38 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | libambix (0.1.2+nmu1) UNRELEASED; urgency=medium 2 | 3 | * Fixed build failure with libsndfile>=1.1 4 | 5 | * Fixed internal type misuse 6 | 7 | -- IOhannes m zmölnig (Debian/GNU) Thu, 29 Sep 2022 12:44:20 +0200 8 | 9 | libambix (0.1.1) unstable; urgency=medium 10 | 11 | * Fixed coverity-scan issues 12 | CID: 153342,153344,153345,153346,153347 13 | 14 | * Adjusted test-suite tresholds 15 | To cater for different precisions on various CPU-types 16 | 17 | -- IOhannes m zmölnig Sun, 16 Oct 2016 23:21:51 +0200 18 | 19 | libambix (0.1) unstable; urgency=medium 20 | 21 | * Support for float64 22 | 23 | * Support for markers in CAF-files 24 | 25 | * Stable matrix inversion 26 | 27 | * Many bug fixes,... 28 | 29 | * travis-ci, coverity & codecov integration 30 | 31 | -- IOhannes m zmölnig Sun, 5 Oct 2016 22:50:17 +0200 32 | 33 | libambix (0.0.1) unstable; urgency=medium 34 | 35 | * Initial release. 36 | 37 | -- IOhannes m zmölnig Sun, 14 Apr 2014 12:21:57 +0200 38 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_identity4x4_float32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | #ifndef FMT 4 | # define FMT FLOAT32 5 | #endif 6 | #ifndef EPS 7 | # define EPS 0 8 | #endif 9 | 10 | int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps, ambixtest_presentationformat_t fmt) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill(mtx, mtyp); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32, 19 | mtx,xtrachannels, 20 | chunksize, fmt, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_defaultmatrix("IDENTITY1024:" STRINGIFY(FMT), 4, 4, AMBIX_MATRIX_IDENTITY, 0, 1024, EPS, FMT); 28 | err+=test_defaultmatrix("IDENTITY0000:" STRINGIFY(FMT), 4, 4, AMBIX_MATRIX_IDENTITY, 0, 0, EPS, FMT); 29 | return pass(); 30 | } 31 | -------------------------------------------------------------------------------- /libambix/tests/pass.c: -------------------------------------------------------------------------------- 1 | /* pass - simple test that always passes 2 | 3 | Copyright © 2012 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | #include "common.h" 25 | 26 | int main(int argc, char**argv) { 27 | 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x7_pcm16.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_7[]={ 4 | 0.588219, 0.758465, 0.240167, 0.827193, 0.899134, 0.121186, 0.974490, 5 | 0.079994, 0.828276, 0.223099, 0.525774, 0.895537, 0.884317, 0.434495, 6 | 0.426266, 0.302895, 0.341656, 0.325299, 0.474342, 0.677271, 0.185883, 7 | 0.183465, 0.654321, 0.243639, 0.779875, 0.250082, 0.939078, 0.449736, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x7]", 4, 7, data_4_7 , 0, 1024, 8e-5); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x7_pcm32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_7[]={ 4 | 0.588219, 0.758465, 0.240167, 0.827193, 0.899134, 0.121186, 0.974490, 5 | 0.079994, 0.828276, 0.223099, 0.525774, 0.895537, 0.884317, 0.434495, 6 | 0.426266, 0.302895, 0.341656, 0.325299, 0.474342, 0.677271, 0.185883, 7 | 0.183465, 0.654321, 0.243639, 0.779875, 0.250082, 0.939078, 0.449736, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x7]", 4, 7, data_4_7 , 0, 1024, 5e-7); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x7_3extra_pcm16.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_7[]={ 4 | 0.588219, 0.758465, 0.240167, 0.827193, 0.899134, 0.121186, 0.974490, 5 | 0.079994, 0.828276, 0.223099, 0.525774, 0.895537, 0.884317, 0.434495, 6 | 0.426266, 0.302895, 0.341656, 0.325299, 0.474342, 0.677271, 0.185883, 7 | 0.183465, 0.654321, 0.243639, 0.779875, 0.250082, 0.939078, 0.449736, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[5x7]", 4, 7, data_4_7 , 3, 1024, 8e-5); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x7_3extra_pcm32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_7[]={ 4 | 0.588219, 0.758465, 0.240167, 0.827193, 0.899134, 0.121186, 0.974490, 5 | 0.079994, 0.828276, 0.223099, 0.525774, 0.895537, 0.884317, 0.434495, 6 | 0.426266, 0.302895, 0.341656, 0.325299, 0.474342, 0.677271, 0.185883, 7 | 0.183465, 0.654321, 0.243639, 0.779875, 0.250082, 0.939078, 0.449736, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x7]", 4, 7, data_4_7 , 3, 1024, 5e-7); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x7_float32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_7[]={ 4 | 0.588219, 0.758465, 0.240167, 0.827193, 0.899134, 0.121186, 0.974490, 5 | 0.079994, 0.828276, 0.223099, 0.525774, 0.895537, 0.884317, 0.434495, 6 | 0.426266, 0.302895, 0.341656, 0.325299, 0.474342, 0.677271, 0.185883, 7 | 0.183465, 0.654321, 0.243639, 0.779875, 0.250082, 0.939078, 0.449736, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x7]", 4, 7, data_4_7 , 0, 1024, 5e-7); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x7_float64.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_7[]={ 4 | 0.588219, 0.758465, 0.240167, 0.827193, 0.899134, 0.121186, 0.974490, 5 | 0.079994, 0.828276, 0.223099, 0.525774, 0.895537, 0.884317, 0.434495, 6 | 0.426266, 0.302895, 0.341656, 0.325299, 0.474342, 0.677271, 0.185883, 7 | 0.183465, 0.654321, 0.243639, 0.779875, 0.250082, 0.939078, 0.449736, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x7]", 4, 7, data_4_7 , 0, 1024, 5e-7); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x7_3extra_float32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_7[]={ 4 | 0.588219, 0.758465, 0.240167, 0.827193, 0.899134, 0.121186, 0.974490, 5 | 0.079994, 0.828276, 0.223099, 0.525774, 0.895537, 0.884317, 0.434495, 6 | 0.426266, 0.302895, 0.341656, 0.325299, 0.474342, 0.677271, 0.185883, 7 | 0.183465, 0.654321, 0.243639, 0.779875, 0.250082, 0.939078, 0.449736, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x7]", 4, 7, data_4_7 , 3, 1024, 5e-7); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x7_3extra_float64.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_7[]={ 4 | 0.588219, 0.758465, 0.240167, 0.827193, 0.899134, 0.121186, 0.974490, 5 | 0.079994, 0.828276, 0.223099, 0.525774, 0.895537, 0.884317, 0.434495, 6 | 0.426266, 0.302895, 0.341656, 0.325299, 0.474342, 0.677271, 0.185883, 7 | 0.183465, 0.654321, 0.243639, 0.779875, 0.250082, 0.939078, 0.449736, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x7]", 4, 7, data_4_7 , 3, 1024, 5e-7); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x9_pcm16.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_9[]={ 4 | 0.519497, 0.101224, 0.775246, 0.219242, 0.795973, 0.649863, 0.190978, 0.837028, 0.763130, 5 | 0.165074, 0.276581, 0.220167, 0.383229, 0.937749, 0.381838, 0.025107, 0.846256, 0.773257, 6 | 0.546205, 0.501742, 0.476078, 0.539815, 0.671716, 0.069030, 0.748010, 0.369414, 0.667491, 7 | 0.192167, 0.936164, 0.792496, 0.447073, 0.689901, 0.618242, 0.769460, 0.815128, 0.466140, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x9]", 4, 9, data_4_9 , 0, 1024, 9e-5); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x9_pcm32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_9[]={ 4 | 0.519497, 0.101224, 0.775246, 0.219242, 0.795973, 0.649863, 0.190978, 0.837028, 0.763130, 5 | 0.165074, 0.276581, 0.220167, 0.383229, 0.937749, 0.381838, 0.025107, 0.846256, 0.773257, 6 | 0.546205, 0.501742, 0.476078, 0.539815, 0.671716, 0.069030, 0.748010, 0.369414, 0.667491, 7 | 0.192167, 0.936164, 0.792496, 0.447073, 0.689901, 0.618242, 0.769460, 0.815128, 0.466140, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x9]", 4, 9, data_4_9 , 0, 1024, 5e-7); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x9_float32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_9[]={ 4 | 0.519497, 0.101224, 0.775246, 0.219242, 0.795973, 0.649863, 0.190978, 0.837028, 0.763130, 5 | 0.165074, 0.276581, 0.220167, 0.383229, 0.937749, 0.381838, 0.025107, 0.846256, 0.773257, 6 | 0.546205, 0.501742, 0.476078, 0.539815, 0.671716, 0.069030, 0.748010, 0.369414, 0.667491, 7 | 0.192167, 0.936164, 0.792496, 0.447073, 0.689901, 0.618242, 0.769460, 0.815128, 0.466140, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x9]", 4, 9, data_4_9 , 0, 1024, 5e-7); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x9_float64.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_9[]={ 4 | 0.519497, 0.101224, 0.775246, 0.219242, 0.795973, 0.649863, 0.190978, 0.837028, 0.763130, 5 | 0.165074, 0.276581, 0.220167, 0.383229, 0.937749, 0.381838, 0.025107, 0.846256, 0.773257, 6 | 0.546205, 0.501742, 0.476078, 0.539815, 0.671716, 0.069030, 0.748010, 0.369414, 0.667491, 7 | 0.192167, 0.936164, 0.792496, 0.447073, 0.689901, 0.618242, 0.769460, 0.815128, 0.466140, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x9]", 4, 9, data_4_9 , 0, 1024, 5e-7); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /m4/iem_operatingsystem.m4: -------------------------------------------------------------------------------- 1 | dnl try to figure out the target operating system and set some AM-macros accordingly 2 | dnl 3 | dnl Copyright (C) 2011 IOhannes m zmölnig 4 | 5 | 6 | AC_DEFUN([IEM_OPERATING_SYSTEM], 7 | [ 8 | AC_CANONICAL_HOST 9 | 10 | LINUX=no 11 | ANDROID=no 12 | MACOSX=no 13 | IPHONEOS=no 14 | BSD=no 15 | WINDOWS=no 16 | MINGW=no 17 | CYGWIN=no 18 | HURD=no 19 | IRIX=no 20 | 21 | case $host_os in 22 | *linux*) 23 | LINUX=yes 24 | ;; 25 | *darwin*) 26 | MACOSX=yes 27 | ;; 28 | GNU/kFreeBSD) 29 | BSD=yes 30 | ;; 31 | *mingw*) 32 | WINDOWS=yes 33 | MINGW=yes 34 | ;; 35 | *cygwin*) 36 | WINDOWS=yes 37 | CYGWIN=yes 38 | ;; 39 | GNU) 40 | HURD=yes 41 | ;; 42 | esac 43 | 44 | 45 | AM_CONDITIONAL(LINUX, test x$LINUX = xyes) 46 | AM_CONDITIONAL(ANDROID, test x$ANDROID = xyes) 47 | AM_CONDITIONAL(MACOSX, test x$MACOSX = xyes) 48 | AM_CONDITIONAL(IPHONEOS, test x$IPHONEOS = xyes) 49 | AM_CONDITIONAL(BSD, test x$BSD = xyes) 50 | AM_CONDITIONAL(WINDOWS, test x$WINDOWS = xyes) 51 | AM_CONDITIONAL(CYGWIN, test x$MINGW = xyes) 52 | AM_CONDITIONAL(MINGW, test x$MINGW = xyes) 53 | AM_CONDITIONAL(HURD, test x$HURD = xyes) 54 | AM_CONDITIONAL(IRIX, test x$IRIX = xyes) 55 | ]) dnl IEM_OPERATING_SYSTEM 56 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x9_3extra_pcm16.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_9[]={ 4 | 0.519497, 0.101224, 0.775246, 0.219242, 0.795973, 0.649863, 0.190978, 0.837028, 0.763130, 5 | 0.165074, 0.276581, 0.220167, 0.383229, 0.937749, 0.381838, 0.025107, 0.846256, 0.773257, 6 | 0.546205, 0.501742, 0.476078, 0.539815, 0.671716, 0.069030, 0.748010, 0.369414, 0.667491, 7 | 0.192167, 0.936164, 0.792496, 0.447073, 0.689901, 0.618242, 0.769460, 0.815128, 0.466140, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x9]", 4, 9, data_4_9 , 3, 1024, 9e-5); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x9_3extra_pcm32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_9[]={ 4 | 0.519497, 0.101224, 0.775246, 0.219242, 0.795973, 0.649863, 0.190978, 0.837028, 0.763130, 5 | 0.165074, 0.276581, 0.220167, 0.383229, 0.937749, 0.381838, 0.025107, 0.846256, 0.773257, 6 | 0.546205, 0.501742, 0.476078, 0.539815, 0.671716, 0.069030, 0.748010, 0.369414, 0.667491, 7 | 0.192167, 0.936164, 0.792496, 0.447073, 0.689901, 0.618242, 0.769460, 0.815128, 0.466140, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM32, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x9]", 4, 9, data_4_9 , 3, 1024, 5e-7); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x9_3extra_float32.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_9[]={ 4 | 0.519497, 0.101224, 0.775246, 0.219242, 0.795973, 0.649863, 0.190978, 0.837028, 0.763130, 5 | 0.165074, 0.276581, 0.220167, 0.383229, 0.937749, 0.381838, 0.025107, 0.846256, 0.773257, 6 | 0.546205, 0.501742, 0.476078, 0.539815, 0.671716, 0.069030, 0.748010, 0.369414, 0.667491, 7 | 0.192167, 0.936164, 0.792496, 0.447073, 0.689901, 0.618242, 0.769460, 0.815128, 0.466140, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x9]", 4, 9, data_4_9 , 3, 1024, 5e-7); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/basic2extended_rand4x9_3extra_float64.c: -------------------------------------------------------------------------------- 1 | #include "common_basic2extended.h" 2 | 3 | float32_t data_4_9[]={ 4 | 0.519497, 0.101224, 0.775246, 0.219242, 0.795973, 0.649863, 0.190978, 0.837028, 0.763130, 5 | 0.165074, 0.276581, 0.220167, 0.383229, 0.937749, 0.381838, 0.025107, 0.846256, 0.773257, 6 | 0.546205, 0.501742, 0.476078, 0.539815, 0.671716, 0.069030, 0.748010, 0.369414, 0.667491, 7 | 0.192167, 0.936164, 0.792496, 0.447073, 0.689901, 0.618242, 0.769460, 0.815128, 0.466140, 8 | }; 9 | 10 | int test_datamatrix(const char*name, uint32_t rows, uint32_t cols, float32_t*data, 11 | uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { 12 | int result=0; 13 | ambix_matrix_t*mtx=0; 14 | STARTTEST("%s\n", name); 15 | mtx=ambix_matrix_init(rows,cols,mtx); 16 | if(!mtx)return 1; 17 | ambix_matrix_fill_data(mtx, data); 18 | result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64, 19 | mtx,xtrachannels, 20 | chunksize, FLOAT32, eps); 21 | ambix_matrix_destroy(mtx); 22 | return result; 23 | } 24 | 25 | int main(int argc, char**argv) { 26 | int err=0; 27 | err+=test_datamatrix ("'rand'[4x9]", 4, 9, data_4_9 , 3, 1024, 5e-7); 28 | return pass(); 29 | } 30 | -------------------------------------------------------------------------------- /libambix/tests/data.h: -------------------------------------------------------------------------------- 1 | /* tests/data.h - AMBIsonics eXchange Library test data -*- c -*- 2 | 3 | Copyright © 2012 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | #ifndef TESTS_DATA_H 25 | #define TESTS_DATA_H 26 | 27 | /* file1.caf 28 | * AMBIX_BASIC, 3rd order (9 channels) 29 | * 44100 samples, all zero 30 | */ 31 | #define AMBIXTEST_FILE1 "data/file1.caf" 32 | 33 | #endif /* TESTS_DATA_H */ 34 | -------------------------------------------------------------------------------- /samples/pd/winhacks.c: -------------------------------------------------------------------------------- 1 | /* winhacks.h - AMBIsonics eXchange hacks for w32 compilation -*- c -*- 2 | 3 | Copyright © 2012 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | Copyright © 2005 Free Software Foundation, Inc. 8 | Written by Kaveh R. Ghazi . 9 | 10 | This file is part of libambix 11 | 12 | libambix is free software; you can redistribute it and/or modify 13 | it under the terms of the GNU Lesser General Public License as 14 | published by the Free Software Foundation; either version 2.1 of 15 | the License, or (at your option) any later version. 16 | 17 | libambix is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this program; if not, see . 24 | 25 | */ 26 | 27 | #ifdef __MINGW32__ 28 | int _get_output_format( void ) { 29 | return 1; 30 | } 31 | #endif /* __MINGW32__ */ 32 | 33 | -------------------------------------------------------------------------------- /libambix/tests/none_float32.c: -------------------------------------------------------------------------------- 1 | /* none_float32 - test ambix none (FLOAT32) 2 | 3 | Copyright © 2012 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | #include "common.h" 25 | #include 26 | #include 27 | 28 | 29 | void check_create_none(const char*path, ambix_sampleformat_t format); 30 | 31 | int main(int argc, char**argv) { 32 | check_create_none(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT32); 33 | 34 | return pass(); 35 | } 36 | -------------------------------------------------------------------------------- /libambix/tests/data/foo.pd: -------------------------------------------------------------------------------- 1 | #N canvas 4 49 450 543 10; 2 | #X obj 183 105 soundfiler; 3 | #N canvas 8 49 450 300 tables 0; 4 | #X obj 100 100 table a0; 5 | #X obj 100 120 table a1; 6 | #X obj 100 140 table a2; 7 | #X obj 100 160 table a3; 8 | #X obj 100 180 table a4; 9 | #X obj 100 200 table a5; 10 | #X obj 100 220 table a6; 11 | #X obj 100 240 table a7; 12 | #X obj 100 260 table a8; 13 | #X restore 315 171 pd tables; 14 | #X msg 153 203 9; 15 | #X obj 153 247 until; 16 | #X obj 153 269 i; 17 | #X obj 153 291 + 1; 18 | #X msg 209 254 -1; 19 | #X obj 153 357 + 100; 20 | #X obj 153 379 pack; 21 | #X obj 153 423 s pd-tables; 22 | #X msg 220 367 clear; 23 | #X obj 152 225 t f b b; 24 | #X msg 153 401 obj 100 \$1 table a\$2; 25 | #X obj 153 313 t f f f; 26 | #X obj 153 335 * 20; 27 | #X msg 186 64 read -resize foo.wav a0 a1 a2 a3 a4 a5 a6 a7 a8; 28 | #X floatatom 183 127 5 0 0 0 - - -; 29 | #X connect 0 0 16 0; 30 | #X connect 2 0 11 0; 31 | #X connect 3 0 4 0; 32 | #X connect 4 0 5 0; 33 | #X connect 5 0 13 0; 34 | #X connect 6 0 4 1; 35 | #X connect 7 0 8 0; 36 | #X connect 8 0 12 0; 37 | #X connect 10 0 9 0; 38 | #X connect 11 0 3 0; 39 | #X connect 11 1 6 0; 40 | #X connect 11 2 10 0; 41 | #X connect 12 0 9 0; 42 | #X connect 13 0 14 0; 43 | #X connect 13 1 8 1; 44 | #X connect 13 2 4 1; 45 | #X connect 14 0 7 0; 46 | #X connect 15 0 0 0; 47 | -------------------------------------------------------------------------------- /libambix/tests/none_float64.c: -------------------------------------------------------------------------------- 1 | /* none_float32 - test ambix none (FLOAT64) 2 | 3 | Copyright © 2012-2016 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | #include "common.h" 25 | #include 26 | #include 27 | 28 | 29 | void check_create_none(const char*path, ambix_sampleformat_t format); 30 | 31 | int main(int argc, char**argv) { 32 | check_create_none(FILENAME_FILE, AMBIX_SAMPLEFORMAT_FLOAT64); 33 | 34 | return pass(); 35 | } 36 | -------------------------------------------------------------------------------- /samples/pd/winhacks.h: -------------------------------------------------------------------------------- 1 | /* winhacks.h - AMBIsonics eXchange hacks for w32 compilation -*- c -*- 2 | 3 | Copyright © 2012 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | #ifndef WINHACKS_H 25 | #define WINHACKS_H 26 | 27 | #ifdef __MINGW32__ 28 | int _get_output_format( void ); 29 | #endif /* mingw */ 30 | 31 | #include "replacement/strndup.h" 32 | 33 | #ifdef _MSC_VER 34 | # define snprintf _snprintf 35 | #endif /* MSVC */ 36 | 37 | #endif /* WINHACKS_H */ 38 | -------------------------------------------------------------------------------- /m4/iem_check_framework.m4: -------------------------------------------------------------------------------- 1 | dnl Copyright (C) 2005-2012 IOhannes m zmölnig 2 | dnl This file is free software; IOhannes m zmölnig 3 | dnl gives unlimited permission to copy and/or distribute it, 4 | dnl with or without modifications, as long as this notice is preserved. 5 | 6 | # IEM_CHECK_FRAMEWORK(FRAMEWORK, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) 7 | # 8 | # 9 | AC_DEFUN([IEM_CHECK_FRAMEWORK], 10 | [ 11 | define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], 12 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) 13 | AC_SUBST(IEM_FRAMEWORK_[]NAME[]) 14 | 15 | AC_MSG_CHECKING([for "$1"-framework]) 16 | 17 | iem_check_ldflags_org="${LDFLAGS}" 18 | LDFLAGS="-framework [$1] ${LDFLAGS}" 19 | 20 | AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [iem_check_ldflags_success="yes"],[iem_check_ldflags_success="no"]) 21 | 22 | if test "x$iem_check_ldflags_success" = "xyes"; then 23 | AC_MSG_RESULT([yes]) 24 | AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1), [1], [framework $1]) 25 | AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_IEM_FRAMEWORK_$1), [1], [framework $1]) 26 | IEM_FRAMEWORK_[]NAME[]="-framework [$1]" 27 | [$2] 28 | else 29 | AC_MSG_RESULT([no]) 30 | LDFLAGS="$iem_check_ldflags_org" 31 | [$3] 32 | fi 33 | AM_CONDITIONAL(HAVE_FRAMEWORK_[]NAME, [test "x$iem_check_ldflags_success" = "xyes"]) 34 | undefine([NAME]) 35 | ])# IEM_CHECK_FRAMEWORK 36 | -------------------------------------------------------------------------------- /libambix/tests/common_basic2extended.h: -------------------------------------------------------------------------------- 1 | /* tests/common_basic2extended.h - AMBIsonics eXchange Library test utilities -*- c -*- 2 | 3 | Copyright © 2012 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | #ifndef TESTS_COMMON_BASIC2EXTENDED_H 25 | #define TESTS_COMMON_BASIC2EXTENDED_H 26 | 27 | #include "common.h" 28 | 29 | /* specific helper-functions */ 30 | int check_create_b2e(const char*path, ambix_sampleformat_t format, 31 | ambix_matrix_t*matrix, uint32_t extrachannels, 32 | uint32_t chunksize, ambixtest_presentationformat_t fmt,float32_t eps); 33 | 34 | 35 | 36 | #endif /* TESTS_COMMON_BASIC2EXTENDED_H */ 37 | 38 | -------------------------------------------------------------------------------- /utils/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = 2 | 3 | bin_PROGRAMS = \ 4 | ambix-info 5 | 6 | noinst_PROGRAMS = \ 7 | ambix-dump \ 8 | ambix-matrix \ 9 | ambix-test 10 | 11 | if HAVE_SNDFILE 12 | bin_PROGRAMS += \ 13 | ambix-interleave \ 14 | ambix-deinterleave 15 | if HAVE_JACK 16 | SUBDIRS += jcommon 17 | bin_PROGRAMS += \ 18 | ambix-jplay \ 19 | ambix-jrecord 20 | endif HAVE_JACK 21 | endif HAVE_SNDFILE 22 | 23 | AM_CPPFLAGS = -I$(top_srcdir)/libambix -I$(top_srcdir) 24 | LDADD = $(top_builddir)/libambix/src/libambix.la 25 | 26 | ambix_info_SOURCES = ambix-info.c 27 | 28 | ambix_interleave_SOURCES = ambix-interleave.c 29 | ambix_interleave_CFLAGS = @SNDFILE_CFLAGS@ 30 | ambix_interleave_LDADD = $(top_builddir)/libambix/src/libambix.la @SNDFILE_LIBS@ 31 | 32 | ambix_deinterleave_SOURCES = ambix-deinterleave.c 33 | ambix_deinterleave_CFLAGS = @SNDFILE_CFLAGS@ 34 | ambix_deinterleave_LDADD = $(top_builddir)/libambix/src/libambix.la @SNDFILE_LIBS@ 35 | 36 | ambix_test_SOURCES = ambix-test.c 37 | 38 | ambix_dump_SOURCES = ambix-dump.c 39 | 40 | ambix_matrix_SOURCES = ambix-matrix.c 41 | 42 | 43 | ambix_jplay_CFLAGS = @JACK_CFLAGS@ @SAMPLERATE_CFLAGS@ @PTHREAD_CFLAGS@ 44 | ambix_jplay_LDADD = $(top_builddir)/libambix/src/libambix.la \ 45 | $(builddir)/jcommon/libjcommon.la \ 46 | @JACK_LIBS@ @SAMPLERATE_LIBS@ @PTHREAD_LIBS@ 47 | ambix_jplay_SOURCES = ambix-jplay.c 48 | 49 | ambix_jrecord_CFLAGS = @JACK_CFLAGS@ @SAMPLERATE_CFLAGS@ @PTHREAD_CFLAGS@ @SNDFILE_CFLAGS@ 50 | ambix_jrecord_LDADD = $(top_builddir)/libambix/src/libambix.la \ 51 | $(builddir)/jcommon/libjcommon.la \ 52 | @JACK_LIBS@ @SAMPLERATE_LIBS@ @PTHREAD_LIBS@ @SNDFILE_LIBS@ 53 | ambix_jrecord_SOURCES = ambix-jrecord.c 54 | -------------------------------------------------------------------------------- /libambix/src/adaptor_acn.c: -------------------------------------------------------------------------------- 1 | /* adapator_acn.c - adaptors to/from ACN channel ordering -*- c -*- 2 | 3 | Copyright © 2012 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | #include "private.h" 25 | 26 | int _matrix_sid2acn(float32_t*data, uint32_t count) { 27 | float32_t*datap=data; 28 | int32_t order=ambix_channels2order(count); 29 | int32_t o; 30 | if(order<0)return 0; 31 | 32 | for(o=0; o<=order; o++) { 33 | uint32_t offset=o>0?ambix_order2channels(o-1):0; 34 | int32_t maxindex=ambix_order2channels(o)-offset; 35 | 36 | int32_t index; 37 | 38 | for(index=1; index=0; index-=2) { 42 | *datap++=(float32_t)(index+offset); 43 | } 44 | } 45 | return 1; 46 | } 47 | -------------------------------------------------------------------------------- /replacement/strndup.h: -------------------------------------------------------------------------------- 1 | /* strndup.h - AMBIsonics eXchange strndup() replacement implementation -*- c -*- 2 | 3 | Copyright © 2012 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | Copyright © 2005 Free Software Foundation, Inc. 8 | Written by Kaveh R. Ghazi . 9 | 10 | This file is part of libambix 11 | 12 | libambix is free software; you can redistribute it and/or modify 13 | it under the terms of the GNU Lesser General Public License as 14 | published by the Free Software Foundation; either version 2.1 of 15 | the License, or (at your option) any later version. 16 | 17 | libambix is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU Lesser General Public License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this program; if not, see . 24 | 25 | */ 26 | 27 | #ifdef HAVE_CONFIG_H 28 | # include "config.h" 29 | #endif 30 | 31 | #ifndef HAVE_STRNDUP 32 | # include 33 | # include 34 | 35 | static char * 36 | strndup (const char *s, size_t n) 37 | { 38 | char *result = NULL; 39 | size_t len = strlen (s); 40 | 41 | if (n < len) 42 | len = n; 43 | 44 | result = (char *) malloc (len + 1); 45 | if (!result) 46 | return 0; 47 | 48 | result[len] = '\0'; 49 | return (char *) memcpy (result, s, len); 50 | } 51 | 52 | #endif /* HAVE_STRNDUP */ 53 | -------------------------------------------------------------------------------- /utils/jcommon/jack-ringbuffer.c: -------------------------------------------------------------------------------- 1 | /* jack-ringbuffer.c - (c) rohan drape, 2005-2006 */ 2 | 3 | #ifdef HAVE_CONFIG_H 4 | # include "config.h" 5 | #endif 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "jack-ringbuffer.h" 16 | #include "common.h" 17 | 18 | void jack_ringbuffer_print_debug(const jack_ringbuffer_t *r, const char *s) 19 | { 20 | eprintf("%s: read_ptr=%d,write_ptr=%d,size=%d,size_mask=%d\n", 21 | s, (int)r->read_ptr, (int)r->write_ptr, 22 | (int)r->size, (int)r->size_mask); 23 | } 24 | 25 | int jack_ringbuffer_wait_for_read(const jack_ringbuffer_t *r, 26 | int nbytes, int fd) 27 | { 28 | int space = (int) jack_ringbuffer_read_space(r); 29 | while(space < nbytes) { 30 | char b; 31 | if(read(fd, &b, 1)== -1) { 32 | eprintf("%s: error reading communication pipe\n", __func__); 33 | FAILURE; 34 | } 35 | space = (int) jack_ringbuffer_read_space(r); 36 | } 37 | return space; 38 | } 39 | 40 | int jack_ringbuffer_wait_for_write(jack_ringbuffer_t *r, int nbytes, int fd) 41 | { 42 | int space = (int)jack_ringbuffer_write_space(r); 43 | while(space < nbytes) { 44 | char b; 45 | if(read(fd, &b, 1)== -1) { 46 | fprintf (stderr, "%s: error reading communication pipe\n", __func__); 47 | FAILURE; 48 | } 49 | space = (int) jack_ringbuffer_write_space(r); 50 | } 51 | return space; 52 | } 53 | 54 | void jack_ringbuffer_read_exactly(jack_ringbuffer_t *r, char *buf, int n) 55 | { 56 | int err = jack_ringbuffer_read(r, buf, n); 57 | if(err != n) { 58 | eprintf("%s: error reading ring buffer (%d != %d)\n", 59 | __func__, err, n); 60 | FAILURE; 61 | } 62 | } 63 | 64 | void jack_ringbuffer_write_exactly(jack_ringbuffer_t *r, const char *buf, int n) 65 | { 66 | int err = jack_ringbuffer_write(r, buf, n); 67 | if(err != n) { 68 | eprintf("%s: error writing ring buffer (%d != %d)\n", __func__, err, n); 69 | FAILURE; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /.deploy-documentation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | WD=$(pwd) 4 | INPUTDIR="${WD}/doc/apiref" 5 | INPUT2DIR="${WD}/coverage" 6 | OUTPUTDIR="${WD}/gh-pages" 7 | REMOTE=https://github.com/iem-projects/ambix 8 | 9 | error() { 10 | echo "$@" 1>&2 11 | } 12 | 13 | if [ -e "${INPUTDIR}/index.html" ]; then 14 | : 15 | else 16 | error "missing {INPUTDIR}/index.html" 17 | exit 0 18 | fi 19 | if [ "x${REMOTE}" = "x" ]; then 20 | error "no remote" 21 | exit 0 22 | fi 23 | COMMIT=$(git describe --always) 24 | 25 | commit_msg() { 26 | echo "Deploy code docs to GitHub Pages" 27 | echo "" 28 | if [ "x${COMMIT}" != x ]; then 29 | echo "Commit: ${COMMIT}" 30 | fi 31 | if [ "x${TRAVIS_BUILD_NUMBER}" != "x" ]; then 32 | echo "Travis build: ${TRAVIS_BUILD_NUMBER}" 33 | fi 34 | if [ "x${TRAVIS_COMMIT}" != "x" ]; then 35 | echo "Travis commit: ${TRAVIS_COMMIT}" 36 | fi 37 | } 38 | 39 | git clone -b gh-pages "${REMOTE}" "${OUTPUTDIR}" 40 | cd "${OUTPUTDIR}" || exit 1 41 | 42 | ##### Configure git. 43 | # Set the push default to simple i.e. push only the current branch. 44 | git config push.default simple 45 | # Pretend to be an user called Travis CI. 46 | git config user.name "Travis CI" 47 | git config user.email "travis@travis-ci.org" 48 | 49 | ## clean gh-pages 50 | rm -rf "${INPUTDIR##*/}" 51 | 52 | ## copy the doxygen documentation 53 | cp -rav "${INPUTDIR}" "${INPUTDIR##*/}" 54 | 55 | ## add and commit to git 56 | git add --all "${INPUTDIR##*/}" 57 | 58 | ## add coverage info (if it is there) 59 | if [ -d "${INPUT2DIR}" ]; then 60 | error "adding coverage info ${INPUT2DIR##*/}" 61 | rm -rf "${INPUT2DIR##*/}" 62 | cp -rav "${INPUT2DIR}" "${INPUT2DIR##*/}" 63 | git add --all "${INPUT2DIR##*/}" 64 | fi 65 | 66 | error "committing to git" 67 | commit_msg | git commit -F - . 68 | 69 | 70 | # and push 71 | error "pushing to git" 72 | if [ "x${GH_REPO_TOKEN}" != "x" ]; then 73 | GH_REPO_REF=${REMOTE#*@} 74 | GH_REPO_REF=${GH_REPO_REF#*//} 75 | git push --force "https://${GH_REPO_TOKEN}@${GH_REPO_REF}" > /dev/null 76 | else 77 | git push --force > /dev/null 78 | fi 79 | 80 | rm -rf "${OUTPUTDIR}" 81 | -------------------------------------------------------------------------------- /utils/README.txt: -------------------------------------------------------------------------------- 1 | ambix-utils: collection of utilities to deal with ambix files 2 | 3 | 4 | ambix-info: 5 | get info about an ambix file 6 | 7 | ambix-interleave -o [-O ] [-X ] [ ...] 8 | merge several (multi-channel) audio files into a single ambix file; 9 | infile1 becomes W-channel, infile2 becomes X-channel,... 10 | by default this will write an 'ambix simple' file (only full sets are accepted) 11 | eventually files are written as 'ambix extended' file with adaptor matrix set to unity 12 | if 'order' is specified, all inchannels not needed for the full set are written as 'extrachannels' 13 | 'matrixfile' is a soundfile/octavefile that is interpreted as matrix: each channel is a row, sampleframes are columns 14 | if 'matrix' is specified it must construct a full-set (it must satisfy rows=(O+1)^2) 15 | if 'matrix' is specified, all inchannels not needed to reconstruct to a full set are 'extrachannels' 16 | if both 'order' and 'matrix' are specified they must match 17 | 18 | ambix-deinterleave 19 | split an ambix file into ambi/non-ambi data 20 | split an ambi file into separate channels (decoded) 21 | if the 'infile' is called 'data.caf', 22 | the output files are called 'data_ambisonics_00.caf' and 'data_extra_00.caf', 23 | where the number for ambisonics channels is the ACN (ambisonics channel number (starting from 0)) 24 | and the numbers for extra channels start at 0 25 | 26 | ambix-jplay 27 | playback an ambix file via jack 28 | jack channels are called "ambisonics_%02d" and "extra_%02d" 29 | reduced sets are always expanded to full sets 30 | Disclaimer: this is a port of jack.play from jack-tools 31 | Copyright (c) 2003-2010, Rohan Drape 32 | Copyright (c) 2012, IOhannes m zmölnig, IEM 33 | Licensed under the GPL-2 (or later) 34 | 35 | ambix-jrec [-O ] [-X ] [-x <#extrachannels>] 36 | record an ambix file via jack (for options see ambix-interleave) 37 | Disclaimer: this is a port of jack.rec from jack-tools 38 | Copyright (c) 2003-2010, Rohan Drape 39 | Copyright (c) 2012, IOhannes m zmölnig, IEM 40 | Licensed under the GPL-2 (or later) 41 | 42 | -------------------------------------------------------------------------------- /utils/jcommon/common.h: -------------------------------------------------------------------------------- 1 | /* jcommon/common.h - common helper functions for jack-utils -*- c -*- 2 | 3 | Copyright © 2003-2001 Rohan Drape 4 | Copyright © 2012 IOhannes m zmölnig . 5 | Institute of Electronic Music and Acoustics (IEM), 6 | University of Music and Dramatic Arts, Graz 7 | 8 | This file is based on Rohan Drape's "jack-tools" collection 9 | 10 | you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as 12 | published by the Free Software Foundation; either version 2 of 13 | the License, or (at your option) any later version. 14 | 15 | ambix-jplay is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU Lesser General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public 21 | License along with this program; if not, see . 22 | */ 23 | 24 | #ifndef JCOMMON_COMMON_H 25 | #define JCOMMON_COMMON_H 26 | 27 | #ifdef HAVE_SYS_TYPES_H 28 | # include 29 | #endif /* HAVE_SYS_TYPES_H */ 30 | 31 | #include 32 | 33 | 34 | #ifndef FAILURE 35 | #define FAILURE exit(1) 36 | #endif 37 | 38 | #define eprintf(...) fprintf(stderr,__VA_ARGS__) 39 | 40 | void *xmalloc(size_t size); 41 | int xpipe(int filedes[2]); 42 | ssize_t xwrite(int filedes, const void *buffer, size_t size); 43 | ssize_t xread(int filedes, void *buffer, size_t size); 44 | 45 | 46 | 47 | 48 | 49 | void jack_client_minimal_error_handler(const char *desc); 50 | void jack_client_minimal_shutdown_handler(void *arg); 51 | int jack_transport_is_rolling(jack_client_t *client); 52 | jack_client_t *jack_client_unique_(const char*name); /* this simply create a unique client-name, withbout telling us... */ 53 | jack_client_t *jack_client_unique(char*name); /* this will change 'name' to the actual result */ 54 | 55 | jack_port_t*_jack_port_register(jack_client_t *client, int direction, const char*format, int n); 56 | 57 | #endif /* JCOMMON_COMMON_H */ 58 | -------------------------------------------------------------------------------- /samples/pd/ambix_info-help.pd: -------------------------------------------------------------------------------- 1 | #N canvas 171 231 707 524 10; 2 | #X obj 103 91 ambix_info; 3 | #X obj 103 141 print info; 4 | #X msg 103 70 open \$1; 5 | #X obj 103 28 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 6 | -1; 7 | #X obj 103 111 t a a; 8 | #X obj 103 49 openpanel; 9 | #X obj 371 261 t a; 10 | #X symbolatom 236 156 0 0 0 3 fileformat - -; 11 | #X symbolatom 321 156 0 0 0 3 sampleformat - -; 12 | #X floatatom 236 291 0 0 0 3 ambichannels - -; 13 | #X floatatom 313 291 0 0 0 3 extrachannels - -; 14 | #X obj 425 321 t a; 15 | #X obj 236 336 route matrix; 16 | #N canvas 4 49 450 300 matrix 0; 17 | #X obj 71 43 inlet; 18 | #X obj 71 63 list prepend matrix; 19 | #X obj 71 83 list trim; 20 | #X obj 71 133 t a; 21 | #X text 100 132 ready for use with [iemmatrix]; 22 | #X connect 0 0 1 0; 23 | #X connect 1 0 2 0; 24 | #X connect 2 0 3 0; 25 | #X restore 236 368 pd matrix; 26 | #X obj 305 370 print ???; 27 | #X obj 236 196 route frames samplerate; 28 | #X obj 407 181 t a a; 29 | #X obj 420 196 route frames samplerate; 30 | #X obj 420 216 /; 31 | #X floatatom 313 211 0 0 0 3 samplerate - -; 32 | #X floatatom 236 211 0 0 0 3 frames - -; 33 | #X floatatom 420 231 0 0 0 3 duration[sec] - -; 34 | #X obj 236 126 route fileformat sampleformat; 35 | #X obj 236 276 route ambichannels extrachannels; 36 | #X obj 236 141 symbol; 37 | #X obj 321 141 symbol; 38 | #X text 266 12 [ambix_info]; 39 | #X text 266 30 get information about an AMBIsonics eXchange file; 40 | #X obj 145 477 ambix_read~; 41 | #X obj 235 477 ambix_readX~; 42 | #X obj 330 477 ambix_info; 43 | #X text 48 477 see also:; 44 | #X connect 0 0 4 0; 45 | #X connect 2 0 0 0; 46 | #X connect 3 0 5 0; 47 | #X connect 4 0 1 0; 48 | #X connect 4 1 22 0; 49 | #X connect 5 0 2 0; 50 | #X connect 6 0 23 0; 51 | #X connect 11 0 12 0; 52 | #X connect 12 0 13 0; 53 | #X connect 12 1 14 0; 54 | #X connect 15 0 20 0; 55 | #X connect 15 1 19 0; 56 | #X connect 15 2 6 0; 57 | #X connect 16 0 15 0; 58 | #X connect 16 1 17 0; 59 | #X connect 17 0 18 0; 60 | #X connect 17 1 18 1; 61 | #X connect 18 0 21 0; 62 | #X connect 22 0 24 0; 63 | #X connect 22 1 25 0; 64 | #X connect 22 2 16 0; 65 | #X connect 23 0 9 0; 66 | #X connect 23 1 10 0; 67 | #X connect 23 2 11 0; 68 | #X connect 24 0 7 0; 69 | #X connect 25 0 8 0; 70 | -------------------------------------------------------------------------------- /utils/jcommon/observe-signal.c: -------------------------------------------------------------------------------- 1 | /* observe-signal.c - (c) rohan drape, 2005-2006 */ 2 | 3 | #define _XOPEN_SOURCE 600 /* To use SA_RESTART and SA_RESETHAND */ 4 | 5 | #ifdef HAVE_CONFIG_H 6 | # include "config.h" 7 | #endif 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include "observe-signal.h" 18 | 19 | volatile unsigned int signal_received = 0; 20 | 21 | static void signal_management_handler(int s) 22 | { 23 | signal_received |= 1 << s; 24 | } 25 | 26 | static void *signal_management_thread(void *PTR) 27 | { 28 | pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0); 29 | sigset_t blocked; 30 | sigprocmask(SIG_SETMASK, 0, &blocked); 31 | int s; 32 | sigwait(&blocked, &s); 33 | if(s != SIGSEGV) { 34 | sigprocmask(SIG_UNBLOCK, &blocked, 0); 35 | } 36 | signal_management_handler(s); 37 | return NULL; 38 | } 39 | 40 | int observe_signals(void) 41 | { 42 | sigset_t signals; 43 | signal_received = 0; 44 | sigemptyset(&signals); 45 | sigaddset(&signals, SIGHUP); 46 | sigaddset(&signals, SIGINT); 47 | sigaddset(&signals, SIGQUIT); 48 | sigaddset(&signals, SIGPIPE); 49 | sigaddset(&signals, SIGTERM); 50 | struct sigaction action; 51 | action.sa_handler = signal_management_handler; 52 | action.sa_mask = signals; 53 | action.sa_flags = SA_RESTART | SA_RESETHAND; 54 | int i; 55 | for(i = 1; i < 32; i++) { 56 | if(sigismember(&signals, i)) { 57 | if(sigaction(i, &action, 0)) { 58 | fprintf(stderr, "sigaction() failed: %d\n", i); 59 | return -1; 60 | } 61 | } 62 | } 63 | if(pthread_sigmask(SIG_SETMASK, &signals, 0)) { 64 | fprintf(stderr, "pthread_sigmask() failed: %s\n", strerror(errno)); 65 | return -1; 66 | } 67 | pthread_t signal_thread_id; 68 | if(pthread_create(&signal_thread_id, 0, signal_management_thread, 0)) { 69 | fprintf(stderr, "pthread_create() failed\n"); 70 | return -1; 71 | } 72 | pthread_detach(signal_thread_id); 73 | return 0; 74 | } 75 | 76 | bool observe_end_of_process(void) 77 | { 78 | return(signal_received & 1< is given in samples per channels (unlike 6 | [readsf~] where you specify it in bytes per channel); 7 | #X text 43 475 see also:; 8 | #X text 311 412 arguments: <#ambioutlet~s:4> <#extraoutlet~s:0> 9 | ; 10 | #X text 207 18 [ambix_write~] write an AMBIsonics eXchange file; 11 | #X msg 111 186 start; 12 | #X msg 111 215 stop; 13 | #X obj 166 308 osc~ 440; 14 | #X obj 145 477 ambix_read~; 15 | #X obj 235 477 ambix_readX~; 16 | #X obj 145 499 writesf~; 17 | #X text 233 308 ACN0; 18 | #X text 243 328 ACN1; 19 | #X obj 188 349 osc~ 220; 20 | #X text 253 348 ACN2; 21 | #X text 263 368 ACN3; 22 | #X obj 178 329 osc~ 110; 23 | #X obj 198 369 osc~ 330; 24 | #X obj 184 396 noise~; 25 | #X obj 74 418 ambix_write~ 4 1; 26 | #X text 240 396 extra0; 27 | #X text 216 47 The [ambix_write~] writes audio signals into an ambix 28 | soundfile \, much like [writesf~] for normal soundfiles.; 29 | #X text 217 78 [ambix_write~] creates a subthread whose task is to 30 | write audio streams to disk. You need not provide any disk access time 31 | between "open" and "start" \, but between "stop" and the next "open" 32 | you must give the object time to flush all the output to disk.; 33 | #X text 217 204 You can also write EXTENDED ambix files \, by specifying 34 | an adaptor-matrix _before_ sending the "open" message.; 35 | #X msg 113 252 matrix 4 4 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1; 36 | #X msg 116 273 matrix; 37 | #X text 167 273 specify NONE-matrix (switch to BASIC mode); 38 | #X text 434 257 (switches to EXTENDED mode); 39 | #X text 416 246 specify [4x4] identity matrix; 40 | #X text 214 149 When writing BASIC ambix files (the default \, if no 41 | extra channels are requested) \, the ambisonics channels will always 42 | be periphonic (3D) semi-normalized (SN3D) and ordered after their ACN. 43 | ; 44 | #X obj 330 477 ambix_info; 45 | #X msg 74 161 open -bytes 3 \$1; 46 | #X connect 1 0 2 0; 47 | #X connect 2 0 33 0; 48 | #X connect 7 0 21 0; 49 | #X connect 8 0 21 0; 50 | #X connect 9 0 21 0; 51 | #X connect 15 0 21 2; 52 | #X connect 18 0 21 1; 53 | #X connect 19 0 21 3; 54 | #X connect 20 0 21 4; 55 | #X connect 26 0 21 0; 56 | #X connect 27 0 21 0; 57 | #X connect 33 0 21 0; 58 | -------------------------------------------------------------------------------- /libambix/src/null.c: -------------------------------------------------------------------------------- 1 | /* null.c - dummy backend support -*- c -*- 2 | 3 | Copyright © 2012 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | */ 22 | 23 | #include "private.h" 24 | 25 | ambix_err_t _ambix_open (ambix_t*ambix, const char *path, const ambix_filemode_t mode, const ambix_info_t*ambixinfo) { 26 | return AMBIX_ERR_INVALID_FILE; 27 | } 28 | 29 | ambix_err_t _ambix_close (ambix_t*ambix) { 30 | return AMBIX_ERR_INVALID_FILE; 31 | } 32 | 33 | SNDFILE*_ambix_get_sndfile (ambix_t*ambix) { 34 | return 0; 35 | } 36 | 37 | int64_t _ambix_readf_int16 (ambix_t*ambix, int16_t*data, int64_t frames) { 38 | return -1; 39 | } 40 | int64_t _ambix_readf_int32 (ambix_t*ambix, int32_t*data, int64_t frames) { 41 | return -1; 42 | } 43 | int64_t _ambix_readf_float32 (ambix_t*ambix, float32_t*data, int64_t frames) { 44 | return -1; 45 | } 46 | int64_t _ambix_readf_float64 (ambix_t*ambix, float64_t*data, int64_t frames) { 47 | return -1; 48 | } 49 | 50 | int64_t _ambix_writef_int16 (ambix_t*ambix, const int16_t*data, int64_t frames) { 51 | return -1; 52 | } 53 | int64_t _ambix_writef_int32 (ambix_t*ambix, const int32_t*data, int64_t frames) { 54 | return -1; 55 | } 56 | int64_t _ambix_writef_float32 (ambix_t*ambix, const float32_t*data, int64_t frames) { 57 | return -1; 58 | } 59 | int64_t _ambix_writef_float64 (ambix_t*ambix, const float64_t*data, int64_t frames) { 60 | return -1; 61 | } 62 | ambix_err_t _ambix_write_uuidchunk(ambix_t*ax, const void*data, int64_t datasize) { 63 | return AMBIX_ERR_UNKNOWN; 64 | } 65 | int64_t _ambix_seek (ambix_t* ambix, int64_t frames, int whence) { 66 | return -1; 67 | } 68 | -------------------------------------------------------------------------------- /utils/jcommon/common.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | # include "config.h" 3 | #endif 4 | #include "common.h" 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | void *xmalloc(size_t size) 12 | { 13 | void *p = malloc(size); 14 | if(p == NULL) { 15 | fprintf(stderr, "malloc() failed: %ld\n", (long)size); 16 | FAILURE; 17 | } 18 | return p; 19 | } 20 | 21 | int xpipe(int filedes[2]) 22 | { 23 | int err = pipe(filedes); 24 | if(err) { 25 | perror("pipe() failed"); 26 | FAILURE; 27 | } 28 | return err; 29 | } 30 | 31 | ssize_t xwrite(int filedes, const void *buffer, size_t size) 32 | { 33 | ssize_t err = write(filedes, buffer, size); 34 | if(err == -1) { 35 | perror("write() failed"); 36 | FAILURE; 37 | } 38 | return err; 39 | } 40 | 41 | ssize_t xread(int filedes, void *buffer, size_t size) 42 | { 43 | ssize_t err = read(filedes, buffer, size); 44 | if(err == -1) { 45 | perror("read() failed"); 46 | FAILURE; 47 | } 48 | return err; 49 | } 50 | 51 | 52 | void jack_client_minimal_error_handler(const char *desc) 53 | { 54 | eprintf("jack error: %s\n", desc); 55 | } 56 | 57 | void jack_client_minimal_shutdown_handler(void *arg) 58 | { 59 | eprintf("jack shutdown\n"); 60 | FAILURE; 61 | } 62 | 63 | int jack_transport_is_rolling(jack_client_t *client) 64 | { 65 | jack_transport_state_t s = jack_transport_query(client , NULL); 66 | return s & JackTransportRolling; 67 | } 68 | 69 | jack_client_t *jack_client_unique(char *name) 70 | { 71 | int n = (int)getpid(); 72 | char uniq[64]; 73 | snprintf(uniq, 64, "%s-%d", name, n); 74 | strncpy(name,uniq,64); 75 | jack_client_t *client = jack_client_open(uniq,JackNullOption,NULL); 76 | if(! client) { 77 | eprintf("jack_client_open() failed: %s\n", uniq); 78 | FAILURE; 79 | } 80 | return client; 81 | } 82 | jack_client_t *jack_client_unique_(const char *name) 83 | { 84 | char uniq[64]; 85 | snprintf(uniq, 64, "%s", name); 86 | return jack_client_unique(uniq); 87 | } 88 | 89 | 90 | jack_port_t*_jack_port_register(jack_client_t *client, int direction, const char*format, int n) { 91 | char name[64]; 92 | jack_port_t*port; 93 | snprintf(name, 64, format, n); 94 | port = jack_port_register(client, name, JACK_DEFAULT_AUDIO_TYPE, direction, 0); 95 | if(!port) { 96 | eprintf("jack_port_register() failed at %s\n", name); 97 | FAILURE; 98 | } 99 | return port; 100 | } 101 | -------------------------------------------------------------------------------- /samples/pd/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | rteambixdir = @rtedir@/ambix 4 | 5 | rteambix_LTLIBRARIES= 6 | dist_rteambix_DATA= 7 | 8 | AM_CFLAGS = 9 | AM_LDFLAGS= -module -avoid-version -shared -shrext .@RTE_EXTENSION@ 10 | 11 | if WINDOWS 12 | AM_LDFLAGS+= -no-undefined 13 | endif 14 | 15 | AM_CPPFLAGS = -I$(top_srcdir)/libambix -I$(top_srcdir) 16 | 17 | # RTE 18 | AM_CFLAGS += @RTE_CFLAGS@ 19 | AM_LDFLAGS+= @RTE_LIBS@ 20 | AM_LDFLAGS+=$(top_builddir)/libambix/src/libambix.la 21 | 22 | ambix_read__la_CFLAGS = $(AM_CFLAGS) @PTHREAD_CFLAGS@ 23 | ambix_read__la_LDFLAGS = $(AM_LDFLAGS) @PTHREAD_LIBS@ 24 | 25 | ambix_readX__la_CFLAGS = $(AM_CFLAGS) @PTHREAD_CFLAGS@ 26 | ambix_readX__la_LDFLAGS = $(AM_LDFLAGS) @PTHREAD_LIBS@ 27 | 28 | ambix_write__la_CFLAGS = $(AM_CFLAGS) @PTHREAD_CFLAGS@ 29 | ambix_write__la_LDFLAGS = $(AM_LDFLAGS) @PTHREAD_LIBS@ 30 | 31 | rteambix_LTLIBRARIES+= \ 32 | ambix_info.la \ 33 | ambix_read~.la \ 34 | ambix_readX~.la \ 35 | ambix_write~.la 36 | 37 | dist_rteambix_DATA+= \ 38 | ambix_read~-help.pd \ 39 | ambix_readX~-help.pd \ 40 | ambix_write~-help.pd \ 41 | ambix_info-help.pd \ 42 | ambix-meta.pd 43 | 44 | 45 | ambix_info_la_SOURCES = ambix_info.c 46 | ambix_read__la_SOURCES = ambix_read~.c 47 | ambix_readX__la_SOURCES = ambix_read~.c 48 | ambix_write__la_SOURCES = ambix_write~.c 49 | 50 | noinst_HEADERS = winhacks.h 51 | 52 | if WINDOWS 53 | ambix_info_la_SOURCES += winhacks.c 54 | ambix_read__la_SOURCES += winhacks.c 55 | ambix_readX__la_SOURCES += winhacks.c 56 | ambix_write__la_SOURCES += winhacks.c 57 | endif WINDOWS 58 | 59 | 60 | # convenience symlinks 61 | .PHONY: convenience-link clean-convenience-link 62 | 63 | convenience-link: $(rteambix_LTLIBRARIES) 64 | @for lib in $^; do \ 65 | for soname in `echo | $(EGREP) "^dlname=" $$lib | $(SED) -e "s|^dlname='\(.*\)'|\1|"`; do \ 66 | echo "$$soname: creating convenience link from $(abs_builddir)/.libs to $(builddir)"; \ 67 | rm -f $$soname ; \ 68 | test -e $(abs_builddir)/.libs/$$soname && \ 69 | $(LN_S) $(abs_builddir)/.libs/$$soname $$soname || true; \ 70 | done; \ 71 | done 72 | 73 | clean-convenience-link: 74 | @for lib in $(rteambix_LTLIBRARIES); do \ 75 | for soname in `echo | $(EGREP) "^dlname=" $$lib | $(SED) -e "s|^dlname='\(.*\)'|\1|"`; do \ 76 | echo "$$soname: cleaning convenience links"; \ 77 | test -L $$soname && rm -f $$soname || true; \ 78 | done; done 79 | 80 | all-local:: convenience-link 81 | 82 | clean-local:: clean-convenience-link 83 | 84 | -------------------------------------------------------------------------------- /libambix/ambix/exportdefs.h: -------------------------------------------------------------------------------- 1 | /* ambix/exportdefs.h - defines for dll import/export -*- c -*- 2 | 3 | Copyright © 2012 IOhannes m zmölnig 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | /** 25 | * @file ambix/exportdefs.h 26 | * @brief export definitions for various compilers 27 | * @details This file is part of libambix 28 | * @author IOhannes m zmölnig 29 | * @date 2012 30 | * @copyright LGPL-2.1 31 | */ 32 | 33 | #ifndef AMBIX_EXPORTDEFS_H 34 | #define AMBIX_EXPORTDEFS_H 35 | 36 | #if defined _MSC_VER 37 | /* MSVC always uses dllimport/dllexport */ 38 | # define DLL_EXPORT 39 | #endif /* _MSC_VER */ 40 | 41 | #ifdef DLL_EXPORT 42 | /* Windows requires explicit import and exporting of functions and classes. 43 | * While this is a pain to do sometimes, in large software development 44 | * projects, it is very useful. 45 | */ 46 | # define AMBIX_EXPORT __declspec(dllexport) 47 | # define AMBIX_IMPORT __declspec(dllimport) 48 | 49 | # define AMBIX_DEPRECATED __declspec(deprecated) 50 | 51 | #elif defined __GNUC__ 52 | # define AMBIX_EXPORT __attribute__ ((visibility("default"))) 53 | # define AMBIX_IMPORT 54 | 55 | # define AMBIX_DEPRECATED __attribute__ ((deprecated)) 56 | 57 | #else 58 | /* unknown compiler */ 59 | # warning set up compiler specific defines 60 | 61 | /** mark symbols to be exported from libambix */ 62 | # define AMBIX_EXPORT 63 | /** mark symbols to be imported from libambix */ 64 | # define AMBIX_IMPORT 65 | /** mark symbols to be deprecated */ 66 | # define AMBIX_DEPRECATED 67 | #endif 68 | 69 | #ifdef AMBIX_INTERNAL 70 | /** mark symbols to be useable outside the library */ 71 | # define AMBIX_API AMBIX_EXPORT 72 | #else 73 | /** mark symbols to be useable outside the library */ 74 | # define AMBIX_API AMBIX_IMPORT 75 | #endif 76 | 77 | #endif /* AMBIX_EXPORTDEFS_H */ 78 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | sudo: required 3 | dist: trusty 4 | 5 | env: 6 | global: 7 | - secure: "nAc3WvwtJBm+hLIYxp4srwgM7qDWRovkEpsza+UITEE8TUqeZND2543xMZlWz1w5qn8V/F/1yX1oYl7Ot0ymmu9Uh41b1NBr3cvo2U8RLDSM9SBoqtyS1pSCnJ2qiSk+hg5GxObWug/ph3TkEgZaDmYCDAgHiv1I9WXVRxeR144=" 8 | - COVERITY_SCAN_BRANCH_PATTERN="(master|coverity-.*)" 9 | - COVERITY_SCAN_NOTIFICATION_EMAIL="dev@umlaeute.mur.at" 10 | - COVERITY_SCAN_BUILD_COMMAND="make" 11 | - COVERITY_SCAN_PROJECT_NAME="$TRAVIS_REPO_SLUG" 12 | - LIBSNDFILE_URL="http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.27.tar.gz" 13 | - LD_LIBRARY_PATH=/usr/local/lib 14 | 15 | os: 16 | - linux 17 | - osx 18 | compiler: 19 | - clang 20 | - gcc 21 | 22 | addons: 23 | apt: 24 | packages: 25 | - libvorbis-dev 26 | - libflac-dev 27 | - libasound2-dev 28 | - doxygen 29 | - lcov 30 | - ca-certificates 31 | 32 | matrix: 33 | include: 34 | - compiler: gcc 35 | env: 36 | - DO_EXTRA="coverage" 37 | - CFLAGS="-g -O0 --coverage" 38 | - CXXFLAGS="-g -O0 --coverage" 39 | - LDFLAGS="--coverage" 40 | - CONFIGUREFLAGS="--enable-debug" 41 | - compiler: gcc 42 | env: 43 | - DO_EXTRA="coverity" 44 | exclude: 45 | - os: osx 46 | compiler: gcc 47 | 48 | install: 49 | ## build libsndfile 50 | - mkdir -p libsndfile/build && curl "$LIBSNDFILE_URL" | tar --strip-components=1 -C libsndfile -xvzf - 51 | - cd libsndfile/build && ../configure --disable-silent-rules && make && sudo make install 52 | ## remove coverage traces 53 | - find . -name "*.gcda" -delete 54 | - find . -name "*.gcno" -delete 55 | ## remove libtool libs 56 | - find /usr/local/lib -type f -name "*.la" -exec sudo rm -f {} \+ 57 | 58 | before_script: 59 | # configure the build 60 | - cd "$TRAVIS_BUILD_DIR" 61 | - ./autogen.sh 62 | - ./configure --disable-silent-rules ${CONFIGUREFLAGS} 63 | # OMG, Coverity scan uses a certificate not supported by travis-ci 64 | - if [ -d /etc/ssl/certs/ ] ; then echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt; fi 65 | # implement Coverity Scan with before_script instead of addons.coverity_scan 66 | # to work around too-early quota check by the coverity_scan addon 67 | - if [[ "x${DO_EXTRA}" = "xcoverity" ]] ; then curl -s 'https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh' | bash || true ; fi 68 | 69 | script: 70 | - make 71 | - if [[ "x${DO_EXTRA}" = "x" ]] ; then make distcheck; fi 72 | 73 | after_success: 74 | - if [[ "x${DO_EXTRA}" = "xcoverage" ]] ; then LD_LIBRARY_PATH=/usr/local/lib ./coverage.sh; fi 75 | - if [[ "yes.${TRAVIS_BRANCH}.${TRAVIS_PULLREQUEST}" = "yes.master." ]]; then ./.deploy-documentation.sh ; fi 76 | - bash <(curl -s https://codecov.io/bash) 77 | -------------------------------------------------------------------------------- /release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #################################### 3 | # prepare package for release 4 | 5 | # DONE: get current version from configure.ac 6 | # DONE: ChangeLog generator using git-dch 7 | # DONE: update configure.ac 8 | # TODO: automatically update AUTHORS 9 | # TODO: automatically prepare NEWS (from ChangeLog) 10 | # TODO: automatically launch editors for ChangeLog/NEWS/AUTHORS 11 | # TODO: automatically tag (if all went well) 12 | 13 | CHANGELOG=CHANGELOG 14 | NEWS=NEWS 15 | AUTHORS=AUTHORS 16 | 17 | error() { 18 | echo "$@" 1>&2 19 | } 20 | fatal() { 21 | error "$@" 22 | exit 1 23 | } 24 | usage() { 25 | fatal "usage: $0 [] " 1>&2 26 | } 27 | 28 | getoldversion () { 29 | dpkg-parsechangelog --count 1 -l${CHANGELOG} | egrep "^Version:" | head -1 | cut -f2 -d' ' 30 | } 31 | getmoduleversion() { 32 | grep "^AC_INIT" configure.ac | 33 | sed -e 's|[^,]*,||' \ 34 | -e 's|,.*||' \ 35 | -e 's|[][]||g' 36 | } 37 | getgitbranch() { 38 | git rev-parse --abbrev-ref HEAD 39 | } 40 | 41 | if [ -d "debian/" ]; then 42 | fatal "debian/ directory exists" 43 | fi 44 | 45 | if [ "$(getgitbranch)" != "master" ]; then 46 | fatal "current branch '$(getgitbranch)' is not 'master'" 47 | fi 48 | 49 | if [ "x$2" = "x" ]; then 50 | ## guess current version 51 | NEWVERSION=$1 52 | OLDVERSION=$(getoldversion) 53 | else 54 | OLDVERSION=$1 55 | NEWVERSION=$2 56 | fi 57 | 58 | if [ "x${NEWVERSION}" = "x" ]; then 59 | NEWVERSION=$(getmoduleversion) 60 | fi 61 | 62 | if git tag -l v${OLDVERSION} | grep . >/dev/null 63 | then 64 | : 65 | else 66 | fatal "it seems like there is no tag 'v${OLDVERSION}'" 67 | fi 68 | 69 | if [ "x${OLDVERSION}" = "x" ]; then 70 | usage 71 | fi 72 | 73 | echo "updating from ${OLDVERSION}" 74 | 75 | if [ "x${NEWVERSION}" = "x" ]; then 76 | usage 77 | fi 78 | 79 | if dpkg --compare-versions ${OLDVERSION} ge ${NEWVERSION} 80 | then 81 | fatal "version mismatch: ${NEWVERSION} is not newer than ${OLDVERSION}" 82 | fi 83 | 84 | echo "updating to ${NEWVERSION}" 85 | 86 | OK=false 87 | mkdir debian 88 | touch debian/control 89 | cp ${CHANGELOG} debian/changelog 90 | gbp dch -R --since "v${OLDVERSION}" -N "${NEWVERSION}" && cat debian/changelog > ${CHANGELOG} && OK=true 91 | dch --news ${NEWS} || OK=false 92 | rm -rf debian 93 | 94 | if [ "x${OK}" = "xtrue" ]; then 95 | sed -e "s|^\(AC_INIT[^,]*\),[[][^,]*[]],\(.*\)|\1,[${NEWVERSION}],\2|" -i configure.ac 96 | fi 97 | 98 | if [ "x${OK}" = "xtrue" ]; then 99 | echo "all went well" 100 | echo "" 101 | echo "- please check your ${CHANGELOG}" 102 | echo "- please check&edit your ${NEWS}" 103 | echo "- please check&edit your ${AUTHORS}" 104 | echo "- and don't forget to git-tag the new version as v${NEWVERSION}" 105 | echo " git tag v${NEWVERSION} -m \"released v${NEWVERSION}\"" 106 | else 107 | fatal "ouch, something went wrong..." 108 | fi 109 | -------------------------------------------------------------------------------- /libambix/src/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | AM_CPPFLAGS = -I$(top_srcdir)/libambix 3 | 4 | lib_LTLIBRARIES = libambix.la 5 | 6 | #------------------------------------------------------------------------------------ 7 | # Rules for library version information: 8 | # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html 9 | # 10 | # 1. Start with version information of `0:0:0' for each libtool library. 11 | # 2. Update the version information only immediately before a public release of 12 | # your software. More frequent updates are unnecessary, and only guarantee 13 | # that the current interface number gets larger faster. 14 | # 3. If the library source code has changed at all since the last update, then 15 | # increment revision (`c:r:a' becomes `c:r+1:a'). 16 | # 4. If any interfaces have been added, removed, or changed since the last 17 | # update, increment current, and set revision to 0. 18 | # 5. If any interfaces have been added since the last public release, then 19 | # increment age. 20 | # 6. If any interfaces have been removed since the last public release, then 21 | # set age to 0. 22 | # 23 | # The following explanation may help to understand the above rules a bit better: 24 | # consider that there are three possible kinds of reactions from users of your 25 | # library to changes in a shared library: 26 | # 27 | # 1. Programs using the previous version may use the new version as drop-in 28 | # replacement, and programs using the new version can also work with the 29 | # previous one. In other words, no recompiling nor relinking is needed. In 30 | # this case, bump revision only, don't touch current nor age. 31 | # 2. Programs using the previous version may use the new version as drop-in 32 | # replacement, but programs using the new version may use APIs not present in 33 | # the previous one. In other words, a program linking against the new version 34 | # may fail with “unresolved symbols” if linking against the old version at 35 | # runtime: set revision to 0, bump current and age. 36 | # 3. Programs may need to be changed, recompiled, relinked in order to use the 37 | # new version. Bump current, set revision and age to 0. 38 | 39 | libambix_la_CPPFLAGS = $(AM_CPPFLAGS) 40 | libambix_la_CFLAGS = $(AM_CFLAGS) 41 | libambix_la_LDFLAGS = $(AM_LDFLAGS) 42 | 43 | libambix_la_CPPFLAGS += -DAMBIX_INTERNAL 44 | if DEBUG 45 | libambix_la_CPPFLAGS += -DDEBUG=1 46 | else 47 | libambix_la_CFLAGS += -fvisibility=hidden 48 | endif 49 | libambix_la_LDFLAGS += -version-info 0:0:0 -no-undefined 50 | libambix_la_LIBADD = $(LIBM) 51 | 52 | libambix_la_OBJCFLAGS = $(libambix_la_CFLAGS) 53 | 54 | libambix_la_SOURCES = libambix.c \ 55 | adaptor.c \ 56 | adaptor_acn.c \ 57 | adaptor_fuma.c \ 58 | matrix.c matrix_invert.c \ 59 | utils.c \ 60 | uuid_chunk.c \ 61 | marker_region_chunk.c \ 62 | private.h 63 | 64 | if HAVE_SNDFILE 65 | libambix_la_SOURCES += sndfile.c 66 | libambix_la_CFLAGS += @SNDFILE_CFLAGS@ 67 | libambix_la_LIBADD += @SNDFILE_LIBS@ 68 | else !HAVE_SNDFILE 69 | if HAVE_FRAMEWORK_AUDIOTOOLBOX 70 | libambix_la_SOURCES += coreaudio.m 71 | libambix_la_LIBADD += @IEM_FRAMEWORK_AUDIOTOOLBOX@ @IEM_FRAMEWORK_FOUNDATION@ 72 | else !HAVE_FRAMEWORK_AUDIOTOOLBOX 73 | libambix_la_SOURCES += null.c 74 | endif !HAVE_FRAMEWORK_AUDIOTOOLBOX 75 | endif !HAVE_SNDFILE 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | libambix - The AMBIsonics eXchange library 2 | ========================================== 3 | 4 | This is libambix `0.0.1` 5 | 6 | libambix is a library of C routines for reading and writing 7 | files following the "ambix" (AMBIsonics eXchange) conventions. 8 | 9 | # Status 10 | 11 | | *Check* | *Health* | 12 | | :--------------------- | :------------------------------------------------------------------ | 13 | | Continuous Integration | ![Travis-CI](https://api.travis-ci.org/umlaeute/pd-iemnet.svg) | 14 | | Static Code Analysis | ![Coverity Scan](https://scan.coverity.com/projects/1736/badge.svg) | 15 | | Test Coverage | [![codecov](https://codecov.io/gh/iem-projects/ambix/branch/master/graph/badge.svg)](https://codecov.io/gh/iem-projects/ambix) | 16 | 17 | 18 | # INTRODUCTION 19 | libambix is a library that reads and writes soundfiles following the "ambix" 20 | specificiation. 21 | Such files are: 22 | - `CAF` (Core Audio Format) files 23 | - *with* a special `UUID-chunk` 24 | 25 | Audio data as output (and accepted as input) by libambix will follow the following specification: 26 | - sample format is either `PCM16`, `PCM24`, `float32` (this one being best 27 | tested) and `float64` 28 | - audio data is *interleaved* 29 | - ambisonics channels are 30 | - normalization : `SN3D` 31 | - channel ordering : `ACN` 32 | 33 | It is planned to provide conversion matrices to present the audio data in other 34 | (common) formats namely 35 | - Furse-Malham set (*FuMa*) 36 | - other normalizations (*N3D*) 37 | - other ordering (*SID*) 38 | 39 | # Download 40 | 41 | Get the source code (and releases) from 42 | https://git.iem.at/ambisonics/libambix 43 | 44 | The source code is also mirrored to 45 | [GitHub](https://github.com/iem-projects/ambix/) 46 | and (less often) to 47 | [SourceForge](https://sourceforge.net/p/iem/ambix/) 48 | 49 | # API Documentation 50 | 51 | An up-to-date API Documentation can be found at 52 | http://iem-projects.github.io/ambix/apiref/ 53 | 54 | # Directory layout 55 | - `libambix/` - all components of the libambix library 56 | - `libambix/src` - the source code for library itself. 57 | - `libambix/ambix` - public header files for the library 58 | - `libambix/tests` - programs which link against libambix and test its functionality. 59 | - `utils/` - utility programs using libambix 60 | 61 | # BUILDING from source 62 | 63 | ## DEPENDENCIES 64 | Currently libambix uses libsndfile to read the actual file. 65 | Due to some advanced functionality, you need at least libsndfile-1.0.26. 66 | The current version of libsndfile can be obtained from 67 | https://github.com/erikd/libsndfile 68 | 69 | 70 | ## LINUX 71 | Wherever possible, you should use the packages supplied by your Linux 72 | distribution. 73 | 74 | If you really do need to compile from source it should be as easy as: 75 | 76 | $ ./configure 77 | $ make 78 | $ make install 79 | 80 | if you want to compile the development version of libambix, you might need 81 | to run the following *before* any of the above: 82 | 83 | $ ./autogen.sh 84 | 85 | ## UNIX 86 | Compile as for Linux. 87 | 88 | 89 | ## Win32/Win64 90 | The default Windows compilers (Microsoft's Visual Studio) are nowhere near 91 | compliant with the 1999 ISO C Standard and hence not able to compile libambix. 92 | 93 | Please use the libambix binaries available on the ambix web site. 94 | 95 | 96 | ## MacOSX 97 | Building on MacOSX should be the same as building it on any other Unix. 98 | 99 | 100 | # CONTACT 101 | 102 | libambix was written by IOhannes m zmölnig at the Institute of Electronic Music 103 | and Acoustics (IEM), and the University of Music and Performing Arts (KUG), Graz, 104 | Austria 105 | The libambix home page is at : 106 | 107 | http://git.iem.at/ambisonics/libambix 108 | -------------------------------------------------------------------------------- /libambix/tests/datatest.c: -------------------------------------------------------------------------------- 1 | /* data - test generic data functionality 2 | 3 | Copyright © 2012-2016 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | #include "common.h" 25 | #include 26 | #include 27 | 28 | static float32_t left[]= { 29 | 0.19, 0.06, 0.14, 30 | 0.05, 0.08, 0.44, 31 | 0.25, 0.90, 0.77, 32 | 0.83, 0.51, 0.58, 33 | }; 34 | 35 | void do_diff(float32_t eps) { 36 | float32_t errf; 37 | unsigned int i; 38 | unsigned int size=sizeof(left)/sizeof(*left); 39 | float32_t*right=malloc(sizeof(left)); 40 | float32_t maxeps=eps; 41 | 42 | STARTTEST("\n"); 43 | data_print(FLOAT32, left, size); 44 | 45 | /* comparisons: 46 | - left/right data is NULL 47 | - non-failing tests: 48 | - all values diff==0 49 | - all values diff0.f, __LINE__, "diffing mtx with itself returned %g (>%g)", errf, 0.f); 57 | 58 | /* compare equal data */ 59 | STARTTEST("equal\n"); 60 | for(i=0; i0.f, __LINE__, "diffing mtx with copy returned %g (>%g)", errf, 0.f); 65 | 66 | /* compare data where all values differ, but eps, __LINE__, "diffing mtx with mtx+eps/2 returned %g (>%g)", errf, size, eps); 73 | for(i=0; ieps, __LINE__, "diffing mtx with mtx-eps/2 returned %g (>%g)", errf, size, eps); 78 | 79 | /* compare data where many values differ with eps */ 80 | STARTTEST("mosteps\n"); 81 | for(i=0; i(eps*2.0), __LINE__, "diffing mtx with one value>eps returned %g (>%g)", errf, size, eps); 90 | fail_if(errf<(eps*1.0), __LINE__, "diffing mtx with one value>eps returned %g (>%g)", errf, size, eps); 91 | 92 | /* compare data where most values differ with >eps */ 93 | STARTTEST("most>eps\n"); 94 | for(i=0; ieps returned %g (<%g)", errf, eps*1.0); 103 | fail_if(errf>eps*2.0, __LINE__, "diffing mtx with one value>eps returned %g (<%g)", errf, eps*2.0); 104 | 105 | free(right); 106 | STOPTEST("\n"); 107 | } 108 | 109 | int main(int argc, char**argv) { 110 | do_diff(1e-1); 111 | do_diff(1e-7); 112 | 113 | return pass(); 114 | } 115 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing to libambix development 2 | ==================================== 3 | 4 | Contribution should be done via 5 | - Merge Requests / Pull Requests 6 | OR 7 | - via git patchsets (`git format-patch`) 8 | 9 | # GIT 10 | 11 | ## Canonical Repositories 12 | 13 | MAIN repository 14 | - https://git.iem.at/ambisonics/libambix 15 | 16 | secondary repository 17 | - https://github.com/iem-projects/ambix 18 | 19 | Please *do not use* these legacy repositories: 20 | - ~~https://github.com/umlaeute/ambix~~ 21 | - ~~https://git.code.sf.net/p/iem/ambix~~ (SourceForge) 22 | 23 | ## Commits 24 | 25 | - make small, atomic commits 26 | - commit often 27 | - be sure that the description matches the actual changeset 28 | - do not mix unrelated changes into a single commit (*"fixed bug BAR, added 29 | feature FOO"* is **bad**) 30 | - never mix changes to different components 31 | (e.g. changes to `libambix/` should go in different commits as changes to `utils/` 32 | and changes to `samples/pd/`) 33 | - even if this temporarily breaks compilation! (e.g. if you are changing the 34 | API of the libambix library, you have to update any code that uses this API; 35 | in this case, first commit the changes to libambix, and then commit the 36 | required changes in the utilities. the latter should be a single commit that 37 | only adapts the code to the new API) 38 | - make small, atomic commits 39 | 40 | # Coding Style 41 | 42 | - libambix is written in `ANSI-C` (aka `C89`) 43 | 44 | - function names use underscores to separate names (e.g. `ambix_open`) 45 | - *public* functions 46 | - each *public* function **MUST** be declared in `libambix/ambix/ambi.h` 47 | - each *public* function **MUST** be declared with the `AMBIX_API` decorator 48 | - each *public* function **MUST** start with the `ambix_` prefix (to avoid nameclashes with other libraries) 49 | - *non-public* functions 50 | - *non-public* functions that are only used within a single source file **MUST** be declared `static` 51 | - *non-public* functions that are used within the entire libambix library **MUST** be prefixed with `_ambix` 52 | - *non-public* functions that are used within the entire libambix library **SHOULD** be declared in `libambix/src/private.h` file 53 | 54 | - type names use underscores to separate names (e.g. `ambix_matrix_t`) 55 | - type names have a `_t` suffix (and an `ambix_` prefix if they are non-trivial) 56 | - *public* types 57 | - complex types (aka `struct`s) should always be opaque (the actual `struct` is kept as an implementation detail) 58 | - if needed, use (public) accessor functions (`get`/`set`) for the elements of a complex type 59 | 60 | - 61 | 62 | ## Code Formatting 63 | 64 | TODO (follow mine :-)) 65 | - no whitespace at the end-of-line 66 | - no empty line at the end-of-file 67 | 68 | 69 | # Code Testing 70 | 71 | ## Unit Tests 72 | 73 | See `libambix/tests/` for example tests. 74 | 75 | All public functionality (and as far as possible all private functionality) 76 | should be tested via unit tests. 77 | The testing "framework" in use is provided by autotools. 78 | 79 | When testing private interfaces (non-public functions), the unit tests 80 | need to be compiled in debug-mode (using the `--enable-debug` configure option) 81 | and the tests should be protected by an `if DEBUG / endif` clause 82 | `libambix/tests/Makefile.am`. 83 | 84 | ## Checking for memory leaks 85 | The unit tests can be instrumented to be run through valgrind: 86 | 87 | cd libambix/tests 88 | make check-valgrind 89 | 90 | The above will run the tests through the standard `memcheck` tool. 91 | If you want to use another valgrind tool, You can specify that as well: 92 | 93 | cd libambix/tests 94 | make check-valgrind-tool VALGRIND_TOOL=memcheck 95 | 96 | ## Continuous Integration 97 | The library is automatically built and tested via 98 | [Travis-CI](https://travis-ci.org/iem-projects/ambix) whenever new code is 99 | committed. 100 | 101 | If you do not have write access to the main repository of libambix, you can 102 | Trigger a CI build for your contribution simply by creating a *Pull Request* 103 | against the [iem-projects/ambix](https://github.com/iem-projects/ambix) 104 | repository on GitHub. 105 | -------------------------------------------------------------------------------- /libambix/tests/common_none.c: -------------------------------------------------------------------------------- 1 | /* none - test ambix none 2 | 3 | Copyright © 2012-2016 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | #include "common.h" 25 | #include 26 | #include 27 | 28 | 29 | void check_create_none(const char*path, ambix_sampleformat_t format) { 30 | ambix_info_t info, rinfo, winfo; 31 | ambix_t*ambix=NULL; 32 | float32_t*orgdata,*data,*resultdata; 33 | uint32_t frames=44100; 34 | uint32_t channels=6; 35 | float32_t periods=10; 36 | int64_t err64, gotframes; 37 | float32_t diff=0., eps=1e-30; 38 | 39 | resultdata=(float32_t*)calloc(channels*frames, sizeof(float32_t)); 40 | data=(float32_t*)calloc(channels*frames, sizeof(float32_t)); 41 | 42 | memset(&winfo, 0, sizeof(winfo)); 43 | memset(&info, 0, sizeof(info)); 44 | 45 | info.fileformat=AMBIX_NONE; 46 | info.ambichannels=0; 47 | info.extrachannels=channels; 48 | info.samplerate=44100; 49 | info.sampleformat=format; 50 | 51 | memcpy(&rinfo, &info, sizeof(info)); 52 | 53 | ambix=ambix_open(path, AMBIX_WRITE, &rinfo); 54 | fail_if((NULL==ambix), __LINE__, "couldn't create ambix file '%s' for writing", path); 55 | 56 | orgdata=data_sine(FLOAT32, frames, channels, periods); 57 | //data_print(FLOAT32, orgdata, 100); 58 | 59 | memcpy(data, orgdata, frames*channels*sizeof(float32_t)); 60 | 61 | fail_if((NULL==data), __LINE__, "couldn't create data %dx%d sine @ %f", (int)frames, (int)channels, (float)periods); 62 | 63 | err64=ambix_writef_float32(ambix, NULL, data, frames); 64 | fail_if((err64!=frames), __LINE__, "wrote only %d frames of %d", (int)err64, (int)frames); 65 | 66 | diff=data_diff(__LINE__, FLOAT32, orgdata, data, frames*channels, eps); 67 | fail_if((diff>eps), __LINE__, "data diff %f > %f", diff, eps); 68 | 69 | fail_if((AMBIX_ERR_SUCCESS!=ambix_close(ambix)), __LINE__, "closing ambix file %p", ambix); 70 | ambix=NULL; 71 | 72 | ambix=ambix_open(path, AMBIX_READ, &rinfo); 73 | fail_if((NULL==ambix), __LINE__, "couldn't create ambix file '%s' for reading", path); 74 | 75 | fail_if((info.fileformat!=rinfo.fileformat), __LINE__, "fileformat mismatch %d!=%d", (int)info.fileformat, (int)rinfo.fileformat); 76 | fail_if((info.samplerate!=rinfo.samplerate), __LINE__, "samplerate mismatch %g!=%g", (float)info.samplerate, (float)rinfo.samplerate); 77 | fail_if((info.sampleformat!=rinfo.sampleformat), __LINE__, "sampleformat mismatch %d!=%d", (int)info.sampleformat, (int)rinfo.sampleformat); 78 | fail_if((info.ambichannels!=rinfo.ambichannels), __LINE__, "ambichannels mismatch %d!=%d", (int)info.ambichannels, (int)rinfo.ambichannels); 79 | fail_if((info.extrachannels!=rinfo.extrachannels), __LINE__, "extrachannels mismatch %d!=%d", (int)info.extrachannels, (int)rinfo.extrachannels); 80 | 81 | gotframes=0; 82 | do { 83 | err64=ambix_readf_float32(ambix, NULL, resultdata+(gotframes*channels), (frames-gotframes)); 84 | fail_if((err64<0), __LINE__, "reading frames failed after %d/%d frames", (int)gotframes, (int)frames); 85 | gotframes+=err64; 86 | } while(err64>0 && gotframeseps), __LINE__, "data diff %f > %f", diff, eps); 90 | 91 | fail_if((AMBIX_ERR_SUCCESS!=ambix_close(ambix)), __LINE__, "closing ambix file %p", ambix); 92 | ambix=NULL; 93 | 94 | 95 | free(resultdata); 96 | free(data); 97 | free(orgdata); 98 | 99 | ambixtest_rmfile(path); 100 | } 101 | -------------------------------------------------------------------------------- /libambix/tests/common_basic.c: -------------------------------------------------------------------------------- 1 | /* simple - test ambix simple 2 | 3 | Copyright © 2012-2016 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | */ 22 | 23 | #include "common.h" 24 | #include 25 | #include 26 | 27 | 28 | void check_create_simple(const char*path, ambix_sampleformat_t format, float32_t eps) { 29 | ambix_info_t info, rinfo, winfo; 30 | ambix_t*ambix=NULL; 31 | float32_t*orgdata,*data,*resultdata; 32 | uint32_t frames=441000; 33 | uint32_t channels=4; 34 | float32_t periods=4724; 35 | int64_t err64; 36 | float32_t diff=0.; 37 | uint32_t gotframes; 38 | 39 | printf("test using '%s' [%d]\n", path, (int)format); 40 | 41 | resultdata=(float32_t*)calloc(channels*frames, sizeof(float32_t)); 42 | data=(float32_t*)calloc(channels*frames, sizeof(float32_t)); 43 | 44 | memset(&winfo, 0, sizeof(winfo)); 45 | memset(&info, 0, sizeof(info)); 46 | 47 | info.fileformat=AMBIX_BASIC; 48 | info.ambichannels=channels; 49 | info.extrachannels=0; 50 | info.samplerate=44100; 51 | info.sampleformat=format; 52 | 53 | memcpy(&rinfo, &info, sizeof(info)); 54 | 55 | ambix=ambix_open(path, AMBIX_WRITE, &rinfo); 56 | fail_if((NULL==ambix), __LINE__, "couldn't create ambix file '%s' for writing", path); 57 | 58 | orgdata=data_sine(FLOAT32, frames, channels, periods); 59 | //data_print(FLOAT32, orgdata, 100); 60 | 61 | memcpy(data, orgdata, frames*channels*sizeof(float32_t)); 62 | 63 | fail_if((NULL==data), __LINE__, "couldn't create data %dx%d sine @ %f", (int)frames, (int)channels, (float)periods); 64 | 65 | err64=ambix_writef_float32(ambix, data, NULL, frames); 66 | fail_if((err64!=frames), __LINE__, "wrote only %d frames of %d", (int)err64, (int)frames); 67 | 68 | diff=data_diff(__LINE__, FLOAT32, orgdata, data, frames*channels, eps); 69 | fail_if((diff>eps), __LINE__, "data diff %f > %f", diff, eps); 70 | 71 | fail_if((AMBIX_ERR_SUCCESS!=ambix_close(ambix)), __LINE__, "closing ambix file %p", ambix); 72 | ambix=NULL; 73 | 74 | ambix=ambix_open(path, AMBIX_READ, &rinfo); 75 | fail_if((NULL==ambix), __LINE__, "couldn't create ambix file '%s' for reading", path); 76 | 77 | fail_if((info.fileformat!=rinfo.fileformat), __LINE__, "fileformat mismatch %d!=%d", (int)info.fileformat, (int)rinfo.fileformat); 78 | fail_if((info.samplerate!=rinfo.samplerate), __LINE__, "samplerate mismatch %g!=%g", (float)info.samplerate, (float)rinfo.samplerate); 79 | fail_if((info.sampleformat!=rinfo.sampleformat), __LINE__, "sampleformat mismatch %d!=%d", (int)info.sampleformat, (int)rinfo.sampleformat); 80 | fail_if((info.ambichannels!=rinfo.ambichannels), __LINE__, "ambichannels mismatch %d!=%d", (int)info.ambichannels, (int)rinfo.ambichannels); 81 | fail_if((info.extrachannels!=rinfo.extrachannels), __LINE__, "extrachannels mismatch %d!=%d", (int)info.extrachannels, (int)rinfo.extrachannels); 82 | 83 | gotframes=0; 84 | do { 85 | err64=ambix_readf_float32(ambix, resultdata+(gotframes*channels), NULL, (frames-gotframes)); 86 | fail_if((err64<0), __LINE__, "reading frames failed after %d/%d frames", (int)gotframes, (int)frames); 87 | gotframes+=err64; 88 | } while(err64>0 && gotframeseps), __LINE__, "data diff %f > %f", diff, eps); 92 | 93 | fail_if((AMBIX_ERR_SUCCESS!=ambix_close(ambix)), __LINE__, "closing ambix file %p", ambix); 94 | ambix=NULL; 95 | 96 | free(data); 97 | free(resultdata); 98 | free(orgdata); 99 | 100 | ambixtest_rmfile(path); 101 | } 102 | -------------------------------------------------------------------------------- /libambix/tests/markers_regions.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "data.h" 3 | 4 | #include 5 | 6 | int main(int argc, char**argv) { 7 | const char*markerfile=FILENAME_FILE; 8 | ambix_t*ambix=NULL; 9 | ambix_info_t info; 10 | memset(&info, 0, sizeof(info)); 11 | uint32_t frames=441000; 12 | uint32_t channels=4; 13 | int64_t err64; 14 | float32_t*data; 15 | 16 | info.fileformat=AMBIX_BASIC; 17 | info.ambichannels=channels; 18 | info.extrachannels=0; 19 | info.samplerate=44100; 20 | info.sampleformat=AMBIX_SAMPLEFORMAT_FLOAT32; 21 | 22 | data=(float32_t*)calloc(channels*frames, sizeof(float32_t)); 23 | 24 | ambix=ambix_open(markerfile, AMBIX_WRITE, &info); 25 | fail_if(NULL==ambix, __LINE__, "File was not open"); 26 | 27 | /* add some markers */ 28 | ambix_marker_t marker_1; 29 | memset(&marker_1, 0, sizeof(ambix_marker_t)); 30 | marker_1.position = 1.0; 31 | strncpy(marker_1.name, "this is marker #1", 255); 32 | 33 | ambix_marker_t marker_2; 34 | memset(&marker_2, 0, sizeof(ambix_marker_t)); 35 | marker_2.position = 2.0; 36 | strncpy(marker_2.name, "this is marker #2", 255); 37 | 38 | 39 | ambix_marker_t marker_3; 40 | memset(&marker_3, 0, sizeof(ambix_marker_t)); 41 | marker_3.position = 3.0; 42 | 43 | fail_if(0!=ambix_add_marker(ambix, &marker_1), __LINE__, "Could not add marker"); 44 | fail_if(0!=ambix_add_marker(ambix, &marker_2), __LINE__, "Could not add marker"); 45 | fail_if(0!=ambix_add_marker(ambix, &marker_3), __LINE__, "Could not add marker"); 46 | 47 | /* add some regions */ 48 | ambix_region_t region_1; 49 | memset(®ion_1, 0, sizeof(ambix_region_t)); 50 | region_1.start_position = 1.0; 51 | region_1.end_position = 2.0; 52 | strncpy(region_1.name, "this is region #1", 255); 53 | 54 | ambix_region_t region_2; 55 | memset(®ion_2, 0, sizeof(ambix_region_t)); 56 | region_2.start_position = 3.0; 57 | region_2.end_position = 4.0; 58 | strncpy(region_2.name, "this is region #2", 255); 59 | 60 | ambix_region_t region_3; 61 | memset(®ion_3, 0, sizeof(ambix_region_t)); 62 | region_3.start_position = 3.0; 63 | region_3.end_position = 4.0; 64 | 65 | fail_if(0!=ambix_add_region(ambix, ®ion_1), __LINE__, "Could not add region"); 66 | fail_if(0!=ambix_add_region(ambix, ®ion_2), __LINE__, "Could not add region"); 67 | fail_if(0!=ambix_add_region(ambix, ®ion_3), __LINE__, "Could not add region"); 68 | 69 | /* write testsamples */ 70 | err64=ambix_writef_float32(ambix, data, NULL, frames); 71 | 72 | ambix_close(ambix); 73 | 74 | 75 | /* open the file again and see wheter the markers and regions have been saved and can be read */ 76 | memset(&info, 0, sizeof(info)); 77 | ambix=ambix_open(markerfile, AMBIX_READ, &info); 78 | 79 | fail_if(0 == ambix_get_num_markers(ambix), __LINE__, "No markers in file"); 80 | fail_if(0 == ambix_get_num_regions(ambix), __LINE__, "No regions in file"); 81 | 82 | ambix_marker_t *marker_1_retr; 83 | ambix_marker_t *marker_2_retr; 84 | ambix_marker_t *marker_3_retr; 85 | 86 | ambix_region_t *region_1_retr; 87 | ambix_region_t *region_2_retr; 88 | ambix_region_t *region_3_retr; 89 | 90 | marker_1_retr=ambix_get_marker(ambix, 0); 91 | marker_2_retr=ambix_get_marker(ambix, 1); 92 | marker_3_retr=ambix_get_marker(ambix, 2); 93 | 94 | region_1_retr=ambix_get_region(ambix, 0); 95 | region_2_retr=ambix_get_region(ambix, 1); 96 | region_3_retr=ambix_get_region(ambix, 2); 97 | 98 | fail_if(marker_1_retr==NULL, __LINE__, "Could not retrieve marker 1"); 99 | fail_if(marker_2_retr==NULL, __LINE__, "Could not retrieve marker 2"); 100 | fail_if(marker_3_retr==NULL, __LINE__, "Could not retrieve marker 3"); 101 | fail_if(region_1_retr==NULL, __LINE__, "Could not retrieve region 1"); 102 | fail_if(region_2_retr==NULL, __LINE__, "Could not retrieve region 2"); 103 | fail_if(region_3_retr==NULL, __LINE__, "Could not retrieve region 3"); 104 | 105 | fail_if(memcmp(&marker_1, marker_1_retr, sizeof(ambix_marker_t)), __LINE__, "Marker 1 does not match"); 106 | fail_if(memcmp(&marker_2, marker_2_retr, sizeof(ambix_marker_t)), __LINE__, "Marker 2 does not match"); 107 | fail_if(memcmp(&marker_3, marker_3_retr, sizeof(ambix_marker_t)), __LINE__, "Marker 3 does not match"); 108 | fail_if(memcmp(®ion_1, region_1_retr, sizeof(ambix_region_t)), __LINE__, "Region 1 does not match"); 109 | fail_if(memcmp(®ion_2, region_2_retr, sizeof(ambix_region_t)), __LINE__, "Region 2 does not match"); 110 | fail_if(memcmp(®ion_3, region_3_retr, sizeof(ambix_region_t)), __LINE__, "Region 3 does not match"); 111 | 112 | if(data) 113 | free(data); 114 | ambix_close(ambix); 115 | ambixtest_rmfile(markerfile); 116 | return pass(); 117 | } 118 | -------------------------------------------------------------------------------- /m4/iem_rte.m4: -------------------------------------------------------------------------------- 1 | dnl Copyright (C) 2005-2012 IOhannes m zmölnig 2 | dnl This file is free software; IOhannes m zmölnig 3 | dnl gives unlimited permission to copy and/or distribute it, 4 | dnl with or without modifications, as long as this notice is preserved. 5 | 6 | # CHECK_RTE() 7 | # 8 | # checks for RTE (currently: Pd) 9 | # if so, they are added to the LDFLAGS, CFLAGS and whatelse 10 | AC_DEFUN([IEM_CHECK_RTE], 11 | [ 12 | IEM_OPERATING_SYSTEM 13 | 14 | AC_ARG_WITH([rte], 15 | AS_HELP_STRING([--with-rte=],[use the given RTE (e.g. 'pd') or none])) 16 | AC_ARG_WITH([pd], 17 | AS_HELP_STRING([--with-pd=],[where to find pd-binary (./bin/pd.exe) and pd-sources])) 18 | ### this should only be set if Pd has been found 19 | # the extension 20 | AC_ARG_WITH([extension], 21 | AS_HELP_STRING([--with-extension=],[enforce a certain file-extension (e.g. pd_linux)])) 22 | 23 | AC_ARG_WITH([rtedir], 24 | [AS_HELP_STRING([--rtedir=DIR], [externals (plugin) dir for RTE (default ${exec_prefix}/lib/pd/extra)])], 25 | [rtedir=$withval], 26 | [rtedir=['${exec_prefix}/lib/pd/extra']]) 27 | 28 | test "x${with_rte}" = "x" && with_rte="yes" 29 | 30 | ## this really should run some autodetection 31 | test "x${with_rte}" = "xyes" && with_rte="pd" 32 | 33 | if test "x${with_rte}" = "xpd"; then 34 | tmp_rte_orgcppflags="$CPPFLAGS" 35 | tmp_rte_orgcflags="$CFLAGS" 36 | tmp_rte_orgcxxflags="$CXXFLAGS" 37 | tmp_rte_orgldflags="$LDFLAGS" 38 | tmp_rte_orglibs="$LIBS" 39 | 40 | tmp_rte_cflags="-DPD" 41 | tmp_rte_libs="" 42 | RTE="Pure Data" 43 | 44 | ## some default paths 45 | if test "x${with_pd}" = "x"; then 46 | case $host_os in 47 | *darwin*) 48 | if test -d "/Applications/Pd-extended.app/Contents/Resources"; then with_pd="/Applications/Pd-extended.app/Contents/Resources"; fi 49 | if test -d "/Applications/Pd.app/Contents/Resources"; then with_pd="/Applications/Pd.app/Contents/Resources"; fi 50 | ;; 51 | *mingw* | *cygwin*) 52 | if test -d "${PROGRAMFILES}/Pd-extended"; then with_pd="${PROGRAMFILES}/Pd-extended"; fi 53 | if test -d "${PROGRAMFILES}/pd"; then with_pd="${PROGRAMFILES}/pd"; fi 54 | ;; 55 | esac 56 | fi 57 | 58 | if test -d "$with_pd" ; then 59 | if test -d "${with_pd}/src" ; then 60 | tmp_rte_cflags="${tmp_rte_cflags}${tmp_rte_cflags:+ }-I${with_pd}/src" 61 | elif test -d "${with_pd}/include/pd" ; then 62 | tmp_rte_cflags="${tmp_rte_cflags}${tmp_rte_cflags:+ }-I${with_pd}/include/pd" 63 | elif test -d "${with_pd}/include" ; then 64 | tmp_rte_cflags="${tmp_rte_cflags}${tmp_rte_cflags:+ }-I${with_pd}/include" 65 | else 66 | tmp_rte_cflags="${tmp_rte_cflags}${tmp_rte_cflags:+ }-I${with_pd}" 67 | fi 68 | if test -d "${with_pd}/bin" ; then 69 | tmp_rte_libs="${tmp_rte_libs}${tmp_rte_libs:+ }-L${with_pd}/bin" 70 | else 71 | tmp_rte_libs="${tmp_rte_libs}${tmp_rte_libs:+ }-L${with_pd}" 72 | fi 73 | 74 | CPPFLAGS="$CPPFLAGS ${tmp_rte_cflags}" 75 | CFLAGS="$CFLAGS ${tmp_rte_cflags}" 76 | CXXFLAGS="$CXXFLAGS ${tmp_rte_cflags}" 77 | LIBS="$LIBS ${tmp_rte_libs}" 78 | fi 79 | 80 | AC_CHECK_LIB([:pd.dll], [nullfn], [have_pddll="yes"], [have_pddll="no"]) 81 | if test "x$have_pddll" = "xyes"; then 82 | tmp_rte_libs="${tmp_rte_libs}${tmp_rte_libs:+ }-Xlinker -l:pd.dll" 83 | else 84 | AC_CHECK_LIB([pd], [nullfn], [tmp_rte_libs="${tmp_rte_libs}${tmp_rte_libs:+ }-lpd"]) 85 | fi 86 | 87 | AC_CHECK_HEADERS([m_pd.h], [have_pd="yes"], [have_pd="no"]) 88 | 89 | dnl LATER check why this doesn't use the --with-pd includes 90 | dnl for now it will basically disable anything that needs s_stuff.h if it cannot be found in /usr[/local]/include 91 | AC_CHECK_HEADERS([s_stuff.h], [], [], 92 | [#ifdef HAVE_M_PD_H 93 | # define PD 94 | # include "m_pd.h" 95 | #endif 96 | ]) 97 | 98 | if test "x$with_extension" != "x"; then 99 | tmp_rte_extension=$with_extension 100 | else 101 | case x$host_os in 102 | x*darwin*) 103 | tmp_rte_extension=pd_darwin 104 | ;; 105 | x*mingw* | x*cygwin*) 106 | tmp_rte_extension=dll 107 | ;; 108 | x) 109 | dnl just assuming that it is still linux (e.g. x86_64) 110 | tmp_rte_extension="pd_linux" 111 | ;; 112 | *) 113 | tmp_rte_extension=pd_`echo $host_os | sed -e '/.*/s/-.*//' -e 's/\[.].*//'` 114 | ;; 115 | esac 116 | fi 117 | RTE_EXTENSION=$tmp_rte_extension 118 | RTE_CFLAGS="$tmp_rte_cflags" 119 | RTE_LIBS="$tmp_rte_libs" 120 | 121 | AC_SUBST(RTE_EXTENSION) 122 | AC_SUBST(RTE_CFLAGS) 123 | AC_SUBST(RTE_LIBS) 124 | AC_SUBST(RTE) 125 | AC_SUBST([rtedir], ['${exec_prefix}/lib/pd/extra'])dnl 126 | 127 | CPPFLAGS="$tmp_rte_orgcppflags" 128 | CFLAGS="$tmp_rte_orgcflags" 129 | CXXFLAGS="$tmp_rte_orgcxxflags" 130 | LDFLAGS="$tmp_rte_orgldflags" 131 | LIBS="$tmp_rte_orglibs" 132 | fi 133 | ]) # CHECK_RTE 134 | -------------------------------------------------------------------------------- /samples/pd/ambix_read~-help.pd: -------------------------------------------------------------------------------- 1 | #N canvas 307 182 758 533 10; 2 | #X obj 405 333 route bang; 3 | #X obj 405 353 print EOF; 4 | #X obj 535 357 print info; 5 | #X msg 94 153 1; 6 | #X obj 74 298 env~; 7 | #X floatatom 74 318 5 0 0 3 ACN0 - -, f 5; 8 | #X obj 495 399 /; 9 | #X floatatom 495 419 5 0 0 1 seconds - -, f 5; 10 | #X obj 495 357 t a a; 11 | #X obj 495 379 route frames samplerate; 12 | #X obj 109 330 env~; 13 | #X floatatom 109 350 5 0 0 3 ACN1 - -, f 5; 14 | #X obj 149 330 env~; 15 | #X floatatom 149 350 5 0 0 3 ACN2 - -, f 5; 16 | #X obj 189 330 env~; 17 | #X floatatom 189 350 5 0 0 3 ACN3 - -, f 5; 18 | #X obj 74 238 ambix_read~ 4 2; 19 | #X obj 264 358 env~; 20 | #X floatatom 264 378 5 0 0 3 xtra0 - -, f 5; 21 | #X obj 299 358 env~; 22 | #X floatatom 299 378 5 0 0 3 xtra1 - -, f 5; 23 | #X msg 99 175 0; 24 | #X msg 646 30 \; pd dsp 1; 25 | #X msg 74 122 open \$1; 26 | #X msg 74 49 bang; 27 | #X obj 74 69 openpanel; 28 | #X obj 145 499 readsf~; 29 | #X text 200 18 [ambix_read~] read an AMBIsonics eXchange file (SIMPLE 30 | mode); 31 | #X text 215 47 The [ambix_read~] reads an ambix soundfile into it's 32 | signal outputs \, much like [readsf~] for normal soundfiles.; 33 | #X text 215 81 You must "open" the ambix file in advance \, to allow 34 | the buffer to be filled up \, and the send "1" to start playback.; 35 | #X text 215 107 Sending "0" stops playback.; 36 | #X text 215 129 Some information on the file is sent to the last outlet 37 | of the object \, e.g. the number of frames (samples per channel) \, 38 | the number of ambisonics- and nonambisonics- channels found in the 39 | file and the samplerate; 40 | #X obj 495 456 route resamplerate; 41 | #X obj 630 441 t a; 42 | #X floatatom 495 471 0 0 0 0 - - -; 43 | #X text 491 486 samplerate (after evtl. re-sampling); 44 | #X text 286 266 is given in samples per channels (unlike 45 | [readsf~] where you specify it in bytes per channel); 46 | #X text 43 475 see also:; 47 | #X obj 145 477 ambix_readX~; 48 | #X text 215 186 The ambisonics channels will always be periphonic (3D) 49 | semi-normalized (SN3D) and ordered after their ACN.; 50 | #X text 225 213 If you work with a Furse-Malham decoder \, you will 51 | need to transform the output data.; 52 | #X text 215 243 arguments: <#ambioutlet~s:4> <#extraoutlet~s:0> 53 | ; 54 | #X obj 242 477 ambix_info; 55 | #N canvas 923 305 706 352 marker/regions 1; 56 | #X msg 42 121 get_all_markers; 57 | #X obj 35 300 outlet; 58 | #X msg 88 206 get_all_regions; 59 | #X msg 75 171 get_region \$1; 60 | #X msg 31 93 get_marker \$1; 61 | #X floatatom 31 72 5 0 0 0 - - -, f 5; 62 | #X floatatom 75 151 5 0 0 0 - - -, f 5; 63 | #X obj 372 90 r info-\$0; 64 | #X msg 344 267 seek \$1; 65 | #X obj 372 112 route marker region; 66 | #X obj 372 139 route 0 1 2; 67 | #X floatatom 344 236 10 0 0 0 - - -, f 10; 68 | #X obj 455 139 route 0 1 2; 69 | #X text 145 119 retrieve all markers; 70 | #X text 26 9 MARKER/REGION Info is sent to the rightmost outlet; 71 | #X text 78 70 get a marker with specific id; 72 | #X text 118 150 get a region with specific id; 73 | #X text 186 206 retrieve all regions; 74 | #X text 460 84 parse marker/region info; 75 | #X text 394 303 and BEFORE starting playback; 76 | #X text 394 286 this only works AFTER opening a file; 77 | #X msg 372 170 set \$1; 78 | #X obj 339 176 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 79 | -1 -1; 80 | #X text 399 267 set playhead to a certain position in [samples]; 81 | #X text 27 29 retrieving markers/regions only works AFTER opening a 82 | file; 83 | #X connect 0 0 1 0; 84 | #X connect 2 0 1 0; 85 | #X connect 3 0 1 0; 86 | #X connect 4 0 1 0; 87 | #X connect 5 0 4 0; 88 | #X connect 6 0 3 0; 89 | #X connect 7 0 9 0; 90 | #X connect 8 0 1 0; 91 | #X connect 9 0 10 0; 92 | #X connect 9 1 12 0; 93 | #X connect 10 0 21 0; 94 | #X connect 10 1 21 0; 95 | #X connect 10 2 21 0; 96 | #X connect 11 0 8 0; 97 | #X connect 21 0 11 0; 98 | #X connect 22 0 11 0; 99 | #X restore 101 207 pd marker/regions; 100 | #X obj 300 323 s info-\$0; 101 | #X connect 0 0 1 0; 102 | #X connect 0 1 8 0; 103 | #X connect 3 0 16 0; 104 | #X connect 4 0 5 0; 105 | #X connect 6 0 7 0; 106 | #X connect 8 0 9 0; 107 | #X connect 8 1 2 0; 108 | #X connect 9 0 6 0; 109 | #X connect 9 1 6 1; 110 | #X connect 9 2 33 0; 111 | #X connect 10 0 11 0; 112 | #X connect 12 0 13 0; 113 | #X connect 14 0 15 0; 114 | #X connect 16 0 4 0; 115 | #X connect 16 1 10 0; 116 | #X connect 16 2 12 0; 117 | #X connect 16 3 14 0; 118 | #X connect 16 4 17 0; 119 | #X connect 16 5 19 0; 120 | #X connect 16 6 0 0; 121 | #X connect 16 6 44 0; 122 | #X connect 17 0 18 0; 123 | #X connect 19 0 20 0; 124 | #X connect 21 0 16 0; 125 | #X connect 23 0 16 0; 126 | #X connect 24 0 25 0; 127 | #X connect 25 0 23 0; 128 | #X connect 32 0 34 0; 129 | #X connect 33 0 32 0; 130 | #X connect 43 0 16 0; 131 | -------------------------------------------------------------------------------- /libambix/src/utils.c: -------------------------------------------------------------------------------- 1 | /* utils.c - various utilities -*- c -*- 2 | 3 | Copyright © 2012 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | #include "private.h" 25 | #include 26 | #include 27 | 28 | uint32_t ambix_order2channels(uint32_t order) { 29 | /* L=(N+1)^2 */ 30 | return (order+1)*(order+1); 31 | } 32 | int32_t ambix_channels2order(uint32_t channels) { 33 | /* L=(N+1)^2 */ 34 | int32_t order1=(int32_t)sqrt((double)channels); 35 | 36 | if(order1*order1==channels) { /* expanded set must be a full set */ 37 | return order1-1; 38 | } 39 | 40 | return -1; 41 | } 42 | 43 | int ambix_is_fullset(uint32_t channels) { 44 | return (ambix_order2channels(ambix_channels2order(channels))==channels); 45 | } 46 | 47 | 48 | void _ambix_print_info(const ambix_info_t*info) { 49 | printf("AMBIX_INFO %p\n", info); 50 | if(!info)return; 51 | printf(" frames\t: %d\n", (int)(info->frames)); 52 | printf(" samplerate\t: %f\n", info->samplerate); 53 | printf(" sampleformat\t: %d\n", info->sampleformat); 54 | printf(" fileformat\t: %d\n", info->fileformat); 55 | printf(" ambichannels\t: %d\n", info->ambichannels); 56 | printf(" otherchannels\t: %d\n", info->extrachannels); 57 | } 58 | 59 | void _ambix_print_matrix(const ambix_matrix_t*mtx) { 60 | printf("matrix %p", mtx); 61 | if(mtx) { 62 | float32_t**data=mtx->data; 63 | uint32_t r, c; 64 | printf(" [%dx%d] = %p\n", mtx->rows, mtx->cols, mtx->data); 65 | for(r=0; rrows; r++) { 66 | for(c=0; ccols; c++) { 67 | printf("%08f ", data[r][c]); 68 | } 69 | printf("\n"); 70 | } 71 | } 72 | printf("\n"); 73 | 74 | } 75 | 76 | void _ambix_print_markers(const ambix_t*ambix) 77 | { 78 | if (ambix->markers) { 79 | int i; 80 | for (i=0; i < ambix->num_markers; i++) { 81 | printf(" marker %d: name: %s position: %f \n", i, ambix->markers[i].name, ambix->markers[i].position); 82 | } 83 | } 84 | } 85 | void _ambix_print_regions(const ambix_t*ambix) 86 | { 87 | if (ambix->regions) { 88 | int i; 89 | for (i=0; i < ambix->num_regions; i++) { 90 | printf(" region %d: name: %s start_position: %f end_position: %f \n", i, ambix->regions[i].name, ambix->regions[i].start_position, ambix->regions[i].end_position); 91 | } 92 | } 93 | } 94 | 95 | void _ambix_print_ambix(const ambix_t*ambix) { 96 | printf("AMBIX %p\n", ambix); 97 | if(!ambix)return; 98 | 99 | printf(" private\t: %p\n", ambix->private_data); 100 | printf(" is_AMBIX\t: %d\n", ambix->is_AMBIX); 101 | printf(" format\t: %d\n", ambix->format); 102 | printf(" filemode\t: %d\n", ambix->filemode); 103 | printf(" byteswap\t: %d\n", ambix->byteswap); 104 | printf(" channels\t: %d\n", ambix->channels); 105 | printf(" info\t:\n"); 106 | _ambix_print_info(&ambix->info); 107 | printf(" realinfo\t:\n"); 108 | _ambix_print_info(&ambix->realinfo); 109 | printf(" matrix\t:\n"); 110 | _ambix_print_matrix(&ambix->matrix); 111 | printf(" matrix2\t:\n"); 112 | _ambix_print_matrix(&ambix->matrix2); 113 | printf(" use_matrix\t: %d\n", ambix->use_matrix); 114 | printf(" adaptorbuffer\t: %p\n", ambix->adaptorbuffer); 115 | printf(" adaptorbuffersize\t: %d\n", (int)(ambix->adaptorbuffersize)); 116 | printf(" ambisonics_order\t: %d\n", ambix->ambisonics_order); 117 | printf(" num_markers\t: %d\n", ambix->num_markers); 118 | _ambix_print_markers(ambix); 119 | printf(" num_regions\t: %d\n", ambix->num_regions); 120 | _ambix_print_regions(ambix); 121 | printf(" startedReading\t: %d\n", ambix->startedReading); 122 | printf(" startedWriting\t: %d\n", ambix->startedWriting); 123 | } 124 | 125 | 126 | void _ambix_swap4array(uint32_t*data, uint64_t datasize) { 127 | uint64_t i; 128 | for(i=0; i is given in samples per channels (unlike 33 | [readsf~] where you specify it in bytes per channel); 34 | #X text 43 525 see also:; 35 | #X text 220 280 arguments: <#ambioutlet~s:4> <#extraoutlet~s:0> 36 | ; 37 | #X text 200 18 [ambix_readX~] read an AMBIsonics eXchange file (EXTENDED 38 | ; 39 | #X text 215 47 The [ambix_readX~] reads an ambix soundfile into it's 40 | signal outputs \, much like [readsf~] for normal soundfiles.; 41 | #X obj 74 277 ambix_readX~ 4 2; 42 | #X obj 45 468 print matrix; 43 | #X obj 45 313 t a a; 44 | #X text 220 186 The ambisonics channels will be presented AS-IS. In 45 | order to obtain a full standard set of ambisonics channels (SN3D \, 46 | ACN) \, you will need to multiply the channels with the adaptor matrix 47 | you will get through the 1st outlet (e.g. using iemmatrix' [mtx_*~] 48 | ; 49 | #X obj 145 527 ambix_read~; 50 | #X obj 77 372 env~; 51 | #X floatatom 77 392 5 0 0 3 ACN0 - -, f 5; 52 | #X obj 112 406 env~; 53 | #X floatatom 112 426 5 0 0 3 ACN1 - -, f 5; 54 | #X obj 152 406 env~; 55 | #X floatatom 152 426 5 0 0 3 ACN2 - -, f 5; 56 | #X obj 192 406 env~; 57 | #X floatatom 192 426 5 0 0 3 ACN3 - -, f 5; 58 | #X obj 77 350 mtx_*~ 4 4; 59 | #X obj 496 552 declare -lib iemmatrix; 60 | #X obj 232 527 ambix_info; 61 | #X obj 289 350 s info-\$0; 62 | #N canvas 923 305 706 352 marker/regions 0; 63 | #X msg 42 121 get_all_markers; 64 | #X obj 35 300 outlet; 65 | #X msg 88 206 get_all_regions; 66 | #X msg 75 171 get_region \$1; 67 | #X msg 31 93 get_marker \$1; 68 | #X floatatom 31 72 5 0 0 0 - - -, f 5; 69 | #X floatatom 75 151 5 0 0 0 - - -, f 5; 70 | #X obj 372 90 r info-\$0; 71 | #X msg 344 267 seek \$1; 72 | #X obj 372 112 route marker region; 73 | #X obj 372 139 route 0 1 2; 74 | #X floatatom 344 236 10 0 0 0 - - -, f 10; 75 | #X obj 455 139 route 0 1 2; 76 | #X text 145 119 retrieve all markers; 77 | #X text 26 9 MARKER/REGION Info is sent to the rightmost outlet; 78 | #X text 78 70 get a marker with specific id; 79 | #X text 118 150 get a region with specific id; 80 | #X text 186 206 retrieve all regions; 81 | #X text 460 84 parse marker/region info; 82 | #X text 394 303 and BEFORE starting playback; 83 | #X text 394 286 this only works AFTER opening a file; 84 | #X msg 372 170 set \$1; 85 | #X obj 339 176 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 86 | -1 -1; 87 | #X text 399 267 set playhead to a certain position in [samples]; 88 | #X text 27 29 retrieving markers/regions only works AFTER opening a 89 | file; 90 | #X connect 0 0 1 0; 91 | #X connect 2 0 1 0; 92 | #X connect 3 0 1 0; 93 | #X connect 4 0 1 0; 94 | #X connect 5 0 4 0; 95 | #X connect 6 0 3 0; 96 | #X connect 7 0 9 0; 97 | #X connect 8 0 1 0; 98 | #X connect 9 0 10 0; 99 | #X connect 9 1 12 0; 100 | #X connect 10 0 21 0; 101 | #X connect 10 1 21 0; 102 | #X connect 10 2 21 0; 103 | #X connect 11 0 8 0; 104 | #X connect 21 0 11 0; 105 | #X connect 22 0 11 0; 106 | #X restore 105 242 pd marker/regions; 107 | #X connect 0 0 1 0; 108 | #X connect 0 1 6 0; 109 | #X connect 3 0 30 0; 110 | #X connect 4 0 5 0; 111 | #X connect 6 0 7 0; 112 | #X connect 6 1 2 0; 113 | #X connect 7 0 4 0; 114 | #X connect 7 1 4 1; 115 | #X connect 7 2 22 0; 116 | #X connect 8 0 9 0; 117 | #X connect 10 0 11 0; 118 | #X connect 12 0 30 0; 119 | #X connect 14 0 30 0; 120 | #X connect 15 0 16 0; 121 | #X connect 16 0 14 0; 122 | #X connect 21 0 23 0; 123 | #X connect 22 0 21 0; 124 | #X connect 30 0 32 0; 125 | #X connect 30 1 43 1; 126 | #X connect 30 2 43 2; 127 | #X connect 30 3 43 3; 128 | #X connect 30 4 43 4; 129 | #X connect 30 5 8 0; 130 | #X connect 30 6 10 0; 131 | #X connect 30 7 0 0; 132 | #X connect 30 7 46 0; 133 | #X connect 32 0 31 0; 134 | #X connect 32 1 43 0; 135 | #X connect 35 0 36 0; 136 | #X connect 37 0 38 0; 137 | #X connect 39 0 40 0; 138 | #X connect 41 0 42 0; 139 | #X connect 43 0 35 0; 140 | #X connect 43 1 37 0; 141 | #X connect 43 2 39 0; 142 | #X connect 43 3 41 0; 143 | #X connect 47 0 30 0; 144 | -------------------------------------------------------------------------------- /libambix/tests/common.h: -------------------------------------------------------------------------------- 1 | /* tests/common.h - AMBIsonics eXchange Library test utilities -*- c -*- 2 | 3 | Copyright © 2012 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | #ifndef TESTS_COMMON_H 25 | #define TESTS_COMMON_H 26 | 27 | #include 28 | 29 | #ifdef HAVE_CONFIG_H 30 | # include "config.h" 31 | #endif 32 | 33 | #include 34 | #include 35 | static inline int my_exit(int i) {exit(i); return i;} 36 | static inline int pass(void) {return my_exit(0); } 37 | static inline int fail(void) {return my_exit(1); } 38 | static inline int skip(void) {return my_exit(77); } 39 | 40 | #include 41 | #include 42 | #define MARK() printf("%s:%d[%s]\n", __FILE__, __LINE__, __FUNCTION__) 43 | 44 | static inline int pass_if (int test, int line, const char *format, ...) 45 | { 46 | if (test) { 47 | va_list argptr ; 48 | printf("@%d: ", line); 49 | va_start (argptr, format) ; 50 | vprintf (format, argptr) ; 51 | va_end (argptr) ; 52 | printf("\n"); 53 | return pass(); 54 | } ; 55 | return test; 56 | } /* pass_if */ 57 | static inline int skip_if (int test, int line, const char *format, ...) 58 | { 59 | if (test) { 60 | va_list argptr ; 61 | printf("@%d: ", line); 62 | va_start (argptr, format) ; 63 | vprintf (format, argptr) ; 64 | va_end (argptr) ; 65 | printf("\n"); 66 | return skip(); 67 | } ; 68 | return test; 69 | } /* skip_if */ 70 | static inline int fail_if (int test, int line, const char *format, ...) 71 | { 72 | if (test) { 73 | va_list argptr ; 74 | printf("@%d: ", line); 75 | va_start (argptr, format) ; 76 | vprintf (format, argptr) ; 77 | va_end (argptr) ; 78 | printf("\n"); 79 | return fail(); 80 | } ; 81 | return test; 82 | } /* fail_if */ 83 | static inline int print_if (int test, int line, const char *format, ...) 84 | { 85 | if (test) { 86 | va_list argptr ; 87 | printf("@%d: ", line); 88 | va_start (argptr, format) ; 89 | vprintf (format, argptr) ; 90 | va_end (argptr) ; 91 | printf("\n"); 92 | } 93 | return test; 94 | } /* print_if */ 95 | 96 | typedef enum { 97 | INT16, 98 | INT32, 99 | FLOAT32, 100 | FLOAT64 101 | } ambixtest_presentationformat_t; 102 | 103 | 104 | void matrix_print(const ambix_matrix_t*mtx); 105 | float32_t matrix_diff(uint32_t line, const ambix_matrix_t*A, const ambix_matrix_t*B, float32_t eps); 106 | 107 | void data_print(ambixtest_presentationformat_t fmt, const void*data, uint64_t frames); 108 | float32_t data_diff(uint32_t line, ambixtest_presentationformat_t fmt, const void*A, const void*B, uint64_t frames, float32_t eps); 109 | 110 | size_t data_size(ambixtest_presentationformat_t fmt); 111 | void*data_calloc(ambixtest_presentationformat_t fmt, size_t nmembers); 112 | void data_transpose(float32_t*outdata, const float32_t*indata, uint32_t inrows, uint32_t incols); 113 | void*data_sine(ambixtest_presentationformat_t fmt, uint64_t frames, uint32_t channels, float32_t periods); 114 | void*data_ramp(ambixtest_presentationformat_t fmt, uint64_t frames, uint32_t channels); 115 | 116 | int64_t ambixtest_readf (ambix_t *ambix, ambixtest_presentationformat_t fmt, 117 | void*ambidata , uint64_t ambioffset, 118 | void*otherdata, uint64_t otheroffset, 119 | int64_t frames); 120 | int64_t ambixtest_writef (ambix_t *ambix, ambixtest_presentationformat_t fmt, 121 | const void*ambidata , const uint64_t ambioffset, 122 | const void*otherdata, const uint64_t otheroffset, 123 | int64_t frames); 124 | int ambixtest_rmfile(const char*path); 125 | int ambixtest_uniquenumber(void); 126 | /* write uniquish filename into 'inbuf' and return a pointer to it 127 | * if ext is NULL, it defaults to '.caf'*/ 128 | char*ambixtest_getfname(char*inbuf, size_t length, const char*path, const char*basename, const char*ext); 129 | #define FILENAME_MAIN ambixtest_getfname(alloca(1024), 1024, 0, argv[0], 0) 130 | #define FILENAME_FILE ambixtest_getfname(alloca(1024), 1024, 0, __FILE__, 0) 131 | 132 | #define STRINGIFY(x) #x 133 | #define STARTTEST printf("<<< running TEST %s[%04d]:%s\t", __FILE__, __LINE__, __FUNCTION__),printf 134 | #define STOPTEST printf(">>> test SUCCESS %s[%04d]:%s\t", __FILE__, __LINE__, __FUNCTION__),printf 135 | 136 | 137 | #endif /* TESTS_COMMON_H */ 138 | 139 | -------------------------------------------------------------------------------- /utils/ambix-matrix.c: -------------------------------------------------------------------------------- 1 | /* ambix-matrix - display ambix matrices -*- c -*- 2 | 3 | Copyright © 2012 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | #ifdef HAVE_CONFIG_H 24 | # include "config.h" 25 | #endif /* HAVE_CONFIG_H */ 26 | 27 | #include "ambix/ambix.h" 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | void print_version(const char*name); 34 | void print_usage(const char*name); 35 | 36 | typedef struct { 37 | ambix_matrixtype_t typ; 38 | const char*name; 39 | } matrix_map_t; 40 | 41 | #if 0 42 | static matrix_map_t matrixmap[] = { 43 | AMBIX_MATRIX_ZERO, "MATRIX_ZERO", 44 | AMBIX_MATRIX_ONE, "MATRIX_ONE", 45 | AMBIX_MATRIX_AMBIX, "MATRIX_AMBIX", 46 | AMBIX_MATRIX_N3D, "MATRIX_N3D", 47 | AMBIX_MATRIX_SID, "MATRIX_SID", 48 | AMBIX_MATRIX_FUMA, "MATRIX_FUMA", 49 | AMBIX_MATRIX_TO_AMBIX, "MATRIX_TO_AMBIX", 50 | AMBIX_MATRIX_TO_N3D, "MATRIX_TO_N3D", 51 | AMBIX_MATRIX_TO_SID, "MATRIX_TO_SID", 52 | AMBIX_MATRIX_TO_FUMA, "MATRIX_TO_FUMA", 53 | }; 54 | #endif 55 | 56 | 57 | static void printmatrix(const ambix_matrix_t*mtx) { 58 | printf("matrix %p", mtx); 59 | if(mtx) { 60 | float32_t**data=mtx->data; 61 | uint32_t r, c; 62 | printf(" [%dx%d] = %p\n", mtx->rows, mtx->cols, mtx->data); 63 | for(r=0; rrows; r++) { 64 | for(c=0; ccols; c++) { 65 | printf("%08f ", data[r][c]); 66 | } 67 | printf("\n"); 68 | } 69 | } 70 | printf("\n"); 71 | } 72 | 73 | static void print_matrix(const char*name, ambix_matrixtype_t typ, uint32_t rows, uint32_t cols) { 74 | ambix_matrix_t*mtx=ambix_matrix_init(rows, cols, NULL); 75 | if(mtx) { 76 | ambix_matrix_t*result=ambix_matrix_fill(mtx, typ); 77 | if(result) { 78 | printf("%s\t%d\n", name, (int)typ); 79 | printmatrix(result); 80 | if(result!=mtx) 81 | ambix_matrix_destroy(result); 82 | } else { 83 | printf("couldn't create matrix [%dx%d] of type %s[%d]\n", rows, cols, name, typ); 84 | } 85 | 86 | ambix_matrix_destroy(mtx); 87 | } 88 | } 89 | 90 | 91 | int main(int argc, char**argv) { 92 | if(argc>1) { 93 | if((!strcmp(argv[1], "-V")) || (!strcmp(argv[1], "--version"))) 94 | print_version(argv[0]); 95 | if((!strcmp(argv[1], "-h")) || (!strcmp(argv[1], "--help"))) 96 | print_usage(argv[0]); 97 | } 98 | 99 | print_matrix("FuMa []" , AMBIX_MATRIX_FUMA, 1, 1); 100 | print_matrix("FuMa [h]" , AMBIX_MATRIX_FUMA, 4, 3); 101 | print_matrix("FuMa [f]" , AMBIX_MATRIX_FUMA, 4, 4); 102 | print_matrix("FuMa [hh]" , AMBIX_MATRIX_FUMA, 9, 5); 103 | print_matrix("FuMa [fh]" , AMBIX_MATRIX_FUMA, 9, 6); 104 | print_matrix("FuMa [ff]" , AMBIX_MATRIX_FUMA, 9, 9); 105 | print_matrix("FuMa [hhh]", AMBIX_MATRIX_FUMA, 16, 7); 106 | print_matrix("FuMa [fhh]", AMBIX_MATRIX_FUMA, 16, 8); 107 | print_matrix("FuMa [ffh]", AMBIX_MATRIX_FUMA, 16, 11); 108 | print_matrix("FuMa [fff]", AMBIX_MATRIX_FUMA, 16, 16); 109 | 110 | 111 | 112 | print_matrix("MaFu []" , AMBIX_MATRIX_TO_FUMA, 1, 1); 113 | print_matrix("MaFu [h]" , AMBIX_MATRIX_TO_FUMA, 3, 4); 114 | print_matrix("MaFu [f]" , AMBIX_MATRIX_TO_FUMA, 4, 4); 115 | print_matrix("MaFu [hh]" , AMBIX_MATRIX_TO_FUMA, 5, 9); 116 | print_matrix("MaFu [fh]" , AMBIX_MATRIX_TO_FUMA, 6, 9); 117 | print_matrix("MaFu [ff]" , AMBIX_MATRIX_TO_FUMA, 9, 9); 118 | print_matrix("MaFu [hhh]", AMBIX_MATRIX_TO_FUMA, 7, 16); 119 | print_matrix("MaFu [fhh]", AMBIX_MATRIX_TO_FUMA, 8, 16); 120 | print_matrix("MaFu [ffh]", AMBIX_MATRIX_TO_FUMA, 11, 16); 121 | print_matrix("MaFu [fff]", AMBIX_MATRIX_TO_FUMA, 16, 16); 122 | 123 | 124 | print_matrix("zero [16]", AMBIX_MATRIX_ZERO, 16, 16); 125 | print_matrix("one [16]", AMBIX_MATRIX_ONE, 16, 16); 126 | print_matrix("identity [16]", AMBIX_MATRIX_IDENTITY, 16, 16); 127 | 128 | print_matrix("SID [16]", AMBIX_MATRIX_SID, 16, 16); 129 | print_matrix("->SID [16]", AMBIX_MATRIX_TO_SID, 16, 16); 130 | 131 | print_matrix("N3D [16]", AMBIX_MATRIX_N3D, 16, 16); 132 | print_matrix("->N3D [16]", AMBIX_MATRIX_TO_N3D, 16, 16); 133 | 134 | return 0; 135 | } 136 | 137 | void print_usage(const char*name) { 138 | printf("\n"); 139 | printf("Usage: %s\n", name); 140 | printf("Print some standard matrices when dealing with ambisonics\n"); 141 | printf("(this may be of limited use when not debugging libambix).\n"); 142 | 143 | printf("\n"); 144 | printf("Options:\n"); 145 | printf(" -h, --help Print this help\n"); 146 | printf(" -V, --version Version information\n"); 147 | printf("\n"); 148 | 149 | #ifdef PACKAGE_BUGREPORT 150 | printf("Report bugs to: %s\n\n", PACKAGE_BUGREPORT); 151 | #endif 152 | #ifdef PACKAGE_URL 153 | printf("Home page: %s\n", PACKAGE_URL); 154 | #endif 155 | 156 | exit(1); 157 | } 158 | void print_version(const char*name) { 159 | #ifdef PACKAGE_VERSION 160 | printf("%s %s\n", name, PACKAGE_VERSION); 161 | #endif 162 | printf("\n"); 163 | printf("Copyright (C) 2012 Institute of Electronic Music and Acoustics (IEM), University of Music and Dramatic Arts (KUG), Graz, Austria.\n"); 164 | printf("\n"); 165 | printf("License LGPLv2.1: GNU Lesser GPL version 2.1 or later \n"); 166 | printf("This is free software: you are free to change and redistribute it.\n"); 167 | printf("There is NO WARRANTY, to the extent permitted by law.\n"); 168 | printf("\n"); 169 | printf("Written by IOhannes m zmoelnig \n"); 170 | exit(1); 171 | } 172 | -------------------------------------------------------------------------------- /m4/pkg.m4: -------------------------------------------------------------------------------- 1 | # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- 2 | # serial 1 (pkg-config-0.24) 3 | # 4 | # Copyright © 2004 Scott James Remnant . 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 as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, but 12 | # WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | # 20 | # As a special exception to the GNU General Public License, if you 21 | # distribute this file as part of a program that contains a 22 | # configuration script generated by Autoconf, you may include it under 23 | # the same distribution terms that you use for the rest of that program. 24 | 25 | # PKG_PROG_PKG_CONFIG([MIN-VERSION]) 26 | # ---------------------------------- 27 | AC_DEFUN([PKG_PROG_PKG_CONFIG], 28 | [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) 29 | m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) 30 | m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) 31 | AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) 32 | AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) 33 | AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) 34 | 35 | if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then 36 | AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) 37 | fi 38 | if test -n "$PKG_CONFIG"; then 39 | _pkg_min_version=m4_default([$1], [0.9.0]) 40 | AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) 41 | if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then 42 | AC_MSG_RESULT([yes]) 43 | else 44 | AC_MSG_RESULT([no]) 45 | PKG_CONFIG="" 46 | fi 47 | fi[]dnl 48 | ])# PKG_PROG_PKG_CONFIG 49 | 50 | # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 51 | # 52 | # Check to see whether a particular set of modules exists. Similar 53 | # to PKG_CHECK_MODULES(), but does not set variables or print errors. 54 | # 55 | # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 56 | # only at the first occurence in configure.ac, so if the first place 57 | # it's called might be skipped (such as if it is within an "if", you 58 | # have to call PKG_CHECK_EXISTS manually 59 | # -------------------------------------------------------------- 60 | AC_DEFUN([PKG_CHECK_EXISTS], 61 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 62 | if test -n "$PKG_CONFIG" && \ 63 | AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then 64 | m4_default([$2], [:]) 65 | m4_ifvaln([$3], [else 66 | $3])dnl 67 | fi]) 68 | 69 | # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) 70 | # --------------------------------------------- 71 | m4_define([_PKG_CONFIG], 72 | [if test -n "$$1"; then 73 | pkg_cv_[]$1="$$1" 74 | elif test -n "$PKG_CONFIG"; then 75 | PKG_CHECK_EXISTS([$3], 76 | [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` 77 | test "x$?" != "x0" && pkg_failed=yes ], 78 | [pkg_failed=yes]) 79 | else 80 | pkg_failed=untried 81 | fi[]dnl 82 | ])# _PKG_CONFIG 83 | 84 | # _PKG_SHORT_ERRORS_SUPPORTED 85 | # ----------------------------- 86 | AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], 87 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 88 | if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then 89 | _pkg_short_errors_supported=yes 90 | else 91 | _pkg_short_errors_supported=no 92 | fi[]dnl 93 | ])# _PKG_SHORT_ERRORS_SUPPORTED 94 | 95 | 96 | # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], 97 | # [ACTION-IF-NOT-FOUND]) 98 | # 99 | # 100 | # Note that if there is a possibility the first call to 101 | # PKG_CHECK_MODULES might not happen, you should be sure to include an 102 | # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac 103 | # 104 | # 105 | # -------------------------------------------------------------- 106 | AC_DEFUN([PKG_CHECK_MODULES], 107 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 108 | AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl 109 | AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl 110 | 111 | pkg_failed=no 112 | AC_MSG_CHECKING([for $1]) 113 | 114 | _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) 115 | _PKG_CONFIG([$1][_LIBS], [libs], [$2]) 116 | 117 | m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS 118 | and $1[]_LIBS to avoid the need to call pkg-config. 119 | See the pkg-config man page for more details.]) 120 | 121 | if test $pkg_failed = yes; then 122 | AC_MSG_RESULT([no]) 123 | _PKG_SHORT_ERRORS_SUPPORTED 124 | if test $_pkg_short_errors_supported = yes; then 125 | $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` 126 | else 127 | $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` 128 | fi 129 | # Put the nasty error message in config.log where it belongs 130 | echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD 131 | 132 | m4_default([$4], [AC_MSG_ERROR( 133 | [Package requirements ($2) were not met: 134 | 135 | $$1_PKG_ERRORS 136 | 137 | Consider adjusting the PKG_CONFIG_PATH environment variable if you 138 | installed software in a non-standard prefix. 139 | 140 | _PKG_TEXT])[]dnl 141 | ]) 142 | elif test $pkg_failed = untried; then 143 | AC_MSG_RESULT([no]) 144 | m4_default([$4], [AC_MSG_FAILURE( 145 | [The pkg-config script could not be found or is too old. Make sure it 146 | is in your PATH or set the PKG_CONFIG environment variable to the full 147 | path to pkg-config. 148 | 149 | _PKG_TEXT 150 | 151 | To get pkg-config, see .])[]dnl 152 | ]) 153 | else 154 | $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS 155 | $1[]_LIBS=$pkg_cv_[]$1[]_LIBS 156 | AC_DEFINE(HAVE_$1[], [1], [Define to 1 if you have $1]) 157 | AC_MSG_RESULT([yes]) 158 | $3 159 | fi[]dnl 160 | ])# PKG_CHECK_MODULES 161 | -------------------------------------------------------------------------------- /utils/ambix-info.c: -------------------------------------------------------------------------------- 1 | /* ambix_info - display info about an ambix file -*- c -*- 2 | 3 | Copyright © 2012 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | #ifdef HAVE_CONFIG_H 24 | # include "config.h" 25 | #endif /* HAVE_CONFIG_H */ 26 | 27 | #include "ambix/ambix.h" 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | void print_usage(const char*name); 34 | void print_version(const char*name); 35 | 36 | void print_markers(ambix_t*ambix) 37 | { 38 | uint32_t num_markers = ambix_get_num_markers(ambix); 39 | if (num_markers) { 40 | ambix_marker_t *marker = NULL; 41 | uint32_t i; 42 | for (i=0; i < num_markers; i++) { 43 | marker = ambix_get_marker(ambix, i); 44 | if (marker) 45 | printf(" Marker %d: name: %s position: %f \n", i, marker->name, marker->position); 46 | } 47 | } 48 | } 49 | void print_regions(ambix_t*ambix) 50 | { 51 | uint32_t num_regions = ambix_get_num_regions(ambix); 52 | if (num_regions) { 53 | ambix_region_t *region = NULL; 54 | uint32_t i; 55 | for (i=0; i < num_regions; i++) { 56 | region = ambix_get_region(ambix, i); 57 | printf(" Region %d: name: %s start_position: %f end_position: %f \n", i, region->name, region->start_position, region->end_position); 58 | } 59 | } 60 | } 61 | 62 | void printinfo(const char*path) { 63 | ambix_info_t info; 64 | ambix_t*ambix; 65 | const ambix_matrix_t*matrix; 66 | memset(&info, 0, sizeof(info)); 67 | 68 | printf("Open file '%s': ", path); 69 | 70 | ambix=ambix_open(path, AMBIX_READ, &info); 71 | if(!ambix) { 72 | printf("failed\n"); 73 | return; 74 | } else 75 | printf("OK\n"); 76 | 77 | printf("Frames\t: %d\n", (int)(info.frames)); 78 | 79 | printf("Samplerate\t: %f\n", info.samplerate); 80 | 81 | printf("Sampleformat\t: %d (", info.sampleformat); 82 | switch(info.sampleformat) { 83 | case(AMBIX_SAMPLEFORMAT_NONE): printf("NONE"); break; 84 | case(AMBIX_SAMPLEFORMAT_PCM16): printf("PCM16"); break; 85 | case(AMBIX_SAMPLEFORMAT_PCM24): printf("PCM24"); break; 86 | case(AMBIX_SAMPLEFORMAT_PCM32): printf("PCM32"); break; 87 | case(AMBIX_SAMPLEFORMAT_FLOAT32): printf("FLOAT32"); break; 88 | case(AMBIX_SAMPLEFORMAT_FLOAT64): printf("FLOAT64"); break; 89 | default: printf("**unknown**"); 90 | } 91 | printf(")\n"); 92 | 93 | printf("ambiXformat\t: %d (", info.fileformat); 94 | switch(info.fileformat) { 95 | case(AMBIX_NONE): printf("NONE"); break; 96 | case(AMBIX_BASIC): printf("BASIC"); break; 97 | case(AMBIX_EXTENDED): printf("EXTENDED"); break; 98 | default: printf("**unknown** 0x%04X", info.fileformat); 99 | } 100 | printf(")\n"); 101 | 102 | printf("Ambisonics channels\t: %d\n", info.ambichannels); 103 | printf("Non-Ambisonics channels\t: %d\n", info.extrachannels); 104 | 105 | 106 | 107 | matrix=ambix_get_adaptormatrix(ambix); 108 | printf("Reconstruction matrix\t: "); 109 | if(!matrix) { 110 | printf("**none**"); 111 | } else { 112 | uint32_t r, c; 113 | printf("[%dx%d]\n", matrix->rows, matrix->cols); 114 | for(r=0; rrows; r++) { 115 | printf("\t"); 116 | for(c=0; ccols; c++) { 117 | printf("%.6f ", matrix->data[r][c]); 118 | } 119 | printf("\n"); 120 | } 121 | } 122 | printf("\n"); 123 | 124 | printf("Number of Markers\t: %d\n", ambix_get_num_markers(ambix)); 125 | print_markers(ambix); 126 | printf("Number of Regions\t: %d\n", ambix_get_num_regions(ambix)); 127 | print_regions(ambix); 128 | 129 | printf("Close file '%s': ", path); 130 | if(AMBIX_ERR_SUCCESS!=ambix_close(ambix)) 131 | printf("failed\n"); 132 | else 133 | printf("OK\n"); 134 | } 135 | 136 | int main(int argc, char**argv) { 137 | if(argc>1) { 138 | int i; 139 | if((!strcmp(argv[1], "-V")) || (!strcmp(argv[1], "--version"))) 140 | print_version(argv[0]); 141 | if((!strcmp(argv[1], "-h")) || (!strcmp(argv[1], "--help"))) 142 | print_usage(argv[0]); 143 | 144 | for(i=1; i\n"); 186 | printf("This is free software: you are free to change and redistribute it.\n"); 187 | printf("There is NO WARRANTY, to the extent permitted by law.\n"); 188 | printf("\n"); 189 | printf("Written by IOhannes m zmoelnig \n"); 190 | exit(1); 191 | } 192 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT([ambix],[0.1.2],[https://git.iem.at/ambisonics/libambix], 2 | [libambix],[http://ambisonics.iem.at/xchange/format]) 3 | AM_INIT_AUTOMAKE([foreign]) 4 | 5 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 6 | 7 | AM_PROG_LIBTOOL 8 | 9 | AC_CONFIG_MACRO_DIR([m4]) 10 | 11 | AC_CONFIG_HEADERS([config.h]) 12 | 13 | AC_CONFIG_FILES([Makefile]) 14 | AC_CONFIG_FILES([libambix/Makefile libambix/src/Makefile libambix/tests/Makefile libambix/tests/data/Makefile]) 15 | AC_CONFIG_FILES([libambix/libambix.pc]) 16 | AC_CONFIG_FILES([utils/Makefile utils/jcommon/Makefile]) 17 | AC_CONFIG_FILES([doc/Makefile]) 18 | AC_CONFIG_FILES([replacement/Makefile]) 19 | 20 | AC_CONFIG_FILES([samples/Makefile]) 21 | AC_CONFIG_FILES([samples/pd/Makefile samples/pd/ambix-meta.pd]) 22 | 23 | AC_CONFIG_FILES([build/Makefile build/w32-vs2008/Makefile]) 24 | 25 | IEM_OPERATING_SYSTEM 26 | 27 | 28 | AC_PROG_INSTALL 29 | 30 | AC_LANG_C 31 | AC_PROG_CC 32 | AC_PROG_MAKE_SET 33 | AM_PROG_CC_C_O 34 | 35 | m4_ifdef([AC_PROG_OBJC], [AC_PROG_OBJC]) 36 | 37 | #------------------------------------------------------------------------------------ 38 | # Rules for library version information: 39 | # 40 | # 1. Start with version information of `0:0:0' for each libtool library. 41 | # 2. Update the version information only immediately before a public release of 42 | # your software. More frequent updates are unnecessary, and only guarantee 43 | # that the current interface number gets larger faster. 44 | # 3. If the library source code has changed at all since the last update, then 45 | # increment revision (`c:r:a' becomes `c:r+1:a'). 46 | # 4. If any interfaces have been added, removed, or changed since the last update, 47 | # increment current, and set revision to 0. 48 | # 5. If any interfaces have been added since the last public release, then increment 49 | # age. 50 | # 6. If any interfaces have been removed since the last public release, then set age 51 | # to 0. 52 | 53 | CLEAN_VERSION=`echo $PACKAGE_VERSION | $SED "s/p.*//"` 54 | VERSION_MINOR=`echo $CLEAN_VERSION | $SED "s/.*\.//"` 55 | 56 | SHARED_VERSION_INFO="0:$VERSION_MINOR:0" 57 | AC_SUBST(SHARED_VERSION_INFO) 58 | 59 | have_pd="no" 60 | IEM_CHECK_RTE 61 | AM_CONDITIONAL(HAVE_PUREDATA, [test "x$have_pd" = "xyes"]) 62 | 63 | AC_HEADER_STDC 64 | AC_CHECK_HEADERS([limits.h]) 65 | 66 | AM_CONDITIONAL(DISABLED, [test "xno" = "xyes"]) 67 | AM_CONDITIONAL(ENABLED, [test "xyes" = "xyes"]) 68 | 69 | 70 | AC_ARG_ENABLE(debug, 71 | AS_HELP_STRING([--enable-debug], 72 | [enable debugging build, default: no]), 73 | AS_CASE(["$enableval"], 74 | yes, debug=true, 75 | no, debug=false, 76 | AC_MSG_ERROR([bad value ${enableval} for --enable-debug])), 77 | [debug=false]) 78 | AM_CONDITIONAL(DEBUG, test x"$debug" = x"true") 79 | 80 | 81 | ## check for math 82 | AC_CHECK_LIB([m],[sqrt]) 83 | 84 | ## checks for libsndfile 85 | AC_ARG_WITH([sndfile], 86 | [AS_HELP_STRING([--with-sndfile], 87 | [use libsndfile as backend for reading ambix-files])], 88 | [], 89 | [with_sndfile=yes]) 90 | have_sndfile="no" 91 | AS_IF([test "x$with_sndfile" != xno], [ 92 | tmp_sndfile_CFLAGS="$CFLAGS" 93 | tmp_sndfile_LIBS="$LIBS" 94 | PKG_CHECK_MODULES([SNDFILE], [sndfile], [have_sndfile="yes"], [have_sndfile="no"]) 95 | 96 | if test "x$have_sndfile" = "xyes"; then 97 | CFLAGS="$CFLAGS $SNDFILE_CFLAGS" 98 | LIBS="$LIBS $SNDFILE_LIBS" 99 | AC_CHECK_HEADERS(sndfile.h) 100 | AC_SEARCH_LIBS([sf_set_chunk], [sndfile], [AC_DEFINE([HAVE_SF_SET_CHUNK], [1], [Define to 1 if libsndfile can set custom chunks using sf_set_chunk()])]) 101 | AC_SEARCH_LIBS([sf_get_chunk_iterator], [sndfile], [AC_DEFINE([HAVE_SF_GET_CHUNK_ITERATOR], [1], [Define to 1 if libsndfile can get custom chunks via an iterator])]) 102 | AC_CHECK_TYPES([SF_CHUNK_INFO], [], [], [[#include ]]) 103 | 104 | dnl a custom version of libsndfile used sf_command to write UUID-chunks 105 | AC_CHECK_TYPES([SF_UUID_INFO], [], [], [[#include ]]) 106 | fi 107 | 108 | CFLAGS="$tmp_sndfile_CFLAGS" 109 | LIBS="$tmp_sndfile_LIBS" 110 | ]) 111 | AM_CONDITIONAL(HAVE_SNDFILE, [test "x$have_sndfile" = "xyes"]) 112 | 113 | ## checks for CoreAudio frameworks 114 | AC_ARG_WITH([CoreAudio], 115 | [AS_HELP_STRING([--with-CoreAudio], 116 | [use CoreAudio as backend for reading ambix-files])], 117 | [], 118 | [with_CoreAudio=check]) 119 | have_audiotoolbox="no" 120 | AS_IF([test "x$with_CoreAudio" != xno], 121 | [ 122 | IEM_CHECK_FRAMEWORK([Foundation], 123 | IEM_CHECK_FRAMEWORK([AudioToolbox], 124 | [have_audiotoolbox="yes"]) 125 | ) 126 | ] 127 | ) 128 | AM_CONDITIONAL([HAVE_FRAMEWORK_AUDIOTOOLBOX], [test "x$have_audiotoolbox" = "xyes"]) 129 | 130 | ## checks for jack 131 | AC_ARG_WITH([jack], 132 | [AS_HELP_STRING([--with-jack], 133 | [use JACK for playback/recording of live sound])], 134 | [], 135 | [with_jack=yes]) 136 | have_jack="no" 137 | AS_IF([test "x$with_jack" != xno], [ 138 | tmp_jack_CFLAGS="$CFLAGS" 139 | tmp_jack_LIBS="$LIBS" 140 | 141 | PKG_CHECK_MODULES([JACK], [jack], [have_jack="yes"], [have_jack="no"]) 142 | 143 | CFLAGS="$tmp_jack_CFLAGS" 144 | LIBS="$tmp_jack_LIBS" 145 | ]) 146 | AM_CONDITIONAL(HAVE_JACK, [test "x$have_jack" = "xyes"]) 147 | 148 | ## checks for samplerate 149 | AC_ARG_WITH([samplerate], 150 | [AS_HELP_STRING([--with-samplerate], 151 | [use libsamplerate for samplerate-conversion])], 152 | [], 153 | [with_samplerate=yes]) 154 | have_samplerate="no" 155 | AS_IF([test "x$with_samplerate" != xno], [ 156 | tmp_samplerate_CFLAGS="$CFLAGS" 157 | tmp_samplerate_LIBS="$LIBS" 158 | 159 | PKG_CHECK_MODULES([SAMPLERATE], [samplerate], [have_samplerate="yes"], [have_samplerate="no"]) 160 | 161 | CFLAGS="$tmp_samplerate_CFLAGS" 162 | LIBS="$tmp_samplerate_LIBS" 163 | ]) 164 | AM_CONDITIONAL(HAVE_SAMPLERATE, [test "x$have_samplerate" = "xyes"]) 165 | 166 | 167 | 168 | AC_CHECK_PROGS([DOXYGEN], [doxygen], [true]) 169 | AM_CONDITIONAL(HAVE_DOXYGEN, [test "x${DOXYGEN}" != "xtrue"]) 170 | AC_SUBST(DOXYGEN) 171 | 172 | AC_CHECK_FUNCS([strndup]) 173 | 174 | AX_PTHREAD 175 | 176 | # run unitttests in valgrind 177 | AC_SUBST(VALGRIND_CHECK_RULES) 178 | m4_ifdef([AX_VALGRIND_CHECK], [AX_VALGRIND_CHECK]) 179 | 180 | AC_OUTPUT 181 | -------------------------------------------------------------------------------- /libambix/src/uuid_chunk.c: -------------------------------------------------------------------------------- 1 | /* uuid_chunk.c - parse an UUID-chunk to extract relevant data -*- c -*- 2 | 3 | Copyright © 2012-2016 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | #include "private.h" 25 | 26 | #ifdef HAVE_STRING_H 27 | # include 28 | #endif /* HAVE_STRING_H */ 29 | #ifdef HAVE_STDLIB_H 30 | # include 31 | #endif /* HAVE_STDLIB_H */ 32 | 33 | /* on UUIDs: 34 | * ideally, we would use UUIDs based on an URI that indicates the format-version 35 | * e.g. URI="http://ambisonics.iem.at/xchange/format/1.0" 36 | * this can be converted to an UUID(v5), using a small perl-script like 37 | * @code 38 | #!/usr/bin/perl 39 | use UUID::Tiny; 40 | my $v5_url_UUIDs = create_UUID_as_string(UUID_V5, UUID_NS_URL, $ARGV[0]); 41 | print "$v5_url_UUIDs\n"; 42 | * @endcode 43 | * 44 | * this gives us: 45 | * http://ambisonics.iem.at/xchange/format/1.0 1ad318c3-00e5-5576-be2d-0dca2460bc89 46 | * http://ambisonics.iem.at/xchange/format/2.0 7c449194-05e1-58e4-9463-d0f8f2a1ed0f 47 | * http://ambisonics.iem.at/xchange/format/3.0 50c26359-d96d-5a67-bc19-db124f7606d0 48 | */ 49 | 50 | #include 51 | 52 | #if 0 53 | static void _ambix_printUUID4(const char data[2]) { 54 | unsigned char data0=data[0]; 55 | unsigned char data1=data[1]; 56 | printf("%02x%02x", data0, data1); 57 | } 58 | static void _ambix_printUUID(const char data[16]) { 59 | /* 8-4-4-4-12 */ 60 | _ambix_printUUID4(data);data+=2; 61 | _ambix_printUUID4(data);data+=2; 62 | printf("-"); 63 | _ambix_printUUID4(data);data+=2; 64 | printf("-"); 65 | _ambix_printUUID4(data);data+=2; 66 | printf("-"); 67 | _ambix_printUUID4(data);data+=2; 68 | printf("-"); 69 | _ambix_printUUID4(data);data+=2; 70 | _ambix_printUUID4(data);data+=2; 71 | _ambix_printUUID4(data);data+=2; 72 | } 73 | #endif 74 | /* 75 | * uarg, this is not a UUID! 76 | * (well it is...UUID::Tiny thinks it's a v2 (DCE security) UUID 77 | */ 78 | static const char _ambix_uuid_v1_[]="IEM.AT/AMBIX/XML"; 79 | /* 80 | * that's a better UUID, based on a SHA1-hash of "http://ambisonics.iem.at/xchange/format/1.0" 81 | */ 82 | static const char _ambix_uuid_v1[]={0x1a, 0xd3, 0x18, 0xc3, 0x00, 0xe5, 0x55, 0x76, 0xbe, 0x2d, 0x0d, 0xca, 0x24, 0x60, 0xbc, 0x89}; 83 | const char* _ambix_getUUID(uint32_t version) { 84 | switch(version) { 85 | default: 86 | break; 87 | case 1: 88 | return _ambix_uuid_v1; 89 | } 90 | return NULL; 91 | } 92 | 93 | uint32_t 94 | _ambix_checkUUID(const char data[16]) { 95 | if(!memcmp(data, _ambix_uuid_v1, 16)) 96 | return 1; 97 | /* compat mode: old AMBIXv1 UUID */ 98 | if(!memcmp(data, _ambix_uuid_v1_, 16)) 99 | return 1; 100 | return 0; 101 | } 102 | 103 | ambix_matrix_t* 104 | _ambix_uuid1_to_matrix(const void*vdata, uint64_t datasize, ambix_matrix_t*orgmtx, int swap) { 105 | const char*cdata=(const char*)vdata; 106 | ambix_matrix_t*mtx=orgmtx; 107 | uint32_t rows; 108 | uint32_t cols; 109 | uint64_t size; 110 | uint32_t index; 111 | 112 | if(datasize<(sizeof(rows)+sizeof(cols))) 113 | return NULL; 114 | 115 | index = 0; 116 | 117 | memcpy(&rows, cdata+index, sizeof(uint32_t)); 118 | index += sizeof(uint32_t); 119 | 120 | memcpy(&cols, cdata+index, sizeof(uint32_t)); 121 | index += sizeof(uint32_t); 122 | 123 | if(swap) { 124 | rows=swap4(rows); 125 | cols=swap4(cols); 126 | } 127 | 128 | size=(uint64_t)rows*cols; 129 | 130 | if(rows<1 || cols<1 || size < 1) 131 | goto cleanup; 132 | 133 | if(size*sizeof(float32_t) > datasize) { 134 | goto cleanup; 135 | } 136 | 137 | if(!mtx) { 138 | mtx=(ambix_matrix_t*)calloc(1, sizeof(ambix_matrix_t)); 139 | if(!mtx) 140 | goto cleanup; 141 | } 142 | 143 | if(!ambix_matrix_init(rows, cols, mtx)) 144 | goto cleanup; 145 | 146 | if(swap) { 147 | if(_ambix_matrix_fill_data_byteswapped(mtx, (number32_t*)(cdata+index)) != AMBIX_ERR_SUCCESS) 148 | goto cleanup; 149 | } else { 150 | if(ambix_matrix_fill_data(mtx, (float32_t*)(cdata+index)) != AMBIX_ERR_SUCCESS) 151 | goto cleanup; 152 | } 153 | 154 | return mtx; 155 | 156 | cleanup: 157 | if(mtx && mtx!=orgmtx) { 158 | ambix_matrix_deinit(mtx); 159 | free(mtx); 160 | mtx=NULL; 161 | } 162 | return NULL; 163 | } 164 | 165 | 166 | uint64_t 167 | _ambix_matrix_to_uuid1(const ambix_matrix_t*matrix, void*vdata, int swap) { 168 | char*cdata=(char*)vdata; 169 | const char*uuid=_ambix_getUUID(1); 170 | uint64_t index=0; 171 | uint64_t datasize=0; 172 | uint32_t rows=matrix->rows; 173 | uint32_t cols=matrix->cols; 174 | float32_t**mtx=matrix->data; 175 | if(!uuid) 176 | return 0; 177 | datasize+=16; /* reserved for the UUID */ 178 | 179 | datasize+=sizeof(uint32_t); /* rows */ 180 | datasize+=sizeof(uint32_t); /* cols */ 181 | datasize+=(uint64_t)rows*(uint64_t)cols*sizeof(float32_t); /* data */ 182 | 183 | if(vdata) { 184 | uint32_t*uidata=(uint32_t*)vdata; 185 | uint64_t r; 186 | uint32_t*swapdata; 187 | uint64_t elements=(uint64_t)rows*(uint64_t)cols; 188 | memcpy(cdata, uuid, 16); 189 | index+=16; 190 | 191 | //swapdata=cdata+index; 192 | swapdata=uidata+(index / sizeof(uint32_t)); 193 | 194 | memcpy(cdata+index, &rows, sizeof(uint32_t)); 195 | index+=sizeof(uint32_t); 196 | 197 | memcpy(cdata+index, &cols, sizeof(uint32_t)); 198 | index+=sizeof(uint32_t); 199 | 200 | for(r=0; r. 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | 22 | */ 23 | 24 | #if 0 25 | # define MARK printf("%s[%d]:%s\t", __FILE__, __LINE__, __FUNCTION__), printf 26 | #else 27 | static void noop(const char*format, ...) {} 28 | # define MARK noop 29 | #endif 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | #include 38 | 39 | #include "winhacks.h" 40 | 41 | /************************* ambix_info object ******************************/ 42 | 43 | /* [ambix_info~] uses the Posix threads package; for the moment we're Linux 44 | only although this should be portable to the other platforms. 45 | 46 | Each instance of ambix_info~ owns a "child" thread for doing the unix (MSW?) file 47 | reading. The parent thread signals the child each time: 48 | (1) a file wants opening or closing; 49 | (2) we've eaten another 1/16 of the shared buffer (so that the 50 | child thread should check if it's time to read some more.) 51 | The child signals the parent whenever a read has completed. Signalling 52 | is done by setting "conditions" and putting data in mutex-controlled common 53 | areas. 54 | */ 55 | 56 | static t_class *ambix_info_class; 57 | 58 | typedef struct _ambix_info { 59 | t_object x_obj; 60 | t_canvas *x_canvas; 61 | 62 | t_outlet*x_outlet; 63 | } t_ambix_info; 64 | 65 | 66 | /* tries to expand the given filename to it's full glory) */ 67 | t_symbol*get_filename(t_canvas*canvas, t_symbol*s) { 68 | int fd=0; 69 | char buf[MAXPDSTRING]; 70 | char result[MAXPDSTRING]; 71 | char*bufptr; 72 | 73 | if(!s || !s->s_name || !*s->s_name) { 74 | return NULL; 75 | } 76 | 77 | if ((fd=canvas_open(canvas, s->s_name, "", buf, &bufptr, MAXPDSTRING, 1))>=0){ 78 | sys_close(fd); 79 | snprintf(result, MAXPDSTRING-1, "%s/%s", buf, bufptr); 80 | result[MAXPDSTRING-1]=0; 81 | return gensym(result); 82 | } else if(canvas) { 83 | canvas_makefilename(canvas, s->s_name, result, MAXPDSTRING); 84 | return gensym(result); 85 | } 86 | return s; 87 | } 88 | 89 | 90 | /******** the object proper runs in the calling (parent) thread ****/ 91 | 92 | static void *ambix_info_new(void) { 93 | t_ambix_info*x = (t_ambix_info *)pd_new(ambix_info_class); 94 | x->x_outlet = outlet_new(&x->x_obj, &s_bang); 95 | x->x_canvas = canvas_getcurrent(); 96 | return (x); 97 | } 98 | 99 | static void ambix_info_open(t_ambix_info *x, t_symbol*s) { 100 | t_atom atoms[1]; 101 | 102 | ambix_info_t ainfo; 103 | ambix_t*ambix=NULL; 104 | const ambix_matrix_t*matrix=NULL; 105 | 106 | t_symbol*filesym=get_filename(x->x_canvas, s); 107 | const char*filename=(filesym!=NULL)?filesym->s_name:NULL; 108 | 109 | memset(&ainfo, 0, sizeof(ainfo)); 110 | 111 | ambix=ambix_open(filename, AMBIX_READ, &ainfo); 112 | 113 | if(!ambix) { 114 | pd_error(x, "[ambix_info]: unable to open '%s'", filename); 115 | return; 116 | } 117 | 118 | 119 | /* filename */ 120 | SETSYMBOL(atoms+0, filesym); 121 | outlet_anything(x->x_outlet, gensym("filename"), 1, atoms); 122 | 123 | /* ambix fileformat */ 124 | switch(ainfo.fileformat) { 125 | case AMBIX_NONE: SETSYMBOL(atoms+0, gensym("NONE")); break; 126 | case AMBIX_BASIC: SETSYMBOL(atoms+0, gensym("BASIC")); break; 127 | case AMBIX_EXTENDED: SETSYMBOL(atoms+0, gensym("EXTENDED")); break; 128 | default: SETSYMBOL(atoms+0, gensym("unknown")); break; 129 | } 130 | outlet_anything(x->x_outlet, gensym("fileformat"), 1, atoms); 131 | 132 | /* number of ambisonics channels */ 133 | SETFLOAT(atoms+0, (t_float)(ainfo.ambichannels)); 134 | outlet_anything(x->x_outlet, gensym("ambichannels"), 1, atoms); 135 | 136 | /* number of non-ambisonics channels */ 137 | SETFLOAT(atoms+0, (t_float)(ainfo.extrachannels)); 138 | outlet_anything(x->x_outlet, gensym("extrachannels"), 1, atoms); 139 | 140 | /* ambix sampleformat */ 141 | switch(ainfo.sampleformat) { 142 | case AMBIX_SAMPLEFORMAT_NONE: SETSYMBOL(atoms+0, gensym("NONE")); break; 143 | case AMBIX_SAMPLEFORMAT_PCM16: SETSYMBOL(atoms+0, gensym("PCM16")); break; 144 | case AMBIX_SAMPLEFORMAT_PCM24: SETSYMBOL(atoms+0, gensym("PCM24")); break; 145 | case AMBIX_SAMPLEFORMAT_PCM32: SETSYMBOL(atoms+0, gensym("PCM32")); break; 146 | case AMBIX_SAMPLEFORMAT_FLOAT32: SETSYMBOL(atoms+0, gensym("FLOAT32")); break; 147 | default: SETSYMBOL(atoms+0, gensym("unknown")); break; 148 | } 149 | outlet_anything(x->x_outlet, gensym("sampleformat"), 1, atoms); 150 | 151 | /* samplerate of file */ 152 | SETFLOAT(atoms+0, (t_float)(ainfo.samplerate)); 153 | outlet_anything(x->x_outlet, gensym("samplerate"), 1, atoms); 154 | 155 | /* number of sample frames in file */ 156 | SETFLOAT(atoms+0, (t_float)(ainfo.frames)); 157 | outlet_anything(x->x_outlet, gensym("frames"), 1, atoms); 158 | 159 | matrix=ambix_get_adaptormatrix(ambix); 160 | 161 | if(matrix) { 162 | int size=matrix->rows*matrix->cols; 163 | if(size) { 164 | uint32_t r, c, index; 165 | t_atom*ap=(t_atom*)getbytes(sizeof(t_atom)*(size+2)); 166 | SETFLOAT(ap+0, matrix->rows); 167 | SETFLOAT(ap+1, matrix->cols); 168 | 169 | index=2; 170 | for(r=0; rrows; r++) { 171 | for(c=0; ccols; c++) { 172 | SETFLOAT(ap+index, matrix->data[r][c]); 173 | index++; 174 | } 175 | } 176 | 177 | outlet_anything(x->x_outlet, gensym("matrix"), size+2, ap); 178 | freebytes(ap, sizeof(t_atom)*(size+2)); 179 | } 180 | } 181 | ambix_close(ambix); 182 | } 183 | 184 | static void ambix_info_free(t_ambix_info *x) { 185 | /* request QUIT and wait for acknowledge */ 186 | outlet_free(x->x_outlet); 187 | } 188 | 189 | AMBIX_EXPORT 190 | void ambix_info_setup(void) { 191 | ambix_info_class = class_new(gensym("ambix_info"), (t_newmethod)ambix_info_new, 192 | (t_method)ambix_info_free, sizeof(t_ambix_info), 0, A_GIMME, A_NULL); 193 | 194 | class_addmethod(ambix_info_class, (t_method)ambix_info_open, gensym("open"), A_SYMBOL, A_NULL); 195 | if(0) { 196 | MARK("setup"); 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /libambix/tests/common_extended.c: -------------------------------------------------------------------------------- 1 | /* extended - test ambix extended 2 | 3 | Copyright © 2012-2016 IOhannes m zmölnig . 4 | Institute of Electronic Music and Acoustics (IEM), 5 | University of Music and Dramatic Arts, Graz 6 | 7 | This file is part of libambix 8 | 9 | libambix is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as 11 | published by the Free Software Foundation; either version 2.1 of 12 | the License, or (at your option) any later version. 13 | 14 | libambix is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public 20 | License along with this program; if not, see . 21 | */ 22 | 23 | #include "common.h" 24 | #include 25 | #include 26 | 27 | 28 | void check_create_extended(const char*path, ambix_sampleformat_t format, uint32_t chunksize, float32_t eps) { 29 | ambix_info_t info, rinfo, winfo; 30 | ambix_t*ambix=NULL; 31 | float32_t*orgambidata,*ambidata,*resultambidata; 32 | float32_t*orgotherdata,*otherdata,*resultotherdata; 33 | uint32_t framesize=441000; 34 | uint32_t ambichannels=4; 35 | uint32_t extrachannels=2; 36 | float32_t periods=20000; 37 | ambix_matrix_t eye={0,0,NULL}; 38 | const ambix_matrix_t*eye2=NULL; 39 | int64_t err64, gotframes; 40 | float32_t diff=0.; 41 | STARTTEST("\n"); 42 | 43 | printf("test using '%s' [%d] with chunks of %d and eps=%f\n", path, (int)format, (int)chunksize, eps); 44 | 45 | resultambidata=(float32_t*)calloc(ambichannels*framesize, sizeof(float32_t)); 46 | ambidata=(float32_t*)calloc(ambichannels*framesize, sizeof(float32_t)); 47 | 48 | resultotherdata=(float32_t*)calloc(extrachannels*framesize, sizeof(float32_t)); 49 | otherdata=(float32_t*)calloc(extrachannels*framesize, sizeof(float32_t)); 50 | 51 | ambix_matrix_init(ambichannels, ambichannels, &eye); 52 | ambix_matrix_fill(&eye, AMBIX_MATRIX_IDENTITY); 53 | 54 | memset(&winfo, 0, sizeof(winfo)); 55 | memset(&info, 0, sizeof(info)); 56 | 57 | info.fileformat=AMBIX_EXTENDED; 58 | info.ambichannels=ambichannels; 59 | info.extrachannels=extrachannels; 60 | info.samplerate=44100; 61 | info.sampleformat=format; 62 | 63 | memcpy(&rinfo, &info, sizeof(info)); 64 | 65 | ambix=ambix_open(path, AMBIX_WRITE, &rinfo); 66 | fail_if((NULL==ambix), __LINE__, "couldn't create ambix file '%s' for writing", path); 67 | 68 | orgambidata=data_sine (FLOAT32, framesize, ambichannels, periods); 69 | orgotherdata=data_ramp(FLOAT32, framesize, extrachannels); 70 | //data_print(FLOAT32, orgdata, 100); 71 | fail_if((NULL==orgambidata), __LINE__, "couldn't create ambidata %dx%d sine @ %f", (int)framesize, (int)ambichannels, (float)periods); 72 | fail_if((NULL==orgotherdata), __LINE__, "couldn't create otherdata %dx%d sine @ %f", (int)framesize, (int)extrachannels, (float)periods); 73 | 74 | memcpy(ambidata, orgambidata, framesize*ambichannels*sizeof(float32_t)); 75 | memcpy(otherdata, orgotherdata, framesize*extrachannels*sizeof(float32_t)); 76 | 77 | fail_if((AMBIX_ERR_SUCCESS!=ambix_set_adaptormatrix(ambix, &eye)), 78 | __LINE__, "failed setting adaptor matrix"); 79 | 80 | if(chunksize>0) { 81 | uint32_t subframe=chunksize; 82 | uint32_t chunks = framesize/chunksize; 83 | uint32_t framesleft=framesize; 84 | uint32_t frame; 85 | printf("writing %d chunks of %d frames\n", (int)chunks, (int)chunksize); 86 | for(frame=0; frameeps), __LINE__, "ambidata diff %f > %f", diff, eps); 103 | diff=data_diff(__LINE__, FLOAT32, orgotherdata, otherdata, framesize*extrachannels, eps); 104 | fail_if((diff>eps), __LINE__, "otherdata diff %f > %f", diff, eps); 105 | 106 | fail_if((AMBIX_ERR_SUCCESS!=ambix_close(ambix)), __LINE__, "closing ambix file %p", ambix); 107 | ambix=NULL; 108 | 109 | 110 | 111 | /* read data back */ 112 | ambix=ambix_open(path, AMBIX_READ, &rinfo); 113 | fail_if((NULL==ambix), __LINE__, "couldn't create ambix file '%s' for reading", path); 114 | 115 | fail_if((info.fileformat!=rinfo.fileformat), __LINE__, "fileformat mismatch %d!=%d", (int)info.fileformat, (int)rinfo.fileformat); 116 | fail_if((info.samplerate!=rinfo.samplerate), __LINE__, "samplerate mismatch %g!=%g", (float)info.samplerate, (float)rinfo.samplerate); 117 | fail_if((info.sampleformat!=rinfo.sampleformat), __LINE__, "sampleformat mismatch %d!=%d", (int)info.sampleformat, (int)rinfo.sampleformat); 118 | fail_if((info.ambichannels!=rinfo.ambichannels), __LINE__, "ambichannels mismatch %d!=%d", (int)info.ambichannels, (int)rinfo.ambichannels); 119 | fail_if((info.extrachannels!=rinfo.extrachannels), __LINE__, "extrachannels mismatch %d!=%d", (int)info.extrachannels, (int)rinfo.extrachannels); 120 | 121 | eye2=ambix_get_adaptormatrix(ambix); 122 | fail_if((NULL==eye2), __LINE__, "failed reading adaptor matrix"); 123 | 124 | diff=matrix_diff(__LINE__, &eye, eye2, eps); 125 | fail_if((diff>eps), __LINE__, "adaptormatrix diff %f > %f", diff, eps); 126 | 127 | 128 | gotframes=0; 129 | do { 130 | //err64=ambix_readf_float32(ambix, resultambidata, resultotherdata, framesize); 131 | err64=ambix_readf_float32(ambix, 132 | resultambidata +(gotframes*ambichannels ), 133 | resultotherdata+(gotframes*extrachannels), 134 | (framesize-gotframes)); 135 | fail_if((err64<0), __LINE__, "reading frames failed after %d/%d frames", (int)gotframes, (int)framesize); 136 | gotframes+=err64; 137 | } while(err64>0 && gotframeseps), __LINE__, "ambidata diff %f > %f", diff, eps); 141 | 142 | diff=data_diff(__LINE__, FLOAT32, orgotherdata, resultotherdata, framesize*extrachannels, eps); 143 | fail_if((diff>eps), __LINE__, "otherdata diff %f > %f", diff, eps); 144 | 145 | fail_if((AMBIX_ERR_SUCCESS!=ambix_close(ambix)), __LINE__, "closing ambix file %p", ambix); 146 | ambix=NULL; 147 | 148 | free(resultambidata); 149 | free(ambidata); 150 | free(resultotherdata); 151 | free(otherdata); 152 | 153 | free(orgambidata); 154 | free(orgotherdata); 155 | 156 | ambix_matrix_deinit(&eye); 157 | 158 | ambixtest_rmfile(path); 159 | } 160 | --------------------------------------------------------------------------------