Update of /cvsroot/pure-data/externals/mjlib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29410
Modified Files: about.c about.h morse.c n2m.c readme.txt makefile.linux Added Files: monorhythm.c monorhythm.h synapseA~.h makefile.darwin Log Message: made all of the objects compile on MacOS X and GNU/Linux
--- NEW FILE: monorhythm.c --- #ifdef NT #include "stdafx.h" #include <io.h> #endif #include "m_pd.h" #include <stdlib.h> #include <time.h> #include "monorhythm.h"
/** * The monorhythm object is designed to help build polyrhythms. Given * a time interval and a pattern it produces the pattern within the time * interval given. Thus if two where set going with the same time interval * the two patterns (assuming they where different) would play against * each other. * * this filename is spelt wrong 'cos I can't spell */
static t_class *monorhythm_class;
/** * clock tick - do a bang and wait the next * time delay in the list */
static void monorhythm_tick(t_monorhythm *x) { if ( x->t_running ) { monorhythm_do_beat( x ); clock_delay(x->x_clock, x->x_beattime ); } }
static void monorhythm_do_beat( t_monorhythm* x ) { float beat; if ( x->x_idx == x->x_size ) { x->x_idx = 0; } if ( x->x_idx == 0) { outlet_bang( x->x_sync ); } beat = x->x_pattern[ x->x_idx++ ]; if ( beat > 1 ) { if ( x->t_exclusive == 0 ) { outlet_bang( x->x_bang ); } outlet_bang( x->x_accent ); } else if ( beat == 1 ) { outlet_bang( x->x_bang ); } }
/** * a bang causes a reset to the start of the bar - used to * synchronize multiple monorhythm's. If the rhythm is not * running it is started */
static void monorhythm_bang(t_monorhythm *x) { if ( x->x_beattime > 0 ) { monorhythm_restart( x ); } }
/** * reset the rhythm to start at the beginning */
static void monorhythm_restart(t_monorhythm *x) { if ( x->x_beattime > 0 ) { x->t_running = 1; x->x_idx = 0; monorhythm_do_beat( x ); clock_delay(x->x_clock, x->x_beattime ); } }
/** * a stop message turns us off */
static void monorhythm_stop(t_monorhythm *x) { x->t_running = 0; }
/** * set exclusive mode */
static void monorhythm_set_exclusive(t_monorhythm *x) { x->t_exclusive = 1; }
/** * set nonexclusive mode */
static void monorhythm_set_nonexclusive(t_monorhythm *x) { x->t_exclusive = 0; }
/** * free our clock and our timer array */
static void monorhythm_free(t_monorhythm *x) { clock_free(x->x_clock); free( x->x_pattern ); }
/* * make a new monorhythm - we can provide a list of times * so read these in too */
static void *monorhythm_new(t_symbol *s, int argc, t_atom *argv) { float f; t_monorhythm *x = (t_monorhythm *)pd_new(monorhythm_class); x->x_pattern = NULL; // parse any settings if ( argc > 0 ) { f = atom_getfloat( &argv[0] ); monorhythm_set_time( x , f ); monorhythm_pattern_seq( x, s , argc - 1 , argv + 1 ); } x->t_running=0; x->t_exclusive = 0; // make us some ins and outs x->x_clock = clock_new(x, (t_method)monorhythm_tick); x->x_bang = outlet_new(&x->x_obj, gensym("bang")); x->x_accent = outlet_new(&x->x_obj, gensym("accent")); x->x_sync = outlet_new(&x->x_obj, gensym("sync")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("pattern")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("timeinterval")); return (x); }
/** * set a time sequence and free the old array */
static void monorhythm_pattern_seq( t_monorhythm *x, t_symbol *s, int ac, t_atom *av ) { int i; if ( x->x_pattern != NULL ) { free( x->x_pattern ); } if ( ac > 0 ) { x->x_pattern = (float *) malloc( ac * sizeof( float )); for( i = 0 ; i < ac ; i++ ) { float t = atom_getfloat( &av[i] ); x->x_pattern[i] = t; } x->x_size=ac; monorhythm_calculate_beat_interval( x ); } else { // if there is no pattern it doens't do anything x->x_pattern = NULL; x->x_size=0; x->t_running = 0; } x->x_idx = 0; }
/** * the time interval is divided by the number of beats that are * going to happen in order to get the beat time. If this would * be invallid for any reason it is set to 0 and the rhythm is stopped */
static void monorhythm_calculate_beat_interval( t_monorhythm *x ) { if ( ( x->x_size > 0 ) && ( x->x_time > 0 )) { x->x_beattime = x->x_time / x->x_size; } else { x->x_beattime = 0; x->t_running = 0; } }
/** * set the time - recalculate the beat time */
static void monorhythm_set_time( t_monorhythm *x, t_float f ) { x->x_time = f; monorhythm_calculate_beat_interval( x ); }
/** * make a new one and setup all of our messages */
void monorhythm_setup(void) { monorhythm_class = class_new(gensym("monorhythm"), (t_newmethod)monorhythm_new, (t_method)monorhythm_free, sizeof(t_monorhythm), 0, A_GIMME, 0); class_addbang(monorhythm_class, monorhythm_bang); class_addmethod(monorhythm_class, (t_method)monorhythm_stop, gensym("stop"), 0); class_addmethod(monorhythm_class, (t_method)monorhythm_bang, gensym("start"), 0); class_addmethod(monorhythm_class, (t_method)monorhythm_pattern_seq, gensym("pattern" ), A_GIMME, 0); class_addmethod(monorhythm_class, (t_method)monorhythm_set_time, gensym("timeinterval" ), A_FLOAT, 0); class_addmethod(monorhythm_class, (t_method)monorhythm_set_exclusive,gensym("exclusive"),0); class_addmethod(monorhythm_class, (t_method)monorhythm_set_nonexclusive,gensym("nonexclusive"),0); class_sethelpsymbol(monorhythm_class, gensym("mjLib/monorhythm")); }
Index: about.h =================================================================== RCS file: /cvsroot/pure-data/externals/mjlib/about.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** about.h 7 Apr 2004 14:31:10 -0000 1.1.1.1 --- about.h 8 Apr 2004 02:35:21 -0000 1.2 *************** *** 1,2 **** --- 1,3 ---- + #include "m_pd.h"
typedef struct _about
--- NEW FILE: synapseA~.h --- /* declarations for the pin~ object */
typedef struct _synapseA_tilde { t_object x_obj; t_float x_f; t_float x_threshold; t_outlet *x_onbang; t_outlet *x_offbang; t_float n_inv; t_float x_state; } t_synapseA_tilde;
t_int *synapseA_tilde_perform(t_int *w); static void synapseA_tilde_dsp(t_synapseA_tilde *x, t_signal **sp); static void synapseA_tilde_free(t_synapseA_tilde *x); static void *synapseA_tilde_new(t_floatarg prob , t_floatarg tick); static void synapseA_tilde_float(t_synapseA_tilde* x, t_float n); static void synapseA_tilde_threshold(t_synapseA_tilde *x, t_float f );
Index: about.c =================================================================== RCS file: /cvsroot/pure-data/externals/mjlib/about.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** about.c 7 Apr 2004 14:31:10 -0000 1.1.1.1 --- about.c 8 Apr 2004 02:35:21 -0000 1.2 *************** *** 3,9 **** #include <io.h> #endif #include "m_pd.h" #include <stdlib.h> ! #include<time.h> #include "about.h"
--- 3,10 ---- #include <io.h> #endif + #include "m_pd.h" #include <stdlib.h> ! #include <time.h> #include "about.h"
--- NEW FILE: monorhythm.h ---
typedef struct _monorhythm { t_object x_obj; t_clock *x_clock; t_float *x_pattern; int x_idx; int x_size; t_float x_time; t_float x_beattime; int t_running; int t_exclusive; t_outlet *x_bang; t_outlet *x_sync; t_outlet *x_accent; } t_monorhythm;
static void monorhythm_tick(t_monorhythm *x); static void monorhythm_start(t_monorhythm *x); static void monorhythm_stop(t_monorhythm *x); static void monorhythm_free(t_monorhythm *x); static void *monorhythm_new(t_symbol *s, int argc, t_atom *argv); static void monorhythm_pattern_seq( t_monorhythm *x, t_symbol *s, int ac, t_atom *av ); static void monorhythm_time_float( t_monorhythm *x1, t_float f ); static void monorhythm_calculate_beat_interval( t_monorhythm *x ); static void monorhythm_set_time( t_monorhythm *x, t_float f ); static void monorhythm_restart(t_monorhythm *x); static void monorhythm_do_beat( t_monorhythm* x ); static void monorhythm_set_exclusive(t_monorhythm *x); static void monorhythm_set_nonexclusive(t_monorhythm *x);
--- NEW FILE: makefile.darwin ---
EXT = pd_darwin 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 = -bundle -bundle_loader ../../pd/bin/pd -flat_namespace WFLAGS = IFLAGS = -I./include -I../src INSTALL_PREFIX=/usr/local
VERSION = "$(shell cat VERSION)"
.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 = about.c convolve~.c pin~.c metroplus.c monorhythm.c morse.c n2m.c prob.c synapseA~.c TARGETS = $(SOURCES:.c=.$(EXT))
all: $(TARGETS)
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_darwin: $(CC) -o $@ $(PDCFLAGS) -DPD $*.o
install:: install -d $(INSTALL_PREFIX)/pd/externs install -m 644 *.$(EXT) $(INSTALL_PREFIX)/pd/externs -install -m 644 mjLib.pd_darwin $(INSTALL_PREFIX)/pd/externs install -m 644 doc/*.pd $(INSTALL_PREFIX)/pd/doc/5.reference
dist: distclean (cd ..;tar czvf mjLib.tar.gz mjLib)
Index: makefile.linux =================================================================== RCS file: /cvsroot/pure-data/externals/mjlib/makefile.linux,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** makefile.linux 7 Apr 2004 14:31:14 -0000 1.1.1.1 --- makefile.linux 8 Apr 2004 02:35:21 -0000 1.2 *************** *** 21,34 **** #LIBS = -lc -lm LIBS = -lpthread -lm -lc ! SOURCES = pin~.c mjLib.c metroplus.c monorythm.c prob.c TARGETS = $(SOURCES:.c=.$(EXT))
all: $(TARGETS)
- mjLib: $(TARGETS) - cc -c $(CFLAGS) -DPD mjLib.c - $(LD) -export_dynamic -shared -o mjLib.pd_linux *.o $(LIBS) - strip --strip-unneeded mjLib.pd_linux - clean:: -rm *.$(EXT) *.o --- 21,29 ---- #LIBS = -lc -lm LIBS = -lpthread -lm -lc ! SOURCES = about.c convolve~.c pin~.c metroplus.c monorhythm.c morse.c n2m.c prob.c synapseA~.c TARGETS = $(SOURCES:.c=.$(EXT))
all: $(TARGETS)
clean:: -rm *.$(EXT) *.o
Index: morse.c =================================================================== RCS file: /cvsroot/pure-data/externals/mjlib/morse.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** morse.c 7 Apr 2004 14:32:26 -0000 1.1.1.1 --- morse.c 8 Apr 2004 02:35:21 -0000 1.2 *************** *** 3,9 **** #include <io.h> #endif #include "m_pd.h" #include <stdlib.h> ! #include<time.h> #include "morse.h"
--- 3,11 ---- #include <io.h> #endif + #include "m_pd.h" #include <stdlib.h> ! #include <time.h> ! #include <string.h> #include "morse.h"
*************** *** 211,215 **** --- 213,225 ---- atom_string( &av[i] , buf, 255 ); l = strlen( buf ); + #ifdef NT + /* this is not part of ANSI or ISO standard C, + only Microsoft and Borland use it. */ strlwr( buf ); + #else + /* Probably needs a loop using tolower(char c) from ctype.h + * This way it'll just be case sensitive + */ + #endif for( j = 0 ; j < l ; j++ ) {
Index: readme.txt =================================================================== RCS file: /cvsroot/pure-data/externals/mjlib/readme.txt,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** readme.txt 7 Apr 2004 14:32:26 -0000 1.1.1.1 --- readme.txt 8 Apr 2004 02:35:21 -0000 1.2 *************** *** 6,22 **** http://www.junklight.com
! The code is free for anyone to use provided you mention me somewhere - its not ! like its going to cost you anything :-). If you need support you can try ! mailing me at the address above - I can be quite busy but I will try and ! deal with any queries.
- Linux
! It is built under windows but I have included the various build files needed ! for linux - delete the file "makefile" and use the configure script to ! make a new one for linux. The files needed by autoconf are there anyway ! if that doesn't work. I can't run PD on the linux machine I have got ! access to (only telnet access) so I am not sure about installing it but all the ! stuff should be there.
Windows --- 6,24 ---- http://www.junklight.com
! The code is free for anyone to use under the GNU GPL. But if you use it, ! please mention me somewhere - its not like its going to cost you anything ! :-). If you need support you can try mailing me at the address above - I ! can be quite busy but I will try and deal with any queries.
! GNU/Linux ! ! Run: "make -f makefile.linux" and all of the objects will be compiled individually. ! ! ! MacOS X ! ! Run: "make -f makefile.darwin" and all of the objects will be compiled individually. !
Windows *************** *** 36,39 **** --- 38,42 ---- that should be you done.
+ General notes
*************** *** 57,60 **** --- 60,68 ---- history:
+ 6th April 2004 + + hans@at.or.at added code to the Pd CVS and made all of the objects compile on + MacOS X and GNU/Linux. + 1st February release 2
Index: n2m.c =================================================================== RCS file: /cvsroot/pure-data/externals/mjlib/n2m.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** n2m.c 7 Apr 2004 14:32:26 -0000 1.1.1.1 --- n2m.c 8 Apr 2004 02:35:21 -0000 1.2 *************** *** 121,124 **** --- 121,126 ---- for( i = 0 ; i < 12 ; i++ ) { + #ifdef NT + /* stricmp() is not an ANSI or ISO standard C function */ if ( stricmp( note , notes_up[i]) == 0) { *************** *** 126,129 **** --- 128,139 ---- break; } + #else + /* replacing with a ANSI function, but it'll now be case sensitive */ + if ( strcmp( note , notes_up[i]) == 0) + { + nnum = i; + break; + } + #endif } return octaveoffset[octave + 1 ] + nnum;