ReactOS  0.4.12-dev-14-gd0c8636
sndrec32.cpp File Reference
#include "stdafx.h"
#include <commctrl.h>
#include <commdlg.h>
#include <winnls.h>
#include "sndrec32.h"
#include "shellapi.h"
Include dependency graph for sndrec32.cpp:

Go to the source code of this file.

Macros

#define gprintf   _snprintf
 

Functions

ATOM MyRegisterClass (HINSTANCE hInstance)
 
ATOM MyRegisterClass_wave (HINSTANCE hInstance)
 
BOOL InitInstance (HINSTANCE, int)
 
BOOL InitInstance_wave (HWND, HINSTANCE, int)
 
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM)
 
LRESULT CALLBACK WndProc_wave (HWND, UINT, WPARAM, LPARAM)
 
INT_PTR CALLBACK AboutDlgProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
 
int APIENTRY _tWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
 
void l_play_finished (void)
 
void l_audio_arrival (unsigned int samples_arrival)
 
void l_buffer_resized (unsigned int new_size)
 
VOID enable_but (DWORD id)
 
VOID disable_but (DWORD id)
 
BOOL open_wav (TCHAR *f)
 
BOOL write_wav (TCHAR *f)
 

Variables

HINSTANCE hInst
 
TCHAR szTitle [MAX_LOADSTRING]
 
TCHAR szWindowClass [MAX_LOADSTRING]
 
BOOL win_first
 
BOOL wout_first
 
HWND main_win
 
HWND wave_win
 
HWND slider
 
HWND buttons [5]
 
HBITMAP butbmps [5]
 
HBITMAP butbmps_dis [5]
 
WNDPROC buttons_std_proc
 
BOOL butdisabled [5]
 
BOOL stopped_flag
 
BOOL isnew
 
BOOL display_dur
 
DWORD slider_pos
 
WORD slider_min
 
WORD slider_max
 
DWORD samples_max
 
OPENFILENAME ofn
 
TCHAR file_path [MAX_PATH]
 
TCHAR str_pos [MAX_LOADSTRING]
 
TCHAR str_dur [MAX_LOADSTRING]
 
TCHAR str_buf [MAX_LOADSTRING]
 
TCHAR str_fmt [MAX_LOADSTRING]
 
TCHAR str_chan [MAX_LOADSTRING]
 
TCHAR str_mono [10]
 
TCHAR str_stereo [10]
 
BOOL path_set
 
snd::audio_membuffer * AUD_BUF
 
snd::audio_waveout * AUD_OUT
 
snd::audio_wavein * AUD_IN
 
BOOL s_recording
 
NONCLIENTMETRICS s_info
 
RECT text_rect
 
RECT text2_rect
 
RECT cli
 

Macro Definition Documentation

◆ gprintf

#define gprintf   _snprintf

Definition at line 19 of file sndrec32.cpp.

Referenced by WndProc().

Function Documentation

◆ _tWinMain()

int APIENTRY _tWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPTSTR  lpCmdLine,
int  nCmdShow 
)

Definition at line 107 of file sndrec32.cpp.

111 {
112  UNREFERENCED_PARAMETER(hPrevInstance);
113  UNREFERENCED_PARAMETER(lpCmdLine);
114 
115  MSG msg;
116  HACCEL hAccelTable;
117 
118  s_info.cbSize = sizeof( NONCLIENTMETRICS );
119 
121 
122  switch (GetUserDefaultUILanguage())
123  {
126  break;
127 
128  default:
129  break;
130  }
131 
133 
138 
143 
144  /* Retrieving default system font, and others system informations */
145  SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
146  sizeof(NONCLIENTMETRICS),
147  &s_info,
148  0);
149 
150  /* Set font size */
151  s_info.lfMenuFont.lfHeight = 14;
152 
153  /* Inits buttons bitmaps */
154 
160 
166 
167  /* Inits audio devices and buffers */
168 
169  snd::audio_membuffer AUD_buffer(snd::A44100_16BIT_STEREO);
170  snd::audio_waveout AUD_waveout(snd::A44100_16BIT_STEREO, AUD_buffer);
171  snd::audio_wavein AUD_wavein(snd::A44100_16BIT_STEREO, AUD_buffer);
172 
173  AUD_buffer.play_finished = l_play_finished;
174  AUD_buffer.audio_arrival = l_audio_arrival;
175  AUD_buffer.buffer_resized = l_buffer_resized;
176 
177  AUD_buffer.alloc_seconds(INITIAL_BUFREC_SECONDS);
178 
179  AUD_IN = &AUD_wavein;
180  AUD_OUT = &AUD_waveout;
181  AUD_BUF = &AUD_buffer;
182 
183  /* Inits slider default parameters */
184 
185  slider_pos = 0;
186  slider_min = 0;
188 
190  path_set = FALSE;
191  isnew = TRUE;
192  display_dur = TRUE;
193 
194  samples_max = AUD_buffer.total_samples();
195 
196  s_recording = false;
197 
198  /* Inits strings */
206  LoadString(hInstance, IDS_STRMONO, str_mono, 10);
207  LoadString(hInstance, IDS_STRSTEREO, str_stereo, 10);
208 
209  /* Registers sndrec32 window class */
210  MyRegisterClass(hInstance);
211  MyRegisterClass_wave(hInstance);
212 
213  if (!InitInstance(hInstance, nCmdShow))
214  {
215  MessageBox(0, TEXT("CreateWindow() Error!"), TEXT("ERROR"), MB_ICONERROR);
216  return FALSE;
217  }
218 
219  /* Loads key accelerators */
220  hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_REACTOS_SNDREC32));
221 
222  /* Starts main loop */
223  while (GetMessage(&msg, NULL, 0, 0))
224  {
225  if (!TranslateAccelerator(main_win, hAccelTable, &msg))
226  {
227  TranslateMessage(&msg);
228  DispatchMessage(&msg);
229  }
230  }
231 
232  if (wout_first)
233  {
234  AUD_waveout.close();
235  }
236 
237  if (win_first)
238  {
239  AUD_wavein.close();
240  }
241 
242  AUD_buffer.clear();
243 
244  return (int)msg.wParam;
245 }
#define IDS_STRBUF
Definition: resource.h:34
BOOL wout_first
Definition: sndrec32.cpp:35
void l_play_finished(void)
Definition: sndrec32.cpp:912
#define TranslateAccelerator
Definition: winuser.h:5726
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IDB_BITMAP2_PLAY_DIS
Definition: resource.h:28
#define DispatchMessage
Definition: winuser.h:5631
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: lang.c:561
BOOL WINAPI TranslateMessage(_In_ const MSG *)
DWORD samples_max
Definition: sndrec32.cpp:54
HBITMAP butbmps_dis[5]
Definition: sndrec32.cpp:42
#define TRUE
Definition: types.h:120
TCHAR str_stereo[10]
Definition: sndrec32.cpp:65
#define REFRESHA_Y
Definition: sndrec32.h:67
#define LAYOUT_RTL
Definition: wingdi.h:1352
TCHAR szTitle[MAX_LOADSTRING]
Definition: sndrec32.cpp:25
audio_format A44100_16BIT_STEREO(44100, 16, 2)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define IDB_BITMAP2_STOP
Definition: resource.h:22
#define MAX_LOADSTRING
Definition: fontview.h:3
#define IDB_BITMAP2_END_DIS
Definition: resource.h:27
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define SystemParametersInfo
Definition: winuser.h:5724
LONG top
Definition: windef.h:297
snd::audio_waveout * AUD_OUT
Definition: sndrec32.cpp:70
BOOL display_dur
Definition: sndrec32.cpp:48
#define IDB_BITMAP2_STOP_DIS
Definition: resource.h:4
#define IDC_REACTOS_SNDREC32
Definition: resource.h:14
LONG left
Definition: windef.h:296
WORD slider_min
Definition: sndrec32.cpp:51
LONG right
Definition: windef.h:298
#define LANG_HEBREW
Definition: nls.h:67
ATOM MyRegisterClass(HINSTANCE hInstance)
Definition: sndrec32.cpp:248
TCHAR str_dur[MAX_LOADSTRING]
Definition: sndrec32.cpp:59
#define IDS_STRDUR
Definition: resource.h:33
BOOL stopped_flag
Definition: sndrec32.cpp:46
#define LoadAccelerators
Definition: winuser.h:5676
void l_audio_arrival(unsigned int samples_arrival)
Definition: sndrec32.cpp:924
BOOL InitInstance(HINSTANCE, int)
Definition: sndrec32.cpp:270
#define REFRESHB_X
Definition: sndrec32.h:71
#define IDS_STRMONO
Definition: resource.h:36
smooth NULL
Definition: ftsmooth.c:416
TCHAR str_fmt[MAX_LOADSTRING]
Definition: sndrec32.cpp:61
#define REFRESHB_Y
Definition: sndrec32.h:72
snd::audio_membuffer * AUD_BUF
Definition: sndrec32.cpp:69
TCHAR str_pos[MAX_LOADSTRING]
Definition: sndrec32.cpp:58
BOOL win_first
Definition: sndrec32.cpp:35
#define IDS_STRFMT
Definition: resource.h:35
#define IDB_BITMAP2_START
Definition: resource.h:19
#define IDS_STRCHAN
Definition: resource.h:39
TCHAR str_mono[10]
Definition: sndrec32.cpp:64
TCHAR szWindowClass[MAX_LOADSTRING]
Definition: sndrec32.cpp:26
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1686
NONCLIENTMETRICS s_info
Definition: sndrec32.cpp:75
#define LoadBitmap
Definition: winuser.h:5677
snd::audio_wavein * AUD_IN
Definition: sndrec32.cpp:71
#define REFRESHB_CX
Definition: sndrec32.h:73
#define REFRESHA_CY
Definition: sndrec32.h:69
#define INITIAL_BUFREC_SECONDS
Definition: sndrec32.h:20
RECT text2_rect
Definition: sndrec32.cpp:78
WORD slider_max
Definition: sndrec32.cpp:52
#define MB_ICONERROR
Definition: winuser.h:781
#define REFRESHB_CY
Definition: sndrec32.h:74
#define MessageBox
Definition: winuser.h:5688
#define IDB_BITMAP2_END
Definition: resource.h:20
DWORD slider_pos
Definition: sndrec32.cpp:50
void l_buffer_resized(unsigned int new_size)
Definition: sndrec32.cpp:929
#define REFRESHA_CX
Definition: sndrec32.h:68
#define REFRESHA_X
Definition: sndrec32.h:66
#define TEXT(s)
Definition: k32.h:26
#define IDB_BITMAP2_REC_DIS
Definition: resource.h:29
BOOL s_recording
Definition: sndrec32.cpp:73
#define IDS_STRPOS
Definition: resource.h:32
HBITMAP butbmps[5]
Definition: sndrec32.cpp:41
#define IDS_APP_TITLE
Definition: resource.h:10
#define GetMessage
Definition: winuser.h:5656
#define IDS_STRSTEREO
Definition: resource.h:37
BOOL isnew
Definition: sndrec32.cpp:47
#define msg(x)
Definition: auth_time.c:54
RECT text_rect
Definition: sndrec32.cpp:77
#define MAKELANGID(p, s)
Definition: nls.h:15
LONG bottom
Definition: windef.h:299
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
#define SLIDER_W
Definition: sndrec32.h:39
#define IDB_BITMAP2_START_DIS
Definition: resource.h:30
#define IDB_BITMAP2_REC
Definition: resource.h:23
BOOL path_set
Definition: sndrec32.cpp:67
ATOM MyRegisterClass_wave(HINSTANCE hInstance)
Definition: sndrec32.cpp:301
TCHAR str_chan[MAX_LOADSTRING]
Definition: sndrec32.cpp:62
#define LoadString
Definition: winuser.h:5685
HWND main_win
Definition: sndrec32.cpp:37
TCHAR str_buf[MAX_LOADSTRING]
Definition: sndrec32.cpp:60
#define IDB_BITMAP2_PLAY
Definition: resource.h:21

