ReactOS  0.4.15-dev-1054-gd029a62
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 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.

Function Documentation

◆ _tWinMain()

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

Definition at line 83 of file sndrec32.cpp.

87 {
88  UNREFERENCED_PARAMETER(hPrevInstance);
89  UNREFERENCED_PARAMETER(lpCmdLine);
90 
91  MSG msg;
92  HACCEL hAccelTable;
93 
94  s_info.cbSize = sizeof( NONCLIENTMETRICS );
95 
97 
98  switch (GetUserDefaultUILanguage())
99  {
102  break;
103 
104  default:
105  break;
106  }
107 
109 
114 
119 
120  /* Retrieving default system font, and others system informations */
121  SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
122  sizeof(NONCLIENTMETRICS),
123  &s_info,
124  0);
125 
126  /* Set font size */
127  s_info.lfMenuFont.lfHeight = 14;
128 
129  /* Inits buttons bitmaps */
130 
136 
142 
143  /* Inits audio devices and buffers */
144 
145  snd::audio_membuffer AUD_buffer(snd::A44100_16BIT_STEREO);
146  snd::audio_waveout AUD_waveout(snd::A44100_16BIT_STEREO, AUD_buffer);
147  snd::audio_wavein AUD_wavein(snd::A44100_16BIT_STEREO, AUD_buffer);
148 
149  AUD_buffer.play_finished = l_play_finished;
150  AUD_buffer.audio_arrival = l_audio_arrival;
151  AUD_buffer.buffer_resized = l_buffer_resized;
152 
153  AUD_buffer.alloc_seconds(INITIAL_BUFREC_SECONDS);
154 
155  AUD_IN = &AUD_wavein;
156  AUD_OUT = &AUD_waveout;
157  AUD_BUF = &AUD_buffer;
158 
159  /* Inits slider default parameters */
160 
161  slider_pos = 0;
162  slider_min = 0;
164 
166  path_set = FALSE;
167  isnew = TRUE;
168  display_dur = TRUE;
169 
170  samples_max = AUD_buffer.total_samples();
171 
172  s_recording = false;
173 
174  /* Inits strings */
184 
185  /* Registers sndrec32 window class */
188 
189  if (!InitInstance(hInstance, nCmdShow))
190  {
191  MessageBox(0, TEXT("CreateWindow() Error!"), TEXT("ERROR"), MB_ICONERROR);
192  return FALSE;
193  }
194 
195  /* Loads key accelerators */
197 
198  /* Starts main loop */
199  while (GetMessage(&msg, NULL, 0, 0))
200  {
201  if (!TranslateAccelerator(main_win, hAccelTable, &msg))
202  {
205  }
206  }
207 
208  if (wout_first)
209  {
210  AUD_waveout.close();
211  }
212 
213  if (win_first)
214  {
215  AUD_wavein.close();
216  }
217 
218  AUD_buffer.clear();
219 
220  return (int)msg.wParam;
221 }
#define IDS_STRBUF
Definition: resource.h:33
BOOL wout_first
Definition: sndrec32.cpp:35
void l_play_finished(void)
Definition: sndrec32.cpp:892
#define TranslateAccelerator
Definition: winuser.h:5835
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IDB_BITMAP2_PLAY_DIS
Definition: resource.h:27
#define DispatchMessage
Definition: winuser.h:5740
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: lang.c:806
BOOL WINAPI TranslateMessage(_In_ const MSG *)
DWORD samples_max
Definition: sndrec32.cpp:54
HBITMAP butbmps_dis[5]
Definition: sndrec32.cpp:42
TCHAR str_stereo[10]
Definition: sndrec32.cpp:65
#define REFRESHA_Y
Definition: sndrec32.h:67
#define LAYOUT_RTL
Definition: wingdi.h:1370
TCHAR szTitle[MAX_LOADSTRING]
Definition: sndrec32.cpp:25
audio_format A44100_16BIT_STEREO(44100, 16, 2)
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define IDB_BITMAP2_STOP
Definition: resource.h:21
#define MAX_LOADSTRING
Definition: fontview.h:3
#define IDB_BITMAP2_END_DIS
Definition: resource.h:26
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define SystemParametersInfo
Definition: winuser.h:5833
LONG top
Definition: windef.h:307
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:13
LONG left
Definition: windef.h:306
WORD slider_min
Definition: sndrec32.cpp:51
LONG right
Definition: windef.h:308
#define LANG_HEBREW
Definition: nls.h:67
ATOM MyRegisterClass(HINSTANCE hInstance)
Definition: sndrec32.cpp:224
TCHAR str_dur[MAX_LOADSTRING]
Definition: sndrec32.cpp:59
#define IDS_STRDUR
Definition: resource.h:32
BOOL stopped_flag
Definition: sndrec32.cpp:46
#define LoadAccelerators
Definition: winuser.h:5785
HINSTANCE hInstance
Definition: charmap.c:20
void l_audio_arrival(unsigned int samples_arrival)
Definition: sndrec32.cpp:904
#define FALSE
Definition: types.h:117
BOOL InitInstance(HINSTANCE, int)
Definition: sndrec32.cpp:246
#define REFRESHB_X
Definition: sndrec32.h:71
#define IDS_STRMONO
Definition: resource.h:35
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:34
#define IDB_BITMAP2_START
Definition: resource.h:18
#define IDS_STRCHAN
Definition: resource.h:38
TCHAR str_mono[10]
Definition: sndrec32.cpp:64
TCHAR szWindowClass[MAX_LOADSTRING]
Definition: sndrec32.cpp:26
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1720
NONCLIENTMETRICS s_info
Definition: sndrec32.cpp:75
#define LoadBitmap
Definition: winuser.h:5786
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:5797
#define IDB_BITMAP2_END
Definition: resource.h:19
DWORD slider_pos
Definition: sndrec32.cpp:50
void l_buffer_resized(unsigned int new_size)
Definition: sndrec32.cpp:909
#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:28
BOOL s_recording
Definition: sndrec32.cpp:73
#define IDS_STRPOS
Definition: resource.h:31
HBITMAP butbmps[5]
Definition: sndrec32.cpp:41
#define IDS_APP_TITLE
Definition: resource.h:10
#define GetMessage
Definition: winuser.h:5765
#define IDS_STRSTEREO
Definition: resource.h:36
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:309
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
#define SLIDER_W
Definition: sndrec32.h:39
#define IDB_BITMAP2_START_DIS
Definition: resource.h:29
#define IDB_BITMAP2_REC
Definition: resource.h:22
BOOL path_set
Definition: sndrec32.cpp:67
ATOM MyRegisterClass_wave(HINSTANCE hInstance)
Definition: sndrec32.cpp:277
TCHAR str_chan[MAX_LOADSTRING]
Definition: sndrec32.cpp:62
#define LoadString
Definition: winuser.h:5794
HWND main_win
Definition: sndrec32.cpp:37
TCHAR str_buf[MAX_LOADSTRING]
Definition: sndrec32.cpp:60
#define IDB_BITMAP2_PLAY
Definition: resource.h:20

◆ disable_but()

VOID disable_but ( DWORD  id)

Definition at line 919 of file sndrec32.cpp.

920 {
921  butdisabled[id] = TRUE;
923 }
HBITMAP butbmps_dis[5]
Definition: sndrec32.cpp:42
#define TRUE
Definition: types.h:120
UINT_PTR WPARAM
Definition: windef.h:207
#define BM_SETIMAGE
Definition: winuser.h:1904
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:5818
GLenum GLuint id
Definition: glext.h:5579

Referenced by WndProc().

◆ enable_but()

VOID enable_but ( DWORD  id)

Definition at line 913 of file sndrec32.cpp.

914 {
915  butdisabled[id] = FALSE;
917 }
UINT_PTR WPARAM
Definition: windef.h:207
#define BM_SETIMAGE
Definition: winuser.h:1904
#define FALSE
Definition: types.h:117
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:5818
GLenum GLuint id
Definition: glext.h:5579

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

◆ InitInstance()

BOOL InitInstance ( HINSTANCE  hInstance,
int  nCmdShow 
)

Definition at line 246 of file sndrec32.cpp.

247 {
248  HWND hWnd;
249 
250  hInst = hInstance;
251 
253  szTitle,
257  MAINWINDOW_W,
258  MAINWINDOW_H,
259  NULL,
260  NULL,
261  hInstance,
262  NULL);
263  if (!hWnd)
264  {
265  return FALSE;
266  }
267 
268  ShowWindow(hWnd, nCmdShow);
270 
271  main_win = hWnd;
272 
273  return TRUE;
274 }
#define CreateWindow
Definition: winuser.h:5729
TCHAR szTitle[MAX_LOADSTRING]
Definition: sndrec32.cpp:25
#define TRUE
Definition: types.h:120
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 FALSE
Definition: types.h:117
#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

Referenced by _tWinMain().

◆ InitInstance_wave()

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

Definition at line 299 of file sndrec32.cpp.

302 {
303  HWND hWnd;
304 
305  hInst = hInstance;
306 
308  TEXT("sndrec32_wave"),
309  TEXT(""),
311  WAVEBAR_X,
312  WAVEBAR_Y,
313  WAVEBAR_CX,
314  WAVEBAR_CY,
315  f,
316  (HMENU)8,
317  hInstance,
318  0);
319 
320  if (!hWnd )
321  {
322  return FALSE;
323  }
324 
325  ShowWindow(hWnd, nCmdShow);
327 
328  wave_win = hWnd;
329 
330  return TRUE;
331 }
#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 FALSE
Definition: types.h:117
#define CreateWindowEx
Definition: winuser.h:5730
#define WAVEBAR_CY
Definition: sndrec32.h:59
GLfloat f
Definition: glext.h:7540
#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

Referenced by WndProc().

◆ l_audio_arrival()

void l_audio_arrival ( unsigned int  samples_arrival)

Definition at line 904 of file sndrec32.cpp.

905 {
906  slider_pos += (DWORD)((slider_max * samples_arrival) / samples_max);
907 }
DWORD samples_max
Definition: sndrec32.cpp:54
#define DWORD
Definition: nt_native.h:44
WORD slider_max
Definition: sndrec32.cpp:52
DWORD slider_pos
Definition: sndrec32.cpp:50

Referenced by _tWinMain().

◆ l_buffer_resized()

void l_buffer_resized ( unsigned int  new_size)

Definition at line 909 of file sndrec32.cpp.

910 {
911 }

Referenced by _tWinMain().

◆ l_play_finished()

void l_play_finished ( void  )

Definition at line 892 of file sndrec32.cpp.

893 {
894  stopped_flag = true;
895 
900 
902 }
#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:913
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

Referenced by _tWinMain().

◆ MyRegisterClass()

ATOM MyRegisterClass ( HINSTANCE  hInstance)

