Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
purr-data
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rishabh Gupta
purr-data
Commits
a11f73ee
Commit
a11f73ee
authored
Mar 16, 2018
by
Jonathan Wilkes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
now it even compiles under the makefile with ADSR.c included... testing time
parent
e3fe52f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
26 deletions
+32
-26
externals/disis/ADSR.c
externals/disis/ADSR.c
+9
-9
externals/disis/ADSR.h
externals/disis/ADSR.h
+3
-1
externals/disis/disis_munger.c
externals/disis/disis_munger.c
+20
-16
No files found.
externals/disis/ADSR.c
View file @
a11f73ee
#include "ADSR.h"
static
t_float
stk_ADSR_tick
(
t_stk_ADSR
*
x
)
t_float
stk_ADSR_tick
(
t_stk_ADSR
*
x
)
{
switch
(
x
->
state
)
{
case
ATTACK
:
x
->
value
+=
x
->
attackRate
;
if
(
x
->
value
>=
target
)
if
(
x
->
value
>=
x
->
target
)
{
x
->
value
=
x
->
target
;
x
->
target
=
x
->
sustainLevel
;
...
...
@@ -15,7 +15,7 @@ static t_float stk_ADSR_tick(t_stk_ADSR *x)
break
;
case
DECAY
:
if
(
x
->
x_
value
>
x
->
sustainLevel
)
if
(
x
->
value
>
x
->
sustainLevel
)
{
x
->
value
-=
x
->
decayRate
;
if
(
x
->
value
<=
x
->
sustainLevel
)
...
...
@@ -98,7 +98,7 @@ void stk_ADSR_keyOff(t_stk_ADSR *x)
void
stk_ADSR_setAttackRate
(
t_stk_ADSR
*
x
,
t_float
rate
)
{
if
(
x
->
rate
<
0
.
0
)
if
(
rate
<
0
.
0
)
fprintf
(
stderr
,
"stk_ADSR_setAttackRate: argument must be >= 0.0!"
);
x
->
attackRate
=
rate
;
}
...
...
@@ -138,13 +138,13 @@ void stk_ADSR_setReleaseRate(t_stk_ADSR *x, t_float rate)
void
stk_ADSR_setAttackTime
(
t_stk_ADSR
*
x
,
t_float
time
)
{
if
(
x
->
time
<=
0
.
0
)
if
(
time
<=
0
.
0
)
fprintf
(
stderr
,
"ADSR::setAttackTime: negative or zero times not allowed!"
);
x
->
attackRate
=
1
.
0
/
(
time
*
x
->
sampleRate
);
}
void
stk_ADSR_setDecayTime
(
t_float
time
)
void
stk_ADSR_setDecayTime
(
t_
stk_ADSR
*
x
,
t_
float
time
)
{
if
(
time
<=
0
.
0
)
fprintf
(
stderr
,
...
...
@@ -152,7 +152,7 @@ void stk_ADSR_setDecayTime(t_float time)
x
->
decayRate
=
(
1
.
0
-
x
->
sustainLevel
)
/
(
time
*
x
->
sampleRate
);
}
void
stk_ADSR_setReleaseTime
(
t_float
time
)
void
stk_ADSR_setReleaseTime
(
t_
stk_ADSR
*
x
,
t_
float
time
)
{
if
(
time
<=
0
.
0
)
fprintf
(
stderr
,
...
...
@@ -170,7 +170,7 @@ void stk_ADSR_setAllTimes(t_stk_ADSR *x, t_float aTime, t_float dTime,
stk_ADSR_setReleaseTime
(
x
,
rTime
);
}
void
stk_ADSR_setTarget
(
stk_ADSR
*
x
,
t_float
target
)
void
stk_ADSR_setTarget
(
t_
stk_ADSR
*
x
,
t_float
target
)
{
if
(
target
<
0
.
0
)
fprintf
(
stderr
,
"ADSR::setTarget: negative target not allowed!"
);
...
...
@@ -181,7 +181,7 @@ void stk_ADSR_setTarget(stk_ADSR *x, t_float target)
if
(
x
->
value
>
x
->
target
)
x
->
state
=
DECAY
;
}
void
stk_ADSR_setValue
(
stk_ADSR
*
x
,
t_float
value
)
void
stk_ADSR_setValue
(
t_
stk_ADSR
*
x
,
t_float
value
)
{
x
->
state
=
SUSTAIN
;
x
->
target
=
value
;
...
...
externals/disis/ADSR.h
View file @
a11f73ee
#include "m_pd.h"
/* port of stk's ADSR class to C */
/* original class notes */
...
...
@@ -83,7 +85,7 @@ void stk_ADSR_setAllTimes(t_stk_ADSR *x, t_float aTime, t_float dTime,
void
stk_ADSR_setTarget
(
t_stk_ADSR
*
x
,
t_float
target
);
/* Return the current envelope state (ATTACK, DECAY, SUSTAIN, RELEASE, IDLE).*/
int
stk_ADSR_getState
(
t_stk_ADSR
*
x
);
t_env_state
stk_ADSR_getState
(
t_stk_ADSR
*
x
);
/* Set to state = ADSR::SUSTAIN with current and target values of value. */
void
stk_ADSR_setValue
(
t_stk_ADSR
*
x
,
t_float
value
);
...
...
externals/disis/disis_munger.c
View file @
a11f73ee
...
...
@@ -243,7 +243,7 @@ static void *munger_alloc(t_disis_munger *x)
return
x
;
}
static
void
*
munger_free
(
t_disis_munger
*
x
)
static
void
munger_free
(
t_disis_munger
*
x
)
{
/* Heap allocated based on number of voices */
int
nv
=
x
->
x_numvoices
,
nchan
=
x
->
x_num_channels
;
...
...
@@ -1207,20 +1207,20 @@ static void munger_scale(t_disis_munger *x, t_symbol *s, int argc, t_atom *argv)
for
(
i
=
0
;
i
<
PITCHTABLESIZE
;
i
++
)
x
->
x_pitchTable
[
i
]
=
0
.;
if
(
argc
>
PITCHTABLESIZE
)
argc
=
PITCHTABLESIZE
;
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
x
->
x_pitchTable
[
i
]
=
atom_getfloatarg
(
i
,
argc
,
argv
);
}
x
->
x_scale_len
=
argc
;
if
(
argc
>
PITCHTABLESIZE
)
argc
=
PITCHTABLESIZE
;
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
x
->
x_pitchTable
[
i
]
=
atom_getfloatarg
(
i
,
argc
,
argv
);
}
x
->
x_scale_len
=
argc
;
i
=
0
;
//wrap input list through all of pitchTable
for
(
j
=
argc
;
j
<
PITCHTABLESIZE
;
j
++
)
{
x
->
x_pitchTable
[
j
]
=
x
->
x_pitchTable
[
i
++
];
if
(
i
>=
argc
)
i
=
0
;
}
i
=
0
;
//wrap input list through all of pitchTable
for
(
j
=
argc
;
j
<
PITCHTABLESIZE
;
j
++
)
{
x
->
x_pitchTable
[
j
]
=
x
->
x_pitchTable
[
i
++
];
if
(
i
>=
argc
)
i
=
0
;
}
}
static
void
munger_bufsize
(
t_disis_munger
*
x
,
t_symbol
*
s
,
int
argc
,
...
...
@@ -1357,10 +1357,12 @@ static void munger_setvoices(t_disis_munger *x, t_symbol *s, int argc,
if
(
temp
>
x
->
x_maxvoices
)
{
if
(
x
->
x_verbose
>
0
)
{
post
(
"disis_munger~ %s error: voices has to be between "
"0 and maxvoices (currently %d)!"
,
x
->
x_munger_name
->
s_name
,
x
->
x_maxvoices
);
temp
=
x
->
x_maxvoices
;
}
temp
=
x
->
x_maxvoices
;
}
if
(
x
->
x_verbose
>
1
)
post
(
"disis_munger~ %s: setting voices to: %d "
,
...
...
@@ -1781,6 +1783,7 @@ static t_int *munger_perform(t_int *w)
}
}
}
return
(
w
+
3
+
x
->
x_num_channels
);
}
static
void
munger_dsp
(
t_disis_munger
*
x
,
t_signal
**
sp
)
...
...
@@ -1826,7 +1829,8 @@ static void munger_dsp(t_disis_munger *x, t_signal **sp)
void
disis_munger_tilde_setup
(
void
)
{
disis_munger_class
=
class_new
(
gensym
(
"disis_munger~"
),
(
t_newmethod
)
munger_new
,
0
,
sizeof
(
t_disis_munger
),
(
t_newmethod
)
munger_new
,
(
t_method
)
munger_free
,
sizeof
(
t_disis_munger
),
CLASS_DEFAULT
,
A_GIMME
,
0
);
CLASS_MAINSIGNALIN
(
disis_munger_class
,
t_disis_munger
,
x_f
);
class_addmethod
(
disis_munger_class
,
(
t_method
)
munger_dsp
,
...
...
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