◆ AboutDlgProc()

INT_PTR CALLBACK AboutDlgProc ( HWND  hWnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
)

Definition at line 83 of file sndrec32.cpp.

Referenced by WndProc().

87 {
88  switch (msg)
89  {
90  case WM_COMMAND:
91  switch (LOWORD(wp))
92  {
93  case IDOK:
94  EndDialog(hWnd, 0);
95  return TRUE;
96  }
97  break;
98  case WM_CLOSE:
99  EndDialog(hWnd, 0);
100  return TRUE;
101  }
102  return FALSE;
103 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
UINT msg
Definition: msvc.h:92
#define WM_CLOSE
Definition: winuser.h:1603
#define WM_COMMAND
Definition: winuser.h:1716
#define LOWORD(l)
Definition: pedump.c:82

◆ disable_but()

VOID disable_but ( DWORD  id)

Definition at line 939 of file sndrec32.cpp.

Referenced by WndProc().

940 {
941  butdisabled[id] = TRUE;
943 }
HBITMAP butbmps_dis[5]
Definition: sndrec32.cpp:42
#define TRUE
Definition: types.h:120
#define BM_SETIMAGE
Definition: winuser.h:1883
UINT_PTR WPARAM
Definition: windef.h:207
LONG_PTR LPARAM
Definition: windef.h:208
BOOL butdisabled[5]
Definition: sndrec32.cpp:45
HWND buttons[5]
Definition: sndrec32.cpp:40
#define IMAGE_BITMAP
Definition: winuser.h:211
#define SendMessage
Definition: winuser.h:5709
GLenum GLuint id
Definition: glext.h:5579

◆ enable_but()

VOID enable_but ( DWORD  id)

Definition at line 933 of file sndrec32.cpp.

Referenced by l_play_finished(), open_wav(), and WndProc().

934 {
935  butdisabled[id] = FALSE;
937 }
#define BM_SETIMAGE
Definition: winuser.h:1883
UINT_PTR WPARAM
Definition: windef.h:207
LONG_PTR LPARAM
Definition: windef.h:208
BOOL butdisabled[5]
Definition: sndrec32.cpp:45
HWND buttons[5]
Definition: sndrec32.cpp:40
HBITMAP butbmps[5]
Definition: sndrec32.cpp:41
#define IMAGE_BITMAP
Definition: winuser.h:211
#define SendMessage
Definition: winuser.h:5709
GLenum GLuint id
Definition: glext.h:5579

◆ InitInstance()

BOOL InitInstance ( HINSTANCE  hInstance,
int  nCmdShow 
)

Definition at line 270 of file sndrec32.cpp.

Referenced by _tWinMain().

271 {
272  HWND hWnd;
273 
274  hInst = hInstance;
275 
277  szTitle,
281  MAINWINDOW_W,
282  MAINWINDOW_H,
283  NULL,
284  NULL,
285  hInstance,
286  NULL);
287  if (!hWnd)
288  {
289  return FALSE;
290  }
291 
292  ShowWindow(hWnd, nCmdShow);
293  UpdateWindow(hWnd);
294 
295  main_win = hWnd;
296 
297  return TRUE;
298 }
#define TRUE
Definition: types.h:120
#define CreateWindow
Definition: winuser.h:5620
TCHAR szTitle[MAX_LOADSTRING]
Definition: sndrec32.cpp:25
BOOL WINAPI UpdateWindow(_In_ HWND)
HWND hWnd
Definition: settings.c:17
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HINSTANCE hInstance
Definition: charmap.c:20
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
TCHAR szWindowClass[MAX_LOADSTRING]
Definition: sndrec32.cpp:26
#define WS_CAPTION
Definition: pedump.c:624
#define WS_OVERLAPPED
Definition: pedump.c:615
#define WS_MINIMIZEBOX
Definition: pedump.c:631
HINSTANCE hInst
Definition: sndrec32.cpp:24
#define MAINWINDOW_W
Definition: sndrec32.h:15
#define MAINWINDOW_H
Definition: sndrec32.h:16
#define WS_SYSMENU
Definition: pedump.c:629
HWND main_win
Definition: sndrec32.cpp:37

◆ InitInstance_wave()

BOOL InitInstance_wave ( HWND  f,
HINSTANCE  hInstance,
int  nCmdShow 
)

Definition at line 323 of file sndrec32.cpp.

Referenced by WndProc().

326 {
327  HWND hWnd;
328 
329  hInst = hInstance;
330 
332  TEXT("sndrec32_wave"),
333  TEXT(""),
335  WAVEBAR_X,
336  WAVEBAR_Y,
337  WAVEBAR_CX,
338  WAVEBAR_CY,
339  f,
340  (HMENU)8,
341  hInstance,
342  0);
343 
344  if (!hWnd )
345  {
346  return FALSE;
347  }
348 
349  ShowWindow(hWnd, nCmdShow);
350  UpdateWindow(hWnd);
351 
352  wave_win = hWnd;
353 
354  return TRUE;
355 }
#define TRUE
Definition: types.h:120
HWND wave_win
Definition: sndrec32.cpp:38
BOOL WINAPI UpdateWindow(_In_ HWND)
HWND hWnd
Definition: settings.c:17
#define WS_CHILD
Definition: pedump.c:617
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HINSTANCE hInstance
Definition: charmap.c:20
#define CreateWindowEx
Definition: winuser.h:5621
#define WAVEBAR_CY
Definition: sndrec32.h:59
#define TEXT(s)
Definition: k32.h:26
HINSTANCE hInst
Definition: sndrec32.cpp:24
#define WAVEBAR_X
Definition: sndrec32.h:56
#define WAVEBAR_Y
Definition: sndrec32.h:57
#define WAVEBAR_CX
Definition: sndrec32.h:58
#define WS_VISIBLE
Definition: pedump.c:620
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define WS_EX_STATICEDGE
Definition: winuser.h:403

◆ l_audio_arrival()

void l_audio_arrival ( unsigned int  samples_arrival)

Definition at line 924 of file sndrec32.cpp.

Referenced by _tWinMain().

925 {
926  slider_pos += (DWORD)((slider_max * samples_arrival) / samples_max);
927 }
DWORD samples_max
Definition: sndrec32.cpp:54
#define DWORD
Definition: msvc.h:34
WORD slider_max
Definition: sndrec32.cpp:52
DWORD slider_pos
Definition: sndrec32.cpp:50

◆ l_buffer_resized()

void l_buffer_resized ( unsigned int  new_size)

Definition at line 929 of file sndrec32.cpp.

Referenced by _tWinMain().

930 {
931 }

◆ l_play_finished()

void l_play_finished ( void  )

Definition at line 912 of file sndrec32.cpp.

Referenced by _tWinMain().

913 {
914  stopped_flag = true;
915 
920 
922 }
#define TRUE
Definition: types.h:120
HWND wave_win
Definition: sndrec32.cpp:38
#define BUTSTART_ID
Definition: sndrec32.h:22
BOOL stopped_flag
Definition: sndrec32.cpp:46
VOID enable_but(DWORD id)
Definition: sndrec32.cpp:933
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define BUTREC_ID
Definition: sndrec32.h:26
#define BUTEND_ID
Definition: sndrec32.h:23
#define BUTPLAY_ID
Definition: sndrec32.h:24

◆ MyRegisterClass()

ATOM MyRegisterClass ( HINSTANCE  hInstance)

Definition at line 248 of file sndrec32.cpp.

Referenced by _tWinMain().

249 {
250  WNDCLASSEX wcex;
251 
252  wcex.cbSize = sizeof(WNDCLASSEX);
253 
254  wcex.style = CS_HREDRAW | CS_VREDRAW;
255  wcex.lpfnWndProc = WndProc;
256  wcex.cbClsExtra = 0;
257  wcex.cbWndExtra = 0;
258  wcex.hInstance = hInstance;
259  wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SNDREC32));
260  wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
265 
266  return RegisterClassEx(&wcex);
267 }
UINT style
Definition: winuser.h:3155
#define MAKEINTRESOURCE
Definition: winuser.h:591
LPCSTR lpszMenuName
Definition: winuser.h:3163
#define RegisterClassEx
Definition: winuser.h:5703
HCURSOR hCursor
Definition: winuser.h:3161
WNDPROC lpfnWndProc
Definition: winuser.h:3156
LPCSTR lpszClassName
Definition: winuser.h:3164
#define IDR_MENU1
Definition: resource.h:6
#define CS_HREDRAW
Definition: winuser.h:648
#define IDI_SNDREC32
Definition: resource.h:12
HICON hIconSm
Definition: winuser.h:3165
HINSTANCE hInstance
Definition: charmap.c:20
HINSTANCE hInstance
Definition: winuser.h:3159
smooth NULL
Definition: ftsmooth.c:416
UINT cbSize
Definition: winuser.h:3154
HBRUSH hbrBackground
Definition: winuser.h:3162
TCHAR szWindowClass[MAX_LOADSTRING]
Definition: sndrec32.cpp:26
#define CS_VREDRAW
Definition: winuser.h:653
int cbWndExtra
Definition: winuser.h:3158
HICON hIcon
Definition: winuser.h:3160
#define COLOR_BTNFACE
Definition: winuser.h:918
#define LoadCursor
Definition: winuser.h:5678
int cbClsExtra
Definition: winuser.h:3157
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM)
Definition: sndrec32.cpp:446
#define IDC_ARROW
Definition: winuser.h:682
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5585
#define LoadIcon
Definition: winuser.h:5679
HBRUSH WINAPI GetSysColorBrush(_In_ int)

◆ MyRegisterClass_wave()

ATOM MyRegisterClass_wave ( HINSTANCE  hInstance)

Definition at line 301 of file sndrec32.cpp.

Referenced by _tWinMain().

