aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/tutorial/signal2/main.cpp
blob: 3876a0cab40c2849cad2aff61c4cc40bf3a1c675 (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
/* 
flext tutorial - signal 2 

Copyright (c) 2002 Thomas Grill (xovo@gmx.net)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.  

-------------------------------------------------------------------------

This is an object showing varous parameters of the pd audio system
*/

// include flext header
#include <flext.h>

// check for appropriate flext version
#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400)
#error You need at least flext version 0.4.0
#endif


// define the class that stands for a pd/Max object
// Attention: the class name must be the same as the object name!! (without the ~)

class signal2:
	// inherit from flext dsp class
	public flext_dsp
{
	// obligatory flext header (class name,base class name)
	FLEXT_HEADER(signal2,flext_dsp)
 
public:
	// constructor
	signal2();

protected:
	void m_bang();  // method for bang

	// this virtual function is obligatory for objects derived from flext_dsp
//	virtual void m_signal(int n, float *const *in, float *const *out);

private:
	FLEXT_CALLBACK(m_bang);  // callback for method "m_bang" 
};

// instantiate the class
FLEXT_NEW_DSP("signal2~",signal2)


signal2::signal2()
{ 
	// define inlets:
	// first inlet must always by of type anything (or signal for dsp objects)
	AddInAnything();  // add one inlet for any message
	
	// add outlets for sample rate, block size, audio in and out channel count
	AddOutFloat(1);
	AddOutInt(3); // although PD knows no int type, flext does!
	
	// register methods
	FLEXT_ADDBANG(0,m_bang);  // register method "m_bang" for bang message into inlet 0
} 

void signal2::m_bang()
{
	// output various parameters of the pd audio system
	ToOutFloat(0,Samplerate()); 
	ToOutInt(1,Blocksize()); 
	ToOutInt(2,ChannelsIn()); 
	ToOutInt(3,ChannelsOut()); 
}

/*
void signal2::m_signal(int, float *const *, float *const *)
{
}
*/