⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 w32g_ut2.c

📁 linux上播放midi音乐,但是要一些设置.可网上查找. 软件名称: TiMidity++-2.13.0.tar
💻 C
📖 第 1 页 / 共 2 页
字号:
/*    TiMidity++ -- MIDI to WAVE converter and player    Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>    Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/#ifdef HAVE_CONFIG_H#include "config.h"#endif /* HAVE_CONFIG_H */#include <windows.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <process.h>#include "timidity.h"#include "common.h"#include "instrum.h"#include "playmidi.h"#include "readmidi.h"#include "output.h"#include "controls.h"#include "recache.h"#ifdef SUPPORT_SOUNDSPEC#include "soundspec.h"#endif /* SUPPORT_SOUNDSPEC */#include "wrd.h"#include "w32g.h"#include "w32g_ut2.h"char *timidity_window_inifile;// ****************************************************************************// DlgChooseFont// hwnd: Owner Window of This Dialog// hwndFontChange: Window to Change Font// hFontPre: Previous Font of hwndFontChange (Call CloseHandle())int DlgChooseFontAndApply(HWND hwnd, HWND hwndFontChange, HFONT hFontPre, char *fontname, int *fontheight, int *fontwidth){	LOGFONT lf;	CHOOSEFONT cf;	HFONT hFont;	memset(&lf,0,sizeof(LOGFONT));	memset(&cf,0,sizeof(CHOOSEFONT));//	lf.lfHeight = 16;//	lf.lfWidth = 8;	strcpy(lf.lfFaceName,"俵俽 柧挬");    cf.lStructSize = sizeof(CHOOSEFONT);    cf.hwndOwner = hwnd;//    cf.hDC = NULL;    cf.lpLogFont = &lf;//    cf.iPointSize = 16;//    cf.Flags = CF_ANSIONLY | CF_FORCEFONTEXIST ;    cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;;//    cf.rgbColors = RGB(0,0,0);//    cf.lCustData = NULL;//    cf.lpfnHook = NULL;//    cf.lpTemplateName = NULL;//    cf.hInstance = 0;//    cf.lpszStyle = NULL;    cf.nFontType = SCREEN_FONTTYPE;//    cf.nSizeMin = 4;//    cf.nSizeMax = 72;	ChooseFont(&cf);//	if(ChooseFont(&cf)==TRUE)//		return -1;	if(hFontPre!=NULL)		CloseHandle(hFontPre);	hFont = CreateFontIndirect(&lf);	SendMessage(hwndFontChange,WM_SETFONT,(WPARAM)hFont,(LPARAM)MAKELPARAM(TRUE,0));	if(fontname!=NULL) strcpy(fontname,lf.lfFaceName);	if(fontheight!=NULL) *fontheight = lf.lfHeight;	if(fontwidth!=NULL) *fontwidth = lf.lfWidth;	return 0;}int DlgChooseFont(HWND hwnd, char *fontName, int *fontHeight, int *fontWidth){	LOGFONT lf;	CHOOSEFONT cf;	memset(&lf,0,sizeof(LOGFONT));	if(fontHeight!=NULL) lf.lfHeight = *fontHeight;	if(fontWidth!=NULL) lf.lfWidth = *fontWidth;	if(fontName!=NULL) strcpy(lf.lfFaceName,fontName);	memset(&cf,0,sizeof(CHOOSEFONT));    cf.lStructSize = sizeof(CHOOSEFONT);    cf.hwndOwner = hwnd;//    cf.hDC = NULL;    cf.lpLogFont = &lf;//    cf.iPointSize = 16;//    cf.Flags = CF_ANSIONLY | CF_FORCEFONTEXIST ;    cf.Flags = CF_ANSIONLY | CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;//    cf.rgbColors = RGB(0,0,0);//    cf.lCustData = NULL;//    cf.lpfnHook = NULL;//    cf.lpTemplateName = NULL;//    cf.hInstance = 0;//    cf.lpszStyle = NULL;    cf.nFontType = SCREEN_FONTTYPE;//    cf.nSizeMin = 4;//    cf.nSizeMax = 72;	if(ChooseFont(&cf)!=TRUE)		return -1;	if(fontName!=NULL) strcpy(fontName,lf.lfFaceName);	if(fontHeight!=NULL) *fontHeight = abs(lf.lfHeight);	if(fontWidth!=NULL) *fontWidth = lf.lfWidth;	return 0;}/**********************************************************************/void SetWindowPosSize ( HWND parent_hwnd, HWND hwnd, int x, int y ){	RECT rc1, rc2;	int width1, height1;	int width2, height2;	if ( GetWindowRect ( hwnd, &rc1 ) ) {		width1 = rc1.right - rc1.left;		height1 = rc1.bottom - rc1.top;		if ( x >= 0 ) {			rc1.right = rc1.right - rc1.left + x;			rc1.left = x;		} else {//			rc1.right = rc1.right - rc1.left;//			rc1.left = 0;		}		if ( y >= 0 ) {			rc1.bottom = rc1.bottom - rc1.top + y;			rc1.top = y;		} else {//			rc1.bottom = rc1.bottom - rc1.top;//			rc1.top = 0;		}		if ( GetClientRect ( parent_hwnd, &rc2 ) ) {			width2 = rc2.right - rc2.left;			height2 = rc2.bottom - rc2.top;			if ( rc1.left < rc2.left ) rc1.left = rc2.left;			if ( rc1.left > rc2.right ) rc1.left = rc2.right;			if ( rc1.top < rc2.top ) rc1.top = rc2.top;			if ( rc1.top > rc2.bottom ) rc1.top = rc2.bottom;			if ( width1 > width2 ) width1 = width2;			if ( height1 > height2 ) height1 = height2;			MoveWindow ( hwnd, rc1.left, rc1.top, width1, height1, TRUE );		}	}}/**********************************************************************/BOOL PosSizeSave = TRUE;#define SEC_MAINWND "MainWnd"int INISaveMainWnd(void){	char *section = SEC_MAINWND;	char *inifile = TIMIDITY_WINDOW_INI_FILE;	char buffer[256];	if ( PosSizeSave ) {		sprintf(buffer,"%d",MainWndInfo.PosX);		if ( MainWndInfo.PosX >= 0 || MainWndInfo.PosY >= 0 ) {			if ( MainWndInfo.PosX < 0 )				MainWndInfo.PosX = 0;			if ( MainWndInfo.PosY < 0 )				MainWndInfo.PosY = 0;		}		if ( MainWndInfo.PosX >= 0 )		WritePrivateProfileString(section,"PosX",buffer,inifile);		sprintf(buffer,"%d",MainWndInfo.PosY);		if ( MainWndInfo.PosY >= 0 )		WritePrivateProfileString(section,"PosY",buffer,inifile);	}	sprintf(buffer,"%d",MainWndInfo.CanvasMode);	WritePrivateProfileString(section,"CanvasMode",buffer,inifile);	WritePrivateProfileString(NULL,NULL,NULL,inifile);		// Write Flush	return 0;}int INILoadMainWnd(void){	char *section = SEC_MAINWND;	char *inifile = TIMIDITY_WINDOW_INI_FILE;	int num;	num = GetPrivateProfileInt(section,"PosX",-1,inifile);	MainWndInfo.PosX = num;	num = GetPrivateProfileInt(section,"PosY",-1,inifile);	MainWndInfo.PosY = num;	num = GetPrivateProfileInt(section,"CanvasMode",-1,inifile);	MainWndInfo.CanvasMode = num;	return 0;}#define SEC_LISTWND "ListWnd"int INISaveListWnd(void){	char *section = SEC_LISTWND;	char *inifile = TIMIDITY_WINDOW_INI_FILE;	char buffer[256];	if ( PosSizeSave ) {		if ( ListWndInfo.PosX >= 0 || ListWndInfo.PosY >= 0 ) {			if ( ListWndInfo.PosX < 0 )				ListWndInfo.PosX = 0;			if ( ListWndInfo.PosY < 0 )				ListWndInfo.PosY = 0;		}		sprintf(buffer,"%d",ListWndInfo.PosX);		if ( ListWndInfo.PosX >= 0 )		WritePrivateProfileString(section,"PosX",buffer,inifile);		sprintf(buffer,"%d",ListWndInfo.PosY);		if ( ListWndInfo.PosY >= 0 )		WritePrivateProfileString(section,"PosY",buffer,inifile);		sprintf(buffer,"%d",ListWndInfo.Width);		WritePrivateProfileString(section,"Width",buffer,inifile);		sprintf(buffer,"%d",ListWndInfo.Height);		WritePrivateProfileString(section,"Height",buffer,inifile);	}	WritePrivateProfileString(section,"fontNameEN",ListWndInfo.fontNameEN,inifile);	WritePrivateProfileString(section,"fontNameJA",ListWndInfo.fontNameJA,inifile);	sprintf(buffer,"%d",ListWndInfo.fontWidth);	WritePrivateProfileString(section,"fontWidth",buffer,inifile);	sprintf(buffer,"%d",ListWndInfo.fontHeight);	WritePrivateProfileString(section,"fontHeight",buffer,inifile);	sprintf(buffer,"%d",ListWndInfo.fontFlags);	WritePrivateProfileString(section,"fontFlags",buffer,inifile);	WritePrivateProfileString(NULL,NULL,NULL,inifile);		// Write Flush	return 0;}int INILoadListWnd(void){	char *section = SEC_LISTWND;	char *inifile = TIMIDITY_WINDOW_INI_FILE;	int num;	char buffer[64];	num = GetPrivateProfileInt(section,"PosX",-1,inifile);	ListWndInfo.PosX = num;	num = GetPrivateProfileInt(section,"PosY",-1,inifile);	ListWndInfo.PosY = num;	num = GetPrivateProfileInt(section,"Width",-1,inifile);	if(num!=-1) ListWndInfo.Width = num;	num = GetPrivateProfileInt(section,"Height",-1,inifile);	if(num!=-1) ListWndInfo.Height = num;	GetPrivateProfileString(section,"fontNameEN","",buffer,32,inifile);	if(buffer[0]!=0) strcpy(ListWndInfo.fontNameEN,buffer);	GetPrivateProfileString(section,"fontNameJA","",buffer,32,inifile);	if(buffer[0]!=0) strcpy(ListWndInfo.fontNameJA,buffer);	num = GetPrivateProfileInt(section,"fontWidth",-1,inifile);	if(num!=-1) ListWndInfo.fontWidth = num;	num = GetPrivateProfileInt(section,"fontHeight",-1,inifile);	if(num!=-1) ListWndInfo.fontHeight = num;	num = GetPrivateProfileInt(section,"fontFlags",-1,inifile);	if(num!=-1) ListWndInfo.fontFlags = num;	return 0;}#define SEC_DOCWND "DocWnd"int INISaveDocWnd(void){	char *section = SEC_DOCWND;	char *inifile = TIMIDITY_WINDOW_INI_FILE;	char buffer[256];	if ( PosSizeSave ) {		if ( DocWndInfo.PosX >= 0 || DocWndInfo.PosY >= 0 ) {			if ( DocWndInfo.PosX < 0 )				DocWndInfo.PosX = 0;			if ( DocWndInfo.PosY < 0 )				DocWndInfo.PosY = 0;		}		sprintf(buffer,"%d",DocWndInfo.PosX);		if ( DocWndInfo.PosX >= 0 )		WritePrivateProfileString(section,"PosX",buffer,inifile);		sprintf(buffer,"%d",DocWndInfo.PosY);		if ( DocWndInfo.PosY >= 0 )		WritePrivateProfileString(section,"PosY",buffer,inifile);		sprintf(buffer,"%d",DocWndInfo.Width);		WritePrivateProfileString(section,"Width",buffer,inifile);		sprintf(buffer,"%d",DocWndInfo.Height);		WritePrivateProfileString(section,"Height",buffer,inifile);	}	WritePrivateProfileString(section,"fontNameEN",DocWndInfo.fontNameEN,inifile);	WritePrivateProfileString(section,"fontNameJA",DocWndInfo.fontNameJA,inifile);	sprintf(buffer,"%d",DocWndInfo.fontWidth);	WritePrivateProfileString(section,"fontWidth",buffer,inifile);	sprintf(buffer,"%d",DocWndInfo.fontHeight);	WritePrivateProfileString(section,"fontHeight",buffer,inifile);	sprintf(buffer,"%d",DocWndInfo.fontFlags);	WritePrivateProfileString(section,"fontFlags",buffer,inifile);	WritePrivateProfileString(NULL,NULL,NULL,inifile);		// Write Flush	return 0;}int INILoadDocWnd(void){	char *section = SEC_DOCWND;	char *inifile = TIMIDITY_WINDOW_INI_FILE;	int num;	char buffer[64];	num = GetPrivateProfileInt(section,"PosX",-1,inifile);	DocWndInfo.PosX = num;	num = GetPrivateProfileInt(section,"PosY",-1,inifile);	DocWndInfo.PosY = num;	num = GetPrivateProfileInt(section,"Width",-1,inifile);	if(num!=-1) DocWndInfo.Width = num;	num = GetPrivateProfileInt(section,"Height",-1,inifile);	if(num!=-1) DocWndInfo.Height = num;	GetPrivateProfileString(section,"fontNameEN","",buffer,32,inifile);	if(buffer[0]!=0) strcpy(DocWndInfo.fontNameEN,buffer);	GetPrivateProfileString(section,"fontNameJA","",buffer,32,inifile);	if(buffer[0]!=0) strcpy(DocWndInfo.fontNameJA,buffer);	num = GetPrivateProfileInt(section,"fontWidth",-1,inifile);	if(num!=-1) DocWndInfo.fontWidth = num;	num = GetPrivateProfileInt(section,"fontHeight",-1,inifile);	if(num!=-1) DocWndInfo.fontHeight = num;	num = GetPrivateProfileInt(section,"fontFlags",-1,inifile);	if(num!=-1) DocWndInfo.fontFlags = num;	return 0;}#define SEC_CONSOLEWND "ConsoleWnd"int INISaveConsoleWnd(void){	char *section = SEC_CONSOLEWND;	char *inifile = TIMIDITY_WINDOW_INI_FILE;	char buffer[256];	if ( PosSizeSave ) {		if ( ConsoleWndInfo.PosX >= 0 || ConsoleWndInfo.PosY >= 0 ) {			if ( ConsoleWndInfo.PosX < 0 )				ConsoleWndInfo.PosX = 0;			if ( ConsoleWndInfo.PosY < 0 )				ConsoleWndInfo.PosY = 0;		}		sprintf(buffer,"%d",ConsoleWndInfo.PosX);		if ( ConsoleWndInfo.PosX >= 0 )		WritePrivateProfileString(section,"PosX",buffer,inifile);		sprintf(buffer,"%d",ConsoleWndInfo.PosY);		if ( ConsoleWndInfo.PosY >= 0 )		WritePrivateProfileString(section,"PosY",buffer,inifile);	}	WritePrivateProfileString(NULL,NULL,NULL,inifile);		// Write Flush	return 0;}int INILoadConsoleWnd(void){	char *section = SEC_CONSOLEWND;	char *inifile = TIMIDITY_WINDOW_INI_FILE;	int num;	num = GetPrivateProfileInt(section,"PosX",-1,inifile);	ConsoleWndInfo.PosX = num;	num = GetPrivateProfileInt(section,"PosY",-1,inifile);	ConsoleWndInfo.PosY = num;	return 0;}/**********************************************************************/// 僾儘僙僗娫捠怣梡偵儊乕儖僗儘僢僩偺僒乕僶乕僗儗僢僪傪梡堄偡傞#define TIMIDITY_MAILSLOT "\\\\.\\mailslot\\timiditypp_mailslot_ver_1_0"// 儊乕儖僗儘僢僩偵搉偝傟傞宍幃// 僿僢僟// 僐儅儞僪柤// 僆僾僔儑儞悢// 僆僾僔儑儞侾// 僆僾僔儑儞俀//   ...// 僿僢僟#define MC_HEADER	"TiMidity++Win32GUI Mailslot-1.0"	// 僐儅儞僪柤// TiMidity 偺廔椆#define MC_TERMINATE	"Terminate"// 僼傽僀儖傪巜掕#define MC_FILES "Files Argc Argv"// 僆僾僔儑儞侾 : 僼傽僀儖柤侾//   ...// 僾儗僀儕僗僩偺僋儕傾#define MC_PLAYLIST_CLEAR	"Playlist Clear"// 墘憈奐巒#define MC_PLAY			"Play"// 師偺僼傽僀儖偺墘憈#define MC_PLAY_NEXT	"Play Next"// 慜偺僼傽僀儖偺墘憈#define MC_PLAY_PREV	"Play Prev"// 墘憈掆巭#define MC_STOP	"Stop"// 墘憈堦帪掆巭#define MC_PAUSE	"Pause"// TiMidity 偺忬懺傪巜掕儊乕儖僗儘僢僩偵憲怣#define MC_SEND_TIMIDITY_INFO	"Send TiMidity Info"// 僆僾僔儑儞侾 : 儊乕儖僗儘僢僩柤// 僆僾僔儑儞俀 : 忬懺侾//   ...// 忬懺// "PlayFileName:乣" : 墘憈僼傽僀儖柤// "PlayTile:乣"		: 墘憈僞僀僩儖柤// "PlayStatus:乣"		: 墘憈忬懺(乣:PLAY,STOP,PAUSE)static HANDLE hMailslot = NULL;void w32gMailslotThread(void);int w32gStartMailslotThread(void){	DWORD dwThreadID;	HANDLE hThread;	hThread = (HANDLE)crt_beginthreadex(NULL,0,(LPTHREAD_START_ROUTINE)w32gMailslotThread,NULL,0,&dwThreadID);	if((unsigned long)hThread==-1){		return FALSE;	// Error!	}	return TRUE;}int ReadFromMailslot(HANDLE hmailslot, char *buffer, int *size){	DWORD dwMessageSize, dwMessageNum, dwMessageReadSize;	BOOL bRes;	int i;	bRes = GetMailslotInfo(hmailslot,NULL,&dwMessageSize,&dwMessageNum,(LPDWORD)NULL);	if(bRes==FALSE || dwMessageSize==MAILSLOT_NO_MESSAGE)		return FALSE;	for(i=0;i<10;i++){		bRes = ReadFile(hMailslot,buffer,dwMessageSize,&dwMessageReadSize,(LPOVERLAPPED)NULL);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -