📄 sndctrl.c
字号:
ReleaseDC(AudioMainWindow,hdc);
}
int AudioButtonPress=0;
LONG OldLVolume,OldRVolume;
int LeftRight=0;
static void AudioDoUpHandle(HWND hwnd,int Mouse)
{
if(AudioButtonPress!=BEAUDIOPOWER && AudioButtonState[BEAUDIOPOWER-1]!=0) return;
switch(AudioButtonPress)
{
case BEMONO:
case BEVOLUME:
case BEMUTE:
case BEAUDIOPOWER:
AudioButtonState[AudioButtonPress-1]^=1;
break;
case BELEFT:
if(AudioButtonState[BEVOLUME-1]==0) break;
if(LeftRight!=0)
{
if(LeftRight==1) break;
OldRVolume=RVolume;
LVolume=OldLVolume;
RVolume=0;
LeftRight=1;
DisplayVolume(LVolume,RVolume);
break;
}
if(Mouse)//Be mouse do it.
{
LVolume+=5041;
if(LVolume>65536) LVolume=65536;
RVolume-=5041;
if(RVolume<0) RVolume=0;
}
DisplayVolume(LVolume,RVolume);
break;
case BEDOWN:
if(AudioButtonState[BEVOLUME-1]==0) break;
if(Mouse)//Be mouse do it
{
if(LeftRight!=2)
{
LVolume-=5041;
if(LVolume<0) LVolume=0;
}
if(LeftRight!=1)
{
RVolume-=5041;
if(RVolume<0) RVolume=0;
}
}
DisplayVolume(LVolume,RVolume);
break;
case BEUP:
if(AudioButtonState[BEVOLUME-1]==0) break;
if(Mouse)//Be mouse do it
{
if(LeftRight!=2)
{
LVolume+=5041;
if(LVolume>65536) LVolume=65536;
}
if(LeftRight!=1)
{
RVolume+=5041;
if(RVolume>65536) RVolume=65536;
}
}
DisplayVolume(LVolume,RVolume);
break;
case BERIGHT:
if(AudioButtonState[BEVOLUME-1]==0) break;
if(LeftRight!=0)
{
if(LeftRight==2) break;
OldLVolume=LVolume;
RVolume=OldRVolume;
LVolume=0;
LeftRight=2;
DisplayVolume(LVolume,RVolume);
break;
}
if(Mouse)//Be mouse do it
{
LVolume-=5041;
if(LVolume<0) LVolume=0;
RVolume+=5041;
if(RVolume>65536) RVolume=65536;
}
DisplayVolume(LVolume,RVolume);
break;
/////////////////// AM,FM,CD //////////////
case BEAM:
case BEFM:
case BECD:
AudioButtonState[AudioButtonPress-1]=1;
if(AudioButtonPress==BEAM)
{
AudioButtonState[BEFM-1]=
AudioButtonState[BECD-1]=0;
AudioDrawButtonState(hwnd,BEFM,0);
AudioDrawButtonState(hwnd,BECD,0);
}
if(AudioButtonPress==BEFM)
{
AudioButtonState[BEAM-1]=
AudioButtonState[BECD-1]=0;
AudioDrawButtonState(hwnd,BEAM,0);
AudioDrawButtonState(hwnd,BECD,0);
}
if(AudioButtonPress==BECD)
{
AudioButtonState[BEAM-1]=
AudioButtonState[BEFM-1]=0;
AudioDrawButtonState(hwnd,BEAM,0);
AudioDrawButtonState(hwnd,BEFM,0);
}
break;
///////// Decoder //////////////
case BEFLOAT:
case BEINT:
case BEQUICK:
AudioButtonState[AudioButtonPress-1]=1;
if(AudioButtonPress==BEFLOAT)
{
AudioButtonState[BEINT-1]=
AudioButtonState[BEQUICK-1]=0;
AudioDrawButtonState(hwnd,BEINT,0);
AudioDrawButtonState(hwnd,BEQUICK,0);
}
if(AudioButtonPress==BEINT)
{
AudioButtonState[BEFLOAT-1]=
AudioButtonState[BEQUICK-1]=0;
AudioDrawButtonState(hwnd,BEFLOAT,0);
AudioDrawButtonState(hwnd,BEQUICK,0);
}
if(AudioButtonPress==BEQUICK)
{
AudioButtonState[BEFLOAT-1]=
AudioButtonState[BEINT-1]=0;
AudioDrawButtonState(hwnd,BEFLOAT,0);
AudioDrawButtonState(hwnd,BEINT,0);
}
break;
}
AudioDrawButtonState(hwnd,AudioButtonPress,AudioButtonState[AudioButtonPress-1]);
// Post Message to handle.
PostMessage(hwnd,WM_COMMAND,AudioButtonPress,0L);
}
int AudioHadDown=0;
int AudioMoveOut=0;
extern HWND MainWindow;// Video Control Window
void PASCAL FAR ClearhInt(void);
HWND PASCAL FAR CreatehInt(HWND hwnd,int x,int y,char *Str);
extern HWND hIntwnd;
extern int hIntBtn;
extern int ButtonPress;
extern int DisplayhIntCount;
extern int tmpCurPos;
extern int Chinese;
static void DrawhInt(HWND hwnd,int CurPos)
{
POINT ptCurrent;
if(AudioButtonPress!=0)
{
ClearhInt();
return;
}
///////////// Create a TrackPopupMenu ////////
if(hIntBtn!=CurPos && hIntBtn!=0) ClearhInt();
if(hIntBtn==CurPos) return;
if(tmpCurPos==CurPos)
{
DisplayhIntCount++;
if(DisplayhIntCount<10) return;
}
else {//Cureent Position
tmpCurPos=CurPos;
DisplayhIntCount=0;
return;
}
switch(CurPos)
{
case BEAUDIOPOWER:
if(Chinese) hIntwnd=CreatehInt(hwnd,12,109,"声音电源");
else hIntwnd=CreatehInt(hwnd,12,109,"Audio power");
if(hIntwnd) hIntBtn=CurPos;
break;
case BELEFT:
if(Chinese) hIntwnd=CreatehInt(hwnd,65,114,"左声道/左均衡");
else hIntwnd=CreatehInt(hwnd,65,114,"Left/Balance");
if(hIntwnd) hIntBtn=CurPos;
break;
case BEUP:
if(Chinese) hIntwnd=CreatehInt(hwnd,160,114,"音量增大");
else hIntwnd=CreatehInt(hwnd,160,114,"Volume up");
if(hIntwnd) hIntBtn=CurPos;
break;
case BEDOWN:
if(Chinese) hIntwnd=CreatehInt(hwnd,96,114,"音量减小");
else hIntwnd=CreatehInt(hwnd,96,114,"Volume down");
if(hIntwnd) hIntBtn=CurPos;
break;
case BERIGHT:
if(Chinese) hIntwnd=CreatehInt(hwnd,224,114,"右声道/右均衡");
else hIntwnd=CreatehInt(hwnd,224,114,"Right/Balance");
if(hIntwnd) hIntBtn=CurPos;
break;
case BEMONO:
if(Chinese) hIntwnd=CreatehInt(hwnd,268,114,"使用单声");
else hIntwnd=CreatehInt(hwnd,268,114,"Mono");
if(hIntwnd) hIntBtn=CurPos;
break;
case BEVOLUME:
if(Chinese) hIntwnd=CreatehInt(hwnd,312,114,"允许改变音量");
else hIntwnd=CreatehInt(hwnd,312,114,"Enable modify volume");
if(hIntwnd) hIntBtn=CurPos;
break;
case BEMUTE:
if(Chinese) hIntwnd=CreatehInt(hwnd,396,114,"无声");
else hIntwnd=CreatehInt(hwnd,396,114,"Mute");
if(hIntwnd) hIntBtn=CurPos;
break;
///////////////////////////
case BEAM:
if(Chinese) hIntwnd=CreatehInt(hwnd,332,41,"11千赫 486可用");
else hIntwnd=CreatehInt(hwnd,332,41,"11KHz 486 Use");
if(hIntwnd) hIntBtn=CurPos;
break;
case BEFM:
if(Chinese) hIntwnd=CreatehInt(hwnd,332,61,"22千赫 奔腾可用");
else hIntwnd=CreatehInt(hwnd,332,61,"22KHz Pentium Use");
if(hIntwnd) hIntBtn=CurPos;
break;
case BECD:
if(Chinese) hIntwnd=CreatehInt(hwnd,331,81,"44千赫 P7/P8可用");
else hIntwnd=CreatehInt(hwnd,331,81,"44KHz P7/P8 Use");
if(hIntwnd) hIntBtn=CurPos;
break;
case BEFLOAT:
if(Chinese) hIntwnd=CreatehInt(hwnd,376,41,"声音浮点解码");
else hIntwnd=CreatehInt(hwnd,386,41,"Float decode");
if(hIntwnd) hIntBtn=CurPos;
break;
case BEINT:
if(Chinese) hIntwnd=CreatehInt(hwnd,376,61,"声音整数解码");
else hIntwnd=CreatehInt(hwnd,376,61,"Integer decode");
if(hIntwnd) hIntBtn=CurPos;
break;
case BEQUICK:
if(Chinese) hIntwnd=CreatehInt(hwnd,376,81,"声音快速解码");
else hIntwnd=CreatehInt(hwnd,386,81,"Quick decode");
if(hIntwnd) hIntBtn=CurPos;
break;
}
}
long PASCAL FAR AudioWndProc(HWND hwnd,WORD message,WORD wParam,LONG lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
DWORD Ret;
int CurPos;
switch(message)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
if(!Playing)
{
AUDIOFACE=LoadBitmap(hInst,"AUDIOFACE");
AudioDrawBitmap(hdc,AUDIOFACE,0,0);
DeleteObject(AUDIOFACE);
AudioDrawAllStatus(hdc);
}
EndPaint(hwnd,&ps);
DisplayVolume(LVolume,RVolume);
return 0;
case WM_NCHITTEST:
if(AudioInButton(hwnd)) break;
lParam=DefWindowProc(hwnd,message,wParam,lParam);
if(lParam==1) return 2;
return lParam;
case WM_LBUTTONDOWN:
AudioButtonPress=AudioInButton(hwnd);
ClearhInt(); //Clear Hint
if(AudioButtonPress!=BEAUDIOPOWER && AudioButtonState[BEAUDIOPOWER-1]!=0) break;
if(AudioButtonPress)
{
SetCapture(hwnd);
AudioDrawButtonState(hwnd,AudioButtonPress,AudioButtonState[AudioButtonPress-1]^1);
}
break;
case WM_LBUTTONUP:
if(AudioButtonPress)
{
int CurPos;
CurPos=AudioInButton(hwnd);
if(CurPos==AudioButtonPress)
{
AudioDoUpHandle(hwnd,1);
}
AudioButtonPress=AudioMoveOut=0;
ReleaseCapture();
}
case WM_NCMOUSEMOVE:
CurPos=AudioInButton(hwnd);
//////////// Draw hint ///////////
if(CurPos) DrawhInt(hwnd,CurPos);
else ClearhInt();
break;
case WM_MOUSEMOVE:
CurPos=AudioInButton(hwnd);
//////////// Draw hint ///////////
if(CurPos) DrawhInt(hwnd,CurPos);
else ClearhInt();
if(AudioButtonPress)
{
if(CurPos!=AudioButtonPress)
{
AudioDrawButtonState(hwnd,AudioButtonPress,AudioButtonState[AudioButtonPress-1]);
AudioMoveOut=1;
}
else if(AudioMoveOut)
{
AudioDrawButtonState(hwnd,AudioButtonPress,AudioButtonState[AudioButtonPress-1]^1);
AudioMoveOut=0;
}
}
break;
case WM_COMMAND: // Audio Command
switch(wParam)
{
case BEAUDIOPOWER:
if(AudioButtonState[BEAUDIOPOWER-1]==0)
{
AudioButtonState[BEMUTE-1]=MuteState;
AudioButtonState[BEVOLUME-1]=VolumeState;
AudioButtonState[BEMONO-1]=MonoState;
if(SampleRate==2) AudioButtonState[BEAM-1]=1;
if(SampleRate==1) AudioButtonState[BEFM-1]=1;
if(SampleRate==0) AudioButtonState[BECD-1]=1;
if(DecodeMode==0) AudioButtonState[BEINT-1]=1;
if(DecodeMode==1) AudioButtonState[BEFLOAT-1]=1;
if(DecodeMode==3) AudioButtonState[BEQUICK-1]=1;
hdc=GetDC(hwnd);
AudioDrawAllStatus(hdc);
ReleaseDC(hwnd,hdc);
LVolume=OldLVolume;
RVolume=OldRVolume;
DisplayVolume(LVolume,RVolume);
}
else {//Power DOWN
int i;
MuteState=AudioButtonState[BEMUTE-1];
VolumeState=AudioButtonState[BEVOLUME-1];
MonoState=AudioButtonState[BEMONO-1];
AudioButtonState[BEMUTE-1]=0;
AudioButtonState[BEVOLUME-1]=0;
AudioButtonState[BEMONO-1]=0;
AudioButtonState[BEAM-1]=
AudioButtonState[BEFM-1]=
AudioButtonState[BECD-1]=
AudioButtonState[BEFLOAT-1]=
AudioButtonState[BEINT-1]=
AudioButtonState[BEQUICK-1]=0;
hdc=GetDC(hwnd);
AudioDrawAllStatus(hdc);
ReleaseDC(hwnd,hdc);
OldLVolume=LVolume;
OldRVolume=RVolume;
LVolume=RVolume=0;
DisplayVolume(LVolume,RVolume);
}
break;
case BEMONO:
if(AudioButtonState[BEMONO-1]==0)
{
LVolume=OldLVolume;
RVolume=OldRVolume;
LeftRight=0;
}
else {
OldLVolume=LVolume;
OldRVolume=RVolume;
RVolume=0;
LeftRight=1;
}
DisplayVolume(LVolume,RVolume);
SetVideoAudeo(LeftRight,LVolume,RVolume);
break;
case BELEFT:
case BEDOWN:
case BEUP:
case BERIGHT:
case BEVOLUME:
case BEMUTE:
SetVideoAudeo(LeftRight,LVolume,RVolume);
break;
/////////// AM,FM,CD //////////
case BEAM:
case BEFM:
case BECD:
if(AudioButtonState[BEAM-1]==1) SampleRate=2;
if(AudioButtonState[BEFM-1]==1) SampleRate=1;
if(AudioButtonState[BECD-1]==1) SampleRate=0;
/////////// Decodee ///////////
case BEFLOAT:
case BEINT:
case BEQUICK:
if(AudioButtonState[BEINT-1]==1) DecodeMode=0;
if(AudioButtonState[BEFLOAT-1]==1) DecodeMode=1;
if(AudioButtonState[BEQUICK-1]==1) DecodeMode=3;
SetVideoAudeo(LeftRight,LVolume,RVolume);
break;
}
break;
////////// Key Board Control. //////////
case WM_KEYDOWN:
switch(wParam)
{
case VK_DELETE:// Mute
AudioButtonPress=BEMUTE;
break;
case VK_ADD: //Volume ++
AudioButtonPress=BEUP;
break;
case VK_SUBTRACT://Volume --
AudioButtonPress=BEDOWN;
break;
}
if(!AudioHadDown) AudioDrawButtonState(hwnd,AudioButtonPress,AudioButtonState[AudioButtonPress-1]^1);
AudioHadDown=1;
switch(wParam)
{
case VK_ADD: //Volume ++
if(AudioButtonState[BEVOLUME-1]==0) break;
if(LeftRight==0)
{//Two channel +
LVolume+=1000;
if(LVolume>65536) LVolume=65536;
RVolume+=1000;
if(RVolume>65536) RVolume=65536;
}
else {//Single channel
if(LeftRight==1)
{//Left
LVolume+=1000;
if(LVolume>65536) LVolume=65536;
}
if(LeftRight==2)
{//Right
RVolume+=1000;
if(RVolume>65536) RVolume=65536;
}
}
DisplayVolume(LVolume,RVolume);
break;
case VK_SUBTRACT://Volume --
if(AudioButtonState[BEVOLUME-1]==0) break;
if(LeftRight==0)
{//Two channel -
LVolume-=1000;
if(LVolume<0) LVolume=0;
RVolume-=1000;
if(RVolume<0) RVolume=0;
}
else {//Single channel
if(LeftRight==1)
{//Left
LVolume-=1000;
if(LVolume<0) LVolume=0;
}
if(LeftRight==2)
{//Right
RVolume-=1000;
if(RVolume<0) RVolume=0;
}
}
DisplayVolume(LVolume,RVolume);
break;
}
//////// Video Control /////////
switch(wParam)
{
case VK_RETURN:
case VK_SPACE://PLAY or STOP
case VK_ESCAPE://POWER down
case VK_HOME://START
case VK_END:// END
case VK_PRIOR://Page UP,Back one Min
case VK_LEFT:// Back Search one Sec
case VK_NEXT:// Page Down,Forward one Min
case VK_RIGHT:// Forward search one Sec
case VK_INSERT:// Open Select,DISC Insert now.
case VK_TAB: //When Play End,loop play from start.
SendMessage(MainWindow,WM_KEYDOWN,wParam,lParam);
break;
}
return 0;
case WM_KEYUP:
AudioDoUpHandle(hwnd,0);
AudioHadDown=0;
AudioButtonPress=0;
//////// Video Control /////////
switch(wParam)
{
case VK_RETURN:
case VK_SPACE://PLAY or STOP
case VK_ESCAPE://POWER down
case VK_HOME://START
case VK_END:// END
case VK_PRIOR://Page UP,Back one Min
case VK_LEFT:// Back Search one Sec
case VK_NEXT:// Page Down,Forward one Min
case VK_RIGHT:// Forward search one Sec
case VK_INSERT:// Open Select,DISC Insert now.
case VK_TAB: //When Play End,loop play from start.
SendMessage(MainWindow,WM_KEYUP,wParam,lParam);
break;
}
return 0;
/////////////////////////
case WM_DESTROY:
if(CheckTime!=-1) KillTimer(hwnd,4545);
RestoreVolume();
FreeAudioDecoder();
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
////////////////// When Play start Call ///////////////
void PASCAL FAR SetVolumeAndMute(void)
{
SetVideoAudeo(LeftRight,LVolume,RVolume);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -