Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
purr-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
YARAMALA SIVA SAI VARDHAN REDDY
purr-data
Commits
1d659c01
Commit
1d659c01
authored
12 years ago
by
Ivica Bukvic
Browse files
Options
Downloads
Patches
Plain Diff
bug fix
http://sourceforge.net/tracker/?func=detail&aid=3605379&group_id=55736&atid=478072
parent
48a04675
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pd/src/d_math.c
+67
-17
67 additions, 17 deletions
pd/src/d_math.c
with
67 additions
and
17 deletions
pd/src/d_math.c
+
67
−
17
View file @
1d659c01
...
@@ -68,12 +68,11 @@ static void clip_setup(void)
...
@@ -68,12 +68,11 @@ static void clip_setup(void)
#define DUMTAB2SIZE 1024
#define DUMTAB2SIZE 1024
#ifdef MSW
#ifdef MSW
#define int32 long
typedef
__int32
int32_t
;
/* use MSVC's internal type */
#endif
#elif defined(IRIX)
typedef
long
int32_t
;
/* a data type that has 32 bits */
#if defined(__unix__) || defined(__APPLE__)
#else
#include
<sys/types.h>
# include <stdint.h>
/* this is where int32_t is defined in C99 */
#define int32 int32_t
#endif
#endif
static
float
rsqrt_exptab
[
DUMTAB1SIZE
],
rsqrt_mantissatab
[
DUMTAB2SIZE
];
static
float
rsqrt_exptab
[
DUMTAB1SIZE
],
rsqrt_mantissatab
[
DUMTAB2SIZE
];
...
@@ -84,8 +83,8 @@ static void init_rsqrt(void)
...
@@ -84,8 +83,8 @@ static void init_rsqrt(void)
for
(
i
=
0
;
i
<
DUMTAB1SIZE
;
i
++
)
for
(
i
=
0
;
i
<
DUMTAB1SIZE
;
i
++
)
{
{
float
f
;
float
f
;
int32
l
=
(
i
?
(
i
==
DUMTAB1SIZE
-
1
?
DUMTAB1SIZE
-
2
:
i
)
:
1
)
<<
23
;
int32
_t
l
=
(
i
?
(
i
==
DUMTAB1SIZE
-
1
?
DUMTAB1SIZE
-
2
:
i
)
:
1
)
<<
23
;
*
(
int32
*
)(
&
f
)
=
l
;
*
(
int32
_t
*
)(
&
f
)
=
l
;
rsqrt_exptab
[
i
]
=
1
.
/
sqrt
(
f
);
rsqrt_exptab
[
i
]
=
1
.
/
sqrt
(
f
);
}
}
for
(
i
=
0
;
i
<
DUMTAB2SIZE
;
i
++
)
for
(
i
=
0
;
i
<
DUMTAB2SIZE
;
i
++
)
...
@@ -97,16 +96,18 @@ static void init_rsqrt(void)
...
@@ -97,16 +96,18 @@ static void init_rsqrt(void)
/* these are used in externs like "bonk" */
/* these are used in externs like "bonk" */
t_float
q8_rsqrt
(
t_float
f
)
t_float
q8_rsqrt
(
t_float
f
0
)
{
{
float
f
=
(
float
)
f0
;
long
l
=
*
(
long
*
)(
&
f
);
long
l
=
*
(
long
*
)(
&
f
);
if
(
f
<
0
)
return
(
0
);
if
(
f
<
0
)
return
(
0
);
else
return
(
rsqrt_exptab
[(
l
>>
23
)
&
0xff
]
*
else
return
(
rsqrt_exptab
[(
l
>>
23
)
&
0xff
]
*
rsqrt_mantissatab
[(
l
>>
13
)
&
0x3ff
]);
rsqrt_mantissatab
[(
l
>>
13
)
&
0x3ff
]);
}
}
t_float
q8_sqrt
(
t_float
f
)
t_float
q8_sqrt
(
t_float
f
0
)
{
{
float
f
=
(
float
)
f0
;
long
l
=
*
(
long
*
)(
&
f
);
long
l
=
*
(
long
*
)(
&
f
);
if
(
f
<
0
)
return
(
0
);
if
(
f
<
0
)
return
(
0
);
else
return
(
f
*
rsqrt_exptab
[(
l
>>
23
)
&
0xff
]
*
else
return
(
f
*
rsqrt_exptab
[(
l
>>
23
)
&
0xff
]
*
...
@@ -556,7 +557,7 @@ void powtodb_tilde_setup(void)
...
@@ -556,7 +557,7 @@ void powtodb_tilde_setup(void)
}
}
/* ----------------------------- pow ----------------------------- */
/* ----------------------------- pow ----------------------------- */
static
t_class
*
pow_tilde_class
;
static
t_class
*
pow_tilde_class
,
*
scalarpow_tilde_class
;
typedef
struct
_pow_tilde
typedef
struct
_pow_tilde
{
{
...
@@ -564,13 +565,34 @@ typedef struct _pow_tilde
...
@@ -564,13 +565,34 @@ typedef struct _pow_tilde
t_float
x_f
;
t_float
x_f
;
}
t_pow_tilde
;
}
t_pow_tilde
;
typedef
struct
_scalarpow_tilde
{
t_object
x_obj
;
t_float
x_f
;
t_float
x_g
;
}
t_scalarpow_tilde
;
static
void
*
pow_tilde_new
(
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
static
void
*
pow_tilde_new
(
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
{
t_pow_tilde
*
x
=
(
t_pow_tilde
*
)
pd_new
(
pow_tilde_class
);
if
(
argc
>
1
)
post
(
"pow~: extra arguments ignored"
);
inlet_new
(
&
x
->
x_obj
,
&
x
->
x_obj
.
ob_pd
,
&
s_signal
,
&
s_signal
);
if
(
argc
)
outlet_new
(
&
x
->
x_obj
,
&
s_signal
);
{
x
->
x_f
=
0
;
t_scalarpow_tilde
*
x
=
return
(
x
);
(
t_scalarpow_tilde
*
)
pd_new
(
scalarpow_tilde_class
);
floatinlet_new
(
&
x
->
x_obj
,
&
x
->
x_g
);
x
->
x_g
=
atom_getfloatarg
(
0
,
argc
,
argv
);
outlet_new
(
&
x
->
x_obj
,
&
s_signal
);
x
->
x_f
=
0
;
return
(
x
);
}
else
{
t_pow_tilde
*
x
=
(
t_pow_tilde
*
)
pd_new
(
pow_tilde_class
);
inlet_new
(
&
x
->
x_obj
,
&
x
->
x_obj
.
ob_pd
,
&
s_signal
,
&
s_signal
);
outlet_new
(
&
x
->
x_obj
,
&
s_signal
);
x
->
x_f
=
0
;
return
(
x
);
}
}
}
t_int
*
pow_tilde_perform
(
t_int
*
w
)
t_int
*
pow_tilde_perform
(
t_int
*
w
)
...
@@ -591,18 +613,46 @@ t_int *pow_tilde_perform(t_int *w)
...
@@ -591,18 +613,46 @@ t_int *pow_tilde_perform(t_int *w)
return
(
w
+
5
);
return
(
w
+
5
);
}
}
t_int
*
scalarpow_tilde_perform
(
t_int
*
w
)
{
t_sample
*
in
=
(
t_sample
*
)(
w
[
1
]);
t_float
g
=
*
(
t_float
*
)(
w
[
2
]);
t_sample
*
out
=
(
t_sample
*
)(
w
[
3
]);
int
n
=
(
int
)(
w
[
4
]);
while
(
n
--
)
{
t_float
f
=
*
in
++
;
if
(
f
>
0
)
*
out
=
pow
(
f
,
g
);
else
*
out
=
0
;
out
++
;
}
return
(
w
+
5
);
}
static
void
pow_tilde_dsp
(
t_pow_tilde
*
x
,
t_signal
**
sp
)
static
void
pow_tilde_dsp
(
t_pow_tilde
*
x
,
t_signal
**
sp
)
{
{
dsp_add
(
pow_tilde_perform
,
4
,
dsp_add
(
pow_tilde_perform
,
4
,
sp
[
0
]
->
s_vec
,
sp
[
1
]
->
s_vec
,
sp
[
2
]
->
s_vec
,
sp
[
0
]
->
s_n
);
sp
[
0
]
->
s_vec
,
sp
[
1
]
->
s_vec
,
sp
[
2
]
->
s_vec
,
sp
[
0
]
->
s_n
);
}
}
static
void
scalarpow_tilde_dsp
(
t_scalarpow_tilde
*
x
,
t_signal
**
sp
)
{
dsp_add
(
scalarpow_tilde_perform
,
4
,
sp
[
0
]
->
s_vec
,
&
x
->
x_g
,
sp
[
1
]
->
s_vec
,
sp
[
0
]
->
s_n
);
}
static
void
pow_tilde_setup
(
void
)
static
void
pow_tilde_setup
(
void
)
{
{
pow_tilde_class
=
class_new
(
gensym
(
"pow~"
),
(
t_newmethod
)
pow_tilde_new
,
0
,
pow_tilde_class
=
class_new
(
gensym
(
"pow~"
),
(
t_newmethod
)
pow_tilde_new
,
0
,
sizeof
(
t_pow_tilde
),
0
,
A_
DEFFLOAT
,
0
);
sizeof
(
t_pow_tilde
),
0
,
A_
GIMME
,
0
);
CLASS_MAINSIGNALIN
(
pow_tilde_class
,
t_pow_tilde
,
x_f
);
CLASS_MAINSIGNALIN
(
pow_tilde_class
,
t_pow_tilde
,
x_f
);
class_addmethod
(
pow_tilde_class
,
(
t_method
)
pow_tilde_dsp
,
gensym
(
"dsp"
),
0
);
class_addmethod
(
pow_tilde_class
,
(
t_method
)
pow_tilde_dsp
,
gensym
(
"dsp"
),
0
);
scalarpow_tilde_class
=
class_new
(
gensym
(
"pow~"
),
0
,
0
,
sizeof
(
t_scalarpow_tilde
),
0
,
0
);
CLASS_MAINSIGNALIN
(
scalarpow_tilde_class
,
t_scalarpow_tilde
,
x_f
);
class_addmethod
(
scalarpow_tilde_class
,
(
t_method
)
scalarpow_tilde_dsp
,
gensym
(
"dsp"
),
0
);
}
}
/* ----------------------------- exp ----------------------------- */
/* ----------------------------- exp ----------------------------- */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment