...
 
Commits (3)
......@@ -49,6 +49,12 @@ objects use Posix-like threads. */
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef union
{
float f;
uint32_t ui;
}t_aliasfloatuint;
#define FORMAT_WAVE 0
#define FORMAT_AIFF 1
#define FORMAT_NEXT 2
......@@ -463,6 +469,7 @@ static void soundfile_xferin_sample(int sfchannels, int nvecs, t_sample **vecs,
int i, j;
unsigned char *sp, *sp2;
t_sample *fp;
t_aliasfloatuint alias;
int nchannels = (sfchannels < nvecs ? sfchannels : nvecs);
int bytesperframe = bytespersamp * sfchannels;
for (i = 0, sp = buf; i < nchannels; i++, sp += bytespersamp)
......@@ -504,16 +511,22 @@ static void soundfile_xferin_sample(int sfchannels, int nvecs, t_sample **vecs,
if (bigendian)
{
for (j = 0, sp2 = sp, fp=vecs[i] + spread * itemsread;
j < nitems; j++, sp2 += bytesperframe, fp += spread)
*(long *)fp = ((sp2[0] << 24) | (sp2[1] << 16)
j < nitems; j++, sp2 += bytesperframe, fp += spread)
{
alias.ui = ((sp2[0] << 24) | (sp2[1] << 16)
| (sp2[2] << 8) | sp2[3]);
*fp = (t_float)alias.f;
}
}
else
{
for (j = 0, sp2 = sp, fp=vecs[i] + spread * itemsread;
j < nitems; j++, sp2 += bytesperframe, fp += spread)
*(long *)fp = ((sp2[3] << 24) | (sp2[2] << 16)
j < nitems; j++, sp2 += bytesperframe, fp += spread)
{
alias.ui = ((sp2[3] << 24) | (sp2[2] << 16)
| (sp2[1] << 8) | sp2[0]);
*fp = (t_float)alias.f;
}
}
}
}
......@@ -531,6 +544,7 @@ static void soundfile_xferin_float(int sfchannels, int nvecs, t_float **vecs,
int i, j;
unsigned char *sp, *sp2;
t_float *fp;
t_aliasfloatuint alias;
int nchannels = (sfchannels < nvecs ? sfchannels : nvecs);
int bytesperframe = bytespersamp * sfchannels;
for (i = 0, sp = buf; i < nchannels; i++, sp += bytespersamp)
......@@ -572,16 +586,22 @@ static void soundfile_xferin_float(int sfchannels, int nvecs, t_float **vecs,
if (bigendian)
{
for (j = 0, sp2 = sp, fp=vecs[i] + spread * itemsread;
j < nitems; j++, sp2 += bytesperframe, fp += spread)
*(long *)fp = ((sp2[0] << 24) | (sp2[1] << 16)
j < nitems; j++, sp2 += bytesperframe, fp += spread)
{
alias.ui = ((sp2[0] << 24) | (sp2[1] << 16)
| (sp2[2] << 8) | sp2[3]);
*fp = (t_float)alias.f;
}
}
else
{
for (j = 0, sp2 = sp, fp=vecs[i] + spread * itemsread;
j < nitems; j++, sp2 += bytesperframe, fp += spread)
*(long *)fp = ((sp2[3] << 24) | (sp2[2] << 16)
j < nitems; j++, sp2 += bytesperframe, fp += spread)
{
alias.ui = ((sp2[3] << 24) | (sp2[2] << 16)
| (sp2[1] << 8) | sp2[0]);
*fp = (t_float)alias.f;
}
}
}
}
......@@ -932,6 +952,7 @@ static void soundfile_xferout_sample(int nchannels, t_sample **vecs,
int i, j;
unsigned char *sp, *sp2;
t_sample *fp;
t_aliasfloatuint alias;
int bytesperframe = bytespersamp * nchannels;
long xx;
for (i = 0, sp = buf; i < nchannels; i++, sp += bytespersamp)
......@@ -1013,8 +1034,8 @@ static void soundfile_xferout_sample(int nchannels, t_sample **vecs,
for (j = 0, sp2 = sp, fp=vecs[i] + onset;
j < nitems; j++, sp2 += bytesperframe, fp += spread)
{
t_sample f2 = *fp * normalfactor;
xx = *(long *)&f2;
alias.f = (float)(*fp * normalfactor);
xx = alias.ui;
sp2[0] = (xx >> 24); sp2[1] = (xx >> 16);
sp2[2] = (xx >> 8); sp2[3] = xx;
}
......@@ -1024,8 +1045,8 @@ static void soundfile_xferout_sample(int nchannels, t_sample **vecs,
for (j = 0, sp2 = sp, fp=vecs[i] + onset;
j < nitems; j++, sp2 += bytesperframe, fp += spread)
{
t_sample f2 = *fp * normalfactor;
xx = *(long *)&f2;
alias.f = (float)(*fp * normalfactor);
xx = alias.ui;
sp2[3] = (xx >> 24); sp2[2] = (xx >> 16);
sp2[1] = (xx >> 8); sp2[0] = xx;
}
......@@ -1040,6 +1061,7 @@ static void soundfile_xferout_float(int nchannels, t_float **vecs,
int i, j;
unsigned char *sp, *sp2;
t_float *fp;
t_aliasfloatuint alias;
int bytesperframe = bytespersamp * nchannels;
long xx;
for (i = 0, sp = buf; i < nchannels; i++, sp += bytespersamp)
......@@ -1121,8 +1143,8 @@ static void soundfile_xferout_float(int nchannels, t_float **vecs,
for (j = 0, sp2 = sp, fp=vecs[i] + onset;
j < nitems; j++, sp2 += bytesperframe, fp += spread)
{
t_sample f2 = *fp * normalfactor;
xx = *(long *)&f2;
alias.f = (float)(*fp * normalfactor);
xx = alias.ui;
sp2[0] = (xx >> 24); sp2[1] = (xx >> 16);
sp2[2] = (xx >> 8); sp2[3] = xx;
}
......@@ -1132,8 +1154,8 @@ static void soundfile_xferout_float(int nchannels, t_float **vecs,
for (j = 0, sp2 = sp, fp=vecs[i] + onset;
j < nitems; j++, sp2 += bytesperframe, fp += spread)
{
t_sample f2 = *fp * normalfactor;
xx = *(long *)&f2;
alias.f = (float)(*fp * normalfactor);
xx = alias.ui;
sp2[3] = (xx >> 24); sp2[2] = (xx >> 16);
sp2[1] = (xx >> 8); sp2[0] = xx;
}
......
......@@ -1693,7 +1693,8 @@ void binbuf_evalfile(t_symbol *name, t_symbol *dir)
b = newb;
}
binbuf_eval(b, 0, 0, 0);
canvas_initbang((t_canvas *)(s__X.s_thing)); /* JMZ*/
if (s__X.s_thing && pd_class(s__X.s_thing) == canvas_class)
canvas_initbang((t_canvas *)(s__X.s_thing));
gensym("#A")->s_thing = bounda;
s__N.s_thing = boundn;
}
......