// Winamp test dsp library 0.9 for Winamp 2 // Copyright (C) 1997, Justin Frankel/Nullsoft // Feel free to base any plugins on this "framework"... #include #include #include #include #include "dsp.h" #include "resource.h" // avoid stupid CRT silliness BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) { return TRUE; } // pitch value //int g_pitch=100; // pitch control window //HWND pitch_control_hwnd; // auxilary pitch buffer (for resampling from) //short *pitch_buffer=NULL; //int pitch_buffer_len=0; //int quit_pitch=0; // module getter. winampDSPModule *getModule(int which); void config(struct winampDSPModule *this_mod); int init(struct winampDSPModule *this_mod); int initEnBand(struct winampDSPModule *this_mod); //int initChange(struct winampDSPModule *this_mod); //void initpitch(struct winampDSPModule *this_mod); void quit(struct winampDSPModule *this_mod); //void quitpitch(struct winampDSPModule *this_mod); int modify_samples1(struct winampDSPModule *this_mod, short int *samples, int numsamples, int bps, int nch, int srate); int modify_samples2(struct winampDSPModule *this_mod, short int *samples, int numsamples, int bps, int nch, int srate); int modify_samples3(struct winampDSPModule *this_mod, short int *samples, int numsamples, int bps, int nch, int srate); //static BOOL CALLBACK pitchProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam); // Module header, includes version, description, and address of the module retriever function winampDSPHeader hdr = { DSP_HDRVER, "Christofer's Broadcast Processor", getModule }; // second module winampDSPModule mod = { "3-band compressor", NULL, // hwndParent NULL, // hDllInstance config, init, modify_samples2, quit }; // first module winampDSPModule mod2 = { "1-band compressor", NULL, // hwndParent NULL, // hDllInstance config, initEnBand, modify_samples1, quit }; /*winampDSPModule mod3 = { "3-band compressor - change", NULL, // hwndParent NULL, // hDllInstance config, initChange, modify_samples2, quit }; */ #ifdef __cplusplus extern "C" { #endif // this is the only exported symbol. returns our main header. __declspec( dllexport ) winampDSPHeader *winampDSPGetHeader2() { return &hdr; } #ifdef __cplusplus } #endif // getmodule routine from the main header. Returns NULL if an invalid module was requested, // otherwise returns either mod1 or mod2 depending on 'which'. winampDSPModule *getModule(int which) { switch (which) { case 0: return &mod; case 1: return &mod2; //case 2: return &mod3; default:return NULL; } } // configuration. Passed this_mod, as a "this" parameter. Allows you to make one configuration // function that shares code for all your modules (you don't HAVE to use it though, you can make // config1(), config2(), etc...) void config(struct winampDSPModule *this_mod) { //ShowWindow((pitch_control_hwnd=CreateDialog(this_mod->hDllInstance,MAKEINTRESOURCE(IDD_DIALOG1),this_mod->hwndParent,pitchProc)),SW_SHOW); MessageBox(this_mod->hwndParent,"* * * Christofer's Broadcast Processor * * *\n" "\n" " * Current settings:\n" " High cutoff: 3,2kHz\n" " Low cutoff: 100Hz\n" " Attack time (look ahead): 180us\n", "About...",MB_OK); } double Attack; double Release; double AttackLP; double ReleaseLP; double AttackBP; double ReleaseBP; double AttackHP; double ReleaseHP; //double AttackAP; double ReleaseAP; double GainLP; double GainBP; double GainHP; double GainAP; double MaxAmp; double MultiplyLP = 1; double MultiplyBP = 1; double MultiplyHP = 1; double MultiplyAP = 1; double MaxDev; double Stereo; int s; double Multiply = 1; double AdderatB; //short int ThresholdAP; int init(struct winampDSPModule *this_mod) { Stereo = 0.1; GainLP = pow(10, -10.0 / 20.0) * 32767; // Threshold GainBP = pow(10, -10.5 / 20.0) * 32767; // Threshold GainHP = pow(10, -20.0 / 20.0) * 32767; // Threshold GainAP = pow(10, 5.0 / 20.0); MaxDev = pow(10, 3.0 / 20.0); /*MultiplyLP = (1 / GainLP); MultiplyBP = (1 / GainBP); MultiplyHP = (1 / GainHP); MultiplyAP = 1;*/ MaxAmp = pow(10, 15.0 / 20.0); //Attack = pow(0.25, 1 / (0.01 * 44100 * 2)); // Enbands //Release = pow(10, 1.0 / 1764000); // Enbands AttackLP = pow(0.25, 1 / (0.01 * 44100)); ReleaseLP = pow(10, 1.0 / 882000); AttackBP = pow(0.25, 1 / (0.01 * 44100)); ReleaseBP = pow(10, 10.0 / 882000); AttackHP = pow(0.25, 1 / (0.01 * 44100)); ReleaseHP = pow(10, 10.0 / 882000); //AttackAP = pow(0.25, 1 / (0.00005 * 44100 * 2)); ReleaseAP = pow(10, 2000.0 / 882000); //ThresholdAP = pow(10, (-0.5) / 20.0) * 32767; return 0; } int initEnBand(struct winampDSPModule *this_mod) { Attack = pow(0.25, 1 / (0.01 * 44100 * 2)); // Enbands Release = pow(10, 1.0 / 1764000); // Enbands return 0; } /*int initChange(struct winampDSPModule *this_mod) { GainBP = pow(10, -3.0 / 20.0); return 0; } void initpitch(struct winampDSPModule *this_mod) { pitch_buffer_len=0; pitch_buffer=NULL; quit_pitch=0; ShowWindow((pitch_control_hwnd=CreateDialog(this_mod->hDllInstance,MAKEINTRESOURCE(IDD_DIALOG1),this_mod->hwndParent,pitchProc)),SW_SHOW); } */ // cleanup (opposite of init()). Destroys the window, unregisters the window class void quit(struct winampDSPModule *this_mod) {/* if (pitch_control_hwnd) { DestroyWindow(pitch_control_hwnd); pitch_control_hwnd=0; }*/ } //void quitpitch(struct winampDSPModule *this_mod) //{ // if (this_mod == &mod3) // { // if (pitch_buffer) GlobalFree(pitch_buffer); // pitch_buffer_len=0; // pitch_buffer=NULL; // quit_pitch=1; // if (pitch_control_hwnd) // { // DestroyWindow(pitch_control_hwnd); // pitch_control_hwnd=0; // } // // } //} int modify_samples1(struct winampDSPModule *this_mod, short int *samples, int numsamples, int bps, int nch, int srate) { int x = numsamples*nch; if (bps == 16) { short *a = samples; if (nch == 2) while (x--) { AdderatB = (a[0] * Multiply); if ((AdderatB > 23264) || (AdderatB < -23264)) { // -3dB if (AdderatB > 0) Multiply = ((AdderatB - 23264) * Attack + 23264) / a[0]; if (AdderatB < 0) Multiply = ((AdderatB + 23264) * Attack - 23264) / a[0]; } if ((AdderatB < 23264) && (AdderatB > -23264) && (Multiply < 8)) Multiply *= Release; s = (a[0] * Multiply); if (s < -32767) s = -32767; if (s > 32767) s = 32767; a[0] = s; a+=1; } } return numsamples; } /*int modify_samples3(struct winampDSPModule *this_mod, short int *samples, int numsamples, int bps, int nch, int srate) { int pitch=g_pitch; int rlen =numsamples*bps/8*nch; int index=0, x; int n; int dindex; if (quit_pitch || g_pitch==100) return numsamples; if (g_pitch > 200) g_pitch=200; if (g_pitch < 50) g_pitch=50; pitch = 100000/pitch; n=(numsamples*pitch)/1000; dindex=(numsamples<<14)/n; if (pitch_buffer_len < rlen) { pitch_buffer_len = rlen; GlobalFree(pitch_buffer); pitch_buffer=GlobalAlloc(GMEM_FIXED,rlen); } if (bps == 16 && nch == 2) { short *buf=pitch_buffer; memcpy(buf,samples,rlen); for (x = 0; x < n; x ++) { int p=(index>>14)<<1; index+=dindex; samples[0] = buf[p]; samples[1] = buf[p+1]; samples+=2; } return n; } else if (bps == 16 && nch == 1) { short *buf=pitch_buffer; memcpy(buf,samples,rlen); for (x = 0; x < n; x ++) { int p=(index>>14); index+=dindex; *samples++ = buf[p]; } return n; } return numsamples; }*/ double yvl_lp[5], xvl_lp[5], yvr_lp[5], xvr_lp[5]; double yvl_bp[9], xvl_bp[9], yvr_bp[9], xvr_bp[9]; double yvl_hp[5], xvl_hp[5], yvr_hp[5], xvr_hp[5]; double LookAhead[16]; //double LookAheadP[10]; double Gain[16]; double Strongest; int modify_samples2(struct winampDSPModule *this_mod, short int *samples, int numsamples, int bps, int nch, int srate) { int x = numsamples; if (bps == 16) { short *a = samples; if (nch == 2) while (x--) { double l, r; // Stereobreddare r = a[1] - Stereo * a[0]; l = a[0] - Stereo * a[1]; // Filter xvr_lp[0] = xvr_lp[1]; xvr_lp[1] = xvr_lp[2]; xvr_lp[2] = xvr_lp[3]; xvr_lp[3] = xvr_lp[4]; xvr_lp[4] = r / 601779216.7; yvr_lp[0] = yvr_lp[1]; yvr_lp[1] = yvr_lp[2]; yvr_lp[2] = yvr_lp[3]; yvr_lp[3] = yvr_lp[4]; yvr_lp[4] = (xvr_lp[0] + xvr_lp[4]) + 4 * (xvr_lp[1] + xvr_lp[3]) + 6 * xvr_lp[2] + (-0.9670472415 * yvr_lp[0]) + (3.9005923504 * yvr_lp[1]) + (-5.9000375847 * yvr_lp[2]) + (3.9664924493 * yvr_lp[3]); // 90Hz xvl_lp[0] = xvl_lp[1]; xvl_lp[1] = xvl_lp[2]; xvl_lp[2] = xvl_lp[3]; xvl_lp[3] = xvl_lp[4]; xvl_lp[4] = l / 601779216.7; yvl_lp[0] = yvl_lp[1]; yvl_lp[1] = yvl_lp[2]; yvl_lp[2] = yvl_lp[3]; yvl_lp[3] = yvl_lp[4]; yvl_lp[4] = (xvl_lp[0] + xvl_lp[4]) + 4 * (xvl_lp[1] + xvl_lp[3]) + 6 * xvl_lp[2] + (-0.9670472415 * yvl_lp[0]) + (3.9005923504 * yvl_lp[1]) + (-5.9000375847 * yvl_lp[2]) + (3.9664924493 * yvl_lp[3]); // 90Hz xvr_bp[0] = xvr_bp[1]; xvr_bp[1] = xvr_bp[2]; xvr_bp[2] = xvr_bp[3]; xvr_bp[3] = xvr_bp[4]; xvr_bp[4] = xvr_bp[5]; xvr_bp[5] = xvr_bp[6]; xvr_bp[6] = xvr_bp[7]; xvr_bp[7] = xvr_bp[8]; xvr_bp[8] = r / 1024.607115; yvr_bp[0] = yvr_bp[1]; yvr_bp[1] = yvr_bp[2]; yvr_bp[2] = yvr_bp[3]; yvr_bp[3] = yvr_bp[4]; yvr_bp[4] = yvr_bp[5]; yvr_bp[5] = yvr_bp[6]; yvr_bp[6] = yvr_bp[7]; yvr_bp[7] = yvr_bp[8]; yvr_bp[8] = (xvr_bp[0] + xvr_bp[8]) - 4 * (xvr_bp[2] + xvr_bp [6]) + 6 * xvr_bp[4] + ( -0.3510340249 * yvr_bp[0]) + ( 3.1613912027 * yvr_bp[1]) // 110Hz - 2,9kHz + (-12.5026849110 * yvr_bp[2]) + ( 28.3597862200 * yvr_bp[3]) + (-40.3532139600 * yvr_bp[4]) + ( 36.8786058000 * yvr_bp[5]) + (-21.1343989150 * yvr_bp[6]) + ( 6.9415485867 * yvr_bp[7]); xvl_bp[0] = xvl_bp[1]; xvl_bp[1] = xvl_bp[2]; xvl_bp[2] = xvl_bp[3]; xvl_bp[3] = xvl_bp[4]; xvl_bp[4] = xvl_bp[5]; xvl_bp[5] = xvl_bp[6]; xvl_bp[6] = xvl_bp[7]; xvl_bp[7] = xvl_bp[8]; xvl_bp[8] = l / 1024.607115; yvl_bp[0] = yvl_bp[1]; yvl_bp[1] = yvl_bp[2]; yvl_bp[2] = yvl_bp[3]; yvl_bp[3] = yvl_bp[4]; yvl_bp[4] = yvl_bp[5]; yvl_bp[5] = yvl_bp[6]; yvl_bp[6] = yvl_bp[7]; yvl_bp[7] = yvl_bp[8]; yvl_bp[8] = (xvl_bp[0] + xvl_bp[8]) - 4 * (xvl_bp[2] + xvl_bp [6]) + 6 * xvl_bp[4] + ( -0.3510340249 * yvl_bp[0]) + ( 3.1613912027 * yvl_bp[1]) // 110Hz - 2,9kHz + (-12.5026849110 * yvl_bp[2]) + ( 28.3597862200 * yvl_bp[3]) + (-40.3532139600 * yvl_bp[4]) + ( 36.8786058000 * yvl_bp[5]) + (-21.1343989150 * yvl_bp[6]) + ( 6.9415485867 * yvl_bp[7]); xvr_hp[0] = xvr_hp[1]; xvr_hp[1] = xvr_hp[2]; xvr_hp[2] = xvr_hp[3]; xvr_hp[3] = xvr_hp[4]; xvr_hp[4] = r / 1.971870170; yvr_hp[0] = yvr_hp[1]; yvr_hp[1] = yvr_hp[2]; yvr_hp[2] = yvr_hp[3]; yvr_hp[3] = yvr_hp[4]; yvr_hp[4] = (xvr_hp[0] + xvr_hp[4]) - 4 * (xvr_hp[1] + xvr_hp[3]) + 6 * xvr_hp[2] + (-0.2571894065 * yvr_hp[0]) + (1.3717141806 * yvr_hp[1]) + (-2.8190571746 * yvr_hp[2]) + (2.6661637080 * yvr_hp[3]); // 3,6kHz xvl_hp[0] = xvl_hp[1]; xvl_hp[1] = xvl_hp[2]; xvl_hp[2] = xvl_hp[3]; xvl_hp[3] = xvl_hp[4]; xvl_hp[4] = l / 1.971870170; yvl_hp[0] = yvl_hp[1]; yvl_hp[1] = yvl_hp[2]; yvl_hp[2] = yvl_hp[3]; yvl_hp[3] = yvl_hp[4]; yvl_hp[4] = (xvl_hp[0] + xvl_hp[4]) - 4 * (xvl_hp[1] + xvl_hp[3]) + 6 * xvl_hp[2] + (-0.2571894065 * yvl_hp[0]) + (1.3717141806 * yvl_hp[1]) + (-2.8190571746 * yvl_hp[2]) + (2.6661637080 * yvl_hp[3]); // 3,6kHz // Kompressorer: Strongest = ((yvl_lp[4]<0?-yvl_lp[4]:yvl_lp[4])>(yvr_lp[4]<0?-yvr_lp[4]:yvr_lp[4])?yvl_lp[4]:yvr_lp[4]); AdderatB = (Strongest * MultiplyLP); if ((AdderatB > GainLP) || (AdderatB < -GainLP)) { if (AdderatB > 0) MultiplyLP = ((AdderatB - GainLP) * AttackLP + GainLP) / Strongest; if (AdderatB < 0) MultiplyLP = ((AdderatB + GainLP) * AttackLP - GainLP) / Strongest; } if ((AdderatB < GainLP) && (AdderatB > -GainLP) && (MultiplyLP < MaxAmp)) MultiplyLP *= ReleaseLP; l = (yvl_lp[4] * MultiplyLP); /*AdderatB = (yvr_lp[4] * MultiplyLP); if ((AdderatB > GainLP) || (AdderatB < -GainLP)) { if (AdderatB > 0) MultiplyLP = ((AdderatB - GainLP) * AttackLP + GainLP) / yvr_lp[4]; if (AdderatB < 0) MultiplyLP = ((AdderatB + GainLP) * AttackLP - GainLP) / yvr_lp[4]; } if ((AdderatB < GainLP) && (AdderatB > -GainLP) && (MultiplyLP < MaxAmp)) MultiplyLP *= ReleaseLP;*/ r = (yvr_lp[4] * MultiplyLP); Strongest = ((yvl_bp[8]<0?-yvl_bp[8]:yvl_bp[8])>(yvr_bp[8]<0?-yvr_bp[8]:yvr_bp[8])?yvl_bp[8]:yvr_bp[8]); AdderatB = (Strongest * MultiplyBP); if ((AdderatB > GainBP) || (AdderatB < -GainBP)) { if (AdderatB > 0) MultiplyBP = ((AdderatB - GainBP) * AttackBP + GainBP) / Strongest; if (AdderatB < 0) MultiplyBP = ((AdderatB + GainBP) * AttackBP - GainBP) / Strongest; } if ((AdderatB < GainBP) && (AdderatB > -GainBP) && (MultiplyBP < MaxAmp)) MultiplyBP *= ReleaseBP; l += (yvl_bp[8] * MultiplyBP); /*AdderatB = (yvr_bp[8] * MultiplyBP); if ((AdderatB > GainBP) || (AdderatB < -GainBP)) { if (AdderatB > 0) MultiplyBP = ((AdderatB - GainBP) * AttackBP + GainBP) / yvr_bp[8]; if (AdderatB < 0) MultiplyBP = ((AdderatB + GainBP) * AttackBP - GainBP) / yvr_bp[8]; } if ((AdderatB < GainBP) && (AdderatB > -GainBP) && (MultiplyBP < MaxAmp)) MultiplyBP *= ReleaseBP;*/ r += (yvr_bp[8] * MultiplyBP); Strongest = ((yvl_hp[4]<0?-yvl_hp[4]:yvl_hp[4])>(yvr_hp[4]<0?-yvr_hp[4]:yvr_hp[4])?yvl_hp[4]:yvr_hp[4]); AdderatB = (Strongest * MultiplyHP); if ((AdderatB > GainHP) || (AdderatB < -GainHP)) { if (AdderatB > 0) MultiplyHP = ((AdderatB - GainHP) * AttackHP + GainHP) / Strongest; if (AdderatB < 0) MultiplyHP = ((AdderatB + GainHP) * AttackHP - GainHP) / Strongest; } if ((AdderatB < GainHP) && (AdderatB > -GainHP) && (MultiplyHP < MaxAmp)) MultiplyHP *= ReleaseHP; if ((MultiplyHP * GainHP) > (MultiplyBP * GainBP * MaxDev)) MultiplyHP = ((MultiplyBP * GainBP * MaxDev) / GainHP); l += (yvl_hp[4] * MultiplyHP); /*AdderatB = (yvr_hp[4] * MultiplyHP); if ((AdderatB > GainHP) || (AdderatB < -GainHP)) { if (AdderatB > 0) MultiplyHP = ((AdderatB - GainHP) * AttackHP + GainHP) / yvr_hp[4]; if (AdderatB < 0) MultiplyHP = ((AdderatB + GainHP) * AttackHP - GainHP) / yvr_hp[4]; } if ((AdderatB < GainHP) && (AdderatB > -GainHP) && (MultiplyHP < MaxAmp)) MultiplyHP *= ReleaseHP; if ((MultiplyHP * GainHP) > (MultiplyBP * GainBP * MaxDev)) MultiplyHP = ((MultiplyBP * GainBP * MaxDev) / GainHP);*/ r += (yvr_hp[4] * MultiplyHP); // Slutlimiter /* AdderatB = (l * MultiplyAP); if ((AdderatB > ThresholdAP) || (AdderatB < -ThresholdAP)) { // -3dB if (AdderatB > 0) MultiplyAP = ((AdderatB - ThresholdAP) * AttackAP + ThresholdAP) / l; if (AdderatB < 0) MultiplyAP = ((AdderatB + ThresholdAP) * AttackAP - ThresholdAP) / l; } if ((AdderatB < ThresholdAP) && (AdderatB > -ThresholdAP) && (MultiplyAP < 1)) MultiplyAP *= ReleaseAP; l *= (MultiplyAP * GainAP); AdderatB = (r * MultiplyAP); if ((AdderatB > ThresholdAP) || (AdderatB < -ThresholdAP)) { // -3dB if (AdderatB > 0) MultiplyAP = ((AdderatB - ThresholdAP) * AttackAP + ThresholdAP) / r; if (AdderatB < 0) MultiplyAP = ((AdderatB + ThresholdAP) * AttackAP - ThresholdAP) / r; } if ((AdderatB < ThresholdAP) && (AdderatB > -ThresholdAP) && (MultiplyAP < 1)) MultiplyAP *= ReleaseAP; r *= (MultiplyAP * GainAP); */ LookAhead[0] = LookAhead[2]; // Vänster LookAhead[2] = LookAhead[4]; LookAhead[4] = LookAhead[6]; LookAhead[6] = LookAhead[8]; LookAhead[8] = LookAhead[10]; // Vänster LookAhead[10] = LookAhead[12]; LookAhead[12] = LookAhead[14]; LookAhead[1] = LookAhead[3]; // Höger LookAhead[3] = LookAhead[5]; LookAhead[5] = LookAhead[7]; LookAhead[7] = LookAhead[9]; LookAhead[9] = LookAhead[11]; LookAhead[11] = LookAhead[13]; LookAhead[13] = LookAhead[15]; LookAhead[14] = l * GainAP; LookAhead[15] = r * GainAP; /*if (LookAhead[0] < 0) LookAheadP[0] = -LookAhead[0]; else LookAheadP[0] = LookAhead[0]; if (LookAhead[1] < 0) LookAheadP[1] = -LookAhead[1]; else LookAheadP[1] = LookAhead[1]; if (LookAhead[2] < 0) LookAheadP[2] = -LookAhead[2]; else LookAheadP[2] = LookAhead[2]; if (LookAhead[3] < 0) LookAheadP[3] = -LookAhead[3]; else LookAheadP[3] = LookAhead[3]; if (LookAhead[4] < 0) LookAheadP[4] = -LookAhead[4]; else LookAheadP[4] = LookAhead[4]; if (LookAhead[5] < 0) LookAheadP[5] = -LookAhead[5]; else LookAheadP[5] = LookAhead[5]; if (LookAhead[6] < 0) LookAheadP[6] = -LookAhead[6]; else LookAheadP[6] = LookAhead[6]; if (LookAhead[7] < 0) LookAheadP[7] = -LookAhead[7]; else LookAheadP[7] = LookAhead[7]; if (LookAhead[8] < 0) LookAheadP[8] = -LookAhead[8]; else LookAheadP[8] = LookAhead[8]; if (LookAhead[9] < 0) LookAheadP[9] = -LookAhead[9]; else LookAheadP[9] = LookAhead[9]; */ Gain[0] = 32767 / (LookAhead[0]<0?-LookAhead[0]:LookAhead[0]); Gain[1] = 32767 / (LookAhead[1]<0?-LookAhead[1]:LookAhead[1]); Gain[2] = 1 - 0.875 * (1 - 32767 / (LookAhead[2]<0?-LookAhead[2]:LookAhead[2])); Gain[3] = 1 - 0.875 * (1 - 32767 / (LookAhead[3]<0?-LookAhead[3]:LookAhead[3])); Gain[4] = 1 - 0.75 * (1 - 32767 / (LookAhead[4]<0?-LookAhead[4]:LookAhead[4])); Gain[5] = 1 - 0.75 * (1 - 32767 / (LookAhead[5]<0?-LookAhead[5]:LookAhead[5])); Gain[6] = 1 - 0.625 * (1 - 32767 / (LookAhead[6]<0?-LookAhead[6]:LookAhead[6])); Gain[7] = 1 - 0.625 * (1 - 32767 / (LookAhead[7]<0?-LookAhead[7]:LookAhead[7])); Gain[8] = 1 - 0.5 * (1 - 32767 / (LookAhead[8]<0?-LookAhead[8]:LookAhead[8])); Gain[9] = 1 - 0.5 * (1 - 32767 / (LookAhead[9]<0?-LookAhead[9]:LookAhead[9])); Gain[10] = 1 - 0.375 * (1 - 32767 / (LookAhead[10]<0?-LookAhead[10]:LookAhead[10])); Gain[11] = 1 - 0.375 * (1 - 32767 / (LookAhead[11]<0?-LookAhead[11]:LookAhead[11])); Gain[12] = 1 - 0.25 * (1 - 32767 / (LookAhead[12]<0?-LookAhead[12]:LookAhead[12])); Gain[13] = 1 - 0.25 * (1 - 32767 / (LookAhead[13]<0?-LookAhead[13]:LookAhead[13])); Gain[14] = 1 - 0.125 * (1 - 32767 / (LookAhead[14]<0?-LookAhead[14]:LookAhead[14])); Gain[15] = 1 - 0.125 * (1 - 32767 / (LookAhead[15]<0?-LookAhead[15]:LookAhead[15])); if (MultiplyAP < 1) MultiplyAP *= ReleaseAP; if (Gain[0] < MultiplyAP) MultiplyAP = Gain[0]; if (Gain[1] < MultiplyAP) MultiplyAP = Gain[1]; if (Gain[2] < MultiplyAP) MultiplyAP = Gain[2]; if (Gain[3] < MultiplyAP) MultiplyAP = Gain[3]; if (Gain[4] < MultiplyAP) MultiplyAP = Gain[4]; if (Gain[5] < MultiplyAP) MultiplyAP = Gain[5]; if (Gain[6] < MultiplyAP) MultiplyAP = Gain[6]; if (Gain[7] < MultiplyAP) MultiplyAP = Gain[7]; if (Gain[8] < MultiplyAP) MultiplyAP = Gain[8]; if (Gain[9] < MultiplyAP) MultiplyAP = Gain[9]; if (Gain[10] < MultiplyAP) MultiplyAP = Gain[10]; if (Gain[11] < MultiplyAP) MultiplyAP = Gain[11]; if (Gain[12] < MultiplyAP) MultiplyAP = Gain[12]; if (Gain[13] < MultiplyAP) MultiplyAP = Gain[13]; if (Gain[14] < MultiplyAP) MultiplyAP = Gain[14]; if (Gain[15] < MultiplyAP) MultiplyAP = Gain[15]; l = LookAhead[0] * MultiplyAP; r = LookAhead[1] * MultiplyAP; /*if (l < -32768) l = -32768; if (l > 32767) l = 32767; if (r < -32768) r = -32768; if (r > 32767) r = 32767;*/ a[0] = (l>32767?32767:l<-32767?-32767:l); a[1] = (r>32767?32767:r<-32767?-32767:r); a+=2; } } return numsamples; } /* static BOOL CALLBACK pitchProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam) { if (uMsg == WM_INITDIALOG) { SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_SETRANGEMAX,0,0); SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_SETRANGEMIN,0,-10); SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_SETPOS,1,1); SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_SETPOS,1,0); SendDlgItemMessage(hwndDlg,IDC_SLIDER2,TBM_SETRANGEMAX,0,20); SendDlgItemMessage(hwndDlg,IDC_SLIDER2,TBM_SETRANGEMIN,0,0); SendDlgItemMessage(hwndDlg,IDC_SLIDER2,TBM_SETPOS,1,1); SendDlgItemMessage(hwndDlg,IDC_SLIDER2,TBM_SETPOS,1,10); SendDlgItemMessage(hwndDlg,IDC_SLIDER3,TBM_SETRANGEMAX,0,0); SendDlgItemMessage(hwndDlg,IDC_SLIDER3,TBM_SETRANGEMIN,0,-10); SendDlgItemMessage(hwndDlg,IDC_SLIDER3,TBM_SETPOS,1,1); SendDlgItemMessage(hwndDlg,IDC_SLIDER3,TBM_SETPOS,1,0); { char str[123]; //wsprintf(str,"%s%d%%",g_pitch>100?"+":"",g_pitch-100); SetDlgItemText(hwndDlg,IDC_BOOGA,"10 ms"); } } if (uMsg == WM_VSCROLL) { HWND swnd = (HWND) lParam; if (swnd == GetDlgItem(hwndDlg,IDC_SLIDER1)) { //g_pitch = -SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_GETPOS,0,0)+100; //AttackLP = pow(0.25, 1 / (SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_GETPOS,0,0) / 1000 * 44100 * 2)); GainLP = pow(10, SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_GETPOS,0,0) / 20.0); { char str[123]; //wsprintf(str,"%s%d%%",g_pitch>100?"+":"",g_pitch-100); SetDlgItemText(hwndDlg,IDC_BOOGA,"Ändrad"); } } if (swnd == GetDlgItem(hwndDlg,IDC_SLIDER3)) { //g_pitch = -SendDlgItemMessage(hwndDlg,IDC_SLIDER1,TBM_GETPOS,0,0)+100; { char str[123]; //wsprintf(str,"%s%d%%",g_pitch>100?"+":"",g_pitch-100); SetDlgItemText(hwndDlg,IDC_BOOGA,"Ändrad"); } } } return 0; } */