Imported Upstream version 1.1.4

parents
This diff is collapsed.
This diff is collapsed.
Pd externals by Iain Mott (iain.mott@bigpond.com)
The makefile for this collection is configured for Linux only - Linux binaries included.
Each external has a demonstration Pd patch (*.pd) associated with it.
Source contents:
polygate~ - switch between multiple signal inputs - variable fade rate both linear & equal power
shuffle - a no-repeat random generator - outputs numbers within a set range
pan~ - equal power stereo panning
system - sends a system message to the console
ln~ - natural log + inverse
rec2pol~ - convert rectangular coordinates to polar eg. can be used to
convert sine & cosine rfft~ output to phase & magnitude
pol2rec~ - inverse of rec2pol~
getenv - Sends value of an environment variable argument on bang.
Use a 'set <NAME>' message to reset the variable name.
two other related patches:
polvoc.pd - example of pol2rec~ etc
noisegate~.pd - simple noisegate used in above
See also 'sqlsingle.tar.gz' archive for the 'sqlsingle' eternal. This object allows communication
and data retrieval from a PostgreSQL database in Pd.
\ No newline at end of file
#N canvas 0 37 876 567 10;
#N canvas 217 33 719 609 fft-analysis 0;
#X obj 213 68 *~;
#X obj 261 23 inlet~;
#X obj 213 91 rfft~;
#X obj 46 403 *~;
#X obj 76 66 *~;
#X obj 113 1 inlet~;
#X obj 61 34 tabreceive~ hanning;
#X obj 78 91 rfft~;
#X obj 77 541 outlet~;
#X obj 81 170 rec2pol~;
#X obj 128 127 *~;
#X obj 88 127 *~;
#X obj 248 118 *~;
#X obj 213 118 *~;
#X obj 97 379 rifft~;
#X obj 170 333 pol2rec~;
#X obj 159 222 *~;
#X obj 191 160 rec2pol~;
#X obj 221 259 *~ 0.02;
#X obj 221 286 *~ 1.4;
#X obj 502 311 block~ 1024 4;
#X obj 141 474 *~ 0.05;
#X text 251 439 noisegate arguments: threshold \, fadein time \, fadeout time;
#X obj 112 441 noisegate~ 80 100 200;
#X obj 302 74 sig~ 0.0097;
#X obj 130 88 sig~ 0.001;
#X connect 0 0 2 0;
#X connect 1 0 0 1;
#X connect 2 0 13 0;
#X connect 2 1 12 0;
#X connect 3 0 23 0;
#X connect 4 0 7 0;
#X connect 5 0 4 1;
#X connect 6 0 4 0;
#X connect 6 0 0 0;
#X connect 6 0 3 0;
#X connect 7 0 11 0;
#X connect 7 1 10 0;
#X connect 9 0 15 0;
#X connect 9 1 16 0;
#X connect 10 0 9 1;
#X connect 11 0 9 0;
#X connect 12 0 17 1;
#X connect 13 0 17 0;
#X connect 14 0 3 1;
#X connect 15 0 14 0;
#X connect 15 1 14 1;
#X connect 16 0 19 0;
#X connect 17 1 16 1;
#X connect 17 1 18 0;
#X connect 18 0 19 0;
#X connect 19 0 15 1;
#X connect 23 0 8 0;
#X connect 23 0 21 0;
#X connect 24 0 12 1;
#X connect 24 0 13 1;
#X connect 25 0 11 1;
#X connect 25 0 10 1;
#X restore 326 407 pd fft-analysis;
#X obj 326 431 *~;
#X obj 474 448 line~;
#X floatatom 680 49 0 0 0;
#N canvas 194 37 397 591 output 0;
#X obj 62 191 t b;
#X obj 62 144 f;
#X obj 62 96 inlet;
#X text 67 76 mute;
#X obj 62 215 f;
#X msg 127 230 0;
#X msg 62 120 bang;
#X obj 62 167 moses 1;
#X obj 127 207 t b f;
#X obj 91 417 outlet;
#X msg 91 393 set \$1;
#X obj 175 154 moses 1;
#X obj 212 419 dbtorms;
#X obj 212 443 pack 0 100;
#X obj 175 130 r master-lvl;
#X obj 91 360 r master-lvl;
#X obj 78 269 s master-lvl;
#X obj 212 467 s master-amp;
#X connect 0 0 4 0;
#X connect 1 0 7 0;
#X connect 2 0 6 0;
#X connect 4 0 16 0;
#X connect 5 0 16 0;
#X connect 6 0 1 0;
#X connect 7 0 0 0;
#X connect 7 1 8 0;
#X connect 8 0 5 0;
#X connect 10 0 9 0;
#X connect 11 1 4 1;
#X connect 12 0 13 0;
#X connect 13 0 17 0;
#X connect 14 0 1 1;
#X connect 14 0 11 0;
#X connect 15 0 10 0;
#X connect 15 0 12 0;
#X restore 680 26 pd output;
#X msg 680 2 mute;
#X text 717 43 MASTER;
#X text 717 57 LEVEL;
#X obj 680 74 s master-lvl;
#X obj 472 421 r master-amp;
#N canvas 275 71 767 761 hanning-window 0;
#X obj 92 206 phasor~;
#X obj 92 234 cos~;
#X obj 23 328 tabwrite~ hanning;
#X obj 30 252 -~;
#X obj 30 218 sig~ 1;
#X msg 37 180 0;
#X text 141 13 CALCULATE HANNING;
#X text 141 27 WINDOW TABLE;
#X graph graph1 0 -1 1024 1 275 581 675 281;
#X array hanning 1024 float;
#X pop;
#X msg 275 547 \; hanning resize 1024;
#X obj 93 131 / 1024;
#X obj 93 171 sig~;
#X text 175 148 sample rate / window size;
#X msg 23 144 bang;
#X obj 66 269 sig~ 0.5;
#X obj 49 300 *~;
#X obj 67 96 samplerate~;
#X obj 25 23 r window-size;
#X obj 25 53 t b f;
#X connect 0 0 1 0;
#X connect 1 0 3 1;
#X connect 3 0 15 0;
#X connect 4 0 3 0;
#X connect 5 0 0 1;
#X connect 10 0 11 0;
#X connect 11 0 0 0;
#X connect 13 0 2 0;
#X connect 13 0 5 0;
#X connect 14 0 15 1;
#X connect 15 0 2 0;
#X connect 16 0 10 0;
#X connect 17 0 18 0;
#X connect 18 0 16 0;
#X connect 18 0 13 0;
#X connect 18 1 10 1;
#X restore 675 143 pd hanning-window;
#X msg 393 66 \; window-size 1024 \; pd dsp 1;
#X text 434 370 filter;
#X text 436 385 input;
#X obj 326 254 phasor~ 220;
#X floatatom 358 151 4 0 0;
#X obj 341 185 mtof;
#X obj 351 293 noise~;
#X obj 351 317 *~ 0.12;
#X obj 201 247 adc~;
#X obj 393 12 loadbang;
#X msg 295 80 36;
#X text 13 81 Example using rec2pol & pol2rec;
#X text 84 245 talk into this:;
#X text 401 150 adjust pitch;
#X text 654 419 IM 2001;
#X obj 322 468 dac~;
#X connect 0 0 1 0;
#X connect 1 0 26 0;
#X connect 1 0 26 1;
#X connect 2 0 1 1;
#X connect 3 0 8 0;
#X connect 4 0 3 0;
#X connect 5 0 4 0;
#X connect 9 0 2 0;
#X connect 14 0 0 0;
#X connect 15 0 16 0;
#X connect 16 0 14 0;
#X connect 17 0 18 0;
#X connect 18 0 0 0;
#X connect 19 0 0 1;
#X connect 20 0 11 0;
#X connect 20 0 21 0;
#X connect 21 0 15 0;
#N canvas 597 95 404 421 10;
#X floatatom 445 83 4 0 0;
#X obj 441 107 t b f;
#X obj 593 177 strconcat .wav;
#X obj 517 236 strconcat;
#X symbolatom 360 301 60 0 0;
#X msg 363 108 set HOME;
#X msg 300 87 set SOUNDSTORE;
#X obj 410 190 makefilename %s/sound;
#X floatatom 608 216 4 0 0;
#X msg 305 53 set SUMDAYPLAY;
#X obj 401 149 getenv SUMDAYPLAY;
#X connect 0 0 1 0;
#X connect 1 0 10 0;
#X connect 1 1 2 0;
#X connect 2 0 3 1;
#X connect 3 0 4 0;
#X connect 5 0 10 0;
#X connect 6 0 10 0;
#X connect 7 0 3 0;
#X connect 8 0 3 2;
#X connect 9 0 10 0;
#X connect 10 0 7 0;
/***************************************************************************
* File: shuffle.c
* Auth: Iain Mott [iain.mott@bigpond.com]
* Maintainer: Iain Mott [iain.mott@bigpond.com]
* Version: Part of motex_1.1.2
* Date: January 2001
*
* Description: Pd external. Sends value of an environment variable argument on bang.
* Use a 'set <NAME>' message to reset the variable name.
* See supporting Pd patch: getenv.pd
*
* Copyright (C) 2001 by Iain Mott [iain.mott@bigpond.com]
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License, which should be included with this
* program, for more details.
*
****************************************************************************/
/*
* getenv - Pd external. Copyright (c) 2001 Iain Mott
* sends value of an environment variable argument on bang
* use a 'set <NAME>' message to reset the variable name
*/
#include "m_pd.h"
#include <stdlib.h>
static t_class *getenv_class;
typedef struct _getenv
{
t_object x_obj;
t_symbol *enval;
char *envar;
} t_getenv;
static void *getenv_new(t_symbol *s, int argc, t_atom *argv)
{
t_getenv *x = (t_getenv *)pd_new(getenv_class);
x->envar = NULL;
if(argc != 1 || argv[0].a_type != A_SYMBOL)
post("getenv: One argument (environment variable) required");
else
{
char *value = getenv(argv[0].a_w.w_symbol->s_name);
if(value)
{
x->envar = argv[0].a_w.w_symbol->s_name;
x->enval = gensym(value);
}
else
post("getenv: Environment variable does not exist");
}
outlet_new(&x->x_obj, &s_symbol);
return (x);
}
void getenv_set(t_getenv *x, t_symbol *f)
{
char *value = getenv(f->s_name);
if(value)
x->enval = gensym(value);
else
post("getenv: Environment variable does not exist");
}
void getenv_bang(t_getenv *x)
{
if(x->envar)
outlet_symbol(x->x_obj.ob_outlet, x->enval);
}
void getenv_setup(void)
{
getenv_class = class_new(gensym("getenv"), (t_newmethod)getenv_new, 0, sizeof(t_getenv), 0, A_GIMME, 0);
class_addmethod(getenv_class, (t_method)getenv_set, gensym("set"), A_SYMBOL, 0);
class_addbang(getenv_class, getenv_bang);
}
#N canvas 277 128 450 300 10;
#X obj 145 100 ln~;
#X obj 158 126 ln~ -1;
#X text 23 4 ln~;
#X text 22 23 same as log~ however '-1' argument creates inverse;
#X obj 129 53 sig~ 22;
#X msg 47 94 bang;
#X obj 59 128 print~ log;
#X obj 43 165 print~ alog;
#X connect 0 0 1 0;
#X connect 0 0 6 0;
#X connect 1 0 7 0;
#X connect 4 0 0 0;
#X connect 5 0 6 0;
#X connect 5 0 7 0;
/***************************************************************************
* File: ln~.c
* Auth: Iain Mott [iain.mott@bigpond.com]
* Maintainer: Iain Mott [iain.mott@bigpond.com]
* Version: Part of motex_1.1.2
* Date: January 2001
*
* Description: Pd signal external. Finds natural log of signal. Optional argument '-1' finfs inverse.
*
* Copyright (C) 2001 by Iain Mott [iain.mott@bigpond.com]
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License, which should be included with this
* program, for more details.
*
****************************************************************************/
#include "math.h"
#include <m_pd.h>
/* ----------------------------- ln ----------------------------- */
static t_class *ln_class;
#define INVTWOPI 0.15915494f
typedef struct _ln
{
t_object x_obj;
int flag;
} t_ln;
/* static void *ln_new(t_symbol *s, int argc, t_atom *argv) */
static void *ln_new(t_floatarg f)
{
/* if (argc > 1) */
/* post("+~: extra arguments ignored"); */
/* { */
t_ln *x = (t_ln *)pd_new(ln_class);
outlet_new(&x->x_obj, &s_signal);
x->flag = f;
return (x);
/* } */
}
t_int *ln_perform(t_int *w)
{
t_float *in1 = (t_float *)(w[1]);
t_float *out = (t_float *)(w[2]);
int n = (int)(w[3]);
int flag = (int)(w[4]);
if(flag != -1)
while (n--) *out++ = (t_float) log(*in1++);
else
while (n--) *out++ = (t_float) exp(*in1++);
return (w+5);
}
t_int *ln_perf8(t_int *w)
{
t_float *in1 = (t_float *)(w[1]);
t_float *out = (t_float *)(w[2]);
int n = (int)(w[3]);
int flag = (int)(w[4]);
if(flag != -1)
{
for (; n; n -= 8, in1 += 8, out += 8)
{
float f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
float f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
out[0] = (t_float) log(f0);
out[1] = (t_float) log(f1);
out[2] = (t_float) log(f2);
out[3] = (t_float) log(f3);
out[4] = (t_float) log(f4);
out[5] = (t_float) log(f5);
out[6] = (t_float) log(f6);
out[7] = (t_float) log(f7);
}
}
else
{
for (; n; n -= 8, in1 += 8, out += 8)
{
float f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
float f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
out[0] = (t_float) exp(f0);
out[1] = (t_float) exp(f1);
out[2] = (t_float) exp(f2);
out[3] = (t_float) exp(f3);
out[4] = (t_float) exp(f4);
out[5] = (t_float) exp(f5);
out[6] = (t_float) exp(f6);
out[7] = (t_float) exp(f7);
}
}
return (w+5);
}
void dsp_add_ln(t_sample *in1, t_sample *out, int n, int flag)
{
if (n&7)
dsp_add(ln_perform, 4, in1, out, n, flag);
else
dsp_add(ln_perf8, 4, in1, out, n, flag);
}
static void ln_dsp(t_ln *x, t_signal **sp)
{
dsp_add_ln(sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n, x->flag);
}
void ln_tilde_setup(void)
{
ln_class = class_new(gensym("ln~"), (t_newmethod)ln_new, 0,
sizeof(t_ln), 0, A_DEFFLOAT, 0);
class_addmethod(ln_class, nullfn, gensym("signal"), 0);
class_addmethod(ln_class, (t_method)ln_dsp, gensym("dsp"), 0);
}
#N canvas 10 10 200 200 10;
#N canvas 20 20 420 300 META 0;
#X text 10 10 META this is a prototype of a libdir meta file;
#X text 10 30 NAME motex;
#X text 10 50 AUTHOR Iain Mott <iain.mott@bigpond.com>;
#X text 10 70 LICENSE GNU GPL;
#X text 10 90 VERSION 1.1.4;
#X restore 10 10 pd META;
#N canvas 1 52 450 300 10;
#X obj 131 140 noisegate~;
#X obj 122 200 dac~;
#X text 49 67 comment;
#X connect 0 0 1 0;
#X connect 0 0 1 1;
#N canvas 5 21 499 368 10;
#X obj 149 44 inlet~;
#X obj 149 314 outlet~;
#X obj 188 139 moses \$1;
#X msg 188 167 bang;
#X msg 257 168 bang;
#X obj 257 189 pack 1 \$2;
#X text 328 309 IM 2001;
#X obj 188 189 pack 0 \$3;
#X obj 188 220 line~;
#X obj 149 279 *~;
#X obj 188 110 env~;
#X connect 0 0 9 0;
#X connect 0 0 10 0;
#X connect 2 0 3 0;
#X connect 2 1 4 0;
#X connect 3 0 7 0;
#X connect 4 0 5 0;
#X connect 5 0 8 0;
#X connect 7 0 8 0;
#X connect 8 0 9 1;
#X connect 9 0 1 0;
#X connect 10 0 2 0;
#N canvas 5 21 629 519 10;
#X floatatom 462 138 4 0 0;
#X floatatom 187 239 0 0 0;
#N canvas 184 223 495 266 output 0;
#X obj 338 160 t b;
#X obj 338 110 f;
#X obj 338 60 inlet;
#X text 344 29 mute;
#X obj 338 185 f;
#X msg 425 178 0;
#X msg 338 85 bang;
#X obj 338 135 moses 1;
#X obj 425 153 t b f;
#X obj 397 117 moses 1;
#X obj 83 148 dbtorms;
#X obj 397 92 r master-lvl;
#X obj 83 42 r master-lvl;
#X obj 338 210 s master-lvl;
#X obj -15 176 inlet~;
#X obj 199 41 inlet;
#X text 199 18 level;
#X obj 199 100 s master-lvl;
#X msg 96 65 set \$1;
#X obj 96 89 outlet;
#X msg 214 64 \; pd dsp 1;
#X obj 83 194 line~;
#X obj -15 207 *~;
#X obj -15 236 dac~;
#X obj 83 171 pack 0 50;
#X text -17 153 audio;
#X text 93 110 show level;
#X obj 31 182 inlet~;
#X obj 31 218 *~;
#X connect 0 0 4 0;
#X connect 1 0 7 0;
#X connect 2 0 6 0;
#X connect 4 0 13 0;
#X connect 5 0 13 0;
#X connect 6 0 1 0;
#X connect 7 0 0 0;
#X connect 7 1 8 0;
#X connect 8 0 5 0;
#X connect 9 1 4 1;
#X connect 10 0 24 0;
#X connect 11 0 1 1;
#X connect 11 0 9 0;
#X connect 12 0 10 0;
#X connect 12 0 18 0;
#X connect 14 0 22 0;
#X connect 15 0 17 0;
#X connect 15 0 20 0;
#X connect 18 0 19 0;
#X connect 21 0 22 1;
#X connect 21 0 28 1;
#X connect 22 0 23 0;
#X connect 24 0 21 0;
#X connect 27 0 28 0;
#X connect 28 0 23 1;
#X restore 158 267 pd output;
#X msg 216 239 MUTE;
#X text 250 238 <-- output amplitude;
#N canvas 5 21 600 400 pulse 1;
#X obj 175 203 cos~;
#X obj 175 131 -~ 0.5;
#X obj 175 179 clip~ -0.5 0.5;
#X obj 175 227 hip~ 5;
#X obj 175 155 *~ 82;
#X obj 175 107 phasor~ 16;
#X obj 175 251 outlet~;
#X floatatom 169 61 4 0 0;
#X connect 0 0 3 0;
#X connect 1 0 4 0;
#X connect 2 0 0 0;
#X connect 3 0 6 0;
#X connect 4 0 2 0;
#X connect 5 0 1 0;
#X connect 7 0 5 0;
#X restore 122 46 pd pulse;
#X msg 368 41 \; pd dsp 1;
#X msg 438 41 \; pd dsp 0;
#X text 390 72 ON;
#X text 455 72 OFF;
#X obj 369 16 loadbang;
#X obj 461 162 / 100;
#X msg 461 182 \$1 30;
#X obj 460 206 line;
#X obj 159 151 pansig~;
#X obj 222 113 osc~ 0.01;
#X floatatom 222 61 4 0 0;
#X obj 263 153 noise~;
#X obj 222 86 / 100;
#X connect 0 0 11 0;
#X connect 1 0 2 2;
#X connect 2 0 1 0;
#X connect 3 0 2 3;
#X connect 5 0 14 0;
#X connect 10 0 6 0;
#X connect 11 0 12 0;
#X connect 12 0 13 0;
#X connect 14 0 2 0;
#X connect 14 1 2 1;
#X connect 15 0 14 1;
#X connect 16 0 18 0;
#X connect 18 0 15 0;
#include "m_pd.h"
#include <math.h>
static t_class *pansig_class;
/* #define RADCONST 0.017453293 */
#define RADCONST 0.785398163
#define ROOT2DIV2 0.707106781
typedef struct _pansig
{
t_object x_obj;
float x_f;
float pan;
float left;
float right;
} t_pansig;
static void *pansig_new(t_symbol *s, int argc, t_atom *argv)
{
t_pansig *x = (t_pansig *)pd_new(pansig_class);
inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
outlet_new(&x->x_obj, gensym("signal"));
outlet_new(&x->x_obj, gensym("signal"));
// inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("pansigf"));
x->x_f = 0;
return (x);
}
static void pansig_getpan(t_floatarg signal, t_floatarg *left, t_floatarg *right)
{
double tmp, result;
double angle;
signal = signal < -1 ? -1 : signal;
signal = signal > 1 ? 1 : signal;
angle = signal * RADCONST;
*right = ROOT2DIV2 * (cos(angle) + sin(angle));
*left = ROOT2DIV2 * (cos(angle) - sin(angle));
/* if(signal < 0) */
/* signal = 0; */
/* if(signal > 0.999) */
/* signal = 0.999; */
/* tmp = (tan(1.5866 * signal - 0.785398) + 1) / 2; */
/* result = sqrt(tmp); */
/* if (result < 0) */
/* *right = 0; */
/* else if (result > 1) */
/* *right = 1; */
/* else */
/* *right = result; */
/* tmp = tmp * -1 + 1; */
/* if(tmp < 0) */
/* tmp = 0; */
/* result = sqrt(tmp); */
/* if (result < 0) */
/* *left = 0; */
/* else if (result > 1) */
/* *left = 1; */
/* else */
/* *left = result; */
}
static t_int *pansig_perform(t_int *w)
{
float *in1 = (t_float *)(w[1]);
float *in2 = (t_float *)(w[2]);
float *out1 = (t_float *)(w[3]);
float *out2 = (t_float *)(w[4]);
int n = (int)(w[5]);
t_pansig *x = (t_pansig *)(w[6]);
float value, value2, left, right;
while (n--)
{
value = *in1++;
value2 = *in2++;
pansig_getpan(value2, &left, &right);
/* *out1++ = value * x->left; */
/* *out2++ = value * x->right; */
*out1++ = value * left;
*out2++ = value * right;
/* *out1++ = value; */
/* *out2++ = value; */
}
return (w+7);
}
static void pansig_dsp(t_pansig *x, t_signal **sp)
{
int n = sp[0]->s_n;
float *in1 = sp[0]->s_vec;
float *in2 = sp[1]->s_vec;
float *out1 = sp[2]->s_vec;
float *out2 = sp[3]->s_vec;
dsp_add(pansig_perform, 6,
in1, in2, out1, out2, n, x);
}
void pansig_f(t_pansig *x, t_floatarg f)
{
double tmp, result;
if(f < 0)
f = 0;
if(f > 0.999)
f = 0.999;
tmp = (tan(1.5866 * f - 0.785398) + 1) / 2;
result = sqrt(tmp);
if (result < 0)
x->right = 0;
else if (result > 1)
x->right = 1;
else
x->right = result;
tmp = tmp * -1 + 1;
if(tmp < 0)
tmp = 0;
result = sqrt(tmp);
if (result < 0)
x->left = 0;
else if (result > 1)
x->left = 1;
else
x->left = result;
}
void pansig_tilde_setup(void)
{
pansig_class = class_new(gensym("pansig~"), (t_newmethod)pansig_new, 0,
sizeof(t_pansig), 0, A_GIMME, 0);
class_addmethod(pansig_class, nullfn, gensym("signal"), 0);