ReactOS  0.4.12-dev-14-gd0c8636
sndrec32.h File Reference
#include "resource.h"
#include "audio_api.hpp"
Include dependency graph for sndrec32.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  riff_hdr
 
struct  wave_hdr
 
struct  data_chunk
 

Macros

#define MAX_LOADSTRING   100
 
#define MAINWINDOW_W   350
 
#define MAINWINDOW_H   190
 
#define CONTROLS_CX   10
 
#define INITIAL_BUFREC_SECONDS   30.0f
 
#define BUTSTART_ID   0
 
#define BUTEND_ID   1
 
#define BUTPLAY_ID   2
 
#define BUTSTOP_ID   3
 
#define BUTREC_ID   4
 
#define SLIDER_ID   5
 
#define WAVEBAR_ID   6
 
#define BUTTONS_H   30
 
#define BUTTONS_W   60
 
#define BUTTONS_CY   100
 
#define BUTTONS_CX   (CONTROLS_CX)
 
#define BUTTONS_SPACE   5
 
#define SLIDER_CX   CONTROLS_CX
 
#define SLIDER_CY   65
 
#define SLIDER_H   30
 
#define SLIDER_W   320
 
#define STRPOS_X   240
 
#define STRPOS_Y   5
 
#define STRDUR_X   (STRPOS_X)
 
#define STRDUR_Y   (STRPOS_Y + 13)
 
#define STRBUF_X   (STRDUR_X)
 
#define STRBUF_Y   (STRDUR_Y + 13)
 
#define STRFMT_X   10
 
#define STRFMT_Y   (STRPOS_Y)
 
#define STRCHAN_X   (STRFMT_X)
 
#define STRCHAN_Y   (STRFMT_Y + 13)
 
#define WAVEBAR_X   (CONTROLS_CX + 90)
 
#define WAVEBAR_Y   (STRPOS_Y)
 
#define WAVEBAR_CX   130
 
#define WAVEBAR_CY   50
 
#define WAVEBAR_TIMERID   2
 
#define WAVEBAR_TIMERTIME   80
 
#define WAVEBAR_COLOR   (RGB(0, 0, 255))
 
#define REFRESHA_X   (STRPOS_X)
 
#define REFRESHA_Y   (STRPOS_Y)
 
#define REFRESHA_CX   (REFRESHA_X + 100)
 
#define REFRESHA_CY   (REFRESHA_Y + 55)
 
#define REFRESHB_X   (STRFMT_X)
 
#define REFRESHB_Y   (STRFMT_Y)
 
#define REFRESHB_CX   (REFRESHB_X + 85)
 
#define REFRESHB_CY   (REFRESHB_Y + 55)
 

Functions

LRESULT CALLBACK Buttons_proc (HWND, UINT, WPARAM, LPARAM)
 
BOOL write_wav (TCHAR *)
 
BOOL open_wav (TCHAR *)
 
VOID enable_but (DWORD)
 
VOID disable_but (DWORD)
 
void l_play_finished (void)
 
void l_audio_arrival (unsigned int)
 
void l_buffer_resized (unsigned int)
 

Macro Definition Documentation

◆ BUTEND_ID

#define BUTEND_ID   1

Definition at line 23 of file sndrec32.h.

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

◆ BUTPLAY_ID

#define BUTPLAY_ID   2

Definition at line 24 of file sndrec32.h.

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

◆ BUTREC_ID

#define BUTREC_ID   4

Definition at line 26 of file sndrec32.h.

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

◆ BUTSTART_ID

#define BUTSTART_ID   0

Definition at line 22 of file sndrec32.h.

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

◆ BUTSTOP_ID

#define BUTSTOP_ID   3

Definition at line 25 of file sndrec32.h.

Referenced by open_wav(), and WndProc().

◆ BUTTONS_CX

#define BUTTONS_CX   (CONTROLS_CX)

Definition at line 33 of file sndrec32.h.

Referenced by WndProc().

◆ BUTTONS_CY

#define BUTTONS_CY   100

Definition at line 32 of file sndrec32.h.

Referenced by WndProc().

◆ BUTTONS_H

#define BUTTONS_H   30

Definition at line 30 of file sndrec32.h.

Referenced by WndProc().

◆ BUTTONS_SPACE

#define BUTTONS_SPACE   5

Definition at line 34 of file sndrec32.h.

Referenced by WndProc().

◆ BUTTONS_W

#define BUTTONS_W   60

Definition at line 31 of file sndrec32.h.

Referenced by WndProc().

◆ CONTROLS_CX

#define CONTROLS_CX   10

Definition at line 18 of file sndrec32.h.

◆ INITIAL_BUFREC_SECONDS

#define INITIAL_BUFREC_SECONDS   30.0f

Definition at line 20 of file sndrec32.h.

Referenced by _tWinMain().

◆ MAINWINDOW_H

#define MAINWINDOW_H   190

Definition at line 16 of file sndrec32.h.

Referenced by InitInstance().

◆ MAINWINDOW_W

#define MAINWINDOW_W   350

Definition at line 15 of file sndrec32.h.

Referenced by InitInstance().

◆ MAX_LOADSTRING

#define MAX_LOADSTRING   100

Definition at line 13 of file sndrec32.h.

◆ REFRESHA_CX

#define REFRESHA_CX   (REFRESHA_X + 100)

Definition at line 68 of file sndrec32.h.

