void CFilterMoog::Init(struct MOOGFILTERCREATESTRUCT& m) { //frequency first then resonance //resonance depends on frequency but not vice versa UpdateFrequency(m); UpdateResonance(m); }
void KeyDown(WPARAM wParam, LPARAM lParam) { int value; switch(wParam) { // Right, increase frequency case VK_RIGHT: if (++scale.v > FREQ_MAX) scale.v = FREQ_MAX; break; // Left, decrease frequency case VK_LEFT: if (--scale.v < FREQ_MIN) scale.v = FREQ_MIN; break; default: return; } UpdateFrequency(); }
void CAESound::UpdateParameters(int16_t a2) { if (GetLifespanTiedToPhysicalEntity()) { if (m_physicalEntity) { SetPosition(m_physicalEntity->GetPos()); } else { m_playingState = 1; } } if (GetRequestUpdates()) { if (m_baseAudio) { (**(void (__stdcall ***)(_DWORD, _DWORD))m_baseAudio)(pThis, a2); UpdateFrequency(); } } }
void CFilterMoog::setCutoffFrequencyHighpass(float cFrequency) { m_HP.cFrequency = cFrequency; UpdateFrequency(m_HP); }
void CFilterMoog::setCutoffFrequencyLowpass(float cFrequency) { m_LP.cFrequency = cFrequency; UpdateFrequency(m_LP); }
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CREATE: // Get the window and client dimensions GetClientRect(hWnd, &window.rect); int width = window.rect.right - window.rect.left; int height = window.rect.bottom - window.rect.top; // Create status bar status.hwnd = CreateWindow(STATUSCLASSNAME, " Turn knob to adjust measurement frequency", WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, hWnd, (HMENU)STATUS_ID, hInst, NULL); // Create tooltip tooltip.hwnd = CreateWindow(TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hWnd, NULL, hInst, NULL); SetWindowPos(tooltip.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); tooltip.info.cbSize = sizeof(tooltip.info); tooltip.info.hwnd = hWnd; tooltip.info.uFlags = TTF_IDISHWND | TTF_SUBCLASS; // Create scale scale.hwnd = CreateWindow(WC_STATIC, NULL, WS_VISIBLE | WS_CHILD | SS_NOTIFY | SS_OWNERDRAW, 8, 8, 160, 40, hWnd, (HMENU)SCALE_ID, hInst, NULL); // Add scale to tooltip tooltip.info.uId = (UINT_PTR)scale.hwnd; tooltip.info.lpszText = "Frequency scale"; SendMessage(tooltip.hwnd, TTM_ADDTOOL, 0, (LPARAM) &tooltip.info); // Create knob knob.hwnd = CreateWindow(KNOBCLASS, NULL, WS_VISIBLE | WS_CHILD, 4, 52, 168, 168, hWnd, (HMENU)KNOB_ID, hInst, NULL); // Add knob to tooltip tooltip.info.uId = (UINT_PTR)knob.hwnd; tooltip.info.lpszText = "Frequency adjustment knob"; SendMessage(tooltip.hwnd, TTM_ADDTOOL, 0, (LPARAM) &tooltip.info); // Create display display.hwnd = CreateWindow(WC_STATIC, NULL, WS_VISIBLE | WS_CHILD | SS_NOTIFY | SS_OWNERDRAW, 176, 8, width - 184, 50, hWnd, (HMENU)DISPLAY_ID, hInst, NULL); // Add display to tooltip tooltip.info.uId = (UINT_PTR)display.hwnd; tooltip.info.lpszText = "Frequency and level display"; SendMessage(tooltip.hwnd, TTM_ADDTOOL, 0, (LPARAM) &tooltip.info); // Create meter meter.hwnd = CreateWindow(WC_STATIC, NULL, WS_VISIBLE | WS_CHILD | SS_NOTIFY | SS_OWNERDRAW, 176, 66, width - 184, 50, hWnd, (HMENU)METER_ID, hInst, NULL); // Add meter to tooltip tooltip.info.uId = (UINT_PTR)meter.hwnd; tooltip.info.lpszText = "Level meter"; SendMessage(tooltip.hwnd, TTM_ADDTOOL, 0, (LPARAM) &tooltip.info); // Create meter slider meter.slider.hwnd = CreateWindow(TRACKBAR_CLASS, NULL, WS_VISIBLE | WS_CHILD | TBS_HORZ | TBS_NOTICKS | TBS_TOP, 178, 92, width - 188, 20, hWnd, (HMENU)SLIDER_ID, hInst, NULL); SendMessage(meter.slider.hwnd, TBM_SETRANGE, TRUE, MAKELONG(MIN_METER, MAX_METER)); SendMessage(meter.slider.hwnd, TBM_SETPOS, TRUE, MIN_METER); // Add slider to tooltip tooltip.info.uId = (UINT_PTR)meter.slider.hwnd; tooltip.info.lpszText = "Level meter"; SendMessage(tooltip.hwnd, TTM_ADDTOOL, 0, (LPARAM) &tooltip.info); // Create spectrum spectrum.hwnd = CreateWindow(WC_STATIC, NULL, WS_VISIBLE | WS_CHILD | SS_NOTIFY | SS_OWNERDRAW, 176, 122, width - 184, 50, hWnd, (HMENU)SPECTRUM_ID, hInst, NULL); // Add spectrum to tooltip tooltip.info.uId = (UINT_PTR)spectrum.hwnd; tooltip.info.lpszText = "Frequency spectrum"; SendMessage(tooltip.hwnd, TTM_ADDTOOL, 0, (LPARAM) &tooltip.info); // Create quit button quit.hwnd = CreateWindow(WC_BUTTON, "Quit", WS_VISIBLE | WS_CHILD, width - 80, 194, 72, 24, hWnd, (HMENU)QUIT_ID, hInst, NULL); // Start audio thread audio.thread = CreateThread(NULL, 0, AudioThread, hWnd, 0, &audio.id); // Start meter timer CreateTimerQueueTimer(&meter.timer, NULL, (WAITORTIMERCALLBACK)MeterCallback, &meter, METER_DELAY, METER_DELAY, WT_EXECUTEDEFAULT); // Update frequency UpdateFrequency(); break; // Colour static text case WM_CTLCOLORSTATIC: return (LRESULT)GetSysColorBrush(COLOR_WINDOW); break; // Draw item case WM_DRAWITEM: return DrawItem(wParam, lParam); break; // Disable menus by capturing this message case WM_INITMENU: break; // Capture system character key to stop pop up menus and other // nonsense case WM_SYSCHAR: break; // Char pressed case WM_CHAR: CharPressed(wParam, lParam); break; // Key pressed case WM_KEYDOWN: KeyDown(wParam, lParam); break; // Buttons case WM_COMMAND: switch (LOWORD(wParam)) { // Quit case QUIT_ID: waveInStop(audio.hwi); waveInClose(audio.hwi); PostQuitMessage(0); break; } break; // Notify case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { // Tooltip case TTN_SHOW: TooltipShow(wParam, lParam); break; case TTN_POP: TooltipPop(wParam, lParam); break; } break; // Process other messages. case WM_DESTROY: waveInStop(audio.hwi); waveInClose(audio.hwi); PostQuitMessage(0); break; // Everything else default: return DefWindowProc(hWnd, uMsg, wParam, lParam); } return 0; }
void MouseMove(HWND hwnd, WPARAM wParam, LPARAM lParam) { static float last; static BOOL move; // Get points POINTS points = MAKEPOINTS(lParam); // Button down if (wParam & MK_LBUTTON) { RECT rect; // Get bounds GetClientRect(hwnd, &rect); int w2 = rect.right / 2; int h2 = rect.bottom / 2; // Calculate position relative to centre int x = points.x - w2; int y = points.y - h2; // Calculate angle float theta = atan2(x, -y); // First point if (!move) move = TRUE; // More points else { // Difference float delta = theta - last; // Allow for crossing origin if (delta > M_PI) delta -= 2.0 * M_PI; if (delta < -M_PI) delta += 2.0 * M_PI; // Calculate scale value scale.v += round(delta * 100.0 / M_PI); // Enforce limits if (scale.v < FREQ_MIN) scale.v = FREQ_MIN; if (scale.v > FREQ_MAX) scale.v = FREQ_MAX; // Update frequency UpdateFrequency(); } // Remember angle last = theta; } // Button not down else if (move) move = FALSE; }