aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES15
-rw-r--r--README40
-rw-r--r--VERSION1
-rw-r--r--catch13~.c67
-rw-r--r--cdplayer.c176
-rw-r--r--config.cache35
-rw-r--r--config.log26
-rwxr-xr-xconfig.status161
-rwxr-xr-xconfigure1845
-rw-r--r--configure.in32
-rw-r--r--d_global13.h40
-rw-r--r--doc/cdplayer.pd30
-rw-r--r--doc/ext13.pd109
-rw-r--r--doc/kalashnikov.pd23
-rw-r--r--doc/mandelbrot.pd13
-rw-r--r--doc/mandelbrot~.pd53
-rw-r--r--doc/openpatch.pd11
-rw-r--r--doc/ossmixer.pd67
-rw-r--r--doc/pipeio~.pd29
-rw-r--r--doc/promiscous~.pd10
-rw-r--r--doc/scramble~.pd107
-rw-r--r--doc/send13.pd11
-rw-r--r--doc/streamio13~.pd51
-rw-r--r--doc/wavinfo.pd18
-rw-r--r--ext13.c75
-rw-r--r--ext13.h8
-rw-r--r--filesize.c51
-rw-r--r--ftos.c67
-rw-r--r--g_canvas.h428
-rw-r--r--install-sh251
-rw-r--r--kalashnikov.c59
-rw-r--r--m_imp.h211
-rw-r--r--m_pd.h546
-rw-r--r--makefile61
-rw-r--r--makefile.in61
-rw-r--r--mandelbrot.c75
-rw-r--r--mandelbrot~.c122
-rw-r--r--messages.c36
-rw-r--r--openpatch.c68
-rw-r--r--ossmixer.c327
-rw-r--r--piperead~.c171
-rw-r--r--pipewrite~.c286
-rw-r--r--promiscous~.c126
-rw-r--r--receive13.c86
-rw-r--r--receive13~.c92
-rw-r--r--scramble~.c637
-rw-r--r--scramble~.c.save634
-rw-r--r--send13.c76
-rw-r--r--send13~.c66
-rw-r--r--sfread.c376
-rw-r--r--stream13.h10
-rw-r--r--streamin13~.c302
-rw-r--r--streamout13~.c382
-rw-r--r--strippath.c68
-rw-r--r--throw13~.c84
-rw-r--r--wavinfo.c130
56 files changed, 8942 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
new file mode 100644
index 0000000..fd3c2c6
--- /dev/null
+++ b/CHANGES
@@ -0,0 +1,15 @@
+#this file starts with the changes for version 0.14 because i was too lazy before:
+
+0.14
+ included --prefix option in configure/makefile
+ ossmixer
+
+0.15
+ send13 / receive13 (s13/r13) like s/r with "set"
+
+0.16
+ cdplayer for linux-atapi-cdrom-playing
+
+0.17
+ minor bugfixes in scramble~
+
diff --git a/README b/README
new file mode 100644
index 0000000..77bb589
--- /dev/null
+++ b/README
@@ -0,0 +1,40 @@
+this ist ext13, a collection of externals for pd
+most of the code comes from other pd-object or externals
+and is just modifyed.
+you can use, copy modify, distribute... blahblah
+there`s no warranty for anything.
+
+
+--------compile------------
+ext13 is developed and tested in linux.
+if you need it for another platform, you have to do the work to port it
+to compile it do
+./configure
+or ./configure --prefix=/usr/lib (or similar) for a path other than /usr/local
+make
+
+
+to get a seperate externalfile (.pd_linux) for every external, or
+
+./configure
+make clean
+make ext13
+to get a single library for all externals.
+
+make install
+will put the externals in /path/to/pd/externs/
+and the helpfiles in /path/to/pd/doc/5.manual/
+
+
+don`t forget to put the files in your pd-path or do a
+-lib /path/to/ext13
+to be able to use it.
+
+
+----------contact---------
+ d13@klingt.org
+
+
+---------thanks to--------
+miller puckete and guenther geiger
+
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..50653ad
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.17
diff --git a/catch13~.c b/catch13~.c
new file mode 100644
index 0000000..88b4d63
--- /dev/null
+++ b/catch13~.c
@@ -0,0 +1,67 @@
+/* Copyright (c) 1997-1999 Miller Puckette source modified by dieb13.
+* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* catch13~ ... = original objects with set-message for changing - bad hack - but works somehow*/
+
+#include "m_pd.h"
+#include "d_global13.h"
+
+#define DEFSENDVS 64 /* LATER get send to get this from canvas */
+
+
+/* ----------------------------- catch13~ ----------------------------- */
+
+ void *sigcatch13_new(t_symbol *s)
+{
+ t_sigcatch13 *x = (t_sigcatch13 *)pd_new(sigcatch13_class);
+ if (!*s->s_name) s = gensym("catch~");
+ pd_bind(&x->x_obj.ob_pd, s);
+ x->x_sym = s;
+ x->x_n = DEFSENDVS;
+ x->x_vec = (float *)getbytes(DEFSENDVS * sizeof(float));
+ outlet_new(&x->x_obj, &s_signal);
+ return (x);
+}
+
+
+ t_int *sigcatch13_perform(t_int *w)
+{
+ t_float *in = (t_float *)(w[1]);
+ t_float *out = (t_float *)(w[2]);
+ int n = (int)(w[3]);
+ while (n--) *out++ = *in, *in++ = 0;
+ return (w+4);
+}
+
+ void sigcatch13_set(t_sigcatch13 *x, t_symbol *s)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+ x->x_sym = s;
+ pd_bind(&x->x_obj.ob_pd, s);
+}
+
+ void sigcatch13_dsp(t_sigcatch13 *x, t_signal **sp)
+{
+ if (x->x_n == sp[0]->s_n)
+ dsp_add(sigcatch13_perform, 3, x->x_vec, sp[0]->s_vec, sp[0]->s_n);
+ else error("sigcatch13 %s: unexpected vector size", x->x_sym->s_name);
+}
+
+ void sigcatch13_free(t_sigcatch13 *x)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+ freebytes(x->x_vec, x->x_n * sizeof(float));
+}
+
+void sigcatch13_setup(void)
+{
+ sigcatch13_class = class_new(gensym("catch13~"), (t_newmethod)sigcatch13_new,
+ (t_method)sigcatch13_free, sizeof(t_sigcatch13), 0, A_DEFSYM, 0);
+ class_addcreator((t_newmethod)sigcatch13_new, gensym("c13~"), A_DEFSYM, 0);
+ class_addmethod(sigcatch13_class, (t_method)sigcatch13_set, gensym("set"),
+ A_SYMBOL, 0);
+ class_addmethod(sigcatch13_class, (t_method)sigcatch13_dsp, gensym("dsp"), 0);
+}
+
+
diff --git a/cdplayer.c b/cdplayer.c
new file mode 100644
index 0000000..a6999dc
--- /dev/null
+++ b/cdplayer.c
@@ -0,0 +1,176 @@
+#include "ext13.h"
+#include "m_pd.h"
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/cdrom.h>
+#include <errno.h>
+#include <string.h>
+
+
+
+/* -------------------------- cdplayer ------------------------------ */
+static t_class *cdplayer_class;
+
+typedef struct _cdplayer
+{
+ t_object x_obj;
+ t_symbol* device;
+} t_cdplayer;
+
+static void *cdplayer_new()
+{
+ char* devicename;
+ int fd;
+ t_cdplayer *x = (t_cdplayer *)pd_new(cdplayer_class);
+
+ outlet_new(&x->x_obj, &s_bang);
+ sprintf(devicename,"/dev/cdrom");
+ x->device = gensym(devicename);
+/*
+ fd = open(x->device->s_name, O_RDONLY);
+ if (fd < 0){
+ post ("cdplayer: could not open %s",x->device->s_name);
+ } else close(fd);
+*/
+ return (x);
+}
+
+static void cdplayer_play(t_cdplayer *x, t_floatarg f)
+{
+ struct cdrom_tochdr header;
+ struct cdrom_ti index;
+ int cdrom;
+ int childpid;
+ int maxTrack;
+ int t = (int)f;
+
+ childpid = fork();
+ if (childpid < 0) {
+ error ("cdplayer: could not fork!");
+ }
+ if (!childpid){
+ cdrom = open(x->device->s_name,O_RDONLY); // Open device
+ if (cdrom > -1){
+ ioctl(cdrom,CDROMREADTOCHDR,(void *) &header); // Get start and end tracks
+ maxTrack = header.cdth_trk1;
+ if (t < 1){
+ post ("track number must be 0 or higher");
+ }
+ if (t > maxTrack){
+ post ("track number too high");
+ }
+
+ index.cdti_trk0=t; // Set first track
+ index.cdti_ind0=0; // Start of track
+
+ index.cdti_trk1=t; // Set final track
+ index.cdti_ind1=99; // End of track
+
+ ioctl(cdrom,CDROMPLAYTRKIND,(void *) &index); // Play the tracks
+ exit (0);
+ }else{
+ error ("cdplayer: could not open %s",x->device->s_name);
+ }
+ close (cdrom);
+ }
+}
+
+static void cdplayer_pause(t_cdplayer *x)
+{
+ int cdrom;
+ int childpid;
+ childpid = fork();
+ if (childpid < 0) {
+ error ("cdplayer: could not fork!");
+ }
+ if (!childpid){
+ cdrom = open(x->device->s_name,O_RDONLY);
+ if (cdrom > -1){
+ ioctl(cdrom,CDROMPAUSE,0);
+ close (cdrom);
+ exit (0);
+ }else{
+ error ("cdplayer: could not open %s",x->device->s_name);
+ }
+ }
+}
+
+static void cdplayer_resume(t_cdplayer *x)
+{
+ int cdrom;
+ int childpid;
+ childpid = fork();
+ if (childpid < 0) {
+ error ("cdplayer: could not fork!");
+ }
+ if (!childpid){
+ cdrom = open(x->device->s_name,O_RDONLY);
+ if (cdrom > -1){
+ ioctl(cdrom,CDROMRESUME,0);
+ close (cdrom);
+ exit (0);
+ }else{
+ error ("cdplayer: could not open %s",x->device->s_name);
+ }
+ }
+}
+
+static void cdplayer_stop(t_cdplayer *x)
+{
+ int cdrom;
+ int childpid;
+ childpid = fork();
+ if (childpid < 0) {
+ error ("cdplayer: could not fork!");
+ }
+ if (!childpid){
+ cdrom = open(x->device->s_name,O_RDONLY);
+ if (cdrom > -1){
+ ioctl(cdrom,CDROMSTOP,0);
+ close (cdrom);
+ exit (0);
+ }else{
+ error ("cdplayer: could not open %s",x->device->s_name);
+ }
+ }
+}
+
+static void cdplayer_eject(t_cdplayer *x)
+{
+ int cdrom;
+ int childpid;
+ childpid = fork();
+ if (childpid < 0) {
+ error ("cdplayer: could not fork!");
+ }
+ if (!childpid){
+ cdrom = open(x->device->s_name,O_RDONLY);
+ if (cdrom > -1){
+ ioctl(cdrom,CDROMEJECT,0);
+ close (cdrom);
+ exit (0);
+ }else{
+ error ("cdplayer: could not open %s",x->device->s_name);
+ }
+ }
+}
+
+static void cdplayer_float(t_cdplayer *x, t_float f)
+{
+ cdplayer_play(x,f);
+}
+
+
+void cdplayer_setup(void)
+{
+ cdplayer_class = class_new(gensym("cdplayer"), (t_newmethod)cdplayer_new, 0, sizeof(t_cdplayer), 0, 0);
+ class_addfloat(cdplayer_class, cdplayer_float);
+ class_addmethod(cdplayer_class, (t_method) cdplayer_play, gensym("play"), A_DEFFLOAT,0);
+ class_addmethod(cdplayer_class, (t_method) cdplayer_pause, gensym("pause"), 0);
+ class_addmethod(cdplayer_class, (t_method) cdplayer_resume, gensym("resume"), 0);
+ class_addmethod(cdplayer_class, (t_method) cdplayer_stop, gensym("stop"), 0);
+ class_addmethod(cdplayer_class, (t_method) cdplayer_eject, gensym("eject"), 0);
+}
diff --git a/config.cache b/config.cache
new file mode 100644
index 0000000..c432d4a
--- /dev/null
+++ b/config.cache
@@ -0,0 +1,35 @@
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+ac_cv_func_getpagesize=${ac_cv_func_getpagesize=yes}
+ac_cv_func_mmap_fixed_mapped=${ac_cv_func_mmap_fixed_mapped=yes}
+ac_cv_func_select=${ac_cv_func_select=yes}
+ac_cv_func_socket=${ac_cv_func_socket=yes}
+ac_cv_func_strerror=${ac_cv_func_strerror=yes}
+ac_cv_header_fcntl_h=${ac_cv_header_fcntl_h=yes}
+ac_cv_header_stdc=${ac_cv_header_stdc=yes}
+ac_cv_header_sys_time_h=${ac_cv_header_sys_time_h=yes}
+ac_cv_header_time=${ac_cv_header_time=yes}
+ac_cv_header_unistd_h=${ac_cv_header_unistd_h=yes}
+ac_cv_lib_c_main=${ac_cv_lib_c_main=yes}
+ac_cv_lib_m_main=${ac_cv_lib_m_main=yes}
+ac_cv_lib_pthread_main=${ac_cv_lib_pthread_main=yes}
+ac_cv_lib_stk_main=${ac_cv_lib_stk_main=no}
+ac_cv_path_install=${ac_cv_path_install='/usr/bin/install -c'}
+ac_cv_prog_CC=${ac_cv_prog_CC=gcc}
+ac_cv_prog_CPP=${ac_cv_prog_CPP='gcc -E'}
+ac_cv_prog_cc_cross=${ac_cv_prog_cc_cross=no}
+ac_cv_prog_cc_g=${ac_cv_prog_cc_g=yes}
+ac_cv_prog_cc_works=${ac_cv_prog_cc_works=yes}
+ac_cv_prog_gcc=${ac_cv_prog_gcc=yes}
diff --git a/config.log b/config.log
new file mode 100644
index 0000000..66f28f8
--- /dev/null
+++ b/config.log
@@ -0,0 +1,26 @@
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+configure:529: checking for gcc
+configure:642: checking whether the C compiler (gcc ) works
+configure:658: gcc -o conftest conftest.c 1>&5
+configure:684: checking whether the C compiler (gcc ) is a cross-compiler
+configure:689: checking whether we are using GNU C
+configure:717: checking whether gcc accepts -g
+configure:779: checking for a BSD compatible install
+configure:835: checking for main in -lc
+configure:878: checking for main in -lm
+configure:921: checking for main in -lpthread
+configure:964: checking for main in -lstk
+configure:1001: checking how to run the C preprocessor
+configure:1081: checking for ANSI C header files
+configure:1188: checking for fcntl.h
+configure:1188: checking for sys/time.h
+configure:1188: checking for unistd.h
+configure:1226: checking whether time.h and sys/time.h may both be included
+configure:1265: checking for unistd.h
+configure:1304: checking for getpagesize
+configure:1357: checking for working mmap
+configure:1530: checking for select
+configure:1530: checking for socket
+configure:1530: checking for strerror
diff --git a/config.status b/config.status
new file mode 100755
index 0000000..389c258
--- /dev/null
+++ b/config.status
@@ -0,0 +1,161 @@
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host zoyd:
+#
+# ./configure
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: ./config.status [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion"
+ exec ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "./config.status generated by autoconf version 2.13"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "$ac_cs_usage"; exit 0 ;;
+ *) echo "$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=.
+ac_given_INSTALL="/usr/bin/install -c"
+
+trap 'rm -fr makefile conftest*; exit 1' 1 2 15
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\&%]/\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF
+/^[ ]*VPATH[ ]*=[^:]*$/d
+
+s%@SHELL@%/bin/sh%g
+s%@CFLAGS@%-g -O2%g
+s%@CPPFLAGS@%%g
+s%@CXXFLAGS@%%g
+s%@FFLAGS@%%g
+s%@DEFS@% -DHAVE_LIBC=1 -DHAVE_LIBM=1 -DHAVE_LIBPTHREAD=1 -DSTDC_HEADERS=1 -DHAVE_FCNTL_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_UNISTD_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_UNISTD_H=1 -DHAVE_GETPAGESIZE=1 -DHAVE_MMAP=1 -DHAVE_SELECT=1 -DHAVE_SOCKET=1 -DHAVE_STRERROR=1 %g
+s%@LDFLAGS@%%g
+s%@LIBS@%-lpthread -lm -lc %g
+s%@exec_prefix@%${prefix}%g
+s%@prefix@%/usr/local%g
+s%@program_transform_name@%s,x,x,%g
+s%@bindir@%${exec_prefix}/bin%g
+s%@sbindir@%${exec_prefix}/sbin%g
+s%@libexecdir@%${exec_prefix}/libexec%g
+s%@datadir@%${prefix}/share%g
+s%@sysconfdir@%${prefix}/etc%g
+s%@sharedstatedir@%${prefix}/com%g
+s%@localstatedir@%${prefix}/var%g
+s%@libdir@%${exec_prefix}/lib%g
+s%@includedir@%${prefix}/include%g
+s%@oldincludedir@%/usr/include%g
+s%@infodir@%${prefix}/info%g
+s%@mandir@%${prefix}/man%g
+s%@CC@%gcc%g
+s%@INSTALL_PROGRAM@%${INSTALL}%g
+s%@INSTALL_SCRIPT@%${INSTALL_PROGRAM}%g
+s%@INSTALL_DATA@%${INSTALL} -m 644%g
+s%@STK@%%g
+s%@CPP@%gcc -E%g
+
+CEOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+
+CONFIG_FILES=${CONFIG_FILES-"makefile"}
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ case "$ac_given_INSTALL" in
+ [/$]*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+
+
+exit 0
diff --git a/configure b/configure
new file mode 100755
index 0000000..8e0cd6c
--- /dev/null
+++ b/configure
@@ -0,0 +1,1845 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.13
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.13"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=filesize.c
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+ac_exeext=
+ac_objext=o
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:529: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:559: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_prog_rejected=no
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:610: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:642: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 653 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:684: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:689: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:698: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:717: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:779: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+
+
+
+echo $ac_n "checking for main in -lc""... $ac_c" 1>&6
+echo "configure:835: checking for main in -lc" >&5
+ac_lib_var=`echo c'_'main | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lc $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 843 "configure"
+#include "confdefs.h"
+
+int main() {
+main()
+; return 0; }
+EOF
+if { (eval echo configure:850: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo c | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lc $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+echo $ac_n "checking for main in -lm""... $ac_c" 1>&6
+echo "configure:878: checking for main in -lm" >&5
+ac_lib_var=`echo m'_'main | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lm $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 886 "configure"
+#include "confdefs.h"
+
+int main() {
+main()
+; return 0; }
+EOF
+if { (eval echo configure:893: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo m | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lm $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+echo $ac_n "checking for main in -lpthread""... $ac_c" 1>&6
+echo "configure:921: checking for main in -lpthread" >&5
+ac_lib_var=`echo pthread'_'main | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lpthread $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 929 "configure"
+#include "confdefs.h"
+
+int main() {
+main()
+; return 0; }
+EOF
+if { (eval echo configure:936: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo pthread | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lpthread $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+echo $ac_n "checking for main in -lstk""... $ac_c" 1>&6
+echo "configure:964: checking for main in -lstk" >&5
+ac_lib_var=`echo stk'_'main | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lstk $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 972 "configure"
+#include "confdefs.h"
+
+int main() {
+main()
+; return 0; }
+EOF
+if { (eval echo configure:979: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ STK=yes
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:1001: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+#line 1016 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1022: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+#line 1033 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1039: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 1050 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1056: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:1081: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1086 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1094: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ ac_cv_header_stdc=yes
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1111 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "memchr" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1129 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "free" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+ :
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1150 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:1161: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+ cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+for ac_hdr in fcntl.h sys/time.h unistd.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1188: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1193 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1198: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+echo "configure:1226: checking whether time.h and sys/time.h may both be included" >&5
+if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1231 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+int main() {
+struct tm *tp;
+; return 0; }
+EOF
+if { (eval echo configure:1240: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_header_time=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_time=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_header_time" 1>&6
+if test $ac_cv_header_time = yes; then
+ cat >> confdefs.h <<\EOF
+#define TIME_WITH_SYS_TIME 1
+EOF
+
+fi
+
+
+for ac_hdr in unistd.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1265: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1270 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1275: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+for ac_func in getpagesize
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1304: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1309 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1332: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+echo $ac_n "checking for working mmap""... $ac_c" 1>&6
+echo "configure:1357: checking for working mmap" >&5
+if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_func_mmap_fixed_mapped=no
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1365 "configure"
+#include "confdefs.h"
+
+/* Thanks to Mike Haertel and Jim Avera for this test.
+ Here is a matrix of mmap possibilities:
+ mmap private not fixed
+ mmap private fixed at somewhere currently unmapped
+ mmap private fixed at somewhere already mapped
+ mmap shared not fixed
+ mmap shared fixed at somewhere currently unmapped
+ mmap shared fixed at somewhere already mapped
+ For private mappings, we should verify that changes cannot be read()
+ back from the file, nor mmap's back from the file at a different
+ address. (There have been systems where private was not correctly
+ implemented like the infamous i386 svr4.0, and systems where the
+ VM page cache was not coherent with the filesystem buffer cache
+ like early versions of FreeBSD and possibly contemporary NetBSD.)
+ For shared mappings, we should conversely verify that changes get
+ propogated back to all the places they're supposed to be.
+
+ Grep wants private fixed already mapped.
+ The main things grep needs to know about mmap are:
+ * does it exist and is it safe to write into the mmap'd area
+ * how to use it (BSD variants) */
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+
+/* This mess was copied from the GNU getpagesize.h. */
+#ifndef HAVE_GETPAGESIZE
+# ifdef HAVE_UNISTD_H
+# include <unistd.h>
+# endif
+
+/* Assume that all systems that can run configure have sys/param.h. */
+# ifndef HAVE_SYS_PARAM_H
+# define HAVE_SYS_PARAM_H 1
+# endif
+
+# ifdef _SC_PAGESIZE
+# define getpagesize() sysconf(_SC_PAGESIZE)
+# else /* no _SC_PAGESIZE */
+# ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+# ifdef EXEC_PAGESIZE
+# define getpagesize() EXEC_PAGESIZE
+# else /* no EXEC_PAGESIZE */
+# ifdef NBPG
+# define getpagesize() NBPG * CLSIZE
+# ifndef CLSIZE
+# define CLSIZE 1
+# endif /* no CLSIZE */
+# else /* no NBPG */
+# ifdef NBPC
+# define getpagesize() NBPC
+# else /* no NBPC */
+# ifdef PAGESIZE
+# define getpagesize() PAGESIZE
+# endif /* PAGESIZE */
+# endif /* no NBPC */
+# endif /* no NBPG */
+# endif /* no EXEC_PAGESIZE */
+# else /* no HAVE_SYS_PARAM_H */
+# define getpagesize() 8192 /* punt totally */
+# endif /* no HAVE_SYS_PARAM_H */
+# endif /* no _SC_PAGESIZE */
+
+#endif /* no HAVE_GETPAGESIZE */
+
+#ifdef __cplusplus
+extern "C" { void *malloc(unsigned); }
+#else
+char *malloc();
+#endif
+
+int
+main()
+{
+ char *data, *data2, *data3;
+ int i, pagesize;
+ int fd;
+
+ pagesize = getpagesize();
+
+ /*
+ * First, make a file with some known garbage in it.
+ */
+ data = malloc(pagesize);
+ if (!data)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ *(data + i) = rand();
+ umask(0);
+ fd = creat("conftestmmap", 0600);
+ if (fd < 0)
+ exit(1);
+ if (write(fd, data, pagesize) != pagesize)
+ exit(1);
+ close(fd);
+
+ /*
+ * Next, try to mmap the file at a fixed address which
+ * already has something else allocated at it. If we can,
+ * also make sure that we see the same garbage.
+ */
+ fd = open("conftestmmap", O_RDWR);
+ if (fd < 0)
+ exit(1);
+ data2 = malloc(2 * pagesize);
+ if (!data2)
+ exit(1);
+ data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
+ if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_FIXED, fd, 0L))
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data2 + i))
+ exit(1);
+
+ /*
+ * Finally, make sure that changes to the mapped area
+ * do not percolate back to the file as seen by read().
+ * (This is a bug on some variants of i386 svr4.0.)
+ */
+ for (i = 0; i < pagesize; ++i)
+ *(data2 + i) = *(data2 + i) + 1;
+ data3 = malloc(pagesize);
+ if (!data3)
+ exit(1);
+ if (read(fd, data3, pagesize) != pagesize)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data3 + i))
+ exit(1);
+ close(fd);
+ unlink("conftestmmap");
+ exit(0);
+}
+
+EOF
+if { (eval echo configure:1505: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_func_mmap_fixed_mapped=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_func_mmap_fixed_mapped=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_func_mmap_fixed_mapped" 1>&6
+if test $ac_cv_func_mmap_fixed_mapped = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_MMAP 1
+EOF
+
+fi
+
+for ac_func in select socket strerror
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1530: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1535 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1558: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+cat > conftest.defs <<\EOF
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
+s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
+s%\[%\\&%g
+s%\]%\\&%g
+s%\$%$$%g
+EOF
+DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
+rm -f conftest.defs
+
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+trap 'rm -fr `echo "makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@CC@%$CC%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@STK@%$STK%g
+s%@CPP@%$CPP%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"makefile"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ case "$ac_given_INSTALL" in
+ [/$]*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/configure.in b/configure.in
new file mode 100644
index 0000000..ef0ea56
--- /dev/null
+++ b/configure.in
@@ -0,0 +1,32 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(filesize.c)
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_SUBST(STK)
+
+
+dnl Checks for libraries.
+dnl Replace `main' with a function in -lc:
+AC_CHECK_LIB(c, main)
+dnl Replace `main' with a function in -lm:
+AC_CHECK_LIB(m, main)
+dnl Replace `main' with a function in -lpthread:
+AC_CHECK_LIB(pthread, main)
+dnl Replace `main' with a function in -lstk:
+AC_CHECK_LIB(stk, main, STK=yes)
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_HEADER_TIME
+
+dnl Checks for library functions.
+AC_FUNC_MMAP
+AC_CHECK_FUNCS(select socket strerror)
+
+
+AC_OUTPUT(makefile)
diff --git a/d_global13.h b/d_global13.h
new file mode 100644
index 0000000..f10077d
--- /dev/null
+++ b/d_global13.h
@@ -0,0 +1,40 @@
+t_class *sigsend13_class;
+t_class *sigthrow13_class;
+t_class *sigreceive13_class;
+t_class *sigcatch13_class;
+
+typedef struct _sigsend13
+{
+ t_object x_obj;
+ t_symbol *x_sym;
+ int x_n;
+ float *x_vec;
+} t_sigsend13;
+
+
+typedef struct _sigreceive13
+{
+ t_object x_obj;
+ t_symbol *x_sym;
+ t_float *x_wherefrom;
+ int x_n;
+} t_sigreceive13;
+
+
+typedef struct _sigcatch13
+{
+ t_object x_obj;
+ t_symbol *x_sym;
+ int x_n;
+ float *x_vec;
+} t_sigcatch13;
+
+
+typedef struct _sigthrow13
+{
+ t_object x_obj;
+ t_symbol *x_sym;
+ t_float *x_whereto;
+ int x_n;
+} t_sigthrow13;
+
diff --git a/doc/cdplayer.pd b/doc/cdplayer.pd
new file mode 100644
index 0000000..8a61caf
--- /dev/null
+++ b/doc/cdplayer.pd
@@ -0,0 +1,30 @@
+#N canvas 0 337 450 300 10;
+#X obj 58 179 cdplayer;
+#X obj 151 235 metro 100;
+#X obj 151 261 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 151 203 1;
+#X obj 151 175 loadbang;
+#X msg 65 98 pause;
+#X msg 44 75 resume;
+#X msg 79 125 stop;
+#X msg 84 148 eject;
+#X text 22 7 cdplayer is an object for atapi-cd-roms under linux;
+#X text 100 76 resume;
+#X text 112 96 pause playing;
+#X text 113 124 stop (no resume);
+#X text 132 149 eject;
+#X text 185 261 <- cdplayer does not block;
+#X text 208 278 because of forking;
+#X floatatom 21 28 5 0 0;
+#X msg 21 51 play \$1;
+#X text 81 50 play a track;
+#X connect 1 0 2 0;
+#X connect 3 0 1 0;
+#X connect 4 0 3 0;
+#X connect 5 0 0 0;
+#X connect 6 0 0 0;
+#X connect 7 0 0 0;
+#X connect 8 0 0 0;
+#X connect 16 0 17 0;
+#X connect 17 0 0 0;
diff --git a/doc/ext13.pd b/doc/ext13.pd
new file mode 100644
index 0000000..8960f5b
--- /dev/null
+++ b/doc/ext13.pd
@@ -0,0 +1,109 @@
+#N canvas 165 0 804 625 10;
+#X obj 59 150 send13~ foo;
+#X obj 52 176 receive13~ foo;
+#X msg 236 122 set barfuss;
+#X text 13 82 send13~ \, receive13~ and catch13~ \, throw13~ are equivalent
+to s~ r~ catch~ throw~ \, but accept set messages.;
+#X obj 15 323 filesize;
+#X msg 15 297 symbol /boot/vmlinuz;
+#X obj 15 350 print;
+#X text 81 324 =;
+#X obj 99 325 fsize;
+#X text 140 153 =;
+#X text 163 143 =;
+#X obj 363 148 c13~;
+#X obj 353 195 t13~;
+#X text 334 195 =;
+#X text 348 145 =;
+#X text 14 275 filesize gives you: guess what;
+#X floatatom 255 292 4 0 0;
+#X msg 255 341 set \$1;
+#X msg 255 365 5;
+#X obj 255 317 ftos 3;
+#X text 255 241 ftos: float to symbol;
+#X floatatom 292 293 4 0 0;
+#X text 254 256 right argument for number of digits;
+#X text 13 23 most of them are not well done/tested and need more work
+for seriuos usage.;
+#X text 13 9 ext13: some extrnals i wrote for my own needs;
+#X obj 16 562 piperead~;
+#X obj 16 589 pipewrite~;
+#X text 13 524 like sfread and sfwrite \, but non-blocking;
+#X text 13 540 good for use with external programs (e.g. mpg123 > pipe)
+;
+#X obj 14 392 strippath;
+#X text 13 372 strip a path from a filename;
+#X obj 15 451 wavinfo;
+#X obj 44 198 receive13~ foo;
+#X obj 427 574 openpatch;
+#X text 499 575 =;
+#X obj 520 576 opa;
+#X msg 485 548 symbol /usr/local/pd/ext13/;
+#X msg 427 526 symbol help.pd;
+#X text 427 508 that you can also use a message for the same result
+;
+#X text 426 493 when i wrote this object \, i didn`t realize;
+#X msg 25 123 set furchtbar;
+#X text 157 176 =;
+#X obj 465 178 streamin13~ 8008 4;
+#X obj 465 203 streamout13~ localhost 8008 4;
+#X text 462 104 streamin13~/out13~ :;
+#X text 461 118 like streamin~/out~ from ggee but;
+#X text 461 132 for multiple channels;
+#X text 462 146 and reduced udp-traffic;
+#X text 463 161 warning: not well tested;
+#X obj 250 146 catch13~ bar;
+#X obj 245 168 throw13~ bar;
+#X obj 236 193 throw13~ bar;
+#X obj 543 318 mandelbrot;
+#X obj 543 340 mandelbrot~;
+#X text 542 244 mandelbrot & mandelbrot~;
+#X text 541 257 z = z*z +c;
+#X text 542 270 you can use it for gem;
+#X text 541 285 maybe you can also find another useful app \; );
+#X text 255 271 useful in combination with makefilename;
+#X text 13 50 contact: dieb13@klingt.org;
+#X text 14 420 get #samples \, channels \, bitspersample \, samplerate
+of a wavfile;
+#X obj 422 397 adc~;
+#X obj 421 449 dac~;
+#X obj 421 423 scramble~ 2;
+#X text 511 423 big fun with spoken words or beats;
+#X obj 17 499 uzi;
+#X text 46 500 =;
+#X obj 62 500 kalashnikov;
+#X text 15 479 uzi like in max for multibang;
+#X obj 380 319 ossmixer;
+#X text 359 302 a simple oss mixer;
+#X obj 33 222 receive13 foo;
+#X text 133 221 =;
+#X obj 144 221 r13 foo;
+#X obj 168 176 r13~ foo;
+#X obj 158 151 s13~ foo;
+#X text 103 247 =;
+#X obj 25 246 send13 foo;
+#X obj 114 247 s13 foo;
+#X text 353 344 a simple atapi-cdplayer;
+#X obj 380 361 cdplayer;
+#X msg 327 326 eject;
+#X connect 2 0 49 0;
+#X connect 2 0 50 0;
+#X connect 2 0 51 0;
+#X connect 4 0 6 0;
+#X connect 5 0 4 0;
+#X connect 16 0 19 0;
+#X connect 17 0 18 0;
+#X connect 19 0 17 0;
+#X connect 21 0 19 1;
+#X connect 36 0 33 1;
+#X connect 37 0 33 0;
+#X connect 40 0 0 0;
+#X connect 40 0 1 0;
+#X connect 40 0 32 0;
+#X connect 40 0 71 0;
+#X connect 40 0 77 0;
+#X connect 61 0 63 0;
+#X connect 61 1 63 1;
+#X connect 63 0 62 0;
+#X connect 63 1 62 1;
+#X connect 81 0 80 0;
diff --git a/doc/kalashnikov.pd b/doc/kalashnikov.pd
new file mode 100644
index 0000000..dfebceb
--- /dev/null
+++ b/doc/kalashnikov.pd
@@ -0,0 +1,23 @@
+#N canvas 304 321 450 300 10;
+#X msg 106 44 bang;
+#X floatatom 158 43 5 0 0;
+#X obj 254 180 print kalashnikov_done;
+#X obj 73 154 print uzi_index;
+#X obj 88 182 print uzi_done;
+#X obj 168 128 print kalashnikov_bang;
+#X obj 58 128 print uzi_bang;
+#X obj 211 154 print kalashnikov_index;
+#X obj 168 89 kalashnikov 2;
+#X obj 58 88 uzi 3;
+#X text 41 14 uzi aka kalashnikov is an easy way to serialize bangs
+;
+#X connect 0 0 8 0;
+#X connect 0 0 9 0;
+#X connect 1 0 8 1;
+#X connect 1 0 9 1;
+#X connect 8 0 5 0;
+#X connect 8 1 7 0;
+#X connect 8 2 2 0;
+#X connect 9 0 6 0;
+#X connect 9 1 3 0;
+#X connect 9 2 4 0;
diff --git a/doc/mandelbrot.pd b/doc/mandelbrot.pd
new file mode 100644
index 0000000..88df2e4
--- /dev/null
+++ b/doc/mandelbrot.pd
@@ -0,0 +1,13 @@
+#N canvas 0 0 450 300 10;
+#X obj 184 89 mandelbrot;
+#X floatatom 186 117 0 0 0;
+#X floatatom 181 61 4 0 0;
+#X floatatom 217 29 4 0 0;
+#X floatatom 267 38 0 0 0;
+#X obj 296 106 cpuload;
+#X floatatom 298 140 4 0 0;
+#X connect 0 0 1 0;
+#X connect 2 0 0 0;
+#X connect 3 0 0 1;
+#X connect 4 0 0 2;
+#X connect 5 0 6 0;
diff --git a/doc/mandelbrot~.pd b/doc/mandelbrot~.pd
new file mode 100644
index 0000000..a4953e0
--- /dev/null
+++ b/doc/mandelbrot~.pd
@@ -0,0 +1,53 @@
+#N canvas 0 0 450 300 10;
+#X obj 114 209 env~;
+#X floatatom 115 237 4 0 0;
+#X floatatom 227 135 4 0 0;
+#X floatatom 118 19 4 0 0;
+#X floatatom 182 27 4 0 0;
+#X obj 113 170 mandelbrot~ 500;
+#X obj 172 211 snapshot~;
+#X floatatom 186 243 4 0 0;
+#X obj 258 164 ticker 15 15;
+#X obj 244 186 metro 100;
+#X obj 50 258 dac~;
+#X obj 113 107 line~;
+#X obj 163 110 line~;
+#X obj 266 99 snapshot~;
+#X floatatom 280 131 4 0 0;
+#X obj 352 52 ticker 15 15;
+#X obj 338 74 metro 100;
+#X msg 181 80 \$1 1000;
+#X msg 105 75 \$1 1000;
+#X obj 183 52 * 0.01;
+#X obj 111 51 * 0.01;
+#X obj 238 19 random 100;
+#X obj 42 215 /~ 50;
+#X obj 350 142 cpuload;
+#X floatatom 354 167 4 0 0;
+#X connect 0 0 1 0;
+#X connect 2 0 5 2;
+#X connect 2 0 22 1;
+#X connect 3 0 20 0;
+#X connect 4 0 19 0;
+#X connect 5 0 6 0;
+#X connect 5 0 0 0;
+#X connect 5 0 22 0;
+#X connect 6 0 7 0;
+#X connect 8 0 9 0;
+#X connect 9 0 6 0;
+#X connect 11 0 5 0;
+#X connect 12 0 5 1;
+#X connect 12 0 13 0;
+#X connect 13 0 14 0;
+#X connect 15 0 16 0;
+#X connect 16 0 13 0;
+#X connect 16 0 21 0;
+#X connect 17 0 12 0;
+#X connect 18 0 11 0;
+#X connect 19 0 17 0;
+#X connect 20 0 18 0;
+#X connect 21 0 4 0;
+#X connect 21 0 3 0;
+#X connect 22 0 10 0;
+#X connect 22 0 10 1;
+#X connect 23 0 24 0;
diff --git a/doc/openpatch.pd b/doc/openpatch.pd
new file mode 100644
index 0000000..ef57b78
--- /dev/null
+++ b/doc/openpatch.pd
@@ -0,0 +1,11 @@
+#N canvas 19 591 373 232 10;
+#X obj 47 87 openpatch;
+#X text 120 88 =;
+#X obj 136 89 opa;
+#X msg 105 49 /tmp;
+#X msg 47 49 foo.pd;
+#X text 43 13 this would open /tmp/tst.pd;
+#X text 24 161 but you can also use;
+#X msg 176 160 \; pd open foo.pd /tmp/ 1 1 \;;
+#X connect 3 0 0 1;
+#X connect 4 0 0 0;
diff --git a/doc/ossmixer.pd b/doc/ossmixer.pd
new file mode 100644
index 0000000..ee8e34f
--- /dev/null
+++ b/doc/ossmixer.pd
@@ -0,0 +1,67 @@
+#N canvas 572 217 606 552 10;
+#X obj 188 331 ossmixer;
+#X msg 251 228 bang;
+#X msg 66 95 get pcm;
+#X msg 80 67 get main;
+#X msg 62 122 get igain;
+#X floatatom 37 167 5 0 0;
+#X text 232 479 altpcm \, reclev \, igain \, ogain;
+#X msg 37 192 set main \$1;
+#X text 35 451 possible channels:;
+#X floatatom 36 220 5 0 0;
+#X msg 36 242 set igain \$1;
+#X msg 230 130 get_source;
+#X msg 311 217 set_source line;
+#X msg 312 240 set_source mic;
+#X msg 314 263 set_source cd;
+#X floatatom 35 267 5 0 0;
+#X msg 35 289 set pcm \$1;
+#X symbolatom 239 359 10 0 0;
+#X floatatom 223 386 5 0 0;
+#X obj 158 387 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 158 358 sel source;
+#X floatatom 199 96 5 0 0;
+#X text 15 36 you will have to do mutings manually (read \, set 0 \,
+set x);
+#X text 146 67 get value of channel;
+#X text 252 98 get value of current channel;
+#X text 249 212 nop;
+#X text 307 131 get recording source;
+#X text 316 281 set rec. source;
+#X text 7 166 s;
+#X text 8 180 e;
+#X text 8 195 t;
+#X text 7 220 v;
+#X text 7 231 a;
+#X text 7 245 l;
+#X text 7 258 u;
+#X text 7 271 e;
+#X text 35 466 main \, treble \, bass \, synth \, pcm \, speaker \,
+line \, line1 \, line2 \, line3 \, mic \, cd \, imix \,;
+#X text 130 421 right outlet: channel name;
+#X text 130 408 left outlet: "source" or value;
+#X msg 252 173 set_device 1;
+#X text 350 175 /dev/mixer1 /dev/mixer2...;
+#X text 15 6 a simple mixer for /dev/mixerX;
+#X text 16 21 only stereo (no seperate L/R);
+#X connect 0 0 20 0;
+#X connect 0 1 17 0;
+#X connect 1 0 0 0;
+#X connect 2 0 0 0;
+#X connect 3 0 0 0;
+#X connect 4 0 0 0;
+#X connect 5 0 7 0;
+#X connect 7 0 0 0;
+#X connect 9 0 10 0;
+#X connect 10 0 0 0;
+#X connect 11 0 0 0;
+#X connect 12 0 0 0;
+#X connect 13 0 0 0;
+#X connect 14 0 0 0;
+#X connect 15 0 16 0;
+#X connect 16 0 0 0;
+#X connect 20 0 19 0;
+#X connect 20 1 18 0;
+#X connect 21 0 0 0;
+#X connect 39 0 0 0;
diff --git a/doc/pipeio~.pd b/doc/pipeio~.pd
new file mode 100644
index 0000000..e7e2951
--- /dev/null
+++ b/doc/pipeio~.pd
@@ -0,0 +1,29 @@
+#N canvas 303 26 450 397 10;
+#X msg 102 140 1;
+#X msg 81 90 0;
+#X obj 226 21 loadbang;
+#X msg 226 47 \; pd dsp 1;
+#X obj 63 67 osc~ 440;
+#X msg 94 117 open /usr/local/pd/ext13/doc/pipein.wav;
+#X obj 246 231 dac~;
+#X obj 63 179 pipewrite~ 2;
+#X obj 142 65 osc~ 480;
+#X obj 224 192 piperead~ 2;
+#X msg 165 140 open /usr/local/pd/ext13/doc/pipein.wav;
+#X msg 227 164 1;
+#X msg 261 166 0;
+#X text 26 256 pipewrite/read: argument: number of channels you can
+create a pipe/fifo from within a shell with mknod pipename p and use
+this construct to send signals to another program/process. useful if
+you run more than one pd or mpeg-players \, ...;
+#X connect 0 0 7 0;
+#X connect 1 0 7 0;
+#X connect 2 0 3 0;
+#X connect 4 0 7 0;
+#X connect 5 0 7 0;
+#X connect 8 0 7 1;
+#X connect 9 0 6 0;
+#X connect 9 1 6 1;
+#X connect 10 0 9 0;
+#X connect 11 0 9 0;
+#X connect 12 0 9 0;
diff --git a/doc/promiscous~.pd b/doc/promiscous~.pd
new file mode 100644
index 0000000..eea18cf
--- /dev/null
+++ b/doc/promiscous~.pd
@@ -0,0 +1,10 @@
+#N canvas 0 0 450 300 10;
+#X obj 136 209 promiscous~;
+#X obj 127 246 dac~;
+#X msg 201 35 bang;
+#X msg 201 61 \; pd dsp 1;
+#X text 69 166 thats passing by \, into a sound signal.;
+#X text 68 146 you must be root to turn all network traffic \,;
+#X connect 0 0 1 0;
+#X connect 0 0 1 1;
+#X connect 2 0 3 0;
diff --git a/doc/scramble~.pd b/doc/scramble~.pd
new file mode 100644
index 0000000..35d10c3
--- /dev/null
+++ b/doc/scramble~.pd
@@ -0,0 +1,107 @@
+#N canvas 259 13 723 441 10;
+#X obj 324 367 dac~;
+#X obj 324 331 scramble~ 2;
+#X floatatom 422 124 0 0 0;
+#X obj 299 241 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 1
+1;
+#X msg 50 36 \; pd dsp 1;
+#X obj 44 11 loadbang;
+#X msg 22 69 \; pd meters 1;
+#X obj 342 262 adc~;
+#X msg 140 285 threshold \$1;
+#X floatatom 140 262 0 0 0;
+#X msg 332 121 open \$1;
+#X obj 324 145 sfread~ 2;
+#X obj 230 104 del 100;
+#X msg 230 80 bang;
+#X msg 237 20 open /usr/local/media/audios/klima_gegengelesen_cato-ok.wav
+;
+#X msg 296 42 open /usr/local/media/audios/restorak.wav;
+#X obj 334 96 openpanel;
+#X msg 333 74 bang;
+#X obj 512 158 openpanel;
+#X msg 511 123 bang;
+#X msg 591 162 start;
+#X msg 594 137 stop;
+#X msg 515 194 open \$1;
+#X obj 422 101 cpuload 100;
+#X obj 513 229 mp3play~;
+#X floatatom 587 199 5 0 0;
+#X msg 146 157 grains \$1;
+#X floatatom 146 133 0 0 0;
+#X floatatom 27 130 0 0 0;
+#X msg 27 153 min_length \$1;
+#X floatatom 18 255 0 0 0;
+#X msg 18 278 direction \$1;
+#X msg 141 206 autofollow;
+#X floatatom 241 199 0 0 0;
+#X msg 242 221 buffer \$1;
+#X text 176 135 # of grains;
+#X text 26 113 minimum low period;
+#X text 209 180 ringbuffer size (882000);
+#X text 6 202 -1 back only;
+#X text 11 214 1 forw. only;
+#X text 11 231 0 both directions;
+#X text 136 244 threshold;
+#X text 110 183 autothreshold;
+#X floatatom 22 309 0 0 0;
+#X msg 22 332 pitch \$1;
+#X msg 107 353 flush;
+#X floatatom 372 375 0 0 0;
+#X floatatom 396 355 0 0 0;
+#X floatatom 169 373 0 0 0;
+#X msg 169 396 normalize \$1;
+#X msg 271 402 analize \$1;
+#X obj 273 374 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X floatatom 400 198 5 0 0;
+#X msg 400 223 autopitch \$1;
+#X connect 1 0 0 0;
+#X connect 1 1 0 1;
+#X connect 1 2 46 0;
+#X connect 1 3 47 0;
+#X connect 3 0 1 0;
+#X connect 5 0 4 0;
+#X connect 5 0 6 0;
+#X connect 7 0 1 0;
+#X connect 7 1 1 1;
+#X connect 8 0 1 0;
+#X connect 9 0 8 0;
+#X connect 10 0 11 0;
+#X connect 11 0 1 0;
+#X connect 11 1 1 1;
+#X connect 12 0 11 0;
+#X connect 13 0 12 0;
+#X connect 14 0 11 0;
+#X connect 14 0 13 0;
+#X connect 15 0 11 0;
+#X connect 15 0 13 0;
+#X connect 16 0 10 0;
+#X connect 17 0 16 0;
+#X connect 18 0 22 0;
+#X connect 19 0 18 0;
+#X connect 20 0 24 0;
+#X connect 21 0 24 0;
+#X connect 22 0 24 0;
+#X connect 23 0 2 0;
+#X connect 24 0 1 0;
+#X connect 24 1 1 1;
+#X connect 25 0 24 1;
+#X connect 26 0 1 0;
+#X connect 27 0 26 0;
+#X connect 28 0 29 0;
+#X connect 29 0 1 0;
+#X connect 30 0 31 0;
+#X connect 31 0 1 0;
+#X connect 32 0 1 0;
+#X connect 33 0 34 0;
+#X connect 34 0 1 0;
+#X connect 43 0 44 0;
+#X connect 44 0 1 0;
+#X connect 45 0 1 0;
+#X connect 48 0 49 0;
+#X connect 49 0 1 0;
+#X connect 50 0 1 0;
+#X connect 51 0 50 0;
+#X connect 52 0 53 0;
+#X connect 53 0 1 0;
diff --git a/doc/send13.pd b/doc/send13.pd
new file mode 100644
index 0000000..ec397e1
--- /dev/null
+++ b/doc/send13.pd
@@ -0,0 +1,11 @@
+#N canvas 0 0 450 300 10;
+#X obj 197 107 receive13 foo;
+#X obj 71 107 send13 foo;
+#X floatatom 197 141 5 0 0;
+#X floatatom 71 79 5 0 0;
+#X msg 197 67 set bar;
+#X msg 118 79 set bar;
+#X connect 0 0 2 0;
+#X connect 3 0 1 0;
+#X connect 4 0 0 0;
+#X connect 5 0 1 0;
diff --git a/doc/streamio13~.pd b/doc/streamio13~.pd
new file mode 100644
index 0000000..5ee91bd
--- /dev/null
+++ b/doc/streamio13~.pd
@@ -0,0 +1,51 @@
+#N canvas 165 0 804 625 10;
+#X obj 18 107 streamin13~ 8008 4;
+#X obj 19 496 streamout13~ localhost 8008 4;
+#X text 15 13 streamin13~/out13~ :;
+#X text 14 27 like streamin~/out~ from ggee but;
+#X text 14 41 for multiple channels;
+#X text 15 55 and reduced udp-traffic;
+#X text 16 70 warning: not well tested;
+#X text 161 110 receives 4 channels in port 8808;
+#X obj 18 150 dac~ 1;
+#X obj 68 150 dac~ 2;
+#X obj 121 150 dac~ 3;
+#X obj 175 151 dac~ 4;
+#X obj 74 462 osc~ 440;
+#X obj 145 463 osc~ 880;
+#X obj 214 462 osc~ 990;
+#X obj 281 463 osc~ 220;
+#X text 245 497 sends 4 dsp-channels to localhost:8008;
+#X msg 19 202 connect foo.com 8008;
+#X msg 32 235 disconnect;
+#X text 175 203 to build up a connection and start sending;
+#X text 117 236 guess;
+#X msg 46 263 format float;
+#X msg 56 287 format 16bit;
+#X msg 72 311 format 8bit;
+#X text 165 284 format defines the resolution of the sent signal;
+#X text 168 302 float is the most expensive with the best resolution
+(32bit);
+#X text 181 337 change the hostname you are sending to;
+#X msg 85 337 host bar.org;
+#X msg 101 364 grain 512;
+#X text 185 363 the number of samples sent at a time;
+#X text 347 462 the signals to send;
+#X floatatom 19 528 5 0 0;
+#X text 72 530 status: 1 = connected 0 = disconnected;
+#X connect 0 0 8 0;
+#X connect 0 1 9 0;
+#X connect 0 2 10 0;
+#X connect 0 3 11 0;
+#X connect 1 0 31 0;
+#X connect 12 0 1 0;
+#X connect 13 0 1 1;
+#X connect 14 0 1 2;
+#X connect 15 0 1 3;
+#X connect 17 0 1 0;
+#X connect 18 0 1 0;
+#X connect 21 0 1 0;
+#X connect 22 0 1 0;
+#X connect 23 0 1 0;
+#X connect 27 0 1 0;
+#X connect 28 0 1 0;
diff --git a/doc/wavinfo.pd b/doc/wavinfo.pd
new file mode 100644
index 0000000..c42cc6e
--- /dev/null
+++ b/doc/wavinfo.pd
@@ -0,0 +1,18 @@
+#N canvas 0 1 450 300 8;
+#X obj 112 79 openpanel;
+#X msg 112 49 bang;
+#X obj 111 105 wavinfo;
+#X floatatom 45 168 20 0 0;
+#X floatatom 165 168 5 0 0;
+#X floatatom 212 169 5 0 0;
+#X floatatom 257 169 5 0 0;
+#X text 44 183 samples;
+#X text 165 183 channels;
+#X text 212 183 bitsize;
+#X text 257 184 rate;
+#X connect 0 0 2 0;
+#X connect 1 0 0 0;
+#X connect 2 0 3 0;
+#X connect 2 1 4 0;
+#X connect 2 2 5 0;
+#X connect 2 3 6 0;
diff --git a/ext13.c b/ext13.c
new file mode 100644
index 0000000..b4eb2d4
--- /dev/null
+++ b/ext13.c
@@ -0,0 +1,75 @@
+#ifndef VERSION
+#define VERSION "0.17"
+#endif
+
+#include "m_pd.h"
+
+#ifndef __DATE__
+#define __DATE__ "05/22/01"
+#endif
+
+typedef struct _ext13
+{
+ t_object x_obj;
+} t_ext13;
+
+static t_class* ext13_class;
+
+void kalashnikov_setup();
+void filesize_setup();
+void openpatch_setup();
+void sigsend13_setup();
+void sigcatch13_setup();
+void sigthrow13_setup();
+void sigreceive13_setup();
+void strippath_setup();
+void streamin13_setup();
+void streamout13_setup();
+void pipewrite_tilde_setup();
+void piperead_tilde_setup();
+void wavinfo_setup();
+void ftos_setup();
+void mandelbrot_setup();
+void scramble_tile_setup();
+void promiscous_tilde_setup();
+void ossmixer_setup();
+void send13_setup();
+void receive13_setup();
+void cdplayer_setup();
+
+static void* ext13_new(t_symbol* s) {
+ t_ext13 *x = (t_ext13 *)pd_new(ext13_class);
+ return (x);
+}
+
+void ext13_setup(void)
+{
+ ext13_class = class_new(gensym("ext13"), (t_newmethod)ext13_new, 0,
+ sizeof(t_ext13), 0,0);
+
+ kalashnikov_setup();
+ filesize_setup();
+ openpatch_setup();
+ sigsend13_setup();
+ sigcatch13_setup();
+ sigthrow13_setup();
+ sigreceive13_setup();
+ strippath_setup();
+ streamin13_setup();
+ streamout13_setup();
+ piperead_tilde_setup();
+ pipewrite_tilde_setup();
+ wavinfo_setup();
+ ftos_setup();
+ mandelbrot_tilde_setup();
+ scramble_tilde_setup();
+ promiscous_tilde_setup();
+ ossmixer_setup();
+ send13_setup();
+ receive13_setup();
+ cdplayer_setup();
+
+ post("EXT13 by dieb13@klingt.org");
+ post("EXT13: version: "VERSION);
+ post("EXT13: compiled: "__DATE__);
+}
diff --git a/ext13.h b/ext13.h
new file mode 100644
index 0000000..fd09168
--- /dev/null
+++ b/ext13.h
@@ -0,0 +1,8 @@
+#ifndef __EXT13_H__
+#define __EXT13_H__
+
+#define BACKGROUND "-fill white"
+#define BACKGROUNDCOLOR "white"
+
+
+#endif
diff --git a/filesize.c b/filesize.c
new file mode 100644
index 0000000..0a87812
--- /dev/null
+++ b/filesize.c
@@ -0,0 +1,51 @@
+#include "ext13.h"
+#include "m_pd.h"
+#include <sys/stat.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+/* -------------------------- filesize ------------------------------ */
+static t_class *filesize_class;
+
+typedef struct _filesize
+{
+ t_object x_obj;
+ t_float x_f;
+ t_symbol *x_s;
+} t_filesize;
+
+
+static void *filesize_new(t_symbol *s)
+{
+ t_filesize *x = (t_filesize *)pd_new(filesize_class);
+ x->x_s = s;
+ outlet_new(&x->x_obj, &s_float);
+ return (x);
+}
+
+static void filesize_bang(t_filesize *x)
+{
+ outlet_float(x->x_obj.ob_outlet, x->x_f);
+}
+
+static void filesize_symbol(t_filesize *x, t_symbol *s)
+{
+ struct stat statbuf;
+ int ok=(stat(s->s_name, &statbuf) >= 0);
+ if (ok>0) outlet_float(x->x_obj.ob_outlet,x->x_f=statbuf.st_size);
+ else post ("filesize:file not found");
+}
+
+void filesize_setup(void)
+{
+ filesize_class = class_new(gensym("filesize"), (t_newmethod)filesize_new, 0,
+ sizeof(t_filesize), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)filesize_new, gensym("fsize"), A_DEFFLOAT, 0);
+ class_addbang(filesize_class, filesize_bang);
+ class_addsymbol(filesize_class, filesize_symbol);
+}
diff --git a/ftos.c b/ftos.c
new file mode 100644
index 0000000..db64e38
--- /dev/null
+++ b/ftos.c
@@ -0,0 +1,67 @@
+#include "ext13.h"
+#include "m_pd.h"
+#include <sys/stat.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+/* -------------------------- ftos ------------------------------ */
+static t_class *ftos_class;
+
+typedef struct _ftos
+{
+ t_object x_obj;
+ t_symbol *x_s;
+ t_symbol *x_fmt;
+ t_float x_f;
+} t_ftos;
+
+
+static void *ftos_new(t_floatarg f)
+{
+ t_ftos *x = (t_ftos *)pd_new(ftos_class);
+ x->x_f=f;
+ floatinlet_new(&x->x_obj, &x->x_f);
+ outlet_new(&x->x_obj,0);
+ x->x_s = gensym("0");
+ return (x);
+}
+
+
+
+static void ftos_bang(t_ftos *x)
+{
+ outlet_symbol(x->x_obj.ob_outlet,x->x_s);
+}
+
+static void ftos_float(t_ftos *x, t_float f)
+{
+ char result[MAXPDSTRING];
+ char fmt[MAXPDSTRING];
+ char num[MAXPDSTRING];
+/* if (!f){f=2;} */
+ sprintf(num,"%d",(int)x->x_f);
+ strcpy(fmt,"%.");
+ strcat(fmt,num);
+ strcat(fmt,"f");
+ x->x_fmt = gensym (fmt);
+ sprintf(result,x->x_fmt->s_name,(float)f);
+ x->x_s = gensym(result);
+ ftos_bang(x);
+}
+
+
+
+void ftos_setup(void)
+{
+ ftos_class = class_new(gensym("ftos"), (t_newmethod)ftos_new, 0,
+ sizeof(t_ftos), 0, A_DEFFLOAT, 0);
+ class_addbang(ftos_class, ftos_bang);
+ class_addfloat(ftos_class, ftos_float);
+/* class_addfloat(ftos_class; ftos_float);*/
+}
diff --git a/g_canvas.h b/g_canvas.h
new file mode 100644
index 0000000..0176f6c
--- /dev/null
+++ b/g_canvas.h
@@ -0,0 +1,428 @@
+/* Copyright (c) 1997-1999 Miller Puckette.
+* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* a header for canvas objects that hold lists of t_gobjs, such as
+* canvases themselves or graphs
+*/
+
+/* --------------------- geometry ---------------------------- */
+#define IOWIDTH 7
+#define IOMIDDLE 3
+#define IOTOPMARGIN 1
+#define IOBOTTOMMARGIN 1
+
+/* ----------------------- data ------------------------------- */
+
+typedef struct _updateheader
+{
+ struct _updateheader *upd_next;
+ unsigned int upd_array:1; /* true if array, false if glist */
+ unsigned int upd_queued:1; /* true if we're queued */
+} t_updateheader;
+
+typedef void (*t_glistmotionfn)(void *z, t_floatarg dx, t_floatarg dy);
+typedef void (*t_glistkeyfn)(void *z, t_floatarg key);
+
+EXTERN_STRUCT _rtext;
+#define t_rtext struct _rtext
+
+EXTERN_STRUCT _gtemplate;
+#define t_gtemplate struct _gtemplate
+
+EXTERN_STRUCT _guiconnect;
+#define t_guiconnect struct _guiconnect
+
+EXTERN_STRUCT _subcanvas;
+#define t_subcanvas struct _subcanvas
+
+EXTERN_STRUCT _tscalar;
+#define t_tscalar struct _tscalar
+
+typedef struct _selection
+{
+ t_gobj *sel_what;
+ struct _selection *sel_next;
+} t_selection;
+
+ /* this structure is instantiated whenever a glist becomes visible. */
+typedef struct _editor
+{
+ t_updateheader e_upd; /* update header structure */
+ t_selection *e_updlist; /* list of objects to update */
+ t_rtext *e_rtext; /* text responder linked list */
+ t_selection *e_selection; /* head of the selection list */
+ t_rtext *e_textedfor; /* the rtext if any that we are editing */
+ t_gobj *e_grab; /* object being "dragged" */
+ t_glistmotionfn e_motionfn; /* ... motion callback */
+ t_glistkeyfn e_keyfn; /* ... keypress callback */
+ t_binbuf *e_connectbuf; /* connections to deleted objects */
+ t_binbuf *e_deleted; /* last stuff we deleted */
+ t_guiconnect *e_guiconnect; /* GUI connection for filtering messages */
+ struct _glist *e_glist; /* glist which owns this */
+ int e_xwas; /* xpos on last mousedown or motion event */
+ int e_ywas; /* ypos, similarly */
+ unsigned int e_onmotion: 3; /* action to take on motion */
+ unsigned int e_lastmoved: 1; /* one if mouse has moved since click */
+ unsigned int e_textdirty: 1; /* one if e_textedfor has changed */
+} t_editor;
+
+#define MA_NONE 0 /* e_onmotion: do nothing on mouse motion */
+#define MA_MOVE 1 /* drag the selection around */
+#define MA_CONNECT 2 /* make a connection */
+#define MA_REGION 3 /* selection region */
+#define MA_PASSOUT 4 /* send on to e_grab */
+#define MA_DRAGTEXT 5 /* drag in text editor to alter selection */
+
+/* editor structure for "garrays". We don't bother to delete and regenerate
+this structure when the "garray" becomes invisible or visible, although we
+could do so if the structure gets big (like the "editor" above.) */
+
+typedef struct _arrayvis
+{
+ t_updateheader av_upd; /* update header structure */
+ t_garray *av_garray; /* owning structure */
+} t_arrayvis;
+
+typedef struct _tick /* where to put ticks on x or y axes */
+{
+ float k_point; /* one point to draw a big tick at */
+ float k_inc; /* x or y increment per little tick */
+ int k_lperb; /* little ticks per big; 0 if no ticks to draw */
+} t_tick;
+
+typedef struct _glist
+{
+ t_gobj gl_gobj; /* header in case we're a glist */
+ t_gobj *gl_list; /* the actual data */
+ struct _gstub *gl_stub; /* safe pointer handler */
+ int gl_valid; /* incremented when pointers might be stale */
+ struct _glist *gl_owner; /* parent glist or 0 if none */
+ float gl_px1; /* bounding rectangle in parent's coords */
+ float gl_py1;
+ float gl_px2;
+ float gl_py2;
+ float gl_x1; /* ... and in our own coordinates */
+ float gl_y1;
+ float gl_x2;
+ float gl_y2;
+ t_tick gl_xtick; /* ticks marking X values */
+ t_tick gl_ytick; /* ... and Y values */
+ int gl_nxlabels; /* X coordinate labels */
+ t_symbol **gl_xlabel;
+ float gl_xlabely; /* ... and their Y coordinates */
+ int gl_nylabels; /* Y coordinate labels */
+ t_symbol **gl_ylabel;
+ float gl_ylabelx;
+ t_editor *gl_editor; /* editor structure when visible */
+ t_symbol *gl_name; /* symbol bound here */
+} t_glist;
+
+#define gl_pd gl_gobj.g_pd
+
+/* a data structure to describe a field in a pure datum */
+
+#define DT_FLOAT 0
+#define DT_SYMBOL 1
+#define DT_LIST 2
+#define DT_ARRAY 3
+
+typedef struct _dataslot
+{
+ int ds_type;
+ t_symbol *ds_name;
+ t_symbol *ds_arraytemplate; /* filled in for arrays only */
+} t_dataslot;
+
+typedef struct _template
+{
+ int t_n;
+ t_dataslot *t_vec;
+} t_template;
+
+struct _array
+{
+ int a_n;
+ int a_elemsize; /* LATERd just look this up from template... */
+ t_word *a_vec;
+ t_symbol *a_templatesym; /* template for elements */
+ int a_valid; /* protection against stale pointers into array */
+ t_gpointer a_gp; /* pointer to scalar or array element we're in */
+ t_gstub *a_stub;
+};
+
+
+/* function types used to define graphical behavior for gobjs, a bit like X
+widgets. These aren't Pd methods because Pd's typechecking can't specify the
+types of pointer arguments. Also it's more convenient this way, since
+every "patchable" object can just get the "text" behaviors. */
+
+ /* Call this to get a gobj's bounding rectangle in pixels */
+typedef void (*t_getrectfn)(t_gobj *x, struct _glist *glist,
+ int *x1, int *y1, int *x2, int *y2);
+ /* and this to displace a gobj: */
+typedef void (*t_displacefn)(t_gobj *x, struct _glist *glist, int dx, int dy);
+ /* change color to show selection: */
+typedef void (*t_selectfn)(t_gobj *x, struct _glist *glist, int state);
+ /* change appearance to show activation/deactivation: */
+typedef void (*t_activatefn)(t_gobj *x, struct _glist *glist, int state);
+ /* warn a gobj it's about to be deleted */
+typedef void (*t_deletefn)(t_gobj *x, struct _glist *glist);
+ /* making visible or invisible */
+typedef void (*t_visfn)(t_gobj *x, struct _glist *glist, int flag);
+ /* field a mouse click (when not in "edit" mode) */
+typedef int (*t_clickfn)(t_gobj *x, struct _glist *glist,
+ int xpix, int ypix, int shift, int alt, int dbl, int doit);
+ /* save to a binbuf */
+typedef void (*t_savefn)(t_gobj *x, t_binbuf *b);
+ /* open properties dialog */
+typedef void (*t_propertiesfn)(t_gobj *x, struct _glist *glist);
+ /* ... and later, resizing; getting/setting color... */
+
+struct _widgetbehavior
+{
+ t_getrectfn w_getrectfn;
+ t_displacefn w_displacefn;
+ t_selectfn w_selectfn;
+ t_activatefn w_activatefn;
+ t_deletefn w_deletefn;
+ t_visfn w_visfn;
+ t_clickfn w_clickfn;
+ t_savefn w_savefn;
+ t_propertiesfn w_propertiesfn;
+};
+
+/* -------- behaviors for scalars defined by objects in template --------- */
+/* these are set by "drawing commands" in g_template.c which add appearance to
+scalars, which live in some other window. If the scalar is just included
+in a canvas the "parent" is a misnomer. There is also a text scalar object
+which really does draw the scalar on the parent window; see g_scalar.c. */
+
+/* note how the click function wants the whole scalar, not the "data", so
+doesn't work on array elements... is this a problem??? */
+
+ /* bounding rectangle: */
+typedef void (*t_parentgetrectfn)(t_gobj *x, struct _glist *glist,
+ t_word *data, t_canvas *template, float basex, float basey,
+ int *x1, int *y1, int *x2, int *y2);
+ /* displace it */
+typedef void (*t_parentdisplacefn)(t_gobj *x, struct _glist *glist,
+ t_word *data, t_canvas *template, float basex, float basey,
+ int dx, int dy);
+ /* change color to show selection */
+typedef void (*t_parentselectfn)(t_gobj *x, struct _glist *glist,
+ t_word *data, t_canvas *template, float basex, float basey,
+ int state);
+ /* change appearance to show activation/deactivation: */
+typedef void (*t_parentactivatefn)(t_gobj *x, struct _glist *glist,
+ t_word *data, t_canvas *template, float basex, float basey,
+ int state);
+ /* making visible or invisible */
+typedef void (*t_parentvisfn)(t_gobj *x, struct _glist *glist,
+ t_word *data, t_canvas *template, float basex, float basey,
+ int flag);
+ /* field a mouse click */
+typedef int (*t_parentclickfn)(t_gobj *x, struct _glist *glist,
+ t_scalar *sc, t_canvas *template, float basex, float basey,
+ int xpix, int ypix, int shift, int alt, int dbl, int doit);
+
+struct _parentwidgetbehavior
+{
+ t_parentgetrectfn w_parentgetrectfn;
+ t_parentdisplacefn w_parentdisplacefn;
+ t_parentselectfn w_parentselectfn;
+ t_parentactivatefn w_parentactivatefn;
+ t_parentvisfn w_parentvisfn;
+ t_parentclickfn w_parentclickfn;
+};
+
+ /* cursor definitions; used as return value for t_parentclickfn */
+#define CURSOR_RUNMODE_NOTHING 0
+#define CURSOR_RUNMODE_CLICKME 1
+#define CURSOR_RUNMODE_THICKEN 2
+#define CURSOR_RUNMODE_ADDPOINT 3
+#define CURSOR_EDITMODE_NOTHING 4
+#define CURSOR_EDITMODE_CONNECT 5
+#define CURSOR_EDITMODE_DISCONNECT 6
+
+extern t_canvas *canvas_editing; /* last canvas to start text edting */
+extern t_class *vinlet_class, *voutlet_class;
+extern t_class *tscalar_class;
+extern t_class *subcanvas_class;
+
+/* ------------------- functions on any gobj ----------------------------- */
+EXTERN void gobj_getrect(t_gobj *x, t_glist *owner, int *x1, int *y1,
+ int *x2, int *y2);
+EXTERN void gobj_displace(t_gobj *x, t_glist *owner, int dx, int dy);
+EXTERN void gobj_select(t_gobj *x, t_glist *owner, int state);
+EXTERN void gobj_activate(t_gobj *x, t_glist *owner, int state);
+EXTERN void gobj_delete(t_gobj *x, t_glist *owner);
+EXTERN void gobj_vis(t_gobj *x, t_glist *glist, int flag);
+EXTERN int gobj_click(t_gobj *x, struct _glist *glist,
+ int xpix, int ypix, int shift, int alt, int dbl, int doit);
+EXTERN void gobj_save(t_gobj *x, t_binbuf *b);
+EXTERN void gobj_properties(t_gobj *x, struct _glist *glist);
+
+/* -------------------- functions on glists --------------------- */
+EXTERN t_glist *glist_new( void);
+EXTERN void glist_init(t_glist *x);
+EXTERN void glist_add(t_glist *x, t_gobj *g);
+EXTERN void glist_clear(t_glist *x);
+EXTERN t_canvas *glist_getcanvas(t_glist *x);
+EXTERN int glist_isselected(t_glist *x, t_gobj *y);
+EXTERN void glist_select(t_glist *x, t_gobj *y);
+EXTERN void glist_deselect(t_glist *x, t_gobj *y);
+EXTERN void glist_noselect(t_glist *x);
+EXTERN void glist_selectall(t_glist *x);
+EXTERN void glist_delete(t_glist *x, t_gobj *y);
+EXTERN void glist_retext(t_glist *x, t_text *y);
+EXTERN void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
+ t_glistkeyfn keyfn, int xpos, int ypos);
+EXTERN int glist_isvisible(t_glist *x);
+EXTERN t_glist *glist_findgraph(t_glist *x);
+EXTERN int glist_getfont(t_glist *x);
+EXTERN void glist_sort(t_glist *canvas);
+EXTERN void glist_read(t_glist *x, t_symbol *filename, t_symbol *format);
+EXTERN void glist_write(t_glist *x, t_symbol *filename, t_symbol *format);
+
+EXTERN float glist_pixelstox(t_glist *x, float xpix);
+EXTERN float glist_pixelstoy(t_glist *x, float ypix);
+EXTERN float glist_xtopixels(t_glist *x, float xval);
+EXTERN float glist_ytopixels(t_glist *x, float yval);
+
+EXTERN void glist_redrawitem(t_glist *owner, t_gobj *gobj);
+EXTERN void glist_getnextxy(t_glist *gl, int *xval, int *yval);
+EXTERN void glist_glist(t_glist *g, t_symbol *s, int argc, t_atom *argv);
+EXTERN t_glist *glist_addglist(t_glist *g, t_symbol *sym,
+ float x1, float y1, float x2, float y2,
+ float px1, float py1, float px2, float py2);
+EXTERN void glist_arraydialog(t_glist *parent, t_symbol *name,
+ t_floatarg size, t_floatarg saveit, t_floatarg newgraph);
+EXTERN t_binbuf *glist_writetobinbuf(t_glist *x, int wholething);
+EXTERN void glist_cleanup(t_glist *x);
+EXTERN void glist_free(t_glist *x);
+
+/* -------------------- functions on texts ------------------------- */
+EXTERN void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize);
+EXTERN void text_drawborder(t_text *x, t_glist *glist, char *tag,
+ int width, int height, int firsttime);
+EXTERN void text_eraseborder(t_text *x, t_glist *glist, char *tag);
+
+/* -------------------- functions on rtexts ------------------------- */
+#define RTEXT_DOWN 1
+#define RTEXT_DRAG 2
+#define RTEXT_DBL 3
+#define RTEXT_SHIFT 4
+
+EXTERN t_rtext *rtext_new(t_glist *glist, t_text *who, t_rtext *next);
+EXTERN t_rtext *rtext_remove(t_rtext *first, t_rtext *x);
+EXTERN t_rtext *glist_findrtext(t_glist *gl, t_text *who);
+EXTERN int rtext_height(t_rtext *x);
+EXTERN void rtext_displace(t_rtext *x, int dx, int dy);
+EXTERN void rtext_select(t_rtext *x, int state);
+EXTERN void rtext_activate(t_rtext *x, int state);
+EXTERN void rtext_free(t_rtext *x);
+EXTERN void rtext_key(t_rtext *x, int n, t_symbol *s);
+EXTERN void rtext_mouse(t_rtext *x, int xval, int yval, int flag);
+EXTERN void rtext_retext(t_rtext *x);
+EXTERN int rtext_width(t_rtext *x);
+EXTERN int rtext_height(t_rtext *x);
+EXTERN char *rtext_gettag(t_rtext *x);
+EXTERN void rtext_gettext(t_rtext *x, char **buf, int *bufsize);
+
+/* -------------------- functions on canvases ------------------------ */
+EXTERN t_class *graph_class, *canvas_class;
+
+EXTERN t_canvas *canvas_new(t_symbol *sel, int argc, t_atom *argv);
+EXTERN t_symbol *canvas_makebindsym(t_symbol *s);
+EXTERN void canvas_vistext(t_canvas *x, t_text *y);
+EXTERN void canvas_fixlinesfor(t_canvas *x, t_text *text);
+EXTERN void canvas_deletelinesfor(t_canvas *x, t_text *text);
+EXTERN void canvas_stowconnections(t_canvas *x);
+EXTERN void canvas_restoreconnections(t_canvas *x);
+EXTERN t_template *canvas_gettemplate(t_canvas *x);
+EXTERN t_template *canvas_gettemplatebyname(t_symbol *s);
+EXTERN t_template *gtemplate_get(t_gtemplate *x);
+EXTERN int template_find_field(t_template *x, t_symbol *name, int *p_onset,
+ int *p_type, t_symbol **p_arraytype);
+EXTERN t_float canvas_getfloat(t_canvas *x, t_symbol *fieldname, t_word *wp,
+ int loud);
+EXTERN void canvas_setfloat(t_canvas *x, t_symbol *fieldname, t_word *wp,
+ t_float f, int loud);
+EXTERN t_symbol *canvas_getsymbol(t_canvas *x, t_symbol *fieldname, t_word *wp,
+ int loud);
+EXTERN void canvas_setsymbol(t_canvas *x, t_symbol *fieldname, t_word *wp,
+ t_symbol *s, int loud);
+
+EXTERN t_inlet *canvas_addinlet(t_canvas *x, t_pd *who, t_symbol *sym);
+EXTERN void canvas_rminlet(t_canvas *x, t_inlet *ip);
+EXTERN t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *sym);
+EXTERN void canvas_rmoutlet(t_canvas *x, t_outlet *op);
+EXTERN void canvas_redrawallfortemplate(t_canvas *template);
+EXTERN void canvas_zapallfortemplate(t_canvas *template);
+EXTERN void canvas_setusedastemplate(t_canvas *x);
+EXTERN t_canvas *canvas_getcurrent(void);
+EXTERN void canvas_setcurrent(t_canvas *x);
+EXTERN void canvas_unsetcurrent(t_canvas *x);
+EXTERN t_canvas *canvas_getrootfor(t_canvas *x);
+EXTERN void canvas_dirty(t_canvas *x, t_int n);
+EXTERN int canvas_isvisible(t_canvas *x);
+EXTERN int canvas_getfont(t_canvas *x);
+typedef int (*t_canvasapply)(t_canvas *x, t_int x1, t_int x2, t_int x3);
+
+EXTERN t_int *canvas_recurapply(t_canvas *x, t_canvasapply *fn,
+ t_int x1, t_int x2, t_int x3);
+
+EXTERN void canvas_resortinlets(t_canvas *x);
+EXTERN void canvas_resortoutlets(t_canvas *x);
+EXTERN void canvas_free(t_canvas *x);
+
+/* ---------------------- functions on subcanvases --------------------- */
+
+EXTERN void subcanvas_fattenforscalars(t_subcanvas *x,
+ int *x1, int *y1, int *x2, int *y2);
+EXTERN void subcanvas_visforscalars(t_subcanvas *x, t_glist *glist, int vis);
+EXTERN int subcanvas_click(t_subcanvas *x, int xpix, int ypix, int shift,
+ int alt, int dbl, int doit);
+EXTERN t_glist *canvas_getglistonsuper(void);
+
+/* --------------------- functions on tscalars --------------------- */
+
+EXTERN void tscalar_getrect(t_tscalar *x, t_glist *owner,
+ int *xp1, int *yp1, int *xp2, int *yp2);
+EXTERN void tscalar_vis(t_tscalar *x, t_glist *owner, int flag);
+EXTERN int tscalar_click(t_tscalar *x, int xpix, int ypix, int shift,
+ int alt, int dbl, int doit);
+
+/* --------- functions on garrays (graphical arrays) -------------------- */
+
+EXTERN t_template *garray_template(t_garray *x);
+
+/* -------------------- arrays --------------------- */
+EXTERN t_garray *graph_array(t_glist *gl, t_symbol *s, t_symbol *template,
+ t_floatarg f, t_floatarg saveit);
+EXTERN t_array *array_new(t_symbol *templatesym, t_gpointer *parent);
+EXTERN void array_resize(t_array *x, t_template *template, int n);
+EXTERN void array_free(t_array *x);
+
+/* --------------------- gpointers and stubs ---------------- */
+EXTERN t_gstub *gstub_new(t_glist *gl, t_array *a);
+EXTERN void gstub_cutoff(t_gstub *gs);
+EXTERN void gpointer_setglist(t_gpointer *gp, t_glist *glist, t_scalar *x);
+
+/* --------------------- scalars ------------------------- */
+EXTERN void word_init(t_word *wp, t_template *template, t_gpointer *gp);
+EXTERN void word_restore(t_word *wp, t_template *template,
+ int argc, t_atom *argv);
+EXTERN t_scalar *scalar_new(t_glist *owner,
+ t_symbol *templatesym);
+EXTERN void scalar_getbasexy(t_scalar *x, float *basex, float *basey);
+
+/* --------------------- templates ------------------------- */
+EXTERN t_template *template_new(int argc, t_atom *argv);
+EXTERN void template_free(t_template *x);
+EXTERN int template_match(t_template *x1, t_template *x2);
+
+/* ----------------------- guiconnects, g_guiconnect.c --------- */
+EXTERN t_guiconnect *guiconnect_new(t_pd *who, t_symbol *sym);
+EXTERN void guiconnect_notarget(t_guiconnect *x, double timedelay);
diff --git a/install-sh b/install-sh
new file mode 100644
index 0000000..e9de238
--- /dev/null
+++ b/install-sh
@@ -0,0 +1,251 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch. It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ true
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ chmodcmd=""
+ else
+ instcmd=mkdir
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f $src -o -d $src ]
+ then
+ true
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ true
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ true
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ true
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/kalashnikov.c b/kalashnikov.c
new file mode 100644
index 0000000..f4ee3a1
--- /dev/null
+++ b/kalashnikov.c
@@ -0,0 +1,59 @@
+#include "ext13.h"
+#include "m_pd.h"
+/*#include "g_canvas.h"*/
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+/* -------------------------- kalashnikov ------------------------------ */
+static t_class *kalashnikov_class;
+
+typedef struct _kalashnikov
+{
+ t_object x_obj;
+ t_float x_f;
+ t_outlet *x_out2;
+ t_outlet *x_out3;
+} t_kalashnikov;
+
+static void *kalashnikov_new(t_floatarg f)
+{
+ t_kalashnikov *x = (t_kalashnikov *)pd_new(kalashnikov_class);
+ x->x_f = f;
+ outlet_new(&x->x_obj, &s_bang);
+ x->x_out3 = outlet_new(&x->x_obj, &s_float);
+ x->x_out2 = outlet_new(&x->x_obj, &s_bang);
+ floatinlet_new(&x->x_obj, &x->x_f);
+ return (x);
+}
+
+static void kalashnikov_bang(t_kalashnikov *x)
+{
+ int count;
+ for (count=x->x_f;count>0;count--){
+ outlet_bang(x->x_obj.ob_outlet);
+ outlet_float(x->x_out3, x->x_f-count);
+ }
+ outlet_bang(x->x_out2);
+}
+
+static void kalashnikov_float(t_kalashnikov *x, t_float f)
+{
+ int count;
+ x->x_f=f;
+ for (count=f;count>0;count--){
+ outlet_bang(x->x_obj.ob_outlet);
+ outlet_float(x->x_out3, f-count);
+ }
+ outlet_bang(x->x_out2);
+}
+
+void kalashnikov_setup(void)
+{
+ kalashnikov_class = class_new(gensym("kalashnikov"), (t_newmethod)kalashnikov_new, 0,
+ sizeof(t_kalashnikov), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)kalashnikov_new, gensym("uzi"), A_DEFFLOAT, 0);
+ class_addbang(kalashnikov_class, kalashnikov_bang);
+ class_addfloat(kalashnikov_class, kalashnikov_float);
+}
diff --git a/m_imp.h b/m_imp.h
new file mode 100644
index 0000000..f5be853
--- /dev/null
+++ b/m_imp.h
@@ -0,0 +1,211 @@
+/* Copyright (c) 1997-1999 Miller Puckette.
+* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* This file contains function prototypes and data types used to implement
+Pd, but not shared with Pd objects. */
+
+#include "m_pd.h"
+
+EXTERN_STRUCT _outconnect;
+#define t_outconnect struct _outconnect
+
+/* LATER consider whether to use 'char' for method arg types to save space */
+
+/* the structure for a method handler ala Max */
+typedef struct _methodentry
+{
+ t_symbol *me_name;
+ t_gotfn me_fun;
+ t_atomtype me_arg[MAXPDARG+1];
+} t_methodentry;
+
+EXTERN_STRUCT _widgetbehavior;
+
+typedef void (*t_bangmethod)(t_pd *x);
+typedef void (*t_pointermethod)(t_pd *x, t_gpointer *gp);
+typedef void (*t_floatmethod)(t_pd *x, t_float f);
+typedef void (*t_symbolmethod)(t_pd *x, t_symbol *s);
+typedef void (*t_listmethod)(t_pd *x, t_symbol *s, int argc, t_atom *argv);
+typedef void (*t_anymethod)(t_pd *x, t_symbol *s, int argc, t_atom *argv);
+
+struct _class
+{
+ t_symbol *c_name; /* name (mostly for error reporting) */
+ t_symbol *c_helpname; /* name of help file */
+ size_t c_size; /* size of an instance */
+ t_methodentry *c_methods; /* methods other than bang, etc below */
+ int c_nmethod; /* number of methods */
+ t_method c_freemethod; /* function to call before freeing */
+ t_bangmethod c_bangmethod; /* common methods */
+ t_pointermethod c_pointermethod;
+ t_floatmethod c_floatmethod;
+ t_symbolmethod c_symbolmethod;
+ t_listmethod c_listmethod;
+ t_anymethod c_anymethod;
+ struct _widgetbehavior *c_wb; /* "gobjs" only */
+ struct _parentwidgetbehavior *c_pwb;/* widget behavior in parent */
+ int c_floatsignalin; /* onset to float for signal input */
+ char c_gobj; /* true if is a gobj */
+ char c_patchable; /* true if we have a t_object header */
+ char c_firstin; /* if patchable, true if draw first inlet */
+ char c_drawcommand; /* a drawing command for a template */
+};
+
+/* s_file.c */
+typedef struct _namelist
+{
+ struct _namelist *nl_next;
+ char *nl_string;
+} t_namelist;
+
+t_namelist *namelist_append(t_namelist *listwas, const char *s);
+void namelist_free(t_namelist *listwas);
+
+extern int sys_debuglevel;
+extern int sys_verbose;
+
+#define DEBUG_MESSUP 1 /* messages up from pd to pd-gui */
+#define DEBUG_MESSDOWN 2 /* messages down from pd-gui to pd */
+
+extern int sys_noloadbang;
+extern int sys_nogui;
+extern char *sys_guicmd;
+
+/* in s_main.c */
+EXTERN int sys_nearestfontsize(int fontsize);
+EXTERN int sys_hostfontsize(int fontsize);
+
+extern int sys_defaultfont;
+extern t_symbol *sys_libdir; /* library directory for auxilliary files */
+/* s_loader.c */
+int sys_load_lib(char *dirname, char *filename);
+
+/* s_unix.c */
+EXTERN void sys_microsleep(int microsec);
+EXTERN double sys_getrealtime(void);
+
+/* s_sgi.c, s_nt.c, s_linux.c each implement the same API for audio
+and MIDI I/O as follows: */
+
+#define DACBLKSIZE 64
+
+#define SENDDACS_NO 0 /* return values for sys_send_dacs() */
+#define SENDDACS_YES 1
+#define SENDDACS_SLEPT 2
+
+ /* MIDI input and output */
+#define MAXMIDIINDEV 16 /* max. number of input ports */
+#define MAXMIDIOUTDEV 16 /* max. number of output ports */
+extern int sys_nmidiin;
+extern int sys_nmidiout;
+extern int sys_midiindevlist[];
+extern int sys_midioutdevlist[];
+
+EXTERN void sys_putmidimess(int portno, int a, int b, int c);
+EXTERN void sys_putmidibyte(int portno, int a);
+EXTERN void sys_poll_midi(void);
+EXTERN void sys_setmiditimediff(double inbuftime, double outbuftime);
+EXTERN void sys_midibytein(int portno, int byte);
+
+extern int sys_hipriority; /* real-time flag, true if priority boosted */
+extern t_sample *sys_soundout;
+extern t_sample *sys_soundin;
+extern float sys_dacsr;
+extern int sys_schedadvance;
+extern int sys_sleepgrain;
+EXTERN void sys_open_audio(int inchans, int outchans, int rate);
+EXTERN void sys_close_audio(void);
+
+EXTERN void sys_open_midi(int nmidiin, int *midiinvec,
+ int nmidiout, int *midioutvec);
+EXTERN void sys_close_midi(void);
+
+EXTERN int sys_send_dacs(void);
+EXTERN void sys_reportidle(void);
+EXTERN void sys_set_priority(int higher);
+EXTERN void sys_audiobuf(int nbufs);
+EXTERN void sys_getmeters(float *inmax, float *outmax);
+
+ /* for NT and Linux, there are additional bits of fluff as follows. */
+#ifdef NT
+EXTERN void nt_listdevs(void);
+EXTERN void nt_soundindev(int which);
+EXTERN void nt_soundoutdev(int which);
+EXTERN void nt_midiindev(int which);
+EXTERN void nt_midioutdev(int which);
+EXTERN void nt_noresync( void);
+#endif
+
+#define API_OSS 0
+#define API_ALSA 1
+#define API_RME 2
+#define API_PORTAUDIO 4
+#ifdef __linux__
+ /* the following definitions allow you to switch at run time
+ between audio APIs in Linux and later in NT. */
+void linux_set_sound_api(int which);
+
+void linux_setfrags(int n);
+void linux_setfragsize(int n);
+void linux_streammode( void);
+void rme_soundindev(int which);
+void rme_soundoutdev(int which);
+void linux_alsa_queue_size(int size);
+#ifdef ALSA99 /* old fashioned ALSA */
+void linux_alsa_devno(int devno);
+#else
+void linux_alsa_devname(char *devname);
+#endif
+#endif /* __linux__ */
+
+/* m_sched.c */
+EXTERN void sys_log_error(int type);
+#define ERR_NOTHING 0
+#define ERR_ADCSLEPT 1
+#define ERR_DACSLEPT 2
+#define ERR_RESYNC 3
+#define ERR_DATALATE 4
+
+/* s_inter.c */
+
+EXTERN void sys_bail(int exitcode);
+EXTERN int sys_pollgui(void);
+
+EXTERN_STRUCT _socketreceiver;
+#define t_socketreceiver struct _socketreceiver
+
+typedef void (*t_socketnotifier)(void *x);
+typedef void (*t_socketreceivefn)(void *x, t_binbuf *b);
+
+EXTERN t_socketreceiver *socketreceiver_new(void *owner,
+ t_socketnotifier notifier, t_socketreceivefn socketreceivefn);
+EXTERN void socketreceiver_read(t_socketreceiver *x, int fd);
+EXTERN void sys_sockerror(char *s);
+EXTERN void sys_closesocket(int fd);
+
+typedef void (*t_fdpollfn)(void *ptr, int fd);
+EXTERN void sys_addpollfn(int fd, t_fdpollfn fn, void *ptr);
+EXTERN void sys_rmpollfn(int fd);
+#ifdef UNIX
+void sys_setalarm(int microsec);
+void sys_setvirtualalarm( void);
+#endif
+
+/* m_obj.c */
+EXTERN t_object *pd_checkobject(t_pd *x);
+
+EXTERN int obj_noutlets(t_object *x);
+EXTERN int obj_ninlets(t_object *x);
+EXTERN t_outconnect *obj_starttraverseoutlet(t_object *x, t_outlet **op,
+ int nout);
+EXTERN t_outconnect *obj_nexttraverseoutlet(t_outconnect *lastconnect,
+ t_object **destp, t_inlet **inletp, int *whichp);
+EXTERN t_outconnect *obj_connect(t_object *source, int outno,
+ t_object *sink, int inno);
+EXTERN void obj_disconnect(t_object *source, int outno, t_object *sink,
+ int inno);
+EXTERN void outlet_setstacklim(void);
+/* misc */
+EXTERN void glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir);
+EXTERN void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv);
diff --git a/m_pd.h b/m_pd.h
new file mode 100644
index 0000000..aa0a7e1
--- /dev/null
+++ b/m_pd.h
@@ -0,0 +1,546 @@
+/* Copyright (c) 1997-1999 Miller Puckette.
+* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
+extern "C" {
+#endif
+
+#ifdef NT
+// #pragma warning( disable : 4091 )
+#pragma warning( disable : 4305 ) /* uncast const double to float */
+#pragma warning( disable : 4244 ) /* uncast float/int conversion etc. */
+#pragma warning( disable : 4101 ) /* unused automatic variables */
+#endif /* NT */
+
+ /* the external storage class is "extern" in UNIX; in NT it's ugly. */
+#ifdef NT
+#ifdef PD_INTERNAL
+#define EXTERN __declspec(dllexport) extern
+#else
+#define EXTERN __declspec(dllimport) extern
+#endif /* PD_INTERNAL */
+#else
+#define EXTERN extern
+#endif /* NT */
+
+ /* and depending on the compiler, hidden data structures are
+ declared differently: */
+#ifdef __GNUC__
+#define EXTERN_STRUCT struct
+#else
+#define EXTERN_STRUCT extern struct
+#endif
+
+
+#if !defined(_SIZE_T) && !defined(_SIZE_T_)
+#include <stddef.h> /* just for size_t -- how lame! */
+#endif
+
+#define MAXPDSTRING 1000 /* use this for anything you want */
+#define MAXPDARG 5 /* max number of args we can typecheck today */
+
+ /* signed and unsigned integer types the size of a pointer: */
+#ifdef __alpha__
+typedef long t_int;
+#else
+typedef int t_int;
+#endif
+
+typedef float t_float; /* a floating-point number at most the same size */
+typedef float t_floatarg; /* floating-point type for function calls */
+
+typedef struct _symbol
+{
+ char *s_name;
+ struct _class **s_thing;
+ struct _symbol *s_next;
+} t_symbol;
+
+EXTERN_STRUCT _array;
+#define t_array struct _array /* g_canvas.h */
+
+/* pointers to glist and array elements go through a "stub" which sticks
+around after the glist or array is freed. The stub itself is deleted when
+both the glist/array is gone and the refcount is zero, ensuring that no
+gpointers are pointing here. */
+
+#define GP_NONE 0 /* the stub points nowhere (has been cut off) */
+#define GP_GLIST 1 /* the stub points to a glist element */
+#define GP_ARRAY 2 /* ... or array */
+
+typedef struct _gstub
+{
+ union
+ {
+ struct _glist *gs_glist; /* glist we're in */
+ struct _array *gs_array; /* array we're in */
+ } gs_un;
+ int gs_which; /* GP_GLIST/GP_ARRAY */
+ int gs_refcount; /* number of gpointers pointing here */
+} t_gstub;
+
+typedef struct _gpointer /* pointer to a gobj in a glist */
+{
+ union
+ {
+ struct _scalar *gp_scalar; /* scalar we're in (if glist) */
+ union word *gp_w; /* raw data (if array) */
+ } gp_un;
+ int gp_valid; /* number which must match gpointee */
+ t_gstub *gp_stub; /* stub which points to glist/array */
+} t_gpointer;
+
+typedef union word
+{
+ t_float w_float;
+ t_symbol *w_symbol;
+ t_gpointer *w_gpointer;
+ t_array *w_array;
+ struct _canvas *w_list;
+ int w_index;
+} t_word;
+
+typedef enum
+{
+ A_NULL,
+ A_FLOAT,
+ A_SYMBOL,
+ A_POINTER,
+ A_SEMI,
+ A_COMMA,
+ A_DEFFLOAT,
+ A_DEFSYM,
+ A_DOLLAR,
+ A_DOLLSYM,
+ A_GIMME,
+ A_CANT
+} t_atomtype;
+
+#define A_DEFSYMBOL A_DEFSYM /* better name for this */
+
+typedef struct _atom
+{
+ t_atomtype a_type;
+ union word a_w;
+} t_atom;
+
+EXTERN_STRUCT _class;
+#define t_class struct _class
+
+EXTERN_STRUCT _outlet;
+#define t_outlet struct _outlet
+
+EXTERN_STRUCT _inlet;
+#define t_inlet struct _inlet
+
+EXTERN_STRUCT _binbuf;
+#define t_binbuf struct _binbuf
+
+EXTERN_STRUCT _clock;
+#define t_clock struct _clock
+
+EXTERN_STRUCT _canvas;
+#define t_canvas struct _canvas
+
+typedef t_class *t_pd; /* pure datum: nothing but a class pointer */
+
+typedef struct _gobj /* a graphical object */
+{
+ t_pd g_pd;
+ struct _gobj *g_next;
+} t_gobj;
+
+typedef struct _scalar /* a graphical object holding data */
+{
+ t_gobj x_gobj;
+ t_symbol *x_template;
+ t_word x_vec[1];
+} t_scalar;
+
+typedef struct _text /* a graphical object with at least one textfield */
+{
+ t_gobj te_g;
+ t_binbuf *te_binbuf;
+ t_outlet *te_outlet;
+ t_inlet *te_inlet;
+ short te_xpos;
+ short te_ypos;
+ short te_width; /* requested width in chars, 0 if auto */
+ unsigned int te_type:2; /* from defs below */
+} t_text;
+
+#define T_TEXT 0 /* just a textual comment */
+#define T_OBJECT 1 /* a MAX style patchable object */
+#define T_MESSAGE 2 /* a MAX stype message */
+#define T_ATOM 3 /* a cell to display a number or symbol */
+
+#define te_pd te_g.g_pd
+
+ /* patchable objects ala Max. At the moment, this is no different from any
+ "text-bearing" object; later we might want text objects without
+ inlets/outlets; it's not clear yet how to do that. */
+
+typedef struct _text t_object;
+
+#define ob_outlet te_outlet
+#define ob_inlet te_inlet
+#define ob_binbuf te_binbuf
+#define ob_pd te_g.g_pd
+#define ob_g te_g
+
+typedef void (*t_method)(void);
+typedef void *(*t_newmethod)( void);
+typedef void (*t_gotfn)(void *x, ...);
+
+/* ---------------- pre-defined symbols --------------*/
+EXTERN t_symbol s_pointer;
+EXTERN t_symbol s_float;
+EXTERN t_symbol s_symbol;
+EXTERN t_symbol s_bang;
+EXTERN t_symbol s_list;
+EXTERN t_symbol s_anything;
+EXTERN t_symbol s_signal;
+EXTERN t_symbol s__N;
+EXTERN t_symbol s__X;
+EXTERN t_symbol s_x;
+EXTERN t_symbol s_y;
+EXTERN t_symbol s_;
+
+/* --------- prototypes from the central message system ----------- */
+EXTERN void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv);
+EXTERN void pd_forwardmess(t_pd *x, int argc, t_atom *argv);
+EXTERN t_symbol *gensym(char *s);
+EXTERN t_gotfn getfn(t_pd *x, t_symbol *s);
+EXTERN t_gotfn zgetfn(t_pd *x, t_symbol *s);
+EXTERN void nullfn(void);
+EXTERN void pd_vmess(t_pd *x, t_symbol *s, char *fmt, ...);
+#define mess0(x, s) ((*getfn((x), (s)))((x)))
+#define mess1(x, s, a) ((*getfn((x), (s)))((x), (a)))
+#define mess2(x, s, a,b) ((*getfn((x), (s)))((x), (a),(b)))
+#define mess3(x, s, a,b,c) ((*getfn((x), (s)))((x), (a),(b),(c)))
+#define mess4(x, s, a,b,c,d) ((*getfn((x), (s)))((x), (a),(b),(c),(d)))
+#define mess5(x, s, a,b,c,d,e) ((*getfn((x), (s)))((x), (a),(b),(c),(d),(e)))
+void obj_list(t_object *x, t_symbol *s, int argc, t_atom *argv);
+
+/* --------------- memory management -------------------- */
+EXTERN void *getbytes(size_t nbytes);
+EXTERN void *getzbytes(size_t nbytes);
+EXTERN void *copybytes(void *src, size_t nbytes);
+EXTERN void freebytes(void *x, size_t nbytes);
+EXTERN void *resizebytes(void *x, size_t oldsize, size_t newsize);
+
+/* -------------------- atoms ----------------------------- */
+
+#define SETSEMI(atom) ((atom)->a_type = A_SEMI, (atom)->a_w.w_index = 0)
+#define SETCOMMA(atom) ((atom)->a_type = A_COMMA, (atom)->a_w.w_index = 0)
+#define SETPOINTER(atom, gp) ((atom)->a_type = A_POINTER, \
+ (atom)->a_w.w_gpointer = (gp))
+#define SETFLOAT(atom, f) ((atom)->a_type = A_FLOAT, (atom)->a_w.w_float = (f))
+#define SETSYMBOL(atom, s) ((atom)->a_type = A_SYMBOL, \
+ (atom)->a_w.w_symbol = (s))
+#define SETDOLLAR(atom, n) ((atom)->a_type = A_DOLLAR, \
+ (atom)->a_w.w_index = (n))
+#define SETDOLLSYM(atom, s) ((atom)->a_type = A_DOLLSYM, \
+ (atom)->a_w.w_symbol= (s))
+
+EXTERN t_float atom_getfloat(t_atom *a);
+EXTERN t_int atom_getint(t_atom *a);
+EXTERN t_symbol *atom_getsymbol(t_atom *a);
+EXTERN t_symbol *atom_gensym(t_atom *a);
+EXTERN t_float atom_getfloatarg(int which, int argc, t_atom *argv);
+EXTERN t_int atom_getintarg(int which, int argc, t_atom *argv);
+EXTERN t_symbol *atom_getsymbolarg(int which, int argc, t_atom *argv);
+
+EXTERN void atom_string(t_atom *a, char *buf, unsigned int bufsize);
+
+/* ------------------ binbufs --------------- */
+
+EXTERN t_binbuf *binbuf_new(void);
+EXTERN void binbuf_free(t_binbuf *x);
+
+EXTERN void binbuf_text(t_binbuf *x, char *text, size_t size);
+EXTERN void binbuf_gettext(t_binbuf *x, char **bufp, int *lengthp);
+EXTERN void binbuf_clear(t_binbuf *x);
+EXTERN void binbuf_add(t_binbuf *x, int argc, t_atom *argv);
+EXTERN void binbuf_addv(t_binbuf *x, char *fmt, ...);
+EXTERN void binbuf_addbinbuf(t_binbuf *x, t_binbuf *y);
+EXTERN void binbuf_addsemi(t_binbuf *x);
+EXTERN void binbuf_restore(t_binbuf *x, int argc, t_atom *argv);
+EXTERN void binbuf_print(t_binbuf *x);
+EXTERN int binbuf_getnatom(t_binbuf *x);
+EXTERN t_atom *binbuf_getvec(t_binbuf *x);
+EXTERN void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv);
+EXTERN int binbuf_read(t_binbuf *b, char *filename, char *dirname,
+ int crflag);
+EXTERN int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname,
+ int crflag);
+EXTERN int binbuf_write(t_binbuf *x, char *filename, char *dir,
+ int crflag);
+EXTERN void binbuf_evalfile(t_symbol *name, t_symbol *dir);
+
+/* ------------------ clocks --------------- */
+
+EXTERN t_clock *clock_new(void *owner, t_method fn);
+EXTERN void clock_set(t_clock *x, double systime);
+EXTERN void clock_delay(t_clock *x, double delaytime);
+EXTERN void clock_unset(t_clock *x);
+EXTERN double clock_getlogicaltime(void);
+EXTERN double clock_getsystime(void); /* OBSOLETE; use clock_getlogicaltime() */
+EXTERN double clock_gettimesince(double prevsystime);
+EXTERN double clock_getsystimeafter(double delaytime);
+EXTERN void clock_free(t_clock *x);
+
+/* ----------------- pure data ---------------- */
+EXTERN t_pd *pd_new(t_class *cls);
+EXTERN void pd_free(t_pd *x);
+EXTERN void pd_bind(t_pd *x, t_symbol *s);
+EXTERN void pd_unbind(t_pd *x, t_symbol *s);
+EXTERN t_pd *pd_findbyclass(t_symbol *s, t_class *c);
+EXTERN void pd_pushsym(t_pd *x);
+EXTERN void pd_popsym(t_pd *x);
+EXTERN t_symbol *pd_getfilename(void);
+EXTERN t_symbol *pd_getdirname(void);
+EXTERN void pd_bang(t_pd *x);
+EXTERN void pd_pointer(t_pd *x, t_gpointer *gp);
+EXTERN void pd_float(t_pd *x, t_float f);
+EXTERN void pd_symbol(t_pd *x, t_symbol *s);
+EXTERN void pd_list(t_pd *x, t_symbol *s, int argc, t_atom *argv);
+EXTERN void pd_anything(t_pd *x, t_symbol *s, int argc, t_atom *argv);
+#define pd_class(x) (*(x))
+
+/* ----------------- pointers ---------------- */
+EXTERN void gpointer_init(t_gpointer *gp);
+EXTERN void gpointer_copy(const t_gpointer *gpfrom, t_gpointer *gpto);
+EXTERN void gpointer_unset(t_gpointer *gp);
+EXTERN int gpointer_check(const t_gpointer *gp, int headok);
+
+/* ----------------- patchable "objects" -------------- */
+EXTERN_STRUCT _inlet;
+#define t_inlet struct _inlet
+EXTERN_STRUCT _outlet;
+#define t_outlet struct _outlet
+
+EXTERN t_inlet *inlet_new(t_object *owner, t_pd *dest, t_symbol *s1,
+ t_symbol *s2);
+EXTERN t_inlet *pointerinlet_new(t_object *owner, t_gpointer *gp);
+EXTERN t_inlet *floatinlet_new(t_object *owner, t_float *fp);
+EXTERN t_inlet *symbolinlet_new(t_object *owner, t_symbol **sp);
+EXTERN void inlet_free(t_inlet *x);
+
+EXTERN t_outlet *outlet_new(t_object *owner, t_symbol *s);
+EXTERN void outlet_bang(t_outlet *x);
+EXTERN void outlet_pointer(t_outlet *x, t_gpointer *gp);
+EXTERN void outlet_float(t_outlet *x, t_float f);
+EXTERN void outlet_symbol(t_outlet *x, t_symbol *s);
+EXTERN void outlet_list(t_outlet *x, t_symbol *s, int argc, t_atom *argv);
+EXTERN void outlet_anything(t_outlet *x, t_symbol *s, int argc, t_atom *argv);
+EXTERN void outlet_free(t_outlet *x);
+
+/* -------------------- canvases -------------- */
+
+EXTERN void glob_setfilename(void *dummy, t_symbol *name, t_symbol *dir);
+
+EXTERN void canvas_setargs(int argc, t_atom *argv);
+EXTERN t_atom *canvas_getarg(int which);
+EXTERN t_symbol *canvas_getcurrentdir(void);
+EXTERN t_canvas *canvas_getcurrent(void);
+EXTERN void canvas_makefilename(t_canvas *c, char *file,
+ char *result,int resultsize);
+EXTERN t_symbol *canvas_getdir(t_canvas *x);
+EXTERN int sys_fontwidth(int fontsize);
+EXTERN int sys_fontheight(int fontsize);
+EXTERN void canvas_dataproperties(t_canvas *x, t_scalar *sc, t_binbuf *b);
+
+/* ---------------- widget behaviors ---------------------- */
+
+EXTERN_STRUCT _widgetbehavior;
+#define t_widgetbehavior struct _widgetbehavior
+
+EXTERN_STRUCT _parentwidgetbehavior;
+#define t_parentwidgetbehavior struct _parentwidgetbehavior
+EXTERN t_parentwidgetbehavior *pd_getparentwidget(t_pd *x);
+
+/* -------------------- classes -------------- */
+
+#define CLASS_DEFAULT 0 /* flags for new classes below */
+#define CLASS_PD 1
+#define CLASS_GOBJ 2
+#define CLASS_PATCHABLE 3
+#define CLASS_NOINLET 8
+
+#define CLASS_TYPEMASK 3
+
+
+EXTERN t_class *class_new(t_symbol *name, t_newmethod newmethod,
+ t_method freemethod, size_t size, int flags, t_atomtype arg1, ...);
+EXTERN void class_addcreator(t_newmethod newmethod, t_symbol *s,
+ t_atomtype type1, ...);
+EXTERN void class_addmethod(t_class *c, t_method fn, t_symbol *sel,
+ t_atomtype arg1, ...);
+EXTERN void class_addbang(t_class *c, t_method fn);
+EXTERN void class_addpointer(t_class *c, t_method fn);
+EXTERN void class_doaddfloat(t_class *c, t_method fn);
+EXTERN void class_addsymbol(t_class *c, t_method fn);
+EXTERN void class_addlist(t_class *c, t_method fn);
+EXTERN void class_addanything(t_class *c, t_method fn);
+EXTERN void class_sethelpsymbol(t_class *c, t_symbol *s);
+EXTERN void class_setwidget(t_class *c, t_widgetbehavior *w);
+EXTERN void class_setparentwidget(t_class *c, t_parentwidgetbehavior *w);
+EXTERN t_parentwidgetbehavior *class_parentwidget(t_class *c);
+EXTERN char *class_getname(t_class *c);
+EXTERN char *class_gethelpname(t_class *c);
+EXTERN void class_setdrawcommand(t_class *c);
+EXTERN int class_isdrawcommand(t_class *c);
+EXTERN void class_domainsignalin(t_class *c, int onset);
+#define CLASS_MAINSIGNALIN(c, type, field) \
+ class_domainsignalin(c, (char *)(&((type *)0)->field) - (char *)0)
+
+#ifndef PD_CLASS_DEF
+#define class_addbang(x, y) class_addbang((x), (t_method)(y))
+#define class_addpointer(x, y) class_addpointer((x), (t_method)(y))
+#define class_addfloat(x, y) class_doaddfloat((x), (t_method)(y))
+#define class_addsymbol(x, y) class_addsymbol((x), (t_method)(y))
+#define class_addlist(x, y) class_addlist((x), (t_method)(y))
+#define class_addanything(x, y) class_addanything((x), (t_method)(y))
+#endif
+
+/* ------------ printing --------------------------------- */
+EXTERN void post(char *fmt, ...);
+EXTERN void startpost(char *fmt, ...);
+EXTERN void poststring(char *s);
+EXTERN void postfloat(float f);
+EXTERN void postatom(int argc, t_atom *argv);
+EXTERN void endpost(void);
+EXTERN void error(char *fmt, ...);
+EXTERN void bug(char *fmt, ...);
+EXTERN void pd_error(void *object, char *fmt, ...);
+EXTERN void sys_logerror(char *object, char *s);
+EXTERN void sys_unixerror(char *object);
+EXTERN void sys_ouch(void);
+
+#ifdef __linux__
+EXTERN char* sys_get_path( void);
+#endif
+EXTERN void sys_addpath(const char* p);
+
+
+/* ------------ system interface routines ------------------- */
+EXTERN int sys_isreadablefile(const char *name);
+EXTERN void sys_bashfilename(const char *from, char *to);
+EXTERN void sys_unbashfilename(const char *from, char *to);
+EXTERN int open_via_path(const char *name, const char *ext, const char *dir,
+ char *dirresult, char **nameresult, unsigned int size, int bin);
+
+/* --------------- signals ----------------------------------- */
+
+typedef float t_sample;
+#define MAXLOGSIG 16
+#define MAXSIGSIZE (1 << MAXLOGSIG)
+
+typedef struct _signal
+{
+ int s_n; /* number of points in the array */
+ t_sample *s_vec; /* the array */
+ float s_sr; /* sample rate */
+ int s_refcount; /* number of times used */
+ int s_isborrowed; /* whether we're going to borrow our array */
+ struct _signal *s_borrowedfrom; /* signal to borrow it from */
+ struct _signal *s_nextfree; /* next in freelist */
+ struct _signal *s_nextused; /* next in used list */
+} t_signal;
+
+
+typedef t_int *(*t_perfroutine)(t_int *args);
+
+EXTERN t_int *plus_perform(t_int *args);
+EXTERN t_int *zero_perform(t_int *args);
+EXTERN t_int *copy_perform(t_int *args);
+
+EXTERN void dsp_add_plus(t_sample *in1, t_sample *in2, t_sample *out, int n);
+EXTERN void dsp_add_copy(t_sample *in, t_sample *out, int n);
+EXTERN void dsp_add_scalarcopy(t_sample *in, t_sample *out, int n);
+EXTERN void dsp_add_zero(t_sample *out, int n);
+
+EXTERN int sys_getblksize(void);
+EXTERN float sys_getsr(void);
+EXTERN int sys_get_inchannels(void);
+EXTERN int sys_get_outchannels(void);
+
+EXTERN void dsp_add(t_perfroutine f, int n, ...);
+EXTERN void dsp_addv(t_perfroutine f, int n, t_int *vec);
+EXTERN void pd_fft(float *buf, int npoints, int inverse);
+EXTERN int ilog2(int n);
+
+EXTERN void mayer_fht(float *fz, int n);
+EXTERN void mayer_fft(int n, float *real, float *imag);
+EXTERN void mayer_ifft(int n, float *real, float *imag);
+EXTERN void mayer_realfft(int n, float *real);
+EXTERN void mayer_realifft(int n, float *real);
+
+EXTERN float *cos_table;
+#define LOGCOSTABSIZE 9
+#define COSTABSIZE (1<<LOGCOSTABSIZE)
+
+EXTERN int canvas_suspend_dsp(void);
+EXTERN void canvas_resume_dsp(int oldstate);
+EXTERN void canvas_update_dsp(void);
+
+/* ----------------------- utility functions for signals -------------- */
+EXTERN float mtof(float);
+EXTERN float ftom(float);
+EXTERN float rmstodb(float);
+EXTERN float powtodb(float);
+EXTERN float dbtorms(float);
+EXTERN float dbtopow(float);
+
+EXTERN float q8_sqrt(float);
+EXTERN float q8_rsqrt(float);
+#ifndef N32
+EXTERN float qsqrt(float); /* old names kept for extern compatibility */
+EXTERN float qrsqrt(float);
+#endif
+/* --------------------- data --------------------------------- */
+
+ /* graphical arrays */
+EXTERN_STRUCT _garray;
+#define t_garray struct _garray
+
+EXTERN t_class *garray_class;
+EXTERN int garray_getfloatarray(t_garray *x, int *size, t_float **vec);
+EXTERN float garray_get(t_garray *x, t_symbol *s, t_int indx);
+EXTERN void garray_redraw(t_garray *x);
+EXTERN int garray_npoints(t_garray *x);
+EXTERN char *garray_vec(t_garray *x);
+EXTERN void garray_resize(t_garray *x, t_floatarg f);
+EXTERN void garray_usedindsp(t_garray *x);
+EXTERN void garray_setsaveit(t_garray *x, int saveit);
+EXTERN t_class *scalar_class;
+
+/* ------- GUI interface - functions to send strings to TK --------- */
+EXTERN void sys_vgui(char *fmt, ...);
+EXTERN void sys_gui(char *s);
+
+EXTERN void gfxstub_new(t_pd *owner, void *key, const char *cmd);
+EXTERN void gfxstub_deleteforkey(void *key);
+
+/*------------- Max 0.26 compatibility --------------------*/
+
+/* the following reflects the new way classes are laid out, with the class
+ pointing to the messlist and not vice versa. Externs shouldn't feel it. */
+typedef t_class *t_externclass;
+
+EXTERN void c_extern(t_externclass *cls, t_newmethod newroutine,
+ t_method freeroutine, t_symbol *name, size_t size, int tiny, \
+ t_atomtype arg1, ...);
+EXTERN void c_addmess(t_method fn, t_symbol *sel, t_atomtype arg1, ...);
+
+#define t_getbytes getbytes
+#define t_freebytes freebytes
+#define t_resizebytes resizebytes
+#define typedmess pd_typedmess
+#define vmess pd_vmess
+
+#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
+}
+#endif
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..4f9d4b7
--- /dev/null
+++ b/makefile
@@ -0,0 +1,61 @@
+
+EXT = pd_linux
+DEFS = -DHAVE_LIBC=1 -DHAVE_LIBM=1 -DHAVE_LIBPTHREAD=1 -DSTDC_HEADERS=1 -DHAVE_FCNTL_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_UNISTD_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_UNISTD_H=1 -DHAVE_GETPAGESIZE=1 -DHAVE_MMAP=1 -DHAVE_SELECT=1 -DHAVE_SOCKET=1 -DHAVE_STRERROR=1 -DPD_VERSION_MINOR=32
+CC = gcc
+CXX = c++
+LD = ld
+AFLAGS =
+LFLAGS = -export_dynamic -shared
+WFLAGS =
+IFLAGS = -I./include
+PREFIX=/usr/local
+INSTALL_PREFIX=$(PREFIX)
+
+VERSION = \"$(shell cat VERSION)\"
+TARNAME = ext13.$(shell cat VERSION).tar.gz
+
+.SUFFIXES: .$(EXT)
+
+PDCFLAGS = -g -O2 $(DEFS) $(IFLAGS) $(WFLAGS) $(LFLAGS) $(AFLAGS) -DVERSION=$(VERSION)
+CFLAGS = -g -O2 $(DEFS) $(IFLAGS) $(WFLAGS) -DVERSION=$(VERSION)
+CXXFLAGS = $(CFLAGS)
+
+#LIBS = -lc -lm
+LIBS = -lpthread -lm -lc
+SOURCES = ftos.c kalashnikov.c openpatch.c sfread.c streamin13~.c strippath.c send13~.c receive13~.c catch13~.c throw13~.c filesize.c messages.c pipewrite~.c piperead~.c streamout13~.c wavinfo.c mandelbrot.c mandelbrot~.c scramble~.c promiscous~.c ossmixer.c send13.c receive13.c cdplayer.c
+TARGETS = $(SOURCES:.c=.$(EXT))
+
+all: $(TARGETS)
+
+ext13: $(TARGETS)
+ cc -c $(CFLAGS) -DPD ext13.c
+ $(LD) -export_dynamic -shared -o ext13.pd_linux *.o $(LIBS)
+ strip --strip-unneeded ext13.pd_linux
+
+clean::
+ -rm *.$(EXT) *.o
+
+distclean: clean
+ -rm config.cache config.log config.status makefile
+
+
+
+.c.o:
+ $(CC) -c -o $@ $(CFLAGS) -DPD $*.c
+
+# cp $@ $*_stat.o
+
+.o.pd_linux:
+ $(CC) -o $@ $(PDCFLAGS) -DPD $*.o
+
+
+
+install::
+ install -d $(INSTALL_PREFIX)/pd/externs
+ install -m 644 *.$(EXT) $(INSTALL_PREFIX)/pd/externs
+ -install -m 644 ext13.pd_linux $(INSTALL_PREFIX)/pd/externs
+ install -m 644 doc/*.pd $(INSTALL_PREFIX)/pd/doc/5.reference
+
+
+dist: distclean
+ (cd ..;tar czvf $(TARNAME) ext13)
diff --git a/makefile.in b/makefile.in
new file mode 100644
index 0000000..82d10c0
--- /dev/null
+++ b/makefile.in
@@ -0,0 +1,61 @@
+
+EXT = pd_linux
+DEFS = -DHAVE_LIBC=1 -DHAVE_LIBM=1 -DHAVE_LIBPTHREAD=1 -DSTDC_HEADERS=1 -DHAVE_FCNTL_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_UNISTD_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_UNISTD_H=1 -DHAVE_GETPAGESIZE=1 -DHAVE_MMAP=1 -DHAVE_SELECT=1 -DHAVE_SOCKET=1 -DHAVE_STRERROR=1 -DPD_VERSION_MINOR=32
+CC = gcc
+CXX = c++
+LD = ld
+AFLAGS =
+LFLAGS = -export_dynamic -shared
+WFLAGS =
+IFLAGS = -I./include
+PREFIX=@prefix@
+INSTALL_PREFIX=$(PREFIX)
+
+VERSION = \"$(shell cat VERSION)\"
+TARNAME = ext13.$(shell cat VERSION).tar.gz
+
+.SUFFIXES: .$(EXT)
+
+PDCFLAGS = -g -O2 $(DEFS) $(IFLAGS) $(WFLAGS) $(LFLAGS) $(AFLAGS) -DVERSION=$(VERSION)
+CFLAGS = -g -O2 $(DEFS) $(IFLAGS) $(WFLAGS) -DVERSION=$(VERSION)
+CXXFLAGS = $(CFLAGS)
+
+#LIBS = -lc -lm
+LIBS = -lpthread -lm -lc
+SOURCES = ftos.c kalashnikov.c openpatch.c sfread.c streamin13~.c strippath.c send13~.c receive13~.c catch13~.c throw13~.c filesize.c messages.c pipewrite~.c piperead~.c streamout13~.c wavinfo.c mandelbrot.c mandelbrot~.c scramble~.c promiscous~.c ossmixer.c send13.c receive13.c cdplayer.c
+TARGETS = $(SOURCES:.c=.$(EXT))
+
+all: $(TARGETS)
+
+ext13: $(TARGETS)
+ cc -c $(CFLAGS) -DPD ext13.c
+ $(LD) -export_dynamic -shared -o ext13.pd_linux *.o $(LIBS)
+ strip --strip-unneeded ext13.pd_linux
+
+clean::
+ -rm *.$(EXT) *.o
+
+distclean: clean
+ -rm config.cache config.log config.status makefile
+
+
+
+.c.o:
+ $(CC) -c -o $@ $(CFLAGS) -DPD $*.c
+
+# cp $@ $*_stat.o
+
+.o.pd_linux:
+ $(CC) -o $@ $(PDCFLAGS) -DPD $*.o
+
+
+
+install::
+ install -d $(INSTALL_PREFIX)/pd/externs
+ install -m 644 *.$(EXT) $(INSTALL_PREFIX)/pd/externs
+ -install -m 644 ext13.pd_linux $(INSTALL_PREFIX)/pd/externs
+ install -m 644 doc/*.pd $(INSTALL_PREFIX)/pd/doc/5.reference
+
+
+dist: distclean
+ (cd ..;tar czvf $(TARNAME) ext13)
diff --git a/mandelbrot.c b/mandelbrot.c
new file mode 100644
index 0000000..0b301cc
--- /dev/null
+++ b/mandelbrot.c
@@ -0,0 +1,75 @@
+#include "ext13.h"
+#include "m_pd.h"
+#include <sys/stat.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+/* -------------------------- mandelbrot ------------------------------ */
+static t_class *mandelbrot_class;
+
+typedef struct _mandelbrot
+{
+ t_object x_obj;
+ t_float cr;
+ t_float ci;
+ t_float k;
+ t_float result;
+} t_mandelbrot;
+
+
+static void *mandelbrot_new(t_floatarg f)
+{
+ t_mandelbrot *x = (t_mandelbrot *)pd_new(mandelbrot_class);
+ x->k=f;
+ if (! x->k) {x->k=100;}
+ floatinlet_new(&x->x_obj, &x->ci);
+ floatinlet_new(&x->x_obj, &x->k);
+ outlet_new(&x->x_obj,0);
+ return (x);
+}
+
+
+
+static void mandelbrot_bang(t_mandelbrot *x)
+{
+ outlet_float(x->x_obj.ob_outlet,x->result);
+}
+
+static void mandelbrot_float(t_mandelbrot *x, t_float f)
+{
+ int i = -2;
+ t_float zr = 0;
+ t_float zi = 0;
+ t_float z2r = 0;
+ t_float z2i = 0;
+ x->cr = f;
+ if ((x->cr < 0 ) && ( x->cr > -0.5) && (x->ci * x->ci < 0.25)){
+ x->result = x->k;
+ }else{
+ while (((z2r + z2i) < 4 ) && (++i < x->k )) {
+ z2r = zr * zr;
+ z2i = zi * zi;
+ zi = 2 * zr * zi + x->ci;
+ zr = z2r - z2i + x->cr;
+ }
+ x->result = i;
+ }
+ outlet_float(x->x_obj.ob_outlet,x->result);
+}
+
+
+
+void mandelbrot_setup(void)
+{
+ mandelbrot_class = class_new(gensym("mandelbrot"), (t_newmethod)mandelbrot_new, 0,
+ sizeof(t_mandelbrot), 0, A_DEFFLOAT, 0);
+ class_addbang(mandelbrot_class, mandelbrot_bang);
+ class_addfloat(mandelbrot_class, mandelbrot_float);
+/* class_addfloat(mandelbrot_class; mandelbrot_float);*/
+}
diff --git a/mandelbrot~.c b/mandelbrot~.c
new file mode 100644
index 0000000..76cc108
--- /dev/null
+++ b/mandelbrot~.c
@@ -0,0 +1,122 @@
+#include "m_pd.h"
+
+/* ----------------------------- mandelbrot~ ----------------------------- */
+t_class *mandelbrot_tilde_class;
+
+typedef struct _mandelbrot_tilde
+{
+ t_object x_obj;
+ float k;
+ float cr;
+ float ci;
+} t_mandelbrot_tilde;
+
+void *mandelbrot_tilde_new(t_symbol *s, t_floatarg f)
+{
+ t_mandelbrot_tilde *x = (t_mandelbrot_tilde *)pd_new(mandelbrot_tilde_class);
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ floatinlet_new(&x->x_obj, &x->k);
+ x->k = f;
+ outlet_new(&x->x_obj, &s_signal);
+ return (x);
+}
+
+
+static int mandelbrot_calc(t_float *cr, t_float *ci, int k)
+{
+ int i = -2;
+ t_float zr = 0;
+ t_float zi = 0;
+ t_float z2r = 0;
+ t_float z2i = 0;
+ while ((z2r + z2i < 4 ) && (++i < k )) {
+ z2r = zr * zr;
+ z2i = zi * zi;
+ zi = 2 * zr * zi + *ci;
+ zr = z2r - z2i + *cr;
+ }
+ return(i);
+}
+
+
+static int mandelbrot_calc8(float cr, float ci, int k)
+{
+ int i = -2;
+ t_float zr = 0;
+ t_float zi = 0;
+ t_float z2r = 0;
+ t_float z2i = 0;
+ while ((z2r + z2i < 4 ) && (++i < k )) {
+ z2r = zr * zr;
+ z2i = zi * zi;
+ zi = 2 * zr * zi + ci;
+ zr = z2r - z2i + cr;
+ }
+ return(i);
+}
+
+
+
+t_int *mandelbrot_tilde_perform(t_int *w)
+{
+
+ t_mandelbrot_tilde *x = (t_mandelbrot_tilde *)(w[1]);
+ t_float *in1 = (t_float *)(w[2]);
+ t_float *in2 = (t_float *)(w[3]);
+ t_float *out = (t_float *)(w[4]);
+ int n = (int)(w[5]);
+ while (n--) *out++ = (t_float)mandelbrot_calc (in1++,in2++, x->k);
+ return (w+6);
+}
+
+
+t_int *mandelbrot_tilde_perf8(t_int *w)
+{
+ t_mandelbrot_tilde *x = (t_mandelbrot_tilde *)(w[1]);
+ t_float *in1 = (t_float *)(w[2]);
+ t_float *in2 = (t_float *)(w[3]);
+ t_float *out = (t_float *)(w[4]);
+ int n = (int)(w[5]);
+ for (; n; n -= 8, in1 += 8, in2 += 8, out += 8)
+ {
+ float f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
+ float f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
+
+ float g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3];
+ float g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7];
+ out[0] = mandelbrot_calc8(f0 ,g0,x->k);
+ out[1] = mandelbrot_calc8(f1 ,g1,x->k);
+ out[2] = mandelbrot_calc8(f2 ,g2,x->k);
+ out[3] = mandelbrot_calc8(f3 ,g3,x->k);
+ out[4] = mandelbrot_calc8(f4 ,g4,x->k);
+ out[5] = mandelbrot_calc8(f5 ,g5,x->k);
+ out[6] = mandelbrot_calc8(f6 ,g6,x->k);
+ out[7] = mandelbrot_calc8(f7 ,g7,x->k);
+
+ }
+ return (w+6);
+}
+
+
+void dsp_add_mandelbrot_tilde(t_mandelbrot_tilde *x,t_sample *in1, t_sample *in2, t_sample *out, int n)
+{
+ if (n&7)
+ dsp_add(mandelbrot_tilde_perform, 5, x, in1, in2, out, n);
+ else
+ dsp_add(mandelbrot_tilde_perf8, 5, x, in1, in2, out, n);
+}
+
+void mandelbrot_tilde_dsp(t_mandelbrot_tilde *x, t_signal **sp)
+{
+ dsp_add_mandelbrot_tilde(x,sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
+}
+
+
+void mandelbrot_tilde_setup(void)
+{
+ mandelbrot_tilde_class = class_new(gensym("mandelbrot~"), (t_newmethod)mandelbrot_tilde_new,
+ 0, sizeof(t_mandelbrot_tilde), 0, A_DEFFLOAT, 0);
+ class_addmethod(mandelbrot_tilde_class, (t_method)mandelbrot_tilde_dsp, gensym("dsp"), 0);
+ CLASS_MAINSIGNALIN(mandelbrot_tilde_class, t_mandelbrot_tilde, k);
+}
+
diff --git a/messages.c b/messages.c
new file mode 100644
index 0000000..a9ece03
--- /dev/null
+++ b/messages.c
@@ -0,0 +1,36 @@
+#include "m_pd.h"
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+/* ------------------------ messages ----------------------------- */
+
+static t_class *messages_class;
+
+
+typedef struct _messages
+{
+ t_object x_obj;
+} t_messages;
+
+
+void messages_bang(t_messages *x)
+{
+ post("bang");
+}
+
+static void *messages_new()
+{
+ t_messages *x = (t_messages *)pd_new(messages_class);
+ return (x);
+}
+
+void messages_setup(void)
+{
+ messages_class = class_new(gensym("messages"), (t_newmethod)messages_new, 0,
+ sizeof(t_messages), 0,0);
+ class_addbang(messages_class,messages_bang);
+}
+
+
diff --git a/openpatch.c b/openpatch.c
new file mode 100644
index 0000000..a9a6ddb
--- /dev/null
+++ b/openpatch.c
@@ -0,0 +1,68 @@
+#include "ext13.h"
+#include "m_pd.h"
+#include <sys/stat.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+/* -------------------------- openpatch ------------------------------ */
+static t_class *openpatch_class;
+
+typedef struct _openpatch
+{
+ t_object x_obj;
+ t_symbol *x_s;
+ t_symbol *x_path;
+} t_openpatch;
+
+
+static void *openpatch_new(t_symbol *s)
+{
+ t_openpatch *x = (t_openpatch *)pd_new(openpatch_class);
+ x->x_s = s;
+ x->x_path=gensym("./");
+ symbolinlet_new(&x->x_obj, &x->x_path);
+ return (x);
+}
+
+
+
+static void openpatch_symbol(t_openpatch *x, t_symbol *s)
+{
+ char *lastslash;
+ char path[MAXPDSTRING], filename[MAXPDSTRING];
+ x->x_s = s;
+ lastslash=strrchr (s->s_name,'/');
+ if (lastslash){
+ strncpy (path,s->s_name,lastslash-s->s_name+1);
+ path[lastslash-s->s_name]=0;
+ strcpy (filename,lastslash+1);
+ filename[lastslash-s->s_name+1]=0;
+ }
+ else {
+ strcpy (filename,s->s_name);
+ sprintf (path,x->x_path->s_name);
+ }
+ post ("path:%s , name:%s",path,filename);
+ glob_evalfile(0,gensym(filename),gensym(path));
+}
+
+
+static void openpatch_bang(t_openpatch *x)
+{
+ if (x->x_s){openpatch_symbol (x,x->x_s);}
+}
+
+void openpatch_setup(void)
+{
+ openpatch_class = class_new(gensym("openpatch"), (t_newmethod)openpatch_new, 0,
+ sizeof(t_openpatch), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)openpatch_new, gensym("opa"), A_DEFFLOAT, 0);
+ class_addbang(openpatch_class, openpatch_bang);
+ class_addsymbol(openpatch_class, openpatch_symbol);
+}
diff --git a/ossmixer.c b/ossmixer.c
new file mode 100644
index 0000000..3770543
--- /dev/null
+++ b/ossmixer.c
@@ -0,0 +1,327 @@
+#include "ext13.h"
+#include "m_pd.h"
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/soundcard.h>
+#include <errno.h>
+#include <string.h>
+
+#ifndef SOUND_MIXER_READ
+# define SOUND_MIXER_READ(x) MIXER_READ(x)
+#endif
+#ifndef SOUND_MIXER_WRITE
+# define SOUND_MIXER_WRITE(x) MIXER_WRITE(x)
+#endif
+
+
+/* -------------------------- ossmixer ------------------------------ */
+static t_class *ossmixer_class;
+
+typedef struct _ossmixer
+{
+ t_object x_obj;
+ int channel;
+ t_symbol* channel_name;
+ t_symbol* device;
+ t_outlet *x_out1;
+} t_ossmixer;
+
+static void *ossmixer_new(t_floatarg f)
+{
+ char* devicename;
+ int fd = -1;
+ t_ossmixer *x = (t_ossmixer *)pd_new(ossmixer_class);
+ outlet_new(&x->x_obj, &s_bang);
+ x->x_out1 = outlet_new(&x->x_obj, &s_symbol);
+ sprintf(devicename,"/dev/mixer%d",(int)f);
+ x->device = gensym(devicename);
+/* x->device = gensym ("/dev/mixer");*/
+ fd = open(x->device->s_name, O_WRONLY);
+ if (fd < 0){
+ post ("ossmixer: could not open %s",x->device->s_name);
+ x->device = gensym("/dev/mixer");
+ close (fd);
+ }else{
+ post ("ossmixer: device set to %s",devicename);
+ }
+ close(fd);
+ return (x);
+}
+
+static void ossmixer_set_device(t_ossmixer *x, t_floatarg f)
+{
+ char* devicename;
+ int fd = -1;
+ sprintf(devicename,"/dev/mixer%d",(int)f);
+ x->device = gensym(devicename);
+ fd = open(x->device->s_name, O_WRONLY);
+ if (fd < 0){
+ post ("ossmixer: could not open %s",x->device->s_name);
+ x->device = gensym("/dev/mixer");
+ close (fd);
+ }else{
+ post ("ossmixer: device set to %s",devicename);
+ }
+}
+
+static void ossmixer_bang(t_ossmixer *x)
+{
+ post ("ossmixer: what should a mixer do with a bang?");
+
+}
+
+static void ossmixer_get(t_ossmixer *x, t_symbol* s)
+{
+ int vol = -1;
+ x->channel = -1;
+ if (!strncmp(s->s_name,"main",4))
+ x->channel = (int) SOUND_MIXER_VOLUME;
+ if (!strncmp(s->s_name,"treble",6))
+ x->channel = (int) SOUND_MIXER_TREBLE;
+ if (!strncmp(s->s_name,"bass",4))
+ x->channel = (int) SOUND_MIXER_BASS;
+ if (!strncmp(s->s_name,"synth",5))
+ x->channel = (int) SOUND_MIXER_SYNTH;
+ if (!strncmp(s->s_name,"pcm",3))
+ x->channel = (int) SOUND_MIXER_PCM;
+ if (!strncmp(s->s_name,"speaker",7))
+ x->channel = (int) SOUND_MIXER_SPEAKER;
+ if (!strncmp(s->s_name,"line",4))
+ x->channel = (int) SOUND_MIXER_LINE;
+ if (!strncmp(s->s_name,"line1",5))
+ x->channel = (int) SOUND_MIXER_LINE1;
+ if (!strncmp(s->s_name,"line2",5))
+ x->channel = (int) SOUND_MIXER_LINE2;
+ if (!strncmp(s->s_name,"line3",5))
+ x->channel = (int) SOUND_MIXER_LINE3;
+ if (!strncmp(s->s_name,"mic",3))
+ x->channel = (int) SOUND_MIXER_MIC;
+ if (!strncmp(s->s_name,"cd",2))
+ x->channel = (int) SOUND_MIXER_CD;
+ if (!strncmp(s->s_name,"imix",4))
+ x->channel = (int) SOUND_MIXER_IMIX;
+ if (!strncmp(s->s_name,"altpcm",6))
+ x->channel = (int) SOUND_MIXER_ALTPCM;
+ if (!strncmp(s->s_name,"reclev",6))
+ x->channel = (int) SOUND_MIXER_RECLEV;
+ if (!strncmp(s->s_name,"reclevel",8))
+ x->channel = (int) SOUND_MIXER_RECLEV;
+ if (!strncmp(s->s_name,"igain",5))
+ x->channel = (int) SOUND_MIXER_IGAIN;
+ if (!strncmp(s->s_name,"ogain",5))
+ x->channel = (int) SOUND_MIXER_OGAIN;
+
+/*
+braucht das wer?
+ #define SOUND_MIXER_DIGITAL1 17
+ #define SOUND_MIXER_DIGITAL2 18
+ #define SOUND_MIXER_DIGITAL3 19
+ #define SOUND_MIXER_PHONEIN 20
+ #define SOUND_MIXER_PHONEOUT 21
+ #define SOUND_MIXER_VIDEO 22
+ #define SOUND_MIXER_RADIO 23
+ #define SOUND_MIXER_MONITOR 24
+*/
+
+
+ if (x->channel > -1){
+ int fd = -1;
+/* fd = open("/dev/mixer0", O_RDONLY);*/
+ fd = open(x->device->s_name, O_RDONLY);
+ if (fd > 0){
+ int vol = 50;
+ if (ioctl(fd, SOUND_MIXER_READ( x->channel ), &vol)==-1){
+ post("ossmixer: undefined mixer channel");
+ }else{
+ x->channel_name = s;
+ vol = vol & 255;
+ outlet_symbol (x->x_out1,s);
+ outlet_float(x->x_obj.ob_outlet,(t_float)vol);
+ }
+ close(fd);
+ }else{
+ post ("ossmixer: could not open device %s",x->device->s_name);
+ }
+ }
+}
+
+static void ossmixer_set(t_ossmixer *x, t_symbol* s, t_float f)
+{
+ int vol = (int) f;
+ if (vol < 0 ){
+ post ("ossmixer: minimum volume: 0");
+ vol = 0;
+ }
+ if (vol > 100 ){
+ post ("ossmixer: maximum volume: 100");
+ vol = 100;
+ }
+ x->channel = -1;
+
+ if (!strncmp(s->s_name,"main",4))
+ x->channel = (int) SOUND_MIXER_VOLUME;
+ if (!strncmp(s->s_name,"treble",6))
+ x->channel = (int) SOUND_MIXER_TREBLE;
+ if (!strncmp(s->s_name,"bass",4))
+ x->channel = (int) SOUND_MIXER_BASS;
+ if (!strncmp(s->s_name,"synth",5))
+ x->channel = (int) SOUND_MIXER_SYNTH;
+ if (!strncmp(s->s_name,"pcm",3))
+ x->channel = (int) SOUND_MIXER_PCM;
+ if (!strncmp(s->s_name,"speaker",7))
+ x->channel = (int) SOUND_MIXER_SPEAKER;
+ if (!strncmp(s->s_name,"line",4))
+ x->channel = (int) SOUND_MIXER_LINE;
+ if (!strncmp(s->s_name,"line1",5))
+ x->channel = (int) SOUND_MIXER_LINE1;
+ if (!strncmp(s->s_name,"line2",5))
+ x->channel = (int) SOUND_MIXER_LINE2;
+ if (!strncmp(s->s_name,"line3",5))
+ x->channel = (int) SOUND_MIXER_LINE3;
+ if (!strncmp(s->s_name,"mic",3))
+ x->channel = (int) SOUND_MIXER_MIC;
+ if (!strncmp(s->s_name,"cd",2))
+ x->channel = (int) SOUND_MIXER_CD;
+ if (!strncmp(s->s_name,"imix",4))
+ x->channel = (int) SOUND_MIXER_IMIX;
+ if (!strncmp(s->s_name,"altpcm",6))
+ x->channel = (int) SOUND_MIXER_ALTPCM;
+ if (!strncmp(s->s_name,"reclev",6))
+ x->channel = (int) SOUND_MIXER_RECLEV;
+ if (!strncmp(s->s_name,"reclevel",8))
+ x->channel = (int) SOUND_MIXER_RECLEV;
+ if (!strncmp(s->s_name,"igain",5))
+ x->channel = (int) SOUND_MIXER_IGAIN;
+ if (!strncmp(s->s_name,"ogain",5))
+ x->channel = (int) SOUND_MIXER_OGAIN;
+
+
+
+ if (x->channel > -1){
+ int fd = -1;
+ fd = open(x->device->s_name, O_WRONLY);
+ if (fd > 0){
+ vol = vol | (vol << 8);
+ if (ioctl(fd, SOUND_MIXER_WRITE( x->channel ), &vol)==-1){
+ post("ossmixer: undefined mixer channel");
+ }else{
+ x->channel_name = s;
+ vol &= 255;
+ outlet_symbol (x->x_out1,s);
+ outlet_float(x->x_obj.ob_outlet,(t_float)vol);
+ }
+ close (fd);
+ }else{
+ post ("ossmixer: could not open device %s",x->device->s_name);
+ }
+ }
+}
+static void ossmixer_get_source(t_ossmixer *x)
+{
+ int fd = -1;
+ int channel = -1;
+ fd = open(x->device->s_name, O_WRONLY);
+ if (fd > 0){
+ if ( ioctl(fd, SOUND_MIXER_READ_RECSRC, &channel) ){
+ post ("ossmixer: could not get recording source");
+ }else{
+ t_symbol* s_ch = gensym("no_source_found");
+ if (channel & SOUND_MASK_VOLUME) s_ch = gensym("main");
+ if (channel & SOUND_MASK_PCM) s_ch = gensym("pcm");
+ if (channel & SOUND_MASK_MIC) s_ch = gensym("mic");
+ if (channel & SOUND_MASK_CD) s_ch = gensym("cd");
+ if (channel & SOUND_MASK_SYNTH) s_ch = gensym("synth");
+ if (channel & SOUND_MASK_LINE) s_ch = gensym("line");
+ if (channel & SOUND_MASK_LINE1) s_ch = gensym("line1");
+ if (channel & SOUND_MASK_LINE2) s_ch = gensym("line2");
+ if (channel & SOUND_MASK_LINE3) s_ch = gensym("line3");
+ if (channel & SOUND_MASK_ALTPCM) s_ch = gensym("altpcm");
+
+ outlet_symbol (x->x_out1,s_ch);
+ outlet_symbol (x->x_obj.ob_outlet,gensym("source"));
+ }
+ close (fd);
+ }else{
+ post ("ossmixer: could not open mixer device");
+ }
+
+}
+
+static void ossmixer_set_source(t_ossmixer *x, t_symbol* s)
+{
+ int channel = -1;
+ if (!strncmp(s->s_name,"main",4))
+ channel = (int) SOUND_MASK_VOLUME;
+ if (!strncmp(s->s_name,"treble",6))
+ channel = (int) SOUND_MASK_TREBLE;
+ if (!strncmp(s->s_name,"bass",4))
+ channel = (int) SOUND_MASK_BASS;
+ if (!strncmp(s->s_name,"synth",5))
+ channel = (int) SOUND_MASK_SYNTH;
+ if (!strncmp(s->s_name,"pcm",3))
+ channel = (int) SOUND_MASK_PCM;
+ if (!strncmp(s->s_name,"speaker",7))
+ channel = (int) SOUND_MASK_SPEAKER;
+ if (!strncmp(s->s_name,"line",4))
+ channel = (int) SOUND_MASK_LINE;
+ if (!strncmp(s->s_name,"line1",5))
+ channel = (int) SOUND_MASK_LINE1;
+ if (!strncmp(s->s_name,"line2",5))
+ channel = (int) SOUND_MASK_LINE2;
+ if (!strncmp(s->s_name,"line3",5))
+ channel = (int) SOUND_MASK_LINE3;
+ if (!strncmp(s->s_name,"mic",3))
+ channel = (int) SOUND_MASK_MIC;
+ if (!strncmp(s->s_name,"cd",2))
+ channel = (int) SOUND_MASK_CD;
+ if (!strncmp(s->s_name,"imix",4))
+ channel = (int) SOUND_MASK_IMIX;
+ if (!strncmp(s->s_name,"altpcm",6))
+ channel = (int) SOUND_MASK_ALTPCM;
+ if (!strncmp(s->s_name,"reclev",6))
+ channel = (int) SOUND_MASK_RECLEV;
+ if (!strncmp(s->s_name,"reclevel",8))
+ channel = (int) SOUND_MASK_RECLEV;
+ if (!strncmp(s->s_name,"igain",5))
+ channel = (int) SOUND_MASK_IGAIN;
+ if (!strncmp(s->s_name,"ogain",5))
+ channel = (int) SOUND_MASK_OGAIN;
+
+ if(channel > -1){
+ int fd = -1;
+ fd = open(x->device->s_name, O_WRONLY);
+ if (fd > 0){
+ if ( ioctl(fd, SOUND_MIXER_WRITE_RECSRC, &channel) ){
+ post ("ossmixer: could not set recordiing source");
+ }else{
+ ossmixer_get_source(x);
+ }
+ close (fd);
+ }else{
+ post ("ossmixer: could not open mixer device %s",x->device->s_name);
+ }
+ }else{
+ post ("ossmixer: channel unknown");
+ }
+}
+
+static void ossmixer_float(t_ossmixer *x, t_float f)
+{
+ ossmixer_set (x, x->channel_name, f);
+}
+
+
+void ossmixer_setup(void)
+{
+ ossmixer_class = class_new(gensym("ossmixer"), (t_newmethod)ossmixer_new, 0, sizeof(t_ossmixer), 0, A_DEFFLOAT, 0);
+ class_addbang(ossmixer_class, ossmixer_bang);
+ class_addfloat(ossmixer_class, ossmixer_float);
+ class_addmethod(ossmixer_class, (t_method) ossmixer_get, gensym("get"), A_DEFSYM, 0);
+ class_addmethod(ossmixer_class, (t_method) ossmixer_set, gensym("set"), A_DEFSYM, A_DEFFLOAT, 0);
+ class_addmethod(ossmixer_class, (t_method) ossmixer_get_source, gensym("get_source"), A_DEFSYM, 0);
+ class_addmethod(ossmixer_class, (t_method) ossmixer_set_source, gensym("set_source"), A_DEFSYM, 0);
+ class_addmethod(ossmixer_class, (t_method) ossmixer_set_device, gensym("set_device"), A_DEFFLOAT, 0);
+}
diff --git a/piperead~.c b/piperead~.c
new file mode 100644
index 0000000..28d6320
--- /dev/null
+++ b/piperead~.c
@@ -0,0 +1,171 @@
+#include "m_pd.h"
+#include "g_canvas.h"
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+/* ------------------------ piperead_tilde~ ----------------------------- */
+
+#ifdef NT
+#define BINREADMODE "rb"
+#else
+#define BINREADMODE "r"
+#endif
+
+static t_class *piperead_tilde_class;
+
+
+typedef struct _piperead_tilde
+{
+ t_object x_obj;
+ void* x_mapaddr;
+ int x_fd;
+ short x_sample;
+ t_int x_play;
+ t_int x_channels;
+ t_glist * x_glist;
+ int buflen;
+ short buf[32768];
+ int readpointer;
+ int writepointer;
+} t_piperead_tilde;
+
+
+void piperead_tilde_open(t_piperead_tilde *x,t_symbol *filename)
+{
+/* struct stat fstate;*/
+ char fname[MAXPDSTRING];
+ canvas_makefilename(glist_getcanvas(x->x_glist), filename->s_name,
+ fname, MAXPDSTRING);
+
+ /* close the old file */
+ if (x->x_fd >= 0) close(x->x_fd);
+
+ if ((x->x_fd = open(fname,( O_NONBLOCK | O_RDONLY))) < 0)
+ {
+ error("can't open %s",fname);
+ return;
+ }
+
+ for (x->writepointer=0;x->writepointer<(x->buflen*0.9);x->writepointer++){
+ read (x->x_fd,&x->buf[x->writepointer],2);
+ }
+/* post ("prebuffering done");*/
+
+}
+
+#define MAX_CHANS 4
+
+t_int *piperead_tilde_perform(t_int *w)
+{
+ t_piperead_tilde* x = (t_piperead_tilde*)(w[1]);
+ int c = x->x_channels;
+ int i;
+ int erg=0;
+ int n;
+ t_float* out[MAX_CHANS];
+ for (i=0;i<c;i++)
+ out[i] = (t_float *)(w[3+i]);
+ n = (int)(w[3+c]);
+
+ while (n--)
+ if (x->x_play){
+ for (i=0;i<c;i++)
+ {
+ if (++x->readpointer>x->buflen){
+ x->readpointer=0;
+ }
+ if (erg != EAGAIN){
+ if (++x->writepointer>x->buflen){
+ x->writepointer=0;
+ }
+ }
+ *out[i]++ = x->buf[x->readpointer]/32768.;
+ erg = read (x->x_fd,&x->buf[x->writepointer],2);
+ }
+ }
+ else
+ {
+ for (i=0;i<c;i++) *out[i]++= 0.;
+ }
+ return (w+c+4);
+}
+
+
+static void piperead_tilde_float(t_piperead_tilde *x, t_floatarg f)
+{
+ int t = f;
+ if (t) {
+ x->x_play=1;
+ }
+ else {
+ x->x_play=0;
+ }
+
+}
+
+static void piperead_tilde_dsp(t_piperead_tilde *x, t_signal **sp)
+{
+ switch (x->x_channels) {
+ case 1:
+ dsp_add(piperead_tilde_perform, 4, x, sp[0]->s_vec,
+ sp[1]->s_vec, sp[0]->s_n);
+ break;
+ case 2:
+ dsp_add(piperead_tilde_perform, 5, x, sp[0]->s_vec,
+ sp[1]->s_vec,sp[2]->s_vec, sp[0]->s_n);
+ break;
+ case 4:
+ dsp_add(piperead_tilde_perform, 6, x, sp[0]->s_vec,
+ sp[1]->s_vec,sp[2]->s_vec,
+ sp[3]->s_vec,sp[4]->s_vec,
+ sp[0]->s_n);
+ break;
+ }
+}
+
+
+static void *piperead_tilde_new(t_floatarg chan, t_floatarg buflen)
+{
+ t_piperead_tilde *x = (t_piperead_tilde *)pd_new(piperead_tilde_class);
+ t_int c = chan;
+ t_int bl = buflen;
+ x->x_glist = (t_glist*) canvas_getcurrent();
+
+ if (c<1 || c > MAX_CHANS) c = 1;
+ if (bl<8 || bl > 32767) bl = 256;
+ x->x_fd = -1;
+ x->x_channels = c;
+ x->buflen=bl;
+ x->x_play = 0;
+
+ while (c--) {
+ outlet_new(&x->x_obj, gensym("signal"));
+ }
+ return (x);
+}
+
+void piperead_tilde_setup(void)
+{
+ piperead_tilde_class = class_new(gensym("piperead~"), (t_newmethod)piperead_tilde_new, 0,
+ sizeof(t_piperead_tilde), 0,A_DEFFLOAT,A_DEFFLOAT,0);
+ class_addmethod(piperead_tilde_class, nullfn, gensym("signal"), 0);
+ class_sethelpsymbol(piperead_tilde_class, gensym("pipeio~"));
+ class_addmethod(piperead_tilde_class, (t_method) piperead_tilde_dsp, gensym("dsp"), 0);
+ class_addmethod(piperead_tilde_class, (t_method) piperead_tilde_open, gensym("open"), A_SYMBOL,A_NULL);
+ class_addfloat(piperead_tilde_class, piperead_tilde_float);
+}
+
+
diff --git a/pipewrite~.c b/pipewrite~.c
new file mode 100644
index 0000000..b609c37
--- /dev/null
+++ b/pipewrite~.c
@@ -0,0 +1,286 @@
+#include "m_imp.h"
+//#include <m_pd.h>
+#include "g_canvas.h"
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+
+/*
+ * ------------------------------------------- pipewrite_tilde~ -------------------------------
+ */
+
+#define MAX_CHANS 4
+#define BLOCKTIME 0.001
+#define uint32 unsigned int
+#define uint16 unsigned short
+#define THERATE 22050
+
+typedef struct _wave
+{
+ char w_fileid[4]; /* chunk id 'RIFF' */
+ uint32 w_chunksize; /* chunk size */
+ char w_waveid[4]; /* wave chunk id 'WAVE' */
+ char w_fmtid[4]; /* format chunk id 'fmt ' */
+ uint32 w_fmtchunksize; /* format chunk size */
+ uint16 w_fmttag; /* format tag, 1 for PCM */
+ uint16 w_nchannels; /* number of channels */
+ uint32 w_samplespersec; /* sample rate in hz */
+ uint32 w_navgbytespersec; /* average bytes per second */
+ uint16 w_nblockalign; /* number of bytes per sample */
+ uint16 w_nbitspersample; /* number of bits in a sample */
+ char w_datachunkid[4]; /* data chunk id 'data' */
+ uint32 w_datachunksize; /* length of data chunk */
+} t_wave;
+
+
+static t_class *pipewrite_tilde_class;
+
+typedef struct _pipewrite_tilde
+{
+ t_object x_obj;
+ t_symbol* filename;
+ int x_file;
+ int finalize;
+ t_int rec;
+ t_int x_channels;
+ t_int size;
+ t_glist * x_glist;
+ t_int x_blocked;
+ t_int x_blockwarn;
+ short maxval;
+} t_pipewrite_tilde;
+
+static void pipewrite_tilde_wave_setup(t_pipewrite_tilde* x,t_wave* w)
+{
+ strncpy(w->w_fileid,"RIFF",4); /* chunk id 'RIFF' */
+ w->w_chunksize = x->size + sizeof(t_wave) - 8; /* chunk size */
+ strncpy(w->w_waveid,"WAVE",4); /* wave chunk id 'WAVE' */
+ strncpy(w->w_fmtid,"fmt ",4); /* format chunk id 'fmt '*/
+ w->w_fmtchunksize = 16; /* format chunk size */
+ w->w_fmttag = 1; /* format tag, 1 for PCM */
+ w->w_nchannels = x->x_channels; /* number of channels */
+ w->w_samplespersec = THERATE; /* sample rate in hz */
+ w->w_navgbytespersec = THERATE * x->x_channels*2; /* average bytes per second */
+ w->w_nblockalign = 4; /* number of bytes per sample */
+ w->w_nbitspersample = 16; /* number of bits in a sample */
+ strncpy(w->w_datachunkid,"data",4); /* data chunk id 'data' */
+ w->w_datachunksize = THERATE * 60 * 60 * 24 *365 /* x->size*/ ; /* length of data chunk */
+
+}
+
+
+
+static void pipewrite_tilde_close(t_pipewrite_tilde *x)
+{
+ if (x->x_file > 0) {
+ t_wave w;
+ pipewrite_tilde_wave_setup(x,&w);
+ lseek(x->x_file,0,SEEK_SET);
+ write(x->x_file,&w,sizeof(w));
+ close(x->x_file);
+ }
+ x->x_file = -1;
+ x->size=0;
+}
+
+
+static void pipewrite_tilde_open(t_pipewrite_tilde *x,t_symbol *filename)
+{
+ char fname[MAXPDSTRING];
+ t_wave w;
+
+ if (filename == &s_) {
+ post("pipewrite_tilde: open without filename");
+ return;
+ }
+
+ canvas_makefilename(glist_getcanvas(x->x_glist), filename->s_name,
+ fname, MAXPDSTRING);
+ x->finalize = 0;
+ x->x_blocked = 0;
+ x->filename = filename;
+ x->maxval=0;
+ x->size=0;
+ post("pipewrite_tilde: filename = %s",x->filename->s_name);
+
+/*
+ pipewrite_tilde_close(x);
+*/
+/* if ((x->x_file = open(fname,O_WRONLY | O_CREAT | O_NONBLOCK ,0664)) < 0)*/
+ if ((x->x_file = open(fname,O_WRONLY | O_CREAT | O_NONBLOCK ,0664)) < 0)
+
+ {
+ error("can't create %s",fname);
+ return;
+ }
+
+
+ pipewrite_tilde_wave_setup(x,&w);
+ write(x->x_file,&w,sizeof(w));
+
+
+}
+
+static void pipewrite_tilde_block(t_pipewrite_tilde *x, t_floatarg f)
+{
+ x->x_blockwarn = f;
+}
+
+
+static void pipewrite_tilde_float(t_pipewrite_tilde *x, t_floatarg f)
+{
+ int t = f;
+ if (t) {
+ if ( !(x->x_file > 0)){
+ post ("pipewrite_tilde:dont have a file to record to");
+ }else{
+ post("pipewrite_tilde: start", f);
+ x->rec=1;
+ }
+ }
+ else {
+ post("pipewrite_tilde: stop", f);
+ x->rec=0;
+ x->finalize=1;
+ }
+
+}
+
+
+static short out[4*64];
+
+static t_int *pipewrite_tilde_perform(t_int *w)
+{
+ t_pipewrite_tilde* x = (t_pipewrite_tilde*)(w[1]);
+ t_float * in[4];
+ int c = x->x_channels;
+ int i,num,n;
+ short* tout = out;
+ int ret;
+ double timebefore,timeafter;
+ double late;
+
+ for (i=0;i < c;i++) {
+ in[i] = (t_float *)(w[2+i]);
+ }
+
+ n = num = (int)(w[2+c]);
+
+ /* loop */
+
+ if (x->rec && x->x_file) {
+
+ while (n--) {
+ for (i=0;i<c;i++) {
+ if (*(in[i]) > 1. ) { *(in[i]) = 1. ; }
+ if (*(in[i]) < -1. ) { *(in[i]) = -1. ; }
+ *tout++ = (*(in[i])++ * 32768.);
+/*
+ if (abs(*tout)>abs(x->maxval)){
+ x->maxval=*tout;
+ post("new maxval:%d, c:%d",x->maxval,c);
+ }
+*/
+ }
+ }
+
+ timebefore = sys_getrealtime();
+ if ((ret =write(x->x_file,out,sizeof(short)*num*c)) < sizeof(short)*num*c) {
+ post("pipewrite_tilde: short write %d",ret);
+
+ }
+ timeafter = sys_getrealtime();
+ late = timeafter - timebefore;
+ x->size +=ret;
+ /* OK, we let only 10 ms block here */
+ if (late > BLOCKTIME && x->x_blockwarn) {
+ post("pipewrite_tilde blocked %f ms",late*1000);
+ x->x_blocked++;
+ if (x->x_blocked > x->x_blockwarn) {
+/* x->rec = 0;*/
+ post("maximum blockcount %d reached, recording normalerweise stopped (set blockcount with \"block <num>\"",x->x_blockwarn);
+ }
+ }
+ }
+ if (!x->rec && x->finalize){
+ pipewrite_tilde_close(x);
+ x->finalize = 0;
+ }
+
+ return (w+3+c);
+}
+
+
+
+static void pipewrite_tilde_dsp(t_pipewrite_tilde *x, t_signal **sp)
+{
+ switch (x->x_channels) {
+ case 1:
+ dsp_add(pipewrite_tilde_perform, 3, x, sp[0]->s_vec,
+ sp[0]->s_n);
+ break;
+ case 2:
+ dsp_add(pipewrite_tilde_perform, 4, x, sp[0]->s_vec,
+ sp[1]->s_vec, sp[0]->s_n);
+ break;
+ case 4:
+ dsp_add(pipewrite_tilde_perform, 6, x, sp[0]->s_vec,
+ sp[1]->s_vec,
+ sp[2]->s_vec,
+ sp[3]->s_vec,
+ sp[0]->s_n);
+ break;
+ }
+}
+
+static void pipewrite_tilde_free(t_pipewrite_tilde* x)
+{
+ pipewrite_tilde_close(x);
+}
+
+
+static void *pipewrite_tilde_new(t_floatarg chan)
+{
+ t_pipewrite_tilde *x = (t_pipewrite_tilde *)pd_new(pipewrite_tilde_class);
+ t_int c = chan;
+
+ if (c<1 || c > MAX_CHANS) c = 1;
+
+ x->x_glist = (t_glist*) canvas_getcurrent();
+ x->x_channels = c--;
+ post("channels:%d",x->x_channels);
+ x->x_file=0;
+ x->rec = 0;
+ x->finalize = 0;
+ x->x_blocked = 0;
+ x->x_blockwarn = 10;
+ while (c--) {
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ }
+
+
+ return (x);
+}
+
+void pipewrite_tilde_setup(void)
+{
+ pipewrite_tilde_class = class_new(gensym("pipewrite~"), (t_newmethod)pipewrite_tilde_new, (t_method)pipewrite_tilde_free,
+ sizeof(t_pipewrite_tilde), 0,A_DEFFLOAT,0);
+ class_addmethod(pipewrite_tilde_class,nullfn,gensym("signal"), 0);
+ class_sethelpsymbol(pipewrite_tilde_class, gensym("pipeio~"));
+ class_addmethod(pipewrite_tilde_class, (t_method) pipewrite_tilde_dsp, gensym("dsp"), 0);
+ class_addmethod(pipewrite_tilde_class, (t_method) pipewrite_tilde_open, gensym("open"), A_SYMBOL,A_NULL);
+ class_addmethod(pipewrite_tilde_class, (t_method) pipewrite_tilde_close, gensym("close"), 0);
+ class_addmethod(pipewrite_tilde_class, (t_method)pipewrite_tilde_block,gensym("block"),A_DEFFLOAT,0);
+ class_addfloat(pipewrite_tilde_class, pipewrite_tilde_float);
+
+}
diff --git a/promiscous~.c b/promiscous~.c
new file mode 100644
index 0000000..1075eb7
--- /dev/null
+++ b/promiscous~.c
@@ -0,0 +1,126 @@
+#include "m_pd.h"
+#include "ext13.h"
+#include <sys/types.h>
+#include <string.h>
+#include <sys/errno.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <net/if.h>
+#include <netinet/if_ether.h>
+#include <netinet/ip.h>
+#include <netdb.h>
+
+
+
+/* ------------------------ promiscous_tilde~ ----------------------------- */
+
+
+#define DEFAULT_NIC "eth0" //NIC
+
+static t_class *promiscous_tilde_class;
+
+
+typedef struct _promiscous_tilde
+{
+ t_object x_obj;
+ int opened;
+ int sock;
+ char* cbuf;
+ t_symbol* interface;
+} t_promiscous_tilde;
+
+
+static int setnic_promisc(char *nic_name){
+ int sock; // socket desc
+ struct ifreq f;
+
+ if( (sock = socket(AF_INET, SOCK_PACKET, htons(ETH_P_ALL))) < 0){
+ post("promiscous~ failed open socket, must be root (euid)");
+ return(-1);
+ }
+ strcpy(f.ifr_name, nic_name);
+ if( ioctl(sock, SIOCGIFFLAGS, &f) < 0) {
+ post("promisous~ failed to get interface flags, continue anyway");
+ return(sock);
+ }
+ f.ifr_flags |= IFF_PROMISC;
+ if( ioctl(sock, SIOCSIFFLAGS, &f) < 0) {
+ post("promiscous~ failed to set promisous mode , continue anyway");
+ }
+ return(sock);
+}
+
+
+t_int *promiscous_tilde_perform(t_int *w)
+{
+ t_promiscous_tilde* x = (t_promiscous_tilde*)(w[1]);
+ int n = (int)(w[3]);/*number of samples*/
+ int l = 0;
+ int ll = 0;
+ int r;
+ static unsigned char packet;
+ fd_set fdset;
+ struct timeval timeout;
+ t_float* out = (t_float *)w[2];
+ int cptr[n];
+
+ if (x->opened){
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+ FD_ZERO(&fdset);
+ FD_SET(x->sock,&fdset);
+ if (r = select(x->sock+1,&fdset,NULL,NULL,&timeout) && x->sock){
+ /* l = recv(x->sock, &cptr,n, 0);*/
+ l = read(x->sock, (char*) &cptr,n);
+ };
+ if (l < 0) l = 0;
+ while (l--){
+ *out++ = cptr[n-l] / 32767.;
+ ll++;
+ }
+ }
+ while (ll < n){
+ *out++ = 0.;
+ ll++;
+ }
+ return (w + 4);
+}
+
+static void promiscous_tilde_dsp(t_promiscous_tilde *x, t_signal **sp)
+{
+ dsp_add(promiscous_tilde_perform, 3, x, sp[0]->s_vec,
+ sp[0]->s_n);
+}
+
+
+static void promiscous_tilde_free(t_promiscous_tilde *x){
+ /*LATER*/
+}
+
+
+static void *promiscous_tilde_new()
+{
+ t_promiscous_tilde *x = (t_promiscous_tilde *)pd_new(promiscous_tilde_class);
+ outlet_new(&x->x_obj, gensym("signal"));
+
+ x->interface = gensym("eth0");
+
+ if((x->sock = setnic_promisc(x->interface->s_name))<0){
+ post ("could not open interface");
+ x->opened = 0;
+ }else{
+ x->opened = 1;
+ }
+ return (x);
+}
+
+
+void promiscous_tilde_setup(void)
+{
+ promiscous_tilde_class = class_new(gensym("promiscous~"), (t_newmethod) promiscous_tilde_new, 0,
+ sizeof(t_promiscous_tilde), CLASS_NOINLET, 0);
+ class_addmethod(promiscous_tilde_class, (t_method) promiscous_tilde_dsp, gensym("dsp"), 0);
+}
diff --git a/receive13.c b/receive13.c
new file mode 100644
index 0000000..4892775
--- /dev/null
+++ b/receive13.c
@@ -0,0 +1,86 @@
+#include "m_pd.h"
+
+#include <string.h>
+#include <stdio.h>
+
+/* -------------------- receive13 ------------------------------ */
+/* this is pd's biultin recieve plus the hack for "set" messages */
+/* it's a pitty, but i don't know where this patch originally */
+/* came from, so i can'z give correct credits... */
+/* ------------------------------------------------------------- */
+
+static t_class *receive13_class;
+
+typedef struct _receive13
+{
+ t_object x_obj;
+ t_symbol *x_sym;
+} t_receive13;
+
+static void receive13_set(t_receive13 *x, t_symbol *s)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+ x->x_sym = s;
+ pd_bind(&x->x_obj.ob_pd, s);
+}
+
+static void receive13_bang(t_receive13 *x)
+{
+ outlet_bang(x->x_obj.ob_outlet);
+}
+
+static void receive13_float(t_receive13 *x, t_float f)
+{
+ outlet_float(x->x_obj.ob_outlet, f);
+}
+
+static void receive13_symbol(t_receive13 *x, t_symbol *s)
+{
+ outlet_symbol(x->x_obj.ob_outlet, s);
+}
+
+static void receive13_pointer(t_receive13 *x, t_gpointer *gp)
+{
+ outlet_pointer(x->x_obj.ob_outlet, gp);
+}
+
+static void receive13_list(t_receive13 *x, t_symbol *s, int argc, t_atom *argv)
+{
+ outlet_list(x->x_obj.ob_outlet, s, argc, argv);
+}
+
+static void receive13_anything(t_receive13 *x, t_symbol *s, int argc, t_atom *argv)
+{
+ outlet_anything(x->x_obj.ob_outlet, s, argc, argv);
+}
+
+static void *receive13_new(t_symbol *s)
+{
+ t_receive13 *x = (t_receive13 *)pd_new(receive13_class);
+ x->x_sym = s;
+ pd_bind(&x->x_obj.ob_pd, s);
+ outlet_new(&x->x_obj, 0);
+ return (x);
+}
+
+static void receive13_free(t_receive13 *x)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+}
+
+void receive13_setup(void)
+{
+ receive13_class = class_new(gensym("receive13"), (t_newmethod)receive13_new,
+ (t_method)receive13_free, sizeof(t_receive13), 0, A_DEFSYM, 0);
+ class_addcreator((t_newmethod)receive13_new, gensym("r13"), A_DEFSYM, 0);
+ class_sethelpsymbol(receive13_class, gensym("ext13"));
+ class_addbang(receive13_class, receive13_bang);
+ class_addfloat(receive13_class, (t_method)receive13_float);
+ class_addsymbol(receive13_class, receive13_symbol);
+ class_addpointer(receive13_class, receive13_pointer);
+ class_addlist(receive13_class, receive13_list);
+ class_addanything(receive13_class, receive13_anything);
+ class_addmethod(receive13_class, (t_method)receive13_set, gensym("set"), A_SYMBOL, 0);
+
+}
+
diff --git a/receive13~.c b/receive13~.c
new file mode 100644
index 0000000..c3dec76
--- /dev/null
+++ b/receive13~.c
@@ -0,0 +1,92 @@
+/* Copyright (c) 1997-1999 Miller Puckette source modified by dieb13.
+* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* catch13~ ... = original objects with set-message for changing - bad hack - but works somehow*/
+
+#include "m_pd.h"
+#include "d_global13.h"
+
+#define DEFSENDVS 64 /* LATER get send to get this from canvas */
+
+/* ----------------------------- receive13~ ----------------------------- */
+
+ void *sigreceive13_new(t_symbol *s)
+{
+ t_sigreceive13 *x = (t_sigreceive13 *)pd_new(sigreceive13_class);
+ if (!*s->s_name) s = gensym("receive13~");
+ x->x_n = DEFSENDVS; /* LATER find our vector size correctly */
+ x->x_sym = s;
+ x->x_wherefrom = 0;
+ outlet_new(&x->x_obj, &s_signal);
+ return (x);
+}
+
+ t_int *sigreceive13_perform(t_int *w)
+{
+ t_sigreceive13 *x = (t_sigreceive13 *)(w[1]);
+ t_float *out = (t_float *)(w[2]);
+ int n = (int)(w[3]);
+ t_float *in = x->x_wherefrom;
+ if (in)
+ {
+ while (n--)
+ *out++ = *in++;
+ }
+ else
+ {
+ while (n--)
+ *out++ = 0;
+ }
+ return (w+4);
+}
+
+ void sigreceive13_set(t_sigreceive13 *x, t_symbol *s)
+{
+ t_sigsend13 *sender = (t_sigsend13 *)pd_findbyclass((x->x_sym = s),
+ sigsend13_class);
+ if (sender)
+ {
+ if (sender->x_n == x->x_n)
+ x->x_wherefrom = sender->x_vec;
+ else
+ {
+ pd_error(x, "receive13~ %s: vector size mismatch", x->x_sym->s_name);
+ x->x_wherefrom = 0;
+ }
+ }
+ else
+ {
+ pd_error(x, "receive13~ %s: no matching send", x->x_sym->s_name);
+ x->x_wherefrom = 0;
+ }
+}
+
+ void sigreceive13_dsp(t_sigreceive13 *x, t_signal **sp)
+{
+ if (sp[0]->s_n != x->x_n)
+ {
+ pd_error(x, "receive13~ %s: vector size mismatch", x->x_sym->s_name);
+ }
+ else
+ {
+ sigreceive13_set(x, x->x_sym);
+ dsp_add(sigreceive13_perform, 3,
+ x, sp[0]->s_vec, sp[0]->s_n);
+ }
+}
+
+void sigreceive13_setup(void)
+{
+ sigreceive13_class = class_new(gensym("receive13~"),
+ (t_newmethod)sigreceive13_new, 0,
+ sizeof(t_sigreceive13),0, A_DEFSYM, 0);
+ class_addcreator((t_newmethod)sigreceive13_new, gensym("r13~"), A_DEFSYM, 0);
+ class_sethelpsymbol(sigreceive13_class, gensym("ext13"));
+ class_addmethod(sigreceive13_class, (t_method)sigreceive13_set, gensym("set"),
+ A_SYMBOL, 0);
+ class_addmethod(sigreceive13_class, (t_method)sigreceive13_dsp, gensym("dsp"),
+ 0);
+}
+
+
diff --git a/scramble~.c b/scramble~.c
new file mode 100644
index 0000000..dd9414d
--- /dev/null
+++ b/scramble~.c
@@ -0,0 +1,637 @@
+#include "m_pd.h"
+#include "ext13.h"
+#include <sys/types.h>
+#include <string.h>
+#include <sys/errno.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+
+
+
+/* ------------------------ scramble_tilde~ ----------------------------- */
+
+static t_class *scramble_tilde_class;
+
+typedef struct _scramble_grain
+{
+ t_float* L;
+ t_float* R;
+ int size;
+ t_float maximum;
+ struct _scramble_grain *next;
+}t_scramble_grain;
+
+typedef struct _scramble_tilde
+{
+ t_object x_obj;
+ int x_n;
+ t_int x_channels;
+ t_float play, analize;
+ t_float dir, current_dir, pitch, actual_pitch, grain_r, autopitch;
+ t_float valsum, valavg;
+ int valsumcount, valsummax;
+ int autofollow, playmode, semitones;
+ t_scramble_grain *firstgrain;
+ t_scramble_grain *workgrain;
+ t_scramble_grain *ring;
+ int grains, newgrains, w_grain, r_grain, n_grain, gotagrain, flush;
+ int r_d, w_d, dist, mindist, lowptr, hiptr, lastlowptr;
+ t_float lowval, hival, prevval, lowborder, normalize;
+ int nsamples;
+ t_outlet *trigger1;
+ t_outlet *trigger2;
+} t_scramble_tilde;
+
+
+/* grain functions*/
+static t_scramble_grain* scramble_tilde_newgrain(){
+ t_scramble_grain* thegrain;
+ thegrain = getbytes( sizeof(t_scramble_grain));
+ thegrain->L = NULL;
+ thegrain->R = NULL;
+ thegrain->size = 0;
+ thegrain->next = NULL;
+ return (thegrain);
+}
+
+
+static t_scramble_grain* scramble_tilde_getgrain(t_scramble_grain* firstgrain, int n){
+ t_scramble_grain* thegrain = firstgrain;
+ while (n--){
+ if (thegrain->next){
+ thegrain = thegrain->next;
+ }else
+ return (NULL);
+ }
+ return (thegrain);
+}
+
+static int scramble_tilde_getsomegrain(t_scramble_grain* firstgrain,int g){
+ t_scramble_grain* thegrain ;
+ int r;
+ do{
+ r = rand() % g;
+ thegrain = scramble_tilde_getgrain(firstgrain, r);
+ }while (thegrain->size == 0);
+ return (r);
+}
+
+static void scramble_tilde_grainbuf(t_scramble_grain* grain, int c, int n){
+ if (!grain->size)
+ grain->L = getbytes(n * sizeof(t_float));
+ else
+ grain->L = resizebytes(grain->L, grain->size * sizeof(t_float), n * sizeof(t_float));
+
+ if (c == 2){
+ if (!grain->size)
+ grain->R = getbytes(n * sizeof(t_float));
+ else
+ grain->R = resizebytes(grain->R, grain->size * sizeof(t_float), n * sizeof(t_float));
+ }
+ grain->size = n;
+}
+
+static void scramble_tilde_freegrain(t_scramble_grain* grain, int c){
+ if (grain->size){
+ freebytes(grain->L, grain->size * sizeof(t_float));
+ if (c == 2) freebytes(grain->R, grain->size * sizeof(t_float));
+ grain->size = 0;
+ grain->next = NULL;
+ }
+}
+
+
+t_int *scramble_tilde_perform(t_int *w)
+{
+ t_scramble_tilde* x = (t_scramble_tilde*)(w[1]);
+ int i;
+ int erg=0;
+ int n;
+ t_float val, valL, valR, killval;
+
+ t_float* out[x->x_channels];
+ t_float* in[x->x_channels];
+
+ float n_factor, frac, a, b, c, d, cminusb;
+ int index;
+ float *fp;
+ t_atom at[2];
+
+ /* anything changed?*/
+ if (x->flush){
+ int i = x->grains;
+ x->flush = 0;
+ x->gotagrain = 0;
+ while (i--)
+ scramble_tilde_grainbuf(scramble_tilde_getgrain(x->firstgrain,i),x->x_channels,0);
+ }
+
+ if (x->newgrains){
+ int tmp = x->grains;
+ if (x->newgrains > x->grains){
+ x->workgrain = scramble_tilde_getgrain(x->firstgrain,x->grains - 1); /*-1 ???*/
+ tmp = x->newgrains;
+ x->newgrains -= x->grains;
+ x->grains = tmp;
+ while (x->newgrains--){
+ x->workgrain->next = scramble_tilde_newgrain();
+ x->workgrain = x->workgrain->next;
+ }
+ // post ("now %d grains",x->grains);
+ }else{
+ if (x->newgrains < x->grains){
+ t_scramble_grain* tmpgrain;
+
+ x->grains = x->newgrains;
+ x->workgrain = scramble_tilde_getgrain(x->firstgrain,x->grains - 1);
+
+ /* delete old grains */
+ while (x->workgrain->next){
+ tmpgrain = x->workgrain->next;
+ scramble_tilde_freegrain(x->workgrain,x->x_channels);
+ x->workgrain = tmpgrain;
+ }
+
+ /* reset readpointer if needed*/
+ if (x->r_grain >= x->grains){
+ x->r_grain = 0;
+ x->grain_r = -1;
+ }
+// post ("now %d grains",x->grains);
+ }
+ }
+ x->newgrains=0;
+ }
+
+ if ((x->ring->size > x->x_n) || (x->ring->size < x->x_n) ){
+// post ("scramble~: new size for ringbuffer:%d samples, %d channels, oldsize:%d",x->x_n,x->x_channels,x->ring->size);
+ scramble_tilde_grainbuf(x->ring, x->x_channels ,x->x_n);
+ x->x_n = x->ring->size;
+ x->dist = 0;
+ x->lowptr = x->r_d;
+ x->lastlowptr = -1;
+ x->lowval = x->lowborder;
+ }
+
+ for (i = 0; i < x->x_channels ;i++)
+ in[i] = (t_float *)(w[2 + i]);
+
+ for (i = 0;i < x->x_channels ;i++)
+ out[i] = (t_float *)(w[2 + x->x_channels + i]);
+
+ n = (int)(w[2 + x->x_channels * 2]);/*number of samples*/
+// post ("n:%d",n);
+
+ while (n--){
+ /*read from input*/
+ if (++x->r_d > x->x_n){
+ x->r_d = 0;
+ }
+ valL = *(t_float*)(x->ring->L + x->r_d) = *in[0]++;
+ if (valL < 0) valL *= -1;
+ if (x->x_channels == 2){
+ valR = *(t_float*)(x->ring->R + x->r_d) = *in[1]++;
+ if (valR < 0) valR *= -1;
+ val = valL + valR / 2.0;
+ if (valL > x->hival){
+ x->hiptr = x->r_d;
+ x->hival = valL;
+ }
+ if (valR > x->hival){
+ x->hiptr = x->r_d;
+ x->hival = valR;
+ }
+ }else {
+ val = valL;
+ if (valL > x->hival){
+ x->hiptr = x->r_d;
+ x->hival = valL;
+ }
+ }
+
+// if (val < 0) val *= -1;
+
+ x->valsum += val;
+// if (x->valsumcount++ > x->mindist * 10){
+ if (x->valsumcount++ && (x->r_d == 0)){
+ x->valavg = x->valsum / x->valsumcount;
+ x->valsumcount = 0;
+ x->valsum = 0;
+ if (x->autofollow && ( x->valavg > 0.003)) {
+ x->lowborder = x->valavg;
+// post ("lowborder = %f",x->lowborder);
+ }
+ }
+
+ if ((val < x->lowborder) && (x->prevval > x->lowborder)){
+ /* a new low-period */
+ x->dist = -1;
+ x->lowptr = x->r_d;
+ x->lowval = val;
+// post ("low");
+ }
+ if ((x->r_d + 1) == x->lastlowptr){
+ /* one round without a point to cut */
+ x->lastlowptr = -1;
+ x->lowval = x->lowborder;
+ x->hival = 0;
+// post ("lastlowptr: reset");
+ }
+
+ if (val < x->lowborder){x->dist++;}
+
+ if (val <= x->lowval) {
+ x->lowptr = x->r_d;
+ x->lowval = val;
+ /*found a point to cut*/
+ }
+
+ if ((val > x->lowborder) && (x->prevval < x->lowborder) && ( x->dist < x->mindist)){
+ /*too short low-period*/
+ x->dist = 0;
+ x->lowptr = x->r_d;
+ x->lowval = x->lowborder;
+// post ("low too short");
+ }
+
+ if ((val > x->lowborder) && (x->prevval < x->lowborder) && ( x->dist > x->mindist)){
+ /*found a low-period to cut */
+ if ((x->lastlowptr != -1) ){
+ int grainlen = 0;
+ int i = 0;
+ int wp = 1; /*first and last sample of grain should be 0.0*/
+
+ x->gotagrain = 1;
+ /* how long is the new grain */
+ if (x->lastlowptr > x->lowptr){
+ grainlen = x->x_n - x->lastlowptr + x->lowptr;
+ }else{
+ grainlen = x->lowptr - x->lastlowptr;
+ }
+
+ if (x->analize){
+ /*find and prepare the grain*/
+ if (++x->w_grain >= x->grains ) x->w_grain = 0;
+ x->workgrain = scramble_tilde_getgrain (x->firstgrain, x->w_grain);
+ scramble_tilde_grainbuf(x->workgrain, x->x_channels, grainlen + 2);
+
+ *(t_float*)(x->workgrain->L) = 0.0;
+ *(t_float*)(x->workgrain->L + x->workgrain->size -1) = 0.0;
+ if (x->x_channels == 2){
+ *(t_float*)(x->workgrain->R) = 0.0;
+ *(t_float*)(x->workgrain->R + x->workgrain->size -1) = 0.0;
+ }
+ x->workgrain->maximum = x->hival;
+
+ /*notify the world*/
+ SETFLOAT(at, grainlen);
+ SETFLOAT(at+1, x->w_grain + 1);
+ outlet_list(x->trigger1, 0, 2, at);
+
+ /*copy to the grain*/
+ i = x->lastlowptr;
+ while (grainlen--){
+ if (++i >= x->x_n) i = 0;
+ *(t_float*)(x->workgrain->L + wp ) = *(t_float*)(x->ring->L + i);
+ if (x->x_channels == 2)
+ *(t_float*)(x->workgrain->R + wp ) = *(t_float*)(x->ring->R + i);
+ wp++;
+ }
+ }/*end if analize*/
+// post ("copied: w_grain: %d",x->w_grain);
+ }/* end lastlowptr != -1*/
+ x->dist = 0;
+ x->hival = 0;
+ x->lastlowptr = x->lowptr;
+ }/*end found a low-period to cut */
+
+ x->prevval = val;
+ }/*end while n-- (read from input)*/
+
+
+/*--------------------playback--------------*/
+ n = (int)(w[2 + x->x_channels * 2]);/*number of samples*/
+
+ x->workgrain = scramble_tilde_getgrain (x->firstgrain, x->r_grain);
+ if (x->normalize && x->workgrain) n_factor = x->normalize / x->workgrain->maximum;
+ else n_factor = 1;
+
+ while (n--){
+ int wgs;
+ if (x->workgrain) wgs = x->workgrain->size - 2;
+ else wgs = 0;
+ if (( (x->grain_r >= wgs) || (x->grain_r < 1) || (x->workgrain == NULL) ) && x->play && x->gotagrain){
+ if (x->playmode < 2){
+ x->r_grain = scramble_tilde_getsomegrain(x->firstgrain, x->grains);
+ x->workgrain = scramble_tilde_getgrain (x->firstgrain, x->r_grain);
+ }else{
+ if (x->n_grain == -1){
+ x->play = 0;
+ x->r_grain = 0;
+ x->workgrain = NULL;
+ }else{
+ x->r_grain = x->n_grain;
+ x->workgrain = scramble_tilde_getgrain (x->firstgrain, x->r_grain);
+ x->n_grain = -1;
+ if ((x->r_grain == x->w_grain) || (x->workgrain == NULL)){
+ x->play = 0;
+ x->r_grain = 0;
+ x->workgrain = NULL;
+ } else if (!x->workgrain->size){
+ x->play = 0;
+ x->r_grain = 0;
+ x->workgrain = NULL;
+ }
+ }
+ }/*end if playmode < 2*/
+
+ if (x->workgrain){
+ if (((rand() % 200) / 100.0 - 1.0 ) < x->dir){
+ x->current_dir = 1;
+ x->grain_r = 1;
+ }
+ else{
+ x->current_dir = -1;
+ x->grain_r = x->workgrain->size -3;
+ }
+
+ if ( ( (x->autopitch >= 1.) && (x->semitones) ) || ( (x->autopitch) && (! x->semitones) ) ){
+ if (x->semitones){
+ int ap = (int)x->autopitch;
+ int rauf = 0;
+ int count ;
+
+ if (rand() % 2 == 1){ rauf = 1;}
+/* post ("rauf:%d",rauf); */
+
+ x->actual_pitch = x->pitch;
+
+ for (count = (rand() % ap); count >= 0; count--){
+ /*1.05946 = 12te wurzel aus 2 */
+ if (rauf){
+ x->actual_pitch = x->actual_pitch * 1.05946;
+ }else{
+ x->actual_pitch = x->actual_pitch / 1.05946;
+ }
+ }
+ }else{
+ if (((rand() % 200) / 100.0 - 1.0 ) > 0){
+ x->actual_pitch = x->pitch + x->pitch * ((rand() % 100 ) / 100.0 * x->autopitch);
+ }else{
+ x->actual_pitch = x->pitch - x->pitch / ((rand() % 100 ) / 100.0 * x->autopitch);
+ }
+ }/*end if semitones*/
+ } else {
+ x->actual_pitch = x->pitch;
+ }/* end if autopitch*/
+
+/* post ("x->actual_pitch:%f, x->autopitch:%f",x->actual_pitch,x->autopitch); */
+
+ if (x->normalize) n_factor = x->normalize / x->workgrain->maximum;
+ else n_factor = 1;
+
+ SETFLOAT(at, (x->workgrain->size - 2) / x->actual_pitch);
+ SETFLOAT(at+1, x->r_grain + 1);
+ outlet_list(x->trigger2, 0, 2, at);
+
+ }/*end if workgrain !=NULL */
+ }/* end finding a new grain*/
+
+ if (x->play && x->gotagrain){
+ /*write graincontent to output*/
+ /* 4 point interpolation taken from ../src/d_array.c tabread4~ */
+ index = x->grain_r;
+ if (index < 1)
+ index = 1, frac = 0;
+ else if (index > x->workgrain->size - 3)
+ index = x->workgrain->size - 3, frac = 1;
+ else
+ frac = x->grain_r - index;
+
+ fp = (t_float*)(x->workgrain->L + index);
+ a = fp[-1];
+ b = fp[0];
+ c = fp[1];
+ d = fp[2];
+
+ cminusb = c-b;
+ *out[0]++ = (b + frac * (
+ cminusb - 0.5f * (frac-1.) * (
+ (a - d + 3.0f * cminusb) * frac + (b - a - cminusb)
+ )
+ )) * n_factor;
+
+ if (x->x_channels == 2){
+ fp = (t_float*)(x->workgrain->R + index);
+ a = fp[-1];
+ b = fp[0];
+ c = fp[1];
+ d = fp[2];
+ cminusb = c-b;
+ *out[1]++ = (b + frac * (
+ cminusb - 0.5f * (frac-1.) * (
+ (a - d + 3.0f * cminusb) * frac + (b - a - cminusb)
+ )
+ )) * n_factor;
+ }
+ x->grain_r += x->current_dir * x->actual_pitch;
+ }else/* if play*/{
+ *out[0]++ = 0;
+ if (x->x_channels == 2)
+ *out[1]++ = 0;
+ }/*end if play */
+ }/*end while n-- */
+ return (w + x->x_channels * 2 + 3);
+}
+
+static void scramble_tilde_dsp(t_scramble_tilde *x, t_signal **sp)
+{
+ switch (x->x_channels) {
+ case 1:
+ dsp_add(scramble_tilde_perform, 4, x, sp[0]->s_vec,
+ sp[1]->s_vec, sp[0]->s_n);
+// post ("1 channel");
+ break;
+ case 2:
+ dsp_add(scramble_tilde_perform, 6, x, sp[0]->s_vec,
+ sp[1]->s_vec,sp[2]->s_vec, sp[3]->s_vec, sp[0]->s_n);
+// post ("2 channels");
+ break;
+ }
+}
+
+
+static void scramble_tilde_free(t_scramble_tilde *x){
+ int n = x->grains - 1;
+ while (n--){
+ scramble_tilde_freegrain (scramble_tilde_getgrain(x->firstgrain,n),x->x_channels);
+ scramble_tilde_freegrain (x->ring,x->x_channels);
+ }
+}
+
+
+static void *scramble_tilde_new(t_floatarg c,t_floatarg b)
+{
+ t_scramble_tilde *x = (t_scramble_tilde *)pd_new(scramble_tilde_class);
+ int i;
+// x->bufL = NULL;
+// x->bufR = NULL;
+ x->x_channels = (t_int)c;
+ if (x->x_channels > 2) {
+ x->x_channels = 2;
+ post ("maximum: 2 channels");
+ }
+ if (x->x_channels < 1) x->x_channels = 1;
+
+ outlet_new(&x->x_obj, gensym("signal"));
+ if (x->x_channels == 2){
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ outlet_new(&x->x_obj, gensym("signal"));
+ }
+
+ x->trigger1 = outlet_new(&x->x_obj, &s_float);
+ x->trigger2 = outlet_new(&x->x_obj, &s_float);
+ x->dir = 1;
+ x->pitch = 1;
+ x->actual_pitch = 1;
+ x->autopitch = 0;
+ x->semitones = 1;
+ x->autofollow = 1;
+ x->playmode = 1;
+ x->normalize = 0;
+ x->analize = 1;
+ x->flush = 0;
+ x->x_n = (int)b;
+ if (x->x_n >882000 ){x->x_n = 882000;}
+ if (x->x_n < 88200 ){x->x_n = 88200;}
+/* x->rR = x->rL = x->wR = x->wL = NULL;*/
+ x->lowptr = 0;
+ x->lastlowptr = x->r_d = x->grain_r = -1;
+ x->mindist = 1024;
+ x->lowborder = 0.35;
+// scramble_tilde_tempbuf(x,x->x_n);
+ x->ring = scramble_tilde_newgrain();
+ scramble_tilde_grainbuf(x->ring,x->x_channels,x->x_n);
+
+ x->valsum = x->valavg = x->valsumcount = 0;
+ x->valsummax = 1024;
+
+ /* the grains:*/
+ x->grains = 50;
+ x->r_grain = 0;
+ x->w_grain = x->n_grain = -1;
+ x->firstgrain = x->workgrain = scramble_tilde_newgrain();
+ for (i = 1;i < x->grains;i++){
+ x->workgrain->next = scramble_tilde_newgrain();
+ x->workgrain = x->workgrain->next;
+ }
+ return (x);
+}
+
+void *scramble_tilde_float(t_scramble_tilde* x, t_float n){
+ x->play = n;
+ if (x->playmode == 2) {
+ x->n_grain = (int)n - 1;
+ x->grain_r = -1;
+ }
+}
+
+void *scramble_tilde_buffer(t_scramble_tilde* x, t_float n){
+ if (n > 64) x->x_n = (int)n;
+// post ("buffersize now:%d",x->x_n);
+}
+
+void *scramble_tilde_threshold(t_scramble_tilde* x, t_float t){
+ if (t >0) {
+ x->lowborder = t;
+ x->autofollow = 0;
+ }else{
+ post ("threshold must be a positive value (0.1 - 0.8 makes sense)");
+ }
+
+}
+
+void *scramble_tilde_grains(t_scramble_tilde* x, t_float g){
+ if ((g > 1) && (g < 2048) ) x->newgrains = (int)g;
+ else post ("scramble~: minimum # of grains must be 2 an maximum # is 2048");
+}
+
+void scramble_tilde_mindist(t_scramble_tilde* x, t_float t){
+ if ((t > 0) && (t < x->x_n)) x->mindist = (int)t;
+ else post ("scramble~: minimum distance must be positive value lower than buffersize");
+}
+
+void scramble_tilde_direction(t_scramble_tilde* x, t_float d){
+ if (d > 1) d = 1;
+ if (d < -1) d = -1;
+ x->dir = d;
+}
+
+void scramble_tilde_autofollow(t_scramble_tilde* x){
+ x->autofollow = 1;
+}
+
+void scramble_tilde_pitch(t_scramble_tilde* x, t_float p){
+ if (p > 0) x->pitch = p;
+ else post ("scramble~: pitch must be > 0");
+}
+
+void scramble_tilde_autopitch(t_scramble_tilde* x, t_float p){
+ x->autopitch = p;
+}
+
+void scramble_tilde_semitones(t_scramble_tilde* x, t_float p){
+ x->semitones = (int)p;
+}
+
+
+void scramble_tilde_normalize(t_scramble_tilde* x, t_float n){
+ x->normalize = n;
+}
+
+void scramble_tilde_analize(t_scramble_tilde* x, t_float f){
+ x->analize = f;
+}
+
+void scramble_tilde_flush(t_scramble_tilde* x){
+ x->flush = 1;
+}
+
+void scramble_tilde_playmode(t_scramble_tilde* x, t_float p){
+ x->playmode = (int)p;
+ if (x->playmode < 0) x->playmode = 0;
+ if (x->playmode < 1) x->playmode = 2;
+ switch (x->playmode){
+ case 0: post ("scramble~: playmode off");
+ break;
+ case 1: post ("scramble~: active playmode");
+ break;
+ case 2: post ("scramble~: passive playmode");
+ break;
+ default: post ("scramble~: invalid playmode");
+ }
+}
+
+
+void scramble_tilde_setup(void)
+{
+ scramble_tilde_class = class_new(gensym("scramble~"), (t_newmethod) scramble_tilde_new, 0,
+ sizeof(t_scramble_tilde), 0, A_DEFFLOAT,A_DEFFLOAT, 0);
+ class_addfloat(scramble_tilde_class,scramble_tilde_float);
+ class_addmethod(scramble_tilde_class, nullfn, gensym("signal"), 0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_dsp, gensym("dsp"), 0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_buffer, gensym("buffer"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_threshold, gensym("threshold"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_grains, gensym("grains"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_mindist, gensym("min_length"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_direction, gensym("direction"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_autofollow, gensym("autofollow"),0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_pitch, gensym("pitch"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_autopitch, gensym("autopitch"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_semitones, gensym("semitones"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_flush, gensym("flush"), 0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_normalize, gensym("normalize"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_analize, gensym("analize"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_playmode, gensym("playmode"), A_DEFFLOAT,0);
+}
diff --git a/scramble~.c.save b/scramble~.c.save
new file mode 100644
index 0000000..f4957a7
--- /dev/null
+++ b/scramble~.c.save
@@ -0,0 +1,634 @@
+#include "m_pd.h"
+#include "ext13.h"
+#include <sys/types.h>
+#include <string.h>
+#include <sys/errno.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+
+
+
+/* ------------------------ scramble_tilde~ ----------------------------- */
+
+static t_class *scramble_tilde_class;
+
+typedef struct _scramble_grain
+{
+ t_float* L;
+ t_float* R;
+ int size;
+ t_float maximum;
+ struct _scramble_grain *next;
+}t_scramble_grain;
+
+typedef struct _scramble_tilde
+{
+ t_object x_obj;
+ int x_n;
+ t_int x_channels;
+ t_float play, analize;
+ t_float dir, current_dir, pitch, actual_pitch, grain_r, autopitch;
+ t_float valsum, valavg;
+ int valsumcount, valsummax;
+ int autofollow, playmode, semitones;
+ t_scramble_grain *firstgrain;
+ t_scramble_grain *workgrain;
+ t_scramble_grain *ring;
+ int grains, newgrains, w_grain, r_grain, n_grain, gotagrain, flush;
+ int r_d, w_d, dist, mindist, lowptr, hiptr, lastlowptr;
+ t_float lowval, hival, prevval, lowborder, normalize;
+ int nsamples;
+ t_outlet *trigger1;
+ t_outlet *trigger2;
+} t_scramble_tilde;
+
+
+/* grain functions*/
+static t_scramble_grain* scramble_tilde_newgrain(){
+ t_scramble_grain* thegrain;
+ thegrain = getbytes( sizeof(t_scramble_grain));
+ thegrain->L = NULL;
+ thegrain->R = NULL;
+ thegrain->size = 0;
+ thegrain->next = NULL;
+ return (thegrain);
+}
+
+
+static t_scramble_grain* scramble_tilde_getgrain(t_scramble_grain* firstgrain, int n){
+ t_scramble_grain* thegrain = firstgrain;
+ while (n--){
+ if (thegrain->next){
+ thegrain = thegrain->next;
+ }else
+ return (NULL);
+ }
+ return (thegrain);
+}
+
+static int scramble_tilde_getsomegrain(t_scramble_grain* firstgrain,int g){
+ t_scramble_grain* thegrain ;
+ int r;
+ do{
+ r = rand() % g;
+ thegrain = scramble_tilde_getgrain(firstgrain, r);
+ }while (thegrain->size == 0);
+ return (r);
+}
+
+static void scramble_tilde_grainbuf(t_scramble_grain* grain, int c, int n){
+ if (!grain->size)
+ grain->L = getbytes(n * sizeof(t_float));
+ else
+ grain->L = resizebytes(grain->L, grain->size * sizeof(t_float), n * sizeof(t_float));
+
+ if (c == 2){
+ if (!grain->size)
+ grain->R = getbytes(n * sizeof(t_float));
+ else
+ grain->R = resizebytes(grain->R, grain->size * sizeof(t_float), n * sizeof(t_float));
+ }
+ grain->size = n;
+}
+
+static void scramble_tilde_freegrain(t_scramble_grain* grain, int c){
+ if (grain->size){
+ freebytes(grain->L, grain->size * sizeof(t_float));
+ if (c == 2) freebytes(grain->R, grain->size * sizeof(t_float));
+ grain->size = 0;
+ grain->next = NULL;
+ }
+}
+
+
+t_int *scramble_tilde_perform(t_int *w)
+{
+ t_scramble_tilde* x = (t_scramble_tilde*)(w[1]);
+ int i;
+ int erg=0;
+ int n;
+ t_float val, valL, valR, killval;
+
+ t_float* out[x->x_channels];
+ t_float* in[x->x_channels];
+
+ float n_factor, frac, a, b, c, d, cminusb;
+ int index;
+ float *fp;
+ t_atom at[2];
+
+ /* anything changed?*/
+ if (x->flush){
+ int i = x->grains;
+ x->flush = 0;
+ x->gotagrain = 0;
+ while (i--)
+ scramble_tilde_grainbuf(scramble_tilde_getgrain(x->firstgrain,i),x->x_channels,0);
+ }
+
+ if (x->newgrains){
+ int tmp = x->grains;
+ if (x->newgrains > x->grains){
+ x->workgrain = scramble_tilde_getgrain(x->firstgrain,x->grains - 1); /*-1 ???*/
+ tmp = x->newgrains;
+ x->newgrains -= x->grains;
+ x->grains = tmp;
+ while (x->newgrains--){
+ x->workgrain->next = scramble_tilde_newgrain();
+ x->workgrain = x->workgrain->next;
+ }
+ // post ("now %d grains",x->grains);
+ }else{
+ if (x->newgrains < x->grains){
+ t_scramble_grain* tmpgrain;
+
+ x->grains = x->newgrains;
+ x->workgrain = scramble_tilde_getgrain(x->firstgrain,x->grains - 1);
+
+ /* delete old grains */
+ while (x->workgrain->next){
+ tmpgrain = x->workgrain->next;
+ scramble_tilde_freegrain(x->workgrain,x->x_channels);
+ x->workgrain = tmpgrain;
+ }
+
+ /* reset readpointer if needed*/
+ if (x->r_grain >= x->grains){
+ x->r_grain = 0;
+ x->grain_r = -1;
+ }
+// post ("now %d grains",x->grains);
+ }
+ }
+ x->newgrains=0;
+ }
+
+ if ((x->ring->size > x->x_n) || (x->ring->size < x->x_n) ){
+// post ("scramble~: new size for ringbuffer:%d samples, %d channels, oldsize:%d",x->x_n,x->x_channels,x->ring->size);
+ scramble_tilde_grainbuf(x->ring, x->x_channels ,x->x_n);
+ x->x_n = x->ring->size;
+ x->dist = 0;
+ x->lowptr = x->r_d;
+ x->lastlowptr = -1;
+ x->lowval = x->lowborder;
+ }
+
+ for (i = 0; i < x->x_channels ;i++)
+ in[i] = (t_float *)(w[2 + i]);
+
+ for (i = 0;i < x->x_channels ;i++)
+ out[i] = (t_float *)(w[2 + x->x_channels + i]);
+
+ n = (int)(w[2 + x->x_channels * 2]);/*number of samples*/
+// post ("n:%d",n);
+
+ while (n--){
+ /*read from input*/
+ if (++x->r_d > x->x_n){
+ x->r_d = 0;
+ }
+ valL = *(t_float*)(x->ring->L + x->r_d) = *in[0]++;
+ if (valL < 0) valL *= -1;
+ if (x->x_channels == 2){
+ valR = *(t_float*)(x->ring->R + x->r_d) = *in[1]++;
+ if (valR < 0) valR *= -1;
+ val = valL + valR / 2.0;
+ if (valL > x->hival){
+ x->hiptr = x->r_d;
+ x->hival = valL;
+ }
+ if (valR > x->hival){
+ x->hiptr = x->r_d;
+ x->hival = valR;
+ }
+ }else {
+ val = valL;
+ if (valL > x->hival){
+ x->hiptr = x->r_d;
+ x->hival = valL;
+ }
+ }
+
+// if (val < 0) val *= -1;
+
+ x->valsum += val;
+// if (x->valsumcount++ > x->mindist * 10){
+ if (x->valsumcount++ && (x->r_d == 0)){
+ x->valavg = x->valsum / x->valsumcount;
+ x->valsumcount = 0;
+ x->valsum = 0;
+ if (x->autofollow && ( x->valavg > 0.003)) {
+ x->lowborder = x->valavg;
+// post ("lowborder = %f",x->lowborder);
+ }
+ }
+
+ if ((val < x->lowborder) && (x->prevval > x->lowborder)){
+ /* a new low-period */
+ x->dist = -1;
+ x->lowptr = x->r_d;
+ x->lowval = val;
+// post ("low");
+ }
+ if ((x->r_d + 1) == x->lastlowptr){
+ /* one round without a point to cut */
+ x->lastlowptr = -1;
+ x->lowval = x->lowborder;
+ x->hival = 0;
+// post ("lastlowptr: reset");
+ }
+
+ if (val < x->lowborder){x->dist++;}
+
+ if (val <= x->lowval) {
+ x->lowptr = x->r_d;
+ x->lowval = val;
+ /*found a point to cut*/
+ }
+
+ if ((val > x->lowborder) && (x->prevval < x->lowborder) && ( x->dist < x->mindist)){
+ /*too short low-period*/
+ x->dist = 0;
+ x->lowptr = x->r_d;
+ x->lowval = x->lowborder;
+// post ("low too short");
+ }
+
+ if ((val > x->lowborder) && (x->prevval < x->lowborder) && ( x->dist > x->mindist)){
+ /*found a low-period to cut */
+ if ((x->lastlowptr != -1) ){
+ int grainlen = 0;
+ int i = 0;
+ int wp = 1; /*first and last sample of grain should be 0.0*/
+
+ x->gotagrain = 1;
+ /* how long is the new grain */
+ if (x->lastlowptr > x->lowptr){
+ grainlen = x->x_n - x->lastlowptr + x->lowptr;
+ }else{
+ grainlen = x->lowptr - x->lastlowptr;
+ }
+
+ if (x->analize){
+ /*find and prepare the grain*/
+ if (++x->w_grain >= x->grains ) x->w_grain = 0;
+ x->workgrain = scramble_tilde_getgrain (x->firstgrain, x->w_grain);
+ scramble_tilde_grainbuf(x->workgrain, x->x_channels, grainlen + 2);
+
+ *(t_float*)(x->workgrain->L) = 0.0;
+ *(t_float*)(x->workgrain->L + x->workgrain->size -1) = 0.0;
+ if (x->x_channels == 2){
+ *(t_float*)(x->workgrain->R) = 0.0;
+ *(t_float*)(x->workgrain->R + x->workgrain->size -1) = 0.0;
+ }
+ x->workgrain->maximum = x->hival;
+
+ /*notify the world*/
+ SETFLOAT(at, grainlen);
+ SETFLOAT(at+1, x->w_grain + 1);
+ outlet_list(x->trigger1, 0, 2, at);
+
+ /*copy to the grain*/
+ i = x->lastlowptr;
+ while (grainlen--){
+ if (++i >= x->x_n) i = 0;
+ *(t_float*)(x->workgrain->L + wp ) = *(t_float*)(x->ring->L + i);
+ if (x->x_channels == 2)
+ *(t_float*)(x->workgrain->R + wp ) = *(t_float*)(x->ring->R + i);
+ wp++;
+ }
+ }/*end if analize*/
+// post ("copied: w_grain: %d",x->w_grain);
+ }/* end lastlowptr != -1*/
+ x->dist = 0;
+ x->hival = 0;
+ x->lastlowptr = x->lowptr;
+ }/*end found a low-period to cut */
+
+ x->prevval = val;
+ }/*end while n-- (read from input)*/
+
+
+/*--------------------playback--------------*/
+ n = (int)(w[2 + x->x_channels * 2]);/*number of samples*/
+
+ x->workgrain = scramble_tilde_getgrain (x->firstgrain, x->r_grain);
+ if (x->normalize && x->workgrain) n_factor = x->normalize / x->workgrain->maximum;
+ else n_factor = 1;
+
+ while (n--){
+ int wgs;
+ if (x->workgrain) wgs = x->workgrain->size - 2;
+ else wgs = 0;
+ if (( (x->grain_r >= wgs) || (x->grain_r < 1) || (x->workgrain == NULL) ) && x->play && x->gotagrain){
+ if (x->playmode < 2){
+ x->r_grain = scramble_tilde_getsomegrain(x->firstgrain, x->grains);
+ x->workgrain = scramble_tilde_getgrain (x->firstgrain, x->r_grain);
+ }else{
+ if (x->n_grain == -1){
+ x->play = 0;
+ x->r_grain = 0;
+ x->workgrain = NULL;
+ }else{
+ x->r_grain = x->n_grain;
+ x->workgrain = scramble_tilde_getgrain (x->firstgrain, x->r_grain);
+ x->n_grain = -1;
+ if ((x->r_grain == x->w_grain) || (x->workgrain == NULL)){
+ x->play = 0;
+ x->r_grain = 0;
+ x->workgrain = NULL;
+ } else if (!x->workgrain->size){
+ x->play = 0;
+ x->r_grain = 0;
+ x->workgrain = NULL;
+ }
+ }
+ }/*end if playmode < 2*/
+
+ if (x->workgrain){
+ if (((rand() % 200) / 100.0 - 1.0 ) < x->dir){
+ x->current_dir = 1;
+ x->grain_r = 1;
+ }
+ else{
+ x->current_dir = -1;
+ x->grain_r = x->workgrain->size -3;
+ }
+
+ if ( ( (x->autopitch >= 1.) && (x->semitones) ) || ( (x->autopitch) && (! x->semitones) ) ){
+ if (x->semitones){
+ int ap = (int)x->autopitch;
+ int rauf = 0;
+ int count ;
+
+ if (rand() % 2 == 1){ rauf = 1;}
+/* post ("rauf:%d",rauf); */
+
+ x->actual_pitch = x->pitch;
+
+ for (count = (rand() % ap); count >= 0; count--){
+ /*1.05946 = 12te wurzel aus 2 */
+ if (rauf){
+ x->actual_pitch = x->actual_pitch * 1.05946;
+ }else{
+ x->actual_pitch = x->actual_pitch / 1.05946;
+ }
+ }
+ }else{
+ if (((rand() % 200) / 100.0 - 1.0 ) > 0){
+ x->actual_pitch = x->pitch + x->pitch * ((rand() % 100 ) / 100.0 * x->autopitch);
+ }else{
+ x->actual_pitch = x->pitch - x->pitch / ((rand() % 100 ) / 100.0 * x->autopitch);
+ }
+ }/*end if semitones*/
+ } else {
+ x->actual_pitch = x->pitch;
+ }/* end if autopitch*/
+
+/* post ("x->actual_pitch:%f, x->autopitch:%f",x->actual_pitch,x->autopitch); */
+
+ if (x->normalize) n_factor = x->normalize / x->workgrain->maximum;
+ else n_factor = 1;
+
+ SETFLOAT(at, (x->workgrain->size - 2) / x->actual_pitch);
+ SETFLOAT(at+1, x->r_grain + 1);
+ outlet_list(x->trigger2, 0, 2, at);
+
+ }/*end if workgrain !=NULL */
+ }/* end finding a new grain*/
+
+ if (x->play && x->gotagrain){
+ /*write graincontent to output*/
+ /* 4 point interpolation taken from ../src/d_array.c tabread4~ */
+ index = x->grain_r;
+ if (index < 1)
+ index = 1, frac = 0;
+ else if (index > x->workgrain->size - 3)
+ index = x->workgrain->size - 3, frac = 1;
+ else
+ frac = x->grain_r - index;
+
+ fp = (t_float*)(x->workgrain->L + index);
+ a = fp[-1];
+ b = fp[0];
+ c = fp[1];
+ d = fp[2];
+
+ cminusb = c-b;
+ *out[0]++ = (b + frac * (
+ cminusb - 0.5f * (frac-1.) * (
+ (a - d + 3.0f * cminusb) * frac + (b - a - cminusb)
+ )
+ )) * n_factor;
+
+ if (x->x_channels == 2){
+ fp = (t_float*)(x->workgrain->R + index);
+ a = fp[-1];
+ b = fp[0];
+ c = fp[1];
+ d = fp[2];
+ cminusb = c-b;
+ *out[1]++ = (b + frac * (
+ cminusb - 0.5f * (frac-1.) * (
+ (a - d + 3.0f * cminusb) * frac + (b - a - cminusb)
+ )
+ )) * n_factor;
+ }
+ x->grain_r += x->current_dir * x->actual_pitch;
+ }else/* if play*/{
+ *out[0]++ = 0;
+ if (x->x_channels == 2)
+ *out[1]++ = 0;
+ }/*end if play */
+ }/*end while n-- */
+ return (w + x->x_channels * 2 + 3);
+}
+
+static void scramble_tilde_dsp(t_scramble_tilde *x, t_signal **sp)
+{
+ switch (x->x_channels) {
+ case 1:
+ dsp_add(scramble_tilde_perform, 4, x, sp[0]->s_vec,
+ sp[1]->s_vec, sp[0]->s_n);
+// post ("1 channel");
+ break;
+ case 2:
+ dsp_add(scramble_tilde_perform, 6, x, sp[0]->s_vec,
+ sp[1]->s_vec,sp[2]->s_vec, sp[3]->s_vec, sp[0]->s_n);
+// post ("2 channels");
+ break;
+ }
+}
+
+
+static void scramble_tilde_free(t_scramble_tilde *x){
+ int n = x->grains - 1;
+ while (n--){
+ scramble_tilde_freegrain (scramble_tilde_getgrain(x->firstgrain,n),x->x_channels);
+ scramble_tilde_freegrain (x->ring,x->x_channels);
+ }
+}
+
+
+static void *scramble_tilde_new(t_floatarg c,t_floatarg b)
+{
+ t_scramble_tilde *x = (t_scramble_tilde *)pd_new(scramble_tilde_class);
+ int i;
+// x->bufL = NULL;
+// x->bufR = NULL;
+ x->x_channels = (t_int)c;
+ if (x->x_channels > 2) {
+ x->x_channels = 2;
+ post ("maximum: 2 channels");
+ }
+ if (x->x_channels < 1) x->x_channels = 1;
+
+ outlet_new(&x->x_obj, gensym("signal"));
+ if (x->x_channels == 2){
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ outlet_new(&x->x_obj, gensym("signal"));
+ }
+
+ x->trigger1 = outlet_new(&x->x_obj, &s_float);
+ x->trigger2 = outlet_new(&x->x_obj, &s_float);
+ x->dir = 1;
+ x->pitch = 1;
+ x->actual_pitch = 1;
+ x->autopitch = 0;
+ x->semitones = 1;
+ x->autofollow = 1;
+ x->playmode = 1;
+ x->normalize = 0;
+ x->analize = 1;
+ x->flush = 0;
+ x->x_n = (int)b;
+ if (x->x_n >882000 ){x->x_n = 882000;}
+ if (x->x_n < 88200 ){x->x_n = 88200;}
+/* x->rR = x->rL = x->wR = x->wL = NULL;*/
+ x->lowptr = 0;
+ x->lastlowptr = x->r_d = x->grain_r = -1;
+ x->mindist = 1024;
+ x->lowborder = 0.35;
+// scramble_tilde_tempbuf(x,x->x_n);
+ x->ring = scramble_tilde_newgrain();
+ scramble_tilde_grainbuf(x->ring,x->x_channels,x->x_n);
+
+ x->valsum = x->valavg = x->valsumcount = 0;
+ x->valsummax = 1024;
+
+ /* the grains:*/
+ x->grains = 50;
+ x->r_grain = 0;
+ x->w_grain = x->n_grain = -1;
+ x->firstgrain = x->workgrain = scramble_tilde_newgrain();
+ for (i = 1;i < x->grains;i++){
+ x->workgrain->next = scramble_tilde_newgrain();
+ x->workgrain = x->workgrain->next;
+ }
+ return (x);
+}
+
+void *scramble_tilde_float(t_scramble_tilde* x, t_float n){
+ x->play = n;
+ if (x->playmode == 2) x->n_grain = (int)n - 1;
+}
+
+void *scramble_tilde_buffer(t_scramble_tilde* x, t_float n){
+ if (n > 64) x->x_n = (int)n;
+// post ("buffersize now:%d",x->x_n);
+}
+
+void *scramble_tilde_threshold(t_scramble_tilde* x, t_float t){
+ if (t >0) {
+ x->lowborder = t;
+ x->autofollow = 0;
+ }else{
+ post ("threshold must be a positive value (0.1 - 0.8 makes sense)");
+ }
+
+}
+
+void *scramble_tilde_grains(t_scramble_tilde* x, t_float g){
+ if ((g > 1) && (g < 2048) ) x->newgrains = (int)g;
+ else post ("scramble~: minimum # of grains must be 2 an maximum # is 2048");
+}
+
+void scramble_tilde_mindist(t_scramble_tilde* x, t_float t){
+ if ((t > 0) && (t < x->x_n)) x->mindist = (int)t;
+ else post ("scramble~: minimum distance must be positive value lower than buffersize");
+}
+
+void scramble_tilde_direction(t_scramble_tilde* x, t_float d){
+ if (d > 1) d = 1;
+ if (d < -1) d = -1;
+ x->dir = d;
+}
+
+void scramble_tilde_autofollow(t_scramble_tilde* x){
+ x->autofollow = 1;
+}
+
+void scramble_tilde_pitch(t_scramble_tilde* x, t_float p){
+ if (p > 0) x->pitch = p;
+ else post ("scramble~: pitch must be > 0");
+}
+
+void scramble_tilde_autopitch(t_scramble_tilde* x, t_float p){
+ x->autopitch = p;
+}
+
+void scramble_tilde_semitones(t_scramble_tilde* x, t_float p){
+ x->semitones = (int)p;
+}
+
+
+void scramble_tilde_normalize(t_scramble_tilde* x, t_float n){
+ x->normalize = n;
+}
+
+void scramble_tilde_analize(t_scramble_tilde* x, t_float f){
+ x->analize = f;
+}
+
+void scramble_tilde_flush(t_scramble_tilde* x){
+ x->flush = 1;
+}
+
+void scramble_tilde_playmode(t_scramble_tilde* x, t_float p){
+ x->playmode = (int)p;
+ if (x->playmode < 0) x->playmode = 0;
+ if (x->playmode < 1) x->playmode = 2;
+ switch (x->playmode){
+ case 0: post ("scramble~: playmode off");
+ break;
+ case 1: post ("scramble~: active playmode");
+ break;
+ case 2: post ("scramble~: passive playmode");
+ break;
+ default: post ("scramble~: invalid playmode");
+ }
+}
+
+
+void scramble_tilde_setup(void)
+{
+ scramble_tilde_class = class_new(gensym("scramble~"), (t_newmethod) scramble_tilde_new, 0,
+ sizeof(t_scramble_tilde), 0, A_DEFFLOAT,A_DEFFLOAT, 0);
+ class_addfloat(scramble_tilde_class,scramble_tilde_float);
+ class_addmethod(scramble_tilde_class, nullfn, gensym("signal"), 0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_dsp, gensym("dsp"), 0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_buffer, gensym("buffer"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_threshold, gensym("threshold"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_grains, gensym("grains"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_mindist, gensym("min_length"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_direction, gensym("direction"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_autofollow, gensym("autofollow"),0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_pitch, gensym("pitch"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_autopitch, gensym("autopitch"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_semitones, gensym("semitones"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_flush, gensym("flush"), 0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_normalize, gensym("normalize"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_analize, gensym("analize"), A_DEFFLOAT,0);
+ class_addmethod(scramble_tilde_class, (t_method) scramble_tilde_playmode, gensym("playmode"), A_DEFFLOAT,0);
+}
diff --git a/send13.c b/send13.c
new file mode 100644
index 0000000..96007ca
--- /dev/null
+++ b/send13.c
@@ -0,0 +1,76 @@
+#include "m_pd.h"
+
+#include <string.h>
+#include <stdio.h>
+
+/* ------------------------- send13 ------------------------------ */
+/* this is pd's biultin send13 plus the hack for "set" messages */
+/* it's a pitty, but i don't know where this patch originally */
+/* came from, so i can'z give correct credits... */
+/* --------------------------------------------------------------- */
+
+
+static t_class *send13_class;
+
+typedef struct _send13
+{
+ t_object x_obj;
+ t_symbol *x_sym;
+} t_send13;
+
+static void send13_bang(t_send13 *x)
+{
+ if (x->x_sym->s_thing) pd_bang(x->x_sym->s_thing);
+}
+
+ static void send13_set(t_send13 *x, t_symbol *s)
+{
+ x->x_sym = s;
+}
+
+static void send13_float(t_send13 *x, t_float f)
+{
+ if (x->x_sym->s_thing) pd_float(x->x_sym->s_thing, f);
+}
+
+static void send13_symbol(t_send13 *x, t_symbol *s)
+{
+ if (x->x_sym->s_thing) pd_symbol(x->x_sym->s_thing, s);
+}
+
+static void send13_pointer(t_send13 *x, t_gpointer *gp)
+{
+ if (x->x_sym->s_thing) pd_pointer(x->x_sym->s_thing, gp);
+}
+
+static void send13_list(t_send13 *x, t_symbol *s, int argc, t_atom *argv)
+{
+ if (x->x_sym->s_thing) pd_list(x->x_sym->s_thing, s, argc, argv);
+}
+
+static void send13_anything(t_send13 *x, t_symbol *s, int argc, t_atom *argv)
+{
+ if (x->x_sym->s_thing) typedmess(x->x_sym->s_thing, s, argc, argv);
+}
+
+static void *send13_new(t_symbol *s)
+{
+ t_send13 *x = (t_send13 *)pd_new(send13_class);
+ x->x_sym = s;
+ return (x);
+}
+
+void send13_setup(void)
+{
+ send13_class = class_new(gensym("send13"), (t_newmethod)send13_new, 0,
+ sizeof(t_send13), 0, A_DEFSYM, 0);
+ class_addcreator((t_newmethod)send13_new, gensym("s13"), A_DEFSYM, 0);
+ class_sethelpsymbol(send13_class, gensym("ext13"));
+ class_addbang(send13_class, send13_bang);
+ class_addfloat(send13_class, send13_float);
+ class_addsymbol(send13_class, send13_symbol);
+ class_addpointer(send13_class, send13_pointer);
+ class_addlist(send13_class, send13_list);
+ class_addanything(send13_class, send13_anything);
+ class_addmethod(send13_class, (t_method)send13_set, gensym("set"), A_SYMBOL, 0);
+}
diff --git a/send13~.c b/send13~.c
new file mode 100644
index 0000000..4245b2d
--- /dev/null
+++ b/send13~.c
@@ -0,0 +1,66 @@
+/* Copyright (c) 1997-1999 Miller Puckette source modified by dieb13.
+* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* catch13~ ... = original objects with set-message for changing - bad hack - but works somehow*/
+
+#include "m_pd.h"
+#include "d_global13.h"
+
+#define DEFSENDVS 64 /* LATER get send to get this from canvas */
+
+/* ----------------------------- send13~ ----------------------------- */
+
+ void *sigsend13_new(t_symbol *s)
+{
+ t_sigsend13 *x = (t_sigsend13 *)pd_new(sigsend13_class);
+ if (!*s->s_name) s = gensym("send13~");
+ pd_bind(&x->x_obj.ob_pd, s);
+ x->x_sym = s;
+ x->x_n = DEFSENDVS;
+ x->x_vec = (float *)getbytes(DEFSENDVS * sizeof(float));
+ return (x);
+}
+
+ t_int *sigsend13_perform(t_int *w)
+{
+ t_float *in = (t_float *)(w[1]);
+ t_float *out = (t_float *)(w[2]);
+ int n = (int)(w[3]);
+ while (n--) *out++ = *in++;
+ return (w+4);
+}
+
+ void sigsend13_set(t_sigsend13 *x, t_symbol *s)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+ x->x_sym = s;
+ pd_bind(&x->x_obj.ob_pd, s);
+}
+
+
+ void sigsend13_dsp(t_sigsend13 *x, t_signal **sp)
+{
+ if (x->x_n == sp[0]->s_n)
+ dsp_add(sigsend13_perform, 3, sp[0]->s_vec, x->x_vec, sp[0]->s_n);
+ else error("sigsend13 %s: unexpected vector size", x->x_sym->s_name);
+}
+
+ void sigsend13_free(t_sigsend13 *x)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_sym);
+ freebytes(x->x_vec, x->x_n * sizeof(float));
+}
+
+void sigsend13_setup(void)
+{
+ sigsend13_class = class_new(gensym("send13~"), (t_newmethod)sigsend13_new,
+ (t_method)sigsend13_free, sizeof(t_sigsend13), 0, A_DEFSYM, 0);
+ class_addmethod(sigsend13_class, (t_method)sigsend13_set, gensym("set"),A_SYMBOL, 0);
+ class_sethelpsymbol(sigsend13_class, gensym("netio13~"));
+ class_sethelpsymbol(sigsend13_class, gensym("ext13"));
+ class_addcreator((t_newmethod)sigsend13_new, gensym("s13~"), A_DEFSYM, 0);
+ class_addmethod(sigsend13_class, nullfn, gensym("signal"), 0);
+ class_addmethod(sigsend13_class, (t_method)sigsend13_dsp, gensym("dsp"), 0);
+}
+
diff --git a/sfread.c b/sfread.c
new file mode 100644
index 0000000..ad78060
--- /dev/null
+++ b/sfread.c
@@ -0,0 +1,376 @@
+#include "m_pd.h"
+#include "g_canvas.h"
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+/* ------------------------ sfread~ ----------------------------- */
+
+#ifdef NT
+#define BINREADMODE "rb"
+#else
+#define BINREADMODE "r"
+#endif
+
+static t_class *sfread_class;
+
+
+typedef struct _sfread
+{
+ t_object x_obj;
+ void* x_mapaddr;
+ int x_fd;
+
+ t_int x_play;
+ t_int x_channels;
+ t_int x_size;
+ t_int x_loop;
+ t_float x_offset;
+ t_float x_skip;
+ t_float x_speed;
+
+ t_glist * x_glist;
+} t_sfread;
+
+
+void sfread_open(t_sfread *x,t_symbol *filename)
+{
+ struct stat fstate;
+ char fname[MAXPDSTRING];
+
+ canvas_makefilename(glist_getcanvas(x->x_glist), filename->s_name,
+ fname, MAXPDSTRING);
+
+
+ /* close the old file */
+
+ if (x->x_mapaddr) munmap(x->x_mapaddr,x->x_size);
+ if (x->x_fd >= 0) close(x->x_fd);
+
+ if ((x->x_fd = open(fname,O_RDONLY)) < 0)
+ {
+ error("can't open %s",fname);
+ return;
+ }
+
+ /* get the size */
+
+ fstat(x->x_fd,&fstate);
+ x->x_size = fstate.st_size;
+
+ /* map the file into memory */
+
+ if (!(x->x_mapaddr = mmap(NULL,x->x_size,PROT_READ,MAP_PRIVATE,x->x_fd,0)))
+ {
+ error("can't mmap %s",fname);
+ return;
+ }
+}
+
+#define MAX_CHANS 4
+
+static t_int *sfread_perform(t_int *w)
+{
+ t_sfread* x = (t_sfread*)(w[1]);
+ short* buf = x->x_mapaddr;
+/* t_float *in = (t_float *)(w[2]); will we need this (indexing) ?*/
+ int c = x->x_channels;
+
+ t_float offset = x->x_offset*c;
+ t_float speed = x->x_speed;
+ int i,n;
+ t_float* out[MAX_CHANS];
+
+ for (i=0;i<c;i++)
+ out[i] = (t_float *)(w[3+i]);
+ n = (int)(w[3+c]);
+
+ /* loop */
+
+ if (x->x_skip*c > x->x_size/sizeof(short))
+ x->x_skip = x->x_size/sizeof(short);
+
+ if (offset + n*c*speed > x->x_size/sizeof(short)) {
+ if (!x->x_loop)
+ x->x_play=0;
+ else {
+ offset = x->x_skip;
+ }
+ }
+
+ if (offset + n*c*speed < 0) {
+ if (!x->x_loop)
+ x->x_play=0;
+ else {
+ offset = x->x_size/(sizeof(short));
+ }
+ }
+
+
+
+ if (x->x_play && x->x_mapaddr) {
+ float aoff = (((int)offset)>>1)<<1;
+ while (n--) {
+ for (i=0;i<c;i++) {
+ *out[i]++ = *(buf+(int)aoff+i)/32768.;
+ }
+ offset+=speed*c;
+ aoff = (((int)offset)>>1)<<1;
+ }
+ }
+ else {
+ while (n--) {
+ for (i=0;i<c;i++)
+ *out[i]++ = 0.;
+ }
+ }
+ x->x_offset = offset/c; /* this should always be integer !! */
+ return (w+c+4);
+}
+
+
+static void sfread_float(t_sfread *x, t_floatarg f)
+{
+ int t = f;
+ if (t) {
+ x->x_play=1;
+ }
+ else {
+ x->x_play=0;
+ }
+
+}
+
+static void sfread_loop(t_sfread *x, t_floatarg f)
+{
+ x->x_loop = f;
+}
+
+
+
+
+static void sfread_bang(t_sfread* x)
+{
+ x->x_offset = x->x_skip*x->x_channels;
+ sfread_float(x,1.0);
+}
+
+
+static void sfread_dsp(t_sfread *x, t_signal **sp)
+{
+/* post("sfread: dsp"); */
+ switch (x->x_channels) {
+ case 1:
+ dsp_add(sfread_perform, 4, x, sp[0]->s_vec,
+ sp[1]->s_vec, sp[0]->s_n);
+ break;
+ case 2:
+ dsp_add(sfread_perform, 5, x, sp[0]->s_vec,
+ sp[1]->s_vec,sp[2]->s_vec, sp[0]->s_n);
+ break;
+ case 4:
+ dsp_add(sfread_perform, 6, x, sp[0]->s_vec,
+ sp[1]->s_vec,sp[2]->s_vec,
+ sp[3]->s_vec,sp[4]->s_vec,
+ sp[0]->s_n);
+ break;
+ }
+}
+
+
+static void *sfread_new(t_floatarg chan,t_floatarg skip)
+{
+ t_sfread *x = (t_sfread *)pd_new(sfread_class);
+ t_int c = chan;
+
+ x->x_glist = (t_glist*) canvas_getcurrent();
+
+ if (c<1 || c > MAX_CHANS) c = 1;
+ floatinlet_new(&x->x_obj, &x->x_skip);
+ floatinlet_new(&x->x_obj, &x->x_speed);
+
+
+ x->x_fd = -1;
+ x->x_mapaddr = NULL;
+
+ x->x_loop = 0;
+ x->x_channels = c;
+ x->x_mapaddr=NULL;
+ x->x_offset = skip;
+ x->x_skip = skip;
+ x->x_speed = 1.0;
+ x->x_play = 0;
+
+ while (c--) {
+ outlet_new(&x->x_obj, gensym("signal"));
+ }
+
+/* post("sfread: x_channels = %d, x_speed = %f",x->x_channels,x->x_speed);*/
+
+ return (x);
+}
+
+/*
+ * ------------------------------------------- sfwrite~ -------------------------------
+ */
+
+
+
+static t_class *sfwrite_class;
+
+typedef struct _sfwrite
+{
+ t_object x_obj;
+ t_symbol* filename;
+ FILE* x_file;
+
+ t_int rec;
+ t_int x_channels;
+ t_int size;
+} t_sfwrite;
+
+
+static void sfwrite_open(t_sfwrite *x,t_symbol *filename)
+{
+ post("sfwrite: open");
+ x->filename = filename;
+ post("sfwrite: filename = %s",x->filename->s_name);
+
+ if ((x->x_file = fopen(x->filename->s_name,"w")) < 0)
+ {
+ error("can't create %s",filename->s_name);
+ return;
+ }
+}
+
+static void sfwrite_float(t_sfwrite *x, t_floatarg f)
+{
+ int t = f;
+ if (t) {
+ post("sfwrite: start", f);
+ x->rec=1;
+ }
+ else {
+ post("sfwrite: stop", f);
+ x->rec=0;
+ }
+
+}
+
+
+static short out[4*64];
+
+static t_int *sfwrite_perform(t_int *w)
+{
+ t_sfwrite* x = (t_sfwrite*)(w[1]);
+ t_float * in[4];
+ int c = x->x_channels;
+ int i,n;
+ short* tout = out;
+
+ for (i=0;i < c;i++) {
+ in[i] = (t_float *)(w[2+i]);
+ }
+
+ n = (int)(w[2+c]);
+
+ /* loop */
+
+ if (x->rec && x->x_file) {
+
+ while (n--) {
+ for (i=0;i<c;i++) {
+ *tout++ = *(in[i])++ * 32768.;
+ }
+ }
+
+ fwrite(out,sizeof(short),64*c,x->x_file);
+ }
+ return (w+3+c);
+}
+
+
+
+static void sfwrite_dsp(t_sfwrite *x, t_signal **sp)
+{
+ post("sfwrite: dsp");
+ switch (x->x_channels) {
+ case 1:
+ dsp_add(sfwrite_perform, 3, x, sp[0]->s_vec,
+ sp[0]->s_n);
+ break;
+ case 2:
+ dsp_add(sfwrite_perform, 4, x, sp[0]->s_vec,
+ sp[1]->s_vec, sp[0]->s_n);
+ break;
+ case 4:
+ dsp_add(sfwrite_perform, 6, x, sp[0]->s_vec,
+ sp[1]->s_vec,
+ sp[2]->s_vec,
+ sp[3]->s_vec,
+ sp[0]->s_n);
+ break;
+ }
+ post("sfwrite: dsp end");
+}
+
+
+static void *sfwrite_new(t_floatarg chan)
+{
+ t_sfwrite *x = (t_sfwrite *)pd_new(sfwrite_class);
+ t_int c = chan;
+
+ post("sfwrite: x_channels = %d, ",c);
+
+ if (c<1 || c > MAX_CHANS) c = 1;
+ x->x_channels = c--;
+ x->x_file=NULL;
+ x->rec = 0;
+ while (c--) {
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ }
+
+
+ return (x);
+}
+
+void sfwrite_setup(void)
+{
+ sfwrite_class = class_new(gensym("sfwrite~"), (t_newmethod)sfwrite_new, 0,
+ sizeof(t_sfwrite), 0,A_DEFFLOAT,0);
+ class_addmethod(sfwrite_class,nullfn,gensym("signal"), 0);
+ class_addmethod(sfwrite_class, (t_method) sfwrite_dsp, gensym("dsp"), 0);
+ class_addmethod(sfwrite_class, (t_method) sfwrite_open, gensym("open"), A_SYMBOL,A_NULL);
+ class_addfloat(sfwrite_class, sfwrite_float);
+
+}
+
+
+void sfread_setup(void)
+{
+ /* sfread */
+
+ sfread_class = class_new(gensym("sfread~"), (t_newmethod)sfread_new, 0,
+ sizeof(t_sfread), 0,A_DEFFLOAT,A_DEFFLOAT,0);
+ class_addmethod(sfread_class, nullfn, gensym("signal"), 0);
+ class_addmethod(sfread_class, (t_method) sfread_dsp, gensym("dsp"), 0);
+ class_addmethod(sfread_class, (t_method) sfread_open, gensym("open"), A_SYMBOL,A_NULL);
+ class_addfloat(sfread_class, sfread_float);
+ class_addbang(sfread_class,sfread_bang);
+ class_addmethod(sfread_class,(t_method)sfread_loop,gensym("loop"),A_FLOAT,A_NULL);
+
+}
+
+
+
+
+
+
diff --git a/stream13.h b/stream13.h
new file mode 100644
index 0000000..efc3461
--- /dev/null
+++ b/stream13.h
@@ -0,0 +1,10 @@
+/* (C) Guenter Geiger 1999 */
+
+#define SF_FLOAT 1
+#define SF_16BIT 2
+#define SF_8BIT 3
+#define SF_MP3 4
+
+#define SF_SIZEOF(a) (a == SF_FLOAT ? sizeof(t_float) : \
+ a == SF_16BIT ? sizeof(short) : 1)
+
diff --git a/streamin13~.c b/streamin13~.c
new file mode 100644
index 0000000..c4efded
--- /dev/null
+++ b/streamin13~.c
@@ -0,0 +1,302 @@
+ /* Written by Guenter Geiger <geiger@debian.org> (C) 1999, adapted and changed to streamin13~ by d13@klingt.org */
+
+#include "m_pd.h"
+#include "stream13.h"
+
+#include <sys/types.h>
+#include <string.h>
+#ifdef unix
+#include <sys/socket.h>
+#include <sys/errno.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <sys/time.h>
+#include <unistd.h>
+#define SOCKET_ERROR -1
+#else
+#include <winsock.h>
+#endif
+
+
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#define INBUFSIZE 8192
+#define MAXDROPS 99
+
+/* Utility functions */
+
+static void sys_sockerror(char *s)
+{
+#ifdef unix
+ int err = errno;
+#else
+ int err = WSAGetLastError();
+ if (err == 10054) return;
+#endif
+ post("%s: %s (%d)\n", s, strerror(err), err);
+}
+
+
+static void sys_closesocket(int fd)
+{
+#ifdef UNIX
+ close(fd);
+#endif
+#ifdef NT
+ closesocket(fd);
+#endif
+}
+
+/* ------------------------ streamin13~ ----------------------------- */
+
+
+static t_class *streamin13_class;
+
+typedef struct _streamin13
+{
+ t_object x_obj;
+ int x_connectsocket;
+ int x_nconnections;
+ int x_ndrops;
+ int x_ndone;
+ int x_fd;
+ int x_format;
+ int x_n;
+ short* cbuf;
+ int nsamples;
+// t_outlet *x_out2;
+ int blocksperreceive;
+ int blockssincereceive;
+} t_streamin13;
+
+
+static void streamin13_tempbuf(t_streamin13 *x,int size)
+{
+ int fullsize = size * x->x_n;
+ if (!x->cbuf)
+ x->cbuf = getbytes(fullsize*sizeof(t_float)*x->blocksperreceive+4);
+ else
+ x->cbuf = resizebytes(x->cbuf,x->nsamples*sizeof(t_float),fullsize*sizeof(t_float)*x->blocksperreceive+4);
+ x->nsamples = size;
+ x->blockssincereceive=0;
+}
+
+
+static int streamin13_listen(t_streamin13 *x,int portno)
+{
+ struct sockaddr_in server;
+ int sockfd;
+ static int on = 1;
+
+
+ shutdown(x->x_connectsocket,SHUT_RDWR);
+ sys_closesocket(x->x_connectsocket);
+
+ sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (sockfd < 0)
+ {
+ sys_sockerror("streamin-socket");
+ x->x_connectsocket = 0;
+ return (0);
+ }
+ server.sin_family = AF_INET;
+ server.sin_addr.s_addr = INADDR_ANY;
+
+ #ifdef unix
+ if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
+ post("setsockopt failed\n");
+ #endif
+
+ /* assign server port number */
+ server.sin_port = htons((u_short)portno);
+ post("listening to port number %d", portno);
+
+ /* name the socket */
+ if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0)
+ {
+ sys_sockerror("streamin-bind");
+ sys_closesocket(sockfd);
+ x->x_connectsocket = 0;
+ }else {
+ x->x_connectsocket = sockfd;
+ x->x_nconnections = 0;
+ x->x_ndrops = 0;
+ x->x_format = SF_FLOAT;
+ x->cbuf = NULL;
+ x->blocksperreceive=16;
+ x->blockssincereceive=0;
+ streamin13_tempbuf(x,64);
+ }
+
+
+}
+
+static void *streamin13_new(t_floatarg fportno ,t_floatarg xn)
+{
+ int i;
+ t_streamin13 *x = (t_streamin13 *)pd_new(streamin13_class);
+ struct sockaddr_in server;
+ streamin13_listen(x,(int)fportno);
+ outlet_new(&x->x_obj, &s_signal);
+ x->x_n = xn;
+ for (i = 0 ;i < x->x_n - 1;i++){
+ outlet_new(&x->x_obj, gensym("signal"));
+ }
+
+ return (x);
+}
+
+
+
+static void streamin13_free(t_streamin13 *x)
+{
+ /* LATER make me clean up open connections */
+}
+
+
+
+
+
+static t_int *streamin13_perform(t_int *w)
+{
+ t_streamin13* x = (t_streamin13*) (w[1]);
+ int offset = 3;
+ int i,j;
+ t_float *out[x->x_n];
+ int n = (int)(w[2]);
+ struct timeval timeout;
+ int packsize;
+ int ret;
+ int length;
+ short* cbuf;
+
+#ifndef NT
+ fd_set fdset;
+#endif
+ for (i=0;i < x->x_n;i++) {
+ out[i] = (t_float *)(w[offset+i]);
+ }
+ if (x->x_connectsocket){
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+
+ if (n != x->nsamples)
+ streamin13_tempbuf(x,n);
+
+
+ // cbuf = x->cbuf + x->blockssincereceive * n * x->x_n;
+
+ #ifndef NT
+ FD_SET(x->x_connectsocket,&fdset);
+ if (!select(x->x_connectsocket+1,&fdset,NULL,NULL,&timeout)
+ || !FD_ISSET(x->x_connectsocket,&fdset)) {
+ x->x_ndrops++;
+ if (x->x_ndrops <= MAXDROPS) {
+/* post("streamin13: drop"); */
+ while (n--){
+ for (j=0;j<x->x_n;j++){
+ *(out[j]++) = 0.0;
+ }
+ }
+ }
+
+ return (w+offset+1+i);
+ } else {
+ x->x_ndone++;
+ }
+ #endif
+
+ if (x->x_ndrops > MAXDROPS) {
+ post("streamin13: dropped %d signal vectors, received %d sigvecs.",x->x_ndrops,x->x_ndone);
+ x->x_ndrops=0;
+ x->x_ndone=0;
+ }
+ if (!(x->blockssincereceive < x->blocksperreceive -1)) {
+
+ length=x->x_n * x->nsamples * SF_SIZEOF(x->x_format) * x->blocksperreceive +4;
+ ret = recv(x->x_connectsocket, (char*) x->cbuf,length, 0);
+ x->blockssincereceive=0;
+ if (x->x_format != *x->cbuf){
+ x->x_format= (short) *x->cbuf;
+ }
+ cbuf = (short*) x->cbuf + 1;
+ if (x->blocksperreceive != (short) *cbuf){
+ x->blocksperreceive=(short) *cbuf;
+ streamin13_tempbuf(x,x->nsamples);
+ }
+ }else{
+ x->blockssincereceive++;
+ }
+ packsize=n * x->x_n * sizeof(short) * x->blocksperreceive + 2;
+ switch (x->x_format) {
+ case SF_FLOAT:{
+ t_float* fbuf = (t_float*) x->cbuf + x->blockssincereceive * n * x->x_n + 1;
+ while (n--){
+ for (j=0;j<x->x_n;j++){
+ *out[j]++ = *fbuf++;
+ }
+ }
+
+ break;
+ }
+ case SF_16BIT:
+ {
+ cbuf = x->cbuf + x->blockssincereceive * n * x->x_n + 2;
+ while (n--){
+ for (j=0;j<x->x_n;j++){
+ *out[j]++ = (float) *cbuf++/32767.;
+ }
+ }
+ break;
+ }
+ case SF_8BIT: {
+ signed char* cbuf = (signed char*) x->cbuf + x->blockssincereceive * n * x->x_n + 4;
+ while (n--){
+ for (j=0;j<x->x_n;j++){
+ *out[j]++ = (float) *cbuf++/127.;
+ }
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ return (w+offset+1+i);
+}
+
+
+
+static void streamin13_dsp(t_streamin13 *x, t_signal **sp)
+{
+ int i;
+ t_int** myvec = getbytes(sizeof(t_int)*(x->x_n + 3));
+
+ myvec[0] = (t_int*)x;
+ myvec[1] = (t_int*)sp[0]->s_n;
+ for (i=0;i < x->x_n;i++)
+ myvec[2 + i] = (t_int*)sp[i]->s_vec;
+ dsp_addv(streamin13_perform, x->x_n + 3, (t_int*)myvec);
+ freebytes(myvec,sizeof(t_int)*(x->x_n + 3));
+
+}
+
+static void streamin13_port(t_streamin13 *x,t_floatarg port)
+{
+ streamin13_listen(x, (int)port);
+}
+
+void streamin13_setup(void)
+{
+ streamin13_class = class_new(gensym("streamin13~"),
+ (t_newmethod) streamin13_new, (t_method) streamin13_free,
+ sizeof(t_streamin13), A_DEFSYM, A_DEFFLOAT, A_DEFFLOAT, 0);
+ class_sethelpsymbol(streamin13_class, gensym("streamio13~"));
+ class_addmethod(streamin13_class, nullfn, gensym("signal"), 0);
+ class_addmethod(streamin13_class, (t_method) streamin13_dsp, gensym("dsp"), 0);
+ class_addmethod(streamin13_class, (t_method)streamin13_port,gensym("port"),A_DEFFLOAT,0);
+}
diff --git a/streamout13~.c b/streamout13~.c
new file mode 100644
index 0000000..97eb986
--- /dev/null
+++ b/streamout13~.c
@@ -0,0 +1,382 @@
+#include "m_pd.h"
+#include "stream13.h"
+
+#include <sys/types.h>
+#include <string.h>
+#ifdef unix
+#include <sys/errno.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#define SOCKET_ERROR -1
+#else
+#include <winsock.h>
+#endif
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+
+/* Utility functions */
+
+static void sys_sockerror(char *s)
+{
+#ifdef unix
+ int err = errno;
+#else
+ int err = WSAGetLastError();
+ if (err == 10054) return;
+#endif
+ post("%s: %s (%d)\n", s, strerror(err), err);
+}
+
+
+
+static void sys_closesocket(int fd)
+{
+#ifdef UNIX
+ close(fd);
+#endif
+#ifdef NT
+ closesocket(fd);
+#endif
+}
+
+
+/* ------------------------ streamout13~ ----------------------------- */
+
+/*
+#define A1 (4 * (3.14159265/2))
+#define A3 (64 * (2.5 - 3.14159265))
+#define A5 (1024 * ((3.14159265/2) - 1.5))
+*/
+
+static t_class *streamout13_class;
+
+typedef struct _streamout13
+{
+ t_object x_obj;
+ int x_fd;
+ int x_protocol;
+ int x_format;
+ int x_realformat;
+ t_symbol* hostname;
+ int portno;
+ int x_n;
+ short* cbuf;
+ int nsamples;
+ int blockspersend;
+ int blockssincesend;
+ int newblockspersend;
+} t_streamout13;
+
+
+static void streamout13_connect(t_streamout13 *x, t_symbol *hostname,
+ t_floatarg fportno)
+{
+ struct sockaddr_in server;
+ struct hostent *hp;
+ int sockfd;
+ int portno = fportno;
+ x->hostname = hostname;
+ x->portno = (int) fportno;
+
+ if (x->x_fd >= 0)
+ {
+ error("streamout13_connect: already connected - reconnecting");
+ sys_closesocket(x->x_fd);
+ x->x_fd = -1;
+ outlet_float(x->x_obj.ob_outlet, 0);
+ }
+
+ /* create a socket */
+ sockfd = socket(AF_INET, x->x_protocol, 0);
+ if (sockfd < 0)
+ {
+ post("streamout13: Connection to %s on port %d failed",hostname->s_name,portno);
+ sys_sockerror("socket");
+ return;
+ }
+ /* connect socket using hostname provided in command line */
+ server.sin_family = AF_INET;
+ hp = gethostbyname(hostname->s_name);
+ if (hp == 0)
+ {
+ post("bad host?\n");
+ return;
+ }
+ memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length);
+
+ /* assign client port number */
+ server.sin_port = htons((u_short)portno);
+
+ /* try to connect. LATER make a separate thread to do this
+ because it might block */
+ if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) < 0)
+ {
+ sys_sockerror("connecting stream socket");
+ sys_closesocket(sockfd);
+ return;
+ }
+
+ post("connected host %s on port %d",hostname->s_name, portno);
+ x->x_fd = sockfd;
+ outlet_float(x->x_obj.ob_outlet, 1);
+}
+
+static void streamout13_disconnect(t_streamout13 *x)
+{
+ if (x->x_fd >= 0)
+ {
+ sys_closesocket(x->x_fd);
+ x->x_fd = -1;
+ outlet_float(x->x_obj.ob_outlet, 0);
+ }
+}
+
+static void streamout13_tempbuf(t_streamout13 *x,int size) {
+ int fullsize = size * x->x_n;
+ if (!x->cbuf)
+ x->cbuf = getbytes(fullsize*sizeof(t_float)*x->blockspersend+4);
+ else
+ x->cbuf = resizebytes(x->cbuf,x->nsamples*sizeof(short),fullsize*sizeof(t_float)*x->blockspersend+4);
+ x->nsamples = size;
+ x->blockssincesend=0;
+}
+
+static t_int *streamout13_perform(t_int *w)
+{
+ t_streamout13* x = (t_streamout13*) (w[1]);
+ int n = (int)(w[2]);
+ t_float *in[x->x_n];
+ int i,j,res = 0;
+ int offset = 3;
+ int sent = 0;
+ int length ;
+ char* buf = (char *)(w[2]);
+ short* cibuf;
+ char* bp;
+
+
+
+ for (i=0;i < x->x_n;i++) {
+ in[i] = (t_float *)(w[offset+i]);
+ }
+
+
+ if (x->x_fd > 0){
+
+ if (n != x->nsamples)
+ streamout13_tempbuf(x,n);
+
+
+ /* format the buffer */
+/*
+ cibuf = x->cbuf + x->blockssincesend * n * x->x_n + 2;
+ while (n--){
+ for (j=0;j<x->x_n;j++){
+ *cibuf++ = (short) 32767.0 * *(in[j]++);
+ }
+ }
+*/
+
+ switch (x->x_format) {
+ case SF_FLOAT:{
+ t_float* fbuf = (t_float*) x->cbuf + x->blockssincesend * n * x->x_n + 1;
+ while (n--){
+ for (j=0;j<x->x_n;j++){
+ *fbuf++ = *(in[j]++);
+ }
+ }
+ break;
+ }
+ case SF_16BIT: {
+ short* sbuf =(short*) x->cbuf + x->blockssincesend * n * x->x_n + 2; /*2 extra bytes for format & grain */
+ while (n--){
+ for (j=0;j<x->x_n;j++){
+ *sbuf++ = (short) 32767.0 * *(in[j]++);
+ }
+ }
+ break;
+ }
+ case SF_8BIT: {
+// signed char* cbuf = (signed char*) ibuf;
+ signed char* cbuf = (signed char*) x->cbuf + x->blockssincesend * n * x->x_n + 4;
+ while (n--)
+ for (j=0;j<x->x_n;j++){
+ *cbuf++ = (127.0 * *in[j]++);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (!(x->blockssincesend < x->blockspersend - 1)){
+
+
+ x->blockssincesend=0;
+ if (x->x_realformat !=x->x_format){
+ x->x_realformat = x->x_format;
+ x->blockspersend = (int) (x->blockspersend * 4 / SF_SIZEOF(x->x_format)) ;
+ x->nsamples=0;
+// post ("formatchange:%d",x->x_format);
+ }
+ if (x->blockspersend != (int) (x->newblockspersend * 4 / SF_SIZEOF(x->x_realformat)) ){
+ x->blockspersend = (int) (x->newblockspersend * 4 / SF_SIZEOF(x->x_realformat) ) ;
+ x->nsamples=0;
+// post ("grainchange:%d",x->blockspersend);
+ }
+ cibuf=x->cbuf;
+ *cibuf=(short)x->x_realformat;
+// *x->cbuf=(short)x->x_realformat;
+ cibuf=x->cbuf + 1;
+ *cibuf=x->blockspersend;
+// post ("out:cibuf:%d",*cibuf);
+
+
+ /* send the buffer */
+
+ length = x->nsamples * x->x_n * x->blockspersend * SF_SIZEOF(x->x_realformat) + 4;
+// outlet_float(x->x_out2,length);
+// post ("out - length:%d",length);
+
+ for (bp = buf, sent = 0; sent < length;) {
+ res = send(x->x_fd, (char*) x->cbuf, length - sent , 0);
+ if (res <= 0)
+ {
+ sys_sockerror("streamout13~-error");
+ streamout13_disconnect(x);
+ break;
+ }
+ else
+ {
+ sent += res;
+ bp += res;
+ }
+ }
+ }else{
+ x->blockssincesend++;
+ }
+ }
+ // post ("b-s-s:%d, length:%d, last:%d, prev:%d",x->blockssincesend,length,*cibuf,prev);
+ return (w + 2 + i * 2);
+}
+
+static void streamout13_dsp(t_streamout13 *x, t_signal **sp)
+{
+/*
+ dsp_add(streamout13_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
+*/
+ int i;
+ t_int** myvec = getbytes(sizeof(t_int)*(x->x_n + 3));
+
+ myvec[0] = (t_int*)x;
+ myvec[1] = (t_int*)sp[0]->s_n;
+ for (i=0;i < x->x_n/*+1*/;i++)
+ myvec[2 + i] = (t_int*)sp[i]->s_vec;
+ dsp_addv(streamout13_perform, x->x_n + 3, (t_int*)myvec);
+ freebytes(myvec,sizeof(t_int)*(x->x_n + 3));
+}
+
+static void streamout13_grain(t_streamout13 *x,t_floatarg grain)
+{
+ if ((grain > 0) && (grain < 24)){
+ x->newblockspersend=(int) grain;
+ post ("streamout13~:grainsize set to %d blocks",(int) grain);
+ }
+
+}
+
+static void streamout13_format(t_streamout13 *x,t_symbol* form)
+{
+ if (!strncmp(form->s_name,"float",5))
+ x->x_format = (int) SF_FLOAT;
+
+ if (!strncmp(form->s_name,"16bit",5))
+ x->x_format = (int) SF_16BIT;
+
+ if (!strncmp(form->s_name,"8bit",4))
+ x->x_format = (int) SF_8BIT;
+
+
+ post ("streamout13~:format set to %s", form->s_name);
+}
+
+static void streamout13_host(t_streamout13 *x,t_symbol* host)
+{
+ if (host != &s_){
+ x->hostname = host;
+ if (x->x_fd >= 0) {
+ streamout13_disconnect(x);
+ streamout13_connect(x,x->hostname,(float) x->portno);
+ }
+ }
+}
+
+
+static void streamout13_float(t_streamout13* x,t_float arg)
+{
+
+ if (arg == 0.0)
+ streamout13_disconnect(x);
+ else
+ streamout13_connect(x,x->hostname,(float) x->portno);
+}
+
+
+static void *streamout13_new(t_symbol* hostname,t_floatarg portno,t_floatarg xn)
+{
+ int i;
+ t_streamout13 *x = (t_streamout13 *)pd_new(streamout13_class);
+ outlet_new(&x->x_obj, &s_float);
+// x->x_out2 = outlet_new(&x->x_obj, &s_float);
+ if (hostname == &s_)
+ x->hostname = gensym("localhost");
+ else
+ x->hostname = hostname;
+
+ if (portno == 0.0)
+ x->portno = 3000;
+ else
+ x->portno = portno;
+ if (xn < 1)
+ x->x_n = 1;
+ else
+ x->x_n = xn;
+
+ for (i = 0 ;i < x->x_n - 1;i++){
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+/* post("creating ~input nr:%d",i);*/
+
+ }
+
+ x->x_fd = -1;
+ x->x_protocol = SOCK_DGRAM;
+ x->x_format = SF_16BIT;
+ x->x_realformat = SF_16BIT;
+ x->cbuf = NULL;
+ x->blockspersend=16;
+ x->newblockspersend=8;
+ x->blockssincesend=0;
+ streamout13_tempbuf(x,64);
+ return (x);
+}
+
+void streamout13_setup(void)
+{
+ streamout13_class = class_new(gensym("streamout13~"), (t_newmethod) streamout13_new, 0,
+ sizeof(t_streamout13), 0, A_DEFSYM, A_DEFFLOAT,A_DEFFLOAT, 0);
+ class_sethelpsymbol(streamout13_class, gensym("streamio13~"));
+ class_addmethod(streamout13_class, (t_method) streamout13_connect,gensym("connect"), A_SYMBOL, A_DEFFLOAT, 0);
+ class_addmethod(streamout13_class, (t_method) streamout13_disconnect, gensym("disconnect"), 0);
+ class_addfloat(streamout13_class,streamout13_float);
+ class_addmethod(streamout13_class, nullfn, gensym("signal"), 0);
+ class_addmethod(streamout13_class, (t_method)streamout13_format,gensym("format"),A_SYMBOL,0);
+ class_addmethod(streamout13_class, (t_method)streamout13_grain,gensym("grain"),A_DEFFLOAT,0);
+ class_addmethod(streamout13_class, (t_method) streamout13_dsp, gensym("dsp"), 0);
+ class_addmethod(streamout13_class, (t_method)streamout13_host,gensym("host"),A_DEFSYM,0);
+
+}
diff --git a/strippath.c b/strippath.c
new file mode 100644
index 0000000..f24be9e
--- /dev/null
+++ b/strippath.c
@@ -0,0 +1,68 @@
+#include "ext13.h"
+#include "m_pd.h"
+#include <sys/stat.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+/* -------------------------- strippath ------------------------------ */
+static t_class *strippath_class;
+
+typedef struct _strippath
+{
+ t_object x_obj;
+ t_symbol *x_s;
+ t_symbol *x_path;
+} t_strippath;
+
+
+static void *strippath_new(t_symbol *s)
+{
+ t_strippath *x = (t_strippath *)pd_new(strippath_class);
+ x->x_s = s;
+ x->x_path=gensym("./");
+ symbolinlet_new(&x->x_obj, &x->x_path);
+ outlet_new(&x->x_obj, &s_symbol);
+ return (x);
+}
+
+
+
+static void strippath_symbol(t_strippath *x, t_symbol *s)
+{
+ char *lastslash;
+ char path[MAXPDSTRING], filename[MAXPDSTRING];
+ x->x_s = s;
+ lastslash=strrchr (s->s_name,'/');
+ if (lastslash){
+ strncpy (path,s->s_name,lastslash-s->s_name+1);
+ path[lastslash-s->s_name]=0;
+ strcpy (filename,lastslash+1);
+// filename[lastslash-s->s_name+1]=0;
+ }
+ else {
+ strcpy (filename,s->s_name);
+ sprintf (path,x->x_path->s_name);
+ }
+ outlet_symbol(x->x_obj.ob_outlet,gensym(filename));
+// post ("path:%s , name:%s",path,filename);
+}
+
+
+static void strippath_bang(t_strippath *x)
+{
+ if (x->x_s){strippath_symbol (x,x->x_s);}
+}
+
+void strippath_setup(void)
+{
+ strippath_class = class_new(gensym("strippath"), (t_newmethod)strippath_new, 0,
+ sizeof(t_strippath), 0, A_DEFFLOAT, 0);
+ class_addbang(strippath_class, strippath_bang);
+ class_addsymbol(strippath_class, strippath_symbol);
+}
diff --git a/throw13~.c b/throw13~.c
new file mode 100644
index 0000000..347953e
--- /dev/null
+++ b/throw13~.c
@@ -0,0 +1,84 @@
+/* Copyright (c) 1997-1999 Miller Puckette source modified by dieb13.
+* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* catch13~ ... = original objects with set-message for changing - bad hack - but works somehow*/
+
+#include "m_pd.h"
+#include "d_global13.h"
+
+#define DEFSENDVS 64 /* LATER get send to get this from canvas */
+
+/* ----------------------------- throw13~ ----------------------------- */
+
+ void *sigthrow13_new(t_symbol *s)
+{
+ t_sigthrow13 *x = (t_sigthrow13 *)pd_new(sigthrow13_class);
+ if (!*s->s_name) s = gensym("throw13~");
+ x->x_sym = s;
+ x->x_whereto = 0;
+ x->x_n = DEFSENDVS;
+ return (x);
+}
+
+ t_int *sigthrow13_perform(t_int *w)
+{
+ t_sigthrow13 *x = (t_sigthrow13 *)(w[1]);
+ t_float *in = (t_float *)(w[2]);
+ int n = (int)(w[3]);
+ t_float *out = x->x_whereto;
+ if (out)
+ {
+ while (n--)
+ *out++ += *in++;
+ }
+ return (w+4);
+}
+
+ void sigthrow13_set(t_sigthrow13 *x, t_symbol *s)
+{
+ t_sigcatch13 *catcher = (t_sigcatch13 *)pd_findbyclass((x->x_sym = s),
+ sigcatch13_class);
+ if (catcher)
+ {
+ if (catcher->x_n == x->x_n)
+ x->x_whereto = catcher->x_vec;
+ else
+ {
+ pd_error(x, "throw13~ %s: vector size mismatch", x->x_sym->s_name);
+ x->x_whereto = 0;
+ }
+ }
+ else
+ {
+ pd_error(x, "throw13~ %s: no matching catch", x->x_sym->s_name);
+ x->x_whereto = 0;
+ }
+}
+
+ void sigthrow13_dsp(t_sigthrow13 *x, t_signal **sp)
+{
+ if (sp[0]->s_n != x->x_n)
+ {
+ pd_error(x, "throw13~ %s: vector size mismatch", x->x_sym->s_name);
+ }
+ else
+ {
+ sigthrow13_set(x, x->x_sym);
+ dsp_add(sigthrow13_perform, 3,
+ x, sp[0]->s_vec, sp[0]->s_n);
+ }
+}
+
+void sigthrow13_setup(void)
+{
+ sigthrow13_class = class_new(gensym("throw13~"), (t_newmethod)sigthrow13_new, 0,
+ sizeof(t_sigthrow13), 0, A_DEFSYM, 0);
+ class_addcreator((t_newmethod)sigthrow13_new, gensym("t13~"), A_DEFSYM, 0);
+ class_addmethod(sigthrow13_class, (t_method)sigthrow13_set, gensym("set"),
+ A_SYMBOL, 0);
+ class_addmethod(sigthrow13_class, nullfn, gensym("signal"), 0);
+ class_addmethod(sigthrow13_class, (t_method)sigthrow13_dsp, gensym("dsp"), 0);
+}
+
+
diff --git a/wavinfo.c b/wavinfo.c
new file mode 100644
index 0000000..1f5d2f9
--- /dev/null
+++ b/wavinfo.c
@@ -0,0 +1,130 @@
+#include "ext13.h"
+#include "m_pd.h"
+#include "g_canvas.h"
+#include <sys/stat.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+/*--*/
+
+/* -------------------------- wavinfo ------------------------------ */
+#define BLOCKTIME 0.001
+#define uint32 unsigned int
+#define uint16 unsigned short
+
+typedef struct _wave
+{
+ char w_fileid[4]; /* chunk id 'RIFF' */
+ uint32 w_chunksize; /* chunk size */
+ char w_waveid[4]; /* wave chunk id 'WAVE' */
+ char w_fmtid[4]; /* format chunk id 'fmt ' */
+ uint32 w_fmtchunksize; /* format chunk size */
+ uint16 w_fmttag; /* format tag, 1 for PCM */
+ uint16 w_nchannels; /* number of channels */
+ uint32 w_samplespersec; /* sample rate in hz */
+ uint32 w_navgbytespersec; /* average bytes per second */
+ uint16 w_nblockalign; /* number of bytes per sample */
+ uint16 w_nbitspersample; /* number of bits in a sample */
+ char w_datachunkid[4]; /* data chunk id 'data' */
+ uint32 w_datachunksize; /* length of data chunk */
+} t_wave;
+
+
+static t_class *wavinfo_class;
+
+typedef struct _wavinfo
+{
+ t_object x_obj;
+ t_glist *x_glist;
+ t_float x_samplerate;
+ t_float x_bitspersample;
+ t_float x_channels;
+ t_float x_length;
+ t_float x_nsamples;
+ int x_fd;
+ t_symbol *x_s;
+ t_outlet *x_out0;
+ t_outlet *x_out1;
+ t_outlet *x_out2;
+ t_outlet *x_out3;
+} t_wavinfo;
+
+
+static void *wavinfo_new(t_symbol *s)
+{
+ t_wavinfo *x = (t_wavinfo *)pd_new(wavinfo_class);
+ x->x_glist = (t_glist*) canvas_getcurrent();
+ x->x_s = s;
+// outlet_new(&x->x_obj, &s_float);
+ x->x_out0 = outlet_new(&x->x_obj, &s_float);
+ x->x_out1 = outlet_new(&x->x_obj, &s_float);
+ x->x_out2 = outlet_new(&x->x_obj, &s_float);
+ x->x_out3 = outlet_new(&x->x_obj, &s_float);
+ return (x);
+}
+
+static void wavinfo_bang(t_wavinfo *x)
+{
+// outlet_float(x->x_obj.ob_outlet, x->x_f);
+}
+
+static void wavinfo_symbol(t_wavinfo *x, t_symbol *filename)
+{
+ struct stat statbuf;
+ t_wave* wavinfo;
+ int result;
+ char fname[MAXPDSTRING];
+ int ok=(stat(filename->s_name, &statbuf) >= 0);
+ if (ok>0) {
+ canvas_makefilename(glist_getcanvas(x->x_glist), filename->s_name,fname, MAXPDSTRING);
+ if ((x->x_fd = open(fname,( O_NONBLOCK | O_RDONLY))) < 0)
+ {
+ error("can't open %s",fname);
+ return;
+ }
+
+ wavinfo = getbytes(sizeof(t_wave));
+
+ result=read (x->x_fd,wavinfo,sizeof(t_wave));
+ if (result > 0){
+ if (strncmp(wavinfo->w_waveid,"WAVE",4)==0){
+ x->x_samplerate=(t_float)wavinfo->w_samplespersec;
+ x->x_bitspersample=(t_float)wavinfo->w_nbitspersample;
+ x->x_channels=(t_float)wavinfo->w_nchannels;
+ x->x_length=(t_float)wavinfo->w_datachunksize;
+ x->x_nsamples= x->x_length / (x->x_channels * x->x_bitspersample) * 8;
+ outlet_float(x->x_out3,x->x_samplerate);
+ outlet_float(x->x_out2,x->x_bitspersample);
+ outlet_float(x->x_out1,x->x_channels);
+ outlet_float(x->x_out0,x->x_nsamples);
+ }else{
+ error("not a valid wave-file");
+ }
+ }else{
+ error("could not read wav-header");
+ }
+ close (x->x_fd);
+ }
+ else post ("wavinfo:file not found");
+}
+
+void wavinfo_setup(void)
+{
+ wavinfo_class = class_new(gensym("wavinfo"), (t_newmethod)wavinfo_new, 0,
+ sizeof(t_wavinfo), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)wavinfo_new, gensym("fsize"), A_DEFFLOAT, 0);
+ class_addbang(wavinfo_class, wavinfo_bang);
+ class_addsymbol(wavinfo_class, wavinfo_symbol);
+}