...
 
Commits (4)
......@@ -21,7 +21,7 @@ LIBS = -L../../../pd/bin -lc -lm
LIBOSC = ../libOSC/libOSC.a
CFLAGS = -g -O2 -DUNIX -Wall -Wimplicit -Wunused -Wmissing-prototypes -O1 -fPIC -I../libOSC -I../../pd/src -I../../../pd/src -I../src
INCLUDES = -I../libOSC -I../../pd/src -I../../../pd/src -I../src
INCLUDES = -I../libOSC -I../../pd/src -I../../../pd/src -I../src -I/usr/include/tirpc
LDFLAGS = -Wl,--export-dynamic -shared
prefix=/usr/local
......
......@@ -21,7 +21,7 @@ LIBS = @LIBS@
LIBOSC = ../libOSC/@LIBOSC@
CFLAGS = @CFLAGS@
INCLUDES = @INCLUDES@
INCLUDES = @INCLUDES@ -I/usr/include/tirpc
LDFLAGS = @LDFLAGS@
prefix=@prefix@
......
......@@ -30,6 +30,7 @@ objects use Posix-like threads. */
#include <string.h>
#include <errno.h>
#include <math.h>
#include <stdint.h>
#include "m_pd.h"
......@@ -49,6 +50,12 @@ objects use Posix-like threads. */
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef union
{
float f;
unint32_t ui;
}t_aliasfloatuint;
#define FORMAT_WAVE 0
#define FORMAT_AIFF 1
#define FORMAT_NEXT 2
......@@ -463,6 +470,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)
......@@ -505,15 +513,17 @@ static void soundfile_xferin_sample(int sfchannels, int nvecs, t_sample **vecs,
{
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)
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)
alias.ui = ((sp2[3] << 24) | (sp2[2] << 16)
| (sp2[1] << 8) | sp2[0]);
*fp = (t_float)alias.f;
}
}
}
......@@ -531,6 +541,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)
......@@ -573,15 +584,17 @@ static void soundfile_xferin_float(int sfchannels, int nvecs, t_float **vecs,
{
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)
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)
alias.ui = ((sp2[3] << 24) | (sp2[2] << 16)
| (sp2[1] << 8) | sp2[0]);
*fp = (t_float)alias.f;
}
}
}
......@@ -932,6 +945,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 +1027,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 +1038,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 +1054,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 +1136,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 +1147,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;
}
......