File: CLAMRemoteController.hxx

package info (click to toggle)
clam 1.4.0-6
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 17,836 kB
  • ctags: 20,981
  • sloc: cpp: 92,504; python: 9,721; ansic: 1,602; xml: 444; sh: 239; makefile: 153; perl: 54; asm: 15
file content (127 lines) | stat: -rw-r--r-- 2,216 bytes parent folder | download | duplicates (2)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef _CLAM_REMOTE_CONTROLLER_
#define _CLAM_REMOTE_CONTROLLER_

#include <ladspa.h>
#include <cstring>
#include <cstdlib>
#include <iostream>

#include "Network.hxx"
#include "PushFlowControl.hxx"
#include "XMLStorage.hxx"
#include "ExternGenerator.hxx"
#include "ExternSink.hxx"
#include "ExternInControl.hxx"
#include "ExternOutControl.hxx"
#include "Text.hxx"
#include "OSCSender.hxx"

//C++ version 
static char *dupstr( char const *args )
{
	char * s;
	size_t v;

	try
	{
		s = new char[v = strlen(args) + 1];
		memcpy( s, args, v );
	}
	catch( std::bad_alloc )
	{
		s = NULL;
	}
	return s;
} 


namespace CLAM
{

class RemoteControlPair : public CLAM::DynamicType
{
public:
	DYNAMIC_TYPE( RemoteControlPair, 3 );
	DYN_ATTRIBUTE( 0, public, std::string, Name ); 
	DYN_ATTRIBUTE( 1, public, ExternInControlConfig, ControlConfig );
	DYN_ATTRIBUTE( 2, public, OSCSenderConfig, SenderConfig );

protected:
	void DefaultInit()
	{
		AddAll();
		UpdateData();
	}
};

class RemoteControlList : public CLAM::DynamicType
{
public:
	DYNAMIC_TYPE( RemoteControlList, 1 );
	DYN_CONTAINER_ATTRIBUTE( 0, public, std::list<RemoteControlPair>, List, Pair);
 
protected:
	void DefaultInit()
	{
		AddAll();
		UpdateData();
	}
};

template<class T>
class LADSPAInfo
{
public:
	std::string name;
	T* processing;
	LADSPA_Data *dataBuffer;
};

typedef std::vector< LADSPAInfo<ExternInControl> > LADSPAInControlList;

class CLAMRemoteController
{
private:
	Network* mNet;		
	LADSPAInControlList mInControlList;
	LADSPAInfo<void> mPortList[4];
	std::vector<OSCSender*> mSenderList;
	TData* mLastValues;
		
	RemoteControlList mRemoteControlList;
	
public:
	CLAMRemoteController();
	~CLAMRemoteController();
	void CreateStructure();
	
	int GetPortCount()
	{
		return 4;
	}
	
	int GetControlCount()
	{
		return ( mInControlList.size() );
	}

	Network& GetNetwork()
	{
		return *mNet;
	}


	void ProcessPorts();

	void FillPortInfo( LADSPA_PortDescriptor* descriptors, char** names, LADSPA_PortRangeHint* rangehints );
	void ConnectTo(unsigned long port, LADSPA_Data * data);
	
	void Run( unsigned long nsamples );
	void ProcessInControlValues();
	void CopyInPortsToOutputPorts( unsigned long nsamples );
};

} //namespace CLAM

#endif