Definition at line 224 of file sndrec32.cpp.

225 {
226  WNDCLASSEX wcex;
227 
228  wcex.cbSize = sizeof(WNDCLASSEX);
229 
230  wcex.style = CS_HREDRAW | CS_VREDRAW;
231  wcex.lpfnWndProc = WndProc;
232  wcex.cbClsExtra = 0;
233  wcex.cbWndExtra = 0;
234  wcex.hInstance = hInstance;
236  wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
241 
242  return RegisterClassEx(&wcex);
243 }
UINT style
Definition: winuser.h:3177
#define MAKEINTRESOURCE
Definition: winuser.h:591
LPCSTR lpszMenuName
Definition: winuser.h:3185
#define RegisterClassEx
Definition: winuser.h:5812
HCURSOR hCursor
Definition: winuser.h:3183
WNDPROC lpfnWndProc
Definition: winuser.h:3178
LPCSTR lpszClassName
Definition: winuser.h:3186
#define IDR_MENU1
Definition: resource.h:6
#define CS_HREDRAW
Definition: winuser.h:648
#define IDI_SNDREC32
Definition: resource.h:11
HICON hIconSm
Definition: winuser.h:3187
HINSTANCE hInstance
Definition: charmap.c:20
HINSTANCE hInstance
Definition: winuser.h:3181
smooth NULL
Definition: ftsmooth.c:416
UINT cbSize
Definition: winuser.h:3176
HBRUSH hbrBackground
Definition: winuser.h:3184
TCHAR szWindowClass[MAX_LOADSTRING]
Definition: sndrec32.cpp:26
#define CS_VREDRAW
Definition: winuser.h:653
int cbWndExtra
Definition: winuser.h:3180
HICON hIcon
Definition: winuser.h:3182
#define COLOR_BTNFACE
Definition: winuser.h:918
#define LoadCursor
Definition: winuser.h:5787
int cbClsExtra
Definition: winuser.h:3179
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM)
Definition: sndrec32.cpp:422
#define IDC_ARROW
Definition: winuser.h:682
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5694
#define LoadIcon
Definition: winuser.h:5788
HBRUSH WINAPI GetSysColorBrush(_In_ int)

Referenced by _tWinMain().

◆ MyRegisterClass_wave()

ATOM MyRegisterClass_wave ( HINSTANCE  hInstance)

Definition at line 277 of file sndrec32.cpp.

278 {
279  WNDCLASSEX wcex;
280 
281  wcex.cbSize = sizeof(WNDCLASSEX);
282 
283  wcex.style = CS_HREDRAW | CS_VREDRAW;
284  wcex.lpfnWndProc = WndProc_wave;
285  wcex.cbClsExtra = 0;
286  wcex.cbWndExtra = 0;
287  wcex.hInstance = hInstance;
288  wcex.hIcon = 0;
289  wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
290  wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
291  wcex.lpszMenuName = 0;
292  wcex.lpszClassName = TEXT("sndrec32_wave");
293  wcex.hIconSm = 0;
294 
295  return RegisterClassEx(&wcex);
296 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
UINT style
Definition: winuser.h:3177
LPCSTR lpszMenuName
Definition: winuser.h:3185
#define RegisterClassEx
Definition: winuser.h:5812
LRESULT CALLBACK WndProc_wave(HWND, UINT, WPARAM, LPARAM)
Definition: sndrec32.cpp:335
HCURSOR hCursor
Definition: winuser.h:3183
WNDPROC lpfnWndProc
Definition: winuser.h:3178
LPCSTR lpszClassName
Definition: winuser.h:3186
#define CS_HREDRAW
Definition: winuser.h:648
HICON hIconSm
Definition: winuser.h:3187
HINSTANCE hInstance
Definition: charmap.c:20
HINSTANCE hInstance
Definition: winuser.h:3181
smooth NULL
Definition: ftsmooth.c:416
UINT cbSize
Definition: winuser.h:3176
HBRUSH hbrBackground
Definition: winuser.h:3184
#define BLACK_BRUSH
Definition: wingdi.h:895
#define CS_VREDRAW
Definition: winuser.h:653
int cbWndExtra
Definition: winuser.h:3180
HICON hIcon
Definition: winuser.h:3182
#define LoadCursor
Definition: winuser.h:5787
int cbClsExtra
Definition: winuser.h:3179
#define TEXT(s)
Definition: k32.h:26
#define IDC_ARROW
Definition: winuser.h:682
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5694

Referenced by _tWinMain().

◆ open_wav()

BOOL open_wav ( TCHAR f)

Definition at line 925 of file sndrec32.cpp.

926 {
927  HANDLE file;
928 
929  riff_hdr r;
930  wave_hdr w;
931  data_chunk d;
932 
933  BOOL b;
934 
935  DWORD bytes_recorded_in_wav = 0;
936  DWORD is_read = 0;
937 
938  file = CreateFile(f,
939  GENERIC_READ,
940  0,
941  0,
944  0);
945  if (!file)
946  {
948  TEXT("Cannot open file. CreateFile() error."),
949  TEXT("ERROR"),
950  MB_OK | MB_ICONERROR);
951 
952  return FALSE;
953  }
954 
955  b = ReadFile(file, (LPVOID)&r, sizeof(r), &is_read, 0);
956  if (!b)
957  {
959  TEXT("Cannot read RIFF header."),
960  TEXT("ERROR"),
961  MB_OK | MB_ICONERROR);
962 
963  CloseHandle(file);
964  return FALSE;
965  }
966 
967  b = ReadFile(file, (LPVOID)&w, sizeof(w), &is_read, 0);
968  if (!b)
969  {
971  TEXT("Cannot read WAVE header."),
972  TEXT("ERROR"),
973  MB_OK | MB_ICONERROR);
974 
975  CloseHandle(file);
976  return FALSE;
977  }
978 
979  b = ReadFile(file, (LPVOID)&d, sizeof(d), &is_read, 0);
980  if (!b)
981  {
983  TEXT("Cannot read WAVE subchunk."),
984  TEXT("ERROR"),
985  MB_OK | MB_ICONERROR);
986 
987  CloseHandle(file);
988  return FALSE;
989  }
990 
991  bytes_recorded_in_wav = r.chunksize - 36;
992  if (bytes_recorded_in_wav == 0)
993  {
995  TEXT("Cannot read file. No audio data."),
996  TEXT("ERROR"),
997  MB_OK | MB_ICONERROR);
998 
999  CloseHandle(file);
1000  return FALSE;
1001  }
1002 
1003  snd::audio_format openfmt(w.SampleRate, w.BitsPerSample, w.NumChannels);
1004 
1005  AUD_BUF->clear();
1006  AUD_BUF->alloc_bytes(bytes_recorded_in_wav);
1007 
1008  b = ReadFile(file,
1009  (LPVOID)AUD_BUF->audio_buffer(),
1010  bytes_recorded_in_wav,
1011  &is_read,
1012  0);
1013 
1014  AUD_BUF->set_b_received(bytes_recorded_in_wav);
1015 
1016  if ((!b) || (is_read != bytes_recorded_in_wav))
1017  {
1019  TEXT("Cannot read file. Error reading audio data."),
1020  TEXT("ERROR"),
1021  MB_OK | MB_ICONERROR);
1022 
1023  CloseHandle(file);
1024 
1025  AUD_BUF->reset();
1026  return FALSE;
1027  }
1028 
1029  CloseHandle(file);
1030 
1036 
1037  samples_max = AUD_BUF->samples_received();
1038 
1039  isnew = FALSE;
1040 
1041  return TRUE;
1042 }
DWORD samples_max
Definition: sndrec32.cpp:54
#define CloseHandle
Definition: compat.h:487
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define BUTSTART_ID
Definition: sndrec32.h:22
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
snd::audio_membuffer * AUD_BUF
Definition: sndrec32.cpp:69
#define OPEN_EXISTING
Definition: compat.h:523
#define b
Definition: ke_i.h:79
GLfloat f
Definition: glext.h:7540
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
VOID enable_but(DWORD id)
Definition: sndrec32.cpp:913
#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:137
#define MB_ICONERROR
Definition: winuser.h:781
#define MessageBox
Definition: winuser.h:5797
#define GENERIC_READ
Definition: compat.h:135
#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:913
#define ReadFile(a, b, c, d, e)
Definition: compat.h:490
#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
HWND main_win
Definition: sndrec32.cpp:37
Definition: fci.c:126