302 {
303  WNDCLASSEX wcex;
304 
305  wcex.cbSize = sizeof(WNDCLASSEX);
306 
307  wcex.style = CS_HREDRAW | CS_VREDRAW;
308  wcex.lpfnWndProc = WndProc_wave;
309  wcex.cbClsExtra = 0;
310  wcex.cbWndExtra = 0;
311  wcex.hInstance = hInstance;
312  wcex.hIcon = 0;
313  wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
314  wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
315  wcex.lpszMenuName = 0;
316  wcex.lpszClassName = TEXT("sndrec32_wave");
317  wcex.hIconSm = 0;
318 
319  return RegisterClassEx(&wcex);
320 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
UINT style
Definition: winuser.h:3155
LPCSTR lpszMenuName
Definition: winuser.h:3163
#define RegisterClassEx
Definition: winuser.h:5703
LRESULT CALLBACK WndProc_wave(HWND, UINT, WPARAM, LPARAM)
Definition: sndrec32.cpp:359
HCURSOR hCursor
Definition: winuser.h:3161
WNDPROC lpfnWndProc
Definition: winuser.h:3156
LPCSTR lpszClassName
Definition: winuser.h:3164
#define CS_HREDRAW
Definition: winuser.h:648
HICON hIconSm
Definition: winuser.h:3165
HINSTANCE hInstance
Definition: charmap.c:20
HINSTANCE hInstance
Definition: winuser.h:3159
smooth NULL
Definition: ftsmooth.c:416
UINT cbSize
Definition: winuser.h:3154
HBRUSH hbrBackground
Definition: winuser.h:3162
#define BLACK_BRUSH
Definition: wingdi.h:894
#define CS_VREDRAW
Definition: winuser.h:653
int cbWndExtra
Definition: winuser.h:3158
HICON hIcon
Definition: winuser.h:3160
#define LoadCursor
Definition: winuser.h:5678
int cbClsExtra
Definition: winuser.h:3157
#define TEXT(s)
Definition: k32.h:26
#define IDC_ARROW
Definition: winuser.h:682
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5585

◆ open_wav()

BOOL open_wav ( TCHAR f)

Definition at line 945 of file sndrec32.cpp.

Referenced by WndProc().

946 {
947  HANDLE file;
948 
949  riff_hdr r;
950  wave_hdr w;
951  data_chunk d;
952 
953  BOOL b;
954 
955  DWORD bytes_recorded_in_wav = 0;
956  DWORD is_read = 0;
957 
958  file = CreateFile(f,
959  GENERIC_READ,
960  0,
961  0,
964  0);
965  if (!file)
966  {
968  TEXT("Cannot open file. CreateFile() error."),
969  TEXT("ERROR"),
970  MB_OK | MB_ICONERROR);
971 
972  return FALSE;
973  }
974 
975  b = ReadFile(file, (LPVOID)&r, sizeof(r), &is_read, 0);
976  if (!b)
977  {
979  TEXT("Cannot read RIFF header."),
980  TEXT("ERROR"),
981  MB_OK | MB_ICONERROR);
982 
983  CloseHandle(file);
984  return FALSE;
985  }
986 
987  b = ReadFile(file, (LPVOID)&w, sizeof(w), &is_read, 0);
988  if (!b)
989  {
991  TEXT("Cannot read WAVE header."),
992  TEXT("ERROR"),
993  MB_OK | MB_ICONERROR);
994 
995  CloseHandle(file);
996  return FALSE;
997  }
998 
999  b = ReadFile(file, (LPVOID)&d, sizeof(d), &is_read, 0);
1000  if (!b)
1001  {
1003  TEXT("Cannot read WAVE subchunk."),
1004  TEXT("ERROR"),
1005  MB_OK | MB_ICONERROR);
1006 
1007  CloseHandle(file);
1008  return FALSE;
1009  }
1010 
1011  bytes_recorded_in_wav = r.chunksize - 36;
1012  if (bytes_recorded_in_wav == 0)
1013  {
1015  TEXT("Cannot read file. No audio data."),
1016  TEXT("ERROR"),
1017  MB_OK | MB_ICONERROR);
1018 
1019  CloseHandle(file);
1020  return FALSE;
1021  }
1022 
1023  snd::audio_format openfmt(w.SampleRate, w.BitsPerSample, w.NumChannels);
1024 
1025  AUD_BUF->clear();
1026  AUD_BUF->alloc_bytes(bytes_recorded_in_wav);
1027 
1028  b = ReadFile(file,
1029  (LPVOID)AUD_BUF->audio_buffer(),
1030  bytes_recorded_in_wav,
1031  &is_read,
1032  0);
1033 
1034  AUD_BUF->set_b_received(bytes_recorded_in_wav);
1035 
1036  if ((!b) || (is_read != bytes_recorded_in_wav))
1037  {
1039  TEXT("Cannot read file. Error reading audio data."),
1040  TEXT("ERROR"),
1041  MB_OK | MB_ICONERROR);
1042 
1043  CloseHandle(file);
1044 
1045  AUD_BUF->reset();
1046  return FALSE;
1047  }
1048 
1049  CloseHandle(file);
1050 
1056 
1057  samples_max = AUD_BUF->samples_received();
1058 
1059  isnew = FALSE;
1060 
1061  return TRUE;
1062 }
DWORD samples_max
Definition: sndrec32.cpp:54
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define BUTSTART_ID
Definition: sndrec32.h:22
snd::audio_membuffer * AUD_BUF
Definition: sndrec32.cpp:69
#define OPEN_EXISTING
Definition: compat.h:426
#define b
Definition: ke_i.h:79
GLfloat f
Definition: glext.h:7540
VOID enable_but(DWORD id)
Definition: sndrec32.cpp:933
unsigned int BOOL
Definition: ntddk_ex.h:94
#define d
Definition: ke_i.h:81
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define MB_ICONERROR
Definition: winuser.h:781
#define MessageBox
Definition: winuser.h:5688
#define GENERIC_READ
Definition: compat.h:124
#define BUTREC_ID
Definition: sndrec32.h:26
#define TEXT(s)
Definition: k32.h:26
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
#define MB_OK
Definition: winuser.h:784
BOOL isnew
Definition: sndrec32.cpp:47
#define BUTSTOP_ID
Definition: sndrec32.h:25
#define BUTEND_ID
Definition: sndrec32.h:23
#define BUTPLAY_ID
Definition: sndrec32.h:24
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
HWND main_win
Definition: sndrec32.cpp:37

◆ WndProc()

LRESULT CALLBACK WndProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 446 of file sndrec32.cpp.

Referenced by MyRegisterClass().

