@@ -101,13 +101,12 @@ make prune
101
101
Usage
102
102
======
103
103
104
- Here's the code snippet of how the library can be initialized and used:
104
+ Here's the code snippet of how the library can be initialized and used in C++ :
105
105
106
106
``` C++
107
-
108
107
#include < lsp-plug.in/dsp/dsp.h>
109
108
#include < stdio.h>
110
-
109
+ # include < stdlib.h >
111
110
112
111
int main (int argc, const char ** argv)
113
112
{
@@ -128,15 +127,16 @@ int main(int argc, const char **argv)
128
127
129
128
// For faster computing we can tune CPU by updating thread context.
130
129
// This will enable Flush-to-Zero and Denormals-are-Zero flags on
131
- // CPUs that support them
130
+ // CPUs that support them. This is thread-local change and should
131
+ // be called in each individual processing thread
132
132
dsp::context_t ctx;
133
133
dsp::start(&ctx);
134
134
135
135
// Here we call some dsp functions, for example dsp::fill_zero
136
136
float v[0x1000];
137
137
dsp::fill_zero(v, sizeof(v)/sizeof(float));
138
138
139
- // At the end, we need to restore the context
139
+ // At the end, we need to restore the context and reset CPU settings to defaults
140
140
dsp::finish(&ctx);
141
141
142
142
return 0;
@@ -145,5 +145,48 @@ int main(int argc, const char **argv)
145
145
146
146
```
147
147
148
+ Also all functions can be accessed from pure C with ```lsp_dsp_``` prefix in the funcion and type names:
149
+
150
+ ```C
151
+ #include <lsp-plug.in/dsp/dsp.h>
152
+ #include <stdio.h>
153
+ #include <stdlib.h>
154
+
155
+ int main(int argc, const char **argv)
156
+ {
157
+ // Initialize DSP
158
+ lsp_dsp_init();
159
+
160
+ // Optionally: output information about the system
161
+ lsp_dsp_info_t *info = lsp_dsp_info();
162
+ if (info != NULL)
163
+ {
164
+ printf("Architecture: %s\n", info->arch);
165
+ printf("Processor: %s\n", info->cpu);
166
+ printf("Model: %s\n", info->model);
167
+ printf("Features: %s\n", info->features);
168
+
169
+ free(info);
170
+ }
171
+
172
+ // For faster computing we can tune CPU by updating thread context.
173
+ // This will enable Flush-to-Zero and Denormals-are-Zero flags on
174
+ // CPUs that support them. This is thread-local change and should
175
+ // be called in each individual processing thread
176
+ lsp_dsp_context_t ctx;
177
+ lsp_dsp_start(&ctx);
178
+
179
+ // Here we call some dsp functions, for example lsp_dsp_fill_zero
180
+ float v[0x1000];
181
+ lsp_dsp_fill_zero(v, sizeof(v)/sizeof(float));
182
+
183
+ // At the end, we need to restore the context and reset CPU settings to defaults
184
+ lsp_dsp_finish(&ctx);
185
+
186
+ return 0;
187
+ }
188
+
189
+
190
+ ```
148
191
149
192
0 commit comments