aboutsummaryrefslogtreecommitdiff
path: root/polarizer
diff options
context:
space:
mode:
Diffstat (limited to 'polarizer')
-rwxr-xr-xpolarizer/makefile46
-rw-r--r--polarizer/polarizer.cpp112
-rw-r--r--polarizer/polarizer.hpp78
-rw-r--r--polarizer/polarizerBi.cpp165
-rw-r--r--polarizer/polarizer~.pd38
5 files changed, 439 insertions, 0 deletions
diff --git a/polarizer/makefile b/polarizer/makefile
new file mode 100755
index 0000000..ba707dd
--- /dev/null
+++ b/polarizer/makefile
@@ -0,0 +1,46 @@
+CXX=g++
+CFLAGS=-O6 -mcpu=pentiumpro -g -ggdb
+FLAGS=-DPD
+
+FLEXTPATH=/usr/local/lib/pd/externs/flext
+#DFXINC=../dfx-library
+
+INCLUDES=/usr/local/lib/pd/include $(FLEXTPATH) #$(DFXINC)
+FLEXTLIB=$(FLEXTPATH)/flext.a
+
+LIBS=m
+
+PDEXTRA=/usr/local/lib/pd/extra
+
+TARGET=polarizer~.pd_linux
+
+SRCS=polarizer.cpp
+
+all: $(TARGET)
+
+%.o : %.cpp %.hpp
+ $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES)) $< -o $@
+
+$(DFXINC)/%.o : $(DFXINC)/%.cpp
+ $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES)) $< -o $@
+
+$(TARGET) : $(patsubst %.cpp,%.o,$(SRCS)) $(FLEXTLIB)
+ $(CXX) $(LDFLAGS) -shared $^ $(patsubst %,-l%,$(LIBS)) -o $@
+ strip --strip-unneeded $@
+ chmod 755 $@
+
+install: $(TARGET)
+ chown root.root $^
+ cp $^ $(PDEXTRA)
+
+.PHONY: clean
+clean:
+ rm -f *.o $(TARGET)
+
+
+
+
+
+
+
+
diff --git a/polarizer/polarizer.cpp b/polarizer/polarizer.cpp
new file mode 100644
index 0000000..e04f8fe
--- /dev/null
+++ b/polarizer/polarizer.cpp
@@ -0,0 +1,112 @@
+/*---------------------------------------------------------------
+
+ © 2001, Marcberg Soft und Hard GmbH, All Rights Perversed
+
+---------------------------------------------------------------*/
+
+#ifndef __polarizer
+#include "polarizer.hpp"
+#endif
+
+#include <stdio.h>
+
+//-----------------------------------------------------------------------------
+// initializations & such
+
+polarizer::polarizer(int argc, t_atom *argv) {
+
+ fSkip = 0.0f;
+ fAmount = 0.5f;
+ fImplode = 0.0f;
+
+ state = polarized; // the first sample is polarized
+
+ post("_ ____polarize~ ");
+
+ AddInSignal();
+ AddInFloat(3);
+ AddOutSignal();
+ SetupInOut();
+
+ FLEXT_ADDMETHOD( 1,setSkip);
+ FLEXT_ADDMETHOD( 2,setAmount);
+ FLEXT_ADDMETHOD( 3,setImplode);
+
+ post("_ ____ ____ _");
+}
+
+// GIMME class:
+FLEXT_NEW_TILDE_G("polarizer~", polarizer)
+
+//-----------------------------------------------------------------------------------------
+void polarizer::processReplacing(float **inputs, float **outputs, long sampleFrames) {
+ float amp;
+
+ for (long samplecount=0; (samplecount < sampleFrames); samplecount++)
+ {
+ amp = processSampleAmp();
+ outputs[0][samplecount] = processOutValue(amp, inputs[0][samplecount]);
+ }
+}
+
+
+void polarizer::m_signal(int n, float *const *in, float *const *out) {
+
+ // directly move everything to the vst part
+ processReplacing((float **)in, (float **)out,(long)n);
+} // end m_signal
+
+
+
+//-----------------------------------------------------------------------------------------
+// titles of each parameter
+
+void polarizer::m_help() {
+ post(" inlet --- uno ----> ___ _ leap [ ranging from about 1 to 81 ] samples");
+ post(" inlet -- due -- >>>>> ___ _ _ polarize :: 0~1 __ ------ _ amount");
+ post(" inlet ------- >> implode << ------- | triggered madness | burn the speakers");
+}
+
+
+//-----------------------------------------------------------------------------------------
+// this is for getting the scalar value amp for the current sample
+
+float polarizer::processSampleAmp() {
+
+ switch (state)
+ {
+ case unaffected: // nothing much happens in this section
+ if (--unaffectedSamples <= 0) // go to polarized when the leap is done
+ state = polarized;
+ return 1.0f;
+ break;
+ // end unaffected
+
+ case polarized:
+ state = unaffected; // go right back to unaffected
+ // but first figure out how long unaffected will last this time
+ unaffectedSamples = leapScaled(fSkip);
+ return (0.5f - fAmount) * 2.0f; // this is the polarization scalar
+ break;
+ // end polarized
+
+ default : return 1.0f;
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+// this is for calculating & sending the current sample output value to the output stream
+
+float polarizer::processOutValue(float amp, float in) {
+ float out = (in * amp); // if implode is off, just do the regular polarizing thing
+
+ if (fImplode >= 1.0f) // if it's on, then implode the audio signal
+ {
+ if (out > 0.0f) // invert the sample between 1 & 0
+ out = 1.0f - out;
+ else // invert the sample between -1 & 0
+ out = -1.0f - out;
+ }
+
+ return out;
+}
diff --git a/polarizer/polarizer.hpp b/polarizer/polarizer.hpp
new file mode 100644
index 0000000..fb0eff4
--- /dev/null
+++ b/polarizer/polarizer.hpp
@@ -0,0 +1,78 @@
+/*---------------------------------------------------------------
+
+ © 2001, Marcberg Soft & Hard GmbH, All Rights Reserved
+
+---------------------------------------------------------------*/
+
+#ifndef __polarizer_H
+#define __polarizer_H
+
+#include <stdlib.h>
+#include <math.h>
+
+#include "flext.h"
+
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 202)
+#error You need at least flext version 0.2.2
+#endif
+
+#define normalize(f,a,b) ((((f < b) ? f : b) > a) ? f : a)
+
+// these are the 2 states of the process:
+enum {
+ unaffected,
+ polarized
+};
+
+//-----------------------------------------------------------------------------
+// constants
+
+const long SKIPMIN = 1;
+const long SKIPMAX = 81;
+const long SKIPRANGE = SKIPMAX - SKIPMIN;
+
+// this is for converting from parameter entries to the real values
+#define leapScaled(A) ( ((long)(powf((A),1.5f)*SKIPRANGE)) + SKIPMIN )
+
+//-----------------------------------------------------------------------------
+
+class polarizer :
+ public flext_dsp {
+
+ FLEXT_HEADER(polarizer, flext_dsp)
+
+public:
+ polarizer(int argc, t_atom *argv);
+// ~polarizer();
+
+ virtual void processReplacing(float **inputs, float **outputs, long sampleFrames);
+
+ virtual void m_signal(int, t_sample *const *, t_sample *const *);
+ virtual void m_help();
+
+protected:
+ float processSampleAmp();
+ float processOutValue(float amp, float in);
+
+ float fSkip, fAmount, fImplode; // the parameters
+ char *programName;
+ long unaffectedSamples; // sample counter
+ int state; // the state of the process
+
+ FLEXT_CALLBACK_F(setSkip)
+ void setSkip(float f) {
+ fSkip = normalize(f,0,1);
+ }
+
+ FLEXT_CALLBACK_F(setAmount)
+ void setAmount(float f) {
+ fAmount = normalize(f,0,1);
+ }
+
+ FLEXT_CALLBACK_F(setImplode)
+ void setImplode(float f) {
+ fImplode = normalize(f,0,1);
+ }
+};
+
+#endif
diff --git a/polarizer/polarizerBi.cpp b/polarizer/polarizerBi.cpp
new file mode 100644
index 0000000..e270f55
--- /dev/null
+++ b/polarizer/polarizerBi.cpp
@@ -0,0 +1,165 @@
+/*---------------------------------------------------------------
+
+ © 2001, Marcberg Soft und Hard GmbH, All Rights Perversed
+
+---------------------------------------------------------------*/
+
+#ifndef __polarizer
+#include "polarizer.hpp"
+#endif
+
+#include <stdio.h>
+
+//-----------------------------------------------------------------------------------------
+// Destroy FX infos
+
+long Polarizer::getVendorVersion() {
+ return 1; }
+
+bool Polarizer::getErrorText(char *text) {
+ strcpy (text, "We're not gonna to make it."); // max 256 char
+ return true; }
+
+bool Polarizer::getVendorString(char *text) {
+ strcpy (text, "Destroy FX"); // a string identifying the vendor (max 64 char)
+ return true; }
+
+bool Polarizer::getProductString(char *text) {
+ // a string identifying the product name (max 64 char)
+ strcpy (text, "Super Destroy FX bipolar VST plugin pack");
+ return true; }
+
+//-----------------------------------------------------------------------------------------
+Polarizer::~Polarizer()
+{
+ if (programName)
+ delete[] programName;
+}
+
+//-----------------------------------------------------------------------------------------
+void Polarizer::setProgramName(char *name)
+{
+ strcpy(programName, name);
+}
+
+//-----------------------------------------------------------------------------------------
+void Polarizer::getProgramName(char *name)
+{
+ strcpy(name, programName);
+}
+
+//-----------------------------------------------------------------------------------------
+void Polarizer::setParameter(long index, float value)
+{
+ switch (index)
+ {
+ case kSkip : fSkip = value; break;
+ case kAmount : fAmount = value; break;
+ case kImplode : fImplode = value; break;
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+float Polarizer::getParameter(long index)
+{
+ switch (index)
+ {
+ default:
+ case kSkip : return fSkip;
+ case kAmount : return fAmount;
+ case kImplode : return fImplode;
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+// titles of each parameter
+
+void Polarizer::getParameterName(long index, char *label)
+{
+ switch (index)
+ {
+ case kSkip : strcpy(label, " leap "); break;
+ case kAmount : strcpy(label, "polarize"); break;
+ case kImplode : strcpy(label, "implode"); break;
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+// numerical display of each parameter's gradiations
+
+void Polarizer::getParameterDisplay(long index, char *text)
+{
+ switch (index)
+ {
+ case kSkip :
+ sprintf(text, "%ld", leapScaled(fSkip));
+ break;
+ case kAmount :
+ sprintf(text, "%.3f", fAmount);
+ break;
+ case kImplode :
+ if (fImplode >= 0.03f) strcpy(text, "yes");
+ else strcpy(text, "no");
+ break;
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+// unit of measure for each parameter
+
+void Polarizer::getParameterLabel(long index, char *label)
+{
+ switch (index)
+ {
+ case kSkip :
+ if (leapScaled(fSkip) == 1) strcpy(label, "sample ");
+ else strcpy(label, "samples");
+ break;
+ case kAmount : strcpy(label, "amount"); break;
+ case kImplode : strcpy(label, " "); break;
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+// this is for getting the scalar value amp for the current sample
+
+float Polarizer::processSampleAmp()
+{
+ switch (state)
+ {
+ case unaffected: // nothing much happens in this section
+ if (--unaffectedSamples <= 0) // go to polarized when the leap is done
+ state = polarized;
+ return 1.0f;
+ break;
+ // end unaffected
+
+ case polarized:
+ state = unaffected; // go right back to unaffected
+ // but first figure out how long unaffected will last this time
+ unaffectedSamples = leapScaled(fSkip);
+ return (0.5f - fAmount) * 2.0f; // this is the polarization scalar
+ break;
+ // end polarized
+
+ default : return 1.0f;
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+// this is for calculating & sending the current sample output value to the output stream
+
+float Polarizer::processOutValue(float amp, float in)
+{
+ float out = (in * amp); // if implode is off, just do the regular polarizing thing
+
+ if (fImplode >= 0.03f) // if it's on, then implode the audio signal
+ {
+ if (out > 0.0f) // invert the sample between 1 & 0
+ out = 1.0f - out;
+ else // invert the sample between -1 & 0
+ out = -1.0f - out;
+ }
+
+ return out;
+}
diff --git a/polarizer/polarizer~.pd b/polarizer/polarizer~.pd
new file mode 100644
index 0000000..74c42d3
--- /dev/null
+++ b/polarizer/polarizer~.pd
@@ -0,0 +1,38 @@
+#N canvas 576 400 662 501 10;
+#X obj 176 238 polarizer~;
+#X floatatom 255 148 5 0 0;
+#X floatatom 265 169 5 0 0;
+#X floatatom 286 189 5 0 0;
+#X obj 171 125 readsf~ 2;
+#X msg 204 86 1;
+#X msg 425 48 0;
+#X msg 208 49 open ../../dresscode/0/3.wav;
+#X obj 310 86 t b;
+#X obj 308 112 delay 100;
+#X obj 238 85 delay 100;
+#X text 463 50 stop this shit;
+#X text 19 10 ____ _ dfx transverb _ by ____ destroy fx ___ _ and martin
+pi;
+#X obj 176 363 dac~ 1 2;
+#X obj 176 317 *~;
+#X obj 227 317 *~;
+#X obj 282 268 vsl 15 128 0 100 0 0 empty empty volume 0 -8 1 8 -143491
+-262144 -1 8500 1;
+#X connect 0 0 15 0;
+#X connect 0 0 14 0;
+#X connect 1 0 0 1;
+#X connect 2 0 0 2;
+#X connect 3 0 0 3;
+#X connect 4 0 0 0;
+#X connect 4 2 10 0;
+#X connect 5 0 4 0;
+#X connect 6 0 4 0;
+#X connect 7 0 4 0;
+#X connect 7 0 8 0;
+#X connect 8 0 9 0;
+#X connect 9 0 5 0;
+#X connect 10 0 7 0;
+#X connect 14 0 13 0;
+#X connect 15 0 13 1;
+#X connect 16 0 15 1;
+#X connect 16 0 14 1;