450 {
451  int wmId;
452  TCHAR str_tmp[MAX_LOADSTRING];
453  PAINTSTRUCT ps;
454  HDC hdc;
455  HFONT font;
456  HFONT oldfont;
457  long long slid_samp = 0;
458 
459  /* Checking for global pointers to buffer and io audio devices */
460  if ((!AUD_IN) || (!AUD_OUT) || (!AUD_BUF))
461  {
462  MessageBox(0, TEXT("Buffer Error"), 0, 0);
463  return 1;
464  }
465 
466  switch (message)
467  {
468  case WM_CREATE:
469  /* Creating the wave bar */
471  {
472  MessageBox(0, TEXT("CreateWindow() Error!"), TEXT("ERROR"), MB_ICONERROR);
473  return FALSE;
474  }
475 
476  /* Creating ALL the buttons */
477  for (int i = 0; i < 5; ++i)
478  {
479  buttons[i] = CreateWindow(TEXT("button"),
480  TEXT(""),
482  BUTTONS_CX + (i * (BUTTONS_W + ((i == 0) ? 0 : BUTTONS_SPACE))),
483  BUTTONS_CY,
484  BUTTONS_W,
485  BUTTONS_H,
486  hWnd,
487  (HMENU)UlongToPtr(i),
488  hInst,
489  0);
490  if (!buttons[i])
491  {
492  MessageBox(0, 0, TEXT("CreateWindow() Error!"), 0);
493  return FALSE;
494  }
495 
496  /* Realize the button bmp image */
498  UpdateWindow(buttons[i]);
499  disable_but(i);
500  }
501 
502  /* Creating the SLIDER window */
504  TEXT(""),
506  SLIDER_CX,
507  SLIDER_CY,
508  SLIDER_W,
509  SLIDER_H,
510  hWnd,
511  (HMENU)SLIDER_ID,
512  hInst,
513  0);
514  if (!slider)
515  {
516  MessageBox(0, 0, TEXT( "CreateWindow() Error!" ), 0);
517  return FALSE;
518  }
519 
520  /* Sets slider limits */
522  TBM_SETRANGE,
523  (WPARAM)TRUE,
525 
529  break;
530 
531  /* Implements slider logic */
532  case WM_HSCROLL:
533  {
534  switch (LOWORD(wParam))
535  {
536  case SB_ENDSCROLL:
537  break;
538  case SB_PAGERIGHT:
539  case SB_PAGELEFT:
540  case TB_THUMBTRACK:
541  /* If the user touch the slider bar, set the
542  audio start position properly */
544  slid_samp = (__int64)slider_pos * (__int64)samples_max;
545  AUD_BUF->set_position(AUD_BUF->audinfo().bytes_in_samples((unsigned int)(slid_samp / (__int64)slider_max)));
546  InvalidateRect(hWnd, &text_rect, TRUE);
547  break;
548  }
549  break;
550  }
551 
552  case WM_COMMAND:
553  wmId = LOWORD(wParam);
554  if ((wmId >= 0) && (wmId < 5) && (butdisabled[wmId] != FALSE))
555  break;
556 
557  switch (wmId)
558  {
559  case ID_FILE_NEW:
560  if (!isnew)
561  {
562  if (AUD_IN->current_status() == snd::WAVEIN_RECORDING)
563  AUD_IN->stop_recording();
564 
565  if ((AUD_OUT->current_status() == snd::WAVEOUT_PLAYING) ||
566  (AUD_OUT->current_status() == snd::WAVEOUT_PAUSED))
567  AUD_OUT->stop();
568 
569  AUD_BUF->reset();
570 
576 
577  samples_max = AUD_BUF->total_samples();
578  slider_pos = 0;
579 
581 
584 
585  isnew = TRUE;
586  display_dur = TRUE;
587 
588  ZeroMemory(file_path, MAX_PATH * sizeof(TCHAR));
589 
591 
592  InvalidateRect(hWnd, &text_rect, TRUE);
593  InvalidateRect(hWnd, &text2_rect, TRUE);
594  }
595  break;
596 
597  case ID_FILE_OPEN:
598  ZeroMemory(&ofn, sizeof(ofn));
599 
600  ofn.lStructSize = sizeof(ofn);
601  ofn.hwndOwner = hWnd;
602  ofn.lpstrFilter = TEXT("Audio Files (*.wav)\0*.wav\0All Files (*.*)\0*.*\0");
606  ofn.lpstrDefExt = TEXT("wav");
607 
608  if (GetOpenFileName(&ofn))
609  {
613 
614  EnableWindow(slider, TRUE);
615  }
616 
617  InvalidateRect(hWnd, &text_rect, TRUE);
618  InvalidateRect(hWnd, &text2_rect, TRUE);
619  break;
620 
621  case ID_ABOUT:
623  return TRUE;
624  break;
625 
626  case ID_FILE_SAVEAS:
627  ZeroMemory(&ofn, sizeof(ofn));
628 
629  ofn.lStructSize = sizeof(ofn);
630  ofn.hwndOwner = hWnd ;
632  ofn.lpstrFilter = TEXT("Audio Files (*.wav)\0*.wav\0All Files (*.*)\0*.*\0");
635 
636  ofn.lpstrDefExt = TEXT("wav");
637 
638  if (GetSaveFileName (&ofn))
639  {
642  }
643  break;
644 
645 
646  case ID_EDIT_AUDIOPROPS:
647  ShellExecute(NULL, NULL, _T("rundll32.exe"), _T("shell32.dll,Control_RunDLL mmsys.cpl,ShowAudioPropertySheet"), NULL, SW_SHOWNORMAL);
648  break;
649 
650  case ID_FILE_EXIT:
651  DestroyWindow(hWnd);
652  break;
653 
654  /* Sndrec32 buttons routines */
655  case BUTSTART_ID:
656  AUD_BUF->set_position_start();
657  slider_pos = 0;
659  break;
660 
661  case BUTEND_ID:
662  DestroyWindow(hWnd);
663  break;
664 
665  case BUTPLAY_ID:
666  if (wout_first == false)
667  {
668  AUD_OUT->open();
669  wout_first = true;
670  }
671 
672  AUD_OUT->play();
673 
678 
679  SetTimer(hWnd, 1, 250, 0);
681 
682  break;
683 
684  case BUTSTOP_ID:
685  if (s_recording)
686  {
687  s_recording = FALSE;
688 
689  AUD_IN->stop_recording();
690 
691  /* Resetting slider position */
692  slider_pos = 0;
694 
695  samples_max = AUD_BUF->samples_received();
696 
698 
703 
705  EnableWindow(slider, TRUE);
706 
707  display_dur = FALSE;
708 
709  AUD_BUF->truncate();
710 
711  InvalidateRect(hWnd, &text_rect, TRUE);
712  InvalidateRect(wave_win, 0, TRUE);
713 
714  }
715  else
716  {
717  AUD_OUT->pause();
718 
723 
724  }
725 
726  KillTimer(hWnd, 1);
727  KillTimer(hWnd, WAVEBAR_TIMERID);
728 
729  InvalidateRect(hWnd, &text_rect, TRUE);
730 
731  break;
732 
733  case BUTREC_ID:
734  if (win_first == false)
735  {
736  AUD_IN->open();
737  win_first = true;
738  }
739 
740  s_recording = TRUE;
741 
742  samples_max = AUD_BUF->total_samples();
743 
744  AUD_IN->start_recording();
745 
747 
752 
753  isnew = FALSE;
754 
756 
757  SetTimer(hWnd, 1, 150, 0);
759 
760  break;
761 
762  default:
763  return DefWindowProc(hWnd, message, wParam, lParam);
764  }
765  break;
766 
767  case WM_TIMER:
768  switch (wParam)
769  {
770  case 1:
771  if (stopped_flag)
772  {
773  KillTimer(hWnd, 1);
774  KillTimer(hWnd, WAVEBAR_TIMERID);
775  slider_pos = 0;
778  }
779 
781  InvalidateRect(hWnd, &text_rect, TRUE);
782  break;
783 
784  case WAVEBAR_TIMERID:
785  InvalidateRect(wave_win, 0, TRUE);
786  SendMessage(wave_win, WM_USER, 0, 0);
787  break;
788  }
789  break;
790 
791  case WM_PAINT:
792  hdc = BeginPaint(hWnd, &ps);
793  font = CreateFontIndirect(&s_info.lfMenuFont);
794  oldfont = (HFONT) SelectObject(hdc, font);
795  SetBkMode(hdc, TRANSPARENT);
796 
797  if (AUD_IN->current_status() == snd::WAVEIN_RECORDING)
798  {
799  gprintf(str_tmp,
801  str_pos,
802  (float)((float)AUD_BUF->bytes_recorded() / (float)AUD_BUF->audinfo().byte_rate()));
803 
804  }
805  else if (AUD_OUT->current_status() == snd::WAVEOUT_PLAYING)
806  {
807  gprintf(str_tmp,
809  str_pos,
810  (float)((float)AUD_BUF->bytes_played() / (float)AUD_BUF->audinfo().byte_rate()));
811  }
812  else
813  {
814  gprintf(str_tmp,
816  str_pos,
817  (float)((((float)slider_pos * (float)samples_max) / (float)slider_max) / (float)AUD_BUF->audinfo().sample_rate()));
818  }
819 
820  ExtTextOut(hdc,
821  STRPOS_X,
822  STRPOS_Y,
823  ETO_OPAQUE,
824  0,
825  str_tmp,
826  _tcslen(str_tmp),
827  0);
828 
829  if (display_dur)
830  {
831  gprintf(str_tmp,
833  str_dur,
834  AUD_BUF->fseconds_total());
835  }
836  else
837  {
838  gprintf(str_tmp,
840  str_dur,
841  AUD_BUF->fseconds_recorded());
842  }
843 
844  ExtTextOut(hdc,
845  STRDUR_X,
846  STRDUR_Y,
847  ETO_OPAQUE,
848  0,
849  str_tmp,
850  _tcslen(str_tmp),
851  0);
852 
853  gprintf(str_tmp,
855  str_buf,
856  (float)((float)AUD_BUF->mem_size() / 1024.0f));
857 
858  ExtTextOut(hdc,
859  STRBUF_X,
860  STRBUF_Y,
861  ETO_OPAQUE,
862  0,
863  str_tmp,
864  _tcslen(str_tmp),
865  0);
866 
867  gprintf(str_tmp,
869  str_fmt,
870  (float)((float)AUD_BUF->audinfo().sample_rate() / 1000.0f),
871  AUD_BUF->audinfo().bits(),
872  AUD_BUF->audinfo().channels() == 2 ? str_mono : str_stereo);
873 
874  ExtTextOut(hdc,
875  STRFMT_X,
876  STRFMT_Y,
877  ETO_OPAQUE,
878  0,
879  str_tmp,
880  _tcslen(str_tmp),
881  0);
882 
883  gprintf(str_tmp,
885  str_chan,
886  AUD_BUF->audinfo().channels() == 2 ? str_stereo : str_mono);
887 
888  ExtTextOut(hdc,
889  STRCHAN_X,
890  STRCHAN_Y,
891  ETO_OPAQUE,
892  0,
893  str_tmp,
894  _tcslen(str_tmp),
895  0);
896 
897  SelectObject(hdc, oldfont);
898  DeleteObject(font);
899  EndPaint(hWnd, &ps);
900  break;
901 
902  case WM_DESTROY:
903  PostQuitMessage(0);
904  break;
905  default:
906  return DefWindowProc(hWnd, message, wParam, lParam);
907  }
908 
909  return 0;
910 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
BOOL wout_first
Definition: sndrec32.cpp:35
#define OFN_EXPLORER
Definition: commdlg.h:104
#define TB_THUMBTRACK
Definition: commctrl.h:2048
#define HDC
Definition: msvc.h:22
BOOL open_wav(TCHAR *f)
Definition: sndrec32.cpp:945
#define MAKEINTRESOURCE
Definition: winuser.h:591
Definition: tftpd.h:59
DWORD samples_max
Definition: sndrec32.cpp:54
#define TRUE
Definition: types.h:120
TCHAR str_stereo[10]
Definition: sndrec32.cpp:65
#define STRCHAN_X
Definition: sndrec32.h:53
#define TBS_ENABLESELRANGE
Definition: commctrl.h:1994
#define CreateWindow
Definition: winuser.h:5620
INT_PTR CALLBACK AboutDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: sndrec32.cpp:83
HWND hwndOwner
Definition: commdlg.h:330
Definition: mk_font.cpp:20
#define MAX_LOADSTRING
Definition: fontview.h:3
#define TRACKBAR_CLASS
Definition: commctrl.h:1983
HWND wave_win
Definition: sndrec32.cpp:38
#define IDR_MENU1
Definition: resource.h:6
#define BUTSTART_ID
Definition: sndrec32.h:22
BOOL WINAPI UpdateWindow(_In_ HWND)
HWND hWnd
Definition: settings.c:17
#define TBM_SETRANGE
Definition: commctrl.h:2007
snd::audio_waveout * AUD_OUT
Definition: sndrec32.cpp:70
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LPCSTR lpstrDefExt
Definition: commdlg.h:345
#define TBM_SETPOS
Definition: commctrl.h:2006
#define ID_FILE_OPEN
Definition: resource.h:42
BOOL display_dur
Definition: sndrec32.cpp:48
#define WS_CHILD
Definition: pedump.c:617
HWND slider
Definition: sndrec32.cpp:39
#define SLIDER_ID
Definition: sndrec32.h:27
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
WORD slider_min
Definition: sndrec32.cpp:51
BOOL WINAPI DestroyWindow(_In_ HWND)
#define BM_SETIMAGE
Definition: winuser.h:1883
#define GetOpenFileName
Definition: commdlg.h:665
WPARAM wParam
Definition: combotst.c:138
#define WAVEBAR_TIMERTIME
Definition: sndrec32.h:62
TCHAR str_dur[MAX_LOADSTRING]
Definition: sndrec32.cpp:59
DWORD nMaxFile
Definition: commdlg.h:337
UINT_PTR WPARAM
Definition: windef.h:207
BOOL stopped_flag
Definition: sndrec32.cpp:46
#define SLIDER_CY
Definition: sndrec32.h:37
OPENFILENAME ofn
Definition: sndrec32.cpp:56
#define GetSaveFileName
Definition: commdlg.h:666
#define DialogBox
Definition: winuser.h:5627
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
GLenum GLclampf GLint i
Definition: glfuncs.h:14
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define STRBUF_X
Definition: sndrec32.h:47
#define ETO_OPAQUE
Definition: wingdi.h:645
LONG_PTR LPARAM
Definition: windef.h:208
#define TBM_GETPOS
Definition: commctrl.h:2001
#define IDD_ABOUTBOX
Definition: resource.h:8
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define ID_FILE_EXIT
Definition: resource.h:47
#define STRFMT_Y
Definition: sndrec32.h:51
#define BUTTONS_SPACE
Definition: sndrec32.h:34
#define ShellExecute
Definition: shellapi.h:679
#define TRANSPARENT
Definition: wingdi.h:948
HDC hdc
Definition: msvc.h:53
#define MAKELONG(a, b)
Definition: typedefs.h:248
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
TCHAR str_fmt[MAX_LOADSTRING]
Definition: sndrec32.cpp:61
snd::audio_membuffer * AUD_BUF
Definition: sndrec32.cpp:69
TCHAR str_pos[MAX_LOADSTRING]
Definition: sndrec32.cpp:58
#define ID_ABOUT
Definition: charmap.c:18
#define BUTTONS_W
Definition: sndrec32.h:31
#define ID_FILE_SAVE
Definition: resource.h:43
BOOL win_first
Definition: sndrec32.cpp:35
#define SB_ENDSCROLL
Definition: winuser.h:574
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define ID_FILE_NEW
Definition: resource.h:41
TCHAR str_mono[10]
Definition: sndrec32.cpp:64
#define STRFMT_X
Definition: sndrec32.h:50
NONCLIENTMETRICS s_info
Definition: sndrec32.cpp:75
#define STRPOS_Y
Definition: sndrec32.h:42
char TCHAR
Definition: xmlstorage.h:189
#define UlongToPtr(ul)
Definition: basetsd.h:98
snd::audio_wavein * AUD_IN
Definition: sndrec32.cpp:71
#define _T(x)
Definition: vfdio.h:22
VOID enable_but(DWORD id)
Definition: sndrec32.cpp:933
#define WM_TIMER
Definition: winuser.h:1718
#define MF_ENABLED
Definition: winuser.h:128
RECT text2_rect
Definition: sndrec32.cpp:78
#define MAX_PATH
Definition: compat.h:26
DWORD lStructSize
Definition: commdlg.h:329
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
WORD slider_max
Definition: sndrec32.cpp:52
#define ID_FILE_SAVEAS
Definition: resource.h:44
#define WM_PAINT
Definition: winuser.h:1602
#define STRCHAN_Y
Definition: sndrec32.h:54
#define ExtTextOut
Definition: wingdi.h:4431
#define TBS_NOTICKS
Definition: commctrl.h:1993
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define WAVEBAR_TIMERID
Definition: sndrec32.h:61
#define STRDUR_X
Definition: sndrec32.h:44
#define MB_ICONERROR
Definition: winuser.h:781
#define BS_BITMAP
Definition: winuser.h:258
#define SB_PAGELEFT
Definition: winuser.h:570
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define MessageBox
Definition: winuser.h:5688
#define WM_COMMAND
Definition: winuser.h:1716
DWORD slider_pos
Definition: sndrec32.cpp:50
#define WM_USER
Definition: winuser.h:1856
#define gprintf
Definition: sndrec32.cpp:19
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SLIDER_CX
Definition: sndrec32.h:36
#define STRBUF_Y
Definition: sndrec32.h:48
#define BUTREC_ID
Definition: sndrec32.h:26
BOOL butdisabled[5]
Definition: sndrec32.cpp:45
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define TEXT(s)
Definition: k32.h:26
HWND buttons[5]
Definition: sndrec32.cpp:40
LPSTR lpstrFile
Definition: commdlg.h:336
BOOL write_wav(TCHAR *f)
Definition: sndrec32.cpp:1065
#define STRPOS_X
Definition: sndrec32.h:41
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
BOOL s_recording
Definition: sndrec32.cpp:73
#define SB_PAGERIGHT
Definition: winuser.h:571
LPCSTR lpstrFilter
Definition: commdlg.h:332
VOID disable_but(DWORD id)
Definition: sndrec32.cpp:939
#define CreateFontIndirect
Definition: wingdi.h:4421
#define WM_HSCROLL
Definition: winuser.h:1719
HBITMAP butbmps[5]
Definition: sndrec32.cpp:41
#define IMAGE_BITMAP
Definition: winuser.h:211
#define TBS_HORZ
Definition: commctrl.h:1987
BOOL isnew
Definition: sndrec32.cpp:47
HINSTANCE hInst
Definition: sndrec32.cpp:24
#define BUTTONS_CX
Definition: sndrec32.h:33
#define BUTSTOP_ID
Definition: sndrec32.h:25
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define ID_EDIT_AUDIOPROPS
Definition: resource.h:56
#define SendMessage
Definition: winuser.h:5709
#define WM_CREATE
Definition: winuser.h:1590
BOOL InitInstance_wave(HWND, HINSTANCE, int)
Definition: sndrec32.cpp:323
RECT text_rect
Definition: sndrec32.cpp:77
#define BUTEND_ID
Definition: sndrec32.h:23
#define BUTTONS_H
Definition: sndrec32.h:30
#define SLIDER_W
Definition: sndrec32.h:39
#define MF_GRAYED
Definition: winuser.h:129
#define STRDUR_Y
Definition: sndrec32.h:45
#define BUTPLAY_ID
Definition: sndrec32.h:24
#define WS_VISIBLE
Definition: pedump.c:620
TCHAR str_chan[MAX_LOADSTRING]
Definition: sndrec32.cpp:62
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define BUTTONS_CY
Definition: sndrec32.h:32
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define SLIDER_H
Definition: sndrec32.h:38
#define __int64
Definition: basetyps.h:16
TCHAR file_path[MAX_PATH]
Definition: sndrec32.cpp:57
TCHAR str_buf[MAX_LOADSTRING]
Definition: sndrec32.cpp:60
DWORD Flags
Definition: commdlg.h:342

