Commit 9e77f069 authored by Jonathan Wilkes's avatar Jonathan Wilkes

Initial commit

parents
*.o
# Mac OS X
*.dylib
# GNU/Linux
*.so
# Windows
This distribution comes with binaries for both OSX (10.9) and Linux (Ubuntu 64-bit). To install, move folders “lyonpotpourri-externals” and “lyonpotpourri-helpfiles” to a location within your Pd search path. If the shipped externals work with your computer hardware, you are good to go. Otherwise, you will need to recompile the externals by typing “make” in a Terminal window. If on OSX, you need to have the developer tools installed in order to run Make.
LyonPotpourri for Pd
Copyright (c) 2007-2012 Eric Lyon
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <strings.h>
#include <string.h>
#define LYONPOTPOURRI_MSG "-<LyonPotpourri 3.0>-"
#define NO_FREE_FUNCTION 0
/* because Max and Pd have different ideas of what A_FLOAT is, use t_floatarg
to force consistency. Otherwise functions that look good will fail on some
hardware. Also note that Pd messages cannot accept arguments of type A_LONG. */
#include "m_pd.h"
// #define t_floatarg float
#define t_double double
#define atom_getsymarg atom_getsymbolarg
#ifndef PIOVERTWO
#define PIOVERTWO 1.5707963268
#endif
#ifndef TWOPI
#define TWOPI 6.2831853072
#endif
#ifndef PI
#define PI 3.14159265358979
#endif
/*** MSP helper functions **/
void atom_arg_getfloat(float *c, long idx, long ac, t_atom *av);
void atom_arg_getsym(t_symbol **c, long idx, long ac, t_atom *av);
// #define potpourri_announce(objname) post("( %s )\t%s",objname,LYONPOTPOURRI_MSG)
#define potpourri_announce(objname) post("%s ( %s )",LYONPOTPOURRI_MSG,objname)
\ No newline at end of file
This diff is collapsed.
#include <math.h>
#include "PenroseOscil.h"
float frequencyToIncrement( float samplingRate, float frequency, int bufferLength ) {
return (frequency / samplingRate) * (float) bufferLength;
}
void makeSineBuffer( float *buffer, int bufferLength ) {
int i;
float myTwoPi = 8. * atan(1.);
for ( i=0; i <= bufferLength; i++ )
*(buffer+i) = sin( myTwoPi * ((float) i / (float) bufferLength) );
return;
}
float bufferOscil( float *phase, float increment, float *buffer,
int bufferLength )
{
float sample;
while ( *phase > bufferLength )
*phase -= bufferLength;
while ( *phase < 0. )
*phase += bufferLength;
sample = *( buffer + (int) (*phase) );
*phase += increment;
return sample;
}
float frequencyToIncrement( float samplingRate, float frequency,
int bufferLength );
void makeSineBuffer( float *buffer, int bufferLength );
float bufferOscil( float *phase, float increment, float *buffer,
int bufferLength );
#include "PenroseRand.h"
float rrand(int *seed)
{
int i = ((*seed = *seed * 1103515245 + 12345)>>16) & 077777;
return((float)i/16384. - 1.);
}
float prand(int *seed)
{
int i = ((*seed = *seed * 1103515245 + 12345)>>16) & 077777;
return((float)i/32768.);
}
float rrand(int *seed);
float prand(int *seed);
Welcome to LyonPotpourri, version 3.0 (64-bit version).
http://disis.music.vt.edu/eric/LyonSoftware/Pd/LyonPotpourri/
LyonPotpourri is a collection of externals developed for the creation and performance of computer music. The externals were originally developed for Max/MSP, and then extended into hybrid code that could compile for both Max/MSP and Pd. As of version 3.0, the code bases of Max/MSP and Pd have diverged to such an extent that I decided to split the LyonPotpourri code into separate Pd and Max/MSP versions.
The Pd platform tends toward minimalism. Therefore, it is particularly advantageous for Pd users to become adept at designing their own externals. It is hoped that in addition to the utility of specific externals in this collection, the source code will be helpful for computer musicians who wish to learn how to write their own externals. For further guidance on that subject, please see my book “Designing Audio Objects for Max/MSP and Pd.”
LyonPotpourri 3.0 is Copyright Eric Lyon, 2007-2013, and is covered under the MIT license. Please see the accompanying License file for details.
Object Listing:
- adsr~ a simple ADSR envelope that can be click triggered
- arrayfilt~ fft-based filtering by drawing into an array
- bashfest~ a click driven buffer player with randomized DSP
- buffet~ provides operations on a stored buffer
- bvplay~ selective playback from a stored buffer with enveloping and increment control
- cartopol~ convert a spectral frame from cartesian to polar form
- channel~ access to a precise address in the signal vector
- chopper~ munging loop playback from a buffer
- clean_selector~ like selector~ but crossfades when switching channels
- click~ converts a bang to a click
- click2float~ translates a signal click to a float message
- clickhold~ sample and hold a click
- convolver~ non-real-time convolution with impulses of arbitrary size
- distortion~ lookup function distortion
- dmach~ pattern based sample accurate drum machine prototype
- expflam~ converts a click to an exponential flam click pattern
- flanjah~ simple flanger
- function~ write various functions into an array
- granola~ granular pitch scaling
- granulesf~ granular synthesis module reading from a soundfile in a buffer
- granule~ granular synthesis module reading from a stored waveform in a buffer
- kbuffer~ low sampling rate buffer to capture gestures
- killdc~ DC block filter
- latch~ sustain an incoming click with sample-accurate timing
- magfreq_analysis~ transforms a time domain signal to a magnitude/frequency spectrum
- markov~ implements a first order Markov chain
- mask~ a click driven pattern sequencer
- npan~ power-panning to an arbitrary number of output channels
- oscil~ oscillator with flexible waveform specification
- phasemod~ phase modulated waveform
- player~ click driven buffer player that can sustain multiple iterations
- poltocar~ convert spectral frame from polar to complex representation
- pulser~ pulse wave generated by additive synthesis
- quadpan~ pan an incoming sound within a quadraphonic plane
- rotapan~ rotate an array of input channels to the same number of output channels
- rtrig~ generates random click triggers
- samm~ sample accurate multiple metronomes, with click signal articulation
- sarec~ sample accurate recording
- sel~ sample-accurate implementation of the sel algorithm
- shoehorn~ collapse from a larger number to a smaller number of audio channels
- sigseq~ signal level numerical sequencer
- splitbank~ - split an incoming sound into complementary, independently tunable spectra
- splitspec~ split an incoming sound into complementary spectra
- squash~ implementation of a compression algorithm by Chris Penrose
- stutter~ stuttering playback from an array
- vdb~ a delay line using an array for storage (no vector limit on feedback delaytime)
- vdp~ a simple, self-contained delay unit
- vecdex~ outputs the sample index within the current signal vector
- waveshape~ a Chebychev function lookup waveshaper
- windowvec~ apply a Hann window to the input signal vector
Best wishes for the success of your creative projects and explorations!
Eric Lyon
ericlyon@vt.edu
Department of Music
Institute for Creativity, Arts, and Technology
Virginia Tech
# lyonpotpourri3.0
Welcome to LyonPotpourri, version 3.0 (64-bit version).
http://disis.music.vt.edu/eric/LyonSoftware/Pd/LyonPotpourri/
LyonPotpourri is a collection of externals developed for the creation and performance of computer music. The externals were originally developed for Max/MSP, and then extended into hybrid code that could compile for both Max/MSP and Pd. As of version 3.0, the code bases of Max/MSP and Pd have diverged to such an extent that I decided to split the LyonPotpourri code into separate Pd and Max/MSP versions.
The Pd platform tends toward minimalism. Therefore, it is particularly advantageous for Pd users to become adept at designing their own externals. It is hoped that in addition to the utility of specific externals in this collection, the source code will be helpful for computer musicians who wish to learn how to write their own externals. For further guidance on that subject, please see my book “Designing Audio Objects for Max/MSP and Pd.”
LyonPotpourri 3.0 is Copyright Eric Lyon, 2007-2013, and is covered under the MIT license. Please see the accompanying License file for details.
Object Listing:
- adsr~ a simple ADSR envelope that can be click triggered
- arrayfilt~ fft-based filtering by drawing into an array
- bashfest~ a click driven buffer player with randomized DSP
- buffet~ provides operations on a stored buffer
- bvplay~ selective playback from a stored buffer with enveloping and increment control
- cartopol~ convert a spectral frame from cartesian to polar form
- channel~ access to a precise address in the signal vector
- chopper~ munging loop playback from a buffer
- clean_selector~ like selector~ but crossfades when switching channels
- click~ converts a bang to a click
- click2float~ translates a signal click to a float message
- clickhold~ sample and hold a click
- convolver~ non-real-time convolution with impulses of arbitrary size
- distortion~ lookup function distortion
- dmach~ pattern based sample accurate drum machine prototype
- expflam~ converts a click to an exponential flam click pattern
- flanjah~ simple flanger
- function~ write various functions into an array
- granola~ granular pitch scaling
- granulesf~ granular synthesis module reading from a soundfile in a buffer
- granule~ granular synthesis module reading from a stored waveform in a buffer
- kbuffer~ low sampling rate buffer to capture gestures
- killdc~ DC block filter
- latch~ sustain an incoming click with sample-accurate timing
- magfreq_analysis~ transforms a time domain signal to a magnitude/frequency spectrum
- markov~ implements a first order Markov chain
- mask~ a click driven pattern sequencer
- npan~ power-panning to an arbitrary number of output channels
- oscil~ oscillator with flexible waveform specification
- phasemod~ phase modulated waveform
- player~ click driven buffer player that can sustain multiple iterations
- poltocar~ convert spectral frame from polar to complex representation
- pulser~ pulse wave generated by additive synthesis
- quadpan~ pan an incoming sound within a quadraphonic plane
- rotapan~ rotate an array of input channels to the same number of output channels
- rtrig~ generates random click triggers
- samm~ sample accurate multiple metronomes, with click signal articulation
- sarec~ sample accurate recording
- sel~ sample-accurate implementation of the sel algorithm
- shoehorn~ collapse from a larger number to a smaller number of audio channels
- sigseq~ signal level numerical sequencer
- splitbank~ - split an incoming sound into complementary, independently tunable spectra
- splitspec~ split an incoming sound into complementary spectra
- squash~ implementation of a compression algorithm by Chris Penrose
- stutter~ stuttering playback from an array
- vdb~ a delay line using an array for storage (no vector limit on feedback delaytime)
- vdp~ a simple, self-contained delay unit
- vecdex~ outputs the sample index within the current signal vector
- waveshape~ a Chebychev function lookup waveshaper
- windowvec~ apply a Hann window to the input signal vector
Best wishes for the success of your creative projects and explorations!
Eric Lyon
ericlyon@vt.edu
Department of Music
Institute for Creativity, Arts, and Technology
Virginia Tech
Updates to LyonPotpourri 3.0
12.22.2013
Nothing yet!
\ No newline at end of file
#N canvas 487 392 455 385 10;
#X obj 115 233 adsr~;
#X msg 115 94 bang;
#X obj 35 187 osc~ 400;
#X obj 97 274 *~;
#X obj 97 304 *~ 0.1;
#X obj 97 335 dac~;
#X msg 175 112 10 50 50 50;
#X text 254 115 adsr data as list;
#X msg 182 137 100 50 100 500;
#X obj 175 90 loadbang;
#N canvas 0 22 673 325 individual-adsr-elements 0;
#X obj 62 244 outlet;
#X msg 62 158 set_a \$1;
#X msg 135 159 set_d \$1;
#X msg 210 158 set_s \$1;
#X msg 283 159 set_r \$1;
#X msg 353 159 set_gain1 \$1;
#X msg 451 160 set_gain2 \$1;
#X obj 353 110 vsl 15 30 0 1 0 0 empty empty empty 0 -8 0 8 -242048
-1 -1 2900 1;
#X obj 451 109 vsl 15 30 0 1 0 0 empty empty empty 0 -8 0 8 -242048
-1 -1 2030 1;
#X obj 62 106 vsl 15 30 1 100 0 0 empty empty empty 0 -8 0 8 -242048
-1 -1 1435 1;
#X obj 135 110 vsl 15 30 10 100 0 0 empty empty empty 0 -8 0 8 -242048
-1 -1 1289 1;
#X obj 210 107 vsl 15 30 50 500 0 0 empty empty empty 0 -8 0 8 -242048
-1 -1 967 1;
#X obj 283 109 vsl 15 30 50 1000 0 0 empty empty empty 0 -8 0 8 -242048
-1 -1 458 1;
#X msg 62 40 50 50 200 200 1 0.7;
#X obj 62 64 unpack f f f f f f;
#X obj 62 16 loadbang;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
#X connect 3 0 0 0;
#X connect 4 0 0 0;
#X connect 5 0 0 0;
#X connect 6 0 0 0;
#X connect 7 0 5 0;
#X connect 8 0 6 0;
#X connect 9 0 1 0;
#X connect 10 0 2 0;
#X connect 11 0 3 0;
#X connect 12 0 4 0;
#X connect 13 0 14 0;
#X connect 14 0 9 0;
#X connect 14 1 10 0;
#X connect 14 2 11 0;
#X connect 14 3 12 0;
#X connect 14 4 7 0;
#X connect 14 5 8 0;
#X connect 15 0 13 0;
#X restore 194 163 pd individual-adsr-elements;
#X obj 205 200 samm~ 40 1;
#X text 30 39 adsr~ - An ADSR envelope triggered by signal clicks or
bangs;
#X obj 26 4 cnv 15 155 25 empty empty LyonPotpourri 20 12 1 18 -260097
-204786 0;
#X text 111 74 trigger ADSR;
#X text 273 197 slow click metronome;
#X connect 0 0 3 1;
#X connect 1 0 0 0;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 4 0 5 0;
#X connect 4 0 5 1;
#X connect 6 0 0 0;
#X connect 8 0 0 0;
#X connect 9 0 6 0;
#X connect 10 0 0 0;
#X connect 11 0 0 0;
#include "MSPd.h"
/* internal metronome now redundant so disabled */
// LyonPotpourri 3.0 - Max references removed
static t_class *adsr_class;
#define OBJECT_NAME "adsr~"
typedef struct _adsr
{
t_object x_obj;
float x_f;
// Variables Here
float a;
float d;
float s;
float r;
int ebreak1;
int ebreak2;
int ebreak3;
int asamps;
int dsamps;
int ssamps;
int rsamps;
int asamps_last;
int dsamps_last;
int ssamps_last;
int rsamps_last;
float tempo;
float egain1;
float egain2;
int tempomode;
int beat_subdiv;
int tsamps;
int counter;
float srate;
short manual_override;
float click_gain; // input click sets volume too
short mute;
} t_adsr;
static void *adsr_new(t_symbol *s, int argc, t_atom *argv);
t_int *adsr_perform(t_int *w);
void adsr_dsp(t_adsr *x, t_signal **sp);
void adsr_assist(t_adsr *x, void *b, long m, long a, char *s);
void adsr_bang(t_adsr *x);
void adsr_manual_override(t_adsr *x, t_floatarg toggle);
void adsr_list (t_adsr *x, t_atom *msg, short argc, t_atom *argv);
void adsr_tempomode(t_adsr *x, t_atom *msg, short argc, t_atom *argv);
void adsr_set_a(t_adsr *x, t_floatarg f);
void adsr_set_d(t_adsr *x, t_floatarg f);
void adsr_set_s(t_adsr *x, t_floatarg f);
void adsr_set_r(t_adsr *x, t_floatarg f);
void adsr_set_gain1(t_adsr *x, t_floatarg f);
void adsr_set_gain2(t_adsr *x, t_floatarg f);
void set_tempo(t_adsr *x, t_floatarg f);
void adsr_mute(t_adsr *x, t_floatarg f);
void atom_arg_getfloat(float *c, long idx, long ac, t_atom *av);
void atom_arg_getsym(t_symbol **c, long idx, long ac, t_atom *av);
void adsr_tilde_setup(void){
adsr_class = class_new(gensym("adsr~"), (t_newmethod)adsr_new,
0,sizeof(t_adsr), 0,A_GIMME,0);
CLASS_MAINSIGNALIN(adsr_class, t_adsr, x_f);
class_addmethod(adsr_class,(t_method)adsr_dsp,gensym("dsp"),0);
class_addmethod(adsr_class,(t_method)adsr_mute,gensym("mute"),A_FLOAT,0);
class_addmethod(adsr_class,(t_method)adsr_list,gensym("list"),A_GIMME,0);
class_addmethod(adsr_class,(t_method)adsr_set_a,gensym("set_a"),A_FLOAT,0);
class_addmethod(adsr_class,(t_method)adsr_set_d,gensym("set_d"),A_FLOAT,0);
class_addmethod(adsr_class,(t_method)adsr_set_s,gensym("set_s"),A_FLOAT,0);
class_addmethod(adsr_class,(t_method)adsr_set_r,gensym("set_r"),A_FLOAT,0);
class_addmethod(adsr_class,(t_method)adsr_set_gain1,gensym("set_gain1"),A_FLOAT,0);
class_addmethod(adsr_class,(t_method)adsr_set_gain2,gensym("set_gain2"),A_FLOAT,0);
class_addbang(adsr_class,(t_method)adsr_bang);
potpourri_announce(OBJECT_NAME);
}
void adsr_mute(t_adsr *x, t_floatarg f)
{
x->mute = (short)f;
}
void adsr_set_gain1(t_adsr *x, t_floatarg f)
{
x->egain1 = f;
return;
}
void adsr_set_gain2(t_adsr *x, t_floatarg f)
{
x->egain2 = f;
return;
}
void adsr_bang(t_adsr *x) {
x->counter = 0;
return;
}
void adsr_set_a(t_adsr *x, t_floatarg f)
{
f /= 1000.0;
x->a = f;
x->asamps = x->a * x->srate;
if( x->tempomode) {
x->rsamps = x->tsamps - (x->asamps+x->dsamps+x->ssamps);
if( x->rsamps < 0 ) {
x->rsamps = 0;
}
} else {
x->tsamps = x->asamps+x->dsamps+x->ssamps+x->rsamps;
}
x->ebreak1 = x->asamps;
x->ebreak2 = x->asamps+x->dsamps;
x->ebreak3 = x->asamps+x->dsamps+x->ssamps;
return ;
}
void adsr_set_d(t_adsr *x, t_floatarg f)
{
f /= 1000.0 ;
x->d = f;
x->dsamps = x->d * x->srate;
if( x->tempomode) {
x->rsamps = x->tsamps - (x->asamps+x->dsamps+x->ssamps);
if( x->rsamps < 0 ) {
x->rsamps = 0;
}
} else {
x->tsamps = x->asamps+x->dsamps+x->ssamps+x->rsamps;
}
x->ebreak2 = x->asamps+x->dsamps;
x->ebreak3 = x->asamps+x->dsamps+x->ssamps;
return ;
}
void adsr_set_s(t_adsr *x, t_floatarg f)
{
f /= 1000.0;
x->s = f;
x->ssamps = x->s * x->srate;
if( x->tempomode) {
x->rsamps = x->tsamps - (x->asamps+x->dsamps+x->ssamps);
if( x->rsamps < 0 ) {
x->rsamps = 0;
}
} else {
x->tsamps = x->asamps+x->dsamps+x->ssamps+x->rsamps;
}
x->ebreak3 = x->asamps+x->dsamps+x->ssamps;
return ;
}
void adsr_set_r(t_adsr *x, t_floatarg f)
{
f /= 1000.0;
if( x->tempomode) {
return;
} else {
x->r = f;
x->rsamps = x->r * x->srate;
x->tsamps = x->asamps+x->dsamps+x->ssamps+x->rsamps;
}
return ;
}
void adsr_list (t_adsr *x, t_atom *msg, short argc, t_atom *argv)
{
t_atom *fraud; // make compiler happy
fraud = msg;
x->rsamps = x->tsamps - (x->asamps+x->dsamps+x->ssamps);
if( x->rsamps < 0 )
x->rsamps = 0;
x->a = (atom_getfloatarg(0,argc,argv)) * .001;
x->d = (atom_getfloatarg(1,argc,argv)) * .001;
x->s = (atom_getfloatarg(2,argc,argv)) * .001;
x->r = (atom_getfloatarg(3,argc,argv)) * .001;
x->asamps = x->a * x->srate;
x->dsamps = x->d * x->srate;
x->ssamps = x->s * x->srate;
x->rsamps = x->r * x->srate;
x->tsamps = x->asamps+x->dsamps+x->ssamps+x->rsamps;
x->ebreak1 = x->asamps;
x->ebreak2 = x->asamps+x->dsamps;
x->ebreak3 = x->asamps+x->dsamps+x->ssamps;
}
static void *adsr_new(t_symbol *s, int argc, t_atom *argv)
{
t_adsr *x = (t_adsr *)pd_new(adsr_class);
t_symbol *fraud; // make compiler happy
fraud = s;
outlet_new(&x->x_obj, gensym("signal"));
x->srate = sys_getsr();
if(!x->srate){
error("zero sampling rate, setting to 44100");
x->srate = 44100;
}
x->a = 10;
x->d = 50;
x->s = 100;
x->r = 100;
x->egain1 = .7;
x->egain2 = .1;
atom_arg_getfloat(&x->a,0,argc,argv);
atom_arg_getfloat(&x->d,1,argc,argv);
atom_arg_getfloat(&x->s,2,argc,argv);
atom_arg_getfloat(&x->r,3,argc,argv);
atom_arg_getfloat(&x->egain1,4,argc,argv);
atom_arg_getfloat(&x->egain2,5,argc,argv);
x->a *= .001;
x->d *= .001;
x->s *= .001;
x->r *= .001;
x->asamps = x->a * x->srate;
x->dsamps = x->d * x->srate;
x->ssamps = x->s * x->srate;
x->rsamps = x->r * x->srate;
x->tsamps = x->asamps+x->dsamps+x->ssamps+x->rsamps;
x->ebreak1 = x->asamps;
x->ebreak2 = x->asamps+x->dsamps;
x->ebreak3 = x->asamps+x->dsamps+x->ssamps;
x->counter = 0;
x->click_gain = 0.0;
x->mute = 0;
return x;
}
t_int *adsr_perform(t_int *w)
{
t_adsr *x = (t_adsr *) (w[1]);
t_float *in = (t_float *)(w[2]);
t_float *out = (t_float *)(w[3]);
int n = (int) w[4];
int tsamps = x->tsamps;
int counter = x->counter;
int ebreak1 = x->ebreak1;
int ebreak2 = x->ebreak2;
int ebreak3 = x->ebreak3;
float egain1 = x->egain1;
float egain2 = x->egain2;
int asamps = x->asamps;
int dsamps = x->dsamps;
int ssamps = x->ssamps;
int rsamps = x->rsamps;