Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32457
Modified Files: Tag: desiredata d_soundfile.c Log Message: cleanup
Index: d_soundfile.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/d_soundfile.c,v retrieving revision 1.4.4.11.2.10.2.21 retrieving revision 1.4.4.11.2.10.2.22 diff -C2 -d -r1.4.4.11.2.10.2.21 -r1.4.4.11.2.10.2.22 *** d_soundfile.c 19 Jul 2007 07:07:34 -0000 1.4.4.11.2.10.2.21 --- d_soundfile.c 19 Jul 2007 16:24:21 -0000 1.4.4.11.2.10.2.22 *************** *** 525,547 **** /* try to fix size fields in header */ if (filetype == FORMAT_WAVE) { ! long datasize = itemswritten * bytesperframe, mofo; if (lseek(fd, ((char *)(&((t_wave *)0)->chunksize)) - (char *)0, SEEK_SET) == 0) goto baddonewrite; ! mofo = swap4(datasize + sizeof(t_wave) - 8, swap); ! if (write(fd, (char *)(&mofo), 4) < 4) goto baddonewrite; if (lseek(fd, ((char *)(&((t_wave *)0)->datachunksize)) - (char *)0, SEEK_SET) == 0) goto baddonewrite; ! mofo = swap4(datasize, swap); ! if (write(fd, (char *)(&mofo), 4) < 4) goto baddonewrite; } if (filetype == FORMAT_AIFF) { ! long mofo; if (lseek(fd, ((char *)(&((t_aiff *)0)->nframeshi)) - (char *)0, SEEK_SET) == 0) goto baddonewrite; ! mofo = swap4(itemswritten, swap); ! if (write(fd, (char *)(&mofo), 4) < 4) goto baddonewrite; if (lseek(fd, ((char *)(&((t_aiff *)0)->chunksize)) - (char *)0, SEEK_SET) == 0) goto baddonewrite; ! mofo = swap4(itemswritten*bytesperframe+AIFFHDRSIZE, swap); ! if (write(fd, (char *)(&mofo), 4) < 4) goto baddonewrite; if (lseek(fd, (AIFFHDRSIZE+4), SEEK_SET) == 0) goto baddonewrite; ! mofo = swap4(itemswritten*bytesperframe, swap); ! if (write(fd, (char *)(&mofo), 4) < 4) goto baddonewrite; } if (filetype == FORMAT_NEXT) { --- 525,547 ---- /* try to fix size fields in header */ if (filetype == FORMAT_WAVE) { ! long datasize = itemswritten * bytesperframe, v; if (lseek(fd, ((char *)(&((t_wave *)0)->chunksize)) - (char *)0, SEEK_SET) == 0) goto baddonewrite; ! v = swap4(datasize + sizeof(t_wave) - 8, swap); ! if (write(fd, (char *)&v, 4) < 4) goto baddonewrite; if (lseek(fd, ((char *)(&((t_wave *)0)->datachunksize)) - (char *)0, SEEK_SET) == 0) goto baddonewrite; ! v = swap4(datasize, swap); ! if (write(fd, (char *)&v, 4) < 4) goto baddonewrite; } if (filetype == FORMAT_AIFF) { ! long v; if (lseek(fd, ((char *)(&((t_aiff *)0)->nframeshi)) - (char *)0, SEEK_SET) == 0) goto baddonewrite; ! v = swap4(itemswritten, swap); ! if (write(fd, (char *)&v,4) < 4) goto baddonewrite; if (lseek(fd, ((char *)(&((t_aiff *)0)->chunksize)) - (char *)0, SEEK_SET) == 0) goto baddonewrite; ! v = swap4(itemswritten*bytesperframe+AIFFHDRSIZE, swap); ! if (write(fd, (char *)&v,4) < 4) goto baddonewrite; if (lseek(fd, (AIFFHDRSIZE+4), SEEK_SET) == 0) goto baddonewrite; ! v = swap4(itemswritten*bytesperframe, swap); ! if (write(fd, (char *)&v,4) < 4) goto baddonewrite; } if (filetype == FORMAT_NEXT) { *************** *** 554,558 **** return; baddonewrite: ! post("%s: %s", filename, strerror(errno)); }
--- 554,558 ---- return; baddonewrite: ! error("%s: %s", filename, strerror(errno)); }
*************** *** 568,575 **** float ff = normalfactor * 32768.; if (bigendian) LOOP { ! int xx = clip(int(32768. + (*fp * ff)) - 0x8000,-0x7fff,+0x7fff); sp2[0] = xx>>8; sp2[1] = xx; } else LOOP { ! int xx = clip(int(32768. + (*fp * ff)) - 0x8000,-0x7fff,+0x7fff); sp2[1] = xx>>8; sp2[0] = xx; } --- 568,575 ---- float ff = normalfactor * 32768.; if (bigendian) LOOP { ! int xx = clip(int(32768. + *fp * ff) - 0x8000,-0x7fff,+0x7fff); sp2[0] = xx>>8; sp2[1] = xx; } else LOOP { ! int xx = clip(int(32768. + *fp * ff) - 0x8000,-0x7fff,+0x7fff); sp2[1] = xx>>8; sp2[0] = xx; } *************** *** 577,584 **** float ff = normalfactor * 8388608.; if (bigendian) LOOP { ! int xx = clip(int(8388608. + (*fp * ff)) - 0x800000,-0x7fffff,+0x7fffff); sp2[0] = xx>>16; sp2[1] = xx>>8; sp2[2] = xx; } else LOOP { ! int xx = clip(int(8388608. + (*fp * ff)) - 0x800000,-0x7fffff,+0x7fffff); sp2[2] = xx>>16; sp2[1] = xx>>8; sp2[0] = xx; } --- 577,584 ---- float ff = normalfactor * 8388608.; if (bigendian) LOOP { ! int xx = clip(int(8388608. + *fp * ff) - 0x800000,-0x7fffff,+0x7fffff); sp2[0] = xx>>16; sp2[1] = xx>>8; sp2[2] = xx; } else LOOP { ! int xx = clip(int(8388608. + *fp * ff) - 0x800000,-0x7fffff,+0x7fffff); sp2[2] = xx>>16; sp2[1] = xx>>8; sp2[0] = xx; } *************** *** 1070,1074 **** return; } - /* TB: we'll have to be sure that no one is accessing the array */ sys_lock(); --- 1070,1073 ---- *************** *** 1105,1109 **** int val; /* value */ char *nvec; /* new array */ - int i; t_garray * x = (t_garray *)pd_findbyclass(argv[0].a_symbol, garray_class); if (!(x)) { --- 1104,1107 ---- *************** *** 1126,1130 **** } /* setting array */ ! for (i=0; i!=size; ++i) nvec[i]=val; /* TB: we'll have to be sure that no one is accessing the array */ sys_lock(); --- 1124,1128 ---- } /* setting array */ ! for (int i=0; i!=size; ++i) nvec[i]=val; /* TB: we'll have to be sure that no one is accessing the array */ sys_lock(); *************** *** 1364,1378 ****
static void soundfiler_setup() { ! soundfiler_class = class_new(gensym("soundfiler"), (t_newmethod)soundfiler_new, 0, sizeof(t_soundfiler), 0, 0); #ifdef THREADED_SF ! class_addmethod(soundfiler_class, (t_method)soundfiler_t_read_addq, gensym("read"), A_GIMME, 0); ! /* class_addmethod(soundfiler_class, (t_method)soundfiler_t_write_addq, */ ! /* gensym("write"), A_GIMME, 0); */ ! class_addmethod(soundfiler_class, (t_method)soundfiler_t_resize_addq, gensym("resize"), A_GIMME, 0); ! class_addmethod(soundfiler_class, (t_method)soundfiler_t_const_addq, gensym("const"), A_GIMME, 0); #else ! class_addmethod(soundfiler_class, (t_method)soundfiler_read, gensym("read"), A_GIMME, 0); #endif /* THREADED_SF */ ! class_addmethod(soundfiler_class, (t_method)soundfiler_write, gensym("write"), A_GIMME, 0); }
--- 1362,1375 ----
static void soundfiler_setup() { ! t_class *c = soundfiler_class = class_new2("soundfiler", (t_newmethod)soundfiler_new, 0, sizeof(t_soundfiler), 0, ""); #ifdef THREADED_SF ! class_addmethod2(c, (t_method)soundfiler_t_read_addq, "read", "*"); ! /* class_addmethod2(c, (t_method)soundfiler_t_write_addq, "write", "*"); */ ! class_addmethod2(c, (t_method)soundfiler_t_resize_addq, "resize", "*"); ! class_addmethod2(c, (t_method)soundfiler_t_const_addq, "const", "*"); #else ! class_addmethod2(c, (t_method)soundfiler_read, "read", "*"); #endif /* THREADED_SF */ ! class_addmethod2(c, (t_method)soundfiler_write, "write", "*"); }
*************** *** 1784,1794 ****
static void readsf_setup() { ! readsf_class = class_new(gensym("readsf~"), (t_newmethod)readsf_new, (t_method)readsf_free, sizeof(t_readsf), 0, A_DEFFLOAT, A_DEFFLOAT, 0); ! class_addfloat(readsf_class, (t_method)readsf_float); ! class_addmethod(readsf_class, (t_method)readsf_start, gensym("start"), 0); ! class_addmethod(readsf_class, (t_method)readsf_stop, gensym("stop"), 0); ! class_addmethod(readsf_class, (t_method)readsf_dsp, gensym("dsp"), 0); ! class_addmethod(readsf_class, (t_method)readsf_open, gensym("open"), A_GIMME, 0); ! class_addmethod(readsf_class, (t_method)readsf_print, gensym("print"), 0); }
--- 1781,1791 ----
static void readsf_setup() { ! t_class *c = readsf_class = class_new2("readsf~", (t_newmethod)readsf_new, (t_method)readsf_free, sizeof(t_readsf), 0, "FF"); ! class_addfloat(c, (t_method)readsf_float); ! class_addmethod2(c, (t_method)readsf_start, "start",""); ! class_addmethod2(c, (t_method)readsf_stop, "stop",""); ! class_addmethod2(c, (t_method)readsf_dsp, "dsp",""); ! class_addmethod2(c, (t_method)readsf_open, "open","*"); ! class_addmethod2(c, (t_method)readsf_print, "print",""); }
*************** *** 2072,2083 ****
static void writesf_setup() { ! writesf_class = class_new(gensym("writesf~"), (t_newmethod)writesf_new, ! (t_method)writesf_free, sizeof(t_writesf), 0, A_DEFFLOAT, A_DEFFLOAT, 0); ! class_addmethod(writesf_class, (t_method)writesf_start, gensym("start"), 0); ! class_addmethod(writesf_class, (t_method)writesf_stop, gensym("stop"), 0); ! class_addmethod(writesf_class, (t_method)writesf_dsp, gensym("dsp"), 0); ! class_addmethod(writesf_class, (t_method)writesf_open, gensym("open"), A_GIMME, 0); ! class_addmethod(writesf_class, (t_method)writesf_print, gensym("print"), 0); ! CLASS_MAINSIGNALIN(writesf_class, t_writesf, f); }
--- 2069,2079 ----
static void writesf_setup() { ! t_class *c = writesf_class = class_new2("writesf~", (t_newmethod)writesf_new, (t_method)writesf_free, sizeof(t_writesf), 0, "FF"); ! class_addmethod2(c, (t_method)writesf_start, "start", ""); ! class_addmethod2(c, (t_method)writesf_stop, "stop", ""); ! class_addmethod2(c, (t_method)writesf_dsp, "dsp", ""); ! class_addmethod2(c, (t_method)writesf_open, "open", "*"); ! class_addmethod2(c, (t_method)writesf_print, "print", ""); ! CLASS_MAINSIGNALIN(c, t_writesf, f); }