Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6286
Modified Files: Tag: desiredata d_soundfile.c Log Message: removed s_ prefixes
Index: d_soundfile.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/d_soundfile.c,v retrieving revision 1.4.4.11.2.10.2.13 retrieving revision 1.4.4.11.2.10.2.14 diff -C2 -d -r1.4.4.11.2.10.2.13 -r1.4.4.11.2.10.2.14 *** d_soundfile.c 10 Jul 2007 05:50:22 -0000 1.4.4.11.2.10.2.13 --- d_soundfile.c 18 Jul 2007 03:37:24 -0000 1.4.4.11.2.10.2.14 *************** *** 397,402 **** t_symbol *filesym; float rate = -1; ! while (argc > 0 && argv->a_type == A_SYMBOL && *argv->a_symbol->s_name == '-') { ! char *flag = argv->a_symbol->s_name + 1; if (!strcmp(flag, "skip")) { if (argc < 2 || argv[1].a_type != A_FLOAT || ((onset = (long) argv[1].a_float) < 0)) goto usage; --- 397,402 ---- t_symbol *filesym; float rate = -1; ! while (argc > 0 && argv->a_type == A_SYMBOL && *argv->a_symbol->name == '-') { ! char *flag = argv->a_symbol->name + 1; if (!strcmp(flag, "skip")) { if (argc < 2 || argv[1].a_type != A_FLOAT || ((onset = (long) argv[1].a_float) < 0)) goto usage; *************** *** 423,431 **** /* check if format not specified and fill in */ if (filetype < 0) { ! const char *s = filesym->s_name + strlen(filesym->s_name); ! if (strlen(filesym->s_name) >= 5 && !strcmp(s-4, ".aif") || !strcmp(s-4, ".AIF")) filetype = FORMAT_AIFF; ! if (strlen(filesym->s_name) >= 6 && !strcmp(s-5, ".aiff") || !strcmp(s-5, ".AIFF")) filetype = FORMAT_AIFF; ! if (strlen(filesym->s_name) >= 5 && !strcmp(s-4, ".snd") || !strcmp(s-4, ".SND")) filetype = FORMAT_NEXT; ! if (strlen(filesym->s_name) >= 4 && !strcmp(s-3, ".au") || !strcmp(s-3, ".AU")) filetype = FORMAT_NEXT; if (filetype < 0) filetype = FORMAT_WAVE; } --- 423,431 ---- /* check if format not specified and fill in */ if (filetype < 0) { ! const char *s = filesym->name + strlen(filesym->name); ! if (strlen(filesym->name) >= 5 && !strcmp(s-4, ".aif") || !strcmp(s-4, ".AIF")) filetype = FORMAT_AIFF; ! if (strlen(filesym->name) >= 6 && !strcmp(s-5, ".aiff") || !strcmp(s-5, ".AIFF")) filetype = FORMAT_AIFF; ! if (strlen(filesym->name) >= 5 && !strcmp(s-4, ".snd") || !strcmp(s-4, ".SND")) filetype = FORMAT_NEXT; ! if (strlen(filesym->name) >= 4 && !strcmp(s-3, ".au") || !strcmp(s-3, ".AU")) filetype = FORMAT_NEXT; if (filetype < 0) filetype = FORMAT_WAVE; } *************** *** 822,827 **** pthread_mutex_t resume_after_callback_mutex = PTHREAD_MUTEX_INITIALIZER; /* dummy */ t_int* outargs; ! while (argc > 0 && argv->a_type == A_SYMBOL && *argv->a_symbol->s_name == '-') { ! char *flag = argv->a_symbol->s_name + 1; if (!strcmp(flag, "skip")) { if (argc < 2 || argv[1].a_type != A_FLOAT || ((skipframes = long(argv[1].a_float)) < 0)) goto usage; --- 822,827 ---- pthread_mutex_t resume_after_callback_mutex = PTHREAD_MUTEX_INITIALIZER; /* dummy */ t_int* outargs; ! while (argc > 0 && argv->a_type == A_SYMBOL && *argv->a_symbol->name == '-') { ! char *flag = argv->a_symbol->name + 1; if (!strcmp(flag, "skip")) { if (argc < 2 || argv[1].a_type != A_FLOAT || ((skipframes = long(argv[1].a_float)) < 0)) goto usage; *************** *** 838,842 **** (bytespersamp > 4) || argv[4].a_type != A_SYMBOL || ! ((endianness = argv[4].a_symbol->s_name[0]) != 'b' && endianness != 'l' && endianness != 'n')) goto usage; --- 838,842 ---- (bytespersamp > 4) || argv[4].a_type != A_SYMBOL || ! ((endianness = argv[4].a_symbol->name[0]) != 'b' && endianness != 'l' && endianness != 'n')) goto usage; *************** *** 855,868 **** } if (argc < 2 || argc > MAXSFCHANS + 1 || argv[0].a_type != A_SYMBOL) goto usage; ! filename = argv[0].a_symbol->s_name; argc--; argv++; for (i = 0; i < argc; i++) { if (argv[i].a_type != A_SYMBOL) goto usage; if (!(garrays[i] = (t_garray *)pd_findbyclass(argv[i].a_symbol, garray_class))) { ! pd_error(x, "%s: no such table", argv[i].a_symbol->s_name); goto done; } else if (!garray_getfloatarray(garrays[i], &vecsize[i], &vecs[i])) ! error("%s: bad template for tabwrite", argv[i].a_symbol->s_name); if (finalsize && finalsize != vecsize[i] && !resize) { post("soundfiler_read: arrays have different lengths; resizing..."); --- 855,868 ---- } if (argc < 2 || argc > MAXSFCHANS + 1 || argv[0].a_type != A_SYMBOL) goto usage; ! filename = argv[0].a_symbol->name; argc--; argv++; for (i = 0; i < argc; i++) { if (argv[i].a_type != A_SYMBOL) goto usage; if (!(garrays[i] = (t_garray *)pd_findbyclass(argv[i].a_symbol, garray_class))) { ! pd_error(x, "%s: no such table", argv[i].a_symbol->name); goto done; } else if (!garray_getfloatarray(garrays[i], &vecsize[i], &vecs[i])) ! error("%s: bad template for tabwrite", argv[i].a_symbol->name); if (finalsize && finalsize != vecsize[i] && !resize) { post("soundfiler_read: arrays have different lengths; resizing..."); *************** *** 871,875 **** finalsize = vecsize[i]; } ! fd = open_soundfile(canvas_getdir(x->canvas)->s_name, filename, headersize, &bytespersamp, &bigendian, &channels, &bytelimit, skipframes); if (fd < 0) { pd_error(x, "soundfiler_read: %s: %s", filename, (errno == EIO ? "unknown or bad header format" : strerror(errno))); --- 871,875 ---- finalsize = vecsize[i]; } ! fd = open_soundfile(canvas_getdir(x->canvas)->name, filename, headersize, &bytespersamp, &bigendian, &channels, &bytelimit, skipframes); if (fd < 0) { pd_error(x, "soundfiler_read: %s: %s", filename, (errno == EIO ? "unknown or bad header format" : strerror(errno))); *************** *** 1046,1054 **** if (argv[i].a_type != A_SYMBOL) goto usage; if (!(garrays[i] = (t_garray *)pd_findbyclass(argv[i].a_symbol, garray_class))) { ! pd_error(obj, "%s: no such table", argv[i].a_symbol->s_name); goto fail; } else if (!garray_getfloatarray(garrays[i], &vecsize, &vecs[i])) ! error("%s: bad template for tabwrite", argv[i].a_symbol->s_name); if (nframes > vecsize - onset) nframes = vecsize - onset; --- 1046,1054 ---- if (argv[i].a_type != A_SYMBOL) goto usage; if (!(garrays[i] = (t_garray *)pd_findbyclass(argv[i].a_symbol, garray_class))) { ! pd_error(obj, "%s: no such table", argv[i].a_symbol->name); goto fail; } else if (!garray_getfloatarray(garrays[i], &vecsize, &vecs[i])) ! error("%s: bad template for tabwrite", argv[i].a_symbol->name); if (nframes > vecsize - onset) nframes = vecsize - onset; *************** *** 1062,1074 **** goto fail; } ! if ((fd = create_soundfile(canvas, filesym->s_name, filetype, nframes, bytespersamp, bigendian, nchannels, swap, samplerate)) < 0) { ! post("%s: %s\n", filesym->s_name, strerror(errno)); goto fail; } if (!normalize) { if ((bytespersamp != 4) && (biggest > 1)) { ! post("%s: normalizing max amplitude %f to 1", filesym->s_name, biggest); normalize = 1; ! } else post("%s: biggest amplitude = %f", filesym->s_name, biggest); } if (normalize) normfactor = (biggest > 0 ? 32767./(32768. * biggest) : 1); --- 1062,1074 ---- goto fail; } ! if ((fd = create_soundfile(canvas, filesym->name, filetype, nframes, bytespersamp, bigendian, nchannels, swap, samplerate)) < 0) { ! post("%s: %s\n", filesym->name, strerror(errno)); goto fail; } if (!normalize) { if ((bytespersamp != 4) && (biggest > 1)) { ! post("%s: normalizing max amplitude %f to 1", filesym->name, biggest); normalize = 1; ! } else post("%s: biggest amplitude = %f", filesym->name, biggest); } if (normalize) normfactor = (biggest > 0 ? 32767./(32768. * biggest) : 1); *************** *** 1081,1085 **** nbytes = write(fd, sampbuf, nchannels * bytespersamp * thiswrite); if (nbytes < nchannels * bytespersamp * thiswrite) { ! post("%s: %s", filesym->s_name, strerror(errno)); if (nbytes > 0) itemswritten += nbytes / (nchannels * bytespersamp); break; --- 1081,1085 ---- nbytes = write(fd, sampbuf, nchannels * bytespersamp * thiswrite); if (nbytes < nchannels * bytespersamp * thiswrite) { ! post("%s: %s", filesym->name, strerror(errno)); if (nbytes > 0) itemswritten += nbytes / (nchannels * bytespersamp); break; *************** *** 1089,1093 **** } if (fd >= 0) { ! soundfile_finishwrite(obj, filesym->s_name, fd, filetype, nframes, itemswritten, nchannels * bytespersamp, swap); close (fd); } --- 1089,1093 ---- } if (fd >= 0) { ! soundfile_finishwrite(obj, filesym->name, fd, filetype, nframes, itemswritten, nchannels * bytespersamp, swap); close (fd); } *************** *** 1125,1129 **** t_garray *x = (t_garray *)pd_findbyclass(argv[0].a_symbol, garray_class); if (!(x)) { ! pd_error(y, "%s: no such table", argv[0].a_symbol->s_name); goto usage; } --- 1125,1129 ---- t_garray *x = (t_garray *)pd_findbyclass(argv[0].a_symbol, garray_class); if (!(x)) { ! pd_error(y, "%s: no such table", argv[0].a_symbol->name); goto usage; } *************** *** 1194,1198 **** t_garray * x = (t_garray *)pd_findbyclass(argv[0].a_symbol, garray_class); if (!(x)) { ! pd_error(y, "%s: no such table", argv[0].a_symbol->s_name); goto usage; } --- 1194,1198 ---- t_garray * x = (t_garray *)pd_findbyclass(argv[0].a_symbol, garray_class); if (!(x)) { ! pd_error(y, "%s: no such table", argv[0].a_symbol->name); goto usage; } *************** *** 1273,1278 **** int bufframes, nitems; FILE *fp; ! while (argc > 0 && argv->a_type == A_SYMBOL && *argv->a_symbol->s_name == '-') { ! char *flag = argv->a_symbol->s_name + 1; if (!strcmp(flag, "skip")) { if (argc < 2 || argv[1].a_type != A_FLOAT || ((skipframes = long(argv[1].a_float)) < 0)) goto usage; --- 1273,1278 ---- int bufframes, nitems; FILE *fp; ! while (argc > 0 && argv->a_type == A_SYMBOL && *argv->a_symbol->name == '-') { ! char *flag = argv->a_symbol->name + 1; if (!strcmp(flag, "skip")) { if (argc < 2 || argv[1].a_type != A_FLOAT || ((skipframes = long(argv[1].a_float)) < 0)) goto usage; *************** *** 1289,1293 **** (bytespersamp > 4) || argv[4].a_type != A_SYMBOL || ! ((endianness = argv[4].a_symbol->s_name[0]) != 'b' && endianness != 'l' && endianness != 'n')) goto usage; if (endianness == 'b') bigendian = 1; --- 1289,1293 ---- (bytespersamp > 4) || argv[4].a_type != A_SYMBOL || ! ((endianness = argv[4].a_symbol->name[0]) != 'b' && endianness != 'l' && endianness != 'n')) goto usage; if (endianness == 'b') bigendian = 1; *************** *** 1305,1309 **** } if (argc < 2 || argc > MAXSFCHANS + 1 || argv[0].a_type != A_SYMBOL) goto usage; ! filename = argv[0].a_symbol->s_name; argc--; argv++; for (i = 0; i < argc; i++) { --- 1305,1309 ---- } if (argc < 2 || argc > MAXSFCHANS + 1 || argv[0].a_type != A_SYMBOL) goto usage; ! filename = argv[0].a_symbol->name; argc--; argv++; for (i = 0; i < argc; i++) { *************** *** 1311,1318 **** if (argv[i].a_type != A_SYMBOL) goto usage; if (!(garrays[i] = (t_garray *)pd_findbyclass(argv[i].a_symbol, garray_class))) { ! pd_error(x, "%s: no such table", argv[i].a_symbol->s_name); goto done; } else if (!garray_getfloatarray(garrays[i], &vecsize, &vecs[i])) ! error("%s: bad template for tabwrite", argv[i].a_symbol->s_name); if (finalsize && finalsize != vecsize && !resize) { post("soundfiler_read: arrays have different lengths; resizing..."); --- 1311,1318 ---- if (argv[i].a_type != A_SYMBOL) goto usage; if (!(garrays[i] = (t_garray *)pd_findbyclass(argv[i].a_symbol, garray_class))) { ! pd_error(x, "%s: no such table", argv[i].a_symbol->name); goto done; } else if (!garray_getfloatarray(garrays[i], &vecsize, &vecs[i])) ! error("%s: bad template for tabwrite", argv[i].a_symbol->name); if (finalsize && finalsize != vecsize && !resize) { post("soundfiler_read: arrays have different lengths; resizing..."); *************** *** 1417,1425 **** if (argv[i].a_type != A_SYMBOL) goto usage; if (!(garrays[i] = (t_garray *)pd_findbyclass(argv[i].a_symbol, garray_class))) { ! pd_error(obj, "%s: no such table", argv[i].a_symbol->s_name); goto fail; } else if (!garray_getfloatarray(garrays[i], &vecsize, &vecs[i])) ! error("%s: bad template for tabwrite", argv[i].a_symbol->s_name); if (nframes > vecsize - onset) nframes = vecsize - onset; --- 1417,1425 ---- if (argv[i].a_type != A_SYMBOL) goto usage; if (!(garrays[i] = (t_garray *)pd_findbyclass(argv[i].a_symbol, garray_class))) { ! pd_error(obj, "%s: no such table", argv[i].a_symbol->name); goto fail; } else if (!garray_getfloatarray(garrays[i], &vecsize, &vecs[i])) ! error("%s: bad template for tabwrite", argv[i].a_symbol->name); if (nframes > vecsize - onset) nframes = vecsize - onset; *************** *** 1433,1445 **** goto fail; } ! if ((fd = create_soundfile(canvas, filesym->s_name, filetype, nframes, bytespersamp, bigendian, nchannels, swap, samplerate)) < 0) { ! post("%s: %s\n", filesym->s_name, strerror(errno)); goto fail; } if (!normalize) { if ((bytespersamp != 4) && (biggest > 1)) { ! post("%s: normalizing max amplitude %f to 1", filesym->s_name, biggest); normalize = 1; ! } else post("%s: biggest amplitude = %f", filesym->s_name, biggest); } if (normalize) normfactor = (biggest > 0 ? 32767./(32768. * biggest) : 1); else normfactor = 1; --- 1433,1445 ---- goto fail; } ! if ((fd = create_soundfile(canvas, filesym->name, filetype, nframes, bytespersamp, bigendian, nchannels, swap, samplerate)) < 0) { ! post("%s: %s\n", filesym->name, strerror(errno)); goto fail; } if (!normalize) { if ((bytespersamp != 4) && (biggest > 1)) { ! post("%s: normalizing max amplitude %f to 1", filesym->name, biggest); normalize = 1; ! } else post("%s: biggest amplitude = %f", filesym->name, biggest); } if (normalize) normfactor = (biggest > 0 ? 32767./(32768. * biggest) : 1); else normfactor = 1; *************** *** 1451,1455 **** nbytes = write(fd, sampbuf, nchannels * bytespersamp * thiswrite); if (nbytes < nchannels * bytespersamp * thiswrite) { ! post("%s: %s", filesym->s_name, strerror(errno)); if (nbytes > 0) itemswritten += nbytes / (nchannels * bytespersamp); break; --- 1451,1455 ---- nbytes = write(fd, sampbuf, nchannels * bytespersamp * thiswrite); if (nbytes < nchannels * bytespersamp * thiswrite) { ! post("%s: %s", filesym->name, strerror(errno)); if (nbytes > 0) itemswritten += nbytes / (nchannels * bytespersamp); break; *************** *** 1459,1463 **** } if (fd >= 0) { ! soundfile_finishwrite(obj, filesym->s_name, fd, filetype, nframes, itemswritten, nchannels * bytespersamp, swap); close (fd); } --- 1459,1463 ---- } if (fd >= 0) { ! soundfile_finishwrite(obj, filesym->name, fd, filetype, nframes, itemswritten, nchannels * bytespersamp, swap); close (fd); } *************** *** 1609,1613 **** int bigendian = x->bigendian; char *filename = x->filename; ! char *dirname = canvas_getdir(x->canvas)->s_name; /* alter the request code so that an ensuing "open" will get noticed. */ x->requestcode = REQUEST_BUSY; --- 1609,1613 ---- int bigendian = x->bigendian; char *filename = x->filename; ! char *dirname = canvas_getdir(x->canvas)->name; /* alter the request code so that an ensuing "open" will get noticed. */ x->requestcode = REQUEST_BUSY; *************** *** 1848,1860 **** t_float bytespersamp = atom_getfloatarg(4, argc, argv); t_symbol *endian = atom_getsymbolarg(5, argc, argv); ! if (!*filesym->s_name) return; pthread_mutex_lock(&x->mutex); x->requestcode = REQUEST_OPEN; ! x->filename = filesym->s_name; x->fifotail = 0; x->fifohead = 0; ! if (*endian->s_name == 'b') x->bigendian = 1; ! else if (*endian->s_name == 'l') x->bigendian = 0; ! else if (*endian->s_name) pd_error(x, "endianness neither 'b' nor 'l'"); else x->bigendian = garray_ambigendian(); x->onsetframes = max(long(onsetframes),0L); --- 1848,1860 ---- t_float bytespersamp = atom_getfloatarg(4, argc, argv); t_symbol *endian = atom_getsymbolarg(5, argc, argv); ! if (!*filesym->name) return; pthread_mutex_lock(&x->mutex); x->requestcode = REQUEST_OPEN; ! x->filename = filesym->name; x->fifotail = 0; x->fifohead = 0; ! if (*endian->name == 'b') x->bigendian = 1; ! else if (*endian->name == 'l') x->bigendian = 0; ! else if (*endian->name) pd_error(x, "endianness neither 'b' nor 'l'"); else x->bigendian = garray_ambigendian(); x->onsetframes = max(long(onsetframes),0L); *************** *** 2138,2142 **** x->swap = swap; x->bigendian = bigendian; ! x->filename = filesym->s_name; x->filetype = filetype; x->itemswritten = 0; --- 2138,2142 ---- x->swap = swap; x->bigendian = bigendian; ! x->filename = filesym->name; x->filetype = filetype; x->itemswritten = 0;