Referenced by WndProc().

◆ WndProc()

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

Definition at line 422 of file sndrec32.cpp.

426 {
427  int wmId;
428  TCHAR str_tmp[MAX_LOADSTRING];
429  PAINTSTRUCT ps;
430  HDC hdc;
431  HFONT font;
432  HFONT oldfont;
433  long long slid_samp = 0;
434  WCHAR szAppName[100];
435  HICON hIcon;
436 
437  /* Checking for global pointers to buffer and io audio devices */
438  if ((!AUD_IN) || (!AUD_OUT) || (!AUD_BUF))
439  {
440  MessageBox(0, TEXT("Buffer Error"), 0, 0);
441  return 1;
442  }
443 
444  switch (message)
445  {
446  case WM_CREATE:
447  /* Creating the wave bar */
449  {
450  MessageBox(0, TEXT("InitInstance_wave() Error!"), TEXT("ERROR"), MB_ICONERROR);
451  return FALSE;
452  }
453 
454  /* Creating ALL the buttons */
455  for (int i = 0; i < 5; ++i)
456  {
457  buttons[i] = CreateWindow(TEXT("button"),
458  TEXT(""),
460  BUTTONS_CX + (i * (BUTTONS_W + ((i == 0) ? 0 : BUTTONS_SPACE))),
461  BUTTONS_CY,
462  BUTTONS_W,
463  BUTTONS_H,
464  hWnd,
465  (HMENU)UlongToPtr(i),
466  hInst,
467  0);
468  if (!buttons[i])
469  {
470  MessageBox(0, 0, TEXT("CreateWindow() Error!"), 0);
471  return FALSE;
472  }
473 
474  /* Realize the button bmp image */
477  disable_but(i);
478  }
479 
480  /* Creating the SLIDER window */
482  TEXT(""),
484  SLIDER_CX,
485  SLIDER_CY,
486  SLIDER_W,
487  SLIDER_H,
488  hWnd,
489  (HMENU)SLIDER_ID,
490  hInst,
491  0);
492  if (!slider)
493  {
494  MessageBox(0, 0, TEXT( "CreateWindow() Error!" ), 0);
495  return FALSE;
496  }
497 
498  /* Sets slider limits */
500  TBM_SETRANGE,
501  (WPARAM)TRUE,
503 
507  break;
508 
509  /* Implements slider logic */
510  case WM_HSCROLL:
511  {
512  switch (LOWORD(wParam))
513  {
514  case SB_ENDSCROLL:
515  break;
516  case SB_PAGERIGHT:
517  case SB_PAGELEFT:
518  case TB_THUMBTRACK:
519  /* If the user touch the slider bar, set the
520  audio start position properly */
522  slid_samp = (__int64)slider_pos * (__int64)samples_max;
523  AUD_BUF->set_position(AUD_BUF->audinfo().bytes_in_samples((unsigned int)(slid_samp / (__int64)slider_max)));
525  break;
526  }
527  break;
528  }
529 
530  case WM_COMMAND:
531  wmId = LOWORD(wParam);
532  if ((wmId >= 0) && (wmId < 5) && (butdisabled[wmId] != FALSE))
533  break;
534 
535  switch (wmId)
536  {
537  case ID_FILE_NEW:
538  if (!isnew)
539  {
540  if (AUD_IN->current_status() == snd::WAVEIN_RECORDING)
541  AUD_IN->stop_recording();
542 
543  if ((AUD_OUT->current_status() == snd::WAVEOUT_PLAYING) ||
544  (AUD_OUT->current_status() == snd::WAVEOUT_PAUSED))
545  AUD_OUT->stop();
546 
547  AUD_BUF->reset();
548 
554 
555  samples_max = AUD_BUF->total_samples();
556  slider_pos = 0;
557 
559 
562 
563  isnew = TRUE;
564  display_dur = TRUE;
565 
566  ZeroMemory(file_path, MAX_PATH * sizeof(TCHAR));
567 
569 
572  }
573  break;
574 
575  case ID_FILE_OPEN:
576  ZeroMemory(&ofn, sizeof(ofn));
577 
578  ofn.lStructSize = sizeof(ofn);
579  ofn.hwndOwner = hWnd;
580  ofn.lpstrFilter = TEXT("Audio Files (*.wav)\0*.wav\0All Files (*.*)\0*.*\0");
584  ofn.lpstrDefExt = TEXT("wav");
585 
586  if (GetOpenFileName(&ofn))
587  {
591 
593  }
594 
597  break;
598 
599  case ID_ABOUT:
604  break;
605 
606  case ID_FILE_SAVEAS:
607  ZeroMemory(&ofn, sizeof(ofn));
608 
609  ofn.lStructSize = sizeof(ofn);
610  ofn.hwndOwner = hWnd ;
612  ofn.lpstrFilter = TEXT("Audio Files (*.wav)\0*.wav\0All Files (*.*)\0*.*\0");
615 
616  ofn.lpstrDefExt = TEXT("wav");
617 
618  if (GetSaveFileName (&ofn))
619  {
622  }
623  break;
624 
625 
626  case ID_EDIT_AUDIOPROPS:
627  ShellExecute(NULL, NULL, _T("rundll32.exe"), _T("shell32.dll,Control_RunDLL mmsys.cpl,ShowAudioPropertySheet"), NULL, SW_SHOWNORMAL);
628  break;
629 
630  case ID_FILE_EXIT:
632  break;
633 
634  /* Sndrec32 buttons routines */
635  case BUTSTART_ID:
636  AUD_BUF->set_position_start();
637  slider_pos = 0;
639  break;
640 
641  case BUTEND_ID:
643  break;
644 
645  case BUTPLAY_ID:
646  if (wout_first == false)
647  {
648  AUD_OUT->open();
649  wout_first = true;
650  }
651 
652  AUD_OUT->play();
653 
658 
659  SetTimer(hWnd, 1, 250, 0);
661 
662  break;
663 
664  case BUTSTOP_ID:
665  if (s_recording)
666  {
667  s_recording = FALSE;
668 
669  AUD_IN->stop_recording();
670 
671  /* Resetting slider position */
672  slider_pos = 0;
674 
675  samples_max = AUD_BUF->samples_received();
676 
678 
683 
686 
687  display_dur = FALSE;
688 
689  AUD_BUF->truncate();
690 
693 
694  }
695  else
696  {
697  AUD_OUT->pause();
698 
703 
704  }
705 
706  KillTimer(hWnd, 1);
708 
710 
711  break;
712 
713  case BUTREC_ID:
714  if (win_first == false)
715  {
716  AUD_IN->open();
717  win_first = true;
718  }
719 
720  s_recording = TRUE;
721 
722  samples_max = AUD_BUF->total_samples();
723 
724  AUD_IN->start_recording();
725 
727 
732 
733  isnew = FALSE;
734 
736 
737  SetTimer(hWnd, 1, 150, 0);
739 
740  break;
741 
742  default:
744  }
745  break;
746 
747  case WM_TIMER:
748  switch (wParam)
749  {
750  case 1:
751  if (stopped_flag)
752  {
753  KillTimer(hWnd, 1);
755  slider_pos = 0;
758  }
759 
762  break;
763 
764  case WAVEBAR_TIMERID:
766  SendMessage(wave_win, WM_USER, 0, 0);
767  break;
768  }
769  break;
770 
771  case WM_PAINT:
772  hdc = BeginPaint(hWnd, &ps);
773  font = CreateFontIndirect(&s_info.lfMenuFont);
774  oldfont = (HFONT) SelectObject(hdc, font);
776 
777  if (AUD_IN->current_status() == snd::WAVEIN_RECORDING)
778  {
779  gprintf(str_tmp,
781  str_pos,
782  (float)((float)AUD_BUF->bytes_recorded() / (float)AUD_BUF->audinfo().byte_rate()));
783 
784  }
785  else if (AUD_OUT->current_status() == snd::WAVEOUT_PLAYING)
786  {
787  gprintf(str_tmp,
789  str_pos,
790  (float)((float)AUD_BUF->bytes_played() / (float)AUD_BUF->audinfo().byte_rate()));
791  }
792  else
793  {
794  gprintf(str_tmp,
796  str_pos,
797  (float)((((float)slider_pos * (float)samples_max) / (float)slider_max) / (float)AUD_BUF->audinfo().sample_rate()));
798  }
799 
800  ExtTextOut(hdc,
801  STRPOS_X,
802  STRPOS_Y,
803  0,
804  0,
805  str_tmp,
806  _tcslen(str_tmp),
807  0);
808 
809  if (display_dur)
810  {
811  gprintf(str_tmp,
813  str_dur,
814  AUD_BUF->fseconds_total());
815  }
816  else
817  {
818  gprintf(str_tmp,
820  str_dur,
821  AUD_BUF->fseconds_recorded());
822  }
823 
824  ExtTextOut(hdc,
825  STRDUR_X,
826  STRDUR_Y,
827  0,
828  0,
829  str_tmp,
830  _tcslen(str_tmp),
831  0);
832 
833  gprintf(str_tmp,
835  str_buf,
836  (float)((float)AUD_BUF->mem_size() / 1024.0f));
837 
838  ExtTextOut(hdc,
839  STRBUF_X,
840  STRBUF_Y,
841  0,
842  0,
843  str_tmp,
844  _tcslen(str_tmp),
845  0);
846 
847  gprintf(str_tmp,
849  str_fmt,
850  (float)((float)AUD_BUF->audinfo().sample_rate() / 1000.0f),
851  AUD_BUF->audinfo().bits(),
852  AUD_BUF->audinfo().channels() == 2 ? str_mono : str_stereo);
853 
854  ExtTextOut(hdc,
855  STRFMT_X,
856  STRFMT_Y,
857  0,
858  0,
859  str_tmp,
860  _tcslen(str_tmp),
861  0);
862 
863  gprintf(str_tmp,
865  str_chan,
866  AUD_BUF->audinfo().channels() == 2 ? str_stereo : str_mono);
867 
868  ExtTextOut(hdc,
869  STRCHAN_X,
870  STRCHAN_Y,
871  0,
872  0,
873  str_tmp,
874  _tcslen(str_tmp),
875  0);
876 
877  SelectObject(hdc, oldfont);
879  EndPaint(hWnd, &ps);
880  break;
881 
882  case WM_DESTROY:
883  PostQuitMessage(0);
884  break;
885  default:
887  }
888 
889  return 0;
890 }
#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:2074
BOOL open_wav(TCHAR *f)
Definition: sndrec32.cpp:925
Definition: tftpd.h:59
static HICON
Definition: imagelist.c:84
DWORD samples_max
Definition: sndrec32.cpp:54
TCHAR str_stereo[10]
Definition: sndrec32.cpp:65
#define STRCHAN_X
Definition: sndrec32.h:53
#define TBS_ENABLESELRANGE
Definition: commctrl.h:2020
#define CreateWindow
Definition: winuser.h:5729
HWND hwndOwner
Definition: commdlg.h:330
Definition: mk_font.cpp:20
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define TRUE
Definition: types.h:120
#define MAX_LOADSTRING
Definition: fontview.h:3
#define TRACKBAR_CLASS
Definition: commctrl.h:2009
HWND wave_win
Definition: sndrec32.cpp:38
#define IDR_MENU1
Definition: resource.h:6
static HDC
Definition: imagelist.c:92
#define BUTSTART_ID
Definition: sndrec32.h:22
BOOL WINAPI UpdateWindow(_In_ HWND)
#define TBM_SETRANGE
Definition: commctrl.h:2033
HWND hWnd
Definition: settings.c:17
snd::audio_waveout * AUD_OUT
Definition: sndrec32.cpp:70
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
#define ZeroMemory
Definition: winbase.h:1648
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LPCSTR lpstrDefExt
Definition: commdlg.h:345
#define TBM_SETPOS
Definition: commctrl.h:2032
#define ID_FILE_OPEN
Definition: resource.h:41
BOOL display_dur
Definition: sndrec32.cpp:48
UINT_PTR WPARAM
Definition: windef.h:207
#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:1904
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#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
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
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1034
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define STRBUF_X
Definition: sndrec32.h:47
#define FALSE
Definition: types.h:117
#define TBM_GETPOS
Definition: commctrl.h:2027
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define ID_FILE_EXIT
Definition: resource.h:46
#define STRFMT_Y
Definition: sndrec32.h:51
#define BUTTONS_SPACE
Definition: sndrec32.h:34
#define ShellExecute
Definition: shellapi.h:691
#define TRANSPARENT
Definition: wingdi.h:949
#define MAKELONG(a, b)
Definition: typedefs.h:249
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
LONG_PTR LPARAM
Definition: windef.h:208
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:42
BOOL win_first
Definition: sndrec32.cpp:35
#define SB_ENDSCROLL
Definition: winuser.h:574
#define UlongToPtr(u)
Definition: config.h:106
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:40
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
snd::audio_wavein * AUD_IN
Definition: sndrec32.cpp:71
#define _T(x)
Definition: vfdio.h:22
VOID enable_but(DWORD id)
Definition: sndrec32.cpp:913
#define IDI_REACTOS_SNDREC32
Definition: resource.h:9
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define WM_TIMER
Definition: winuser.h:1724
#define MF_ENABLED
Definition: winuser.h:128
RECT text2_rect
Definition: sndrec32.cpp:78
#define MAX_PATH
Definition: compat.h:34
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:43
#define WM_PAINT
Definition: winuser.h:1602
#define STRCHAN_Y
Definition: sndrec32.h:54
#define ExtTextOut
Definition: wingdi.h:4453
#define TBS_NOTICKS
Definition: commctrl.h:2019
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define WAVEBAR_TIMERID
Definition: sndrec32.h:61
#define STRDUR_X
Definition: sndrec32.h:44
HDC hdc
Definition: main.c:9
#define MB_ICONERROR
Definition: winuser.h:781
#define BS_BITMAP
Definition: winuser.h:258
BOOL WINAPI ShellAboutW(HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon)
#define SB_PAGELEFT
Definition: winuser.h:570
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define MessageBox
Definition: winuser.h:5797
#define WM_COMMAND
Definition: winuser.h:1722
DWORD slider_pos
Definition: sndrec32.cpp:50
#define WM_USER
Definition: winuser.h:1877
#define gprintf
Definition: sndrec32.cpp:19
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
TCHAR szAppName[128]
Definition: solitaire.cpp:16
#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
static float(__cdecl *square_half_float)(float x
HICON hIcon
Definition: msconfig.c:44
BOOL write_wav(TCHAR *f)
Definition: sndrec32.cpp:1045
#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:919
#define CreateFontIndirect
Definition: wingdi.h:4443
#define WM_HSCROLL
Definition: winuser.h:1725
HBITMAP butbmps[5]
Definition: sndrec32.cpp:41
#define IDS_APP_TITLE
Definition: resource.h:10
#define IMAGE_BITMAP
Definition: winuser.h:211
#define TBS_HORZ
Definition: commctrl.h:2013
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:55
#define SendMessage
Definition: winuser.h:5818
#define WM_CREATE
Definition: winuser.h:1590
BOOL InitInstance_wave(HWND, HINSTANCE, int)
Definition: sndrec32.cpp:299
RECT text_rect
Definition: sndrec32.cpp:77
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define BUTEND_ID
Definition: sndrec32.h:23
#define BUTTONS_H
Definition: sndrec32.h:30
#define SLIDER_W
Definition: sndrec32.h:39
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#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

Referenced by MyRegisterClass().

◆ WndProc_wave()

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

Definition at line 335 of file sndrec32.cpp.

339 {
340  PAINTSTRUCT ps;
341  HDC hdc;
342  HPEN pen;
343  HPEN oldpen;
344 
345  unsigned int max_h = (cli.bottom / 2);
346  unsigned int samples;
347  unsigned int x, line_h;
348 
349  switch (message)
350  {
351  case WM_CREATE:
353  break;
354 
355  case WM_PAINT:
356  /* Initialize hdc objects */
357  hdc = BeginPaint(hWnd, &ps);
358  pen = (HPEN)CreatePen(PS_SOLID, 1, WAVEBAR_COLOR);
359  oldpen = (HPEN) SelectObject(hdc, (HBRUSH)pen);
360  if (AUD_OUT->current_status() == snd::WAVEOUT_PLAYING)
361  {
362  samples = AUD_OUT->tot_samples_buf();
363  for (unsigned int i = 0; i < WAVEBAR_CX; ++i)
364  {
365  x = (i * samples) / WAVEBAR_CX;
366  line_h = (AUD_OUT->nsample(x) * max_h) / AUD_OUT->samplevalue_max();
367  if (line_h)
368  {
369  MoveToEx(hdc, i, max_h, 0);
370  LineTo(hdc, i, max_h - (line_h * 2));
371  LineTo(hdc, i, max_h + (line_h * 2));
372  }
373  else
374  {
375  SetPixel(hdc, i, max_h, WAVEBAR_COLOR);
376  }
377  }
378  }
379  else if (AUD_IN->current_status() == snd::WAVEIN_RECORDING)
380  {
381  samples = AUD_IN->tot_samples_buf();
382  for (unsigned int i = 0; i < WAVEBAR_CX; ++i)
383  {
384  x = (i * samples) / WAVEBAR_CX;
385  line_h = (AUD_IN->nsample(x) * max_h) / AUD_IN->samplevalue_max();
386  if (line_h)
387  {
388  MoveToEx(hdc, i, max_h, 0);
389  LineTo(hdc, i, max_h - (line_h * 2));
390  LineTo(hdc, i, max_h + (line_h * 2));
391  }
392  else
393  {
394  SetPixel( hdc, i, max_h, WAVEBAR_COLOR );
395  }
396  }
397  }
398  else
399  {
400  /* In standby mode draw a simple line */
401  MoveToEx(hdc, 0, cli.bottom / 2, 0);
402  LineTo(hdc, WAVEBAR_CX, cli.bottom / 2);
403  }
404 
405  SelectObject(hdc, oldpen);
406  DeleteObject( pen );
407  EndPaint( hWnd, &ps );
408  break;
409 
410  case WM_USER:
411  break;
412 
413  default:
415  }
416 
417  return 0;
418 }
GLsizei samples
Definition: glext.h:7006
FORCEINLINE VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: arm.h:50
Definition: tftpd.h:59
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define WAVEBAR_COLOR
Definition: sndrec32.h:64
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
snd::audio_waveout * AUD_OUT
Definition: sndrec32.cpp:70
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
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:585
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define DefWindowProc
Definition: ros2win.h:31
snd::audio_wavein * AUD_IN
Definition: sndrec32.cpp:71
RECT cli
Definition: sndrec32.cpp:79
#define WM_PAINT
Definition: winuser.h:1602
HDC hdc
Definition: main.c:9
#define WM_USER
Definition: winuser.h:1877
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define WM_CREATE
Definition: winuser.h:1590
LONG bottom
Definition: windef.h:309
#define WAVEBAR_CX
Definition: sndrec32.h:58
LPARAM lParam
Definition: combotst.c:139

Referenced by MyRegisterClass_wave().

◆ write_wav()

BOOL write_wav ( TCHAR f)

Definition at line 1045 of file sndrec32.cpp.

1046 {
1047  HANDLE file;
1048  DWORD written;
1049  BOOL is_writ;
1050  int i;
1051  riff_hdr r;
1052  wave_hdr w;
1053  data_chunk d;
1054 
1056  if (!file)
1057  {
1058  i = MessageBox(main_win,
1059  TEXT("File already exist. Overwrite it?"),
1060  TEXT("Warning"),
1062 
1063  if (i == IDYES)
1064  {
1066  if (!file)
1067  {
1069  TEXT("File Error, CreateFile() failed."),
1070  TEXT("ERROR"),
1071  MB_OK | MB_ICONERROR);
1072 
1073  return FALSE;
1074  }
1075 
1076  } else
1077  return FALSE;
1078  }
1079 
1080  r.magic = 0x46464952;
1081  r.format = 0x45564157;
1082  r.chunksize = 36 + AUD_BUF->bytes_recorded();
1083 
1084  w.Subchunkid = 0x20746d66;
1085  w.Subchunk1Size = 16;
1086  w.AudioFormat = 1;
1087  w.NumChannels = AUD_BUF->audinfo().channels();
1088  w.SampleRate = AUD_BUF->audinfo().sample_rate();
1089  w.ByteRate = AUD_BUF->audinfo().byte_rate();
1090  w.BlockAlign = AUD_BUF->audinfo().block_align();
1091  w.BitsPerSample = AUD_BUF->audinfo().bits();
1092 
1093  d.subc = 0x61746164;
1094  d.subc_size = AUD_BUF->bytes_recorded();
1095 
1096  /* Writing headers */
1097  is_writ = WriteFile(file, (LPCVOID)&r, sizeof(r), &written, 0);
1098  if (!is_writ)
1099  {
1101  TEXT("File Error, WriteFile() failed."),
1102  TEXT("ERROR"),
1103  MB_OK | MB_ICONERROR);
1104 
1105  CloseHandle(file);
1106  return FALSE;
1107  }
1108 
1109  is_writ = WriteFile(file, (LPCVOID)&w, sizeof(w), &written, 0);
1110  if (!is_writ)
1111  {
1113  TEXT("File Error, WriteFile() failed."),
1114  TEXT("ERROR"),
1115  MB_OK | MB_ICONERROR);
1116 
1117  CloseHandle(file);
1118  return FALSE;
1119  }
1120 
1121  is_writ = WriteFile(file, (LPCVOID)&d, sizeof(d), &written, 0);
1122  if (!is_writ)
1123  {
1125  TEXT("File Error, WriteFile() failed."),
1126  TEXT("ERROR"),
1127  MB_OK | MB_ICONERROR);
1128 
1129  CloseHandle(file);
1130  return FALSE;
1131  }
1132 
1133  is_writ = WriteFile(file,
1134  (LPCVOID)AUD_BUF->audio_buffer(),
1135  AUD_BUF->bytes_recorded(),
1136  &written,
1137  0);
1138  if (!is_writ)
1139  {
1141  TEXT("File Error, WriteFile() failed."),
1142  TEXT("ERROR"),
1143  MB_OK | MB_ICONERROR);
1144 
1145  CloseHandle(file);
1146  return FALSE;
1147  }
1148 
1149  CloseHandle(file);
1150  return TRUE;
1151 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:487
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define IDYES
Definition: winuser.h:829
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
#define MB_YESNO
Definition: winuser.h:811
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
#define MB_ICONQUESTION
Definition: winuser.h:783
snd::audio_membuffer * AUD_BUF
Definition: sndrec32.cpp:69
GLfloat f
Definition: glext.h:7540
#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:137
#define MB_ICONERROR
Definition: winuser.h:781
#define MessageBox
Definition: winuser.h:5797
#define CREATE_ALWAYS
Definition: disk.h:72
#define TEXT(s)
Definition: k32.h:26
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
#define MB_OK
Definition: winuser.h:784
CONST void * LPCVOID
Definition: windef.h:191
#define CREATE_NEW
Definition: disk.h:69
HWND main_win
Definition: sndrec32.cpp:37
Definition: fci.c:126

Referenced by WndProc().

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(), printk(), and WndProc_wave().

◆ 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.

Referenced by InitInstance(), InitInstance_wave(), and WndProc().

◆ 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.

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

◆ 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(), and WndProc().

◆ 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.

Referenced by _tWinMain(), and WndProc().

◆ text_rect

RECT text_rect

Definition at line 77 of file sndrec32.cpp.

Referenced by _tWinMain(), ID3DXFontImpl_DrawTextW(), MONTHCAL_PaintTodayTitle(), and WndProc().

◆ wave_win

HWND wave_win

Definition at line 38 of file sndrec32.cpp.

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

◆ 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().