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
Wynn
purr-data
Commits
13d9f965
Commit
13d9f965
authored
Dec 08, 2008
by
Miller Puckette
Browse files
test06 - bonk and sigmund improvements; deleted flush for stdout
parent
634a77cc
Changes
8
Hide whitespace changes
Inline
Side-by-side
doc/3.audio.examples/B16.long-varispeed.pd
View file @
13d9f965
#N canvas
202 17
779 858 12;
#N canvas
31 5
779 858 12;
#X obj 399 526 metro 100;
#X obj 212 472 phasor~;
#X obj 399 556 snapshot~;
...
...
@@ -7,7 +7,7 @@
#X obj 23 461 phasor~;
#X floatatom 23 329 5 -100 1000 0 - - -;
#X obj 23 518 tabread4~ \$0-tab;
#X msg 2
81 330
0.5;
#X msg 2
90 329
0.5;
#X msg 326 329 0.01;
#X obj 398 455 loadbang;
#X msg 399 478 1;
...
...
@@ -59,7 +59,6 @@
;
#X text 387 739 (approximately zero but not exactly because of;
#X text 389 753 truncation error!);
#X msg 340 408 0.5;
#X obj 341 383 t b f;
#X text 400 357 convert to samples;
#X text 385 384 set both last-onset and previous-onset;
...
...
@@ -74,13 +73,13 @@
#X text 206 402 convert to;
#X text 469 472 in order to change onset to reflect it;
#X text 469 456 Each 100 msec \, poll phase of phasor~;
#X text 24
36
Here is how to use the tabread~ "onset" input to allow
#X text 24
29
Here is how to use the tabread~ "onset" input to allow
clean varispeed playback from a long table. At left \, a phasor~ is
naiveley rescaled to the size of the tble. At right \, the phasor~
gets only a 10000-point range about a moving "onset". Ten times per
second \, we poll tha phasor~ phase \, sum its value into the onset
\, and back up the phase of the phasor~ correspondingly.;
#X text 2
5
1
50
The tricky bits are \, first \, that we need to poll
#X text 2
4
1
38
The tricky bits are \, first \, that we need to poll
the phasor~ phase one sample into the future (so we add the per-sample
increment into the snapshot~ result). Second \, we can't just reset
the phasor~ to a fixed point - instead \, we measure how much the onset
...
...
@@ -88,19 +87,22 @@ has actually increased (which has truncation error from summing in
the phase snapshot) \, and subtract that increase from the phase \,
giving a value that differs from zero by the truncation error but reflects
the true phase we should reset to for continuity.;
#X text 26 2
90
The metronome rate is arbitrary but should be fast enough
#X text 26 2
81
The metronome rate is arbitrary but should be fast enough
that the phasor~ never has time to wrap.;
#X text 518 539 extrapolate snapshot of phase by one;
#X text 517 552 sample to sync with next block;
#X text 41 617 BAD;
#X text 160 770 GOOD;
#X text 195 9 VARIABLE SPEED PLAYBACK FROM LONG TABLES;
#X msg 340 408 0;
#X text 369 328 <- reset phase. 0.5 causes trouble for the "bad" way.
;
#X connect 0 0 2 0;
#X connect 1 0 24 0;
#X connect 2 0 31 0;
#X connect 5 0 26 0;
#X connect 6 0 45 0;
#X connect 6 0 6
5
0;
#X connect 6 0 6
4
0;
#X connect 7 0 4 0;
#X connect 7 0 4 1;
#X connect 8 0 5 1;
...
...
@@ -147,10 +149,10 @@ that the phasor~ never has time to wrap.;
#X connect 40 0 35 0;
#X connect 40 0 38 0;
#X connect 45 0 5 0;
#X connect 51 0 5
8
0;
#X connect 57 0
1 1
;
#X connect 5
8 0 57 0
;
#X connect 5
8
1 1
9
1;
#X connect
58 1 12 1
;
#X connect 6
5
0
1
0;
#X connect
65
0
30
0;
#X connect 51 0 5
7
0;
#X connect 57 0
79 0
;
#X connect 5
7 1 19 1
;
#X connect 5
7
1 1
2
1;
#X connect
64 0 1 0
;
#X connect 6
4
0
30
0;
#X connect
79
0
15
0;
extra/bonk~/bonk~.c
View file @
13d9f965
/*
###########################################################################
# bonk~ - a Max/MSP external
# by miller puckette and ted ap
p
el
# by miller puckette and ted apel
# http://crca.ucsd.edu/~msp/
# Max/MSP port by barry threw
# http://www.barrythrew.com
...
...
@@ -911,7 +911,7 @@ static void bonk_print(t_bonk *x, t_floatarg f)
h
->
h_before
,
h
->
h_countup
);
}
post
(
"filter details (frequencies are in units of %.2f-Hz. bins):"
,
x
->
x_sr
);
x
->
x_sr
/
x
->
x_npoints
);
for
(
j
=
0
;
j
<
x
->
x_nfilters
;
j
++
)
post
(
"%2d cf %.2f bw %.2f nhops %d hop %d skip %d npoints %d"
,
j
,
...
...
extra/pd~/pd~.c
View file @
13d9f965
...
...
@@ -71,6 +71,7 @@ typedef struct _pd_tilde
t_object
x_obj
;
t_clock
*
x_clock
;
t_outlet
*
x_outlet1
;
/* for messages back from subproc */
t_canvas
*
x_canvas
;
#endif
/* PD */
#ifdef MSP
t_pxobject
x_obj
;
...
...
@@ -165,7 +166,8 @@ static void pd_tilde_readmessages(t_pd_tilde *x)
}
static
void
pd_tilde_donew
(
t_pd_tilde
*
x
,
char
*
pddir
,
char
*
schedlibdir
,
char
*
pdargs
,
int
ninsig
,
int
noutsig
,
int
fifo
,
float
samplerate
)
char
*
patchdir
,
char
*
pdargs
,
int
ninsig
,
int
noutsig
,
int
fifo
,
float
samplerate
)
{
int
i
,
pid
,
pipe1
[
2
],
pipe2
[
2
];
char
cmdbuf
[
MAXPDSTRING
],
pdexecbuf
[
MAXPDSTRING
],
schedbuf
[
MAXPDSTRING
];
...
...
@@ -195,8 +197,8 @@ static void pd_tilde_donew(t_pd_tilde *x, char *pddir, char *schedlibdir,
}
}
snprintf
(
cmdbuf
,
MAXPDSTRING
,
"%s -schedlib %s/pdsched -inchannels %d -outchannels %d -r %g %s
\n
"
,
pdexecbuf
,
schedlibdir
,
ninsig
,
noutsig
,
samplerate
,
pdargs
);
"%s -schedlib %s/pdsched
-path %s
-inchannels %d -outchannels %d -r %g %s
\n
"
,
pdexecbuf
,
schedlibdir
,
patchdir
,
ninsig
,
noutsig
,
samplerate
,
pdargs
);
#if 0
#ifdef PD
fprintf(stderr, "%s", cmdbuf);
...
...
@@ -368,6 +370,7 @@ static void pd_tilde_pdtilde(t_pd_tilde *x, t_symbol *s,
{
t_symbol
*
sel
=
((
argc
>
0
&&
argv
->
a_type
==
A_SYMBOL
)
?
argv
->
a_w
.
w_symbol
:
gensym
(
"?"
));
char
*
patchdir
;
if
(
sel
==
gensym
(
"start"
))
{
char
pdargstring
[
MAXPDSTRING
];
...
...
@@ -383,6 +386,7 @@ static void pd_tilde_pdtilde(t_pd_tilde *x, t_symbol *s,
if
(
strlen
(
pdargstring
)
<
MAXPDSTRING
-
1
)
strcat
(
pdargstring
,
" "
);
}
patchdir
=
canvas_getdir
(
x
->
x_canvas
)
->
s_name
;
#endif
#ifdef MAX
while
(
argc
--
)
...
...
@@ -401,9 +405,11 @@ static void pd_tilde_pdtilde(t_pd_tilde *x, t_symbol *s,
strcat
(
pdargstring
,
" "
);
argv
++
;
}
patchdir
=
"."
;
#endif
pd_tilde_donew
(
x
,
x
->
x_pddir
->
s_name
,
x
->
x_schedlibdir
->
s_name
,
pdargstring
,
x
->
x_ninsig
,
x
->
x_noutsig
,
x
->
x_fifo
,
x
->
x_sr
);
patchdir
,
pdargstring
,
x
->
x_ninsig
,
x
->
x_noutsig
,
x
->
x_fifo
,
x
->
x_sr
);
}
else
if
(
sel
==
gensym
(
"stop"
))
{
...
...
@@ -540,6 +546,7 @@ static void *pd_tilde_new(t_symbol *s, int argc, t_atom *argv)
x
->
x_outfd
=
0
;
x
->
x_childpid
=
-
1
;
x
->
x_msgbuf
=
0
;
x
->
x_canvas
=
canvas_getcurrent
();
for
(
j
=
1
,
g
=
x
->
x_insig
;
j
<
ninsig
;
j
++
,
g
++
)
inlet_new
(
&
x
->
x_obj
,
&
x
->
x_obj
.
ob_pd
,
&
s_signal
,
&
s_signal
);
x
->
x_outlet1
=
outlet_new
(
&
x
->
x_obj
,
0
);
...
...
extra/sigmund~/sigmund~.c
View file @
13d9f965
...
...
@@ -363,7 +363,7 @@ static void sigmund_getrawpeaks(int npts, float *insamps,
#define PITCHUNCERTAINTY 0.3
#define HALFTONEINC 0.059
#define SUBHARMONICS 16
#define DBPERHALFTONE 0.
5
#define DBPERHALFTONE 0.
0
static
void
sigmund_getpitch
(
int
npeak
,
t_peak
*
peakv
,
float
*
freqp
,
float
npts
,
float
srate
,
int
loud
)
...
...
@@ -405,8 +405,6 @@ static void sigmund_getpitch(int npeak, t_peak *peakv, float *freqp,
for
(
i
=
0
;
i
<
nsalient
;
i
++
)
{
t_peak
*
thispeak
=
bigpeaks
[
i
];
float
pitchuncertainty
=
4
*
PITCHUNCERTAINTY
*
fperbin
/
(
HALFTONEINC
*
thispeak
->
p_freq
);
float
weightindex
=
(
48
.
/
LOG2
)
*
log
(
thispeak
->
p_freq
/
(
2
.
*
fperbin
));
float
loudness
=
sqrt
(
thispeak
->
p_amp
);
...
...
@@ -415,8 +413,8 @@ static void sigmund_getpitch(int npeak, t_peak *peakv, float *freqp,
{
float
subindex
=
weightindex
-
(
48
.
/
LOG2
)
*
log
(
j
+
1
.);
int
loindex
=
subindex
-
pitchuncertainty
;
int
hiindex
=
sub
index
+
pitchuncertainty
+
1
;
int
loindex
=
subindex
-
0
.
5
;
int
hiindex
=
lo
index
+
2
;
if
(
hiindex
<
0
)
break
;
if
(
hiindex
>=
npit
)
...
...
@@ -424,7 +422,7 @@ static void sigmund_getpitch(int npeak, t_peak *peakv, float *freqp,
if
(
loindex
<
0
)
loindex
=
0
;
for
(
k
=
loindex
;
k
<=
hiindex
;
k
++
)
weights
[
k
]
+=
loudness
*
4
.
/
(
4
.
+
j
);
weights
[
k
]
+=
loudness
*
6
.
/
(
6
.
+
j
);
}
sumweight
+=
loudness
;
}
...
...
@@ -441,29 +439,35 @@ static void sigmund_getpitch(int npeak, t_peak *peakv, float *freqp,
freq
=
0
;
goto
done
;
}
for
(
i
=
bestbin
+
1
;
i
<
npit
;
i
++
)
if
(
bestbin
>
0
&&
bestbin
<
npit
-
1
)
{
i
f
(
weights
[
i
]
<
bestweight
)
break
;
bestbin
+=
0
.
5
;
i
nt
ibest
=
bestbin
;
bestbin
+=
(
weights
[
ibest
+
1
]
-
weights
[
ibest
-
1
])
/
(
weights
[
ibest
+
1
]
+
weights
[
ibest
]
+
weights
[
ibest
-
1
])
;
}
freq
=
2
*
fperbin
*
exp
((
LOG2
/
48
.)
*
bestbin
);
for
(
sumamp
=
sumweight
=
sumfreq
=
0
,
i
=
0
;
i
<
nsalient
;
i
++
)
{
t_peak
*
thispeak
=
bigpeaks
[
i
];
float
thisloudness
=
sqrt
(
thispeak
->
p_amp
)
;
float
thisloudness
=
thispeak
->
p_amp
;
float
thisfreq
=
thispeak
->
p_freq
;
float
harmonic
=
thisfreq
/
freq
;
float
intpart
=
(
int
)(
0
.
5
+
harmonic
);
float
inharm
=
freq
*
(
harmonic
-
intpart
);
if
(
harmonic
<
1
)
continue
;
if
(
inharm
<
0
.
25
*
fperbin
&&
inharm
>
-
0
.
25
*
fperbin
)
float
inharm
=
harmonic
-
intpart
;
#if 0
if (loud)
post("freq %f intpart %f inharm %f", freq, intpart, inharm);
#endif
if
(
intpart
>=
1
&&
intpart
<=
16
&&
inharm
<
0
.
015
*
intpart
&&
inharm
>
-
(
0
.
015
*
intpart
))
{
float
weight
=
thisloudness
*
intpart
;
sumweight
+=
weight
;
sumfreq
+=
weight
*
thisfreq
/
intpart
;
#if 0
if (loud)
post("weight %f freq %f", weight, thisfreq);
#endif
}
}
if
(
sumweight
>
0
)
...
...
extra/stdout/stdout-help.pd
View file @
13d9f965
#N canvas 110 37 789 525 10;
#X msg 84 147 walk the dog;
#X msg 91 169 1;
#X msg 90 215 flush;
#X obj 84 240 stdout;
#X text 472 410 updated for Pd version 0.42;
#N canvas 121 60 488 321 12;
#X msg 126 203 walk the dog;
#X msg 117 156 1;
#X obj 117 240 stdout;
#X text 269 287 updated for Pd version 0.42;
#X obj 14 13 stdout;
#X text 67 14 - write messages to standard output;
#X msg 96 192 1 2;
#X connect 0 0 3 0;
#X connect 1 0 3 0;
#X connect 2 0 3 0;
#X connect 7 0 3 0;
#X msg 122 179 1 2;
#X obj 119 291 pd~;
#X text 44 291 see also:;
#X text 34 39 Sends messages to Pd's standard output. This is useful
in conjunction with the pd~ object \, which starts a pd sub-process.
Messages sent to the sub-process standard output appear on the output
of the pd~ object in the owning process. This might also be useful
in other situations. Note that there's no corresponding "stdin" object
- there seems to be no one canonical way such a thing should act.;
#X connect 0 0 2 0;
#X connect 1 0 2 0;
#X connect 6 0 2 0;
extra/stdout/stdout.c
View file @
13d9f965
...
...
@@ -37,7 +37,7 @@ static void stdout_anything(t_stdout *x, t_symbol *s, int argc, t_atom *argv)
printf
(
"%s;
\n
"
,
msgbuf
);
}
static
void
stdout_f
lush
(
t_stdout
*
x
)
static
void
stdout_f
ree
(
t_stdout
*
x
)
{
fflush
(
stdout
);
}
...
...
@@ -45,7 +45,6 @@ static void stdout_flush(t_stdout *x)
void
stdout_setup
(
void
)
{
stdout_class
=
class_new
(
gensym
(
"stdout"
),
(
t_newmethod
)
stdout_new
,
(
t_method
)
stdout_flush
,
sizeof
(
t_stdout
),
0
,
0
);
class_addmethod
(
stdout_class
,
(
t_method
)
stdout_flush
,
gensym
(
"flush"
),
0
);
(
t_method
)
stdout_free
,
sizeof
(
t_stdout
),
0
,
0
);
class_addanything
(
stdout_class
,
stdout_anything
);
}
linux/cp-to-max.sh
100644 → 100755
View file @
13d9f965
File mode changed from 100644 to 100755
src/m_pd.h
View file @
13d9f965
...
...
@@ -11,7 +11,7 @@ extern "C" {
#define PD_MAJOR_VERSION 0
#define PD_MINOR_VERSION 42
#define PD_BUGFIX_VERSION 0
#define PD_TEST_VERSION "test
5
"
#define PD_TEST_VERSION "test
6
"
/* old name for "MSW" flag -- we have to take it for the sake of many old
"nmakefiles" for externs, which will define NT and not MSW */
...
...
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