mirror of
https://github.com/reactos/reactos.git
synced 2025-07-05 19:41:21 +00:00
SndRec32 patch by Marco Pagliaricci, bug #4978.
svn path=/trunk/; revision=44384
This commit is contained in:
parent
76e69bee97
commit
64c6953516
12 changed files with 236 additions and 148 deletions
15
reactos/base/applications/sndrec32/audio_api.hpp
Normal file
15
reactos/base/applications/sndrec32/audio_api.hpp
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef __AUDIO_API__
|
||||||
|
#define __AUDIO_API__
|
||||||
|
|
||||||
|
#include "audio_def.hpp"
|
||||||
|
|
||||||
|
#include "audio_format.hpp"
|
||||||
|
#include "audio_membuffer.hpp"
|
||||||
|
#include "audio_producer.hpp"
|
||||||
|
#include "audio_receiver.hpp"
|
||||||
|
#include "audio_resampler_acm.hpp"
|
||||||
|
#include "audio_wavein.hpp"
|
||||||
|
#include "audio_waveout.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -9,10 +9,13 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#define _AUDIO_DEFAULT_FORMAT A44100_16BIT_STEREO
|
#define _AUDIO_DEFAULT_FORMAT A44100_16BIT_STEREO
|
||||||
|
|
||||||
#define _AUDIO_DEFAULT_WAVEINBUFFERS 8
|
#define _AUDIO_DEFAULT_WAVEINBUFFERS 8
|
||||||
#define _AUDIO_DEFAULT_WAVEINBUFSECS 0.1f
|
#define _AUDIO_DEFAULT_WAVEINBUFSECS 0.1f
|
||||||
#define _AUDIO_DEFAULT_WAVEOUTBUFFERS 8
|
|
||||||
#define _AUDIO_DEFAULT_WAVEOUTBUFSECS 0.1f
|
#define _AUDIO_DEFAULT_WAVEOUTBUFFERS 2
|
||||||
|
#define _AUDIO_DEFAULT_WAVEOUTBUFSECS 1.0f
|
||||||
|
|
||||||
#define _AUDIO_DEFAULT_BUFSECS 1.0f
|
#define _AUDIO_DEFAULT_BUFSECS 1.0f
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +32,9 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <mmsystem.h> //Windows MultiMedia (WINMM) audio apis
|
#include <mmsystem.h> //Windows MultiMedia (WINMM) audio apis
|
||||||
#include <mmreg.h> //codecs stuff
|
#include <mmreg.h> //codecs stuff
|
||||||
#include <Msacm.h> //codecs stuff
|
#include <msacm.h> //codecs stuff
|
||||||
|
|
||||||
|
//#pragma comment(lib, "winmm.lib")
|
||||||
|
//#pragma comment(lib, "msacm32.lib")
|
||||||
|
|
||||||
#endif //ifdef _AUDIO_DEF__H_
|
#endif //ifdef _AUDIO_DEF__H_
|
||||||
|
|
|
@ -122,6 +122,13 @@ class audio_format
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int bytes_in_samples( unsigned int samples ) const
|
||||||
|
{
|
||||||
|
|
||||||
|
return (( samples * ( bits_psample / 8 )) * chan );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,13 @@
|
||||||
_AUDIO_NAMESPACE_START_
|
_AUDIO_NAMESPACE_START_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
/////// Protected Functions /////////
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
audio_membuffer::alloc_mem_( unsigned int bytes )
|
audio_membuffer::alloc_mem_( unsigned int bytes )
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* PROGRAMMERS: Marco Pagliaricci <ms_blue (at) hotmail (dot) it>
|
* PROGRAMMERS: Marco Pagliaricci <ms_blue (at) hotmail (dot) it>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
#include "StdAfx.h"
|
|
||||||
#include "audio_producer.hpp"
|
#include "audio_producer.hpp"
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ void
|
||||||
if ( err != MMSYSERR_NOERROR )
|
if ( err != MMSYSERR_NOERROR )
|
||||||
{
|
{
|
||||||
//TODO: throw error
|
//TODO: throw error
|
||||||
printf("acmOpen error: %i\n", err);
|
MessageBox( 0, _T("acmOpen error: %i"), _T("ERROR"), MB_ICONERROR );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,8 @@ void
|
||||||
if ( err != MMSYSERR_NOERROR )
|
if ( err != MMSYSERR_NOERROR )
|
||||||
{
|
{
|
||||||
//TODO: throw error
|
//TODO: throw error
|
||||||
printf("acmSize error\n");
|
MessageBox( 0, _T("acmStreamSize error"), _T("ERROR"), MB_ICONERROR );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +179,9 @@ void
|
||||||
if ( err != MMSYSERR_NOERROR )
|
if ( err != MMSYSERR_NOERROR )
|
||||||
{
|
{
|
||||||
//TODO: throw error
|
//TODO: throw error
|
||||||
printf("prep. header error\n");
|
MessageBox( 0, _T("acmStreamPrepareHeader error"), _T("ERROR"), MB_ICONERROR );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -243,6 +246,8 @@ void
|
||||||
|
|
||||||
|
|
||||||
//TODO: throw error
|
//TODO: throw error
|
||||||
|
MessageBox( 0, _T("acmStreamUnPrepareHeader error"), _T("ERROR"), MB_ICONERROR );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,6 +286,9 @@ void
|
||||||
|
|
||||||
//TODO: throw error!
|
//TODO: throw error!
|
||||||
|
|
||||||
|
MessageBox( 0, _T("acmStreamClose error"), _T("ERROR"), MB_ICONERROR );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -357,7 +365,8 @@ void
|
||||||
if ( err != MMSYSERR_NOERROR )
|
if ( err != MMSYSERR_NOERROR )
|
||||||
{
|
{
|
||||||
//TODO: throw error
|
//TODO: throw error
|
||||||
printf("acm convert error\n");
|
MessageBox( 0, _T("acmStreamConvert error"), _T("ERROR"), MB_ICONERROR );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,7 +378,7 @@ void
|
||||||
while(( ACMSTREAMHEADER_STATUSF_DONE & acm_header.fdwStatus ) == 0 );
|
while(( ACMSTREAMHEADER_STATUSF_DONE & acm_header.fdwStatus ) == 0 );
|
||||||
|
|
||||||
|
|
||||||
printf("Processed successfully %lu bytes of audio.\n", acm_header.cbDstLengthUsed );
|
//printf("Processed successfully %i bytes of audio.\n", acm_header.cbDstLengthUsed );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -531,7 +531,7 @@ audio_waveout::play( void )
|
||||||
// Reads the audio from the start.
|
// Reads the audio from the start.
|
||||||
//
|
//
|
||||||
|
|
||||||
audio_buf.set_position_start();
|
//audio_buf.set_position_start();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ audio_waveout::stop( void )
|
||||||
if ( err != MMSYSERR_NOERROR )
|
if ( err != MMSYSERR_NOERROR )
|
||||||
{
|
{
|
||||||
|
|
||||||
MessageBox(0, _T("err waveout reset.\n"),_T("ERROR"), 0);
|
MessageBox(0, _T("err WaveOutReset.\n"),_T("ERROR"), 0);
|
||||||
//TODO: throw error
|
//TODO: throw error
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,14 @@
|
||||||
// Used by reactOS_sndrec32.rc
|
// Used by reactOS_sndrec32.rc
|
||||||
//
|
//
|
||||||
#define IDC_MYICON 2
|
#define IDC_MYICON 2
|
||||||
|
#define IDB_BITMAP2_STOP_DIS 8
|
||||||
#define IDD_REACTOS_SNDREC32_DIALOG 102
|
#define IDD_REACTOS_SNDREC32_DIALOG 102
|
||||||
#define IDS_APP_TITLE 103
|
#define IDS_APP_TITLE 103
|
||||||
#define IDD_ABOUTBOX 103
|
#define IDD_ABOUTBOX 103
|
||||||
#define IDM_ABOUT 104
|
#define IDM_ABOUT 104
|
||||||
#define IDI_REACTOS_SNDREC32 107
|
#define IDI_REACTOS_SNDREC32 107
|
||||||
#define IDI_REACTOS_SNDREC32LL 107
|
#define IDI_REACTOS_SNDREC32LL 107
|
||||||
|
#define IDI_SNDREC32 107
|
||||||
#define IDI_SMALL 108
|
#define IDI_SMALL 108
|
||||||
#define IDC_REACTOS_SNDREC32 109
|
#define IDC_REACTOS_SNDREC32 109
|
||||||
#define IDR_MAINFRAME 128
|
#define IDR_MAINFRAME 128
|
||||||
|
@ -21,6 +23,11 @@
|
||||||
#define IDB_BITMAP2_REC 137
|
#define IDB_BITMAP2_REC 137
|
||||||
#define IDI_ICON1 138
|
#define IDI_ICON1 138
|
||||||
#define IDR_MENU1 139
|
#define IDR_MENU1 139
|
||||||
|
#define IDI_ICON2 140
|
||||||
|
#define IDB_BITMAP2_END_DIS 141
|
||||||
|
#define IDB_BITMAP2_PLAY_DIS 142
|
||||||
|
#define IDB_BITMAP2_REC_DIS 143
|
||||||
|
#define IDB_BITMAP2_START_DIS 144
|
||||||
#define ID_FILE_NEW 32771
|
#define ID_FILE_NEW 32771
|
||||||
#define ID_FILE_OPEN 32772
|
#define ID_FILE_OPEN 32772
|
||||||
#define ID_FILE_SAVE 32773
|
#define ID_FILE_SAVE 32773
|
||||||
|
@ -36,7 +43,7 @@
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NO_MFC 1
|
#define _APS_NO_MFC 1
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 140
|
#define _APS_NEXT_RESOURCE_VALUE 145
|
||||||
#define _APS_NEXT_COMMAND_VALUE 32779
|
#define _APS_NEXT_COMMAND_VALUE 32779
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||||
#define _APS_NEXT_SYMED_VALUE 110
|
#define _APS_NEXT_SYMED_VALUE 110
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "sndrec32.h"
|
#include "sndrec32.h"
|
||||||
|
|
||||||
#include "kkaudio.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#pragma comment(lib, "comctl32.lib")
|
||||||
|
|
||||||
|
|
||||||
HINSTANCE hInst;
|
HINSTANCE hInst;
|
||||||
TCHAR szTitle[MAX_LOADSTRING];
|
TCHAR szTitle[MAX_LOADSTRING];
|
||||||
TCHAR szWindowClass[MAX_LOADSTRING];
|
TCHAR szWindowClass[MAX_LOADSTRING];
|
||||||
|
@ -31,6 +33,7 @@ HWND main_win;
|
||||||
HWND slider;
|
HWND slider;
|
||||||
HWND buttons[5];
|
HWND buttons[5];
|
||||||
HBITMAP butbmps[5];
|
HBITMAP butbmps[5];
|
||||||
|
HBITMAP butbmps_dis[5];
|
||||||
WNDPROC buttons_std_proc;
|
WNDPROC buttons_std_proc;
|
||||||
|
|
||||||
BOOL butdisabled[5];
|
BOOL butdisabled[5];
|
||||||
|
@ -42,19 +45,15 @@ DWORD slider_pos;
|
||||||
WORD slider_min;
|
WORD slider_min;
|
||||||
WORD slider_max;
|
WORD slider_max;
|
||||||
|
|
||||||
long long samples_max;
|
DWORD samples_max;
|
||||||
|
|
||||||
OPENFILENAME ofn;
|
OPENFILENAME ofn;
|
||||||
TCHAR file_path[MAX_PATH];
|
TCHAR file_path[MAX_PATH];
|
||||||
BOOL path_set;
|
BOOL path_set;
|
||||||
|
|
||||||
using snd::audio_membuffer;
|
snd::audio_membuffer * AUD_BUF;
|
||||||
using snd::audio_wavein;
|
snd::audio_waveout * AUD_OUT;
|
||||||
using snd::audio_waveout;
|
snd::audio_wavein * AUD_IN;
|
||||||
|
|
||||||
audio_membuffer * AUD_BUF;
|
|
||||||
audio_waveout * AUD_OUT;
|
|
||||||
audio_wavein * AUD_IN;
|
|
||||||
|
|
||||||
|
|
||||||
BOOL s_recording;
|
BOOL s_recording;
|
||||||
|
@ -88,9 +87,11 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
butbmps[3] = LoadBitmap( hInstance, MAKEINTRESOURCE( IDB_BITMAP2_STOP ));
|
butbmps[3] = LoadBitmap( hInstance, MAKEINTRESOURCE( IDB_BITMAP2_STOP ));
|
||||||
butbmps[4] = LoadBitmap( hInstance, MAKEINTRESOURCE( IDB_BITMAP2_REC ));
|
butbmps[4] = LoadBitmap( hInstance, MAKEINTRESOURCE( IDB_BITMAP2_REC ));
|
||||||
|
|
||||||
|
butbmps_dis[0] = LoadBitmap( hInstance, MAKEINTRESOURCE( IDB_BITMAP2_START_DIS ));
|
||||||
|
butbmps_dis[1] = LoadBitmap( hInstance, MAKEINTRESOURCE( IDB_BITMAP2_END_DIS ));
|
||||||
|
butbmps_dis[2] = LoadBitmap( hInstance, MAKEINTRESOURCE( IDB_BITMAP2_PLAY_DIS ));
|
||||||
|
butbmps_dis[3] = LoadBitmap( hInstance, MAKEINTRESOURCE( IDB_BITMAP2_STOP_DIS ));
|
||||||
|
butbmps_dis[4] = LoadBitmap( hInstance, MAKEINTRESOURCE( IDB_BITMAP2_REC_DIS ));
|
||||||
|
|
||||||
|
|
||||||
snd::audio_membuffer AUD_buffer( snd::A44100_16BIT_STEREO );
|
snd::audio_membuffer AUD_buffer( snd::A44100_16BIT_STEREO );
|
||||||
|
@ -123,10 +124,16 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
samples_max = AUD_buffer.total_samples();
|
samples_max = AUD_buffer.total_samples();
|
||||||
|
|
||||||
|
|
||||||
|
LoadString(hInstance,
|
||||||
|
IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LoadString(hInstance,
|
||||||
|
IDC_REACTOS_SNDREC32, szWindowClass, MAX_LOADSTRING);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
|
||||||
LoadString(hInstance, IDC_REACTOS_SNDREC32, szWindowClass, MAX_LOADSTRING);
|
|
||||||
MyRegisterClass(hInstance);
|
MyRegisterClass(hInstance);
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,7 +143,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_REACTOS_SNDREC32));
|
hAccelTable = LoadAccelerators(hInstance,
|
||||||
|
MAKEINTRESOURCE( IDC_REACTOS_SNDREC32 ));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,12 +196,12 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
|
||||||
wcex.cbClsExtra = 0;
|
wcex.cbClsExtra = 0;
|
||||||
wcex.cbWndExtra = 0;
|
wcex.cbWndExtra = 0;
|
||||||
wcex.hInstance = hInstance;
|
wcex.hInstance = hInstance;
|
||||||
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REACTOS_SNDREC32LL));
|
wcex.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_SNDREC32 ));
|
||||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
wcex.hbrBackground = (HBRUSH)(16);
|
wcex.hbrBackground = (HBRUSH)(16);
|
||||||
wcex.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
|
wcex.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
|
||||||
wcex.lpszClassName = szWindowClass;
|
wcex.lpszClassName = szWindowClass;
|
||||||
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_REACTOS_SNDREC32LL));
|
wcex.hIconSm = LoadIcon( wcex.hInstance, MAKEINTRESOURCE( IDI_SNDREC32 ));
|
||||||
|
|
||||||
|
|
||||||
return RegisterClassEx(&wcex);
|
return RegisterClassEx(&wcex);
|
||||||
|
@ -284,9 +292,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
butdisabled[ i ] = TRUE;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Realize the button bmp image
|
// Realize the button bmp image
|
||||||
|
@ -294,9 +299,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
SendMessage(buttons[i], BM_SETIMAGE, ( WPARAM )IMAGE_BITMAP, ( LPARAM )butbmps[i]);
|
SendMessage(buttons[i], BM_SETIMAGE, ( WPARAM )IMAGE_BITMAP, ( LPARAM )butbmps[i]);
|
||||||
|
|
||||||
|
|
||||||
UpdateWindow( buttons[i] );
|
UpdateWindow( buttons[i] );
|
||||||
|
|
||||||
|
disable_but( i );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -325,8 +331,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
// Sets slider limits
|
// Sets slider limits
|
||||||
//
|
//
|
||||||
|
|
||||||
//slider_min = 0;
|
|
||||||
//slider_max = 100;
|
|
||||||
|
|
||||||
SendMessage(
|
SendMessage(
|
||||||
slider,
|
slider,
|
||||||
|
@ -338,12 +342,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
UpdateWindow( slider );
|
UpdateWindow( slider );
|
||||||
|
|
||||||
|
enable_but( BUTREC_ID );
|
||||||
|
|
||||||
//
|
EnableWindow( slider, FALSE );
|
||||||
// Enables REC button.
|
|
||||||
//
|
|
||||||
|
|
||||||
butdisabled[ BUTREC_ID ] = FALSE;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -367,7 +368,24 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
case SB_PAGERIGHT:
|
case SB_PAGERIGHT:
|
||||||
case SB_PAGELEFT:
|
case SB_PAGELEFT:
|
||||||
case TB_THUMBTRACK:
|
case TB_THUMBTRACK:
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// If the user touch the slider bar,
|
||||||
|
// set the audio start position properly
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
slider_pos = SendMessage(slider, TBM_GETPOS, 0, 0);
|
slider_pos = SendMessage(slider, TBM_GETPOS, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
|
AUD_BUF->set_position(
|
||||||
|
AUD_BUF->audinfo().bytes_in_samples(
|
||||||
|
(( slider_pos * samples_max ) / slider_max )
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -407,17 +425,27 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
AUD_BUF->reset();
|
AUD_BUF->reset();
|
||||||
|
|
||||||
butdisabled[ BUTREC_ID ] = FALSE;
|
enable_but( BUTREC_ID );
|
||||||
butdisabled[ BUTSTART_ID ] = TRUE;
|
disable_but( BUTSTART_ID );
|
||||||
butdisabled[ BUTEND_ID ] = TRUE;
|
disable_but( BUTEND_ID );
|
||||||
butdisabled[ BUTSTOP_ID ] = TRUE;
|
disable_but( BUTSTOP_ID );
|
||||||
butdisabled[ BUTPLAY_ID ] = TRUE;
|
disable_but( BUTPLAY_ID );
|
||||||
|
|
||||||
|
|
||||||
samples_max = AUD_BUF->total_samples();
|
samples_max = AUD_BUF->total_samples();
|
||||||
slider_pos = 0;
|
slider_pos = 0;
|
||||||
|
|
||||||
SendMessage(slider, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) slider_pos);
|
SendMessage(slider, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) slider_pos);
|
||||||
|
|
||||||
|
EnableMenuItem( GetMenu( hWnd ), ID_FILE_SAVEAS, MF_GRAYED );
|
||||||
|
EnableMenuItem( GetMenu( hWnd ), ID_FILE_SAVE, MF_GRAYED );
|
||||||
|
|
||||||
|
isnew = TRUE;
|
||||||
|
|
||||||
|
ZeroMemory( file_path, MAX_PATH );
|
||||||
|
|
||||||
|
EnableWindow( slider, FALSE );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -442,6 +470,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
if( GetOpenFileName( &ofn ))
|
if( GetOpenFileName( &ofn ))
|
||||||
{
|
{
|
||||||
open_wav( file_path );
|
open_wav( file_path );
|
||||||
|
EnableMenuItem( GetMenu( hWnd ), ID_FILE_SAVE, MF_ENABLED );
|
||||||
|
EnableMenuItem( GetMenu( hWnd ), ID_FILE_SAVEAS, MF_ENABLED );
|
||||||
|
|
||||||
|
EnableWindow( slider, TRUE );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -471,9 +504,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
if ( GetSaveFileName ( &ofn ))
|
if ( GetSaveFileName ( &ofn ))
|
||||||
{
|
{
|
||||||
|
|
||||||
write_wav( file_path );
|
write_wav( file_path );
|
||||||
|
|
||||||
|
EnableMenuItem( GetMenu( hWnd ), ID_FILE_SAVE, MF_ENABLED );
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -488,22 +521,29 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
//
|
//
|
||||||
|
|
||||||
case BUTSTART_ID:
|
case BUTSTART_ID:
|
||||||
Beep(200,200);
|
|
||||||
|
AUD_BUF->set_position_start();
|
||||||
|
|
||||||
|
slider_pos = 0;
|
||||||
|
|
||||||
|
SendMessage( slider, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) slider_pos );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case BUTEND_ID:
|
case BUTEND_ID:
|
||||||
Beep(300,200);
|
//Beep(300,200);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BUTPLAY_ID:
|
case BUTPLAY_ID:
|
||||||
|
|
||||||
AUD_OUT->play();
|
AUD_OUT->play();
|
||||||
|
|
||||||
butdisabled[ BUTSTART_ID ] = TRUE;
|
disable_but( BUTSTART_ID );
|
||||||
butdisabled[ BUTEND_ID ] = TRUE;
|
disable_but( BUTEND_ID );
|
||||||
butdisabled[ BUTREC_ID ] = TRUE;
|
disable_but( BUTREC_ID );
|
||||||
butdisabled[ BUTPLAY_ID ] = TRUE;
|
disable_but( BUTPLAY_ID );
|
||||||
|
|
||||||
|
|
||||||
SetTimer( hWnd, 1, 250, 0 );
|
SetTimer( hWnd, 1, 250, 0 );
|
||||||
|
|
||||||
|
@ -516,11 +556,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
AUD_IN->stop_recording();
|
AUD_IN->stop_recording();
|
||||||
|
|
||||||
butdisabled[ BUTSTART_ID ] = FALSE;
|
|
||||||
butdisabled[ BUTEND_ID ] = FALSE;
|
|
||||||
butdisabled[ BUTREC_ID ] = FALSE;
|
|
||||||
butdisabled[ BUTPLAY_ID ] = FALSE;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -535,14 +570,25 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
EnableMenuItem((HMENU)IDR_MENU1, ID_FILE_SAVEAS, MF_ENABLED );
|
EnableMenuItem((HMENU)IDR_MENU1, ID_FILE_SAVEAS, MF_ENABLED );
|
||||||
|
|
||||||
|
|
||||||
|
enable_but( BUTSTART_ID );
|
||||||
|
enable_but( BUTEND_ID );
|
||||||
|
enable_but( BUTREC_ID );
|
||||||
|
enable_but( BUTPLAY_ID );
|
||||||
|
|
||||||
|
EnableMenuItem( GetMenu( hWnd ), ID_FILE_SAVEAS, MF_ENABLED );
|
||||||
|
EnableWindow( slider, TRUE );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
AUD_OUT->pause();
|
AUD_OUT->pause();
|
||||||
|
|
||||||
butdisabled[ BUTSTART_ID ] = FALSE;
|
enable_but( BUTSTART_ID );
|
||||||
butdisabled[ BUTEND_ID ] = FALSE;
|
enable_but( BUTEND_ID );
|
||||||
butdisabled[ BUTREC_ID ] = FALSE;
|
enable_but( BUTREC_ID );
|
||||||
butdisabled[ BUTPLAY_ID ] = FALSE;
|
enable_but( BUTPLAY_ID );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,15 +604,16 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
AUD_IN->start_recording();
|
AUD_IN->start_recording();
|
||||||
|
|
||||||
butdisabled[ BUTSTOP_ID ] = FALSE;
|
enable_but( BUTSTOP_ID );
|
||||||
butdisabled[ BUTSTART_ID ] = TRUE;
|
|
||||||
butdisabled[ BUTEND_ID ] = TRUE;
|
|
||||||
butdisabled[ BUTREC_ID ] = TRUE;
|
|
||||||
butdisabled[ BUTPLAY_ID ] = TRUE;
|
|
||||||
|
|
||||||
isnew = FALSE;
|
disable_but( BUTSTART_ID );
|
||||||
|
disable_but( BUTEND_ID );
|
||||||
|
disable_but( BUTREC_ID );
|
||||||
|
disable_but( BUTPLAY_ID );
|
||||||
|
|
||||||
|
isnew = FALSE;
|
||||||
|
|
||||||
|
EnableWindow( slider, FALSE );
|
||||||
|
|
||||||
SetTimer( hWnd, 1, 150, 0 );
|
SetTimer( hWnd, 1, 150, 0 );
|
||||||
|
|
||||||
|
@ -586,7 +633,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
KillTimer(hWnd, 1);
|
KillTimer(hWnd, 1);
|
||||||
slider_pos = 0;
|
slider_pos = 0;
|
||||||
|
|
||||||
butdisabled[ BUTPLAY_ID ] = FALSE;
|
enable_but( BUTPLAY_ID );
|
||||||
|
|
||||||
stopped_flag = FALSE;
|
stopped_flag = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -616,6 +663,61 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void l_play_finished ( void )
|
||||||
|
{
|
||||||
|
|
||||||
|
stopped_flag = true;
|
||||||
|
|
||||||
|
|
||||||
|
enable_but( BUTSTART_ID );
|
||||||
|
enable_but( BUTEND_ID );
|
||||||
|
enable_but( BUTREC_ID );
|
||||||
|
enable_but( BUTPLAY_ID );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void l_audio_arrival ( unsigned int samples_arrival )
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
slider_pos += (DWORD) (( slider_max * samples_arrival ) / samples_max );
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void l_buffer_resized ( unsigned int new_size )
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID enable_but( DWORD id )
|
||||||
|
{
|
||||||
|
|
||||||
|
butdisabled[ id ] = FALSE;
|
||||||
|
|
||||||
|
SendMessage(buttons[ id ], BM_SETIMAGE, ( WPARAM )IMAGE_BITMAP, ( LPARAM )butbmps[ id ]);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
VOID disable_but( DWORD id )
|
||||||
|
{
|
||||||
|
|
||||||
|
butdisabled[ id ] = TRUE;
|
||||||
|
|
||||||
|
SendMessage(buttons[ id ], BM_SETIMAGE, ( WPARAM )IMAGE_BITMAP, ( LPARAM )butbmps_dis[ id ]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL open_wav( TCHAR * f )
|
BOOL open_wav( TCHAR * f )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -663,14 +765,9 @@ BOOL open_wav( TCHAR * f )
|
||||||
|
|
||||||
if ( !b )
|
if ( !b )
|
||||||
{
|
{
|
||||||
DWORD t = GetLastError();
|
|
||||||
TCHAR p[100];
|
|
||||||
wsprintf(p,TEXT("Errore n: %i"),t);
|
|
||||||
|
|
||||||
MessageBox(
|
MessageBox(
|
||||||
main_win,
|
main_win,
|
||||||
//TEXT("Cannot read RIFF header."),
|
TEXT("Cannot read RIFF header."),
|
||||||
p,
|
|
||||||
TEXT("ERROR"),
|
TEXT("ERROR"),
|
||||||
MB_OK|MB_ICONERROR
|
MB_OK|MB_ICONERROR
|
||||||
);
|
);
|
||||||
|
@ -721,25 +818,8 @@ BOOL open_wav( TCHAR * f )
|
||||||
bytes_recorded_in_wav = r.chunksize - 36;
|
bytes_recorded_in_wav = r.chunksize - 36;
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
unsigned char * gg = (unsigned char*)&bytes_recorded_in_wav;
|
|
||||||
|
|
||||||
gg[0] = gg[3];
|
|
||||||
gg[1] = gg[2];
|
|
||||||
|
|
||||||
bytes_recorded_in_wav = (DWORD) *gg;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TCHAR p [100];
|
|
||||||
wsprintf(p,TEXT("bytes: %i"),bytes_recorded_in_wav);
|
|
||||||
MessageBox(0,p,0,0);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( bytes_recorded_in_wav == 0 )
|
if ( bytes_recorded_in_wav == 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
MessageBox(
|
MessageBox(
|
||||||
main_win,
|
main_win,
|
||||||
TEXT("Cannot read file. No audio data."),
|
TEXT("Cannot read file. No audio data."),
|
||||||
|
@ -795,12 +875,11 @@ BOOL open_wav( TCHAR * f )
|
||||||
|
|
||||||
CloseHandle( file );
|
CloseHandle( file );
|
||||||
|
|
||||||
butdisabled[ BUTPLAY_ID ] = FALSE;
|
enable_but( BUTPLAY_ID );
|
||||||
butdisabled[ BUTSTOP_ID ] = FALSE;
|
enable_but( BUTSTOP_ID );
|
||||||
butdisabled[ BUTEND_ID ] = FALSE;
|
enable_but( BUTSTART_ID );
|
||||||
butdisabled[ BUTSTART_ID ] = FALSE;
|
enable_but( BUTEND_ID );
|
||||||
butdisabled[ BUTREC_ID ] = FALSE;
|
enable_but( BUTREC_ID );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
samples_max = AUD_BUF->samples_received();
|
samples_max = AUD_BUF->samples_received();
|
||||||
|
@ -994,49 +1073,3 @@ BOOL
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void l_play_finished ( void )
|
|
||||||
{
|
|
||||||
|
|
||||||
stopped_flag = true;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void l_audio_arrival ( unsigned int samples_arrival )
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
slider_pos += (DWORD) (( slider_max * samples_arrival ) / samples_max );
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void l_buffer_resized ( unsigned int new_size )
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID enable_but( DWORD id )
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
VOID disable_but( DWORD id )
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
#include "audio_api.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,7 @@ LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
|
||||||
|
|
||||||
// Icon with lowest ID value placed first to ensure application icon
|
// Icon with lowest ID value placed first to ensure application icon
|
||||||
// remains consistent on all systems.
|
// remains consistent on all systems.
|
||||||
IDI_REACTOS_SNDREC32LL ICON "reactOS_sndrec32.ico"
|
IDI_SNDREC32 ICON "reactOS_sndrec32.ico"
|
||||||
IDI_SMALL ICON "small.ico"
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -125,6 +124,11 @@ IDB_BITMAP2_END BITMAP "but_end.bmp"
|
||||||
IDB_BITMAP2_PLAY BITMAP "but_play.bmp"
|
IDB_BITMAP2_PLAY BITMAP "but_play.bmp"
|
||||||
IDB_BITMAP2_STOP BITMAP "but_stop.bmp"
|
IDB_BITMAP2_STOP BITMAP "but_stop.bmp"
|
||||||
IDB_BITMAP2_REC BITMAP "but_rec.bmp"
|
IDB_BITMAP2_REC BITMAP "but_rec.bmp"
|
||||||
|
IDB_BITMAP2_END_DIS BITMAP "but_end_dis.bmp"
|
||||||
|
IDB_BITMAP2_PLAY_DIS BITMAP "but_play_dis.bmp"
|
||||||
|
IDB_BITMAP2_REC_DIS BITMAP "but_rec_dis.bmp"
|
||||||
|
IDB_BITMAP2_START_DIS BITMAP "but_start_dis.bmp"
|
||||||
|
IDB_BITMAP2_STOP_DIS BITMAP "but_stop_dis.bmp"
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -138,7 +142,7 @@ BEGIN
|
||||||
MENUITEM "New", ID_NEW
|
MENUITEM "New", ID_NEW
|
||||||
MENUITEM "Open...", ID_FILE_OPEN
|
MENUITEM "Open...", ID_FILE_OPEN
|
||||||
MENUITEM "Save", ID_FILE_SAVE, GRAYED
|
MENUITEM "Save", ID_FILE_SAVE, GRAYED
|
||||||
MENUITEM "Save As...", ID_FILE_SAVEAS
|
MENUITEM "Save As...", ID_FILE_SAVEAS, GRAYED
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "Exit", ID_EXIT
|
MENUITEM "Exit", ID_EXIT
|
||||||
END
|
END
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// File di intestazione di Windows:
|
// File di intestazione di Windows:
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <Commdlg.h>
|
#include <commdlg.h>
|
||||||
|
|
||||||
// File di intestazione Runtime C
|
// File di intestazione Runtime C
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue