aboutsummaryrefslogtreecommitdiff
path: root/pd/src
diff options
context:
space:
mode:
authorGuenter Geiger <ggeiger@users.sourceforge.net>2004-02-02 11:28:02 +0000
committerGuenter Geiger <ggeiger@users.sourceforge.net>2004-02-02 11:28:02 +0000
commitae6b5d89ea93b95c2990895077cf5e8f0bba9ad9 (patch)
tree1e7570f11ac688e94342968e90301c4684e61193 /pd/src
parentf26399eba6ee6ce9eb7bae9a4b60a90dc2ebca94 (diff)
This commit was generated by cvs2svn to compensate for changes in r1301,
which included commits to RCS files with non-trunk default branches. svn path=/trunk/; revision=1302
Diffstat (limited to 'pd/src')
-rw-r--r--pd/src/CHANGELOG.txt80
-rw-r--r--pd/src/configure.in.ok248
-rw-r--r--pd/src/configure.in.oops272
-rw-r--r--pd/src/configure.in.pa_v19231
-rw-r--r--pd/src/d_delay.c4
-rw-r--r--pd/src/d_global.c15
-rw-r--r--pd/src/d_osc.c4
-rw-r--r--pd/src/makefile.nt102
-rw-r--r--pd/src/makefile.nt.pa19185
-rw-r--r--pd/src/s_audio_alsa.c.old946
-rw-r--r--pd/src/x_midi.c17
11 files changed, 1994 insertions, 110 deletions
diff --git a/pd/src/CHANGELOG.txt b/pd/src/CHANGELOG.txt
new file mode 100644
index 00000000..27441d36
--- /dev/null
+++ b/pd/src/CHANGELOG.txt
@@ -0,0 +1,80 @@
+This file describes implementation and API changes; stuff more visible to the
+user appears in the "release notes" instead.
+
+0.37.1
+
+makefile.in: MANINSTDIR = $(DESTDIR)/$(MANDIR) changed to
+ $(DESTDIR)/$(INSTALL_PREFIX)/$(MANDIR) (thx. Mathieu Bouchard)
+
+applied 2 jack patches from Luke Yelavich
+
+add -fno-strict-aliasing to config script (linux&mac) to improve underflow,
+etc., protection
+
+add underflow protection to vcf~ object; rewrote underflow protection to be
+faster in throw~/catch~ and send~/receive~
+
+fixed bug in -inchannels/-outchannels arg parsing
+
+fixed u_main.tk to make "apple" key work to accelerate menus on MACOS
+
+fooled with MIDI to try to get sysex and other system messages to work.
+Needs lots of testing now...
+
+finally fixed OSS to open audio with NODELAY... also cleared dup-on-exec flag.
+
+bug fix in scalar_properties
+
+major editions to the IEM GUIs to fix bugs in how "$" variables are handled.
+The code still isn't pretty but hopefully at least works now.
+
+tried to get alsa noninterleaved access to work (needed for RME). Failed
+to get my RME card to load under ALSA and gave up for now.
+
+fixed scalar drawing to fail gracefully when the template canvas disappears
+
+bug fix in vd~ for very small delays (d_delay.c)
+
+set up sys_oldtclversion flag to correct for changed text selection
+(u_main.tk, s_main.c, g_rtext.c)
+
+tried again to add "readn" support to s_audio_alsa.c: coded, but failing so far.
+
+fixed broken octave divider example
+
+removed "-Werror" from default makefile; fixed configure script to respect
+"CFLAGS" environment variable instead. Suggest developers should use
+"setenv CFLAGS -Werror".
+
+added "-alsaadd" flag so people can specify alsa devnames to add to list.
+fixed some problems with Pd crashing when ALSA failed to open.
+
+took out the 2-pixel padding for MSW in g_canvas.g (HORIZBORDER/VERTBORDER)
+
+went back to s_midi_mmio (portaudio version got assertion errors and anyway
+I could never get sysex working in it as I had wanted.)
+
+Took bug fixes from s_midi_pm.c, s_audio_jack.c, s_inter.c from "devel" branch;
+also added "static" flag to configure.in (but the devel configure.in as a whole
+doesn't seem to work for OSX, for me at least.)
+
+Might have fixed a bug where labels disappear in buttons, etc, when saved
+and reloaded.
+
+brought s_audio_alsa.c up to alsa 1.0.0 compatibility
+
+fixed "-alsaadd" (never worked before)
+
+fooled with macintosh audio. Fixed some (not all) of the audio I/O APIs
+to deal with open failures better (reducing sys_{in,out}channels accordingly)
+
+In the Alsa API, the synchronization test was too stringent and was loosened
+to 3*DACBLKSIZE/2.
+
+'make install' fixed to deal with 'extra' correctly.
+
+one more improvement in jack support (guenter)
+
+make an "nrt" flag so mac can disable pthread_setschedparam call if yu want.
+
+
diff --git a/pd/src/configure.in.ok b/pd/src/configure.in.ok
new file mode 100644
index 00000000..897eafdf
--- /dev/null
+++ b/pd/src/configure.in.ok
@@ -0,0 +1,248 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(d_arithmetic.c)
+
+AC_SUBST(alsa)
+AC_SUBST(jack, no)
+AC_SUBST(portaudio)
+AC_SUBST(PDLIB)
+AC_SUBST(DEFINES)
+AC_SUBST(MORECFLAGS)
+AC_SUBST(EXT)
+AC_SUBST(OPT_CFLAGS)
+AC_SUBST(USE_OPT_CFLAGS, YES)
+AC_SUBST(SYSSRC)
+AC_SUBST(STRIPFLAG)
+AC_SUBST(GUINAME)
+AC_SUBST(GUIFLAGS)
+AC_SUBST(OSNUMBER)
+AC_SUBST(EXTERNTARGET)
+
+dnl other defaults
+
+dnl check for features
+
+AC_ARG_ENABLE(alsa, [ --disable-alsa disable ALSA],
+ alsa="no")
+AC_ARG_ENABLE(jack, [ --enable-jack jack audio server],
+ jack="yes")
+AC_ARG_ENABLE(portaudio, [ --enable-portaudio portaudio],
+ portaudio="yes")
+AC_ARG_ENABLE(debug, [ --enable-debug debugging support],
+ USE_OPT_CFLAGS="no")
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+AC_PROG_CPP
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_HEADER_TIME
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/ioctl.h sys/time.h unistd.h bstring.h)
+
+dnl Checks for library functions.
+AC_PROG_GCC_TRADITIONAL
+AC_TYPE_SIGNAL
+AC_FUNC_VPRINTF
+AC_CHECK_FUNCS(gettimeofday select socket strerror)
+
+
+dnl Checks for libraries.
+dnl Checking for `dlopen' function in -ldl:
+AC_CHECK_LIB(dl, dlopen,PDLIB="$PDLIB -ldl",
+ echo "dynamic link support required" || exit 1)
+
+dnl Checking for `sin' function in -lffm:
+dnl ffm is the fast math library on the alpha
+AC_CHECK_LIB(ffm, sin,PDLIB="$PDLIB -lffm")
+
+dnl Checking for `sin' function in -lm:
+AC_CHECK_LIB(m, sin,PDLIB="$PDLIB -lm",
+ echo "math library required" || exit 1)
+
+dnl Checking for `pthread_create' function in -pthread
+AC_CHECK_LIB(pthread, pthread_create,PDLIB="$PDLIB -lpthread",
+ echo "pthreads required" || exit 1)
+
+dnl This should be fixed so Pd can use ALSA shared libraries where appropriate.
+if test "$alsa" != no; then
+ AC_CHECK_LIB(asound,snd_pcm_info,PDLIB="$PDLIB -lasound" ; alsa="yes",alsa="")
+fi
+
+dnl Find paths to includes and libraries for X11
+AC_PATH_X
+dnl Checking for `XCreateWindow' function in -lX11:
+AC_CHECK_LIB(X11, XCreateWindow, LIBS="$LIBS -lX11 -L$x_libraries",
+ echo "no X11 found" || exit 1, -L$x_libraries)
+
+dnl look for tcl 8.x... do I really have to go through all this!?
+
+foundit=no
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl.h,foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl8.7/tcl.h,
+ GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.7";foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl8.6/tcl.h,
+ GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.6";foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl8.5/tcl.h,
+ GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.5";foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl8.4/tcl.h,
+ GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.4";foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl8.3/tcl.h,
+ GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.3";foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl8.2/tcl.h,
+ GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.2";foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ echo no tcl header found
+ exit -1
+fi
+
+AC_CHECK_LIB(tcl8.7, main,,
+ AC_CHECK_LIB(tcl8.6, main,,
+ AC_CHECK_LIB(tcl8.5, main,,
+ AC_CHECK_LIB(tcl8.4, main,,
+ AC_CHECK_LIB(tcl8.3, main,,
+ AC_CHECK_LIB(tcl8.2, main,,
+ AC_CHECK_LIB(tcl8.0, main,,echo no tcl library found || exit 1)))))))
+
+AC_CHECK_LIB(tk8.7, main,,
+ AC_CHECK_LIB(tk8.6, main,,
+ AC_CHECK_LIB(tk8.5, main,,
+ AC_CHECK_LIB(tk8.4, main,,
+ AC_CHECK_LIB(tk8.3, main,,
+ AC_CHECK_LIB(tk8.2, main,,
+ AC_CHECK_LIB(tk8.0, main,,echo no tk library found || exit 1)))))))
+
+dnl Checking for tk.h or tkstep.h - not used at the moment
+dnl AC_CHECK_HEADER(tk.h,DEFINES="$DEFINES -DTKINC=\\\"tk.h\\\"")
+dnl AC_CHECK_HEADER(tkstep.h,DEFINES="$DEFINES -DTKINC=\\\"tkstep.h\\\"")
+
+if test `uname -s` = Linux;
+then
+ LDFLAGS="-Wl,-export-dynamic"
+ EXT=pd_linux
+ MORECFLAGS="-DDL_OPEN -DUSEAPI_PORTAUDIO -DPA_USE_OSS -DPA_LITTLE_ENDIAN \
+ -DUSEAPI_OSS \
+ -I../portaudio/pa_common \
+ -I../portaudio/pablio -I../portaudio/portmidi-macosx -Werror"
+ SYSSRC="s_midi_oss.c s_audio_pa.c s_audio_oss.c \
+ ../portaudio/pa_common/pa_allocation.c \
+ ../portaudio/pa_common/pa_converters.c \
+ ../portaudio/pa_common/pa_cpuload.c \
+ ../portaudio/pa_common/pa_dither.c \
+ ../portaudio/pa_common/pa_front.c \
+ ../portaudio/pa_common/pa_process.c \
+ ../portaudio/pa_common/pa_skeleton.c \
+ ../portaudio/pa_common/pa_stream.c \
+ ../portaudio/pa_common/pa_trace.c \
+ ../portaudio/pablio/pablio_pd.c \
+ ../portaudio/pablio/ringbuffer_pd.c \
+ ../portaudio/pa_unix/pa_unix_hostapis.c \
+ ../portaudio/pa_unix/pa_unix_util.c \
+ ../portaudio/pa_unix_oss/pa_unix_oss.c "
+ STRIPFLAG=-s
+ GUINAME="pd-gui"
+ if test $USE_OPT_CFLAGS == "YES";
+ then
+ OPT_CFLAGS="-O6 -funroll-loops -fomit-frame-pointer"
+ else
+ OPT_CFLAGS="-g"
+ fi
+ OSNUMBER=0
+fi
+
+dnl **** note -- SGI/IRIX code is broken here!!! ***
+
+if test `uname -s` = IRIX64;
+then
+ LDFLAGS="-n32 -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \
+ -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \
+ -shared -rdata_shared"
+ EXT=pd_irix6
+ MORECFLAGS=-DDL_OPEN
+ SYSSRC=s_sgi.c
+ STRIPFLAG=-s
+ GUINAME="pd-gui"
+ OSNUMBER=0
+fi
+
+if test `uname -s` = IRIX32;
+then
+ LDFLAGS="-o32 -DUNIX -DIRIX -O2 -shared -rdata_shared"
+ EXT=pd_irix5
+ MORECFLAGS=-DDL_OPEN
+ SYSSRC=s_sgi.c
+ STRIPFLAG=-s
+ GUINAME="pd-gui"
+ OSNUMBER=0
+fi
+
+if test `uname -s` = Darwin;
+then
+ LDFLAGS="-Wl -framework Tcl -framework Tk -framework CoreAudio \
+ -framework AudioUnit -framework AudioToolbox \
+ -framework Carbon -framework CoreMIDI"
+ EXT=pd_darwin
+ MORECFLAGS="-DMACOSX -I/usr/X11R6/include \
+ -I../portaudio_v18/pa_common \
+ -I../portaudio_v18/pablio \
+ -I../portmidi_osx \
+ -Wno-error \
+ -DUSEAPI_PORTAUDIO -DPA_BIG_ENDIAN"
+ SYSSRC="s_midi_pm.c s_audio_pa.c \
+ ../portaudio_v18/pa_common/pa_lib.c \
+ ../portaudio_v18/pa_common/pa_trace.c \
+ ../portaudio_v18/pa_common/pa_convert.c \
+ ../portaudio_v18/pablio/pablio_pd.c \
+ ../portaudio_v18/pablio/ringbuffer_pd.c \
+ ../portaudio_v18/pa_mac_core/pa_mac_core.c \
+ ../portmidi_osx/pmdarwin.c \
+ ../portmidi_osx/pmmacosx.c \
+ ../portmidi_osx/pmutil.c \
+ ../portmidi_osx/portmidi.c \
+ ../portmidi_osx/ptdarwin.c "
+ STRIPFLAG=""
+ GUINAME="pdtcl"
+ GUIFLAGS="-framework Tcl -framework Tk \
+ -I/Library/Frameworks/Tk.framework/Versions/Current/Headers \
+ -I/Library/Frameworks/Tcl.framework/Versions/Current/Headers \
+ -I/Library/Frameworks/Tcl.framework/Versions/8.4/PrivateHeaders"
+ if test $USE_OPT_CFLAGS == "YES";
+ then
+ OPT_CFLAGS="-O2"
+ else
+ OPT_CFLAGS="-g"
+ fi
+ OSNUMBER=2
+ EXTERNTARGET=pd_darwin
+fi
+
+AC_OUTPUT(makefile)
+
diff --git a/pd/src/configure.in.oops b/pd/src/configure.in.oops
new file mode 100644
index 00000000..5a7be36e
--- /dev/null
+++ b/pd/src/configure.in.oops
@@ -0,0 +1,272 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(d_arithmetic.c)
+
+AC_SUBST(alsa)
+AC_SUBST(jack, no)
+AC_SUBST(portaudio)
+AC_SUBST(PDLIB)
+AC_SUBST(DEFINES)
+AC_SUBST(MORECFLAGS)
+AC_SUBST(EXT)
+AC_SUBST(OPT_CFLAGS)
+AC_SUBST(USE_OPT_CFLAGS, YES)
+AC_SUBST(SYSSRC)
+AC_SUBST(STRIPFLAG)
+AC_SUBST(GUINAME)
+AC_SUBST(GUIFLAGS)
+AC_SUBST(OSNUMBER)
+AC_SUBST(EXTERNTARGET)
+
+dnl other defaults
+
+dnl check for features
+
+AC_ARG_ENABLE(alsa, [ --disable-alsa disable ALSA],
+ alsa="no")
+AC_ARG_ENABLE(jack, [ --enable-jack jack audio server],
+ jack="yes")
+AC_ARG_ENABLE(portaudio, [ --enable-portaudio portaudio],
+ portaudio="yes")
+AC_ARG_ENABLE(debug, [ --enable-debug debugging support],
+ USE_OPT_CFLAGS="no")
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+AC_PROG_CPP
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_HEADER_TIME
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/ioctl.h sys/time.h unistd.h bstring.h)
+
+dnl Checks for library functions.
+AC_PROG_GCC_TRADITIONAL
+AC_TYPE_SIGNAL
+AC_FUNC_VPRINTF
+AC_CHECK_FUNCS(gettimeofday select socket strerror)
+
+
+dnl Checks for libraries.
+dnl Checking for `dlopen' function in -ldl:
+AC_CHECK_LIB(dl, dlopen,PDLIB="$PDLIB -ldl",
+ echo "dynamic link support required" || exit 1)
+
+dnl Checking for `sin' function in -lffm:
+dnl ffm is the fast math library on the alpha
+AC_CHECK_LIB(ffm, sin,PDLIB="$PDLIB -lffm")
+
+dnl Checking for `sin' function in -lm:
+AC_CHECK_LIB(m, sin,PDLIB="$PDLIB -lm",
+ echo "math library required" || exit 1)
+
+dnl Checking for `pthread_create' function in -pthread
+AC_CHECK_LIB(pthread, pthread_create,PDLIB="$PDLIB -lpthread",
+ echo "pthreads required" || exit 1)
+
+dnl This should be fixed so Pd can use ALSA shared libraries where appropriate.
+if test "$alsa" != no; then
+ AC_CHECK_LIB(asound,snd_pcm_info,PDLIB="$PDLIB -lasound" ; alsa="yes",alsa="")
+fi
+
+dnl Find paths to includes and libraries for X11
+AC_PATH_X
+dnl Checking for `XCreateWindow' function in -lX11:
+AC_CHECK_LIB(X11, XCreateWindow, LIBS="$LIBS -lX11 -L$x_libraries",
+ echo "no X11 found" || exit 1, -L$x_libraries)
+
+dnl look for tcl 8.x... do I really have to go through all this!?
+
+foundit=no
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl.h,foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl8.7/tcl.h,
+ GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.7";foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl8.6/tcl.h,
+ GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.6";foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl8.5/tcl.h,
+ GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.5";foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl8.4/tcl.h,
+ GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.4";foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl8.3/tcl.h,
+ GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.3";foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ AC_CHECK_HEADER(tcl8.2/tcl.h,
+ GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.2";foundit=yes,)
+fi
+if test $foundit == "no";
+then
+ echo no tcl header found
+ exit -1
+fi
+
+AC_CHECK_LIB(tcl8.7, main,,
+ AC_CHECK_LIB(tcl8.6, main,,
+ AC_CHECK_LIB(tcl8.5, main,,
+ AC_CHECK_LIB(tcl8.4, main,,
+ AC_CHECK_LIB(tcl8.3, main,,
+ AC_CHECK_LIB(tcl8.2, main,,
+ AC_CHECK_LIB(tcl8.0, main,,echo no tcl library found || exit 1)))))))
+
+AC_CHECK_LIB(tk8.7, main,,
+ AC_CHECK_LIB(tk8.6, main,,
+ AC_CHECK_LIB(tk8.5, main,,
+ AC_CHECK_LIB(tk8.4, main,,
+ AC_CHECK_LIB(tk8.3, main,,
+ AC_CHECK_LIB(tk8.2, main,,
+ AC_CHECK_LIB(tk8.0, main,,echo no tk library found || exit 1)))))))
+
+dnl Checking for tk.h or tkstep.h - not used at the moment
+dnl AC_CHECK_HEADER(tk.h,DEFINES="$DEFINES -DTKINC=\\\"tk.h\\\"")
+dnl AC_CHECK_HEADER(tkstep.h,DEFINES="$DEFINES -DTKINC=\\\"tkstep.h\\\"")
+
+if test `uname -s` = Linux;
+then
+ dnl Ckecking for ALSA
+
+ AC_CHECK_LIB(asound,snd_pcm_open,LIBS="$LIBS -lasound";alsa=yes,alsa=no)
+
+ dnl Checking for JACK
+
+ AC_CHECK_LIB(rt,shm_open,LIBS="$LIBS -lrt")
+ AC_CHECK_LIB(jack,jack_set_xrun_callback,LIBS="$LIBS -ljack";jack=xrun,jack=no)
+ AC_CHECK_LIB(jack,jack_set_error_function,LIBS="$LIBS -ljack";jack=yes,jack=no)
+
+ LDFLAGS="-Wl,-export-dynamic"
+ EXT=pd_linux
+ MORECFLAGS="-DDL_OPEN -DPA_USE_OSS -DPA_LITTLE_ENDIAN \
+ -DUSEAPI_OSS \
+ -I../portaudio/pa_common \
+ -I../portaudio/pablio -I../portaudio/portmidi-macosx -Werror"
+ SYSSRC="s_midi_oss.c s_audio_oss.c"
+ if test x$portaudio == "xYES";
+ then
+ MORECFLAGS="-DUSEAPI_PORTAUDIO "$MORECFLAGS
+ SYSSRC="s_audio_pa.c \
+ ../portaudio/pa_common/pa_allocation.c \
+ ../portaudio/pa_common/pa_converters.c \
+ ../portaudio/pa_common/pa_cpuload.c \
+ ../portaudio/pa_common/pa_dither.c \
+ ../portaudio/pa_common/pa_front.c \
+ ../portaudio/pa_common/pa_process.c \
+ ../portaudio/pa_common/pa_skeleton.c \
+ ../portaudio/pa_common/pa_stream.c \
+ ../portaudio/pa_common/pa_trace.c \
+ ../portaudio/pablio/pablio_pd.c \
+ ../portaudio/pablio/ringbuffer_pd.c \
+ ../portaudio/pa_linux_alsa/callback_thread.c \
+ ../portaudio/pa_linux_alsa/pa_linux_alsa.c \
+ ../portaudio/pa_linux_alsa/blocking_calls.c \
+ ../portaudio/pa_unix/pa_unix_hostapis.c \
+ ../portaudio/pa_unix/pa_unix_util.c \
+ ../portaudio/pa_unix_oss/pa_unix_oss.c "$SYSSRC
+ fi
+ STRIPFLAG=-s
+ GUINAME="pd-gui"
+ if test x$USE_OPT_CFLAGS == "xYES";
+ then
+ OPT_CFLAGS="-O6 -funroll-loops -fomit-frame-pointer"
+ else
+ OPT_CFLAGS="-g"
+ fi
+ OSNUMBER=0
+fi
+
+dnl **** note -- SGI/IRIX code is broken here!!! ***
+
+if test `uname -s` = IRIX64;
+then
+ LDFLAGS="-n32 -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \
+ -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \
+ -shared -rdata_shared"
+ EXT=pd_irix6
+ MORECFLAGS=-DDL_OPEN
+ SYSSRC=s_sgi.c
+ STRIPFLAG=-s
+ GUINAME="pd-gui"
+ OSNUMBER=0
+fi
+
+if test `uname -s` = IRIX32;
+then
+ LDFLAGS="-o32 -DUNIX -DIRIX -O2 -shared -rdata_shared"
+ EXT=pd_irix5
+ MORECFLAGS=-DDL_OPEN
+ SYSSRC=s_sgi.c
+ STRIPFLAG=-s
+ GUINAME="pd-gui"
+ OSNUMBER=0
+fi
+
+if test `uname -s` = Darwin;
+then
+ LDFLAGS="-Wl -framework Tcl -framework Tk -framework CoreAudio \
+ -framework AudioUnit -framework AudioToolbox \
+ -framework Carbon -framework CoreMIDI"
+ EXT=pd_darwin
+ MORECFLAGS="-DMACOSX -I/usr/X11R6/include \
+ -I../portaudio_v18/pa_common \
+ -I../portaudio_v18/pablio \
+ -I../portmidi_osx \
+ -Wno-error \
+ -DUSEAPI_PORTAUDIO -DPA_BIG_ENDIAN"
+ SYSSRC="s_midi_pm.c s_audio_pa.c \
+ ../portaudio_v18/pa_common/pa_lib.c \
+ ../portaudio_v18/pa_common/pa_trace.c \
+ ../portaudio_v18/pa_common/pa_convert.c \
+ ../portaudio_v18/pablio/pablio_pd.c \
+ ../portaudio_v18/pablio/ringbuffer_pd.c \
+ ../portaudio_v18/pa_mac_core/pa_mac_core.c \
+ ../portmidi_osx/pmdarwin.c \
+ ../portmidi_osx/pmmacosx.c \
+ ../portmidi_osx/pmutil.c \
+ ../portmidi_osx/portmidi.c \
+ ../portmidi_osx/ptdarwin.c "
+ STRIPFLAG=""
+ GUINAME="pdtcl"
+ GUIFLAGS="-framework Tcl -framework Tk \
+ -I/Library/Frameworks/Tk.framework/Versions/Current/Headers \
+ -I/Library/Frameworks/Tcl.framework/Versions/Current/Headers \
+ -I/Library/Frameworks/Tcl.framework/Versions/8.4/PrivateHeaders"
+ if test x$USE_OPT_CFLAGS == "xYES";
+ then
+ OPT_CFLAGS="-O2"
+ else
+ OPT_CFLAGS="-g"
+ fi
+ OSNUMBER=2
+ EXTERNTARGET=pd_darwin
+ if test "x$jack == "xyes";
+ then
+ LDFLAGS=$LDFLAGS" -framework Jack"
+ MORECFLAGS=$MORECFLAGS" -DUSEAPI_JACK"
+ SYSSRC=$SYSSRC" s_audio_jack.c"
+ endif
+fi
+
+AC_OUTPUT(makefile)
+
diff --git a/pd/src/configure.in.pa_v19 b/pd/src/configure.in.pa_v19
new file mode 100644
index 00000000..5d82597b
--- /dev/null
+++ b/pd/src/configure.in.pa_v19
@@ -0,0 +1,231 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(d_arithmetic.c)
+
+AC_SUBST(alsa)
+AC_SUBST(jack)
+AC_SUBST(PDLIB)
+AC_SUBST(DEFINES)
+AC_SUBST(MORECFLAGS)
+AC_SUBST(EXT)
+AC_SUBST(OPT_CFLAGS)
+AC_SUBST(USE_OPT_CFLAGS)
+AC_SUBST(SYSSRC)
+AC_SUBST(STRIPFLAG)
+AC_SUBST(GUINAME)
+AC_SUBST(GUIFLAGS)
+AC_SUBST(OSNUMBER)
+AC_SUBST(EXTERNTARGET)
+
+dnl other defaults
+
+dnl check for features
+
+AC_ARG_ENABLE(alsa, [ --disable-alsa disable ALSA],
+ alsa="no")
+AC_ARG_ENABLE(jack, [ --enable-jack jack audio server],
+ jack="yes")
+AC_ARG_ENABLE(debug, [ --enable-debug debugging support],
+ USE_OPT_CFLAGS="NO", USE_OPT_CFLAGS="YES")
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+AC_PROG_CPP
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_HEADER_TIME
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/ioctl.h sys/time.h unistd.h bstring.h)
+
+dnl Checks for library functions.
+AC_PROG_GCC_TRADITIONAL
+AC_TYPE_SIGNAL
+AC_FUNC_VPRINTF
+AC_CHECK_FUNCS(gettimeofday select socket strerror)
+
+
+dnl Checks for libraries.
+dnl Checking for `dlopen' function in -ldl:
+AC_CHECK_LIB(dl, dlopen,PDLIB="$PDLIB -ldl",
+ echo "dynamic link support required" || exit 1)
+
+dnl Checking for `sin' function in -lffm:
+dnl ffm is the fast math library on the alpha
+AC_CHECK_LIB(ffm, sin,PDLIB="$PDLIB -lffm")
+
+dnl Checking for `sin' function in -lm:
+AC_CHECK_LIB(m, sin,PDLIB="$PDLIB -lm",
+ echo "math library required" || exit 1)
+
+dnl Checking for `pthread_create' function in -pthread
+AC_CHECK_LIB(pthread, pthread_create,PDLIB="$PDLIB -lpthread",
+ echo "pthreads required" || exit 1)
+
+dnl This should be fixed so Pd can use ALSA shared libraries where appropriate.
+if test "$alsa" != no; then
+ AC_CHECK_LIB(asound,snd_pcm_info,PDLIB="$PDLIB -lasound" ; alsa="yes",alsa="")
+fi
+
+dnl Find paths to includes and libraries for X11
+AC_PATH_X
+dnl Checking for `XCreateWindow' function in -lX11:
+AC_CHECK_LIB(X11, XCreateWindow, LIBS="$LIBS -lX11 -L$x_libraries",
+ echo "no X11 found" || exit 1, -L$x_libraries)
+
+dnl look for tcl 8.x... do I really have to go through all this!?
+
+AC_CHECK_HEADER(tcl8.7/tcl.h,GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.7",
+ AC_CHECK_HEADER(tcl8.6/tcl.h,GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.6",
+ AC_CHECK_HEADER(tcl8.5/tcl.h,GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.5",
+ AC_CHECK_HEADER(tcl8.4/tcl.h,GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.4",
+ AC_CHECK_HEADER(tcl8.3/tcl.h,GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.3",
+ AC_CHECK_HEADER(tcl8.2/tcl.h,GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.2",
+ AC_CHECK_HEADER(tcl.h,, echo no tcl/tk headers found)))))))
+
+
+AC_CHECK_LIB(tcl8.7, main,,
+ AC_CHECK_LIB(tcl8.6, main,,
+ AC_CHECK_LIB(tcl8.5, main,,
+ AC_CHECK_LIB(tcl8.4, main,,
+ AC_CHECK_LIB(tcl8.3, main,,
+ AC_CHECK_LIB(tcl8.2, main,,
+ AC_CHECK_LIB(tcl8.0, main)))))))
+
+AC_CHECK_LIB(tk8.7, main,,
+ AC_CHECK_LIB(tk8.6, main,,
+ AC_CHECK_LIB(tk8.5, main,,
+ AC_CHECK_LIB(tk8.4, main,,
+ AC_CHECK_LIB(tk8.3, main,,
+ AC_CHECK_LIB(tk8.2, main,,
+ AC_CHECK_LIB(tk8.0, main)))))))
+
+dnl Checking for tk.h or tkstep.h - not used at the moment
+dnl AC_CHECK_HEADER(tk.h,DEFINES="$DEFINES -DTKINC=\\\"tk.h\\\"")
+dnl AC_CHECK_HEADER(tkstep.h,DEFINES="$DEFINES -DTKINC=\\\"tkstep.h\\\"")
+
+if test `uname -s` = Linux;
+then
+ dnl Ckecking for ALSA
+
+ AC_CHECK_LIB(asound,snd_pcm_open,LIBS="$LIBS -lasound";alsa=yes,alsa=no)
+
+ dnl Checking for JACK
+
+ AC_CHECK_LIB(rt,shm_open,LIBS="$LIBS -lrt")
+ AC_CHECK_LIB(jack,jack_set_xrun_callback,LIBS="$LIBS -ljack";jack=xrun,jack=no)
+ AC_CHECK_LIB(jack,jack_set_error_function,LIBS="$LIBS -ljack";jack=yes,jack=no)
+
+ LDFLAGS="-Wl,-export-dynamic"
+ EXT=pd_linux
+ MORECFLAGS="-DDL_OPEN -DUSEAPI_PORTAUDIO -DPA_USE_OSS -DPA_LITTLE_ENDIAN \
+ -DUSEAPI_OSS \
+ -I../portaudio_v18/pa_common \
+ -I../portaudio_v18/pablio \
+ -I../portaudio/portmidi-macosx -Werror"
+ SYSSRC="s_midi_oss.c s_audio_pa.c s_audio_oss.c \
+ ../portaudio_v18/pa_common/pa_lib.c \
+ ../portaudio_v18/pa_common/pa_trace.c \
+ ../portaudio_v18/pa_common/pa_convert.c \
+ ../portaudio_v18/pablio/pablio_pd.c \
+ ../portaudio_v18/pablio/ringbuffer_pd.c \
+
+ \
+ ../portaudio/pa_common/pa_allocation.c \
+ ../portaudio/pa_common/pa_converters.c \
+ ../portaudio/pa_common/pa_cpuload.c \
+ ../portaudio/pa_common/pa_dither.c \
+ ../portaudio/pa_common/pa_front.c \
+ ../portaudio/pa_common/pa_process.c \
+ ../portaudio/pa_common/pa_skeleton.c \
+ ../portaudio/pa_common/pa_stream.c \
+ ../portaudio/pa_common/pa_trace.c \
+ ../portaudio/pablio/pablio_pd.c \
+ ../portaudio/pablio/ringbuffer_pd.c \
+ ../portaudio/pa_unix/pa_unix_hostapis.c \
+ ../portaudio/pa_unix/pa_unix_util.c \
+ ../portaudio/pa_unix_oss/pa_unix_oss.c "
+ STRIPFLAG=-s
+ GUINAME="pd-gui"
+ if test $USE_OPT_CFLAGS == "YES";
+ then
+ OPT_CFLAGS="-O6 -funroll-loops -fomit-frame-pointer"
+ else
+ OPT_CFLAGS="-g"
+ fi
+ OSNUMBER=0
+fi
+
+dnl **** note -- SGI/IRIX code is broken here!!! ***
+
+if test `uname -s` = IRIX64;
+then
+ LDFLAGS="-n32 -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \
+ -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \
+ -shared -rdata_shared"
+ EXT=pd_irix6
+ MORECFLAGS=-DDL_OPEN
+ SYSSRC=s_sgi.c
+ STRIPFLAG=-s
+ GUINAME="pd-gui"
+ OSNUMBER=0
+fi
+
+if test `uname -s` = IRIX32;
+then
+ LDFLAGS="-o32 -DUNIX -DIRIX -O2 -shared -rdata_shared"
+ EXT=pd_irix5
+ MORECFLAGS=-DDL_OPEN
+ SYSSRC=s_sgi.c
+ STRIPFLAG=-s
+ GUINAME="pd-gui"
+ OSNUMBER=0
+fi
+
+if test `uname -s` = Darwin;
+then
+ LDFLAGS="-Wl -framework Tcl -framework Tk -framework CoreAudio \
+ -framework AudioUnit -framework AudioToolbox \
+ -framework Carbon -framework CoreMIDI"
+ EXT=pd_darwin
+ MORECFLAGS="-DMACOSX -I/usr/X11R6/include \
+ -I../portaudio_v18/pa_common \
+ -I../portaudio_v18/pablio \
+ -I../portmidi_osx \
+ -Wno-error \
+ -DUSEAPI_PORTAUDIO -DPA_BIG_ENDIAN"
+ SYSSRC="s_midi_pm.c s_audio_pa.c \
+ ../portaudio_v18/pa_common/pa_lib.c \
+ ../portaudio_v18/pa_common/pa_trace.c \
+ ../portaudio_v18/pa_common/pa_convert.c \
+ ../portaudio_v18/pablio/pablio_pd.c \
+ ../portaudio_v18/pablio/ringbuffer_pd.c \
+ ../portaudio_v18/pa_mac_core/pa_mac_core.c \
+ ../portmidi_osx/pmdarwin.c \
+ ../portmidi_osx/pmmacosx.c \
+ ../portmidi_osx/pmutil.c \
+ ../portmidi_osx/portmidi.c \
+ ../portmidi_osx/ptdarwin.c "
+ STRIPFLAG=""
+ GUINAME="pdtcl"
+ GUIFLAGS="-framework Tcl -framework Tk \
+ -I/Library/Frameworks/Tk.framework/Versions/Current/Headers \
+ -I/Library/Frameworks/Tcl.framework/Versions/Current/Headers \
+ -I/Library/Frameworks/Tcl.framework/Versions/8.4/PrivateHeaders"
+ if test $USE_OPT_CFLAGS == "YES";
+ then
+ OPT_CFLAGS="-O2"
+ else
+ OPT_CFLAGS="-g"
+ fi
+ OSNUMBER=2
+ EXTERNTARGET=pd_darwin
+fi
+
+AC_OUTPUT(makefile)
+
diff --git a/pd/src/d_delay.c b/pd/src/d_delay.c
index 1d4defcf..920b28e5 100644
--- a/pd/src/d_delay.c
+++ b/pd/src/d_delay.c
@@ -247,7 +247,7 @@ static t_int *sigvd_perform(t_int *w)
int nsamps = ctl->c_n;
float limit = nsamps - n - 1;
- float fn = n-4;
+ float fn = n-1;
float *vp = ctl->c_vec, *bp, *wp = vp + ctl->c_phase;
float zerodel = x->x_zerodel;
while (n--)
@@ -261,7 +261,7 @@ static t_int *sigvd_perform(t_int *w)
fn = fn - 1.0f;
idelsamps = delsamps;
frac = delsamps - (float)idelsamps;
- bp = wp - (idelsamps + 3);
+ bp = wp - idelsamps;
if (bp < vp + 4) bp += nsamps;
d = bp[-3];
c = bp[-2];
diff --git a/pd/src/d_global.c b/pd/src/d_global.c
index a84a1ae0..d764ee1b 100644
--- a/pd/src/d_global.c
+++ b/pd/src/d_global.c
@@ -40,11 +40,9 @@ static t_int *sigsend_perform(t_int *w)
int n = (int)(w[3]);
while (n--)
{
- float f = *in++;
- if (PD_BADFLOAT(f))
- f = 0;
-
- *out++ = f;
+ *out = (PD_BADFLOAT(*in) ? 0 : *in);
+ out++;
+ in++;
}
return (w+4);
}
@@ -244,10 +242,9 @@ static t_int *sigthrow_perform(t_int *w)
{
while (n--)
{
- float f = *in++;
- if (PD_BADFLOAT(f))
- f = 0;
- *out++ += f;
+ *out += (PD_BADFLOAT(*in) ? 0 : *in);
+ out++;
+ in++;
}
}
return (w+4);
diff --git a/pd/src/d_osc.c b/pd/src/d_osc.c
index a7990fc6..8fe7f29b 100644
--- a/pd/src/d_osc.c
+++ b/pd/src/d_osc.c
@@ -448,6 +448,10 @@ static t_int *sigvcf_perform(t_int *w)
+ coefr * re2 - coefi * im;
*out2++ = im = coefi * re2 + coefr * im;
}
+ if (PD_BADFLOAT(re))
+ re = 0;
+ if (PD_BADFLOAT(im))
+ im = 0;
c->c_re = re;
c->c_im = im;
return (w+7);
diff --git a/pd/src/makefile.nt b/pd/src/makefile.nt
index 9105d734..f149f01e 100644
--- a/pd/src/makefile.nt
+++ b/pd/src/makefile.nt
@@ -13,12 +13,12 @@ LIB = /NODEFAULTLIB:libc /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel \
$(LDIR)\libc.lib $(LDIR)\oldnames.lib $(LDIR)\kernel32.lib \
$(LDIR)\wsock32.lib $(LDIR)\winmm.lib ..\bin\pthreadVC.lib
-GLIB = $(LIB) ..\lib\tcl83.lib ..\lib\tk83.lib
+GLIB = $(LIB) ..\bin\tcl83.lib ..\bin\tk83.lib
CFLAGS = /nologo /W3 /DMSW /DNT /DPD /DPD_INTERNAL /DWIN32 /DWINDOWS /Ox \
-DPA_LITTLE_ENDIAN -DUSEAPI_MMIO -DUSEAPI_PORTAUDIO
LFLAGS = /nologo
-SYSSRC = s_audio_pa.c s_audio_mmio.c s_midi_pm.c
+SYSSRC = s_audio_pa.c s_audio_mmio.c s_midi_mmio.c
SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \
g_scalar.c g_traversal.c g_guiconnect.c g_readwrite.c g_editor.c \
@@ -37,56 +37,19 @@ SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \
PADIR = ..\portaudio
INCPA = -I$(PADIR) -I$(PADIR)\pa_common -I$(PADIR)\pablio -I..\lib\asio
-SRCPA = \
- $(PADIR)/pa_common/pa_allocation.c \
- $(PADIR)/pa_common/pa_converters.c \
- $(PADIR)/pa_common/pa_cpuload.c \
- $(PADIR)/pa_common/pa_dither.c \
- $(PADIR)/pa_common/pa_front.c \
- $(PADIR)/pa_common/pa_process.c \
- $(PADIR)/pa_common/pa_skeleton.c \
- $(PADIR)/pa_common/pa_stream.c \
- $(PADIR)/pa_common/pa_trace.c \
- $(PADIR)/pablio/pablio_pd.c \
- $(PADIR)/pablio/ringbuffer_pd.c \
- $(PADIR)/pa_win/pa_win_hostapis.c \
- $(PADIR)/pa_win/pa_win_util.c \
- $(PADIR)/pa_win/pa_x86_plain_converters.c \
- $(PADIR)/pa_win_wmme/pa_win_wmme.c
-
-# $(PADIR)/pa_win_ds/dsound_wrapper.c \
-# $(PADIR)/pa_win_ds/pa_dsound.c \
-# $(PADIR)/pa_win_ds/pa_win_ds.c \
-
-PAOBJ = \
- pa_allocation.obj pa_converters.obj pa_cpuload.obj pa_dither.obj pa_front.obj \
- pa_process.obj pa_skeleton.obj pa_stream.obj pa_trace.obj pablio_pd.obj \
- ringbuffer_pd.obj pa_win_hostapis.obj pa_win_util.obj \
- pa_x86_plain_converters.obj \
- pa_win_wmme.obj pa_asio.obj \
-
-# dsound_wrapper.obj pa_dsound.obj pa_win_ds.obj
-
-
+SRCPA = $(PADIR)/pa_common/pa_lib.c $(PADIR)/pa_common/pa_trace.c \
+ $(PADIR)/pablio/pablio_pd.c $(PADIR)/pablio/ringbuffer_pd.c
SRCASIO = $(PADIR)/pa_asio/pa_asio.cpp
-ASIOLIB = $(LDIR)\user32.lib $(LDIR)\gdi32.lib $(LDIR)\winspool.lib \
- $(LDIR)\comdlg32.lib \
+
+ASIOLIB = $(LDIR)\user32.lib $(LDIR)\gdi32.lib $(LDIR)\winspool.lib $(LDIR)\comdlg32.lib \
$(LDIR)\advapi32.lib $(LDIR)\shell32.lib $(LDIR)\ole32.lib $(LDIR)\oleaut32.lib $(LDIR)\uuid.lib \
$(LDIR)\odbc32.lib $(LDIR)\odbccp32.lib ..\lib\asio\asiolib.lib
-PMDIR = ..\portmidi
-INCPM = -I$(PMDIR)\pm_common -I$(PMDIR)\pm_win -I$(PMDIR)\porttime
-SRCPM = \
- $(PMDIR)/pm_common/portmidi.c \
- $(PMDIR)/pm_common/pmutil.c \
- $(PMDIR)/pm_win/pmwin.c \
- $(PMDIR)/pm_win/pmwinmm.c \
- $(PMDIR)/porttime/porttime.c \
- $(PMDIR)/porttime/ptwinmm.c \
-PMOBJ = portmidi.obj pmutil.obj pmwin.obj pmwinmm.obj porttime.obj ptwinmm.obj
+PAOBJ = pa_lib.obj pa_trace.obj pablio_pd.obj ringbuffer_pd.obj pa_asio.obj
-OBJC = $(SRC:.c=.obj) $(PAOBJ) $(PMOBJ)
+
+OBJC = $(SRC:.c=.obj) $(PAOBJ)
GSRC = t_main.c t_tkcmd.c
@@ -124,60 +87,19 @@ gui: ..\bin\pdtcl.dll
link $(LFLAGS) /out:..\bin\pdreceive.exe /INCREMENTAL:NO u_pdreceive.obj \
$(LIB)
-# explicit rules to compile portaudio and portmidi sources:
-pa_allocation.obj: $(PADIR)\pa_common\pa_allocation.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_allocation.c
-pa_converters.obj: $(PADIR)\pa_common\pa_converters.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_converters.c
-pa_cpuload.obj: $(PADIR)\pa_common\pa_cpuload.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_cpuload.c
-pa_dither.obj: $(PADIR)\pa_common\pa_dither.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_dither.c
-pa_front.obj: $(PADIR)\pa_common\pa_front.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_front.c
-pa_process.obj: $(PADIR)\pa_common\pa_process.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_process.c
-pa_skeleton.obj: $(PADIR)\pa_common\pa_skeleton.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_skeleton.c
-pa_stream.obj: $(PADIR)\pa_common\pa_stream.c
- cl /c $(ALLCF) $(PADIR)\pa_common\pa_stream.c
+# explicit rules to compile portaudio sources:
+pa_lib.obj: $(PADIR)\pa_common\pa_lib.c
+ cl /c $(ALLCF) $(PADIR)\pa_common\pa_lib.c
pa_trace.obj: $(PADIR)\pa_common\pa_trace.c
cl /c $(ALLCF) $(PADIR)\pa_common\pa_trace.c
pablio_pd.obj: $(PADIR)\pablio\pablio_pd.c
cl /c $(ALLCF) $(PADIR)\pablio\pablio_pd.c
ringbuffer_pd.obj: $(PADIR)\pablio\ringbuffer_pd.c
cl /c $(ALLCF) $(PADIR)\pablio\ringbuffer_pd.c
-pa_win_hostapis.obj: $(PADIR)\pa_win\pa_win_hostapis.c
- cl /c $(ALLCF) $(PADIR)\pa_win\pa_win_hostapis.c
-pa_win_util.obj: $(PADIR)\pa_win\pa_win_util.c
- cl /c $(ALLCF) $(PADIR)\pa_win\pa_win_util.c
-pa_x86_plain_converters.obj: $(PADIR)\pa_win\pa_x86_plain_converters.c
- cl /c $(ALLCF) $(PADIR)\pa_win\pa_x86_plain_converters.c
-dsound_wrapper.obj: $(PADIR)\pa_win_ds\dsound_wrapper.c
- cl /c $(ALLCF) $(PADIR)\pa_win_ds\dsound_wrapper.c
-pa_dsound.obj: $(PADIR)\pa_win_ds\pa_dsound.c
- cl /c $(ALLCF) $(PADIR)\pa_win_ds\pa_dsound.c
-pa_win_ds.obj: $(PADIR)\pa_win_ds\pa_win_ds.c
- cl /c $(ALLCF) $(PADIR)\pa_win_ds\pa_win_ds.c
-pa_win_wmme.obj: $(PADIR)\pa_win_wmme\pa_win_wmme.c
- cl /c $(ALLCF) $(PADIR)\pa_win_wmme\pa_win_wmme.c
pa_asio.obj: $(PADIR)\pa_asio\pa_asio.cpp
cl /c $(ALLCF) $(PADIR)\pa_asio\pa_asio.cpp
-portmidi.obj: $(PMDIR)\pm_common\portmidi.c
- cl /c $(ALLCF) $(PMDIR)\pm_common\portmidi.c
-pmutil.obj: $(PMDIR)\pm_common\pmutil.c
- cl /c $(ALLCF) $(PMDIR)\pm_common\pmutil.c
-pmwin.obj: $(PMDIR)\pm_win\pmwin.c
- cl /c $(ALLCF) $(PMDIR)\pm_win\pmwin.c
-pmwinmm.obj: $(PMDIR)\pm_win\pmwinmm.c
- cl /c $(ALLCF) $(PMDIR)\pm_win\pmwinmm.c
-porttime.obj: $(PMDIR)\porttime\porttime.c
- cl /c $(ALLCF) $(PMDIR)\porttime\porttime.c
-ptwinmm.obj: $(PMDIR)\porttime\ptwinmm.c
- cl /c $(ALLCF) $(PMDIR)\porttime\ptwinmm.c
-
# the following should also clean up "bin" but it doesn't because "bin" holds
# precious stuff from elsewhere.
clean:
diff --git a/pd/src/makefile.nt.pa19 b/pd/src/makefile.nt.pa19
new file mode 100644
index 00000000..9105d734
--- /dev/null
+++ b/pd/src/makefile.nt.pa19
@@ -0,0 +1,185 @@
+# Makefile for PD on MSW
+
+all: pd gui ..\bin\pd.tk ..\bin\pdsend.exe ..\bin\pdreceive.exe
+
+VC = "C:\Program Files\Microsoft Visual Studio\VC98"
+#VC="\Program Files\DevStudio\Vc"
+INCLUDE = -I.\ -I..\Tcl\include -I$(VC)\include
+
+LDIR = $(VC)\lib
+
+LIB = /NODEFAULTLIB:libc /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel \
+ /NODEFAULTLIB:uuid \
+ $(LDIR)\libc.lib $(LDIR)\oldnames.lib $(LDIR)\kernel32.lib \
+ $(LDIR)\wsock32.lib $(LDIR)\winmm.lib ..\bin\pthreadVC.lib
+
+GLIB = $(LIB) ..\lib\tcl83.lib ..\lib\tk83.lib
+CFLAGS = /nologo /W3 /DMSW /DNT /DPD /DPD_INTERNAL /DWIN32 /DWINDOWS /Ox \
+ -DPA_LITTLE_ENDIAN -DUSEAPI_MMIO -DUSEAPI_PORTAUDIO
+LFLAGS = /nologo
+
+SYSSRC = s_audio_pa.c s_audio_mmio.c s_midi_pm.c
+
+SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \
+ g_scalar.c g_traversal.c g_guiconnect.c g_readwrite.c g_editor.c \
+ g_all_guis.c g_bang.c g_hdial.c g_hslider.c g_mycanvas.c g_numbox.c \
+ g_toggle.c g_vdial.c g_vslider.c g_vumeter.c \
+ m_pd.c m_class.c m_obj.c m_atom.c m_memory.c m_binbuf.c \
+ m_conf.c m_glob.c m_sched.c \
+ s_main.c s_inter.c s_file.c s_print.c \
+ s_loader.c s_path.c s_entry.c s_audio.c s_midi.c \
+ d_ugen.c d_ctl.c d_arithmetic.c d_osc.c d_filter.c d_dac.c d_misc.c \
+ d_math.c d_fft.c d_mayer_fft.c d_fftroutine.c d_array.c d_global.c \
+ d_delay.c d_resample.c \
+ x_arithmetic.c x_connective.c x_interface.c x_midi.c x_misc.c \
+ x_time.c x_acoustics.c x_net.c x_qlist.c x_gui.c d_soundfile.c \
+ $(SYSSRC)
+
+PADIR = ..\portaudio
+INCPA = -I$(PADIR) -I$(PADIR)\pa_common -I$(PADIR)\pablio -I..\lib\asio
+SRCPA = \
+ $(PADIR)/pa_common/pa_allocation.c \
+ $(PADIR)/pa_common/pa_converters.c \
+ $(PADIR)/pa_common/pa_cpuload.c \
+ $(PADIR)/pa_common/pa_dither.c \
+ $(PADIR)/pa_common/pa_front.c \
+ $(PADIR)/pa_common/pa_process.c \
+ $(PADIR)/pa_common/pa_skeleton.c \
+ $(PADIR)/pa_common/pa_stream.c \
+ $(PADIR)/pa_common/pa_trace.c \
+ $(PADIR)/pablio/pablio_pd.c \
+ $(PADIR)/pablio/ringbuffer_pd.c \
+ $(PADIR)/pa_win/pa_win_hostapis.c \
+ $(PADIR)/pa_win/pa_win_util.c \
+ $(PADIR)/pa_win/pa_x86_plain_converters.c \
+ $(PADIR)/pa_win_wmme/pa_win_wmme.c
+
+# $(PADIR)/pa_win_ds/dsound_wrapper.c \
+# $(PADIR)/pa_win_ds/pa_dsound.c \
+# $(PADIR)/pa_win_ds/pa_win_ds.c \
+
+PAOBJ = \
+ pa_allocation.obj pa_converters.obj pa_cpuload.obj pa_dither.obj pa_front.obj \
+ pa_process.obj pa_skeleton.obj pa_stream.obj pa_trace.obj pablio_pd.obj \
+ ringbuffer_pd.obj pa_win_hostapis.obj pa_win_util.obj \
+ pa_x86_plain_converters.obj \
+ pa_win_wmme.obj pa_asio.obj \
+
+# dsound_wrapper.obj pa_dsound.obj pa_win_ds.obj
+
+
+SRCASIO = $(PADIR)/pa_asio/pa_asio.cpp
+ASIOLIB = $(LDIR)\user32.lib $(LDIR)\gdi32.lib $(LDIR)\winspool.lib \
+ $(LDIR)\comdlg32.lib \
+$(LDIR)\advapi32.lib $(LDIR)\shell32.lib $(LDIR)\ole32.lib $(LDIR)\oleaut32.lib $(LDIR)\uuid.lib \
+$(LDIR)\odbc32.lib $(LDIR)\odbccp32.lib ..\lib\asio\asiolib.lib
+
+PMDIR = ..\portmidi
+INCPM = -I$(PMDIR)\pm_common -I$(PMDIR)\pm_win -I$(PMDIR)\porttime
+SRCPM = \
+ $(PMDIR)/pm_common/portmidi.c \
+ $(PMDIR)/pm_common/pmutil.c \
+ $(PMDIR)/pm_win/pmwin.c \
+ $(PMDIR)/pm_win/pmwinmm.c \
+ $(PMDIR)/porttime/porttime.c \
+ $(PMDIR)/porttime/ptwinmm.c \
+
+PMOBJ = portmidi.obj pmutil.obj pmwin.obj pmwinmm.obj porttime.obj ptwinmm.obj
+
+OBJC = $(SRC:.c=.obj) $(PAOBJ) $(PMOBJ)
+
+GSRC = t_main.c t_tkcmd.c
+
+GOBJ = $(GSRC:.c=.obj)
+.PHONY: pd gui
+
+ALLCF = $(CFLAGS) $(INCLUDE) $(INCASIO) $(INCPA) $(INCPM) /D_WINDOWS /DPA_NO_DS
+
+.c.obj:
+ cl /c $(ALLCF) /Tc$*.c
+
+pd: ..\bin\pd.exe
+
+gui: ..\bin\pdtcl.dll
+
+..\bin\pd.exe: s_entry.obj ..\bin\pd.lib
+ link $(LFLAGS) /out:..\bin\pd.exe /INCREMENTAL:NO s_entry.obj \
+ ..\bin\pd.lib $(LIB) $(ASIOLIB)
+
+..\bin\pd.dll ..\bin\pd.lib: $(OBJC) $(OBJASIO)
+ link $(LFLAGS) /dll /export:sys_main /out:..\bin\pd.dll $(OBJC) \
+ $(OBJASIO) $(LIB) $(ASIOLIB)
+
+..\bin\pdtcl.dll: t_tkcmd.obj
+ link $(LFLAGS) /dll /export:Pdtcl_Init /out:..\bin\pdtcl.dll \
+ t_tkcmd.obj $(GLIB)
+
+..\bin\pd.tk: u_main.tk; copy u_main.tk ..\bin\pd.tk
+
+..\bin\pdsend.exe: u_pdsend.obj
+ link $(LFLAGS) /out:..\bin\pdsend.exe /INCREMENTAL:NO u_pdsend.obj \
+ $(LIB)
+
+..\bin\pdreceive.exe: u_pdreceive.obj
+ link $(LFLAGS) /out:..\bin\pdreceive.exe /INCREMENTAL:NO u_pdreceive.obj \
+ $(LIB)
+
+# explicit rules to compile portaudio and portmidi sources:
+pa_allocation.obj: $(PADIR)\pa_common\pa_allocation.c
+ cl /c $(ALLCF) $(PADIR)\pa_common\pa_allocation.c
+pa_converters.obj: $(PADIR)\pa_common\pa_converters.c
+ cl /c $(ALLCF) $(PADIR)\pa_common\pa_converters.c
+pa_cpuload.obj: $(PADIR)\pa_common\pa_cpuload.c
+ cl /c $(ALLCF) $(PADIR)\pa_common\pa_cpuload.c
+pa_dither.obj: $(PADIR)\pa_common\pa_dither.c
+ cl /c $(ALLCF) $(PADIR)\pa_common\pa_dither.c
+pa_front.obj: $(PADIR)\pa_common\pa_front.c
+ cl /c $(ALLCF) $(PADIR)\pa_common\pa_front.c
+pa_process.obj: $(PADIR)\pa_common\pa_process.c
+ cl /c $(ALLCF) $(PADIR)\pa_common\pa_process.c
+pa_skeleton.obj: $(PADIR)\pa_common\pa_skeleton.c
+ cl /c $(ALLCF) $(PADIR)\pa_common\pa_skeleton.c
+pa_stream.obj: $(PADIR)\pa_common\pa_stream.c
+ cl /c $(ALLCF) $(PADIR)\pa_common\pa_stream.c
+pa_trace.obj: $(PADIR)\pa_common\pa_trace.c
+ cl /c $(ALLCF) $(PADIR)\pa_common\pa_trace.c
+pablio_pd.obj: $(PADIR)\pablio\pablio_pd.c
+ cl /c $(ALLCF) $(PADIR)\pablio\pablio_pd.c
+ringbuffer_pd.obj: $(PADIR)\pablio\ringbuffer_pd.c
+ cl /c $(ALLCF) $(PADIR)\pablio\ringbuffer_pd.c
+pa_win_hostapis.obj: $(PADIR)\pa_win\pa_win_hostapis.c
+ cl /c $(ALLCF) $(PADIR)\pa_win\pa_win_hostapis.c
+pa_win_util.obj: $(PADIR)\pa_win\pa_win_util.c
+ cl /c $(ALLCF) $(PADIR)\pa_win\pa_win_util.c
+pa_x86_plain_converters.obj: $(PADIR)\pa_win\pa_x86_plain_converters.c
+ cl /c $(ALLCF) $(PADIR)\pa_win\pa_x86_plain_converters.c
+dsound_wrapper.obj: $(PADIR)\pa_win_ds\dsound_wrapper.c
+ cl /c $(ALLCF) $(PADIR)\pa_win_ds\dsound_wrapper.c
+pa_dsound.obj: $(PADIR)\pa_win_ds\pa_dsound.c
+ cl /c $(ALLCF) $(PADIR)\pa_win_ds\pa_dsound.c
+pa_win_ds.obj: $(PADIR)\pa_win_ds\pa_win_ds.c
+ cl /c $(ALLCF) $(PADIR)\pa_win_ds\pa_win_ds.c
+pa_win_wmme.obj: $(PADIR)\pa_win_wmme\pa_win_wmme.c
+ cl /c $(ALLCF) $(PADIR)\pa_win_wmme\pa_win_wmme.c
+
+pa_asio.obj: $(PADIR)\pa_asio\pa_asio.cpp
+ cl /c $(ALLCF) $(PADIR)\pa_asio\pa_asio.cpp
+
+portmidi.obj: $(PMDIR)\pm_common\portmidi.c
+ cl /c $(ALLCF) $(PMDIR)\pm_common\portmidi.c
+pmutil.obj: $(PMDIR)\pm_common\pmutil.c
+ cl /c $(ALLCF) $(PMDIR)\pm_common\pmutil.c
+pmwin.obj: $(PMDIR)\pm_win\pmwin.c
+ cl /c $(ALLCF) $(PMDIR)\pm_win\pmwin.c
+pmwinmm.obj: $(PMDIR)\pm_win\pmwinmm.c
+ cl /c $(ALLCF) $(PMDIR)\pm_win\pmwinmm.c
+porttime.obj: $(PMDIR)\porttime\porttime.c
+ cl /c $(ALLCF) $(PMDIR)\porttime\porttime.c
+ptwinmm.obj: $(PMDIR)\porttime\ptwinmm.c
+ cl /c $(ALLCF) $(PMDIR)\porttime\ptwinmm.c
+
+# the following should also clean up "bin" but it doesn't because "bin" holds
+# precious stuff from elsewhere.
+clean:
+ del *.obj
+
diff --git a/pd/src/s_audio_alsa.c.old b/pd/src/s_audio_alsa.c.old
new file mode 100644
index 00000000..99ca3403
--- /dev/null
+++ b/pd/src/s_audio_alsa.c.old
@@ -0,0 +1,946 @@
+/* Copyright (c) 1997-2003 Guenter Geiger, Miller Puckette, Larry Troxler,
+* Winfried Ritsch, Karl MacMillan, and others.
+* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* this file inputs and outputs audio using the ALSA API available on linux. */
+
+#include <alsa/asoundlib.h>
+
+#include "m_pd.h"
+#include "s_stuff.h"
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/mman.h>
+
+typedef int16_t t_alsa_sample16;
+typedef int32_t t_alsa_sample32;
+#define ALSA_SAMPLEWIDTH_16 sizeof(t_alsa_sample16)
+#define ALSA_SAMPLEWIDTH_32 sizeof(t_alsa_sample32)
+#define ALSA_XFERSIZE16 (signed int)(sizeof(t_alsa_sample16) * DEFDACBLKSIZE)
+#define ALSA_XFERSIZE32 (signed int)(sizeof(t_alsa_sample32) * DEFDACBLKSIZE)
+#define ALSA_MAXDEV 1
+#define ALSA_JITTER 1024
+#define ALSA_EXTRABUFFER 2048
+#define ALSA_DEFFRAGSIZE 64
+#define ALSA_DEFNFRAG 12
+
+#ifndef INT32_MAX
+#define INT32_MAX 0x7fffffff
+#endif
+
+#if (SND_LIB_MAJOR < 1)
+#define ALSAAPI9
+#endif
+
+typedef struct _alsa_dev
+{
+ snd_pcm_t *inhandle;
+ snd_pcm_t *outhandle;
+ int innoninterleave; /* true if we're set for noninterleaved read */
+ int outnoninterleave; /* same for write */
+} t_alsa_dev;
+
+t_alsa_dev alsa_device;
+static void *alsa_snd_buf = 0;
+static void **alsa_buf_ptrs;
+static int alsa_samplewidth;
+static snd_pcm_status_t* in_status;
+static snd_pcm_status_t* out_status;
+
+static int alsa_mode;
+static int alsa_buf_samps; /* believed actual ALSA bufsize in sample frames */
+static int alsa_inchannels;
+static int alsa_outchannels;
+
+/* Defines */
+#define DEBUG(x) x
+#define DEBUG2(x) {x;}
+
+static void alsa_checkiosync( void);
+static void alsa_numbertoname(int devno, char *devname, int nchar);
+
+ /* don't assume we can turn all 31 bits when doing float-to-fix;
+ otherwise some audio drivers (e.g. Midiman/ALSA) wrap around. */
+#define FMAX 0x7ffff000
+#define CLIP32(x) (((x)>FMAX)?FMAX:((x) < -FMAX)?-FMAX:(x))
+
+/* support for ALSA pcmv2 api by Karl MacMillan<karlmac@peabody.jhu.edu> */
+
+static void check_error(int err, const char *why)
+{
+ if (err < 0)
+ fprintf(stderr, "%s: %s\n", why, snd_strerror(err));
+}
+
+/* was: alsa_open_audio(int wantinchans, int wantoutchans, int srate) */
+
+int alsa_open_audio(int naudioindev, int *audioindev, int nchindev,
+ int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev,
+ int *choutdev, int rate)
+{
+ int err, inchans = 0, outchans = 0, subunitdir;
+ char devname[512];
+ snd_pcm_hw_params_t* hw_params;
+ snd_pcm_sw_params_t* sw_params;
+ snd_output_t* out;
+ int frag_size = (sys_blocksize ? sys_blocksize : ALSA_DEFFRAGSIZE);
+ int nfrags, i;
+ short* tmp_buf;
+ unsigned int tmp_uint;
+ snd_pcm_uframes_t tmp_snd_pcm_uframes;
+ int wantinchans, wantoutchans, devno;
+
+ if (naudioindev >= 2 || naudiooutdev >= 2)
+ post("alsa: only one input and output device allowed (extras ignored");
+ if (naudioindev >= 1 && naudiooutdev >= 1 &&
+ audioindev[0] != audiooutdev[0])
+ post("alsa: changing output device to agree with input device");
+ if (nchindev)
+ wantinchans = chindev[0];
+ else wantinchans = (naudioindev ? 2 : 0);
+ if (nchoutdev)
+ wantoutchans = choutdev[0];
+ else wantoutchans = (naudiooutdev ? 2 : 0);
+ devno = (naudioindev > 0 ? audioindev[0] :
+ (naudiooutdev > 0 ? audiooutdev[0] : 0));
+
+ alsa_numbertoname(devno, devname, 512);
+
+ if (sys_verbose)
+ post("device name %s; channels in %d, out %d", devname, wantinchans,
+ wantoutchans);
+
+ nfrags = sys_schedadvance * (float)rate / (1e6 * frag_size);
+ /* save our belief as to ALSA's buffer size for later */
+ alsa_buf_samps = nfrags * frag_size;
+
+ if (sys_verbose)
+ post("audio buffer set to %d", (int)(0.001 * sys_schedadvance));
+
+ alsa_device.innoninterleave = alsa_device.outnoninterleave = 0;
+ if (wantinchans)
+ {
+ err = snd_pcm_open(&alsa_device.inhandle, devname,
+ SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK);
+
+ check_error(err, "snd_pcm_open (input)");
+ if (err < 0)
+ inchans = 0;
+ else
+ {
+ inchans = wantinchans;
+ snd_pcm_nonblock(alsa_device.inhandle, 1);
+ }
+ }
+ if (wantoutchans)
+ {
+ err = snd_pcm_open(&alsa_device.outhandle, devname,
+ SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
+
+ check_error(err, "snd_pcm_open (output)");
+ if (err < 0)
+ outchans = 0;
+ else
+ {
+ outchans = wantoutchans;
+ snd_pcm_nonblock(alsa_device.outhandle, 1);
+ }
+ }
+ if (inchans)
+ {
+ if (sys_verbose)
+ post("opening sound input...");
+ err = snd_pcm_hw_params_malloc(&hw_params);
+ check_error(err, "snd_pcm_hw_params_malloc (input)");
+
+ // get the default params
+ err = snd_pcm_hw_params_any(alsa_device.inhandle, hw_params);
+ check_error(err, "snd_pcm_hw_params_any (input)");
+
+ /* try to set interleaved access */
+ err = snd_pcm_hw_params_set_access(alsa_device.inhandle,
+ hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
+ if (err < 0)
+ {
+ /* OK, so try non-interleaved */
+ err = snd_pcm_hw_params_set_access(alsa_device.inhandle,
+ hw_params, SND_PCM_ACCESS_RW_NONINTERLEAVED);
+ if (err >= 0)
+ {
+ post("using non-interleaved audio input");
+ alsa_device.innoninterleave = 1;
+ }
+ }
+ check_error(err, "snd_pcm_hw_params_set_access (input)");
+ // Try to set 32 bit format first
+ err = snd_pcm_hw_params_set_format(alsa_device.inhandle, hw_params,
+ SND_PCM_FORMAT_S32);
+ if (err < 0)
+ {
+ /* fprintf(stderr,
+ "PD-ALSA: 32 bit format not available - using 16\n"); */
+ err = snd_pcm_hw_params_set_format(alsa_device.inhandle, hw_params,
+ SND_PCM_FORMAT_S16);
+ check_error(err, "snd_pcm_hw_params_set_format (input)");
+ alsa_samplewidth = 2;
+ }
+ else
+ {
+ alsa_samplewidth = 4;
+ }
+ post("Sample width set to %d bytes", alsa_samplewidth);
+ // set the subformat
+ err = snd_pcm_hw_params_set_subformat(alsa_device.inhandle, hw_params,
+ SND_PCM_SUBFORMAT_STD);
+ check_error(err, "snd_pcm_hw_params_set_subformat (input)");
+ // set the number of channels
+ tmp_uint = inchans;
+ err = snd_pcm_hw_params_set_channels_min(alsa_device.inhandle,
+ hw_params, &tmp_uint);
+ check_error(err, "snd_pcm_hw_params_set_channels (input)");
+ if (tmp_uint != (unsigned)inchans)
+ post("ALSA: set input channels to %d", tmp_uint);
+ inchans = tmp_uint;
+ // set the sampling rate
+ err = snd_pcm_hw_params_set_rate_min(alsa_device.inhandle, hw_params,
+ &rate, 0);
+ check_error(err, "snd_pcm_hw_params_set_rate_min (input)");
+#if 0
+ err = snd_pcm_hw_params_get_rate(hw_params, &subunitdir);
+ post("input sample rate %d", err);
+#endif
+ // set the period - ie frag size
+ // post("fragsize a %d", frag_size);
+
+ /* LATER try this to get a recommended period size...
+ right now, it trips an assertion failure in ALSA lib */
+#if 0
+ post("input period was %d, min %d, max %d\n",
+ snd_pcm_hw_params_get_period_size(hw_params, 0),
+ snd_pcm_hw_params_get_period_size_min(hw_params, 0),
+ snd_pcm_hw_params_get_period_size_max(hw_params, 0));
+#endif
+#ifdef ALSAAPI9
+ err = snd_pcm_hw_params_set_period_size_near(alsa_device.inhandle,
+ hw_params,
+ (snd_pcm_uframes_t)
+ frag_size, 0);
+#else
+ tmp_snd_pcm_uframes = frag_size;
+ err = snd_pcm_hw_params_set_period_size_near(alsa_device.inhandle,
+ hw_params, &tmp_snd_pcm_uframes, 0);
+#endif
+ check_error(err, "snd_pcm_hw_params_set_period_size_near (input)");
+ // post("fragsize b %d", frag_size);
+ // set the number of periods - ie numfrags
+ // post("nfrags a %d", nfrags);
+#ifdef ALSAAPI9
+ err = snd_pcm_hw_params_set_periods_near(alsa_device.inhandle,
+ hw_params, nfrags, 0);
+#else
+ tmp_uint = nfrags;
+ err = snd_pcm_hw_params_set_periods_near(alsa_device.inhandle,
+ hw_params, &tmp_uint, 0);
+#endif
+ check_error(err, "snd_pcm_hw_params_set_periods_near (input)");
+ // set the buffer size
+#ifdef ALSAAPI9
+ err = snd_pcm_hw_params_set_buffer_size_near(alsa_device.inhandle,
+ hw_params, nfrags * frag_size);
+#else
+ tmp_snd_pcm_uframes = nfrags * frag_size;
+ err = snd_pcm_hw_params_set_buffer_size_near(alsa_device.inhandle,
+ hw_params, &tmp_snd_pcm_uframes);
+#endif
+ check_error(err, "snd_pcm_hw_params_set_buffer_size_near (input)");
+
+ err = snd_pcm_hw_params(alsa_device.inhandle, hw_params);
+ check_error(err, "snd_pcm_hw_params (input)");
+
+ snd_pcm_hw_params_free(hw_params);
+
+ err = snd_pcm_sw_params_malloc(&sw_params);
+ check_error(err, "snd_pcm_sw_params_malloc (input)");
+ err = snd_pcm_sw_params_current(alsa_device.inhandle, sw_params);
+ check_error(err, "snd_pcm_sw_params_current (input)");
+ err = snd_pcm_sw_params_set_start_threshold(alsa_device.inhandle,
+ sw_params, nfrags * frag_size);
+ check_error(err, "snd_pcm_sw_params_set_start_threshold (input)");
+ err = snd_pcm_sw_params_set_stop_threshold(alsa_device.inhandle,
+ sw_params, 0x7fffffff);
+ check_error(err, "snd_pcm_sw_params_set_stop_threshold (input)");
+ err = snd_pcm_sw_params_set_avail_min(alsa_device.inhandle, sw_params,
+ frag_size);
+ check_error(err, "snd_pcm_sw_params_set_avail_min (input)");
+ err = snd_pcm_sw_params(alsa_device.inhandle, sw_params);
+ check_error(err, "snd_pcm_sw_params (input)");
+
+ snd_pcm_sw_params_free(sw_params);
+
+ snd_output_stdio_attach(&out, stderr, 0);
+#if 0
+ if (sys_verbose)
+ {
+ snd_pcm_dump_hw_setup(alsa_device.inhandle, out);
+ snd_pcm_dump_sw_setup(alsa_device.inhandle, out);
+ }
+#endif
+ }
+
+ if (outchans)
+ {
+ int foo;
+ if (sys_verbose)
+ post("opening sound output...");
+ err = snd_pcm_hw_params_malloc(&hw_params);
+ check_error(err, "snd_pcm_sw_params (output)");
+
+ // get the default params
+ err = snd_pcm_hw_params_any(alsa_device.outhandle, hw_params);
+ check_error(err, "snd_pcm_hw_params_any (output)");
+ // set interleaved access - FIXME deal with other access types
+ err = snd_pcm_hw_params_set_access(alsa_device.outhandle, hw_params,
+ SND_PCM_ACCESS_RW_INTERLEAVED);
+ check_error(err, "snd_pcm_hw_params_set_access (output)");
+
+ /* try to set interleaved access */
+ err = snd_pcm_hw_params_set_access(alsa_device.outhandle,
+ hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
+ if (err < 0)
+ {
+ /* OK, so try non-interleaved */
+ err = snd_pcm_hw_params_set_access(alsa_device.outhandle,
+ hw_params, SND_PCM_ACCESS_RW_NONINTERLEAVED);
+ if (err >= 0)
+ {
+ post("using non-interleaved audio");
+ alsa_device.outnoninterleave = 1;
+ }
+ }
+ check_error(err, "snd_pcm_hw_params_set_access (output)");
+
+
+ // Try to set 32 bit format first
+ err = snd_pcm_hw_params_set_format(alsa_device.outhandle, hw_params,
+ SND_PCM_FORMAT_S32);
+ if (err < 0)
+ {
+ err = snd_pcm_hw_params_set_format(alsa_device.outhandle,
+ hw_params,SND_PCM_FORMAT_S16);
+ check_error(err, "snd_pcm_hw_params_set_format (output)");
+ /* fprintf(stderr,
+ "PD-ALSA: 32 bit format not available - using 16\n"); */
+ alsa_samplewidth = 2;
+ }
+ else
+ {
+ alsa_samplewidth = 4;
+ }
+ // set the subformat
+ err = snd_pcm_hw_params_set_subformat(alsa_device.outhandle, hw_params,
+ SND_PCM_SUBFORMAT_STD);
+ check_error(err, "snd_pcm_hw_params_set_subformat (output)");
+ // set the number of channels
+ tmp_uint = outchans;
+ err = snd_pcm_hw_params_set_channels_min(alsa_device.outhandle,
+ hw_params, &tmp_uint);
+ check_error(err, "snd_pcm_hw_params_set_channels (output)");
+ if (tmp_uint != (unsigned)outchans)
+ post("alsa: set output channels to %d", tmp_uint);
+ outchans = tmp_uint;
+ // set the sampling rate
+ err = snd_pcm_hw_params_set_rate_min(alsa_device.outhandle, hw_params,
+ &rate, 0);
+ check_error(err, "snd_pcm_hw_params_set_rate_min (output)");
+#if 0
+ err = snd_pcm_hw_params_get_rate(hw_params, &subunitdir);
+ post("output sample rate %d", err);
+#endif
+ // set the period - ie frag size
+#if 0
+ post("output period was %d, min %d, max %d\n",
+ snd_pcm_hw_params_get_period_size(hw_params, 0),
+ snd_pcm_hw_params_get_period_size_min(hw_params, 0),
+ snd_pcm_hw_params_get_period_size_max(hw_params, 0));
+#endif
+ // post("fragsize c %d", frag_size);
+#ifdef ALSAAPI9
+ err = snd_pcm_hw_params_set_period_size_near(alsa_device.outhandle,
+ hw_params,
+ (snd_pcm_uframes_t)
+ frag_size, 0);
+#else
+ tmp_snd_pcm_uframes = frag_size;
+ err = snd_pcm_hw_params_set_period_size_near(alsa_device.outhandle,
+ hw_params, &tmp_snd_pcm_uframes, 0);
+#endif
+ // post("fragsize d %d", frag_size);
+ check_error(err, "snd_pcm_hw_params_set_period_size_near (output)");
+ // set the number of periods - ie numfrags
+#ifdef ALSAAPI9
+ err = snd_pcm_hw_params_set_periods_near(alsa_device.outhandle,
+ hw_params, nfrags, 0);
+#else
+ tmp_uint = nfrags;
+ err = snd_pcm_hw_params_set_periods_near(alsa_device.outhandle,
+ hw_params, &tmp_uint, 0);
+#endif
+ check_error(err, "snd_pcm_hw_params_set_periods_near (output)");
+ // set the buffer size
+#ifdef ALSAAPI9
+ err = snd_pcm_hw_params_set_buffer_size_near(alsa_device.outhandle,
+ hw_params, nfrags * frag_size);
+#else
+ tmp_snd_pcm_uframes = nfrags * frag_size;
+ err = snd_pcm_hw_params_set_buffer_size_near(alsa_device.outhandle,
+ hw_params, &tmp_snd_pcm_uframes);
+#endif
+ check_error(err, "snd_pcm_hw_params_set_buffer_size_near (output)");
+
+ err = snd_pcm_hw_params(alsa_device.outhandle, hw_params);
+ check_error(err, "snd_pcm_hw_params (output)");
+
+ snd_pcm_hw_params_free(hw_params);
+
+ err = snd_pcm_sw_params_malloc(&sw_params);
+ check_error(err, "snd_pcm_sw_params_malloc (output)");
+ err = snd_pcm_sw_params_current(alsa_device.outhandle, sw_params);
+ check_error(err, "snd_pcm_sw_params_current (output)");
+ err = snd_pcm_sw_params_set_start_threshold(alsa_device.outhandle,
+ sw_params, nfrags * frag_size);
+ check_error(err, "snd_pcm_sw_params_set_start_threshold (output)");
+ err = snd_pcm_sw_params_set_stop_threshold(alsa_device.outhandle,
+ sw_params, 0x7fffffff);
+ check_error(err, "snd_pcm_sw_params_set_stop_threshold (output)");
+ err = snd_pcm_sw_params_set_avail_min(alsa_device.outhandle, sw_params,
+ frag_size);
+ check_error(err, "snd_pcm_sw_params_set_avail_min (output)");
+ err = snd_pcm_sw_params(alsa_device.outhandle, sw_params);
+ check_error(err, "snd_pcm_sw_params (output)");
+ snd_pcm_sw_params_free(sw_params);
+
+ snd_output_stdio_attach(&out, stderr, 0);
+#if 0
+ if (sys_verbose)
+ {
+ snd_pcm_dump_hw_setup(alsa_device.outhandle, out);
+ snd_pcm_dump_sw_setup(alsa_device.outhandle, out);
+ }
+#endif
+ }
+
+ if (inchans)
+ snd_pcm_prepare(alsa_device.inhandle);
+ if (outchans)
+ snd_pcm_prepare(alsa_device.outhandle);
+
+ // if duplex we can link the channels so they start together
+ if (inchans && outchans)
+ snd_pcm_link(alsa_device.inhandle, alsa_device.outhandle);
+
+ // set up the status variables
+ err = snd_pcm_status_malloc(&in_status);
+ check_error(err, "snd_pcm_status_malloc");
+ err = snd_pcm_status_malloc(&out_status);
+ check_error(err, "snd_pcm_status_malloc");
+
+ // set up the buffer
+ if (alsa_snd_buf)
+ free(alsa_snd_buf);
+ alsa_snd_buf = (void *)malloc(
+ sizeof(char) * alsa_samplewidth * DEFDACBLKSIZE *
+ (outchans > inchans ? outchans : inchans));
+ memset(alsa_snd_buf, 0, sizeof(char) * alsa_samplewidth * DEFDACBLKSIZE *
+ (outchans > inchans ? outchans : inchans));
+ /* make an array of pointers too in case we need them */
+ if (alsa_buf_ptrs)
+ free(alsa_buf_ptrs);
+ alsa_buf_ptrs = (void **)malloc(
+ sizeof(void *) * (outchans > inchans ? outchans : inchans));
+ for (i = 0; i < (outchans > inchans ? outchans : inchans); i++)
+ alsa_buf_ptrs[i] = (t_alsa_sample32 *)alsa_snd_buf + i * DEFDACBLKSIZE;
+
+ // fill the buffer with silence
+ if (outchans)
+ {
+ i = (frag_size * nfrags)/DEFDACBLKSIZE + 1;
+ while (i--)
+ {
+ if (alsa_device.outnoninterleave)
+ snd_pcm_writen(alsa_device.outhandle, alsa_buf_ptrs,
+ DEFDACBLKSIZE);
+ else snd_pcm_writei(alsa_device.outhandle, alsa_snd_buf,
+ DEFDACBLKSIZE);
+ }
+ /* confused about this: */
+ /* if ((err = snd_pcm_start(alsa_device.outhandle) < 0))
+ check_error(err, "output start failed\n"); */
+ }
+ else if (inchans)
+ {
+ if (snd_pcm_start(alsa_device.inhandle) < 0)
+ check_error(err, "input start failed\n");
+ }
+ alsa_outchannels = outchans;
+ alsa_inchannels = inchans;
+
+ return (!(inchans || outchans));
+}
+
+void alsa_close_audio(void)
+{
+ int err;
+ if (alsa_inchannels)
+ {
+ err = snd_pcm_close(alsa_device.inhandle);
+ check_error(err, "snd_pcm_close (input)");
+ }
+ if (alsa_outchannels)
+ {
+ err = snd_pcm_close(alsa_device.outhandle);
+ check_error(err, "snd_pcm_close (output)");
+ }
+}
+
+// #define DEBUG_ALSA_XFER
+
+int alsa_send_dacs(void)
+{
+ static int16_t *sp;
+ static int xferno = 0;
+ static int callno = 0;
+ static double timenow;
+ double timelast;
+ t_sample *fp, *fp1, *fp2;
+ int i, j, k, err, devno = 0;
+ int inputcount = 0, outputcount = 0, inputlate = 0, outputlate = 0;
+ int result;
+ int inchannels = (sys_inchannels > alsa_inchannels ?
+ alsa_inchannels : sys_inchannels);
+ int outchannels = (sys_outchannels > alsa_outchannels ?
+ alsa_outchannels : sys_outchannels);
+ unsigned int intransfersize = DEFDACBLKSIZE;
+ unsigned int outtransfersize = DEFDACBLKSIZE;
+
+ // get the status
+ if (!inchannels && !outchannels)
+ {
+ return SENDDACS_NO;
+ }
+
+ timelast = timenow;
+ timenow = sys_getrealtime();
+
+#ifdef DEBUG_ALSA_XFER
+ if (timenow - timelast > 0.050)
+ fprintf(stderr, "(%d)",
+ (int)(1000 * (timenow - timelast))), fflush(stderr);
+#endif
+
+ callno++;
+
+ alsa_checkiosync(); /* check I/O are in sync and data not late */
+
+ if (alsa_inchannels)
+ {
+ snd_pcm_status(alsa_device.inhandle, in_status);
+ if (snd_pcm_status_get_avail(in_status) < intransfersize)
+ return SENDDACS_NO;
+ }
+ if (alsa_outchannels)
+ {
+ snd_pcm_status(alsa_device.outhandle, out_status);
+ if (snd_pcm_status_get_avail(out_status) < outtransfersize)
+ return SENDDACS_NO;
+ }
+
+ /* do output */
+ if (alsa_outchannels)
+ {
+ fp = sys_soundout;
+ if (alsa_samplewidth == 4)
+ {
+ if (alsa_device.outnoninterleave)
+ {
+ int n = outchannels * DEFDACBLKSIZE;
+ for (i = 0, fp1 = fp; i < n; i++)
+ {
+ float s1 = *fp1 * INT32_MAX;
+ ((t_alsa_sample32 *)alsa_snd_buf)[i] = CLIP32(s1);
+ }
+ n = alsa_outchannels * DEFDACBLKSIZE;
+ for (; i < n; i++)
+ ((t_alsa_sample32 *)alsa_snd_buf)[i] = 0;
+ }
+ else
+ {
+ for (i = 0, fp1 = fp; i < outchannels; i++,
+ fp1 += DEFDACBLKSIZE)
+ {
+ for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
+ j += alsa_outchannels, fp2++)
+ {
+ float s1 = *fp2 * INT32_MAX;
+ ((t_alsa_sample32 *)alsa_snd_buf)[j] = CLIP32(s1);
+ }
+ }
+ }
+ }
+ else
+ {
+ for (i = 0, fp1 = fp; i < outchannels; i++, fp1 += DEFDACBLKSIZE)
+ {
+ for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
+ j += alsa_outchannels, fp2++)
+ {
+ int s = *fp2 * 32767.;
+ if (s > 32767)
+ s = 32767;
+ else if (s < -32767)
+ s = -32767;
+ ((t_alsa_sample16 *)alsa_snd_buf)[j] = s;
+ }
+ }
+ }
+
+ if (alsa_device.outnoninterleave)
+ result = snd_pcm_writen(alsa_device.outhandle, alsa_buf_ptrs,
+ outtransfersize);
+ else result = snd_pcm_writei(alsa_device.outhandle, alsa_snd_buf,
+ outtransfersize);
+
+ if (result != (int)outtransfersize)
+ {
+ #ifdef DEBUG_ALSA_XFER
+ if (result >= 0 || errno == EAGAIN)
+ fprintf(stderr, "ALSA: write returned %d of %d\n",
+ result, outtransfersize);
+ else fprintf(stderr, "ALSA: write: %s\n",
+ snd_strerror(errno));
+ fprintf(stderr,
+ "inputcount %d, outputcount %d, outbufsize %d\n",
+ inputcount, outputcount,
+ (ALSA_EXTRABUFFER + sys_advance_samples)
+ * alsa_samplewidth * outchannels);
+ #endif
+ sys_log_error(ERR_DACSLEPT);
+ return (SENDDACS_NO);
+ }
+
+ /* zero out the output buffer */
+ memset(sys_soundout, 0, DEFDACBLKSIZE * sizeof(*sys_soundout) *
+ sys_outchannels);
+ if (sys_getrealtime() - timenow > 0.002)
+ {
+ #ifdef DEBUG_ALSA_XFER
+ fprintf(stderr, "output %d took %d msec\n",
+ callno, (int)(1000 * (timenow - timelast))), fflush(stderr);
+ #endif
+ timenow = sys_getrealtime();
+ sys_log_error(ERR_DACSLEPT);
+ }
+ }
+ /* do input */
+ if (alsa_inchannels)
+ {
+ if (alsa_device.innoninterleave)
+ result = snd_pcm_readn(alsa_device.inhandle, alsa_buf_ptrs,
+ intransfersize);
+ else result = snd_pcm_readi(alsa_device.inhandle, alsa_snd_buf,
+ intransfersize);
+ if (result < (int)intransfersize)
+ {
+#ifdef DEBUG_ALSA_XFER
+ if (result < 0)
+ fprintf(stderr,
+ "snd_pcm_read %d %d: %s\n",
+ callno, xferno, snd_strerror(errno));
+ else fprintf(stderr,
+ "snd_pcm_read %d %d returned only %d\n",
+ callno, xferno, result);
+ fprintf(stderr,
+ "inputcount %d, outputcount %d, inbufsize %d\n",
+ inputcount, outputcount,
+ (ALSA_EXTRABUFFER + sys_advance_samples)
+ * alsa_samplewidth * inchannels);
+#endif
+ sys_log_error(ERR_ADCSLEPT);
+ return (SENDDACS_NO);
+ }
+ fp = sys_soundin;
+ if (alsa_samplewidth == 4)
+ {
+ if (alsa_device.innoninterleave)
+ {
+ int n = inchannels * DEFDACBLKSIZE;
+ for (i = 0, fp1 = fp; i < n; i++)
+ *fp1 = (float) ((t_alsa_sample32 *)alsa_snd_buf)[i]
+ * (1./ INT32_MAX);
+ }
+ else
+ {
+ for (i = 0, fp1 = fp; i < inchannels;
+ i++, fp1 += DEFDACBLKSIZE)
+ {
+ for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
+ j += alsa_inchannels, fp2++)
+ *fp2 = (float) ((t_alsa_sample32 *)alsa_snd_buf)[j]
+ * (1./ INT32_MAX);
+ }
+ }
+ }
+ else
+ {
+ for (i = 0, fp1 = fp; i < inchannels; i++, fp1 += DEFDACBLKSIZE)
+ {
+ for (j = i, k = DEFDACBLKSIZE, fp2 = fp1; k--;
+ j += alsa_inchannels, fp2++)
+ *fp2 = (float) ((t_alsa_sample16 *)alsa_snd_buf)[j]
+ * 3.051850e-05;
+ }
+ }
+ }
+ xferno++;
+ if (sys_getrealtime() - timenow > 0.002)
+ {
+#ifdef DEBUG_ALSA_XFER
+ fprintf(stderr, "routine took %d msec\n",
+ (int)(1000 * (sys_getrealtime() - timenow)));
+#endif
+ sys_log_error(ERR_ADCSLEPT);
+ }
+ return SENDDACS_YES;
+}
+
+void alsa_printstate( void)
+{
+ int i, result;
+ snd_pcm_sframes_t indelay, outdelay;
+ if (sys_audioapi != API_ALSA)
+ {
+ error("restart-audio: implemented for ALSA only.");
+ return;
+ }
+ if (sys_inchannels)
+ {
+ result = snd_pcm_delay(alsa_device.inhandle, &indelay);
+ if (result < 0)
+ post("snd_pcm_delay 1 failed");
+ else post("in delay %d", indelay);
+ }
+ if (sys_outchannels)
+ {
+ result = snd_pcm_delay(alsa_device.outhandle, &outdelay);
+ if (result < 0)
+ post("snd_pcm_delay 2 failed");
+ else post("out delay %d", outdelay);
+ }
+ post("sum %d (%d mod 64)\n", indelay + outdelay, (indelay+outdelay)%64);
+
+ post("buf samples %d", alsa_buf_samps);
+}
+
+
+void alsa_resync( void)
+{
+ int i, result;
+ if (sys_audioapi != API_ALSA)
+ {
+ error("restart-audio: implemented for ALSA only.");
+ return;
+ }
+ memset(alsa_snd_buf, 0,
+ sizeof(char) * alsa_samplewidth * DEFDACBLKSIZE * sys_outchannels);
+ for (i = 0; i < 1000000; i++)
+ {
+ if (alsa_device.outnoninterleave)
+ result = snd_pcm_writen(alsa_device.outhandle, alsa_buf_ptrs,
+ DEFDACBLKSIZE);
+ else result = snd_pcm_writei(alsa_device.outhandle, alsa_snd_buf,
+ DEFDACBLKSIZE);
+ if (result != (int)DEFDACBLKSIZE)
+ break;
+ }
+ post("%d written", i);
+}
+
+void alsa_putzeros(int n)
+{
+ int i, result;
+ memset(alsa_snd_buf, 0,
+ sizeof(char) * alsa_samplewidth * DEFDACBLKSIZE * alsa_outchannels);
+ for (i = 0; i < n; i++)
+ {
+ if (alsa_device.outnoninterleave)
+ result = snd_pcm_writen(alsa_device.outhandle, alsa_buf_ptrs,
+ DEFDACBLKSIZE);
+ else result = snd_pcm_writei(alsa_device.outhandle, alsa_snd_buf,
+ DEFDACBLKSIZE);
+#if 0
+ if (result != DEFDACBLKSIZE)
+ post("result %d", result);
+#endif
+ }
+}
+
+void alsa_getzeros(int n)
+{
+ int i, result;
+ for (i = 0; i < n; i++)
+ {
+ result = snd_pcm_readi(alsa_device.inhandle, alsa_snd_buf,
+ DEFDACBLKSIZE);
+#if 0
+ if (result != DEFDACBLKSIZE)
+ post("result %d", result);
+#endif
+ }
+}
+
+ /* call this only if both input and output are open */
+static void alsa_checkiosync( void)
+{
+ int i, result, checkit = 1, giveup = 1000, alreadylogged = 0;
+ snd_pcm_sframes_t indelay, outdelay, defect;
+
+ if (!(alsa_outchannels && alsa_inchannels))
+ return;
+ while (checkit)
+ {
+ checkit = 0;
+ if (giveup-- <= 0)
+ return;
+ result = snd_pcm_delay(alsa_device.outhandle, &outdelay);
+ if (result < 0)
+ {
+ post("output snd_pcm_delay failed: %s", snd_strerror(result));
+ if (snd_pcm_status(alsa_device.outhandle, out_status) < 0)
+ post("output snd_pcm_status failed");
+ else post("astate %d",
+ snd_pcm_status_get_state(out_status));
+ return;
+ }
+ if (outdelay < 0)
+ sys_log_error(ERR_DATALATE), alreadylogged = 1;
+
+ if (sys_inchannels)
+ {
+ result = snd_pcm_delay(alsa_device.inhandle, &indelay);
+ if (result < 0)
+ {
+ post("input snd_pcm_delay failed");
+ return;
+ }
+ defect = indelay + outdelay - alsa_buf_samps;
+ if (defect < -DEFDACBLKSIZE)
+ {
+ checkit = 1;
+ alsa_putzeros(1);
+ if (!alreadylogged)
+ sys_log_error(ERR_RESYNC), alreadylogged = 1;
+ }
+ else if (defect > 0)
+ {
+ checkit = 1;
+ alsa_getzeros(1);
+ if (!alreadylogged)
+ sys_log_error(ERR_RESYNC), alreadylogged = 1;
+ }
+ }
+ }
+}
+
+void alsa_listdevs( void)
+{
+ post("device listing not implemented in ALSA yet\n");
+}
+
+static int alsa_nnames = 0;
+static char **alsa_names = 0;
+
+void alsa_adddev(char *name)
+{
+ if (alsa_nnames)
+ alsa_names = (char **)t_resizebytes(alsa_names,
+ alsa_nnames * sizeof(char *),
+ (alsa_nnames+1) * sizeof(char *));
+ else alsa_names = (char **)t_getbytes(sizeof(char *));
+ alsa_names[alsa_nnames] = gensym(name)->s_name;
+ alsa_nnames++;
+}
+
+static void alsa_numbertoname(int devno, char *devname, int nchar)
+{
+ int ndev = 0, cardno = -1;
+ while (!snd_card_next(&cardno) && cardno >= 0)
+ ndev++;
+ if (devno < 2*ndev)
+ {
+ if (devno & 1)
+ snprintf(devname, nchar, "plughw:%d", devno/2);
+ else snprintf(devname, nchar, "hw:%d", devno/2);
+ }
+ else if (devno <2*ndev + alsa_nnames)
+ snprintf(devname, nchar, "%s", alsa_names[devno - 2*ndev]);
+ else snprintf(devname, nchar, "???");
+}
+
+ /* For each hardware card found, we list two devices, the "hard" and
+ "plug" one. The card scan is derived from portaudio code. */
+void alsa_getdevs(char *indevlist, int *nindevs,
+ char *outdevlist, int *noutdevs, int *canmulti,
+ int maxndev, int devdescsize)
+{
+ int ndev = 0, cardno = -1, i, j;
+ *canmulti = 0; /* only one device; must be the same for input&output */
+ while (!snd_card_next(&cardno) && cardno >= 0)
+ {
+ snd_ctl_t *ctl;
+ snd_ctl_card_info_t *info;
+ char devname[80];
+ const char *desc;
+ if (2 * ndev + 2 > maxndev)
+ break;
+ /* apparently, "cardno" is just a counter; but check that here */
+ if (ndev != cardno)
+ fprintf(stderr, "oops: ALSA cards not reported in order?\n");
+ sprintf(devname, "hw:%d", cardno );
+ /* fprintf(stderr, "\ntry %s...\n", devname); */
+ if (snd_ctl_open(&ctl, devname, 0) >= 0)
+ {
+ snd_ctl_card_info_malloc(&info);
+ snd_ctl_card_info(ctl, info);
+ desc = snd_ctl_card_info_get_name(info);
+ snd_ctl_card_info_free(info);
+ }
+ else
+ {
+ fprintf(stderr, "ALSA card scan error\n");
+ desc = "???";
+ }
+ /* fprintf(stderr, "name: %s\n", snd_ctl_card_info_get_name(info)); */
+ sprintf(indevlist + 2*ndev * devdescsize, "%s (hardware)", desc);
+ sprintf(indevlist + (2*ndev + 1) * devdescsize, "%s (plug-in)", desc);
+ sprintf(outdevlist + 2*ndev * devdescsize, "%s (hardware)", desc);
+ sprintf(outdevlist + (2*ndev + 1) * devdescsize, "%s (plug-in)", desc);
+ ndev++;
+ }
+ for (i = 0, j = 2*ndev; i < alsa_nnames; i++, j++)
+ {
+ if (j >= maxndev)
+ break;
+ snprintf(indevlist + j * devdescsize, devdescsize, "%s",
+ alsa_names[i]);
+ }
+ *nindevs = *noutdevs = j;
+}
diff --git a/pd/src/x_midi.c b/pd/src/x_midi.c
index 7eac1108..1ff0e4b3 100644
--- a/pd/src/x_midi.c
+++ b/pd/src/x_midi.c
@@ -85,24 +85,23 @@ static void midiin_setup(void)
void inmidi_byte(int portno, int byte)
{
- static int sysex;
t_atom at[2];
- if (byte == 0xf0)
- sysex |= (1 << portno);
- if (sysexin_sym->s_thing && (sysex & (1 << portno)))
+ if (midiin_sym->s_thing)
{
SETFLOAT(at, byte);
SETFLOAT(at+1, portno + 1);
- pd_list(sysexin_sym->s_thing, 0, 2, at);
+ pd_list(midiin_sym->s_thing, 0, 2, at);
}
- if (byte == 0xf7)
- sysex &= (~(1 << portno));
+}
- if (midiin_sym->s_thing)
+void inmidi_sysex(int portno, int byte)
+{
+ t_atom at[2];
+ if (sysexin_sym->s_thing)
{
SETFLOAT(at, byte);
SETFLOAT(at+1, portno + 1);
- pd_list(midiin_sym->s_thing, 0, 2, at);
+ pd_list(sysexin_sym->s_thing, 0, 2, at);
}
}