aboutsummaryrefslogtreecommitdiff
path: root/pd/src/d_soundfile.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-10-09 16:41:04 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-10-09 16:41:04 +0000
commite1fc51c3a1d944193032d8bb1d95741d090b6d3b (patch)
tree7a2121c73a5acb69a080e73ad8e3b50cc3670616 /pd/src/d_soundfile.c
parent21c068f1916330e90f814bed461fe0821d1665ec (diff)
checked in pd-0.43-1test4.src.tar.gz
svn path=/trunk/; revision=15558
Diffstat (limited to 'pd/src/d_soundfile.c')
-rw-r--r--pd/src/d_soundfile.c13
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)