ReactOS  0.4.15-dev-1171-gab82533
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.

◆ BUTPLAY_ID

#define BUTPLAY_ID   2

Definition at line 24 of file sndrec32.h.

◆ BUTREC_ID

#define BUTREC_ID   4

Definition at line 26 of file sndrec32.h.

◆ BUTSTART_ID

#define BUTSTART_ID   0

Definition at line 22 of file sndrec32.h.

◆ BUTSTOP_ID

#define BUTSTOP_ID   3

Definition at line 25 of file sndrec32.h.

◆ BUTTONS_CX

#define BUTTONS_CX   (CONTROLS_CX)

Definition at line 33 of file sndrec32.h.

◆ BUTTONS_CY

#define BUTTONS_CY   100

Definition at line 32 of file sndrec32.h.

◆ BUTTONS_H

#define BUTTONS_H   30

Definition at line 30 of file sndrec32.h.

◆ BUTTONS_SPACE

#define BUTTONS_SPACE   5

Definition at line 34 of file sndrec32.h.

◆ BUTTONS_W

#define BUTTONS_W   60

Definition at line 31 of file sndrec32.h.

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

◆ MAINWINDOW_H

#define MAINWINDOW_H   190

Definition at line 16 of file sndrec32.h.

◆ MAINWINDOW_W

#define MAINWINDOW_W   350

Definition at line 15 of file sndrec32.h.

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

◆ REFRESHA_CY

#define REFRESHA_CY   (REFRESHA_Y + 55)

Definition at line 69 of file sndrec32.h.

◆ REFRESHA_X

#define REFRESHA_X   (STRPOS_X)

Definition at line 66 of file sndrec32.h.

◆ REFRESHA_Y

#define REFRESHA_Y   (STRPOS_Y)

Definition at line 67 of file sndrec32.h.

◆ REFRESHB_CX

#define REFRESHB_CX   (REFRESHB_X + 85)

Definition at line 73 of file sndrec32.h.

◆ REFRESHB_CY

#define REFRESHB_CY   (REFRESHB_Y + 55)

Definition at line 74 of file sndrec32.h.

◆ REFRESHB_X

#define REFRESHB_X   (STRFMT_X)

Definition at line 71 of file sndrec32.h.

◆ REFRESHB_Y

#define REFRESHB_Y   (STRFMT_Y)

Definition at line 72 of file sndrec32.h.

◆ SLIDER_CX

#define SLIDER_CX   CONTROLS_CX

Definition at line 36 of file sndrec32.h.

◆ SLIDER_CY

#define SLIDER_CY   65

Definition at line 37 of file sndrec32.h.

◆ SLIDER_H

#define SLIDER_H   30

Definition at line 38 of file sndrec32.h.

◆ SLIDER_ID

#define SLIDER_ID   5

Definition at line 27 of file sndrec32.h.

◆ SLIDER_W

#define SLIDER_W   320

Definition at line 39 of file sndrec32.h.

◆ STRBUF_X

#define STRBUF_X   (STRDUR_X)

Definition at line 47 of file sndrec32.h.

◆ STRBUF_Y

#define STRBUF_Y   (STRDUR_Y + 13)

Definition at line 48 of file sndrec32.h.

◆ STRCHAN_X

#define STRCHAN_X   (STRFMT_X)

Definition at line 53 of file sndrec32.h.

◆ STRCHAN_Y

#define STRCHAN_Y   (STRFMT_Y + 13)

Definition at line 54 of file sndrec32.h.

◆ STRDUR_X

#define STRDUR_X   (STRPOS_X)

Definition at line 44 of file sndrec32.h.

◆ STRDUR_Y

#define STRDUR_Y   (STRPOS_Y + 13)

Definition at line 45 of file sndrec32.h.

◆ STRFMT_X

#define STRFMT_X   10

Definition at line 50 of file sndrec32.h.

◆ STRFMT_Y

#define STRFMT_Y   (STRPOS_Y)

Definition at line 51 of file sndrec32.h.

◆ STRPOS_X

#define STRPOS_X   240

Definition at line 41 of file sndrec32.h.

◆ STRPOS_Y

#define STRPOS_Y   5

Definition at line 42 of file sndrec32.h.

◆ WAVEBAR_COLOR

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

Definition at line 64 of file sndrec32.h.

◆ WAVEBAR_CX

#define WAVEBAR_CX   130

Definition at line 58 of file sndrec32.h.

◆ WAVEBAR_CY

#define WAVEBAR_CY   50

Definition at line 59 of file sndrec32.h.

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

◆ WAVEBAR_TIMERTIME

#define WAVEBAR_TIMERTIME   80

Definition at line 62 of file sndrec32.h.

◆ WAVEBAR_X

#define WAVEBAR_X   (CONTROLS_CX + 90)

Definition at line 56 of file sndrec32.h.

◆ WAVEBAR_Y

#define WAVEBAR_Y   (STRPOS_Y)

Definition at line 57 of file sndrec32.h.

Function Documentation

◆ Buttons_proc()

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

◆ disable_but()

VOID disable_but ( DWORD  )

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  )

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

◆ l_audio_arrival()

void l_audio_arrival ( unsigned int  )

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  )

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

◆ open_wav()

BOOL open_wav ( TCHAR )

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

◆ write_wav()

BOOL write_wav ( TCHAR )

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