ReactOS 0.4.16-dev-292-gbbdcc14
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  id)

Definition at line 917 of file sndrec32.cpp.

918{
921}
#define TRUE
Definition: types.h:120
GLuint id
Definition: glext.h:5910
HBITMAP butbmps_dis[5]
Definition: sndrec32.cpp:42
BOOL butdisabled[5]
Definition: sndrec32.cpp:45
HWND buttons[5]
Definition: sndrec32.cpp:40
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define IMAGE_BITMAP
Definition: winuser.h:211
#define BM_SETIMAGE
Definition: winuser.h:1925
#define SendMessage
Definition: winuser.h:5855

Referenced by WndProc().

◆ enable_but()

VOID enable_but ( DWORD  id)

Definition at line 911 of file sndrec32.cpp.

912{
915}
#define FALSE
Definition: types.h:117
HBITMAP butbmps[5]
Definition: sndrec32.cpp:41

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

◆ l_audio_arrival()

void l_audio_arrival ( unsigned int  samples_arrival)

Definition at line 902 of file sndrec32.cpp.

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

Referenced by _tWinMain().

◆ l_buffer_resized()

void l_buffer_resized ( unsigned int  new_size)

Definition at line 907 of file sndrec32.cpp.

908{
909}

Referenced by _tWinMain().

◆ l_play_finished()

void l_play_finished ( void  )

Definition at line 890 of file sndrec32.cpp.

891{
892 stopped_flag = true;
893
898
900}
BOOL stopped_flag
Definition: sndrec32.cpp:46
VOID enable_but(DWORD id)
Definition: sndrec32.cpp:911
HWND wave_win
Definition: sndrec32.cpp:38
#define BUTREC_ID
Definition: sndrec32.h:26
#define BUTPLAY_ID
Definition: sndrec32.h:24
#define BUTEND_ID
Definition: sndrec32.h:23
#define BUTSTART_ID
Definition: sndrec32.h:22
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by _tWinMain().

◆ open_wav()

BOOL open_wav ( TCHAR f)

Definition at line 923 of file sndrec32.cpp.

924{
925 HANDLE file;
926
927 riff_hdr r;
928 wave_hdr w;
930
931 BOOL b;
932
933 DWORD bytes_recorded_in_wav = 0;
934 DWORD is_read = 0;
935
936 file = CreateFile(f,
938 0,
939 0,
942 0);
943 if (!file)
944 {
946 TEXT("Cannot open file. CreateFile() error."),
947 TEXT("ERROR"),
949
950 return FALSE;
951 }
952
953 b = ReadFile(file, (LPVOID)&r, sizeof(r), &is_read, 0);
954 if (!b)
955 {
957 TEXT("Cannot read RIFF header."),
958 TEXT("ERROR"),
960
962 return FALSE;
963 }
964
965 b = ReadFile(file, (LPVOID)&w, sizeof(w), &is_read, 0);
966 if (!b)
967 {
969 TEXT("Cannot read WAVE header."),
970 TEXT("ERROR"),
972
974 return FALSE;
975 }
976
977 b = ReadFile(file, (LPVOID)&d, sizeof(d), &is_read, 0);
978 if (!b)
979 {
981 TEXT("Cannot read WAVE subchunk."),
982 TEXT("ERROR"),
984
986 return FALSE;
987 }
988
989 bytes_recorded_in_wav = r.chunksize - 36;
990 if (bytes_recorded_in_wav == 0)
991 {
993 TEXT("Cannot read file. No audio data."),
994 TEXT("ERROR"),
996
998 return FALSE;
999 }
1000
1001 snd::audio_format openfmt(w.SampleRate, w.BitsPerSample, w.NumChannels);
1002
1003 AUD_BUF->clear();
1004 AUD_BUF->alloc_bytes(bytes_recorded_in_wav);
1005
1006 b = ReadFile(file,
1007 (LPVOID)AUD_BUF->audio_buffer(),
1008 bytes_recorded_in_wav,
1009 &is_read,
1010 0);
1011
1012 AUD_BUF->set_b_received(bytes_recorded_in_wav);
1013
1014 if ((!b) || (is_read != bytes_recorded_in_wav))
1015 {
1017 TEXT("Cannot read file. Error reading audio data."),
1018 TEXT("ERROR"),
1020
1022
1023 AUD_BUF->reset();
1024 return FALSE;
1025 }
1026
1028
1034
1035 samples_max = AUD_BUF->samples_received();
1036
1037 isnew = FALSE;
1038
1039 return TRUE;
1040}
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define GENERIC_READ
Definition: compat.h:135
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLfloat f
Definition: glext.h:7540
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define TEXT(s)
Definition: k32.h:26
#define d
Definition: ke_i.h:81
#define b
Definition: ke_i.h:79
HWND main_win
Definition: sndrec32.cpp:37
BOOL isnew
Definition: sndrec32.cpp:47
snd::audio_membuffer * AUD_BUF
Definition: sndrec32.cpp:69
#define BUTSTOP_ID
Definition: sndrec32.h:25
Definition: fci.c:127
#define CreateFile
Definition: winbase.h:3774
#define MB_ICONERROR
Definition: winuser.h:790
#define MB_OK
Definition: winuser.h:793
#define MessageBox
Definition: winuser.h:5834

