forked from fxsound2/fxsound-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComMem.cpp
More file actions
184 lines (156 loc) · 4.94 KB
/
Copy pathComMem.cpp
File metadata and controls
184 lines (156 loc) · 4.94 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
FxSound
Copyright (C) 2023 FxSound LLC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Standard includes */
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "codedefs.h"
#include "pt_defs.h"
#include "slout.h"
#define PC_TARGET
#include "platform.h"
#include "boardrv1.h"
extern "C"
{
#include "hrdwr.h"
#include "comSftwr.h"
#include "c_dsps.h"
}
#include "comSftwrCPP.h"
#include "com.h"
#include "u_com.h"
/*
* FUNCTION: comMemReInitialize()
* DESCRIPTION:
* This function is called when a parameter written to the DSP
* requires that the memory of the DSP be reinitialized.
* For example, in the LexReverb, after the roomsize is written,
* this function needs to be called to reinit all the memory pointers
* that are used in the LexReverb.
*/
int PT_DECLSPEC comMemReInitialize(PT_HANDLE *hp_com, realtype r_sampling_freq)
{
struct comHdlType *cast_handle;
cast_handle = (struct comHdlType *)hp_com;
if (cast_handle == NULL)
return(NOT_OKAY);
/* Currently just does a reinitialization of memory. Flag can be set to also init parameters */
if( comSftwrInitDspAlgorithmCPP(cast_handle->comSftwr_hdl, r_sampling_freq,
DSPS_RE_INIT_MEMORY) != OKAY)
return(NOT_OKAY);
return(OKAY);
}
/*
* FUNCTION: ComCheckOutProcessor()
* DESCRIPTION:
* Checks out or checks in a processor number for use with this particular instance of this plug-in.
* Set i_checkout_flag to IS_TRUE to checkout a processor or to IS_FALSE to check one in.
*/
int comCheckOutProcessor(char *cp_dsp_function, int i_checkout_flag, int *ip_processor_num)
{
int processor_found;
int processor_index;
int plug_in_index;
int i, j;
/* Statics */
static int first_entry = IS_TRUE;
/* Array containing processor status, 1 -> checked out, 0 -> available */
static int processor_array[DSPFX_NUM_PLUGIN_TYPES][DSPFX_MAX_NUM_PROCS];
/* If this is the first call to this function, zero the processor array */
if (first_entry == IS_TRUE)
{
first_entry = IS_FALSE;
for(i=0; i < DSPFX_NUM_PLUGIN_TYPES; i++)
{
for(j=0; j < DSPFX_MAX_NUM_PROCS; j++)
processor_array[i][j] = 0;
}
}
/* Find the plug-in type index number */
plug_in_index = 0;
/* Note that since for each plug-in type, different strings can be passed in,
* ie, flang1, flang2, we will compare only the first unique chars for each
* plug-in type.
*/
if (strncmp(cp_dsp_function, "dly", 3) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "flang", 5) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "chor", 4) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "pitch", 5) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "peq", 3) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "trm", 3) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "pan", 3) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "R1s", 3) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "cmp8", 4) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "aural", 5) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "max", 3) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "lex", 3) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "apt", 3) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "ply", 3) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "cmp0", 4) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "wid", 3) != 0)
plug_in_index++;
else if (strncmp(cp_dsp_function, "proto10", 7) != 0)
plug_in_index++;
if ( plug_in_index >= DSPFX_NUM_PLUGIN_TYPES )
return(NOT_OKAY);
if (i_checkout_flag == IS_TRUE)
{
i = 0;
processor_found = 0;
while ( (processor_found == 0) && (i < DSPFX_MAX_NUM_PROCS) )
{
if ( processor_array[plug_in_index][i] == 0 )
{
/* Note that Processor numbers range from 1 to DSPFX_MAX_NUM_PROCS */
*ip_processor_num = i + 1;
processor_array[plug_in_index][i] = 1;
processor_found = 1;
}
i++;
}
if (processor_found == 0)
{
/* We hit this case if all processors are assigned */
return(NOT_OKAY);
}
}
else
{
/* Checkin case */
processor_index = *ip_processor_num - 1;
if ( (processor_index < 0) || (processor_index >= DSPFX_MAX_NUM_PROCS) )
return(NOT_OKAY);
processor_array[plug_in_index][processor_index] = 0;
}
return(OKAY);
}