Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Flachy Joe
purr-data
Commits
6fac50f5
Commit
6fac50f5
authored
Jun 02, 2018
by
Pranay Gupta
Browse files
changes made to incorporate double values of factors in soundfile access routines
parent
e281c7a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
pd/src/d_soundfile.c
View file @
6fac50f5
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment