1 /*=========================================================================== 2 BASS_FX 2.4 - Copyright (c) 2002-2018 (: JOBnik! :) [Arthur Aminov, ISRAEL] 3 [http://www.jobnik.org] 4 5 bugs/suggestions/questions: 6 forum : http://www.un4seen.com/forum/?board=1 7 http://www.jobnik.org/forums 8 e-mail : [email protected] 9 -------------------------------------------------- 10 11 NOTE: This header will work only with BASS_FX version 2.4.12 12 Check www.un4seen.com or www.jobnik.org for any later versions. 13 14 * Requires BASS 2.4 (available at http://www.un4seen.com) 15 ===========================================================================*/ 16 17 #ifndef BASS_FX_H 18 #define BASS_FX_H 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #ifndef BASS_FXDEF 25 #define BASS_FXDEF(f) WINAPI f 26 #endif 27 28 // BASS_CHANNELINFO types 29 #define BASS_CTYPE_STREAM_TEMPO 0x1f200 30 #define BASS_CTYPE_STREAM_REVERSE 0x1f201 31 32 // Tempo / Reverse / BPM / Beat flag 33 #define BASS_FX_FREESOURCE 0x10000 // Free the source handle as well? 34 35 // BASS_FX Version 36 DWORD BASS_FXDEF(BASS_FX_GetVersion)(); 37 38 /*=========================================================================== 39 DSP (Digital Signal Processing) 40 ===========================================================================*/ 41 42 /* 43 Multi-channel order of each channel is as follows: 44 3 channels left-front, right-front, center. 45 4 channels left-front, right-front, left-rear/side, right-rear/side. 46 5 channels left-front, right-front, center, left-rear/side, right-rear/side. 47 6 channels (5.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side. 48 8 channels (7.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side, left-rear center, right-rear center. 49 */ 50 51 // DSP channels flags 52 #define BASS_BFX_CHANALL -1 // all channels at once (as by default) 53 #define BASS_BFX_CHANNONE 0 // disable an effect for all channels 54 #define BASS_BFX_CHAN1 1 // left-front channel 55 #define BASS_BFX_CHAN2 2 // right-front channel 56 #define BASS_BFX_CHAN3 4 // see above info 57 #define BASS_BFX_CHAN4 8 // see above info 58 #define BASS_BFX_CHAN5 16 // see above info 59 #define BASS_BFX_CHAN6 32 // see above info 60 #define BASS_BFX_CHAN7 64 // see above info 61 #define BASS_BFX_CHAN8 128 // see above info 62 63 // if you have more than 8 channels (7.1), use this macro 64 #define BASS_BFX_CHANNEL_N(n) (1<<((n)-1)) 65 66 // DSP effects 67 enum { 68 BASS_FX_BFX_ROTATE = 0x10000, // A channels volume ping-pong / multi channel 69 BASS_FX_BFX_ECHO, // Echo / 2 channels max (deprecated) 70 BASS_FX_BFX_FLANGER, // Flanger / multi channel (deprecated) 71 BASS_FX_BFX_VOLUME, // Volume / multi channel 72 BASS_FX_BFX_PEAKEQ, // Peaking Equalizer / multi channel 73 BASS_FX_BFX_REVERB, // Reverb / 2 channels max (deprecated) 74 BASS_FX_BFX_LPF, // Low Pass Filter 24dB / multi channel (deprecated) 75 BASS_FX_BFX_MIX, // Swap, remap and mix channels / multi channel 76 BASS_FX_BFX_DAMP, // Dynamic Amplification / multi channel 77 BASS_FX_BFX_AUTOWAH, // Auto Wah / multi channel 78 BASS_FX_BFX_ECHO2, // Echo 2 / multi channel (deprecated) 79 BASS_FX_BFX_PHASER, // Phaser / multi channel 80 BASS_FX_BFX_ECHO3, // Echo 3 / multi channel (deprecated) 81 BASS_FX_BFX_CHORUS, // Chorus/Flanger / multi channel 82 BASS_FX_BFX_APF, // All Pass Filter / multi channel (deprecated) 83 BASS_FX_BFX_COMPRESSOR, // Compressor / multi channel (deprecated) 84 BASS_FX_BFX_DISTORTION, // Distortion / multi channel 85 BASS_FX_BFX_COMPRESSOR2, // Compressor 2 / multi channel 86 BASS_FX_BFX_VOLUME_ENV, // Volume envelope / multi channel 87 BASS_FX_BFX_BQF, // BiQuad filters / multi channel 88 BASS_FX_BFX_ECHO4, // Echo 4 / multi channel 89 BASS_FX_BFX_PITCHSHIFT, // Pitch shift using FFT / multi channel (not available on mobile) 90 BASS_FX_BFX_FREEVERB // Reverb using "Freeverb" algo / multi channel 91 }; 92 93 /* 94 Deprecated effects in 2.4.10 version: 95 ------------------------------------ 96 BASS_FX_BFX_ECHO -> use BASS_FX_BFX_ECHO4 97 BASS_FX_BFX_ECHO2 -> use BASS_FX_BFX_ECHO4 98 BASS_FX_BFX_ECHO3 -> use BASS_FX_BFX_ECHO4 99 BASS_FX_BFX_REVERB -> use BASS_FX_BFX_FREEVERB 100 BASS_FX_BFX_FLANGER -> use BASS_FX_BFX_CHORUS 101 BASS_FX_BFX_COMPRESSOR -> use BASS_FX_BFX_COMPRESSOR2 102 BASS_FX_BFX_APF -> use BASS_FX_BFX_BQF with BASS_BFX_BQF_ALLPASS filter 103 BASS_FX_BFX_LPF -> use 2x BASS_FX_BFX_BQF with BASS_BFX_BQF_LOWPASS filter and appropriate fQ values 104 */ 105 106 // Rotate 107 typedef struct { 108 float fRate; // rotation rate/speed in Hz (A negative rate can be used for reverse direction) 109 int lChannel; // BASS_BFX_CHANxxx flag/s (supported only even number of channels) 110 } BASS_BFX_ROTATE; 111 112 // Echo (deprecated) 113 typedef struct { 114 float fLevel; // [0....1....n] linear 115 int lDelay; // [1200..30000] 116 } BASS_BFX_ECHO; 117 118 // Flanger (deprecated) 119 typedef struct { 120 float fWetDry; // [0....1....n] linear 121 float fSpeed; // [0......0.09] 122 int lChannel; // BASS_BFX_CHANxxx flag/s 123 } BASS_BFX_FLANGER; 124 125 // Volume 126 typedef struct { 127 int lChannel; // BASS_BFX_CHANxxx flag/s or 0 for global volume control 128 float fVolume; // [0....1....n] linear 129 } BASS_BFX_VOLUME; 130 131 // Peaking Equalizer 132 typedef struct { 133 int lBand; // [0...............n] more bands means more memory & cpu usage 134 float fBandwidth; // [0.1...........<10] in octaves - fQ is not in use (Bandwidth has a priority over fQ) 135 float fQ; // [0...............1] the EE kinda definition (linear) (if Bandwidth is not in use) 136 float fCenter; // [1Hz..<info.freq/2] in Hz 137 float fGain; // [-15dB...0...+15dB] in dB (can be above/below these limits) 138 int lChannel; // BASS_BFX_CHANxxx flag/s 139 } BASS_BFX_PEAKEQ; 140 141 // Reverb (deprecated) 142 typedef struct { 143 float fLevel; // [0....1....n] linear 144 int lDelay; // [1200..10000] 145 } BASS_BFX_REVERB; 146 147 // Low Pass Filter (deprecated) 148 typedef struct { 149 float fResonance; // [0.01...........10] 150 float fCutOffFreq; // [1Hz...info.freq/2] cutoff frequency 151 int lChannel; // BASS_BFX_CHANxxx flag/s 152 } BASS_BFX_LPF; 153 154 // Swap, remap and mix 155 typedef struct { 156 const int *lChannel; // an array of channels to mix using BASS_BFX_CHANxxx flag/s (lChannel[0] is left channel...) 157 } BASS_BFX_MIX; 158 159 // Dynamic Amplification 160 typedef struct { 161 float fTarget; // target volume level [0<......1] linear 162 float fQuiet; // quiet volume level [0.......1] linear 163 float fRate; // amp adjustment rate [0.......1] linear 164 float fGain; // amplification level [0...1...n] linear 165 float fDelay; // delay in seconds before increasing level [0.......n] linear 166 int lChannel; // BASS_BFX_CHANxxx flag/s 167 } BASS_BFX_DAMP; 168 169 // Auto Wah 170 typedef struct { 171 float fDryMix; // dry (unaffected) signal mix [-2......2] 172 float fWetMix; // wet (affected) signal mix [-2......2] 173 float fFeedback; // output signal to feed back into input [-1......1] 174 float fRate; // rate of sweep in cycles per second [0<....<10] 175 float fRange; // sweep range in octaves [0<....<10] 176 float fFreq; // base frequency of sweep Hz [0<...1000] 177 int lChannel; // BASS_BFX_CHANxxx flag/s 178 } BASS_BFX_AUTOWAH; 179 180 // Echo 2 (deprecated) 181 typedef struct { 182 float fDryMix; // dry (unaffected) signal mix [-2......2] 183 float fWetMix; // wet (affected) signal mix [-2......2] 184 float fFeedback; // output signal to feed back into input [-1......1] 185 float fDelay; // delay sec [0<......n] 186 int lChannel; // BASS_BFX_CHANxxx flag/s 187 } BASS_BFX_ECHO2; 188 189 // Phaser 190 typedef struct { 191 float fDryMix; // dry (unaffected) signal mix [-2......2] 192 float fWetMix; // wet (affected) signal mix [-2......2] 193 float fFeedback; // output signal to feed back into input [-1......1] 194 float fRate; // rate of sweep in cycles per second [0<....<10] 195 float fRange; // sweep range in octaves [0<....<10] 196 float fFreq; // base frequency of sweep [0<...1000] 197 int lChannel; // BASS_BFX_CHANxxx flag/s 198 } BASS_BFX_PHASER; 199 200 // Echo 3 (deprecated) 201 typedef struct { 202 float fDryMix; // dry (unaffected) signal mix [-2......2] 203 float fWetMix; // wet (affected) signal mix [-2......2] 204 float fDelay; // delay sec [0<......n] 205 int lChannel; // BASS_BFX_CHANxxx flag/s 206 } BASS_BFX_ECHO3; 207 208 // Chorus/Flanger 209 typedef struct { 210 float fDryMix; // dry (unaffected) signal mix [-2......2] 211 float fWetMix; // wet (affected) signal mix [-2......2] 212 float fFeedback; // output signal to feed back into input [-1......1] 213 float fMinSweep; // minimal delay ms [0<...6000] 214 float fMaxSweep; // maximum delay ms [0<...6000] 215 float fRate; // rate ms/s [0<...1000] 216 int lChannel; // BASS_BFX_CHANxxx flag/s 217 } BASS_BFX_CHORUS; 218 219 // All Pass Filter (deprecated) 220 typedef struct { 221 float fGain; // reverberation time [-1=<..<=1] 222 float fDelay; // delay sec [0<....<=n] 223 int lChannel; // BASS_BFX_CHANxxx flag/s 224 } BASS_BFX_APF; 225 226 // Compressor (deprecated) 227 typedef struct { 228 float fThreshold; // compressor threshold [0<=...<=1] 229 float fAttacktime; // attack time ms [0<.<=1000] 230 float fReleasetime; // release time ms [0<.<=5000] 231 int lChannel; // BASS_BFX_CHANxxx flag/s 232 } BASS_BFX_COMPRESSOR; 233 234 // Distortion 235 typedef struct { 236 float fDrive; // distortion drive [0<=...<=5] 237 float fDryMix; // dry (unaffected) signal mix [-5<=..<=5] 238 float fWetMix; // wet (affected) signal mix [-5<=..<=5] 239 float fFeedback; // output signal to feed back into input [-1<=..<=1] 240 float fVolume; // distortion volume [0=<...<=2] 241 int lChannel; // BASS_BFX_CHANxxx flag/s 242 } BASS_BFX_DISTORTION; 243 244 // Compressor 2 245 typedef struct { 246 float fGain; // output gain of signal after compression [-60....60] in dB 247 float fThreshold; // point at which compression begins [-60.....0] in dB 248 float fRatio; // compression ratio [1.......n] 249 float fAttack; // attack time in ms [0.01.1000] 250 float fRelease; // release time in ms [0.01.5000] 251 int lChannel; // BASS_BFX_CHANxxx flag/s 252 } BASS_BFX_COMPRESSOR2; 253 254 // Volume envelope 255 typedef struct { 256 int lChannel; // BASS_BFX_CHANxxx flag/s 257 int lNodeCount; // number of nodes 258 const struct BASS_BFX_ENV_NODE *pNodes; // the nodes 259 BOOL bFollow; // follow source position 260 } BASS_BFX_VOLUME_ENV; 261 262 #pragma pack(push,4) 263 typedef struct BASS_BFX_ENV_NODE { 264 double pos; // node position in seconds (1st envelope node must be at position 0) 265 float val; // node value 266 } BASS_BFX_ENV_NODE; 267 #pragma pack(pop) 268 269 // BiQuad Filters 270 enum { 271 BASS_BFX_BQF_LOWPASS, 272 BASS_BFX_BQF_HIGHPASS, 273 BASS_BFX_BQF_BANDPASS, // constant 0 dB peak gain 274 BASS_BFX_BQF_BANDPASS_Q, // constant skirt gain, peak gain = Q 275 BASS_BFX_BQF_NOTCH, 276 BASS_BFX_BQF_ALLPASS, 277 BASS_BFX_BQF_PEAKINGEQ, 278 BASS_BFX_BQF_LOWSHELF, 279 BASS_BFX_BQF_HIGHSHELF 280 }; 281 282 typedef struct { 283 int lFilter; // BASS_BFX_BQF_xxx filter types 284 float fCenter; // [1Hz..<info.freq/2] Cutoff (central) frequency in Hz 285 float fGain; // [-15dB...0...+15dB] Used only for PEAKINGEQ and Shelving filters in dB (can be above/below these limits) 286 float fBandwidth; // [0.1...........<10] Bandwidth in octaves (fQ is not in use (fBandwidth has a priority over fQ)) 287 // (between -3 dB frequencies for BANDPASS and NOTCH or between midpoint 288 // (fGgain/2) gain frequencies for PEAKINGEQ) 289 float fQ; // [0.1.............1] The EE kinda definition (linear) (if fBandwidth is not in use) 290 float fS; // [0.1.............1] A "shelf slope" parameter (linear) (used only with Shelving filters) 291 // when fS = 1, the shelf slope is as steep as you can get it and remain monotonically 292 // increasing or decreasing gain with frequency. 293 int lChannel; // BASS_BFX_CHANxxx flag/s 294 } BASS_BFX_BQF; 295 296 // Echo 4 297 typedef struct { 298 float fDryMix; // dry (unaffected) signal mix [-2.......2] 299 float fWetMix; // wet (affected) signal mix [-2.......2] 300 float fFeedback; // output signal to feed back into input [-1.......1] 301 float fDelay; // delay sec [0<.......n] 302 BOOL bStereo; // echo adjoining channels to each other [TRUE/FALSE] 303 int lChannel; // BASS_BFX_CHANxxx flag/s 304 } BASS_BFX_ECHO4; 305 306 // Pitch shift (not available on mobile) 307 typedef struct { 308 float fPitchShift; // A factor value which is between 0.5 (one octave down) and 2 (one octave up) (1 won't change the pitch) [1 default] 309 // (fSemitones is not in use, fPitchShift has a priority over fSemitones) 310 float fSemitones; // Semitones (0 won't change the pitch) [0 default] 311 long lFFTsize; // Defines the FFT frame size used for the processing. Typical values are 1024, 2048 and 4096 [2048 default] 312 // It may be any value <= 8192 but it MUST be a power of 2 313 long lOsamp; // Is the STFT oversampling factor which also determines the overlap between adjacent STFT frames [8 default] 314 // It should at least be 4 for moderate scaling ratios. A value of 32 is recommended for best quality (better quality = higher CPU usage) 315 int lChannel; // BASS_BFX_CHANxxx flag/s 316 } BASS_BFX_PITCHSHIFT; 317 318 // Freeverb 319 #define BASS_BFX_FREEVERB_MODE_FREEZE 1 320 321 typedef struct { 322 float fDryMix; // dry (unaffected) signal mix [0........1], def. 0 323 float fWetMix; // wet (affected) signal mix [0........3], def. 1.0f 324 float fRoomSize; // room size [0........1], def. 0.5f 325 float fDamp; // damping [0........1], def. 0.5f 326 float fWidth; // stereo width [0........1], def. 1 327 DWORD lMode; // 0 or BASS_BFX_FREEVERB_MODE_FREEZE, def. 0 (no freeze) 328 int lChannel; // BASS_BFX_CHANxxx flag/s 329 } BASS_BFX_FREEVERB; 330 331 /*=========================================================================== 332 set dsp fx - BASS_ChannelSetFX 333 remove dsp fx - BASS_ChannelRemoveFX 334 set parameters - BASS_FXSetParameters 335 retrieve parameters - BASS_FXGetParameters 336 reset the state - BASS_FXReset 337 ===========================================================================*/ 338 339 /*=========================================================================== 340 Tempo, Pitch scaling and Sample rate changers 341 ===========================================================================*/ 342 343 // NOTE: Enable Tempo supported flags in BASS_FX_TempoCreate and the others to source handle. 344 345 // tempo attributes (BASS_ChannelSet/GetAttribute) 346 enum { 347 BASS_ATTRIB_TEMPO = 0x10000, 348 BASS_ATTRIB_TEMPO_PITCH, 349 BASS_ATTRIB_TEMPO_FREQ 350 }; 351 352 // tempo attributes options 353 enum { 354 BASS_ATTRIB_TEMPO_OPTION_USE_AA_FILTER = 0x10010, // TRUE (default) / FALSE (default for multi-channel on mobile devices for lower CPU usage) 355 BASS_ATTRIB_TEMPO_OPTION_AA_FILTER_LENGTH, // 32 default (8 .. 128 taps) 356 BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO, // TRUE (default on mobile devices for lower CPU usage) / FALSE (default) 357 BASS_ATTRIB_TEMPO_OPTION_SEQUENCE_MS, // 82 default, 0 = automatic 358 BASS_ATTRIB_TEMPO_OPTION_SEEKWINDOW_MS, // 28 default, 0 = automatic 359 BASS_ATTRIB_TEMPO_OPTION_OVERLAP_MS, // 8 default 360 BASS_ATTRIB_TEMPO_OPTION_PREVENT_CLICK // TRUE / FALSE (default) 361 }; 362 363 // tempo algorithm flags 364 #define BASS_FX_TEMPO_ALGO_LINEAR 0x200 365 #define BASS_FX_TEMPO_ALGO_CUBIC 0x400 // default 366 #define BASS_FX_TEMPO_ALGO_SHANNON 0x800 367 368 HSTREAM BASS_FXDEF(BASS_FX_TempoCreate)(DWORD chan, DWORD flags); 369 DWORD BASS_FXDEF(BASS_FX_TempoGetSource)(HSTREAM chan); 370 float BASS_FXDEF(BASS_FX_TempoGetRateRatio)(HSTREAM chan); 371 372 /*=========================================================================== 373 Reverse playback 374 ===========================================================================*/ 375 376 // NOTES: 1. MODs won't load without BASS_MUSIC_PRESCAN flag. 377 // 2. Enable Reverse supported flags in BASS_FX_ReverseCreate and the others to source handle. 378 379 // reverse attribute (BASS_ChannelSet/GetAttribute) 380 #define BASS_ATTRIB_REVERSE_DIR 0x11000 381 382 // playback directions 383 #define BASS_FX_RVS_REVERSE -1 384 #define BASS_FX_RVS_FORWARD 1 385 386 HSTREAM BASS_FXDEF(BASS_FX_ReverseCreate)(DWORD chan, float dec_block, DWORD flags); 387 DWORD BASS_FXDEF(BASS_FX_ReverseGetSource)(HSTREAM chan); 388 389 /*=========================================================================== 390 BPM (Beats Per Minute) 391 ===========================================================================*/ 392 393 // bpm flags 394 #define BASS_FX_BPM_BKGRND 1 // if in use, then you can do other processing while detection's in progress. Available only in Windows platforms (BPM/Beat) 395 #define BASS_FX_BPM_MULT2 2 // if in use, then will auto multiply bpm by 2 (if BPM < minBPM*2) 396 397 // translation options (deprecated) 398 enum { 399 BASS_FX_BPM_TRAN_X2, // multiply the original BPM value by 2 (may be called only once & will change the original BPM as well!) 400 BASS_FX_BPM_TRAN_2FREQ, // BPM value to Frequency 401 BASS_FX_BPM_TRAN_FREQ2, // Frequency to BPM value 402 BASS_FX_BPM_TRAN_2PERCENT, // BPM value to Percents 403 BASS_FX_BPM_TRAN_PERCENT2 // Percents to BPM value 404 }; 405 406 typedef void (CALLBACK BPMPROC)(DWORD chan, float bpm, void *user); 407 typedef void (CALLBACK BPMPROGRESSPROC)(DWORD chan, float percent, void *user); 408 typedef BPMPROGRESSPROC BPMPROCESSPROC; // back-compatibility 409 410 float BASS_FXDEF(BASS_FX_BPM_DecodeGet)(DWORD chan, double startSec, double endSec, DWORD minMaxBPM, DWORD flags, BPMPROGRESSPROC *proc, void *user); 411 BOOL BASS_FXDEF(BASS_FX_BPM_CallbackSet)(DWORD handle, BPMPROC *proc, double period, DWORD minMaxBPM, DWORD flags, void *user); 412 BOOL BASS_FXDEF(BASS_FX_BPM_CallbackReset)(DWORD handle); 413 float BASS_FXDEF(BASS_FX_BPM_Translate)(DWORD handle, float val2tran, DWORD trans); // deprecated 414 BOOL BASS_FXDEF(BASS_FX_BPM_Free)(DWORD handle); 415 416 /*=========================================================================== 417 Beat position trigger 418 ===========================================================================*/ 419 420 typedef void (CALLBACK BPMBEATPROC)(DWORD chan, double beatpos, void *user); 421 422 BOOL BASS_FXDEF(BASS_FX_BPM_BeatCallbackSet)(DWORD handle, BPMBEATPROC *proc, void *user); 423 BOOL BASS_FXDEF(BASS_FX_BPM_BeatCallbackReset)(DWORD handle); 424 BOOL BASS_FXDEF(BASS_FX_BPM_BeatDecodeGet)(DWORD chan, double startSec, double endSec, DWORD flags, BPMBEATPROC *proc, void *user); 425 BOOL BASS_FXDEF(BASS_FX_BPM_BeatSetParameters)(DWORD handle, float bandwidth, float centerfreq, float beat_rtime); 426 BOOL BASS_FXDEF(BASS_FX_BPM_BeatGetParameters)(DWORD handle, float *bandwidth, float *centerfreq, float *beat_rtime); 427 BOOL BASS_FXDEF(BASS_FX_BPM_BeatFree)(DWORD handle); 428 429 /*=========================================================================== 430 Macros 431 ===========================================================================*/ 432 433 // translate linear level to logarithmic dB 434 #define BASS_BFX_Linear2dB(level) (20*log10(level)) 435 436 // translate logarithmic dB level to linear 437 #define BASS_BFX_dB2Linear(dB) pow(10,(dB)/20) 438 439 #ifdef __cplusplus 440 } 441 #endif 442 443 #endif 444