aboutsummaryrefslogtreecommitdiff
path: root/polarizer/polarizer.hpp
blob: fb0eff451a66bf8ac6de40405c13e623bd6f825d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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