diff options
Diffstat (limited to 'test')
34 files changed, 4403 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..1dda51c --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,45 @@ +INCLUDES = -I$(top_srcdir)/libaudiofile + +noinst_PROGRAMS = \ + error \ + floatto24 \ + transparency \ + miscread \ + miscwrite \ + query2 \ + testaupv \ + writeaiff \ + writeircam \ + writenext \ + writewave \ + writeraw \ + writeavr \ + writeiff \ + writenist \ + writeulaw \ + writealaw \ + loop \ + instparamwrite \ + instparamtest \ + sixteen-to-eight \ + testfloat \ + twentyfour \ + twentyfour2 \ + pipe \ + testmarkers \ + testchannelmatrix \ + printmarkers \ + seek + +EXTRA_DIST = transparency.sh misc.sh pipe.sh + +TESTS = error writeaiff writeircam writenext writewave writeraw \ + writeavr writeiff writenist \ + writeulaw writealaw \ + misc.sh transparency.sh pipe.sh \ + query2 sixteen-to-eight twentyfour twentyfour2 floatto24 \ + testfloat testmarkers testchannelmatrix seek + +LDADD = $(top_builddir)/libaudiofile/libaudiofile.la + +DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la diff --git a/test/Makefile.in b/test/Makefile.in new file mode 100644 index 0000000..4287dbd --- /dev/null +++ b/test/Makefile.in @@ -0,0 +1,702 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AMTAR = @AMTAR@ +AS = @AS@ +AUDIOFILE_MAJOR_VERSION = @AUDIOFILE_MAJOR_VERSION@ +AUDIOFILE_MICRO_VERSION = @AUDIOFILE_MICRO_VERSION@ +AUDIOFILE_MINOR_VERSION = @AUDIOFILE_MINOR_VERSION@ +AUDIOFILE_VERSION = @AUDIOFILE_VERSION@ +AUDIOFILE_VERSION_INFO = @AUDIOFILE_VERSION_INFO@ +AUDIO_LIB = @AUDIO_LIB@ +AWK = @AWK@ +CC = @CC@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +STRIP = @STRIP@ +TEST_BIN = @TEST_BIN@ +VERSION = @VERSION@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +INCLUDES = -I$(top_srcdir)/libaudiofile + +noinst_PROGRAMS = \ + error \ + floatto24 \ + transparency \ + miscread \ + miscwrite \ + query2 \ + testaupv \ + writeaiff \ + writeircam \ + writenext \ + writewave \ + writeraw \ + writeavr \ + writeiff \ + writenist \ + writeulaw \ + writealaw \ + loop \ + instparamwrite \ + instparamtest \ + sixteen-to-eight \ + testfloat \ + twentyfour \ + twentyfour2 \ + pipe \ + testmarkers \ + testchannelmatrix \ + printmarkers \ + seek + + +EXTRA_DIST = transparency.sh misc.sh pipe.sh + +TESTS = error writeaiff writeircam writenext writewave writeraw \ + writeavr writeiff writenist \ + writeulaw writealaw \ + misc.sh transparency.sh pipe.sh \ + query2 sixteen-to-eight twentyfour twentyfour2 floatto24 \ + testfloat testmarkers testchannelmatrix seek + + +LDADD = $(top_builddir)/libaudiofile/libaudiofile.la + +DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +subdir = test +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +noinst_PROGRAMS = error$(EXEEXT) floatto24$(EXEEXT) \ + transparency$(EXEEXT) miscread$(EXEEXT) miscwrite$(EXEEXT) \ + query2$(EXEEXT) testaupv$(EXEEXT) writeaiff$(EXEEXT) \ + writeircam$(EXEEXT) writenext$(EXEEXT) writewave$(EXEEXT) \ + writeraw$(EXEEXT) writeavr$(EXEEXT) writeiff$(EXEEXT) \ + writenist$(EXEEXT) writeulaw$(EXEEXT) writealaw$(EXEEXT) \ + loop$(EXEEXT) instparamwrite$(EXEEXT) instparamtest$(EXEEXT) \ + sixteen-to-eight$(EXEEXT) testfloat$(EXEEXT) \ + twentyfour$(EXEEXT) twentyfour2$(EXEEXT) pipe$(EXEEXT) \ + testmarkers$(EXEEXT) testchannelmatrix$(EXEEXT) \ + printmarkers$(EXEEXT) seek$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) + +error_SOURCES = error.c +error_OBJECTS = error.$(OBJEXT) +error_LDADD = $(LDADD) +error_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +error_LDFLAGS = +floatto24_SOURCES = floatto24.c +floatto24_OBJECTS = floatto24.$(OBJEXT) +floatto24_LDADD = $(LDADD) +floatto24_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +floatto24_LDFLAGS = +instparamtest_SOURCES = instparamtest.c +instparamtest_OBJECTS = instparamtest.$(OBJEXT) +instparamtest_LDADD = $(LDADD) +instparamtest_DEPENDENCIES = \ + $(top_builddir)/libaudiofile/libaudiofile.la +instparamtest_LDFLAGS = +instparamwrite_SOURCES = instparamwrite.c +instparamwrite_OBJECTS = instparamwrite.$(OBJEXT) +instparamwrite_LDADD = $(LDADD) +instparamwrite_DEPENDENCIES = \ + $(top_builddir)/libaudiofile/libaudiofile.la +instparamwrite_LDFLAGS = +loop_SOURCES = loop.c +loop_OBJECTS = loop.$(OBJEXT) +loop_LDADD = $(LDADD) +loop_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +loop_LDFLAGS = +miscread_SOURCES = miscread.c +miscread_OBJECTS = miscread.$(OBJEXT) +miscread_LDADD = $(LDADD) +miscread_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +miscread_LDFLAGS = +miscwrite_SOURCES = miscwrite.c +miscwrite_OBJECTS = miscwrite.$(OBJEXT) +miscwrite_LDADD = $(LDADD) +miscwrite_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +miscwrite_LDFLAGS = +pipe_SOURCES = pipe.c +pipe_OBJECTS = pipe.$(OBJEXT) +pipe_LDADD = $(LDADD) +pipe_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +pipe_LDFLAGS = +printmarkers_SOURCES = printmarkers.c +printmarkers_OBJECTS = printmarkers.$(OBJEXT) +printmarkers_LDADD = $(LDADD) +printmarkers_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +printmarkers_LDFLAGS = +query2_SOURCES = query2.c +query2_OBJECTS = query2.$(OBJEXT) +query2_LDADD = $(LDADD) +query2_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +query2_LDFLAGS = +seek_SOURCES = seek.c +seek_OBJECTS = seek.$(OBJEXT) +seek_LDADD = $(LDADD) +seek_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +seek_LDFLAGS = +sixteen_to_eight_SOURCES = sixteen-to-eight.c +sixteen_to_eight_OBJECTS = sixteen-to-eight.$(OBJEXT) +sixteen_to_eight_LDADD = $(LDADD) +sixteen_to_eight_DEPENDENCIES = \ + $(top_builddir)/libaudiofile/libaudiofile.la +sixteen_to_eight_LDFLAGS = +testaupv_SOURCES = testaupv.c +testaupv_OBJECTS = testaupv.$(OBJEXT) +testaupv_LDADD = $(LDADD) +testaupv_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +testaupv_LDFLAGS = +testchannelmatrix_SOURCES = testchannelmatrix.c +testchannelmatrix_OBJECTS = testchannelmatrix.$(OBJEXT) +testchannelmatrix_LDADD = $(LDADD) +testchannelmatrix_DEPENDENCIES = \ + $(top_builddir)/libaudiofile/libaudiofile.la +testchannelmatrix_LDFLAGS = +testfloat_SOURCES = testfloat.c +testfloat_OBJECTS = testfloat.$(OBJEXT) +testfloat_LDADD = $(LDADD) +testfloat_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +testfloat_LDFLAGS = +testmarkers_SOURCES = testmarkers.c +testmarkers_OBJECTS = testmarkers.$(OBJEXT) +testmarkers_LDADD = $(LDADD) +testmarkers_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +testmarkers_LDFLAGS = +transparency_SOURCES = transparency.c +transparency_OBJECTS = transparency.$(OBJEXT) +transparency_LDADD = $(LDADD) +transparency_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +transparency_LDFLAGS = +twentyfour_SOURCES = twentyfour.c +twentyfour_OBJECTS = twentyfour.$(OBJEXT) +twentyfour_LDADD = $(LDADD) +twentyfour_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +twentyfour_LDFLAGS = +twentyfour2_SOURCES = twentyfour2.c +twentyfour2_OBJECTS = twentyfour2.$(OBJEXT) +twentyfour2_LDADD = $(LDADD) +twentyfour2_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +twentyfour2_LDFLAGS = +writeaiff_SOURCES = writeaiff.c +writeaiff_OBJECTS = writeaiff.$(OBJEXT) +writeaiff_LDADD = $(LDADD) +writeaiff_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +writeaiff_LDFLAGS = +writealaw_SOURCES = writealaw.c +writealaw_OBJECTS = writealaw.$(OBJEXT) +writealaw_LDADD = $(LDADD) +writealaw_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +writealaw_LDFLAGS = +writeavr_SOURCES = writeavr.c +writeavr_OBJECTS = writeavr.$(OBJEXT) +writeavr_LDADD = $(LDADD) +writeavr_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +writeavr_LDFLAGS = +writeiff_SOURCES = writeiff.c +writeiff_OBJECTS = writeiff.$(OBJEXT) +writeiff_LDADD = $(LDADD) +writeiff_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +writeiff_LDFLAGS = +writeircam_SOURCES = writeircam.c +writeircam_OBJECTS = writeircam.$(OBJEXT) +writeircam_LDADD = $(LDADD) +writeircam_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +writeircam_LDFLAGS = +writenext_SOURCES = writenext.c +writenext_OBJECTS = writenext.$(OBJEXT) +writenext_LDADD = $(LDADD) +writenext_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +writenext_LDFLAGS = +writenist_SOURCES = writenist.c +writenist_OBJECTS = writenist.$(OBJEXT) +writenist_LDADD = $(LDADD) +writenist_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +writenist_LDFLAGS = +writeraw_SOURCES = writeraw.c +writeraw_OBJECTS = writeraw.$(OBJEXT) +writeraw_LDADD = $(LDADD) +writeraw_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +writeraw_LDFLAGS = +writeulaw_SOURCES = writeulaw.c +writeulaw_OBJECTS = writeulaw.$(OBJEXT) +writeulaw_LDADD = $(LDADD) +writeulaw_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +writeulaw_LDFLAGS = +writewave_SOURCES = writewave.c +writewave_OBJECTS = writewave.$(OBJEXT) +writewave_LDADD = $(LDADD) +writewave_DEPENDENCIES = $(top_builddir)/libaudiofile/libaudiofile.la +writewave_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/error.Po $(DEPDIR)/floatto24.Po \ +@AMDEP_TRUE@ $(DEPDIR)/instparamtest.Po \ +@AMDEP_TRUE@ $(DEPDIR)/instparamwrite.Po $(DEPDIR)/loop.Po \ +@AMDEP_TRUE@ $(DEPDIR)/miscread.Po $(DEPDIR)/miscwrite.Po \ +@AMDEP_TRUE@ $(DEPDIR)/pipe.Po $(DEPDIR)/printmarkers.Po \ +@AMDEP_TRUE@ $(DEPDIR)/query2.Po $(DEPDIR)/seek.Po \ +@AMDEP_TRUE@ $(DEPDIR)/sixteen-to-eight.Po $(DEPDIR)/testaupv.Po \ +@AMDEP_TRUE@ $(DEPDIR)/testchannelmatrix.Po \ +@AMDEP_TRUE@ $(DEPDIR)/testfloat.Po $(DEPDIR)/testmarkers.Po \ +@AMDEP_TRUE@ $(DEPDIR)/transparency.Po $(DEPDIR)/twentyfour.Po \ +@AMDEP_TRUE@ $(DEPDIR)/twentyfour2.Po $(DEPDIR)/writeaiff.Po \ +@AMDEP_TRUE@ $(DEPDIR)/writealaw.Po $(DEPDIR)/writeavr.Po \ +@AMDEP_TRUE@ $(DEPDIR)/writeiff.Po $(DEPDIR)/writeircam.Po \ +@AMDEP_TRUE@ $(DEPDIR)/writenext.Po $(DEPDIR)/writenist.Po \ +@AMDEP_TRUE@ $(DEPDIR)/writeraw.Po $(DEPDIR)/writeulaw.Po \ +@AMDEP_TRUE@ $(DEPDIR)/writewave.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = error.c floatto24.c instparamtest.c instparamwrite.c \ + loop.c miscread.c miscwrite.c pipe.c printmarkers.c query2.c \ + seek.c sixteen-to-eight.c testaupv.c testchannelmatrix.c \ + testfloat.c testmarkers.c transparency.c twentyfour.c \ + twentyfour2.c writeaiff.c writealaw.c writeavr.c writeiff.c \ + writeircam.c writenext.c writenist.c writeraw.c writeulaw.c \ + writewave.c +DIST_COMMON = Makefile.am Makefile.in +SOURCES = error.c floatto24.c instparamtest.c instparamwrite.c loop.c miscread.c miscwrite.c pipe.c printmarkers.c query2.c seek.c sixteen-to-eight.c testaupv.c testchannelmatrix.c testfloat.c testmarkers.c transparency.c twentyfour.c twentyfour2.c writeaiff.c writealaw.c writeavr.c writeiff.c writeircam.c writenext.c writenist.c writeraw.c writeulaw.c writewave.c + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) +error$(EXEEXT): $(error_OBJECTS) $(error_DEPENDENCIES) + @rm -f error$(EXEEXT) + $(LINK) $(error_LDFLAGS) $(error_OBJECTS) $(error_LDADD) $(LIBS) +floatto24$(EXEEXT): $(floatto24_OBJECTS) $(floatto24_DEPENDENCIES) + @rm -f floatto24$(EXEEXT) + $(LINK) $(floatto24_LDFLAGS) $(floatto24_OBJECTS) $(floatto24_LDADD) $(LIBS) +instparamtest$(EXEEXT): $(instparamtest_OBJECTS) $(instparamtest_DEPENDENCIES) + @rm -f instparamtest$(EXEEXT) + $(LINK) $(instparamtest_LDFLAGS) $(instparamtest_OBJECTS) $(instparamtest_LDADD) $(LIBS) +instparamwrite$(EXEEXT): $(instparamwrite_OBJECTS) $(instparamwrite_DEPENDENCIES) + @rm -f instparamwrite$(EXEEXT) + $(LINK) $(instparamwrite_LDFLAGS) $(instparamwrite_OBJECTS) $(instparamwrite_LDADD) $(LIBS) +loop$(EXEEXT): $(loop_OBJECTS) $(loop_DEPENDENCIES) + @rm -f loop$(EXEEXT) + $(LINK) $(loop_LDFLAGS) $(loop_OBJECTS) $(loop_LDADD) $(LIBS) +miscread$(EXEEXT): $(miscread_OBJECTS) $(miscread_DEPENDENCIES) + @rm -f miscread$(EXEEXT) + $(LINK) $(miscread_LDFLAGS) $(miscread_OBJECTS) $(miscread_LDADD) $(LIBS) +miscwrite$(EXEEXT): $(miscwrite_OBJECTS) $(miscwrite_DEPENDENCIES) + @rm -f miscwrite$(EXEEXT) + $(LINK) $(miscwrite_LDFLAGS) $(miscwrite_OBJECTS) $(miscwrite_LDADD) $(LIBS) +pipe$(EXEEXT): $(pipe_OBJECTS) $(pipe_DEPENDENCIES) + @rm -f pipe$(EXEEXT) + $(LINK) $(pipe_LDFLAGS) $(pipe_OBJECTS) $(pipe_LDADD) $(LIBS) +printmarkers$(EXEEXT): $(printmarkers_OBJECTS) $(printmarkers_DEPENDENCIES) + @rm -f printmarkers$(EXEEXT) + $(LINK) $(printmarkers_LDFLAGS) $(printmarkers_OBJECTS) $(printmarkers_LDADD) $(LIBS) +query2$(EXEEXT): $(query2_OBJECTS) $(query2_DEPENDENCIES) + @rm -f query2$(EXEEXT) + $(LINK) $(query2_LDFLAGS) $(query2_OBJECTS) $(query2_LDADD) $(LIBS) +seek$(EXEEXT): $(seek_OBJECTS) $(seek_DEPENDENCIES) + @rm -f seek$(EXEEXT) + $(LINK) $(seek_LDFLAGS) $(seek_OBJECTS) $(seek_LDADD) $(LIBS) +sixteen-to-eight$(EXEEXT): $(sixteen_to_eight_OBJECTS) $(sixteen_to_eight_DEPENDENCIES) + @rm -f sixteen-to-eight$(EXEEXT) + $(LINK) $(sixteen_to_eight_LDFLAGS) $(sixteen_to_eight_OBJECTS) $(sixteen_to_eight_LDADD) $(LIBS) +testaupv$(EXEEXT): $(testaupv_OBJECTS) $(testaupv_DEPENDENCIES) + @rm -f testaupv$(EXEEXT) + $(LINK) $(testaupv_LDFLAGS) $(testaupv_OBJECTS) $(testaupv_LDADD) $(LIBS) +testchannelmatrix$(EXEEXT): $(testchannelmatrix_OBJECTS) $(testchannelmatrix_DEPENDENCIES) + @rm -f testchannelmatrix$(EXEEXT) + $(LINK) $(testchannelmatrix_LDFLAGS) $(testchannelmatrix_OBJECTS) $(testchannelmatrix_LDADD) $(LIBS) +testfloat$(EXEEXT): $(testfloat_OBJECTS) $(testfloat_DEPENDENCIES) + @rm -f testfloat$(EXEEXT) + $(LINK) $(testfloat_LDFLAGS) $(testfloat_OBJECTS) $(testfloat_LDADD) $(LIBS) +testmarkers$(EXEEXT): $(testmarkers_OBJECTS) $(testmarkers_DEPENDENCIES) + @rm -f testmarkers$(EXEEXT) + $(LINK) $(testmarkers_LDFLAGS) $(testmarkers_OBJECTS) $(testmarkers_LDADD) $(LIBS) +transparency$(EXEEXT): $(transparency_OBJECTS) $(transparency_DEPENDENCIES) + @rm -f transparency$(EXEEXT) + $(LINK) $(transparency_LDFLAGS) $(transparency_OBJECTS) $(transparency_LDADD) $(LIBS) +twentyfour$(EXEEXT): $(twentyfour_OBJECTS) $(twentyfour_DEPENDENCIES) + @rm -f twentyfour$(EXEEXT) + $(LINK) $(twentyfour_LDFLAGS) $(twentyfour_OBJECTS) $(twentyfour_LDADD) $(LIBS) +twentyfour2$(EXEEXT): $(twentyfour2_OBJECTS) $(twentyfour2_DEPENDENCIES) + @rm -f twentyfour2$(EXEEXT) + $(LINK) $(twentyfour2_LDFLAGS) $(twentyfour2_OBJECTS) $(twentyfour2_LDADD) $(LIBS) +writeaiff$(EXEEXT): $(writeaiff_OBJECTS) $(writeaiff_DEPENDENCIES) + @rm -f writeaiff$(EXEEXT) + $(LINK) $(writeaiff_LDFLAGS) $(writeaiff_OBJECTS) $(writeaiff_LDADD) $(LIBS) +writealaw$(EXEEXT): $(writealaw_OBJECTS) $(writealaw_DEPENDENCIES) + @rm -f writealaw$(EXEEXT) + $(LINK) $(writealaw_LDFLAGS) $(writealaw_OBJECTS) $(writealaw_LDADD) $(LIBS) +writeavr$(EXEEXT): $(writeavr_OBJECTS) $(writeavr_DEPENDENCIES) + @rm -f writeavr$(EXEEXT) + $(LINK) $(writeavr_LDFLAGS) $(writeavr_OBJECTS) $(writeavr_LDADD) $(LIBS) +writeiff$(EXEEXT): $(writeiff_OBJECTS) $(writeiff_DEPENDENCIES) + @rm -f writeiff$(EXEEXT) + $(LINK) $(writeiff_LDFLAGS) $(writeiff_OBJECTS) $(writeiff_LDADD) $(LIBS) +writeircam$(EXEEXT): $(writeircam_OBJECTS) $(writeircam_DEPENDENCIES) + @rm -f writeircam$(EXEEXT) + $(LINK) $(writeircam_LDFLAGS) $(writeircam_OBJECTS) $(writeircam_LDADD) $(LIBS) +writenext$(EXEEXT): $(writenext_OBJECTS) $(writenext_DEPENDENCIES) + @rm -f writenext$(EXEEXT) + $(LINK) $(writenext_LDFLAGS) $(writenext_OBJECTS) $(writenext_LDADD) $(LIBS) +writenist$(EXEEXT): $(writenist_OBJECTS) $(writenist_DEPENDENCIES) + @rm -f writenist$(EXEEXT) + $(LINK) $(writenist_LDFLAGS) $(writenist_OBJECTS) $(writenist_LDADD) $(LIBS) +writeraw$(EXEEXT): $(writeraw_OBJECTS) $(writeraw_DEPENDENCIES) + @rm -f writeraw$(EXEEXT) + $(LINK) $(writeraw_LDFLAGS) $(writeraw_OBJECTS) $(writeraw_LDADD) $(LIBS) +writeulaw$(EXEEXT): $(writeulaw_OBJECTS) $(writeulaw_DEPENDENCIES) + @rm -f writeulaw$(EXEEXT) + $(LINK) $(writeulaw_LDFLAGS) $(writeulaw_OBJECTS) $(writeulaw_LDADD) $(LIBS) +writewave$(EXEEXT): $(writewave_OBJECTS) $(writewave_DEPENDENCIES) + @rm -f writewave$(EXEEXT) + $(LINK) $(writewave_LDFLAGS) $(writewave_OBJECTS) $(writewave_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/error.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/floatto24.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/instparamtest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/instparamwrite.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/loop.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/miscread.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/miscwrite.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pipe.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/printmarkers.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/query2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/seek.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/sixteen-to-eight.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/testaupv.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/testchannelmatrix.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/testfloat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/testmarkers.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/transparency.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/twentyfour.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/twentyfour2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/writeaiff.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/writealaw.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/writeavr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/writeiff.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/writeircam.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/writenext.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/writenist.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/writeraw.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/writeulaw.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/writewave.Po@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ +uninstall-info-am: + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(PROGRAMS) + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: GTAGS all all-am check check-TESTS check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS distclean distclean-compile \ + distclean-depend distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + tags uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/error.c b/test/error.c new file mode 100644 index 0000000..c321319 --- /dev/null +++ b/test/error.c @@ -0,0 +1,135 @@ +/* + Audio File Library + + Copyright (C) 2000-2001, Silicon Graphics, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <audiofile.h> + +int expectedError; +int verbose = 0; + +void myerrorfunc (long error, const char *description) +{ + if (error != expectedError) + { + if (verbose) + { + printf("WRONG ERROR CODE:\n"); + printf("%s [error code %ld]--", description, error); + printf("expected error code %d\n", expectedError); + } + exit(EXIT_FAILURE); + } + else + { + if (verbose) + { + printf("CORRECT ERROR CODE:\n"); + printf("%s [error code %ld]\n", description, error); + } + } +} + +void testnull (void) +{ + expectedError = AF_BAD_FILEHANDLE; + + if (verbose) printf("closing null file handle\n"); + afCloseFile(AF_NULL_FILEHANDLE); + + if (verbose) printf("reading from null file handle\n"); + afReadFrames(AF_NULL_FILEHANDLE, AF_DEFAULT_TRACK, NULL, 0); + + if (verbose) printf("writing to null file handle\n"); + afWriteFrames(AF_NULL_FILEHANDLE, AF_DEFAULT_TRACK, NULL, 0); + + if (verbose) printf("setting position on null file handle\n"); + afSeekFrame(AF_NULL_FILEHANDLE, AF_DEFAULT_TRACK, 0); + + if (verbose) printf("retrieving position on null file handle\n"); + afTellFrame(AF_NULL_FILEHANDLE, AF_DEFAULT_TRACK); + + if (verbose) printf("getting data offset of null file handle\n"); + afGetDataOffset(AF_NULL_FILEHANDLE, AF_DEFAULT_TRACK); + + if (verbose) printf("getting track byte count of null file handle\n"); + afGetTrackBytes(AF_NULL_FILEHANDLE, AF_DEFAULT_TRACK); + + if (verbose) printf("getting frame count of null file handle\n"); + afGetFrameCount(AF_NULL_FILEHANDLE, AF_DEFAULT_TRACK); + + expectedError = AF_BAD_FILESETUP; + if (verbose) printf("freeing null file setup\n"); + afFreeFileSetup(AF_NULL_FILESETUP); +} + +void testbad (void) +{ + AFfilesetup setup; + setup = afNewFileSetup(); + + expectedError = AF_BAD_OPEN; + if (verbose) printf("opening nonexistent file\n"); + afOpenFile("sldkjflsdkfjalksdjflaksdjflsakfdj", "r", NULL); + + expectedError = AF_BAD_FILEFMT; + if (verbose) printf("initializing file format to invalid value\n"); + afInitFileFormat(setup, 91094); + + expectedError = AF_BAD_SAMPFMT; + if (verbose) printf("initializing sample format and sample width to invalid value\n"); + afInitSampleFormat(setup, AF_DEFAULT_TRACK, 3992, 3932); + + afFreeFileSetup(setup); + + expectedError = AF_BAD_FILESETUP; + if (verbose) printf("initializing file format on a file setup which has been deallocated\n"); + afInitFileFormat(setup, AF_FILE_AIFFC); +} + +void testbadquery (void) +{ + expectedError = AF_BAD_QUERY; + if (verbose) printf("querying on bad selectors\n"); + afQueryLong(AF_QUERYTYPE_FILEFMT, 9999, 9999, 9999, 9999); + + expectedError = AF_BAD_QUERYTYPE; + if (verbose) printf("querying using bad query type\n"); + afQueryLong(9999, 9999, 9999, 9999, 9999); +} + +int main (int argc, char **argv) +{ + afSetErrorHandler(myerrorfunc); + + if (argc == 2 && strcmp(argv[1], "-v") == 0) + verbose = 1; + + testnull(); + testbad(); + testbadquery(); + + return 0; +} diff --git a/test/floatto24.c b/test/floatto24.c new file mode 100644 index 0000000..191daaf --- /dev/null +++ b/test/floatto24.c @@ -0,0 +1,182 @@ +/* + Audio File Library + + Copyright (C) 2001, Silicon Graphics, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + floatto24.c + + This program creates a BICSF floating-point sound file and then + reads the sample data back as 24-bit data (i.e. 32-bit integers + with the high 8 bits equal to the sign extension of the lower + 24 bits). +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <audiofile.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#define TEST_FILE "/tmp/test.sf" +#define FRAME_COUNT 10 + +/* + When converted to samples with width 24 bits, the samples + should have the following values: +*/ + +const float samples[] = +{ + 0, + 0.5, + -0.5, + 0, + 1, + -1, + -0.25, + 0.25, + 0.75, + -0.75 +}; + +const int referenceConvertedSamples[] = +{ + 0, + 4194303, /* = (2^23 - 1) / 2 */ + -4194303, + 0, + 8388607, /* = 2^23 - 1 */ + -8388607, + -2097151, + 2097151, /* = (2^23 - 1) / 4 */ + 6291455, /* = (2^23 - 1) * 3 / 4 */ + -6291455 +}; + +int main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + AFframecount framesWritten, framesRead; + + int readsamples[FRAME_COUNT] = {-1000, -1001, -1002, -1003, + -1004, -1005, -1006, -1007}; + int i; + + if ((setup = afNewFileSetup()) == AF_NULL_FILESETUP) + { + fprintf(stderr, "Could not allocate file setup.\n"); + exit(EXIT_FAILURE); + } + + afInitFileFormat(setup, AF_FILE_IRCAM); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_FLOAT, 32); + + file = afOpenFile(TEST_FILE, "w", setup); + if (file == AF_NULL_FILEHANDLE) + { + printf("could not open file for writing\n"); + exit(EXIT_FAILURE); + } + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, (void *) samples, + FRAME_COUNT); + + if (framesWritten != FRAME_COUNT) + { + fprintf(stderr, "Wrong number of frames read.\n"); + exit(EXIT_FAILURE); + } + + if (afCloseFile(file) != 0) + { + fprintf(stderr, "Closing file returned non-zero status.\n"); + exit(EXIT_FAILURE); + } + + file = afOpenFile(TEST_FILE, "r", AF_NULL_FILESETUP); + if (file == AF_NULL_FILEHANDLE) + { + fprintf(stderr, "Could not open file for writing.\n"); + exit(EXIT_FAILURE); + } + + if (afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, + AF_SAMPFMT_TWOSCOMP, 24) != 0) + { + fprintf(stderr, "afSetVirtualSampleFormat returned non-zero status.\n"); + exit(EXIT_FAILURE); + } + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, readsamples, + FRAME_COUNT); + + if (framesRead != FRAME_COUNT) + { + fprintf(stderr, "Wrong number of frames read.\n"); + exit(EXIT_FAILURE); + } + + for (i=0; i<framesRead; i++) + { +#ifdef DEBUG + printf("[%d] = %d\n", i, readsamples[i]); +#endif + + if (readsamples[i] == -1000 - i) + { + fprintf(stderr, "Data in destination array untouched.\n"); + exit(EXIT_FAILURE); + } + + /* + Ensure that the high-order 8 bits represent + sign extension: only 0x00 (+) or 0xff (-) is + valid. + */ + if ((readsamples[i] & 0xff000000) != 0x000000 && + (readsamples[i] & 0xff000000) != 0xff000000) + { + fprintf(stderr, "Data is not within range of " + "{-2^23, ..., 2^23-1}.\n"); + exit(EXIT_FAILURE); + } + + if (readsamples[i] != referenceConvertedSamples[i]) + { + fprintf(stderr, "Data doesn't match reference data.\n"); + exit(EXIT_FAILURE); + } + } + + if (afCloseFile(file) != 0) + { + fprintf(stderr, "Closing file returned non-zero status.\n"); + exit(EXIT_FAILURE); + } + + unlink(TEST_FILE); + + exit(EXIT_SUCCESS); +} diff --git a/test/instparamtest.c b/test/instparamtest.c new file mode 100644 index 0000000..a92b640 --- /dev/null +++ b/test/instparamtest.c @@ -0,0 +1,77 @@ +/* + Audio File Library + + Copyright 1998, Michael Pruett <michael@68k.org> + Copyright 2000, Silicon Graphics, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +#include <audiofile.h> +#include <stdio.h> +#include <stdlib.h> + +main (int argc, char **argv) +{ + AFfilehandle file; + long result; + int count, instids; + + if (argc != 2) + { + fprintf(stderr, "usage: %s filename\n", argv[0]); + exit(EXIT_FAILURE); + } + + file = afOpenFile(argv[1], "r", NULL); + if (file == AF_NULL_FILEHANDLE) + { + fprintf(stderr, "could not open file '%s'\n", argv[1]); + exit(EXIT_FAILURE); + } + + count = afGetInstIDs(file, &instids); + printf("%ld instruments in file '%s'\n", count, argv[1]); + + result = afGetInstParamLong(file, AF_DEFAULT_INST, AF_INST_MIDI_BASENOTE); + printf("MIDI base note: %ld\n", result); + + result = afGetInstParamLong(file, AF_DEFAULT_INST, AF_INST_NUMCENTS_DETUNE); + printf("detune in cents: %ld\n", result); + + result = afGetInstParamLong(file, AF_DEFAULT_INST, AF_INST_MIDI_LONOTE); + printf("MIDI low note: %ld\n", result); + + result = afGetInstParamLong(file, AF_DEFAULT_INST, AF_INST_MIDI_HINOTE); + printf("MIDI high note: %ld\n", result); + + result = afGetInstParamLong(file, AF_DEFAULT_INST, AF_INST_MIDI_LOVELOCITY); + printf("MIDI low velocity: %ld\n", result); + + result = afGetInstParamLong(file, AF_DEFAULT_INST, AF_INST_MIDI_HIVELOCITY); + printf("MIDI high velocity: %ld\n", result); + + result = afGetInstParamLong(file, AF_DEFAULT_INST, AF_INST_NUMDBS_GAIN); + printf("gain in decibels: %ld\n", result); + + result = afGetInstParamLong(file, AF_DEFAULT_INST, AF_INST_SUSLOOPID); + printf("sustain loop id: %ld\n", result); + + result = afGetInstParamLong(file, AF_DEFAULT_INST, AF_INST_RELLOOPID); + printf("release loop id: %ld\n", result); + + afCloseFile(file); +} diff --git a/test/instparamwrite.c b/test/instparamwrite.c new file mode 100644 index 0000000..99a5819 --- /dev/null +++ b/test/instparamwrite.c @@ -0,0 +1,55 @@ +/* + Audio File Library + + Copyright 2000, Silicon Graphics, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +#include <stdio.h> + +#include <audiofile.h> + +main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + AUpvlist list; + + if (argc != 2) + { + fprintf(stderr, "usage: instparamwrite filename\n"); + } + + setup = afNewFileSetup(); + afInitFileFormat(setup, AF_FILE_AIFFC); + + file = afOpenFile(argv[1], "w", setup); + if (file == AF_NULL_FILEHANDLE) + { + fprintf(stderr, "could not open file %s for writing", argv[1]); + } + + afFreeFileSetup(setup); + + /* Set the base note to a 'D.' */ + afSetInstParamLong(file, AF_DEFAULT_INST, AF_INST_MIDI_BASENOTE, 50); + + /* Detune down by 30 cents. */ + afSetInstParamLong(file, AF_DEFAULT_INST, AF_INST_NUMCENTS_DETUNE, -30); + + afCloseFile(file); +} diff --git a/test/loop.c b/test/loop.c new file mode 100644 index 0000000..3778eef --- /dev/null +++ b/test/loop.c @@ -0,0 +1,37 @@ +#include <audiofile.h> + +int main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + int markerIDs[] = {1, 2, 3, 4}; + int loopIDs[] = {1, 2}; + short frames[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + + setup = afNewFileSetup(); + afInitFileFormat(setup, AF_FILE_AIFF); + + afInitMarkIDs(setup, AF_DEFAULT_TRACK, markerIDs, 4); + afInitMarkName(setup, AF_DEFAULT_TRACK, 1, "sustain loop start"); + afInitMarkName(setup, AF_DEFAULT_TRACK, 2, "sustain loop end"); + afInitMarkName(setup, AF_DEFAULT_TRACK, 3, "release loop start"); + afInitMarkName(setup, AF_DEFAULT_TRACK, 4, "release loop end"); + + afInitLoopIDs(setup, AF_DEFAULT_INST, loopIDs, 2); + + file = afOpenFile(argv[1], "w", setup); + + afWriteFrames(file, AF_DEFAULT_TRACK, frames, 5); + + afSetMarkPosition(file, AF_DEFAULT_TRACK, 1, 0); + afSetMarkPosition(file, AF_DEFAULT_TRACK, 2, 2); + afSetMarkPosition(file, AF_DEFAULT_TRACK, 3, 4); + afSetMarkPosition(file, AF_DEFAULT_TRACK, 4, 5); + + afSetLoopStart(file, AF_DEFAULT_INST, 1, 1); + afSetLoopEnd(file, AF_DEFAULT_INST, 1, 2); + afSetLoopStart(file, AF_DEFAULT_INST, 2, 3); + afSetLoopEnd(file, AF_DEFAULT_INST, 2, 4); + + afCloseFile(file); +} diff --git a/test/misc.sh b/test/misc.sh new file mode 100755 index 0000000..6d8866a --- /dev/null +++ b/test/misc.sh @@ -0,0 +1,20 @@ +# +# Test miscellaneous data reading and writing for AIFF, AIFF-C, and WAVE +# file formats. +# + +for i in aiff aifc wave +do +./miscwrite $i /tmp/misc.test || (echo "failed: miscwrite $i"; exit) +./miscread /tmp/misc.test > /tmp/misc.out || (echo "failed: miscread $i"; exit) + +diff /tmp/misc.out - <<END || exit +Miscellaneous 201, 19 bytes: +1998 Michael Pruett +Miscellaneous 203, 43 bytes: +Michael Pruett's home-brew methamphetamines +END + +rm -f /tmp/misc.test /tmp/misc.out +echo "passed: miscellaneous $i" +done diff --git a/test/miscread.c b/test/miscread.c new file mode 100644 index 0000000..75084e2 --- /dev/null +++ b/test/miscread.c @@ -0,0 +1,85 @@ +/* + Audio File Library + + Copyright 1998, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#endif + +/* Two frames of 16-bit stereo samples. */ +u_int16_t data[] = {0, 1, 2, 3}; + +int main (int argc, char **argv) +{ + AFfilehandle file; + int *miscids; + int i, misccount; + + if (argc < 2) + { + fprintf(stderr, "usage: %s <audio file>\n", argv[0]); + exit(EXIT_FAILURE); + } + + file = afOpenFile(argv[1], "r", NULL); + if (file == NULL) + { + fprintf(stderr, "could not open file %s for reading\n", argv[1]); + exit(EXIT_FAILURE); + } + misccount = afGetMiscIDs(file, NULL); + miscids = malloc(sizeof (int) * misccount); + afGetMiscIDs(file, miscids); + + for (i=0; i<misccount; i++) + { + char *data; + int datasize; + + datasize = afGetMiscSize(file, miscids[i]); + printf("Miscellaneous %d, %d bytes:\n", + afGetMiscType(file, miscids[i]), datasize); + + /* + We know that the data in this test is a string, + so make the buffer large enough for a null terminator. + */ + data = malloc(datasize+1); + afReadMisc(file, miscids[i], data, datasize); + data[datasize] = '\0'; + + puts(data); + free(data); + } + + afCloseFile(file); + + return 0; +} diff --git a/test/miscwrite.c b/test/miscwrite.c new file mode 100644 index 0000000..d299c9b --- /dev/null +++ b/test/miscwrite.c @@ -0,0 +1,106 @@ +/* + Audio File Library + + Copyright 1998, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#endif + +#ifdef DEBUG +#define DEBG printf +#else +#define DEBG +#endif + +char copyright[] = "1998 Michael Pruett"; +char name[] = "Michael Pruett's home-brew methamphetamines"; + +/* Two frames of 16-bit stereo samples. */ +u_int16_t data[] = {0, 1, 2, 3}; + +int main (int argc, char **argv) +{ + int filefmt; + AFfilehandle file; + AFfilesetup setup; + int miscids[] = {1, 2}; + int result; + + if (argc < 3) + { + fprintf(stderr, "usage: %s <file format> <audio file>\n", + argv[0]); + exit(EXIT_FAILURE); + } + + if (strcmp(argv[1], "aiff") == 0) + filefmt = AF_FILE_AIFF; + else if (strcmp(argv[1], "aifc") == 0) + filefmt = AF_FILE_AIFFC; + else if (strcmp(argv[1], "wave") == 0) + filefmt = AF_FILE_WAVE; + else + { + fprintf(stderr, "unrecognized file format '%s'\n", argv[1]); + exit(EXIT_FAILURE); + } + + setup = afNewFileSetup(); + afInitFileFormat(setup, filefmt); + afInitMiscIDs(setup, miscids, 2); + afInitMiscType(setup, 1, AF_MISC_COPY); + afInitMiscType(setup, 2, AF_MISC_NAME); + afInitMiscSize(setup, 1, strlen(copyright)); + afInitMiscSize(setup, 2, strlen(name)); + + file = afOpenFile(argv[2], "w", setup); + if (file == NULL) + { + fprintf(stderr, "could not open file '%s' for writing\n", argv[2]); + exit(EXIT_FAILURE); + } + + result = afWriteMisc(file, 1, copyright, strlen(copyright)); + DEBG("wrote miscellaneous data of type %d with length = %d\n", + afGetMiscType(file, 1), result); + result = afWriteMisc(file, 2, name, strlen(name)); + + DEBG("wrote miscellaneous data of type %d with length = %d\n", + afGetMiscType(file, 2), result); + + /* Write out two token frames of sample data. */ + afWriteFrames(file, AF_DEFAULT_TRACK, data, 2); + + afCloseFile(file); + afFreeFileSetup(setup); + + return 0; +} diff --git a/test/pipe.c b/test/pipe.c new file mode 100644 index 0000000..3cec723 --- /dev/null +++ b/test/pipe.c @@ -0,0 +1,116 @@ +/* + Audio File Library + + Copyright (C) 2001, Silicon Graphics, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + pipe.c + + This program provides a simple test of Audio File Library + operation on non-seekable file handles. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif + +#include <audiofile.h> +#include <stdio.h> +#include <stdlib.h> + +#define SAMPLE_COUNT 12 +#define FRAME_COUNT 6 + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + exit(EXIT_FAILURE); + } +} + +int main (int argc, char **argv) +{ + AFfilesetup setup; + AFfilehandle file; + int16_t samples[SAMPLE_COUNT] = {-1,3,9,2,-5,4,8,-3,6,21,11,-2}; + int output = 0; + + setup = afNewFileSetup(); + + afInitFileFormat(setup, AF_FILE_RAWDATA); + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16); + afInitChannels(setup, AF_DEFAULT_TRACK, 2); + afInitRate(setup, AF_DEFAULT_TRACK, 44100); +#ifdef WORDS_BIGENDIAN + afInitByteOrder(setup, AF_DEFAULT_TRACK, AF_BYTEORDER_BIGENDIAN); +#else + afInitByteOrder(setup, AF_DEFAULT_TRACK, AF_BYTEORDER_LITTLEENDIAN); +#endif + + if (argc > 1 && !strcmp(argv[1], "out")) + output = 1; + + if (output) + { + AFframecount framesWritten; + + file = afOpenFD(1, "w", setup); + + afFreeFileSetup(setup); + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, samples, + FRAME_COUNT); + + ensure(framesWritten == FRAME_COUNT, + "incorrect number of frames written"); + + fprintf(stderr, "pipe write passed\n"); + } + else + { + AFframecount framesRead; + int16_t samplesRead[SAMPLE_COUNT]; + + file = afOpenFD(0, "r", setup); + + afFreeFileSetup(setup); + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, samplesRead, + FRAME_COUNT); + + ensure(framesRead == FRAME_COUNT, + "incorrect number of frames read"); + + ensure(memcmp(samplesRead, samples, + SAMPLE_COUNT * sizeof (int16_t)) == 0, + "samples read do not match samples written"); + + fprintf(stderr, "pipe read passed\n"); + } + + afCloseFile(file); + + exit(EXIT_SUCCESS); +} diff --git a/test/pipe.sh b/test/pipe.sh new file mode 100755 index 0000000..62a34bf --- /dev/null +++ b/test/pipe.sh @@ -0,0 +1,5 @@ +# pipe.sh +# This script provides a simple test of Audio File Library +# operation on non-seekable file handles. + +(./pipe out | ./pipe) && echo "passed pipe test" diff --git a/test/printmarkers.c b/test/printmarkers.c new file mode 100644 index 0000000..b3c8561 --- /dev/null +++ b/test/printmarkers.c @@ -0,0 +1,126 @@ +/* + Audio File Library + + Copyright (C) 2002, Silicon Graphics, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + printmarkers + + This program lists the markers in an audio file. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <assert.h> +#include <audiofile.h> + +void printtime (AFframecount position, double rate) +{ + double time_in_seconds; + + time_in_seconds = (double) position / rate; + + /* Handle hours. */ + if (time_in_seconds > 3600) + { + printf("%d:", (int) (time_in_seconds / 3600)); + time_in_seconds = fmod(time_in_seconds, 3600); + } + + /* Handle minutes. */ + if (time_in_seconds > 60) + { + printf("%02d:", (int) (time_in_seconds / 60)); + time_in_seconds = fmod(time_in_seconds, 60); + } + + /* Handle seconds and milliseconds. */ + printf("%02.3f", time_in_seconds); +} + +int main (int argc, char **argv) +{ + AFfilehandle file; + double rate; + int markcount; + int *markids; + int i; + + if (argc != 2) + { + fprintf(stderr, "usage: %s filename\n", argv[0]); + fprintf(stderr, "where filename is the name of an audio file containing markers\n"); + exit(0); + } + + file = afOpenFile(argv[1], "r", NULL); + if (file == AF_NULL_FILEHANDLE) + { + fprintf(stderr, "Could not open file '%s' for reading.", argv[1]); + exit(0); + } + + markcount = afGetMarkIDs(file, AF_DEFAULT_TRACK, NULL); + if (markcount <= 0) + { + fprintf(stderr, "The file '%s' does not contain any markers.", argv[1]); + exit(0); + } + + markids = calloc(markcount, sizeof (int)); + if (markids == NULL) + { + fprintf(stderr, "Could not allocate enough memory for markers."); + exit(0); + } + + afGetMarkIDs(file, AF_DEFAULT_TRACK, markids); + + rate = afGetRate(file, AF_DEFAULT_TRACK); + + for (i=0; i<markcount; i++) + { + AFframecount position; + const char *name, *comment; + + position = afGetMarkPosition(file, AF_DEFAULT_TRACK, markids[i]); + + name = afGetMarkName(file, AF_DEFAULT_TRACK, markids[i]); + comment = afGetMarkComment(file, AF_DEFAULT_TRACK, markids[i]); + + printf("marker %d, position %lld, time ", markids[i], position); + + printtime(position, rate); + + printf("\n"); + + if (name != NULL) + printf("\tname: %s\n", name); + if (comment != NULL) + printf("\tcomment: %s\n", comment); + } + + afCloseFile(file); + + return EXIT_SUCCESS; +} diff --git a/test/query2.c b/test/query2.c new file mode 100644 index 0000000..69bb93e --- /dev/null +++ b/test/query2.c @@ -0,0 +1,170 @@ +/* + Audio File Library + + Copyright 1998-2000, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#include <dmedia/audioutil.h> +#else +#include <audiofile.h> +#include <aupvlist.h> +#endif + +#include <stdio.h> +#include <stdlib.h> + +const char *paramtypename (int paramtype); +void printinstparams (int format); + +#define DEBUG + +#ifdef DEBUG +#define DEBG printf +#else +#define DEBG +#endif + +int main (int ac, char **av) +{ + AUpvlist formatlist; + int *flist; + long lvalue; + int i, formatcount; + + formatlist = afQuery(AF_QUERYTYPE_FILEFMT, AF_QUERY_IDS, 0, 0, 0); + formatcount = afQueryLong(AF_QUERYTYPE_FILEFMT, AF_QUERY_ID_COUNT, 0, 0, 0); + + DEBG("formatcount = %d\n", formatcount); + + AUpvgetval(formatlist, 0, &flist); + AUpvfree(formatlist); + + for (i=0; i<formatcount; i++) + { + int format; + char *formatstring; + + format = flist[i]; + DEBG("format = %d\n", format); + formatstring = afQueryPointer(AF_QUERYTYPE_FILEFMT, AF_QUERY_NAME, + format, 0, 0); + DEBG("format = %s\n", formatstring); + + lvalue = afQueryLong(AF_QUERYTYPE_INST, AF_QUERY_SUPPORTED, + format, 0, 0); + DEBG("instrument query: supported: %ld\n", lvalue); + + lvalue = afQueryLong(AF_QUERYTYPE_INST, AF_QUERY_MAX_NUMBER, + format, 0, 0); + DEBG("instrument query: maximum number: %ld\n", lvalue); + + lvalue = afQueryLong(AF_QUERYTYPE_INSTPARAM, AF_QUERY_SUPPORTED, + format, 0, 0); + DEBG("instrument parameter query: supported: %ld\n", lvalue); + + /* + Print instrument parameter information only if + instrument parameters are supported. + */ + if (lvalue) + printinstparams(format); + } + free(flist); + + return 0; +} + +void printinstparams (int format) +{ + int i, *iarray; + long instParamCount; + + instParamCount = afQueryLong(AF_QUERYTYPE_INSTPARAM, AF_QUERY_ID_COUNT, + format, 0, 0); + DEBG("instrument parameter query: id count: %ld\n", instParamCount); + + iarray = afQueryPointer(AF_QUERYTYPE_INSTPARAM, AF_QUERY_IDS, + format, 0, 0); + + if (iarray == NULL) + printf("AF_QUERYTYPE_INSTPARAM failed for format %d\n", format); + + for (i=0; i<instParamCount; i++) + { + int paramType; + AUpvlist defaultValue; + + DEBG("instrument parameter query: id: %d\n", iarray[i]); + paramType = afQueryLong(AF_QUERYTYPE_INSTPARAM, + AF_QUERY_TYPE, format, iarray[i], 0); + + DEBG("\ttype of parameter: %s\n", paramtypename(paramType)); + DEBG("\tname of parameter: %s\n", + (char *) afQueryPointer(AF_QUERYTYPE_INSTPARAM, + AF_QUERY_NAME, format, iarray[i], 0)); + + defaultValue = afQuery(AF_QUERYTYPE_INSTPARAM, AF_QUERY_DEFAULT, + format, iarray[i], 0); + + if (paramType == AU_PVTYPE_LONG) + { + long ldefault; + AUpvgetval(defaultValue, 0, &ldefault); + DEBG("\tdefault value: %ld\n", ldefault); + } + else if (paramType == AU_PVTYPE_DOUBLE) + { + double ddefault; + AUpvgetval(defaultValue, 0, &ddefault); + DEBG("\tdefault value: %f\n", ddefault); + } + else if (paramType == AU_PVTYPE_PTR) + { + void *vdefault; + AUpvgetval(defaultValue, 0, &vdefault); + DEBG("\tdefault value: %p\n", vdefault); + } + } + + free(iarray); +} + +const char *paramtypename (int paramtype) +{ + static const char *longname = "long"; + static const char *doublename = "double"; + static const char *pointername = "pointer"; + + switch (paramtype) + { + case AU_PVTYPE_LONG: + return longname; + case AU_PVTYPE_DOUBLE: + return doublename; + case AU_PVTYPE_PTR: + return pointername; + } + + return NULL; +} diff --git a/test/seek.c b/test/seek.c new file mode 100644 index 0000000..e4508b9 --- /dev/null +++ b/test/seek.c @@ -0,0 +1,124 @@ +/* + Audio File Library + + Copyright (C) 2003, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + seek.c + + This program tests seeking within an audio file. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <audiofile.h> + +#define TEST_FILE "/tmp/test.aiff" +#define FRAME_COUNT 2000 +#define PAD_FRAME_COUNT (FRAME_COUNT + 5) +#define DATA_LENGTH (FRAME_COUNT * sizeof (short)) + +void cleanup (void) +{ +#ifndef DEBUG + unlink(TEST_FILE); +#endif +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + AFframecount framesread; + short data[FRAME_COUNT]; + short readdata[PAD_FRAME_COUNT]; + int i; + + setup = afNewFileSetup(); + ensure(setup != NULL, "could not create file setup"); + + afInitFileFormat(setup, AF_FILE_AIFF); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + + file = afOpenFile(TEST_FILE, "w", setup); + ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing"); + + afFreeFileSetup(setup); + + /* Initialize data to a nontrivial test pattern. */ + for (i=0; i<FRAME_COUNT; i++) + { + if ((i%2) != 0) + data[i] = i; + else + data[i] = -i; + } + + afWriteFrames(file, AF_DEFAULT_TRACK, data, FRAME_COUNT); + + afCloseFile(file); + + file = afOpenFile(TEST_FILE, "r", AF_NULL_FILESETUP); + ensure(file != AF_NULL_FILEHANDLE, "could not open file for reading"); + + /* + For each position in the file, seek to that position and + read to the end of the file, checking that the data read + matches the data written. + */ + for (i=0; i<FRAME_COUNT; i++) + { + AFfileoffset currentposition; + + memset(readdata, 0, DATA_LENGTH); + + afSeekFrame(file, AF_DEFAULT_TRACK, i); + currentposition = afTellFrame(file, AF_DEFAULT_TRACK); + ensure(currentposition == i, "incorrect seek position"); + + framesread = afReadFrames(file, AF_DEFAULT_TRACK, readdata + i, + PAD_FRAME_COUNT); + ensure(framesread == FRAME_COUNT - i, + "incorrect number of frames read"); + + ensure(memcmp(data + i, readdata + i, framesread * sizeof (short)) == 0, + "error in data read"); + } + + afCloseFile(file); + + cleanup(); + return 0; +} diff --git a/test/sixteen-to-eight.c b/test/sixteen-to-eight.c new file mode 100644 index 0000000..48ace03 --- /dev/null +++ b/test/sixteen-to-eight.c @@ -0,0 +1,111 @@ +/* + Audio File Library + + Copyright 2000, Silicon Graphics, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + sixteen-to-eight.c + + This program tests the conversion from 16-bit integers to 8-bit + integers. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <audiofile.h> + +#define TEST_FILE "/tmp/test.wave" + +int main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + int16_t frames16[] = {14298, 392, 3923, -683, 958, -1921}; + int8_t frames8[] = {55, 1, 15, -3, 3, -8}; + int i, frameCount = 6; + int8_t byte; + AFframecount result; + + setup = afNewFileSetup(); + + afInitFileFormat(setup, AF_FILE_WAVE); + + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_UNSIGNED, 8); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + + file = afOpenFile(TEST_FILE, "w", setup); + if (file == AF_NULL_FILEHANDLE) + { + fprintf(stderr, "could not open file for writing\n"); + exit(EXIT_FAILURE); + } + + afFreeFileSetup(setup); + + afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16); + + afWriteFrames(file, AF_DEFAULT_TRACK, frames16, frameCount); + + afCloseFile(file); + + file = afOpenFile(TEST_FILE, "r", AF_NULL_FILESETUP); + if (file == AF_NULL_FILEHANDLE) + { + fprintf(stderr, "could not open file for reading\n"); + exit(EXIT_FAILURE); + } + + afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 8); + + for (i=0; i<frameCount; i++) + { + /* Read one frame. */ + result = afReadFrames(file, AF_DEFAULT_TRACK, &byte, 1); + + if (result != 1) + break; + + /* Compare the byte read with its precalculated value. */ + if (memcmp(&byte, &frames8[i], 1) != 0) + { + printf("error\n"); + printf("expected %d, got %d\n", frames8[i], byte); + exit(EXIT_FAILURE); + } + else + { +#ifdef DEBUG + printf("got what was expected: %d\n", byte); +#endif + } + } + + afCloseFile(file); + unlink(TEST_FILE); + + exit(EXIT_SUCCESS); +} diff --git a/test/testaupv.c b/test/testaupv.c new file mode 100644 index 0000000..37946bb --- /dev/null +++ b/test/testaupv.c @@ -0,0 +1,80 @@ +/* + Audio File Library + + Copyright 1998, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + testaupv.c + + This is a program to test the AUpvlist commands. +*/ + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/dm_audioutil.h> +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#include <aupvlist.h> +#endif + +#include <stdio.h> +#include <stdlib.h> + +int main (int argc, char **argv) +{ + AUpvlist list; + int size; + AFfilehandle file; + + long fuck = 99; + + if (argc != 2) + { + fprintf(stderr, "usage: testaupv filename\n"); + exit(EXIT_FAILURE); + } + + file = afOpenFile(argv[1], "r", NULL); + + list = AUpvnew(4); + size = AUpvgetmaxitems(list); + + printf("AUpvsetparam: %d\n", AUpvsetparam(list, 0, AF_INST_MIDI_BASENOTE)); + printf("AUpvsetparam: %d\n", AUpvsetparam(list, 1, AF_INST_MIDI_LONOTE)); + printf("AUpvsetparam: %d\n", AUpvsetparam(list, 2, AF_INST_SUSLOOPID)); + printf("AUpvsetparam: %d\n", AUpvsetparam(list, 3, AF_INST_RELLOOPID)); + + afGetInstParams(file, AF_DEFAULT_INST, list, 4); + + AUpvgetval(list, 0, &fuck); + printf("AUpvgetval: %ld\n", fuck); + + AUpvgetval(list, 1, &fuck); + printf("AUpvgetval: %ld\n", fuck); + + AUpvgetval(list, 2, &fuck); + printf("AUpvgetval: %ld\n", fuck); + + AUpvgetval(list, 3, &fuck); + printf("AUpvgetval: %ld\n", fuck); + + afCloseFile(file); + + return 0; +} diff --git a/test/testchannelmatrix.c b/test/testchannelmatrix.c new file mode 100644 index 0000000..e2c016a --- /dev/null +++ b/test/testchannelmatrix.c @@ -0,0 +1,123 @@ +/* + Audio File Library + + Copyright (C) 2003, Silicon Graphics, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + testchannelmatrix.c + + This program tests the channel matrix functionality of virtual + sample format conversion in the Audio File Library. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <audiofile.h> + +#define TEST_FILE "/tmp/test.aiff" + +const short samples[] = {300, -300, 515, -515, 2315, -2315, 9154, -9154}; +#define SAMPLE_COUNT (sizeof (samples) / sizeof (short)) +#define CHANNEL_COUNT 2 + +void cleanup (void) +{ + unlink(TEST_FILE); +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (void) +{ + AFfilesetup setup; + AFfilehandle file; + int framesWritten, framesRead; + const int frameCount = SAMPLE_COUNT / CHANNEL_COUNT; + short readsamples[SAMPLE_COUNT]; + int i; + int sampleFormat, sampleWidth; + + setup = afNewFileSetup(); + + afInitChannels(setup, AF_DEFAULT_TRACK, CHANNEL_COUNT); + afInitFileFormat(setup, AF_FILE_AIFFC); + + /* Write stereo data to test file. */ + file = afOpenFile(TEST_FILE, "w", setup); + ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing"); + + afFreeFileSetup(setup); + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, samples, + frameCount); + ensure(framesWritten == frameCount, + "number of frames written doesn't match " + "number of frames requested"); + + ensure(afCloseFile(file) == 0, "error closing file"); + + /* + Open the test file and read stereo data mixed down to a + single channel. The default channel matrix for one + file channel and two virtual channels is {0.5, 0.5}, + and since each odd sample is the inverse of the + corresponding even sample, the data read should be all + zeros. + */ + file = afOpenFile(TEST_FILE, "r", AF_NULL_FILESETUP); + ensure(file != AF_NULL_FILEHANDLE, "could not open file for reading"); + + ensure(afGetChannels(file, AF_DEFAULT_TRACK) == 2, + "file doesn't have exactly two channels"); + afGetSampleFormat(file, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); + ensure(sampleFormat == AF_SAMPFMT_TWOSCOMP && sampleWidth == 16, + "file doesn't contain 16-bit two's complement data"); + ensure(afGetFileFormat(file, NULL) == AF_FILE_AIFFC, + "file format doesn't match format requested"); + + afSetVirtualChannels(file, AF_DEFAULT_TRACK, 1); + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, readsamples, + frameCount); + ensure(framesRead == frameCount, "number of frames read does not match number of frames requested"); + + for (i=0; i<SAMPLE_COUNT/CHANNEL_COUNT; i++) + { + ensure(readsamples[i] == 0, + "data written to file is not as expected"); + } + + ensure(afCloseFile(file) == 0, "error closing file"); + + cleanup(); + exit(EXIT_SUCCESS); +} diff --git a/test/testfloat.c b/test/testfloat.c new file mode 100644 index 0000000..daf29a6 --- /dev/null +++ b/test/testfloat.c @@ -0,0 +1,132 @@ +/* + Audio File Library + + Copyright (C) 2001, Silicon Graphics, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + testfloat.c + + This program tests floating-point reading and writing for + the AIFF-C, WAVE, NeXT .snd, and IRCAM file formats. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <audiofile.h> + +#define TEST_FILE "/tmp/test.float" + +const float samples[] = + {1.0, 0.6, -0.3, 0.95, 0.2, -0.6, 0.9, 0.4, -0.22, 0.125, 0.1, -0.4}; +#define SAMPLE_COUNT (sizeof (samples) / sizeof (float)) + +void testfloat (int fileFormat); + +void cleanup (void) +{ + unlink(TEST_FILE); +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (int argc, char **argv) +{ + /* These file formats support floating-point audio data. */ + int fileFormatCount = 4; + int fileFormats[] = + {AF_FILE_AIFFC, AF_FILE_WAVE, AF_FILE_NEXTSND, AF_FILE_IRCAM}; + char *formatNames[] = {"AIFF-C", "WAVE", "NeXT .snd", "IRCAM"}; + int i; + + for (i=0; i<fileFormatCount; i++) + { + printf("testfloat: testing %s\n", formatNames[i]); + testfloat(fileFormats[i]); + } + + printf("testfloat passed\n"); + exit(EXIT_SUCCESS); +} + +void testfloat (int fileFormat) +{ + AFfilesetup setup; + AFfilehandle file; + int framesWritten, framesRead; + const int frameCount = SAMPLE_COUNT/2; + float readsamples[SAMPLE_COUNT]; + int i; + int sampleFormat, sampleWidth; + + setup = afNewFileSetup(); + + afInitFileFormat(setup, fileFormat); + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_FLOAT, 32); + afInitChannels(setup, AF_DEFAULT_TRACK, 2); + + file = afOpenFile(TEST_FILE, "w", setup); + ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing"); + + afFreeFileSetup(setup); + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, samples, + frameCount); + ensure(framesWritten == frameCount, "number of frames written does not match number of frames requested"); + + ensure(afCloseFile(file) == 0, "error closing file"); + + file = afOpenFile(TEST_FILE, "r", AF_NULL_FILESETUP); + ensure(file != AF_NULL_FILEHANDLE, "could not open file for reading"); + + ensure(afGetChannels(file, AF_DEFAULT_TRACK) == 2, + "file doesn't have exactly two channels"); + afGetSampleFormat(file, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); + ensure(sampleFormat == AF_SAMPFMT_FLOAT && sampleWidth == 32, + "file doesn't contain 32-bit floating-point data"); + ensure(afGetFileFormat(file, NULL) == fileFormat, + "file format doesn't match format requested"); + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, readsamples, + frameCount); + ensure(framesRead == frameCount, "number of frames read does not match number of frames requested"); + + for (i=0; i<SAMPLE_COUNT; i++) + { + ensure(readsamples[i] == samples[i], + "data written to file doesn't match data read"); + } + + ensure(afCloseFile(file) == 0, "error closing file"); + + cleanup(); +} diff --git a/test/testmarkers.c b/test/testmarkers.c new file mode 100644 index 0000000..5dd5b1d --- /dev/null +++ b/test/testmarkers.c @@ -0,0 +1,134 @@ +/* + Audio File Library + + Copyright (C) 2002, Silicon Graphics, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <assert.h> +#include <audiofile.h> + +#define TEST_FILE "/tmp/markers.test" + +#define FRAME_COUNT 200 + +void cleanup (void) +{ +#ifndef DEBUG + unlink(TEST_FILE); +#endif +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int testmarkers (int fileformat) +{ + AFfilehandle file; + AFfilesetup setup; + int markids[] = {1, 2, 3, 4}; + AFframecount markpositions[] = {14, 54, 23, 101}; + const char *marknames[] = {"one", "two", "three", "four"}; + short frames[FRAME_COUNT * 2]; + int readmarkcount; + int readmarkids[4]; + AFframecount frameswritten; + int i; + + setup = afNewFileSetup(); + ensure(setup != AF_NULL_FILESETUP, "Could not create file setup"); + + afInitFileFormat(setup, fileformat); + afInitChannels(setup, AF_DEFAULT_TRACK, 2); + + afInitMarkIDs(setup, AF_DEFAULT_TRACK, markids, 4); + + afInitMarkName(setup, AF_DEFAULT_TRACK, markids[0], marknames[0]); + afInitMarkName(setup, AF_DEFAULT_TRACK, markids[1], marknames[1]); + afInitMarkName(setup, AF_DEFAULT_TRACK, markids[2], marknames[2]); + afInitMarkName(setup, AF_DEFAULT_TRACK, markids[3], marknames[3]); + + file = afOpenFile(TEST_FILE, "w", setup); + ensure(file != AF_NULL_FILEHANDLE, "Could not open file for writing"); + + afFreeFileSetup(setup); + + frameswritten = afWriteFrames(file, AF_DEFAULT_TRACK, frames, FRAME_COUNT); + ensure(frameswritten == FRAME_COUNT, "Error writing audio data"); + + afSetMarkPosition(file, AF_DEFAULT_TRACK, markids[0], markpositions[0]); + afSetMarkPosition(file, AF_DEFAULT_TRACK, markids[1], markpositions[1]); + afSetMarkPosition(file, AF_DEFAULT_TRACK, markids[2], markpositions[2]); + afSetMarkPosition(file, AF_DEFAULT_TRACK, markids[3], markpositions[3]); + + afCloseFile(file); + + file = afOpenFile(TEST_FILE, "r", NULL); + ensure(file != AF_NULL_FILEHANDLE, "Could not open file for reading"); + + readmarkcount = afGetMarkIDs(file, AF_DEFAULT_TRACK, NULL); + ensure(readmarkcount == 4, "Number of markers is not correct"); + + afGetMarkIDs(file, AF_DEFAULT_TRACK, readmarkids); + + for (i=0; i<readmarkcount; i++) + ensure(readmarkids[i] = markids[i], + "Marker identification numbers do not match"); + + for (i=0; i<readmarkcount; i++) + { + AFframecount readmarkposition; + const char *readmarkname; + + readmarkposition = afGetMarkPosition(file, AF_DEFAULT_TRACK, readmarkids[i]); + + readmarkname = afGetMarkName(file, AF_DEFAULT_TRACK, readmarkids[i]); + + ensure(readmarkposition == markpositions[i], + "Marker positions do not match"); + ensure(strcmp(readmarkname, marknames[i]) == 0, + "Marker names do not match"); + } + + afCloseFile(file); + + return EXIT_SUCCESS; +} + +int main (void) +{ + testmarkers(AF_FILE_AIFF); + testmarkers(AF_FILE_AIFFC); + testmarkers(AF_FILE_WAVE); + + cleanup(); + + return EXIT_SUCCESS; +} diff --git a/test/transparency.c b/test/transparency.c new file mode 100644 index 0000000..36620b9 --- /dev/null +++ b/test/transparency.c @@ -0,0 +1,129 @@ +/* + Audio File Library + + Copyright 1998-2000, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + transparency.c + + This program does a small sanity check on file writing + operations. + + If this program fails, something in the Audio File Library is broken. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#endif + +void usage (void) +{ + fprintf(stderr, "usage: transparency file1 file2 [format]\n"); + fprintf(stderr, "where format is one of aiff, aifc, next, or wave\n"); + fprintf(stderr, "(format defaults to aiff.)\n"); + exit(0); +} + +int main (int argc, char **argv) +{ + AFfilehandle outfile; + AFfilesetup outfilesetup; + unsigned short buffer[] = {0x1122, 0x3344, 0x5566, 0x7788, + 0x99aa, 0xbbcc, 0xddee, 0xff00}; + int format = AF_FILE_AIFF; + AFframecount result; + + if (argc < 3) + usage(); + + if (argc > 3) + { + if (!strcmp(argv[3], "aiff")) + format = AF_FILE_AIFF; + else if (!strcmp(argv[3], "aifc")) + format = AF_FILE_AIFFC; + else if (!strcmp(argv[3], "next")) + format = AF_FILE_NEXTSND; + else if (!strcmp(argv[3], "wave")) + format = AF_FILE_WAVE; + else + { + fprintf(stderr, "%s: invalid format.\n", argv[3]); + usage(); + } + } + + outfilesetup = afNewFileSetup(); + afInitFileFormat(outfilesetup, format); + + outfile = afOpenFile(argv[1], "w", outfilesetup); + if (outfile == AF_NULL_FILEHANDLE) + { + fprintf(stderr, "could not open file %s for writing\n", argv[1]); + exit(EXIT_FAILURE); + } + + result = afWriteFrames(outfile, AF_DEFAULT_TRACK, buffer, 2); + if (result != 2) + { + fprintf(stderr, "afWriteFrames did not return expected result\n"); + fprintf(stderr, "got %ld, expected 2\n", result); + exit(EXIT_FAILURE); + } + afWriteFrames(outfile, AF_DEFAULT_TRACK, buffer + 4, 2); + if (result != 2) + { + fprintf(stderr, "afWriteFrames did not return expected result\n"); + fprintf(stderr, "got %ld, expected 2\n", result); + exit(EXIT_FAILURE); + } + + afCloseFile(outfile); + + outfile = afOpenFile(argv[2], "w", outfilesetup); + if (outfile == AF_NULL_FILEHANDLE) + { + fprintf(stderr, "could not open file %s for writing\n", argv[1]); + exit(EXIT_FAILURE); + } + + result = afWriteFrames(outfile, AF_DEFAULT_TRACK, buffer, 4); + if (result != 4) + { + fprintf(stderr, "afWriteFrames did not return expected result\n"); + fprintf(stderr, "got %ld, expected 4\n", result); + exit(EXIT_FAILURE); + } + + afCloseFile(outfile); + + afFreeFileSetup(outfilesetup); + + return 0; +} diff --git a/test/transparency.sh b/test/transparency.sh new file mode 100755 index 0000000..365e16f --- /dev/null +++ b/test/transparency.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +for i in aiff aifc next wave +do + ./transparency /tmp/dicko1 /tmp/dicko2 $i || + (echo "did not complete test $i." ; exit) + diff /tmp/dicko1 /tmp/dicko2 || + (echo "failed $i format transparency test." ; exit) +done + +echo "passed all transparency tests." + +rm /tmp/dicko1 /tmp/dicko2 diff --git a/test/twentyfour.c b/test/twentyfour.c new file mode 100644 index 0000000..c5bcaf6 --- /dev/null +++ b/test/twentyfour.c @@ -0,0 +1,236 @@ +/* + Audio File Library + + Copyright (C) 2001, Silicon Graphics, Inc. + Michael Pruett <mpruett@sgi.com> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + twentyfour.c + + This program tests the conversion between 24-bit signed integer + data in a file and 32-bit signed integer data in memory. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <audiofile.h> +#include <assert.h> + +#define TEST_FILE "/tmp/test.aiff" +#define FRAME_COUNT 6 + +int main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + /* All elements in frames32 must be in the range -2^23 to 2^23 - 1. */ + const int32_t frames32[FRAME_COUNT] = + {4314298, -49392, 3923, -143683, 43, -992129}; + const u_int8_t frames24[FRAME_COUNT*3] = + { + 0x41, 0xd4, 0xba, /* 4314298 */ + 0xff, 0x3f, 0x10, /* -49392 */ + 0x00, 0x0f, 0x53, /* 3923 */ + 0xfd, 0xce, 0xbd, /* -143683 */ + 0x00, 0x00, 0x2b, /* 43 */ + 0xf0, 0xdc, 0x7f /* -992129 */ + }; + int32_t readframes32[FRAME_COUNT]; + int i; + + setup = afNewFileSetup(); + assert(setup); + + afInitFileFormat(setup, AF_FILE_AIFF); + + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 24); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + + file = afOpenFile(TEST_FILE, "w", setup); + if (file == AF_NULL_FILEHANDLE) + { + fprintf(stderr, "could not open file for writing\n"); + exit(EXIT_FAILURE); + } + + afFreeFileSetup(setup); + + afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 24); + afWriteFrames(file, AF_DEFAULT_TRACK, frames32, FRAME_COUNT); + + afCloseFile(file); + + file = afOpenFile(TEST_FILE, "r", AF_NULL_FILESETUP); + if (file == AF_NULL_FILEHANDLE) + { + fprintf(stderr, "could not open file for reading\n"); + exit(EXIT_FAILURE); + } + + /* Test virtual sample width of 24 bits. */ +#ifdef DEBUG + fprintf(stderr, "Testing virtual sample width of 24 bits.\n"); +#endif + afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 24); + + for (i=0; i<FRAME_COUNT; i++) + { + u_int8_t x[4]; + u_int8_t y[4]; + u_int8_t z[4]; + + if ((frames32[i] & 0x800000) != 0) + x[0] = 0xff; + else + x[0] = 0; + x[1] = (frames32[i] >> 16) & 0xff; + x[2] = (frames32[i] >> 8) & 0xff; + x[3] = (frames32[i]) & 0xff; + + /* + Check to see that the precomputed values match + what we've just computed. + */ + if (x[1] != frames24[3*i] || + x[2] != frames24[3*i + 1] || + x[3] != frames24[3*i + 2]) + { + fprintf(stderr, "Data doesn't match pre-computed values.\n"); + exit(EXIT_FAILURE); + } + + if (afReadFrames(file, AF_DEFAULT_TRACK, y, 1) != 1) + { + fprintf(stderr, "Could not read from test file.\n"); + exit(EXIT_FAILURE); + } + + /* + x is in big-endian byte order; make z a + native-endian copy of x. + */ +#ifdef WORDS_BIGENDIAN + memcpy(z, x, 4); +#else + z[0] = x[3]; + z[1] = x[2]; + z[2] = x[1]; + z[3] = x[0]; +#endif + +#ifdef DEBUG + printf("x = %02x %02x %02x %02x\n", x[0], x[1], x[2], x[3]); + printf("y = %02x %02x %02x %02x\n", y[0], y[1], y[2], y[3]); + printf("z = %02x %02x %02x %02x\n", z[0], z[1], z[2], z[3]); +#endif + + /* + Check to see that the data read from the file + matches computed value. + */ + if (memcmp(y, z, 4) != 0) + { + fprintf(stderr, "Data read from file is incorrect.\n"); + exit(EXIT_FAILURE); + } + } + + /* Test virtual sample width of 32 bits. */ +#ifdef DEBUG + fprintf(stderr, "Testing virtual sample width of 32 bits.\n"); +#endif + afSeekFrame(file, AF_DEFAULT_TRACK, 0); + afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 32); + + for (i=0; i<FRAME_COUNT; i++) + { + u_int8_t x[4]; + u_int8_t y[4]; + u_int8_t z[4]; + + x[0] = (frames32[i] >> 16) & 0xff; + x[1] = (frames32[i] >> 8) & 0xff; + x[2] = (frames32[i]) & 0xff; + x[3] = 0; + + /* + Check to see that the precomputed values match + what we've just computed. + */ + if (x[0] != frames24[3*i] || + x[1] != frames24[3*i + 1] || + x[2] != frames24[3*i + 2]) + { + fprintf(stderr, "Data doesn't match pre-computed values.\n"); + exit(EXIT_FAILURE); + } + + if (afReadFrames(file, AF_DEFAULT_TRACK, y, 1) != 1) + { + fprintf(stderr, "Could not read from test file.\n"); + exit(EXIT_FAILURE); + } + + /* + x is in big-endian byte order; make z a + native-endian copy of x. + */ +#ifdef WORDS_BIGENDIAN + memcpy(z, x, 4); +#else + z[0] = x[3]; + z[1] = x[2]; + z[2] = x[1]; + z[3] = x[0]; +#endif + +#ifdef DEBUG + printf("x = %02x %02x %02x %02x\n", x[0], x[1], x[2], x[3]); + printf("y = %02x %02x %02x %02x\n", y[0], y[1], y[2], y[3]); + printf("z = %02x %02x %02x %02x\n", z[0], z[1], z[2], z[3]); +#endif + + /* + Check to see that the data read from the file + matches computed value. + */ + if (memcmp(y, z, 4) != 0) + { + fprintf(stderr, "Data read from file is incorrect.\n"); + exit(EXIT_FAILURE); + } + } + + if (afCloseFile(file) != 0) + { + fprintf(stderr, "Error closing file.\n"); + exit(EXIT_FAILURE); + } + unlink(TEST_FILE); + + exit(EXIT_SUCCESS); +} diff --git a/test/twentyfour2.c b/test/twentyfour2.c new file mode 100644 index 0000000..6a83ce7 --- /dev/null +++ b/test/twentyfour2.c @@ -0,0 +1,127 @@ +/* + Audio File Library + + Copyright (C) 2003, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + twentyfour2.c + + This program checks reading and writing a large amount of 24-bit + audio data to an AIFF file. + + This program serves as a regression test for a bug in the Audio + File Library in which requesting more than _AF_ATOMIC_NVFRAMES + (1024 frames) from afReadFrames when reading a 24-bit audio file + would result in corrupted audio data. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> + +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif + +#include <audiofile.h> + +#define TEST_FILE "/tmp/test.aiff" +#define FRAME_COUNT 10000 + +void cleanup (void) +{ +#ifndef DEBUG + unlink(TEST_FILE); +#endif +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (void) +{ + AFfilehandle file; + AFfilesetup setup; + int32_t *buffer, *readbuffer; + int i; + AFframecount frameswritten, framesread; + + setup = afNewFileSetup(); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 24); + + file = afOpenFile(TEST_FILE, "w", setup); + ensure(file != NULL, "could not open test file for writing"); + + buffer = malloc(sizeof (int32_t) * FRAME_COUNT); + ensure(buffer != NULL, "could not allocate buffer for audio data"); + + readbuffer = malloc(sizeof (int32_t) * FRAME_COUNT); + ensure(readbuffer != NULL, "could not allocate buffer for audio data"); + + for (i=0; i<FRAME_COUNT; i++) + { + if ((i%3) == 0) + buffer[i] = -i; + else + buffer[i] = i; + } + + frameswritten = afWriteFrames(file, AF_DEFAULT_TRACK, buffer, FRAME_COUNT); + ensure(frameswritten == FRAME_COUNT, "incorrect number of frames written"); + + afCloseFile(file); + + /* + Now open file for reading and ensure that the data read + is equal to the data written. + */ + file = afOpenFile(TEST_FILE, "r", AF_NULL_FILESETUP); + ensure(file != NULL, "could not open test file for reading"); + + framesread = afReadFrames(file, AF_DEFAULT_TRACK, readbuffer, FRAME_COUNT); + ensure(framesread == FRAME_COUNT, "incorrect number of frames read"); + +#ifdef DEBUG + for (i=0; i<FRAME_COUNT; i++) + { + if (buffer[i] != readbuffer[i]) + { + printf("buffer[%d] = %d, readbuffer[%d] = %d\n", + i, buffer[i], i, readbuffer[i]); + } + } +#endif + + ensure(!memcmp(buffer, readbuffer, sizeof (int32_t) * FRAME_COUNT), + "data read does not match data written"); + + cleanup(); + return 0; +} diff --git a/test/writeaiff.c b/test/writeaiff.c new file mode 100644 index 0000000..6907c1b --- /dev/null +++ b/test/writeaiff.c @@ -0,0 +1,123 @@ +/* + Audio File Library + + Copyright 1998-1999, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + writeaiff.c + + This program tests the validity of the AIFF file reading and writing + code. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#endif + +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> + +#define TEST_FILE "/tmp/test.aiff" + +void cleanup (void) +{ +#ifndef DEBUG + unlink(TEST_FILE); +#endif +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + u_int16_t samples[] = {11, 51, 101, 501, 1001, 5001, 10001, 50001}; + int i; + int sampleFormat, sampleWidth; + int framesRead, framesWritten; + + setup = afNewFileSetup(); + afInitFileFormat(setup, AF_FILE_AIFF); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16); + + file = afOpenFile(TEST_FILE, "w", setup); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing"); + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, samples, 8); + ensure(framesWritten == 8, + "number of frames written does not match number of frames requested"); + + ensure(afCloseFile(file) == 0, "error closing file"); + afFreeFileSetup(setup); + + file = afOpenFile(TEST_FILE, "r", NULL); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for reading"); + + ensure(afGetFileFormat(file, NULL) == AF_FILE_AIFF, + "test file not created as AIFF"); + + afGetSampleFormat(file, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); + ensure(sampleFormat == AF_SAMPFMT_TWOSCOMP, + "test file not two's complement"); + ensure(sampleWidth == 16, + "test file sample format is not 16-bit"); + + ensure(afGetChannels(file, AF_DEFAULT_TRACK) == 1, + "test file doesn't have exactly one channel"); + + ensure(afGetByteOrder(file, AF_DEFAULT_TRACK) == AF_BYTEORDER_BIGENDIAN, + "test file not big-endian"); + + for (i=0; i<8; i++) + { + u_int16_t temporary; + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, &temporary, 1); + ensure(framesRead == 1, + "number of frames read does not match number of frames requested"); + + ensure(temporary == samples[i], + "data written to file doesn't match data read from file"); + } + + ensure(afCloseFile(file) == 0, "error closing file"); + + cleanup(); + + printf("writeaiff test passed.\n"); + + exit(0); +} diff --git a/test/writealaw.c b/test/writealaw.c new file mode 100644 index 0000000..c746831 --- /dev/null +++ b/test/writealaw.c @@ -0,0 +1,166 @@ +/* + Audio File Library + + Copyright (C) 2000, Michael Pruett <michael@68k.org> + Copyright (C) 2001, Silicon Graphics, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + writealaw.c + + The writealaw program performs sanity testing on the Audio File + Library's G.711 A-law compression by writing and then reading + back known data to a file to make sure the two sets of data agree. + + This program writes a set of data which is invariant under G.711 + A-law compression to a file and then reads that set of data back. + + The data read from that file should match the data written + exactly. + + If this test fails, something in the Audio File Library is broken. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#define TEST_FILE "/tmp/test.alaw" + +#define FRAME_COUNT 16 +#define SAMPLE_COUNT FRAME_COUNT + +void testalaw (int fileFormat); + +void cleanup (void) +{ +#ifndef DEBUG + unlink(TEST_FILE); +#endif +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (int argc, char **argv) +{ + printf("writealaw: testing NeXT .snd.\n"); + testalaw(AF_FILE_NEXTSND); + printf("writealaw: testing AIFF-C.\n"); + testalaw(AF_FILE_AIFFC); + printf("writealaw: testing WAVE.\n"); + testalaw(AF_FILE_WAVE); + + printf("writealaw test passed.\n"); + + exit(0); +} + +void testalaw (int fileFormat) +{ + AFfilehandle file; + AFfilesetup setup; + u_int16_t samples[] = {8, 24, 88, 120, 184, 784, 912, 976, + 1120, 1440, 1888, 8960, 9984, 16128, 19968, 32256}; + u_int16_t readsamples[SAMPLE_COUNT]; + AFframecount framesWritten, framesRead; + int i; + + setup = afNewFileSetup(); + + afInitCompression(setup, AF_DEFAULT_TRACK, AF_COMPRESSION_G711_ALAW); + afInitFileFormat(setup, fileFormat); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + + file = afOpenFile(TEST_FILE, "w", setup); + afFreeFileSetup(setup); + + ensure(afGetCompression(file, AF_DEFAULT_TRACK) == + AF_COMPRESSION_G711_ALAW, + "test file not created with G.711 A-law compression"); + + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing"); + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, samples, + FRAME_COUNT); + + ensure(framesWritten == FRAME_COUNT, + "number of frames requested does not match number of frames written"); + afCloseFile(file); + + /* Open the file for reading and verify the data. */ + file = afOpenFile(TEST_FILE, "r", NULL); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for reading"); + + ensure(afGetFileFormat(file, NULL) == fileFormat, + "test file format incorrect"); + + ensure(afGetCompression(file, AF_DEFAULT_TRACK) == + AF_COMPRESSION_G711_ALAW, + "test file not opened with G.711 A-law compression"); + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, readsamples, + FRAME_COUNT); + + ensure(framesRead == FRAME_COUNT, + "number of frames read does not match number of frames requested"); + +#ifdef DEBUG + for (i=0; i<SAMPLE_COUNT; i++) + printf("readsamples[%d]: %d\n", i, readsamples[i]); + for (i=0; i<SAMPLE_COUNT; i++) + printf("samples[%d]: %d\n", i, samples[i]); +#endif + + for (i=0; i<SAMPLE_COUNT; i++) + { + ensure(samples[i] == readsamples[i], + "data written does not match data read"); + } + + /* G.711 compression uses one byte per sample. */ + ensure(afGetTrackBytes(file, AF_DEFAULT_TRACK) == SAMPLE_COUNT, + "track byte count is incorrect"); + + ensure(afGetFrameCount(file, AF_DEFAULT_TRACK) == FRAME_COUNT, + "frame count is incorrect"); + + ensure(afGetChannels(file, AF_DEFAULT_TRACK) == 1, + "channel count is incorrect"); + + ensure(afCloseFile(file) == 0, "error closing file"); + + cleanup(); +} diff --git a/test/writeavr.c b/test/writeavr.c new file mode 100644 index 0000000..10c1c94 --- /dev/null +++ b/test/writeavr.c @@ -0,0 +1,123 @@ +/* + Audio File Library + + Copyright (C) 2004, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + writeavr.c + + This program tests the validity of the AVR file reading and + writing code. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#endif + +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> + +#define TEST_FILE "/tmp/test.avr" + +void cleanup (void) +{ +#ifndef DEBUG + unlink(TEST_FILE); +#endif +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + int16_t samples[] = {11, 51, 101, 501, 1001, 5001, 10001, 50001}; + int i; + int sampleFormat, sampleWidth; + int framesRead, framesWritten; + + setup = afNewFileSetup(); + afInitFileFormat(setup, AF_FILE_AVR); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16); + + file = afOpenFile(TEST_FILE, "w", setup); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing"); + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, samples, 8); + ensure(framesWritten == 8, + "number of frames written does not match number of frames requested"); + + ensure(afCloseFile(file) == 0, "error closing file"); + afFreeFileSetup(setup); + + file = afOpenFile(TEST_FILE, "r", NULL); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for reading"); + + ensure(afGetFileFormat(file, NULL) == AF_FILE_AVR, + "test file not created as AVR"); + + afGetSampleFormat(file, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); + ensure(sampleFormat == AF_SAMPFMT_TWOSCOMP, + "test file not two's complement"); + ensure(sampleWidth == 16, + "test file sample format is not 16-bit"); + + ensure(afGetChannels(file, AF_DEFAULT_TRACK) == 1, + "test file doesn't have exactly one channel"); + + ensure(afGetByteOrder(file, AF_DEFAULT_TRACK) == AF_BYTEORDER_BIGENDIAN, + "test file not big-endian"); + + for (i=0; i<8; i++) + { + int16_t temporary; + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, &temporary, 1); + ensure(framesRead == 1, + "number of frames read does not match number of frames requested"); + + ensure(temporary == samples[i], + "data written to file doesn't match data read from file"); + } + + ensure(afCloseFile(file) == 0, "error closing file"); + + cleanup(); + + printf("writeavr test passed.\n"); + + exit(0); +} diff --git a/test/writeiff.c b/test/writeiff.c new file mode 100644 index 0000000..63d714b --- /dev/null +++ b/test/writeiff.c @@ -0,0 +1,123 @@ +/* + Audio File Library + + Copyright (C) 2004, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + writeiff.c + + This program tests the validity of the IFF/8SVX file reading + and writing code. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#endif + +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> + +#define TEST_FILE "/tmp/test.iff" + +void cleanup (void) +{ +#ifndef DEBUG + unlink(TEST_FILE); +#endif +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + int8_t samples[] = {11, 51, 101, -101, -54, 120, -15, 99}; + int i; + int sampleFormat, sampleWidth; + int framesRead, framesWritten; + + setup = afNewFileSetup(); + afInitFileFormat(setup, AF_FILE_IFF_8SVX); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 8); + + file = afOpenFile(TEST_FILE, "w", setup); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing"); + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, samples, 7); + ensure(framesWritten == 7, + "number of frames written does not match number of frames requested"); + + ensure(afCloseFile(file) == 0, "error closing file"); + afFreeFileSetup(setup); + + file = afOpenFile(TEST_FILE, "r", NULL); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for reading"); + + ensure(afGetFileFormat(file, NULL) == AF_FILE_IFF_8SVX, + "test file not created as IFF/8SVX"); + + afGetSampleFormat(file, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); + ensure(sampleFormat == AF_SAMPFMT_TWOSCOMP, + "test file not two's complement"); + ensure(sampleWidth == 8, + "test file sample format is not 8-bit"); + + ensure(afGetChannels(file, AF_DEFAULT_TRACK) == 1, + "test file doesn't have exactly one channel"); + + ensure(afGetByteOrder(file, AF_DEFAULT_TRACK) == AF_BYTEORDER_BIGENDIAN, + "test file not big-endian"); + + for (i=0; i<7; i++) + { + int8_t temporary; + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, &temporary, 1); + ensure(framesRead == 1, + "number of frames read does not match number of frames requested"); + + ensure(temporary == samples[i], + "data written to file doesn't match data read from file"); + } + + ensure(afCloseFile(file) == 0, "error closing file"); + + cleanup(); + + printf("writeiff test passed.\n"); + + exit(0); +} diff --git a/test/writeircam.c b/test/writeircam.c new file mode 100644 index 0000000..b46dc16 --- /dev/null +++ b/test/writeircam.c @@ -0,0 +1,128 @@ +/* + Audio File Library + + Copyright 1998-1999, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + writeircam.c + + This program tests the validity of the IRCAM/BICSF format + reading and writing code. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#endif + +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> + +#define TEST_FILE "/tmp/test.au" + +void cleanup (void) +{ +#ifndef DEBUG + unlink(TEST_FILE); +#endif +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + u_int16_t samples[] = {11, 51, 101, 501, 1001, 5001, 10001, 50001}; + int i; + int sampleFormat, sampleWidth; + int framesRead, framesWritten; + + setup = afNewFileSetup(); + afInitFileFormat(setup, AF_FILE_IRCAM); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16); + + file = afOpenFile(TEST_FILE, "w", setup); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing"); + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, samples, 8); + ensure(framesWritten == 8, + "number of frames written does not match number of frames requested"); + + ensure(afCloseFile(file) == 0, "error closing file"); + afFreeFileSetup(setup); + + file = afOpenFile(TEST_FILE, "r", NULL); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for reading"); + + ensure(afGetFileFormat(file, NULL) == AF_FILE_IRCAM, + "test file not created as IRCAM/BICSF"); + + afGetSampleFormat(file, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); + ensure(sampleFormat == AF_SAMPFMT_TWOSCOMP, + "test file not two's complement"); + ensure(sampleWidth == 16, + "test file sample format is not 16-bit"); + + ensure(afGetChannels(file, AF_DEFAULT_TRACK) == 1, + "test file doesn't have exactly one channel"); + +#ifdef WORDS_BIGENDIAN + ensure(afGetByteOrder(file, AF_DEFAULT_TRACK) == AF_BYTEORDER_BIGENDIAN, + "test file not big-endian"); +#else + ensure(afGetByteOrder(file, AF_DEFAULT_TRACK) == AF_BYTEORDER_LITTLEENDIAN, + "test file not little-endian"); +#endif + + for (i=0; i<8; i++) + { + u_int16_t temporary; + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, &temporary, 1); + ensure(framesRead == 1, + "number of frames read does not match number of frames requested"); + + ensure(temporary == samples[i], + "data written to file doesn't match data read from file"); + } + + ensure(afCloseFile(file) == 0, "error closing file"); + + cleanup(); + + printf("writeircam test passed.\n"); + + exit(0); +} diff --git a/test/writenext.c b/test/writenext.c new file mode 100644 index 0000000..7d1c16b --- /dev/null +++ b/test/writenext.c @@ -0,0 +1,123 @@ +/* + Audio File Library + + Copyright 1998-1999, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + writenext.c + + This program tests the validity of the NeXT/Sun .snd/.au format + reading and writing code. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#endif + +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> + +#define TEST_FILE "/tmp/test.au" + +void cleanup (void) +{ +#ifndef DEBUG + unlink(TEST_FILE); +#endif +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + u_int16_t samples[] = {11, 51, 101, 501, 1001, 5001, 10001, 50001}; + int i; + int sampleFormat, sampleWidth; + int framesRead, framesWritten; + + setup = afNewFileSetup(); + afInitFileFormat(setup, AF_FILE_NEXTSND); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16); + + file = afOpenFile(TEST_FILE, "w", setup); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing"); + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, samples, 8); + ensure(framesWritten == 8, + "number of frames written does not match number of frames requested"); + + ensure(afCloseFile(file) == 0, "error closing file"); + afFreeFileSetup(setup); + + file = afOpenFile(TEST_FILE, "r", NULL); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for reading"); + + ensure(afGetFileFormat(file, NULL) == AF_FILE_NEXTSND, + "test file not created as NeXT/Sun .snd/.au"); + + afGetSampleFormat(file, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); + ensure(sampleFormat == AF_SAMPFMT_TWOSCOMP, + "test file not two's complement"); + ensure(sampleWidth == 16, + "test file sample format is not 16-bit"); + + ensure(afGetChannels(file, AF_DEFAULT_TRACK) == 1, + "test file doesn't have exactly one channel"); + + ensure(afGetByteOrder(file, AF_DEFAULT_TRACK) == AF_BYTEORDER_BIGENDIAN, + "test file not big-endian"); + + for (i=0; i<8; i++) + { + u_int16_t temporary; + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, &temporary, 1); + ensure(framesRead == 1, + "number of frames read does not match number of frames requested"); + + ensure(temporary == samples[i], + "data written to file doesn't match data read from file"); + } + + ensure(afCloseFile(file) == 0, "error closing file"); + + cleanup(); + + printf("writenext test passed.\n"); + + exit(0); +} diff --git a/test/writenist.c b/test/writenist.c new file mode 100644 index 0000000..454a92a --- /dev/null +++ b/test/writenist.c @@ -0,0 +1,128 @@ +/* + Audio File Library + + Copyright (C) 2004, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + writenist.c + + This program tests the validity of the NIST SPHERE format + reading and writing code. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#endif + +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> + +#define TEST_FILE "/tmp/test.sph" + +void cleanup (void) +{ +#ifndef DEBUG + unlink(TEST_FILE); +#endif +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + int16_t samples[] = {11, 51, -101, 501, 1001, -5001, -10001, 50001}; + int i; + int sampleFormat, sampleWidth; + int framesRead, framesWritten; + + setup = afNewFileSetup(); + afInitFileFormat(setup, AF_FILE_NIST_SPHERE); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16); + + file = afOpenFile(TEST_FILE, "w", setup); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing"); + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, samples, 8); + ensure(framesWritten == 8, + "number of frames written does not match number of frames requested"); + + ensure(afCloseFile(file) == 0, "error closing file"); + afFreeFileSetup(setup); + + file = afOpenFile(TEST_FILE, "r", NULL); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for reading"); + + ensure(afGetFileFormat(file, NULL) == AF_FILE_NIST_SPHERE, + "test file not created as NIST SPHERE"); + + afGetSampleFormat(file, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); + ensure(sampleFormat == AF_SAMPFMT_TWOSCOMP, + "test file not two's complement"); + ensure(sampleWidth == 16, + "test file sample format is not 16-bit"); + + ensure(afGetChannels(file, AF_DEFAULT_TRACK) == 1, + "test file doesn't have exactly one channel"); + +#if WORDS_BIGENDIAN + ensure(afGetByteOrder(file, AF_DEFAULT_TRACK) == AF_BYTEORDER_BIGENDIAN, + "test file not big-endian"); +#else + ensure(afGetByteOrder(file, AF_DEFAULT_TRACK) == AF_BYTEORDER_LITTLEENDIAN, + "test file not little-endian"); +#endif + + for (i=0; i<8; i++) + { + int16_t temporary; + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, &temporary, 1); + ensure(framesRead == 1, + "number of frames read does not match number of frames requested"); + + ensure(temporary == samples[i], + "data written to file doesn't match data read from file"); + } + + ensure(afCloseFile(file) == 0, "error closing file"); + + cleanup(); + + printf("writenist test passed.\n"); + + exit(0); +} diff --git a/test/writeraw.c b/test/writeraw.c new file mode 100644 index 0000000..5729a48 --- /dev/null +++ b/test/writeraw.c @@ -0,0 +1,130 @@ +/* + Audio File Library + + Copyright (C) 1998-1999, Michael Pruett <michael@68k.org> + Copyright (C) 2002, Silicon Graphics, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + writeraw.c + + This program tests the validity of the AIFF file reading and writing + code. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#endif + +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> + +#define TEST_FILE "/tmp/test.raw" + +void cleanup (void) +{ +#ifndef DEBUG + unlink(TEST_FILE); +#endif +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + u_int16_t samples[] = {11, 51, 101, 501, 1001, 5001, 10001, 50001}; + int i; + int sampleFormat, sampleWidth; + int framesRead, framesWritten; + int nativeByteOrder; + +#ifdef WORDS_BIGENDIAN + nativeByteOrder = AF_BYTEORDER_BIGENDIAN; +#else + nativeByteOrder = AF_BYTEORDER_LITTLEENDIAN; +#endif + + setup = afNewFileSetup(); + afInitFileFormat(setup, AF_FILE_RAWDATA); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16); + + file = afOpenFile(TEST_FILE, "w", setup); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing"); + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, samples, 8); + ensure(framesWritten == 8, + "number of frames written does not match number of frames requested"); + + ensure(afCloseFile(file) == 0, "error closing file"); + + file = afOpenFile(TEST_FILE, "r", setup); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for reading"); + + ensure(afGetFileFormat(file, NULL) == AF_FILE_RAWDATA, + "test file not created as raw audio data file"); + + afGetSampleFormat(file, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); + ensure(sampleFormat == AF_SAMPFMT_TWOSCOMP, + "test file not two's complement"); + ensure(sampleWidth == 16, + "test file sample format is not 16-bit"); + + ensure(afGetChannels(file, AF_DEFAULT_TRACK) == 1, + "test file doesn't have exactly one channel"); + + ensure(afGetByteOrder(file, AF_DEFAULT_TRACK) == nativeByteOrder, + "test file not in native byte order"); + + for (i=0; i<8; i++) + { + u_int16_t temporary; + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, &temporary, 1); + ensure(framesRead == 1, + "number of frames read does not match number of frames requested"); + + ensure(temporary == samples[i], + "data written to file doesn't match data read from file"); + } + + ensure(afCloseFile(file) == 0, "error closing file"); + + cleanup(); + + printf("writeraw test passed.\n"); + + exit(EXIT_SUCCESS); +} diff --git a/test/writeulaw.c b/test/writeulaw.c new file mode 100644 index 0000000..45d76b2 --- /dev/null +++ b/test/writeulaw.c @@ -0,0 +1,166 @@ +/* + Audio File Library + + Copyright (C) 2000, Michael Pruett <michael@68k.org> + Copyright (C) 2001, Silicon Graphics, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + writeulaw.c + + The writeulaw program performs sanity testing on the Audio File + Library's G.711 u-law compression by writing and then reading + back known data to a file to make sure the two sets of data agree. + + This program writes a set of data which is invariant under G.711 + u-law compression to a file and then reads that set of data back. + + The data read from that file should match the data written + exactly. + + If this test fails, something in the Audio File Library is broken. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#define TEST_FILE "/tmp/test.ulaw" + +#define FRAME_COUNT 16 +#define SAMPLE_COUNT FRAME_COUNT + +void testulaw (int fileFormat); + +void cleanup (void) +{ +#ifndef DEBUG + unlink(TEST_FILE); +#endif +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (int argc, char **argv) +{ + printf("writeulaw: testing NeXT .snd.\n"); + testulaw(AF_FILE_NEXTSND); + printf("writeulaw: testing AIFF-C.\n"); + testulaw(AF_FILE_AIFFC); + printf("writeulaw: testing WAVE.\n"); + testulaw(AF_FILE_WAVE); + + printf("writeulaw test passed.\n"); + + exit(0); +} + +void testulaw (int fileFormat) +{ + AFfilehandle file; + AFfilesetup setup; + u_int16_t samples[] = {8, 16, 80, 120, 180, 780, 924, 988, + 1116, 1436, 1884, 8828, 9852, 15996, 19836, 32124}; + u_int16_t readsamples[SAMPLE_COUNT]; + AFframecount framesWritten, framesRead; + int i; + + setup = afNewFileSetup(); + + afInitCompression(setup, AF_DEFAULT_TRACK, AF_COMPRESSION_G711_ULAW); + afInitFileFormat(setup, fileFormat); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + + file = afOpenFile(TEST_FILE, "w", setup); + afFreeFileSetup(setup); + + ensure(afGetCompression(file, AF_DEFAULT_TRACK) == + AF_COMPRESSION_G711_ULAW, + "test file not created with G.711 u-law compression"); + + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing"); + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, samples, + FRAME_COUNT); + + ensure(framesWritten == FRAME_COUNT, + "number of frames requested does not match number of frames written"); + afCloseFile(file); + + /* Open the file for reading and verify the data. */ + file = afOpenFile(TEST_FILE, "r", NULL); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for reading"); + + ensure(afGetFileFormat(file, NULL) == fileFormat, + "test file format incorrect"); + + ensure(afGetCompression(file, AF_DEFAULT_TRACK) == + AF_COMPRESSION_G711_ULAW, + "test file not opened with G.711 u-law compression"); + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, readsamples, + FRAME_COUNT); + + ensure(framesRead == FRAME_COUNT, + "number of frames read does not match number of frames requested"); + +#ifdef DEBUG + for (i=0; i<SAMPLE_COUNT; i++) + printf("readsamples[%d]: %d\n", i, readsamples[i]); + for (i=0; i<SAMPLE_COUNT; i++) + printf("samples[%d]: %d\n", i, samples[i]); +#endif + + for (i=0; i<SAMPLE_COUNT; i++) + { + ensure(samples[i] == readsamples[i], + "data written does not match data read"); + } + + /* G.711 compression uses one byte per sample. */ + ensure(afGetTrackBytes(file, AF_DEFAULT_TRACK) == SAMPLE_COUNT, + "track byte count is incorrect"); + + ensure(afGetFrameCount(file, AF_DEFAULT_TRACK) == FRAME_COUNT, + "frame count is incorrect"); + + ensure(afGetChannels(file, AF_DEFAULT_TRACK) == 1, + "channel count is incorrect"); + + ensure(afCloseFile(file) == 0, "error closing file"); + + cleanup(); +} diff --git a/test/writewave.c b/test/writewave.c new file mode 100644 index 0000000..65afede --- /dev/null +++ b/test/writewave.c @@ -0,0 +1,123 @@ +/* + Audio File Library + + Copyright 1998-1999, Michael Pruett <michael@68k.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307, USA. +*/ + +/* + writewave.c + + This program tests the validity of the MS RIFF Wave format reading + and writing code. +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> + +#ifdef __USE_SGI_HEADERS__ +#include <dmedia/audiofile.h> +#else +#include <audiofile.h> +#endif + +#define TEST_FILE "/tmp/test.wave" + +void cleanup (void) +{ +#ifndef DEBUG + unlink(TEST_FILE); +#endif +} + +void ensure (int condition, const char *message) +{ + if (!condition) + { + printf("%s.\n", message); + cleanup(); + exit(EXIT_FAILURE); + } +} + +int main (int argc, char **argv) +{ + AFfilehandle file; + AFfilesetup setup; + u_int16_t samples[] = {11, 51, 101, 501, 1001, 5001, 10001, 50001}; + int i; + int sampleFormat, sampleWidth; + int framesRead, framesWritten; + + setup = afNewFileSetup(); + afInitFileFormat(setup, AF_FILE_WAVE); + afInitChannels(setup, AF_DEFAULT_TRACK, 1); + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16); + + file = afOpenFile(TEST_FILE, "w", setup); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing"); + + framesWritten = afWriteFrames(file, AF_DEFAULT_TRACK, samples, 8); + ensure(framesWritten == 8, + "number of frames written does not match number of frames requested"); + + ensure(afCloseFile(file) == 0, "error closing file"); + afFreeFileSetup(setup); + + file = afOpenFile(TEST_FILE, "r", NULL); + ensure(file != AF_NULL_FILEHANDLE, "unable to open file for reading"); + + ensure(afGetFileFormat(file, NULL) == AF_FILE_WAVE, + "test file not created as Wave"); + + afGetSampleFormat(file, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); + ensure(sampleFormat == AF_SAMPFMT_TWOSCOMP, + "test file not two's complement"); + ensure(sampleWidth == 16, + "test file sample format is not 16-bit"); + + ensure(afGetChannels(file, AF_DEFAULT_TRACK) == 1, + "test file doesn't have exactly one channel"); + + ensure(afGetByteOrder(file, AF_DEFAULT_TRACK) == AF_BYTEORDER_LITTLEENDIAN, + "test file not little-endian"); + + for (i=0; i<8; i++) + { + u_int16_t temporary; + + framesRead = afReadFrames(file, AF_DEFAULT_TRACK, &temporary, 1); + ensure(framesRead == 1, + "number of frames read does not match number of frames requested"); + + ensure(temporary == samples[i], + "data written to file doesn't match data read from file"); + } + + ensure(afCloseFile(file) == 0, "error closing file"); + + cleanup(); + + printf("writewave test passed.\n"); + + exit(0); +} |