◆ WndProc_wave()

LRESULT CALLBACK WndProc_wave ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 359 of file sndrec32.cpp.

Referenced by MyRegisterClass_wave().

363 {
364  PAINTSTRUCT ps;
365  HDC hdc;
366  HPEN pen;
367  HPEN oldpen;
368 
369  unsigned int max_h = (cli.bottom / 2);
370  unsigned int samples;
371  unsigned int x, line_h;
372 
373  switch (message)
374  {
375  case WM_CREATE:
376  GetClientRect(hWnd, &cli);
377  break;
378 
379  case WM_PAINT:
380  /* Initialize hdc objects */
381  hdc = BeginPaint(hWnd, &ps);
382  pen = (HPEN)CreatePen(PS_SOLID, 1, WAVEBAR_COLOR);
383  oldpen = (HPEN) SelectObject(hdc, (HBRUSH)pen);
384  if (AUD_OUT->current_status() == snd::WAVEOUT_PLAYING)
385  {
386  samples = AUD_OUT->tot_samples_buf();
387  for (unsigned int i = 0; i < WAVEBAR_CX; ++i)
388  {
389  x = (i * samples) / WAVEBAR_CX;
390  line_h = (AUD_OUT->nsample(x) * max_h) / AUD_OUT->samplevalue_max();
391  if (line_h)
392  {
393  MoveToEx(hdc, i, max_h, 0);
394  LineTo(hdc, i, max_h - (line_h * 2));
395  LineTo(hdc, i, max_h + (line_h * 2));
396  }
397  else
398  {
399  SetPixel(hdc, i, max_h, WAVEBAR_COLOR);
400  }
401  }
402  }
403  else if (AUD_IN->current_status() == snd::WAVEIN_RECORDING)
404  {
405  samples = AUD_IN->tot_samples_buf();
406  for (unsigned int i = 0; i < WAVEBAR_CX; ++i)
407  {
408  x = (i * samples) / WAVEBAR_CX;
409  line_h = (AUD_IN->nsample(x) * max_h) / AUD_IN->samplevalue_max();
410  if (line_h)
411  {
412  MoveToEx(hdc, i, max_h, 0);
413  LineTo(hdc, i, max_h - (line_h * 2));
414  LineTo(hdc, i, max_h + (line_h * 2));
415  }
416  else
417  {
418  SetPixel( hdc, i, max_h, WAVEBAR_COLOR );
419  }
420  }
421  }
422  else
423  {
424  /* In standby mode draw a simple line */
425  MoveToEx(hdc, 0, cli.bottom / 2, 0);
426  LineTo(hdc, WAVEBAR_CX, cli.bottom / 2);
427  }
428 
429  SelectObject(hdc, oldpen);
430  DeleteObject( pen );
431  EndPaint( hWnd, &ps );
432  break;
433 
434  case WM_USER:
435  break;
436 
437  default:
438  return DefWindowProc(hWnd, message, wParam, lParam);
439  }
440 
441  return 0;
442 }
#define HDC
Definition: msvc.h:22
GLsizei samples
Definition: glext.h:7006
Definition: tftpd.h:59
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define WAVEBAR_COLOR
Definition: sndrec32.h:64
snd::audio_waveout * AUD_OUT
Definition: sndrec32.cpp:70
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define PS_SOLID
Definition: wingdi.h:584
GLenum GLclampf GLint i
Definition: glfuncs.h:14
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
HDC hdc
Definition: msvc.h:53
#define DefWindowProc
Definition: ros2win.h:31
FORCEINLINE VOID SetPixel(IN ULONG Left, IN ULONG Top, IN UCHAR Color)
Definition: vga.c:99
snd::audio_wavein * AUD_IN
Definition: sndrec32.cpp:71
RECT cli
Definition: sndrec32.cpp:79
#define WM_PAINT
Definition: winuser.h:1602
#define WM_USER
Definition: winuser.h:1856
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
INT x
Definition: msvc.h:62
#define WM_CREATE
Definition: winuser.h:1590
LONG bottom
Definition: windef.h:299
#define WAVEBAR_CX
Definition: sndrec32.h:58
LPARAM lParam
Definition: combotst.c:139

