+
+
+
+ATOM
+MyRegisterClass_wave( HINSTANCE hInstance )
+{
+ WNDCLASSEX wcex;
+
+ wcex.cbSize = sizeof( WNDCLASSEX );
+
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
+ wcex.lpfnWndProc = WndProc_wave;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = hInstance;
+ wcex.hIcon = 0;
+ wcex.hCursor = LoadCursor( NULL, IDC_ARROW );
+ wcex.hbrBackground = ( HBRUSH )GetStockObject( BLACK_BRUSH );
+ wcex.lpszMenuName = 0;
+ wcex.lpszClassName = TEXT( "sndrec32_wave" );
+ wcex.hIconSm = 0;
+
+
+ return RegisterClassEx( &wcex );
+}
+
+BOOL
+InitInstance_wave( HWND f, HINSTANCE hInstance, int nCmdShow )
+{
+ HWND hWnd;
+
+ hInst = hInstance;
+
+ hWnd = CreateWindow(
+ TEXT( "sndrec32_wave" ),
+ TEXT(""),
+ WS_DLGFRAME|WS_VISIBLE|WS_CHILD,
+ WAVEBAR_X,
+ WAVEBAR_Y,
+ WAVEBAR_CX,
+ WAVEBAR_CY,
+ f, ( HMENU ) 8,
+ hInstance, 0
+ );
+
+ if ( !hWnd )
+ {
+ return FALSE;
+ }
+
+ ShowWindow( hWnd, nCmdShow );
+ UpdateWindow( hWnd );
+
+ wave_win = hWnd;
+
+
+ return TRUE;
+}
+
+
+LRESULT CALLBACK
+WndProc_wave( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
+{
+ PAINTSTRUCT ps;
+ HDC hdc;
+ HPEN pen;
+
+
+
+ unsigned int max_h = ( cli.bottom / 2 );
+ unsigned int samples;
+ unsigned int x, line_h;
+
+
+
+ switch ( message )
+ {
+
+
+ case WM_CREATE:
+
+
+ GetClientRect( hWnd, &cli );
+
+ break;
+
+
+ case WM_PAINT:
+
+ //
+ // Initialize hdc objects
+ //
+
+ hdc = BeginPaint( hWnd, &ps );
+
+ pen = ( HPEN ) CreatePen( PS_SOLID, 1, WAVEBAR_COLOR );
+
+ SelectObject( hdc, ( HBRUSH )pen );
+
+ if ( AUD_OUT->current_status() == snd::WAVEOUT_PLAYING )
+ {
+
+ samples = AUD_OUT->tot_samples_buf();
+
+
+ for ( unsigned int i = 0; i < WAVEBAR_CX; ++i )
+ {
+
+ x = ( i * samples ) / WAVEBAR_CX;
+
+ line_h = ( abs(AUD_OUT->nsample( x )) * max_h ) / AUD_OUT->samplevalue_max();
+
+
+ if ( line_h )
+ {
+ MoveToEx( hdc, i, max_h, 0 );
+ LineTo( hdc, i, max_h - ( line_h * 2 ));
+ LineTo( hdc, i, max_h + ( line_h * 2 ));
+ } else
+ SetPixel( hdc, i, max_h, WAVEBAR_COLOR );
+
+ }
+
+
+ } else if ( AUD_IN->current_status() == snd::WAVEIN_RECORDING ) {
+
+
+ samples = AUD_IN->tot_samples_buf();
+
+
+ for ( unsigned int i = 0; i < WAVEBAR_CX; ++i )
+ {
+
+ x = ( i * samples ) / WAVEBAR_CX;
+
+ line_h = ( AUD_IN->nsample( x ) * max_h ) / AUD_IN->samplevalue_max();
+
+
+ if ( line_h )
+ {
+ MoveToEx( hdc, i, max_h, 0 );
+ LineTo( hdc, i, max_h - ( line_h * 2 ));
+ LineTo( hdc, i, max_h + ( line_h * 2 ));
+ } else
+ SetPixel( hdc, i, max_h, WAVEBAR_COLOR );
+
+ }
+
+
+ } else {
+
+ //
+ // In standby mode draw a simple line.
+ //
+
+ MoveToEx( hdc, 0, cli.bottom / 2, 0 );
+ LineTo( hdc, WAVEBAR_CX, cli.bottom / 2 );
+
+ }
+
+
+ DeleteObject( pen );
+
+ EndPaint( hWnd, &ps );
+
+ break;
+
+
+ case WM_USER:
+
+
+ break;
+
+
+ default:
+ return DefWindowProc( hWnd, message, wParam, lParam );
+
+
+ }
+
+
+ return 0;
+
+}
+
+
+
+LRESULT CALLBACK
+WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )