diff options
-rwxr-xr-x | signal/Makefile | 75 | ||||
-rw-r--r-- | signal/apply~-help.pd | 22 | ||||
-rw-r--r-- | signal/apply~.c | 151 | ||||
-rwxr-xr-x | signal/pipewrite~.c | 214 | ||||
-rw-r--r-- | signal/rtin~-help.pd | 32 | ||||
-rwxr-xr-x | signal/rtin~.c | 81 | ||||
-rw-r--r-- | signal/sfread~-help.pd | 44 | ||||
-rwxr-xr-x | signal/sfread~.c | 315 | ||||
-rwxr-xr-x | signal/stream.h | 3 | ||||
-rwxr-xr-x | signal/streamout~.c | 5 |
10 files changed, 25 insertions, 917 deletions
diff --git a/signal/Makefile b/signal/Makefile index ebf4c30..1657154 100755 --- a/signal/Makefile +++ b/signal/Makefile @@ -1,51 +1,24 @@ -current: nt
-
-
-# TARGETS += stk
-
-VERSION = \"0.16\"
-
-.SUFFIXES: .dll .obj
-# ----------------------- NT ----------------------------
-
-NTOBJECTS = *.obj
-NTDLLS = *.dll
-
-PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo
-
-PDNTINCLUDE = /I. /I..\..\pd\src /I..\include
-ProgramFiles = C:\Program Files
-PDNTLDIR = "$(ProgramFiles)\Microsoft Visual Studio\Vc98\lib"
-#PDNTLDIR = "C:\Programme\Msdev\Vc98\lib"
-
-PDNTLIB = $(PDNTLDIR)\libc.lib \
- $(PDNTLDIR)\oldnames.lib \
- $(PDNTLDIR)\wsock32.lib \
- $(PDNTLDIR)\kernel32.lib \
- $(PDNTLDIR)\uuid.lib \
- ..\..\pd\bin\pd.lib
-
-nt: $(NTOBJECTS)
- -link /dll $(PDNTLIB) sfplay~.obj /export:sfplay_tilde_setup
- -link /dll $(PDNTLIB) atan2~.obj /export:atan2_tilde_setup
- -link /dll $(PDNTLIB) exp~.obj /export:exp_tilde_setup
- -link /dll $(PDNTLIB) log~.obj /export:log_tilde_setup
- -link /dll $(PDNTLIB) mixer~.obj /export:mixer_tilde_setup
- -link /dll $(PDNTLIB) sfwrite~.obj /export:swrite_tilde_setup
- -link /dll $(PDNTLIB) streamin~.obj /export:streamin_tilde_setup
- -link /dll $(PDNTLIB) streamout~.obj /export:streamout_tilde_setup
- -link /dll $(PDNTLIB) moog~.obj /export:moog_tilde_setup
-
-clean:
- del *.obj
- del *.dll
-
-
-.c.obj:
- -cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c
-
-.obj.dll:
-
-
-
-
+# Adapt the PDPATH if your pd is not installed in the standard place + +PDPATH="$(PROGRAMFILES)/pd" + +EXTERNALS = $(shell ls *.c) + +all: $(EXTERNALS:.c=.dll) + +.SUFFIXES: .dll + +DEFINES = -DPD -DNT +CFLAGS = -Wall -W -Wshadow -Wstrict-prototypes \ + -Wno-unused -Wno-parentheses -Wno-switch + +INCLUDE = -I.. -I. -I$(PDPATH)/src +LIBS = -lwsock32 + +%.dll: %.c + $(CC) -mms-bitfields $(CFLAGS) $(DEFINES) $(INCLUDE) -o "$*.o" -c "$*.c" + gcc -shared -o "$*.dll" "$*.o" $(PDPATH)/bin/pd.dll $(LIBS) + rm "$*.o" + +clean: + -rm *.a *.def *.dll *.o
\ No newline at end of file diff --git a/signal/apply~-help.pd b/signal/apply~-help.pd deleted file mode 100644 index 9ba48b2..0000000 --- a/signal/apply~-help.pd +++ /dev/null @@ -1,22 +0,0 @@ -#N canvas 284 112 450 300 10; -#X obj 40 122 sig~; -#X obj 40 194 snapshot~; -#X floatatom 40 217 10 0 0; -#X msg 77 123 bang; -#X floatatom 40 76 5 0 0; -#X obj 137 152 apply~; -#X msg 137 88 what; -#X obj 40 152 apply~ rint; -#X obj 356 213 loadbang; -#X msg 356 235 \; pd dsp 1; -#X text 176 87 Click to show available functions; -#X text 19 30 Apply~ applies a one argument function to the input buffer -; -#X connect 0 0 7 0; -#X connect 1 0 2 0; -#X connect 3 0 1 0; -#X connect 4 0 0 0; -#X connect 4 0 3 0; -#X connect 6 0 5 0; -#X connect 7 0 1 0; -#X connect 8 0 9 0; diff --git a/signal/apply~.c b/signal/apply~.c deleted file mode 100644 index 7463383..0000000 --- a/signal/apply~.c +++ /dev/null @@ -1,151 +0,0 @@ -/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-
-#include "math.h"
-#include <m_pd.h>
-
-/* ----------------------------- apply ----------------------------- */
-static t_class *apply_class;
-
-
-typedef double (*t_apply_onearg)(double);
-typedef double (*t_apply_twoarg)(double);
-
-static double nop(double f) {
- return f;
-}
-
-typedef struct _funlist {
- char* name;
- t_int* fun;
- int numarg;
- char* desc;
-} t_funlist;
-
-#define MFUN1(x,d) {#x,(t_int*)x,1,d}
-
-static t_funlist funlist[] =
- {
- MFUN1(nop,"does nothing"),
- MFUN1(sin,"calculate sine"),
- MFUN1(asin,"calculate arcus sine"),
- MFUN1(cos,"calculate cosine"),
- MFUN1(acos,"calculate arcus cosine"),
- MFUN1(tan,"calculate tangent"),
- MFUN1(atan,"calculate arcus tangent"),
-
- MFUN1(sinh,""),
- MFUN1(asinh,""),
- MFUN1(cosh,""),
- MFUN1(acosh,""),
- MFUN1(tanh,""),
- MFUN1(atanh,""),
-
- MFUN1(exp,""),
- MFUN1(expm1,""),
- // MFUN1(exp10),
- // MFUN1(pow10),
- MFUN1(log,""),
- MFUN1(log1p,""),
- MFUN1(log10,""),
- // MFUN1(log2),
- MFUN1(sqrt,""),
- MFUN1(cbrt,""),
-
-
- MFUN1(rint,""),
- // MFUN1(round),
- MFUN1(ceil,""),
- MFUN1(floor,""),
- // MFUN1(trunc),
-
- MFUN1(erf,""),
- MFUN1(erfc,""),
- MFUN1(gamma,""),
- MFUN1(lgamma,""),
- // MFUN1(tgamma),
-
- MFUN1(j0,""),
- MFUN1(j1,""),
- MFUN1(y0,""),
- MFUN1(j1,"")
- };
-
-
-
-typedef struct _apply
-{
- t_object x_obj;
- t_int* x_fun;
-} t_apply;
-
-static void *apply_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_symbol* fname;
- int i;
- int numfun = sizeof(funlist)/sizeof(t_funlist);
- t_apply *x = (t_apply *)pd_new(apply_class);
- outlet_new(&x->x_obj, &s_signal);
-
- x->x_fun = (t_int*)nop;
- if (argc < 1) {
- post("nop operation requested");
- }
- else {
- if (argv[0].a_type != A_SYMBOL)
- goto nofun;
- fname = atom_getsymbol(argv);
- for (i=0;i<numfun;i++)
- if (!strcmp(fname->s_name,funlist[i].name))
- x->x_fun = funlist[i].fun;
-
-
-
- }
-
-
- return (x);
- nofun:
- post("apply first argument has to be a function");
- return (x);
-}
-
-
-static void apply_what(t_apply* x)
-{
- int i;
- int numfun = sizeof(funlist)/sizeof(t_funlist);
- for (i=0;i<numfun;i++)
- post("function: %s: %s",funlist[i].name,funlist[i].desc);
-}
-
-t_int *apply_perform(t_int *w)
-{
- t_apply* x = (t_apply*)(w[1]);
- t_float *in1 = (t_float *)(w[2]);
- t_float *out = (t_float *)(w[3]);
-
- int n = (int)(w[4]);
- while (n--) *out++ = (t_float) ((t_apply_onearg)x->x_fun)(*in1++);
- return (w+5);
-}
-
-
-void dsp_add_apply(t_apply* x,t_sample *in1, t_sample *out, int n)
-{
- dsp_add(apply_perform, 4,x, in1, out, n);
-}
-
-static void apply_dsp(t_apply *x, t_signal **sp)
-{
- dsp_add_apply(x,sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
-}
-
-void apply_tilde_setup(void)
-{
- apply_class = class_new(gensym("apply~"), (t_newmethod)apply_new, 0,
- sizeof(t_apply), 0, A_GIMME, 0);
- class_addmethod(apply_class, nullfn, gensym("signal"), 0);
- class_addmethod(apply_class, (t_method)apply_dsp, gensym("dsp"), 0);
- class_addmethod(apply_class, (t_method)apply_what, gensym("what"), 0);
-}
diff --git a/signal/pipewrite~.c b/signal/pipewrite~.c deleted file mode 100755 index 3067261..0000000 --- a/signal/pipewrite~.c +++ /dev/null @@ -1,214 +0,0 @@ -/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-
-#include <m_pd.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>
-#include <signal.h>
-
-/*
- * -------------------------- pipewrite~ -------------------------------
- */
-
-#define MAX_CHANS 4
-#define BLOCKTIME 0.001
-#define uint32 unsigned int
-#define uint16 unsigned short
-
-static t_class *pipewrite_class;
-
-typedef struct _pipewrite
-{
- t_object x_obj;
- t_symbol* filename;
- int x_file;
- t_int x_channels;
- t_int size;
- t_glist * x_glist;
- t_int x_blocked;
- t_int x_blockwarn;
- short maxval;
-} t_pipewrite;
-
-static void pipewrite_close(t_pipewrite *x)
-{
- if (x->x_file > 0) {
- close(x->x_file);
- }
- x->x_file = -1;
- x->size=0;
-}
-
-
-static void pipewrite_open(t_pipewrite *x,t_symbol *filename)
-{
- char fname[MAXPDSTRING];
-
- if (filename == &s_) {
- post("pipewrite: open without filename");
- return;
- }
-
- canvas_makefilename(glist_getcanvas(x->x_glist), filename->s_name,
- fname, MAXPDSTRING);
- x->x_blocked = 0;
- x->filename = filename;
- x->maxval=0;
- x->size=0;
- post("pipewrite: filename = %s",x->filename->s_name);
-
- pipewrite_close(x);
-
- if ((x->x_file = open(fname,O_WRONLY | O_NONBLOCK)) < 0)
- {
-
- error("can't open pipe %s: ",fname);
- perror("system says");
- return;
- }
-}
-
-static void pipewrite_block(t_pipewrite *x, t_floatarg f)
-{
- x->x_blockwarn = f;
-}
-
-
-static short out[4*64];
-
-static t_int *pipewrite_perform(t_int *w)
-{
- t_pipewrite* x = (t_pipewrite*)(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;
- struct sigaction action;
- struct sigaction oldaction;
-
-
- if (x->x_file < 0) {
- pipewrite_open(x,x->filename);
- }
-
- action.sa_handler = SIG_IGN;
- sigaction(SIGPIPE, &action, &oldaction);
-
- for (i=0;i < c;i++) {
- in[i] = (t_float *)(w[2+i]);
- }
-
- n = num = (int)(w[2+c]);
-
- /* loop */
-
- if (x->x_file >= 0) {
-
- 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.);
- }
- }
-
- timebefore = sys_getrealtime();
- if ((ret = write(x->x_file,out,sizeof(short)*num*c)) < sizeof(short)*num*c) {
- post("pipewrite: 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) {
- x->x_blocked++;
- if (x->x_blocked > x->x_blockwarn) {
- x->x_blocked=0;
-/* post("maximum blockcount %d reached",x->x_blockwarn); */
- }
- }
- }
-
- sigaction(SIGPIPE, &oldaction, NULL);
-
- return (w+3+c);
-}
-
-
-
-static void pipewrite_dsp(t_pipewrite *x, t_signal **sp)
-{
- switch (x->x_channels) {
- case 1:
- dsp_add(pipewrite_perform, 3, x, sp[0]->s_vec,
- sp[0]->s_n);
- break;
- case 2:
- dsp_add(pipewrite_perform, 4, x, sp[0]->s_vec,
- sp[1]->s_vec, sp[0]->s_n);
- break;
- case 4:
- dsp_add(pipewrite_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_free(t_pipewrite* x)
-{
- pipewrite_close(x);
-}
-
-
-static void *pipewrite_new(t_symbol* name,t_floatarg chan)
-{
- t_pipewrite *x = (t_pipewrite *)pd_new(pipewrite_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->x_blocked = 0;
- x->x_blockwarn = 10;
- while (c--) {
- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
- }
-
- if (name && name != &s_) { /* start the pipe */
- pipewrite_open(x,name);
- }
-
- return (x);
-}
-
-void pipewrite_tilde_setup(void)
-{
- pipewrite_class = class_new(gensym("pipewrite~"), (t_newmethod)pipewrite_new, (t_method)pipewrite_free,
- sizeof(t_pipewrite), 0,A_DEFSYM,A_DEFFLOAT,A_NULL);
- class_addmethod(pipewrite_class,nullfn,gensym("signal"), 0);
- class_addmethod(pipewrite_class, (t_method) pipewrite_dsp, gensym("dsp"), 0);
- class_addmethod(pipewrite_class, (t_method) pipewrite_open, gensym("open"), A_SYMBOL,A_NULL);
- class_addmethod(pipewrite_class, (t_method) pipewrite_close, gensym("close"), 0);
- class_addmethod(pipewrite_class, (t_method)pipewrite_block,gensym("block"),A_DEFFLOAT,0);
-
-}
diff --git a/signal/rtin~-help.pd b/signal/rtin~-help.pd deleted file mode 100644 index 176be1a..0000000 --- a/signal/rtin~-help.pd +++ /dev/null @@ -1,32 +0,0 @@ -#N canvas 321 9 450 300 10;
-#X obj 121 96 noise~;
-#X obj 139 202 dac~;
-#X obj 152 157 *~;
-#X obj 210 121 line~;
-#X msg 175 34 bang;
-#X obj 332 193 print;
-#X msg 141 69 1 \, 0 10;
-#X obj 270 89 int;
-#X obj 329 86 + 1;
-#X obj 263 141 sel 0;
-#X floatatom 274 167 5 0 0;
-#X obj 366 82 metro 20;
-#X floatatom 355 52 5 0 0;
-#X obj 270 110 % 8;
-#X obj 227 15 rtin~;
-#X msg 231 48 bang;
-#X connect 0 0 2 0;
-#X connect 2 0 1 0;
-#X connect 2 0 1 1;
-#X connect 3 0 2 1;
-#X connect 4 0 6 0;
-#X connect 6 0 3 0;
-#X connect 7 0 13 0;
-#X connect 8 0 7 1;
-#X connect 9 0 6 0;
-#X connect 12 0 11 1;
-#X connect 13 0 8 0;
-#X connect 13 0 9 0;
-#X connect 13 0 10 0;
-#X connect 14 0 15 0;
-#X connect 15 0 7 0;
diff --git a/signal/rtin~.c b/signal/rtin~.c deleted file mode 100755 index 5338137..0000000 --- a/signal/rtin~.c +++ /dev/null @@ -1,81 +0,0 @@ -/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/time.h>
-#include <unistd.h>
-
-#ifdef NT
-#include <sys/timeb.h>
-void gettimeofday(struct timeval* t,void* timezone)
-{ struct timeb timebuffer;
- ftime( &timebuffer );
- t->tv_sec=timebuffer.time;
- t->tv_usec=1000*timebuffer.millitm;
-}
-#endif
-
-#include "math.h"
-#include <m_pd.h>
-
-
-/* ----------------------------- rtin ----------------------------- */
-static t_class *rtin_class;
-
-
-#define INVTWOPI 0.15915494f
-
-typedef struct _rtin
-{
- t_object x_obj;
- t_int fd;
- t_int usec;
-} t_rtin;
-
-static void *rtin_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_rtin *x = (t_rtin *)pd_new(rtin_class);
- /* inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);*/
- outlet_new(&x->x_obj, &s_float);
-
- x->usec=0;
- x->fd = open("/dev/midi00",O_RDWR|O_NDELAY);
-
- return (x);
-
-}
-
-t_int *rtin_perform(t_int *w)
-{
- struct timeval tv;
- long diff;
- t_rtin* x = (t_rtin *)(w[1]);
-// int n = (int)(w[2]);
- char c;
-
-
- if (read(x->fd,&c,1) == 1) {
- gettimeofday(&tv, NULL);
- diff = tv.tv_usec - x->usec;
- if (diff < 0) diff+=1000000;
- if (diff > 10000) outlet_float(x->x_obj.ob_outlet,diff*0.001);
- x->usec=tv.tv_usec;
- }
-
-
- return (w+2);
-}
-
-static void rtin_dsp(t_rtin *x, t_signal **sp)
-{
- dsp_add(rtin_perform, 1, x);
-}
-
-void rtin_tilde_setup(void)
-{
- rtin_class = class_new(gensym("rtin~"), (t_newmethod)rtin_new, 0,
- sizeof(t_rtin), 0, A_GIMME, 0);
- class_addmethod(rtin_class, nullfn, gensym("signal"), 0);
- class_addmethod(rtin_class, (t_method)rtin_dsp, gensym("dsp"), 0);
-}
diff --git a/signal/sfread~-help.pd b/signal/sfread~-help.pd deleted file mode 100644 index 5cc1058..0000000 --- a/signal/sfread~-help.pd +++ /dev/null @@ -1,44 +0,0 @@ -#N canvas 89 114 600 456 8;
-#X msg 34 135 bang;
-#X obj 228 324 dac~;
-#X msg 70 218 1;
-#X floatatom 348 128;
-#X text 14 33 file to open;
-#X text 33 116 start playback;
-#X msg 70 240 0;
-#X text 34 10 SFREAD;
-#X text 34 21 =======;
-#X text 346 96 playback speed (defaults to 1);
-#X text 93 8 The file should have the systems samplerate (44100) and endianess matching the machine.;
-#X text 25 257 pause on/off during playback;
-#X text 277 46 resets sound to position;
-#X msg 322 63 200;
-#X text 288 164 instatiation: sfread <channels> <skip>;
-#X text 276 35 start position in samples (defaults to <skip>);
-#X floatatom 231 102;
-#X msg 172 114 loop 1;
-#X msg 152 94 loop 0;
-#X msg 364 224 size;
-#X floatatom 336 275;
-#X text 333 205 Get the size (in frames);
-#X obj 207 164 sfread~ 2 62;
-#X msg 14 85 open \$1;
-#X obj 14 66 openpanel;
-#X msg 69 66 bang;
-#X msg 365 249 state;
-#X connect 0 0 22 0;
-#X connect 2 0 22 0;
-#X connect 3 0 22 2;
-#X connect 6 0 22 0;
-#X connect 13 0 22 1;
-#X connect 16 0 22 1;
-#X connect 17 0 22 0;
-#X connect 18 0 22 0;
-#X connect 19 0 22 0;
-#X connect 22 0 1 0;
-#X connect 22 1 1 1;
-#X connect 22 2 20 0;
-#X connect 23 0 22 0;
-#X connect 24 0 23 0;
-#X connect 25 0 24 0;
-#X connect 26 0 22 0;
diff --git a/signal/sfread~.c b/signal/sfread~.c deleted file mode 100755 index d87b0b4..0000000 --- a/signal/sfread~.c +++ /dev/null @@ -1,315 +0,0 @@ -/* (C) Guenter Geiger <geiger@epy.co.at> */ - - -#include <m_pd.h> - -#include <stdio.h> -#include <string.h> -#ifndef NT -#include <unistd.h> -#include <sys/mman.h> -#else -#include <io.h> -#endif - - -#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_canvas * x_canvas; - t_outlet *x_bangout; -} t_sfread; - - -void sfread_open(t_sfread *x,t_symbol *filename) -{ - struct stat fstate; - char fname[MAXPDSTRING]; - - if (filename == &s_) { - post("sfread: open without filename"); - return; - } - - canvas_makefilename(x->x_canvas, 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); - x->x_play = 0; - x->x_mapaddr = NULL; - 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; - int end = x->x_size/sizeof(short); - 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 (offset > end) - offset = end; - - if (offset + n*c*speed > end) { // playing forward end - if (!x->x_loop) { - x->x_play=0; - offset = x->x_skip*c; - } - } - - if (offset + n*c*speed < 0) { // playing backwards end - if (!x->x_loop) { - x->x_play=0; - offset = end; - } - - } - - - if (x->x_play && x->x_mapaddr) { - - if (speed != 1) { /* different speed */ - float aoff = (((int)offset)>>1)<<1; - float frac = offset - (int)offset; - while (n--) { - for (i=0;i<c;i++) { - t_sample as = *(buf+(int)aoff+i)*3.052689e-05; - t_sample bs = *(buf+(int)aoff+i+c)*3.052689e-05; - - *out[i]++ = as + frac*(bs-as); - } - offset+=speed*c; - aoff = (((int)offset)>>1)<<1; - if (aoff > end) { - if (x->x_loop) aoff = x->x_skip; - else break; - } - if (aoff < 0) { - if (x->x_loop) aoff = end; - else break; - } - } - /* Fill with zero in case of end */ - n++; - while (n--) - for (i=0;i<c;i++) - *out[i]++ = 0; - offset = aoff; - } - else { /* speed == 1 */ - int aoff = (((int)offset)>>1)<<1; - while (n--) { - for (i=0;i<c;i++) { - *out[i]++ = *(buf+aoff+i)*3.052689e-05; - } - aoff+=c; - if (aoff > end) { - if (x->x_loop) aoff = x->x_skip; - else break; - } - } - - /* Fill with zero in case of end */ - n++; - while (n--) - for (i=0;i<c;i++) - *out[i]++ = 0.; - offset = aoff; - } - - } - 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_mapaddr) { - 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_size(t_sfread* x) -{ - t_atom a; - - SETFLOAT(&a,x->x_size*0.5/x->x_channels); - outlet_list(x->x_bangout, gensym("size"),1,&a); -} - -static void sfread_state(t_sfread* x) -{ - t_atom a; - - SETFLOAT(&a,x->x_play); - outlet_list(x->x_bangout, gensym("state"),1,&a); -} - - - - -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_canvas = canvas_getcurrent(); - - if (c<1 || c > MAX_CHANS) c = 1; - floatinlet_new(&x->x_obj, &x->x_offset); - floatinlet_new(&x->x_obj, &x->x_speed); - - - x->x_fd = -1; - x->x_mapaddr = NULL; - - x->x_size = 0; - 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")); - } - - x->x_bangout = outlet_new(&x->x_obj, &s_float); - -/* post("sfread: x_channels = %d, x_speed = %f",x->x_channels,x->x_speed);*/ - - return (x); -} - -void sfread_tilde_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_addmethod(sfread_class, (t_method) sfread_size, gensym("size"), 0); - class_addmethod(sfread_class, (t_method) sfread_state, gensym("state"), 0); - 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/signal/stream.h b/signal/stream.h index 331cf30..3ccc205 100755 --- a/signal/stream.h +++ b/signal/stream.h @@ -8,8 +8,7 @@ #define SF_ALAW 20
#define SF_MP3 30
-#define SF_SIZEOF(a) (a == SF_FLOAT ? sizeof(t_float) : \
- a == SF_16BIT ? sizeof(short) : 1)
+#define SF_SIZEOF(a) (a == SF_FLOAT ? sizeof(t_float) : a == SF_16BIT ? sizeof(short) : 1)
diff --git a/signal/streamout~.c b/signal/streamout~.c index 16150b7..e020419 100755 --- a/signal/streamout~.c +++ b/signal/streamout~.c @@ -17,11 +17,6 @@ #include <winsock.h>
#endif
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
/* Utility functions */
|