◆ write_wav()

BOOL write_wav ( TCHAR f)

Definition at line 1065 of file sndrec32.cpp.

Referenced by WndProc().

1066 {
1067  HANDLE file;
1068  DWORD written;
1069  BOOL is_writ;
1070  int i;
1071  riff_hdr r;
1072  wave_hdr w;
1073  data_chunk d;
1074 
1076  if (!file)
1077  {
1078  i = MessageBox(main_win,
1079  TEXT("File already exist. Overwrite it?"),
1080  TEXT("Warning"),
1082 
1083  if (i == IDYES)
1084  {
1086  if (!file)
1087  {
1089  TEXT("File Error, CreateFile() failed."),
1090  TEXT("ERROR"),
1091  MB_OK | MB_ICONERROR);
1092 
1093  return FALSE;
1094  }
1095 
1096  } else
1097  return FALSE;
1098  }
1099 
1100  r.magic = 0x46464952;
1101  r.format = 0x45564157;
1102  r.chunksize = 36 + AUD_BUF->bytes_recorded();
1103 
1104  w.Subchunkid = 0x20746d66;
1105  w.Subchunk1Size = 16;
1106  w.AudioFormat = 1;
1107  w.NumChannels = AUD_BUF->audinfo().channels();
1108  w.SampleRate = AUD_BUF->audinfo().sample_rate();
1109  w.ByteRate = AUD_BUF->audinfo().byte_rate();
1110  w.BlockAlign = AUD_BUF->audinfo().block_align();
1111  w.BitsPerSample = AUD_BUF->audinfo().bits();
1112 
1113  d.subc = 0x61746164;
1114  d.subc_size = AUD_BUF->bytes_recorded();
1115 
1116  /* Writing headers */
1117  is_writ = WriteFile(file, (LPCVOID)&r, sizeof(r), &written, 0);
1118  if (!is_writ)
1119  {
1121  TEXT("File Error, WriteFile() failed."),
1122  TEXT("ERROR"),
1123  MB_OK | MB_ICONERROR);
1124 
1125  CloseHandle(file);
1126  return FALSE;
1127  }
1128 
1129  is_writ = WriteFile(file, (LPCVOID)&w, sizeof(w), &written, 0);
1130  if (!is_writ)
1131  {
1133  TEXT("File Error, WriteFile() failed."),
1134  TEXT("ERROR"),
1135  MB_OK | MB_ICONERROR);
1136 
1137  CloseHandle(file);
1138  return FALSE;
1139  }
1140 
1141  is_writ = WriteFile(file, (LPCVOID)&d, sizeof(d), &written, 0);
1142  if (!is_writ)
1143  {
1145  TEXT("File Error, WriteFile() failed."),
1146  TEXT("ERROR"),
1147  MB_OK | MB_ICONERROR);
1148 
1149  CloseHandle(file);
1150  return FALSE;
1151  }
1152 
1153  is_writ = WriteFile(file,
1154  (LPCVOID)AUD_BUF->audio_buffer(),
1155  AUD_BUF->bytes_recorded(),
1156  &written,
1157  0);
1158  if (!is_writ)
1159  {
1161  TEXT("File Error, WriteFile() failed."),
1162  TEXT("ERROR"),
1163  MB_OK | MB_ICONERROR);
1164 
1165  CloseHandle(file);
1166  return FALSE;
1167  }
1168 
1169  CloseHandle(file);
1170  return TRUE;
1171 }
DWORD format
Definition: sndrec32.h:80
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
WORD BlockAlign
Definition: sndrec32.h:91
#define IDYES
Definition: winuser.h:829
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
DWORD subc_size
Definition: sndrec32.h:98
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define MB_YESNO
Definition: winuser.h:811
#define GENERIC_WRITE
Definition: nt_native.h:90
DWORD chunksize
Definition: sndrec32.h:79
#define MB_ICONQUESTION
Definition: winuser.h:783
snd::audio_membuffer * AUD_BUF
Definition: sndrec32.cpp:69
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
GLfloat f
Definition: glext.h:7540
unsigned int BOOL
Definition: ntddk_ex.h:94
#define d
Definition: ke_i.h:81
DWORD magic
Definition: sndrec32.h:78
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD subc
Definition: sndrec32.h:97
DWORD ByteRate
Definition: sndrec32.h:90
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define MB_ICONERROR
Definition: winuser.h:781
#define MessageBox
Definition: winuser.h:5688
WORD BitsPerSample
Definition: sndrec32.h:92
#define CREATE_ALWAYS
Definition: disk.h:72
#define TEXT(s)
Definition: k32.h:26
DWORD Subchunkid
Definition: sndrec32.h:85
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
#define MB_OK
Definition: winuser.h:784
WORD NumChannels
Definition: sndrec32.h:88
DWORD Subchunk1Size
Definition: sndrec32.h:86
CONST void * LPCVOID
Definition: windef.h:191
WORD AudioFormat
Definition: sndrec32.h:87
#define CREATE_NEW
Definition: disk.h:69
HWND main_win
Definition: sndrec32.cpp:37
DWORD SampleRate
Definition: sndrec32.h:89

Variable Documentation

◆ AUD_BUF

snd::audio_membuffer* AUD_BUF

Definition at line 69 of file sndrec32.cpp.

Referenced by _tWinMain(), open_wav(), WndProc(), and write_wav().

◆ AUD_IN

snd::audio_wavein* AUD_IN

Definition at line 71 of file sndrec32.cpp.

Referenced by _tWinMain(), WndProc(), and WndProc_wave().

◆ AUD_OUT

snd::audio_waveout* AUD_OUT

Definition at line 70 of file sndrec32.cpp.

Referenced by _tWinMain(), WndProc(), and WndProc_wave().

◆ butbmps

HBITMAP butbmps[5]

Definition at line 41 of file sndrec32.cpp.

Referenced by _tWinMain(), enable_but(), and WndProc().

◆ butbmps_dis

HBITMAP butbmps_dis[5]

Definition at line 42 of file sndrec32.cpp.

Referenced by _tWinMain(), and disable_but().

◆ butdisabled

BOOL butdisabled[5]

Definition at line 45 of file sndrec32.cpp.

Referenced by disable_but(), enable_but(), and WndProc().

◆ buttons

◆ buttons_std_proc

WNDPROC buttons_std_proc

Definition at line 43 of file sndrec32.cpp.

◆ cli

RECT cli

Definition at line 79 of file sndrec32.cpp.

Referenced by EnablePassThrough(), MaskIrqs(), PICE_KdpPrintString(), and printk().

◆ display_dur

BOOL display_dur

Definition at line 48 of file sndrec32.cpp.

Referenced by _tWinMain(), and WndProc().

◆ file_path

◆ hInst

HINSTANCE hInst

Definition at line 24 of file sndrec32.cpp.

◆ isnew

BOOL isnew

Definition at line 47 of file sndrec32.cpp.

Referenced by _tWinMain(), open_wav(), and WndProc().

◆ main_win

HWND main_win

Definition at line 37 of file sndrec32.cpp.

◆ ofn

◆ path_set

BOOL path_set

Definition at line 67 of file sndrec32.cpp.

Referenced by _tWinMain().

◆ s_info

NONCLIENTMETRICS s_info

Definition at line 75 of file sndrec32.cpp.

Referenced by _tWinMain(), and WndProc().

◆ s_recording

BOOL s_recording

Definition at line 73 of file sndrec32.cpp.

Referenced by _tWinMain(), and WndProc().

◆ samples_max

DWORD samples_max

Definition at line 54 of file sndrec32.cpp.

Referenced by _tWinMain(), l_audio_arrival(), open_wav(), and WndProc().

◆ slider

HWND slider

Definition at line 39 of file sndrec32.cpp.

Referenced by BtrfsDeviceResize::DeviceResizeDlgProc().

◆ slider_max

WORD slider_max

Definition at line 52 of file sndrec32.cpp.

Referenced by _tWinMain(), l_audio_arrival(), and WndProc().

◆ slider_min

WORD slider_min

Definition at line 51 of file sndrec32.cpp.

Referenced by _tWinMain(), and WndProc().

◆ slider_pos

DWORD slider_pos

Definition at line 50 of file sndrec32.cpp.

Referenced by _tWinMain(), l_audio_arrival(), and WndProc().

◆ stopped_flag

BOOL stopped_flag

Definition at line 46 of file sndrec32.cpp.

Referenced by _tWinMain(), l_play_finished(), and WndProc().

◆ str_buf

Definition at line 60 of file sndrec32.cpp.

Referenced by _tWinMain(), test_sorting(), testScreenBuffer(), and WndProc().

◆ str_chan

TCHAR str_chan[MAX_LOADSTRING]

Definition at line 62 of file sndrec32.cpp.

Referenced by _tWinMain(), and WndProc().

◆ str_dur

Definition at line 59 of file sndrec32.cpp.

Referenced by _tWinMain(), and WndProc().

◆ str_fmt

Definition at line 61 of file sndrec32.cpp.

Referenced by _tWinMain(), and WndProc().

◆ str_mono

TCHAR str_mono[10]

Definition at line 64 of file sndrec32.cpp.

Referenced by _tWinMain(), and WndProc().

◆ str_pos

Definition at line 58 of file sndrec32.cpp.

Referenced by _tWinMain(), and WndProc().

◆ str_stereo

TCHAR str_stereo[10]

Definition at line 65 of file sndrec32.cpp.

Referenced by _tWinMain(), and WndProc().

◆ szTitle

Definition at line 25 of file sndrec32.cpp.

Referenced by _tWinMain(), and InitInstance().

◆ szWindowClass

TCHAR szWindowClass[MAX_LOADSTRING]

Definition at line 26 of file sndrec32.cpp.

Referenced by _tWinMain(), InitInstance(), and MyRegisterClass().

◆ text2_rect

RECT text2_rect

Definition at line 78 of file sndrec32.cpp.

◆ text_rect

RECT text_rect

Definition at line 77 of file sndrec32.cpp.

Referenced by ID3DXFontImpl_DrawTextW(), and MONTHCAL_PaintTodayTitle().

◆ wave_win

HWND wave_win

Definition at line 38 of file sndrec32.cpp.

◆ win_first

BOOL win_first

Definition at line 35 of file sndrec32.cpp.

Referenced by _tWinMain(), and WndProc().

◆ wout_first

BOOL wout_first

Definition at line 35 of file sndrec32.cpp.

Referenced by _tWinMain(), and WndProc().