diff options
Diffstat (limited to 'pd/src/d_soundfile.c')
-rw-r--r-- | pd/src/d_soundfile.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/pd/src/d_soundfile.c b/pd/src/d_soundfile.c index 8c350305..ef121e11 100644 --- a/pd/src/d_soundfile.c +++ b/pd/src/d_soundfile.c @@ -286,7 +286,8 @@ int open_soundfile_via_fd(int fd, int headersize, { long chunksize = swap4(((t_wavechunk *)buf)->wc_size, swap), seekto = headersize + chunksize + 8, seekout; - + if (seekto & 1) /* pad up to even number of bytes */ + seekto++; if (!strncmp(((t_wavechunk *)buf)->wc_id, "fmt ", 4)) { long commblockonset = headersize + 8; @@ -338,6 +339,8 @@ int open_soundfile_via_fd(int fd, int headersize, { long chunksize = swap4(((t_datachunk *)buf)->dc_size, swap), seekto = headersize + chunksize + 8, seekout; + if (seekto & 1) /* pad up to even number of bytes */ + seekto++; /* post("chunk %c %c %c %c seek %d", ((t_datachunk *)buf)->dc_id[0], ((t_datachunk *)buf)->dc_id[1], @@ -368,8 +371,8 @@ int open_soundfile_via_fd(int fd, int headersize, goto badheader; headersize = seekto; } - bytelimit = swap4(((t_datachunk *)buf)->dc_size, swap); - headersize += 8; + bytelimit = swap4(((t_datachunk *)buf)->dc_size, swap) - 8; + headersize += sizeof(t_datachunk); } } /* seek past header and any sample frames to skip */ @@ -784,7 +787,7 @@ static int create_soundfile(t_canvas *canvas, const char *filename, memcpy(&aiffhdr->a_nframeshi, &longtmp, 4); aiffhdr->a_bitspersamp = swap2(8 * bytespersamp, swap); memcpy(aiffhdr->a_samprate, dogdoo, sizeof(dogdoo)); - longtmp = swap4(datasize, swap); + longtmp = swap4(datasize + 8, swap); memcpy(aiffhdr->a_samprate + sizeof(dogdoo), &longtmp, 4); memset(aiffhdr->a_samprate + sizeof(dogdoo) + 4, 0, 8); headersize = AIFFPLUS; @@ -1327,7 +1330,7 @@ static void soundfiler_read(t_soundfiler *x, t_symbol *s, goto done; usage: pd_error(x, "usage: read [flags] filename tablename..."); - post("flags: -skip <n> -nframes <n> -resize -maxsize <n> ..."); + post("flags: -skip <n> -resize -maxsize <n> ..."); post("-raw <headerbytes> <channels> <bytespersamp> <endian (b, l, or n)>."); done: if (fd >= 0) |