Referenced by _tWinMain().

◆ REFRESHA_CY

#define REFRESHA_CY   (REFRESHA_Y + 55)

Definition at line 69 of file sndrec32.h.

Referenced by _tWinMain().

◆ REFRESHA_X

#define REFRESHA_X   (STRPOS_X)

Definition at line 66 of file sndrec32.h.

Referenced by _tWinMain().

◆ REFRESHA_Y

#define REFRESHA_Y   (STRPOS_Y)

Definition at line 67 of file sndrec32.h.

Referenced by _tWinMain().

◆ REFRESHB_CX

#define REFRESHB_CX   (REFRESHB_X + 85)

Definition at line 73 of file sndrec32.h.

Referenced by _tWinMain().

◆ REFRESHB_CY

#define REFRESHB_CY   (REFRESHB_Y + 55)

Definition at line 74 of file sndrec32.h.

Referenced by _tWinMain().

◆ REFRESHB_X

#define REFRESHB_X   (STRFMT_X)

Definition at line 71 of file sndrec32.h.

Referenced by _tWinMain().

◆ REFRESHB_Y

#define REFRESHB_Y   (STRFMT_Y)

Definition at line 72 of file sndrec32.h.

Referenced by _tWinMain().

◆ SLIDER_CX

#define SLIDER_CX   CONTROLS_CX

Definition at line 36 of file sndrec32.h.

Referenced by WndProc().

◆ SLIDER_CY

#define SLIDER_CY   65

Definition at line 37 of file sndrec32.h.

Referenced by WndProc().

◆ SLIDER_H

#define SLIDER_H   30

Definition at line 38 of file sndrec32.h.

Referenced by WndProc().

◆ SLIDER_ID

#define SLIDER_ID   5

Definition at line 27 of file sndrec32.h.

Referenced by WndProc().

◆ SLIDER_W

#define SLIDER_W   320

Definition at line 39 of file sndrec32.h.

Referenced by _tWinMain(), and WndProc().

◆ STRBUF_X

#define STRBUF_X   (STRDUR_X)

Definition at line 47 of file sndrec32.h.

Referenced by WndProc().

◆ STRBUF_Y

#define STRBUF_Y   (STRDUR_Y + 13)

Definition at line 48 of file sndrec32.h.

Referenced by WndProc().

◆ STRCHAN_X

#define STRCHAN_X   (STRFMT_X)

Definition at line 53 of file sndrec32.h.

Referenced by WndProc().

◆ STRCHAN_Y

#define STRCHAN_Y   (STRFMT_Y + 13)

Definition at line 54 of file sndrec32.h.

Referenced by WndProc().

◆ STRDUR_X

#define STRDUR_X   (STRPOS_X)

Definition at line 44 of file sndrec32.h.

Referenced by WndProc().

◆ STRDUR_Y

#define STRDUR_Y   (STRPOS_Y + 13)

Definition at line 45 of file sndrec32.h.

Referenced by WndProc().

◆ STRFMT_X

#define STRFMT_X   10

Definition at line 50 of file sndrec32.h.

Referenced by WndProc().

◆ STRFMT_Y

#define STRFMT_Y   (STRPOS_Y)

Definition at line 51 of file sndrec32.h.

Referenced by WndProc().

◆ STRPOS_X

#define STRPOS_X   240

Definition at line 41 of file sndrec32.h.

Referenced by WndProc().

◆ STRPOS_Y

#define STRPOS_Y   5

Definition at line 42 of file sndrec32.h.

Referenced by WndProc().

◆ WAVEBAR_COLOR

#define WAVEBAR_COLOR   (RGB(0, 0, 255))

Definition at line 64 of file sndrec32.h.

Referenced by WndProc_wave().

◆ WAVEBAR_CX

#define WAVEBAR_CX   130

Definition at line 58 of file sndrec32.h.

Referenced by InitInstance_wave(), and WndProc_wave().

◆ WAVEBAR_CY

#define WAVEBAR_CY   50

Definition at line 59 of file sndrec32.h.

Referenced by InitInstance_wave().

◆ WAVEBAR_ID

#define WAVEBAR_ID   6

Definition at line 28 of file sndrec32.h.

◆ WAVEBAR_TIMERID

#define WAVEBAR_TIMERID   2

Definition at line 61 of file sndrec32.h.

Referenced by WndProc().

◆ WAVEBAR_TIMERTIME

#define WAVEBAR_TIMERTIME   80

Definition at line 62 of file sndrec32.h.

Referenced by WndProc().

◆ WAVEBAR_X

#define WAVEBAR_X   (CONTROLS_CX + 90)

Definition at line 56 of file sndrec32.h.

Referenced by InitInstance_wave().

◆ WAVEBAR_Y

#define WAVEBAR_Y   (STRPOS_Y)

Definition at line 57 of file sndrec32.h.

Referenced by InitInstance_wave().

Function Documentation

◆ Buttons_proc()

LRESULT CALLBACK Buttons_proc ( HWND  ,
UINT  ,
WPARAM  ,
LPARAM   
)

◆ disable_but()

VOID disable_but ( DWORD  )

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  )

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

◆ l_audio_arrival()

void l_audio_arrival ( unsigned  int)

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)

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

◆ open_wav()

BOOL open_wav ( TCHAR )

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

◆ write_wav()

BOOL write_wav ( TCHAR )

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