![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Distotion_Unit.cpp@0:8e3468376286, 2011-05-07 (annotated)
- Committer:
- faker
- Date:
- Sat May 07 12:37:10 2011 +0000
- Revision:
- 0:8e3468376286
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
faker | 0:8e3468376286 | 1 | /*****************************************************/ |
faker | 0:8e3468376286 | 2 | /* Distotion_Unit.cpp */ |
faker | 0:8e3468376286 | 3 | /* */ |
faker | 0:8e3468376286 | 4 | /*****************************************************/ |
faker | 0:8e3468376286 | 5 | |
faker | 0:8e3468376286 | 6 | #define DIST_MAIN |
faker | 0:8e3468376286 | 7 | #include "Distotion_Unit.h" |
faker | 0:8e3468376286 | 8 | |
faker | 0:8e3468376286 | 9 | #define LIMIT_P (32767) |
faker | 0:8e3468376286 | 10 | #define LIMIT_N (-32768) |
faker | 0:8e3468376286 | 11 | |
faker | 0:8e3468376286 | 12 | int distotion(int iEffectIn) { |
faker | 0:8e3468376286 | 13 | |
faker | 0:8e3468376286 | 14 | int iSignal; |
faker | 0:8e3468376286 | 15 | |
faker | 0:8e3468376286 | 16 | // Input Gain |
faker | 0:8e3468376286 | 17 | iSignal = iEffectIn * g_inputGain; |
faker | 0:8e3468376286 | 18 | |
faker | 0:8e3468376286 | 19 | // Clip |
faker | 0:8e3468376286 | 20 | switch(g_distMode){ |
faker | 0:8e3468376286 | 21 | case 1: if (iSignal < 0)iSignal *= (-1); |
faker | 0:8e3468376286 | 22 | if (iSignal >= g_clipLevel)iSignal = g_clipLevel; |
faker | 0:8e3468376286 | 23 | break; |
faker | 0:8e3468376286 | 24 | case 2: if (iSignal >= g_clipLevel)iSignal = g_clipLevel; |
faker | 0:8e3468376286 | 25 | if (iSignal <= -g_clipLevel)iSignal = -g_clipLevel; |
faker | 0:8e3468376286 | 26 | break; |
faker | 0:8e3468376286 | 27 | case 3: if (iSignal >= g_clipLevel)iSignal = g_clipLevel; |
faker | 0:8e3468376286 | 28 | if (iSignal <= (-g_clipLevel / 2))iSignal = (-g_clipLevel / 2); |
faker | 0:8e3468376286 | 29 | break; |
faker | 0:8e3468376286 | 30 | default:break; |
faker | 0:8e3468376286 | 31 | } |
faker | 0:8e3468376286 | 32 | |
faker | 0:8e3468376286 | 33 | // Output Gain |
faker | 0:8e3468376286 | 34 | iSignal *= g_outputGain; |
faker | 0:8e3468376286 | 35 | if (iSignal >= LIMIT_P)iSignal = LIMIT_P; |
faker | 0:8e3468376286 | 36 | if (iSignal <= LIMIT_N)iSignal = LIMIT_N; |
faker | 0:8e3468376286 | 37 | |
faker | 0:8e3468376286 | 38 | return iSignal; |
faker | 0:8e3468376286 | 39 | |
faker | 0:8e3468376286 | 40 | } |
faker | 0:8e3468376286 | 41 | |
faker | 0:8e3468376286 | 42 | #undef DIST_MAIN |