Referenced by WndProc().

◆ write_wav()

BOOL write_wav ( TCHAR f)

Definition at line 1043 of file sndrec32.cpp.

1044{
1045 HANDLE file;
1046 DWORD written;
1047 BOOL is_writ;
1048 int i;
1049 riff_hdr r;
1050 wave_hdr w;
1051 data_chunk d;
1052
1054 if (!file)
1055 {
1057 TEXT("File already exist. Overwrite it?"),
1058 TEXT("Warning"),
1060
1061 if (i == IDYES)
1062 {
1064 if (!file)
1065 {
1067 TEXT("File Error, CreateFile() failed."),
1068 TEXT("ERROR"),
1070
1071 return FALSE;
1072 }
1073
1074 } else
1075 return FALSE;
1076 }
1077
1078 r.magic = 0x46464952;
1079 r.format = 0x45564157;
1080 r.chunksize = 36 + AUD_BUF->bytes_recorded();
1081
1082 w.Subchunkid = 0x20746d66;
1083 w.Subchunk1Size = 16;
1084 w.AudioFormat = 1;
1085 w.NumChannels = AUD_BUF->audinfo().channels();
1086 w.SampleRate = AUD_BUF->audinfo().sample_rate();
1087 w.ByteRate = AUD_BUF->audinfo().byte_rate();
1088 w.BlockAlign = AUD_BUF->audinfo().block_align();
1089 w.BitsPerSample = AUD_BUF->audinfo().bits();
1090
1091 d.subc = 0x61746164;
1092 d.subc_size = AUD_BUF->bytes_recorded();
1093
1094 /* Writing headers */
1095 is_writ = WriteFile(file, (LPCVOID)&r, sizeof(r), &written, 0);
1096 if (!is_writ)
1097 {
1099 TEXT("File Error, WriteFile() failed."),
1100 TEXT("ERROR"),
1102
1104 return FALSE;
1105 }
1106
1107 is_writ = WriteFile(file, (LPCVOID)&w, sizeof(w), &written, 0);
1108 if (!is_writ)
1109 {
1111 TEXT("File Error, WriteFile() failed."),
1112 TEXT("ERROR"),
1114
1116 return FALSE;
1117 }
1118
1119 is_writ = WriteFile(file, (LPCVOID)&d, sizeof(d), &written, 0);
1120 if (!is_writ)
1121 {
1123 TEXT("File Error, WriteFile() failed."),
1124 TEXT("ERROR"),
1126
1128 return FALSE;
1129 }
1130
1131 is_writ = WriteFile(file,
1132 (LPCVOID)AUD_BUF->audio_buffer(),
1133 AUD_BUF->bytes_recorded(),
1134 &written,
1135 0);
1136 if (!is_writ)
1137 {
1139 TEXT("File Error, WriteFile() failed."),
1140 TEXT("ERROR"),
1142
1144 return FALSE;
1145 }
1146
1148 return TRUE;
1149}
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
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 CREATE_ALWAYS
Definition: disk.h:72
#define CREATE_NEW
Definition: disk.h:69
#define GENERIC_WRITE
Definition: nt_native.h:90
CONST void * LPCVOID
Definition: windef.h:191
#define MB_YESNO
Definition: winuser.h:820
#define MB_ICONQUESTION
Definition: winuser.h:792
#define IDYES
Definition: winuser.h:838

Referenced by WndProc().