-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSunVox.java
582 lines (533 loc) · 30 KB
/
SunVox.java
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
package com.github.technus.sunvoxlib.model;
import com.github.technus.sunvoxlib.SunVoxLib;
import com.github.technus.sunvoxlib.model.number.*;
import com.github.technus.sunvoxlib.model.slot.Slot;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.github.technus.sunvoxlib.model.SunVoxException.*;
public class SunVox implements AutoCloseable {
protected static SunVox INSTANCE = new SunVox();
public static SunVox getInstance() {
return INSTANCE;
}
private volatile BufferType bufferType;
private volatile boolean useCallback;
private EngineVersion engineVersion;
@Override
public void close() {
deinit();
}
public boolean isInitialized(){
return bufferType!=null;
}
public boolean isUsingCallbacks(){
if(!isInitialized())
throw new RuntimeException("Cannot check if callbacks are required on non initialized engine");
return useCallback;
}
public BufferType getBufferType(){
if(!isInitialized())
throw new RuntimeException("Cannot check if buffer type on non initialized engine");
return bufferType;
}
public EngineVersion getEngineVersion(){
if(!isInitialized())
throw new RuntimeException("Cannot check engine version on non initialized engine");
return engineVersion;
}
/**
*
* @param slot slot number
* @param track_num track number (within the virtual pattern)
* @param note 0 - nothing; 1..127 - note number; 128 - note off; 129, 130... - see {@link NoteCommand}
* @param vel velocity 1..129; 0 - default
* @param module 0 (empty) or module number + 1 (1..65535)
* @param ctl 0xCCEE; CC - controller number (1..255); EE - effect
* @param ctl_val value of the controller or parameter of the effect
*/
public void sendEvent(int slot, int track_num, int note, int vel, int module, int ctl, int ctl_val) {
voidIfOk(SunVoxLib.sv_send_event(slot, track_num, note, vel, module, ctl, ctl_val));
}
//region Main
/**
* Global sound system initialization
* @param freq desired sample rate (Hz)
* min - 44100
* the actual rate may be different, if SV_INIT_FLAG_OFFLINE is not set
* @param flags set of flags {@link InitializationFlag}
* @return SunVox engine version
*/
public EngineVersion init(int freq, InitializationFlag... flags) {
return init(null,freq,flags);
}
/**
* Global sound system initialization
* @param config string with additional configuration in the following format: "option_name=value|option_name=value"
* or NULL for auto config
* example: "buffer=1024|audiodriver=alsa|audiodevice=hw:0,0"
* @param freq desired sample rate (Hz)
* min - 44100
* the actual rate may be different, if SV_INIT_FLAG_OFFLINE is not set
* @param flags set of flags {@link InitializationFlag}
* @return SunVox engine version
*/
public EngineVersion init(String config, int freq, InitializationFlag... flags) {
return init(config,freq,2,flags);
}
/**
* Global sound system initialization
* @param config string with additional configuration in the following format: "option_name=value|option_name=value"
* or NULL for auto config
* example: "buffer=1024|audiodriver=alsa|audiodevice=hw:0,0"
* @param freq desired sample rate (Hz)
* min - 44100
* the actual rate may be different, if SV_INIT_FLAG_OFFLINE is not set
* @param channels only 2 supported now
* @param flags set of flags {@link InitializationFlag}
* @return SunVox engine version
*/
protected synchronized EngineVersion init(String config, int freq, int channels, InitializationFlag... flags) {
if(isInitialized())
throw new RuntimeException("Was already initialized");
BufferType type = BufferType.forFlags(flags);
useCallback = Arrays.stream(flags).anyMatch(x->x.getValue()==InitializationFlag.USER_AUDIO_CALLBACK.getValue());
engineVersion = new EngineVersion(intIfOk(SunVoxLib.sv_init(config,freq,channels,InitializationFlag.ofAll(flags).getValue())));
bufferType = type;
return engineVersion;
}
/**
* Global sound system deinitialization
*/
protected synchronized void deinit() {
if(!isInitialized())
throw new RuntimeException("Was already deinitialized");
voidIfOk(SunVoxLib.sv_deinit());
bufferType = null;
}
/**
* Get current sampling rate (it may differ from the frequency specified in {@link #init})
* @return sampling rate
*/
public int getSampleRate() {
return intIfOk(SunVoxLib.sv_get_sample_rate());
}
/**
* Handle input ON/OFF requests to enable/disable input ports of the sound card (for example, after the Input module creation).
* Call it from the main thread only, where the SunVox sound stream is not locked.
*/
public void updateInput() {
voidIfOk(SunVoxLib.sv_update_input());
}
/**
* get the next piece of SunVox audio from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @return buffer status
*/
@Deprecated
public int audioCallback(byte[] buf, int frames, int latency, int out_time) {
return intIfOk(SunVoxLib.sv_audio_callback(buf, frames, latency, out_time));
}
/**
* get the next piece of SunVox audio from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @return buffer status
*/
@Deprecated
public BufferStatus callback(byte[] buf, int frames, int latency, int out_time) {
return BufferStatus.MAPPING.get(audioCallback(buf,frames,latency,out_time));
}
/**
* get the next piece of SunVox audio from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @return buffer status
*/
public int audioCallback(short[] buf, int frames, int latency, int out_time) {
return intIfOk(SunVoxLib.sv_audio_callback(buf, frames, latency, out_time));
}
/**
* get the next piece of SunVox audio from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @return buffer status
*/
public BufferStatus callback(short[] buf, int frames, int latency, int out_time) {
return BufferStatus.MAPPING.get(audioCallback(buf, frames, latency, out_time));
}
/**
* get the next piece of SunVox audio from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @return buffer status
*/
public int audioCallback(float[] buf, int frames, int latency, int out_time) {
return intIfOk(SunVoxLib.sv_audio_callback(buf, frames, latency, out_time));
}
/**
* get the next piece of SunVox audio from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @return buffer status
*/
public BufferStatus callback(float[] buf, int frames, int latency, int out_time) {
return BufferStatus.MAPPING.get(audioCallback(buf, frames, latency, out_time));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_type bufferType
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
@Deprecated
public int audioCallback2(byte[] buf, int frames, int latency, int out_time, BufferType in_type, int in_channels, byte[] in_buf) {
return intIfOk(SunVoxLib.sv_audio_callback2(buf, frames, latency, out_time, in_type.getValue(), in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_type bufferType
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
@Deprecated
public BufferStatus callback2(byte[] buf, int frames, int latency, int out_time, BufferType in_type, int in_channels, byte[] in_buf) {
return BufferStatus.MAPPING.get(audioCallback2(buf, frames, latency, out_time, in_type, in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
@Deprecated
public int audioCallback2(byte[] buf, int frames, int latency, int out_time, int in_channels, short[] in_buf) {
return intIfOk(SunVoxLib.sv_audio_callback2(buf, frames, latency, out_time, BufferType.INT16.getValue(), in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
@Deprecated
public BufferStatus callback2(byte[] buf, int frames, int latency, int out_time, int in_channels, short[] in_buf) {
return BufferStatus.MAPPING.get(audioCallback2(buf, frames, latency, out_time, in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
@Deprecated
public int audioCallback2(byte[] buf, int frames, int latency, int out_time, int in_channels, float[] in_buf) {
return intIfOk(SunVoxLib.sv_audio_callback2(buf, frames, latency, out_time, BufferType.FLOAT32.getValue(), in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
@Deprecated
public BufferStatus callback2(byte[] buf, int frames, int latency, int out_time, int in_channels, float[] in_buf) {
return BufferStatus.MAPPING.get(audioCallback2(buf, frames, latency, out_time, in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_type bufferType
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
@Deprecated
public int audioCallback2(short[] buf, int frames, int latency, int out_time, BufferType in_type, int in_channels, byte[] in_buf) {
return intIfOk(SunVoxLib.sv_audio_callback2(buf, frames, latency, out_time, in_type.getValue(), in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_type bufferType
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
@Deprecated
public BufferStatus callback2(short[] buf, int frames, int latency, int out_time, BufferType in_type, int in_channels, byte[] in_buf) {
return BufferStatus.MAPPING.get(audioCallback2(buf, frames, latency, out_time, in_type, in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
public int audioCallback2(short[] buf, int frames, int latency, int out_time, int in_channels, short[] in_buf) {
return intIfOk(SunVoxLib.sv_audio_callback2(buf, frames, latency, out_time, BufferType.INT16.getValue(), in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
public BufferStatus callback2(short[] buf, int frames, int latency, int out_time, int in_channels, short[] in_buf) {
return BufferStatus.MAPPING.get(audioCallback2(buf, frames, latency, out_time, in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
public int audioCallback2(short[] buf, int frames, int latency, int out_time, int in_channels, float[] in_buf) {
return intIfOk(SunVoxLib.sv_audio_callback2(buf, frames, latency, out_time, BufferType.FLOAT32.getValue(), in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
public BufferStatus callback2(short[] buf, int frames, int latency, int out_time, int in_channels, float[] in_buf) {
return BufferStatus.MAPPING.get(audioCallback2(buf, frames, latency, out_time, in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_type bufferType
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
@Deprecated
public int audioCallback2(float[] buf, int frames, int latency, int out_time, BufferType in_type, int in_channels, byte[] in_buf) {
return intIfOk(SunVoxLib.sv_audio_callback2(buf, frames, latency, out_time, in_type.getValue(), in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_type bufferType
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
@Deprecated
public BufferStatus callback2(float[] buf, int frames, int latency, int out_time, BufferType in_type, int in_channels, byte[] in_buf) {
return BufferStatus.MAPPING.get(audioCallback2(buf, frames, latency, out_time, in_type, in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
public int audioCallback2(float[] buf, int frames, int latency, int out_time, int in_channels, short[] in_buf) {
return intIfOk(SunVoxLib.sv_audio_callback2(buf, frames, latency, out_time, BufferType.INT16.getValue(), in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
public BufferStatus callback2(float[] buf, int frames, int latency, int out_time, int in_channels, short[] in_buf) {
return BufferStatus.MAPPING.get(audioCallback2(buf, frames, latency, out_time, in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
public int audioCallback2(float[] buf, int frames, int latency, int out_time, int in_channels, float[] in_buf) {
return intIfOk(SunVoxLib.sv_audio_callback2(buf, frames, latency, out_time, BufferType.FLOAT32.getValue(), in_channels, in_buf));
}
/**
* send some data to the Input module and receive the filtered data from the Output module
* @param buf output buffer of type {@link Short} (if {@link InitializationFlag#AUDIO_INT16} is set in {@link #init})
* or {@link Float} (if {@link InitializationFlag#AUDIO_FLOAT32} is set in {@link #init})
* stereo data will be interleaved in this buffer: LRLR... (LR is a single frame (Left+Right))
* @param frames number of frames in destination buffer
* @param latency audio latency (in frames)
* @param out_time buffer output time (in system ticks)
* @param in_channels number of input channels
* @param in_buf input buffer
* stereo data must be interleaved in this buffer: LRLR...
* @return buffer status
*/
public BufferStatus callback2(float[] buf, int frames, int latency, int out_time, int in_channels, float[] in_buf) {
return BufferStatus.MAPPING.get(audioCallback2(buf, frames, latency, out_time, in_channels, in_buf));
}
//endregion
//region Other
/**
* SunVox engine uses system-provided time space, measured in system tick (don't confuse it with the project ticks).
* These ticks are required for parameters of functions such as {@link #audioCallback} {@link #audioCallback2} and {@link Slot#setEventT}.
* @return current tick counter (from 0 to 0xFFFFFFFF)
*/
public int getTicks() {
return intIfOk(SunVoxLib.sv_get_ticks());
}
/**
* SunVox engine uses system-provided time space, measured in system tick (don't confuse it with the project ticks).
* These ticks are required for parameters of functions such as {@link #audioCallback} {@link #audioCallback2} and {@link Slot#setEventT}.
* @return number of system ticks per second
*/
public int getTicksPerSecond() {
return intIfOk(SunVoxLib.sv_get_ticks_per_second());
}
/**
* Get the latest messages from the log
* @param size max number of bytes to read
* @return latest log messages
*/
public String getLog(int size) {
return stringIfNotNull(SunVoxLib.sv_get_log(size));
}
//endregion
}