1 /* am.cpp
2 
3    Computer Music Toolkit - a library of LADSPA plugins. Copyright (C)
4    2000 Richard W.E. Furse. The author may be contacted at
5    richard@muse.demon.co.uk.
6 
7    This library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public Licence as
9    published by the Free Software Foundation; either version 2 of the
10    Licence, or (at your option) any later version.
11 
12    This library is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this library; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20    02111-1307, USA. */
21 
22 /*****************************************************************************/
23 
24 #include <stdlib.h>
25 #include <string.h>
26 
27 /*****************************************************************************/
28 
29 #include "cmt.h"
30 
31 /*****************************************************************************/
32 
33 #define AM_INPUT1 0
34 #define AM_INPUT2 1
35 #define AM_OUTPUT 2
36 
37 /** This plugin multiplies two signals together to produce a third. */
38 class AmplitudeModulator : public CMT_PluginInstance {
39 public:
40 
AmplitudeModulator(const LADSPA_Descriptor *,unsigned long)41   AmplitudeModulator(const LADSPA_Descriptor *,
42 		     unsigned long)
43     : CMT_PluginInstance(3) {
44   }
45 
46   friend void runAmplitudeModulator(LADSPA_Handle Instance,
47 			     unsigned long SAmplitudeModulatorpleCount);
48 
49 };
50 
51 /*****************************************************************************/
52 
53 void
runAmplitudeModulator(LADSPA_Handle Instance,unsigned long SAmplitudeModulatorpleCount)54 runAmplitudeModulator(LADSPA_Handle Instance,
55 		      unsigned long SAmplitudeModulatorpleCount) {
56 
57   AmplitudeModulator * poAmplitudeModulator = (AmplitudeModulator *)Instance;
58 
59   LADSPA_Data * pfInput1 = poAmplitudeModulator->m_ppfPorts[AM_INPUT1];
60   LADSPA_Data * pfInput2 = poAmplitudeModulator->m_ppfPorts[AM_INPUT2];
61   LADSPA_Data * pfOutput = poAmplitudeModulator->m_ppfPorts[AM_OUTPUT];
62 
63   for (unsigned long lSAmplitudeModulatorpleIndex = 0;
64        lSAmplitudeModulatorpleIndex < SAmplitudeModulatorpleCount;
65        lSAmplitudeModulatorpleIndex++)
66     *(pfOutput++) = *(pfInput1++) * *(pfInput2++);
67 }
68 
69 /*****************************************************************************/
70 
71 void
initialise_am()72 initialise_am() {
73 
74   CMT_Descriptor * psDescriptor = new CMT_Descriptor
75     (1070,
76      "am",
77      LADSPA_PROPERTY_HARD_RT_CAPABLE,
78      "Amplitude Modulator",
79      CMT_MAKER("Richard W.E. Furse"),
80      CMT_COPYRIGHT("2000", "Richard W.E. Furse"),
81      NULL,
82      CMT_Instantiate<AmplitudeModulator>,
83      NULL,
84      runAmplitudeModulator,
85      NULL,
86      NULL,
87      NULL);
88   psDescriptor->addPort
89     (LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO,
90      "Input 1");
91   psDescriptor->addPort
92     (LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO,
93      "Input 2");
94   psDescriptor->addPort
95     (LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO,
96      "Output");
97 
98   registerNewPluginDescriptor(psDescriptor);
99 }
100 
101 /*****************************************************************************/
102 
103 /* EOF */
104