Initial commit

This commit is contained in:
2026-09-13 11:54:43 +08:00
commit 498501c98a
58 changed files with 17145 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "GlobalUnit.h"
#include "AboutFormUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TAboutForm *AboutForm;
//---------------------------------------------------------------------------
__fastcall TAboutForm::TAboutForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TAboutForm::m_lblURLMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
m_lblURL->Font->Style = TFontStyles()<<fsUnderline;
}
//---------------------------------------------------------------------------
void __fastcall TAboutForm::m_lblURLMouseLeave(TObject *Sender)
{
m_lblURL->Font->Style = TFontStyles()>>fsUnderline;
m_lblURL->Invalidate() ;
}
//---------------------------------------------------------------------------
void __fastcall TAboutForm::m_lblURLClick(TObject *Sender)
{
if( m_lblURL->Caption.Length()>0 ){
ShellExecute(Handle,NULL, m_lblURL->Caption.c_str(), NULL,NULL,SW_SHOWNORMAL);
}
}
//---------------------------------------------------------------------------
void __fastcall TAboutForm::FormCreate(TObject *Sender)
{
String strSoftware = L"";
char buff[MAX_PATH] = {20};
sprintf(buff,"%d.%d.%d.%d",g_infoSoftwareUpdate.version.majorVersion,\
g_infoSoftwareUpdate.version.minorVersion,g_infoSoftwareUpdate.version.modifyVersion,\
g_infoSoftwareUpdate.version.buildVersion);
strSoftware = L"°æ±¾:" + (String)buff;
m_lblVersion->Caption = strSoftware;
m_lblURL->Caption = g_strServerURL;
}
//---------------------------------------------------------------------------
File diff suppressed because it is too large Load Diff
+33
View File
@@ -0,0 +1,33 @@
//---------------------------------------------------------------------------
#ifndef AboutFormUnitH
#define AboutFormUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TAboutForm : public TForm
{
__published: // IDE-managed Components
TLabel *m_lblCompany;
TLabel *m_lblURL;
TLabel *m_lblName1;
TLabel *m_lblVersion;
TLabel *m_lblName2;
TImage *m_imgLogo;
void __fastcall m_lblURLMouseMove(TObject *Sender, TShiftState Shift, int X, int Y);
void __fastcall m_lblURLMouseLeave(TObject *Sender);
void __fastcall m_lblURLClick(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TAboutForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TAboutForm *AboutForm;
//---------------------------------------------------------------------------
#endif
+424
View File
@@ -0,0 +1,424 @@
// ---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <mmsystem.h>
#include "GlobalUnit.h"
// ---------------------------------------------------------------------------
#pragma package(smart_init)
#define EX_NULL = NULL
const char * LSZ_STYLTYPES[24] = { "流行", "民谣", "摇滚", "舞曲", "爵士", "蓝调",
"桑巴", "古典", "圆舞曲", "独立", "乡村", "R&B",
"电子", "小夜曲", "进行曲", "叙事曲", "说唱", "拉丁",
"曼波", "雷鬼", "萨尔萨", "摇摆", "波萨", "FUNKY" } ;
const char * LSZ_LIST_HEADS[] = { "作者", "风格名", "节拍", "描述", "风格类型",
"消耗", "价格", "好评度" };
const TColor g_clrSegment[4][8] = {{RGB(250,244,213),RGB(248,235,159), // 伴奏颜色
RGB(247,224,128),RGB(244,205,100),
RGB(246,187,95),RGB(246,172,82),
RGB(244,149,64),RGB(234,132,59)},
{RGB(254,214,247),RGB(246,193,241), // 加花颜色
RGB(240,172,236),RGB(238,149,234),
RGB(236,111,231),RGB(236,75,231),
RGB(236,47,231),RGB(224,15,231)},
{RGB(196,230,147),RGB(179,215,176), // 前奏颜色
RGB(164,200,161),RGB(148,185,145)},
{RGB(203,219,247),RGB(189,206,230), // 尾奏颜色
RGB(177,193,220),RGB(164,180,205)}};
/*************************************************************************************** /
// 全局变量
/************************************************************************************** */
//FILENAMES g_infoFiles; // 文件路径信息
TMAKESTYLEINFO g_infoAuthor; // 作者相关信息
//TSTYLEINFO g_tpInfoAuthor; // 临时作者相关信息
//FILENAMES g_tpInfoFiles; // 临时文件路径信息
wstring g_strFontPath, // 音色库路径
g_strFontFile, // 音色库文件名
g_strLastSaveFile, // 上次保存音乐文件名
g_strExecutePath, // 执行文件路径
g_strProjectName; // 工程文件名
char g_strCurrentVersion[20] = "", g_strServerURL[256] = "";
int g_iSelectedStyleID = -1, // 风格ID
g_iMelodyKey = -1, // 主旋律调号
g_iComposeKey = -1, // 伴奏调号,用于录音升降调
g_iMelodyTimeSignature = 0, // 主旋律拍号
g_nMelodyTempo = 75, // 主旋律速度
g_nBuildVersion;
float g_fRecordVolume = -1, // 录音音量
g_fSpeakerVolume = -1, // 喇叭音量
g_fAudioVolume = 1, // 音频音量
g_fMusicVolume = 1; // 伴奏音量
double g_dblStep = 0, g_dblTimePerBar = 0;
TUSERINFO g_infoUser;
TSOFTWAREINFO g_infoSoftwareUpdate;
bool g_bShowRecordHint = true, // 噪音侦测
g_bUpdateMandatory = false, // 客户端需要强制更新
g_bWeakup = false, // 旋律弱起
g_bAutoLogin = true, g_bLogon = false, g_bUserSaved = false, // 用户保存工程文件
g_bSavePassWord = false, g_bAudioLoaded = false; // 音频已加载
bool g_bRecreator = true; // 审核与合成标记
vector<wstring>g_lstRecentProject; // 最近的工程文件
/*************************************************************************************** /
// 全局函数声明
/************************************************************************************** */
CM_Initialize f_CM_Initialize EX_NULL;
CM_Release f_CM_Release EX_NULL;
CM_Clear f_CM_Clear EX_NULL;
CM_Compose f_CM_Compose EX_NULL;
CM_RecombineFiles f_CM_RecombineFiles EX_NULL;
CM_GetSegmentInfo f_CM_GetSegmentInfo EX_NULL;
CM_GetTracksInfo f_CM_GetTracksInfo EX_NULL;
CM_MakeStyle f_CM_MakeStyle EX_NULL;
CM_DeleteTrack f_CM_DeleteTrack EX_NULL;
CM_GetStyleInfo f_CM_GetStyleInfo EX_NULL;
CM_GetStyleInfos f_CM_GetStyleInfos EX_NULL;
CM_GenerateCheckData f_CM_GenerateCheckData EX_NULL;
CM_CompareStyle f_CM_CompareStyle EX_NULL;
MM_InitialObjects f_MM_InitialObjects EX_NULL;
MM_DestroyObjects f_MM_DestroyObjects EX_NULL;
MM_GetFontInfo f_MM_GetFontInfo EX_NULL;
MM_SetDefaultFont f_MM_SetDefaultFont EX_NULL;
MM_LoadCompose f_MM_LoadCompose EX_NULL;
MM_FreeComposes f_MM_FreeComposes EX_NULL;
MM_Stop f_MM_Stop EX_NULL;
MM_Play f_MM_Play EX_NULL;
MM_LoadDemo f_MM_LoadDemo EX_NULL;
MM_PlayDemo f_MM_PlayDemo EX_NULL;
MM_SetTempo f_MM_SetTempo EX_NULL;
MM_SetTimeSignature f_MM_SetTimeSignature EX_NULL;
MM_SetTrackEvent f_MM_SetTrackEvent EX_NULL;
CS_InitialService f_CS_InitialService EX_NULL;
CS_DestroyService f_CS_DestroyService EX_NULL;
CS_Login f_CS_Login EX_NULL;
CS_Logoff f_CS_Logoff EX_NULL;
CS_CancelOperation f_CS_CancelOperation EX_NULL;
CS_UploadStyle f_CS_UploadStyle EX_NULL;
/*
CS_DownloadStyle f_CS_DownloadStyle EX_NULL;
*/
CS_UpdateStyle f_CS_UpdateStyle EX_NULL;
CS_CheckStyle f_CS_CheckStyle EX_NULL;
/*************************************************************************************** /
// 全局函数实现
/************************************************************************************** */
HRESULT GetMSFunctions(HINSTANCE hDll) {
f_CM_Initialize = (CM_Initialize)GetProcAddress(hDll, "CM_Initialize");
f_CM_Release = (CM_Release)GetProcAddress(hDll, "CM_Release");
f_CM_Clear = (CM_Clear)GetProcAddress(hDll, "CM_Clear");
f_CM_Compose = (CM_Compose)GetProcAddress(hDll, "CM_Compose");
f_CM_RecombineFiles = (CM_RecombineFiles)GetProcAddress(hDll, "CM_RecombineFiles");
f_CM_GetSegmentInfo = (CM_GetSegmentInfo)GetProcAddress(hDll, "CM_GetSegmentInfo");
f_CM_GetTracksInfo = (CM_GetTracksInfo)GetProcAddress(hDll, "CM_GetTracksInfo");
f_CM_MakeStyle = (CM_MakeStyle)GetProcAddress(hDll, "CM_MakeStyle");
f_CM_DeleteTrack = (CM_DeleteTrack)GetProcAddress(hDll, "CM_DeleteTrack");
f_CM_GetStyleInfo = (CM_GetStyleInfo)GetProcAddress(hDll, "CM_GetStyleInfo");
f_CM_GetStyleInfos = (CM_GetStyleInfos)GetProcAddress(hDll, "CM_GetStyleInfos");
f_CM_GenerateCheckData = (CM_GenerateCheckData)GetProcAddress(hDll, "CM_GenerateCheckData");
f_CM_CompareStyle = (CM_CompareStyle)GetProcAddress(hDll, "CM_CompareStyle");
if (!(f_CM_Initialize && f_CM_Release && f_CM_Compose && f_CM_RecombineFiles &&
f_CM_GetSegmentInfo && f_CM_GetTracksInfo && f_CM_MakeStyle && f_CM_DeleteTrack &&
f_CM_GetStyleInfo && f_CM_GetStyleInfos && f_CM_GenerateCheckData &&
f_CM_CompareStyle && f_CM_Clear )) {
return S_FALSE;
}
return S_OK;
}
HRESULT GetMMFunctions(HINSTANCE hDll) {
f_MM_InitialObjects = (MM_InitialObjects)GetProcAddress(hDll, "MM_InitialObjects");
f_MM_DestroyObjects = (MM_DestroyObjects)GetProcAddress(hDll, "MM_DestroyObjects");
f_MM_GetFontInfo = (MM_GetFontInfo)GetProcAddress(hDll, "MM_GetFontInfo");
f_MM_SetDefaultFont = (MM_SetDefaultFont)GetProcAddress(hDll, "MM_SetDefaultFont");
f_MM_LoadCompose = (MM_LoadCompose)GetProcAddress(hDll, "MM_LoadCompose");
f_MM_FreeComposes = (MM_FreeComposes)GetProcAddress(hDll, "MM_FreeComposes");
f_MM_Stop = (MM_Stop)GetProcAddress(hDll, "MM_Stop");
f_MM_SetTempo = (MM_SetTempo)GetProcAddress(hDll, "MM_SetTempo");
f_MM_Play = (MM_Play)GetProcAddress(hDll, "MM_Play");
f_MM_LoadDemo = (MM_LoadDemo)GetProcAddress(hDll, "MM_LoadDemo");
f_MM_PlayDemo = (MM_PlayDemo)GetProcAddress(hDll, "MM_PlayDemo");
f_MM_SetTimeSignature = (MM_SetTimeSignature)GetProcAddress(hDll, "MM_SetTimeSignature");
f_MM_SetTrackEvent = (MM_SetTrackEvent)GetProcAddress(hDll, "MM_SetTrackEvent");
if (!(f_MM_InitialObjects && f_MM_DestroyObjects && f_MM_GetFontInfo &&
f_MM_SetDefaultFont && f_MM_LoadCompose && f_MM_Stop && f_MM_Play &&
f_MM_LoadDemo && f_MM_PlayDemo && f_MM_SetTempo && f_MM_SetTimeSignature &&
f_MM_SetTrackEvent && f_MM_FreeComposes )) {
return S_FALSE;
}
return S_OK;
}
HRESULT GetCSFunctions(HINSTANCE hDll) {
// VERIFY( hDll );
f_CS_InitialService = (CS_InitialService)GetProcAddress(hDll,
"CS_InitialService");
f_CS_DestroyService = (CS_DestroyService)GetProcAddress(hDll,
"CS_DestroyService");
f_CS_Login = (CS_Login)GetProcAddress(hDll, "CS_Login");
f_CS_Logoff = (CS_Logoff)GetProcAddress(hDll, "CS_Logoff");
f_CS_CancelOperation = (CS_CancelOperation)GetProcAddress(hDll,
"CS_CancelOperation");
f_CS_UploadStyle = (CS_UploadStyle)GetProcAddress(hDll, "CS_UploadStyle");
/*
f_CS_DownloadStyle = (CS_DownloadStyle)GetProcAddress(hDll,
"CS_DownloadStyle");
*/
f_CS_UpdateStyle = (CS_UpdateStyle)GetProcAddress(hDll, "CS_UpdateStyle");
f_CS_CheckStyle = (CS_CheckStyle)GetProcAddress(hDll, "CS_CheckStyle");
if (!(f_CS_InitialService && f_CS_DestroyService && f_CS_Login &&
f_CS_Logoff && f_CS_CancelOperation && f_CS_UploadStyle &&
/* f_CS_DownloadStyle && */f_CS_UpdateStyle && f_CS_CheckStyle)) {
return S_FALSE;
}
return S_OK;
}
void SetPlayTimer(bool bStart, UINT& tTimer, UINT& tAccuracy, void* pUser) {
if (bStart) { // 打开定时器
// 设置定时器
TIMECAPS tc;
MMRESULT mrError;
// 利用函数timeGetDevCaps取出系统分辨率的取值范围,如果有错报错退出
memset(&tc, 0, sizeof(TIMECAPS));
mrError = timeGetDevCaps(&tc, sizeof(TIMECAPS));
if (!mrError == TIMERR_NOERROR) {
DebugPrint("Get system accuracy failed! code = %x", mrError);
}
// 分辨率的值不能超出系统的取值范围
tAccuracy = tc.wPeriodMin > TIMER_ACCURACY ? tc.wPeriodMin :
TIMER_ACCURACY;
tAccuracy = tAccuracy < tc.wPeriodMax ? tAccuracy : tc.wPeriodMax;
// 调用timeBeginPeriod函数设置定时器的分辨率
timeBeginPeriod(tAccuracy);
tTimer = timeSetEvent(TIMER_PLAY_INTERVAL, tAccuracy,
(LPTIMECALLBACK)OnMediaTimer, (DWORD_PTR)pUser, TIME_PERIODIC);
}
else { // 关闭定时器
timeKillEvent(tTimer);
timeEndPeriod(tAccuracy);
}
}
void CALLBACK OnMediaTimer(UINT tTimerID, UINT msg, DWORD dwUser, DWORD dwl,
DWORD dw2) {
PostMessage((HWND)dwUser, MSG_MEDIATIME, 0, 0);
}
#include <stdio.h>
#include <stdarg.h>
#include <tchar.h>
#include <time.h>
#define MAX_DEBUG_PRINT 10240
string wstr2str(const wstring& _src) {
int nBufSize = WideCharToMultiByte(GetACP(), 0, _src.c_str(), -1, NULL, 0,
0, FALSE);
char *szBuf = new char[nBufSize];
WideCharToMultiByte(GetACP(), 0, _src.c_str(), -1, szBuf, nBufSize,
0, FALSE);
string strRet(szBuf);
delete[]szBuf;
return strRet;
}
wstring str2wstr(const string& _src) {
int nBufSize = MultiByteToWideChar(GetACP(), 0, _src.c_str(), -1, NULL, 0);
wchar_t *wsBuf = new wchar_t[nBufSize];
MultiByteToWideChar(GetACP(), 0, _src.c_str(), -1, wsBuf, nBufSize);
wstring wstrRet(wsBuf);
delete[]wsBuf;
return wstrRet;
}
string GBToUTF8(const char* str) {
string result;
WCHAR *strSrc;
char *szRes;
// 获得临时变量的大小
int i = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
strSrc = new WCHAR[i + 1];
MultiByteToWideChar(CP_ACP, 0, str, -1, strSrc, i);
// 获得临时变量的大小
i = WideCharToMultiByte(CP_UTF8, 0, strSrc, -1, NULL, 0, NULL, NULL);
szRes = new char[i + 1];
int j = WideCharToMultiByte(CP_UTF8, 0, strSrc, -1, szRes, i, NULL, NULL);
result = szRes;
delete[]strSrc;
delete[]szRes;
return result;
}
string UFF8ToMBCS(const char *pcUtf8) {
// wchar_t pcUnicode[CHAR_BUFSIZE];
int nUnicodeLen = MultiByteToWideChar(CP_UTF8, 0, pcUtf8, -1, NULL, 0);
wchar_t * pcUnicode = new wchar_t[nUnicodeLen + 1];
memset(pcUnicode, 0, nUnicodeLen * 2 + 2);
// utf8 to unicode
MultiByteToWideChar(CP_UTF8, 0, pcUtf8, -1, pcUnicode, nUnicodeLen);
// unicode to gb2312
int nMBCSLen = WideCharToMultiByte(CP_ACP, 0, pcUnicode, -1, NULL, 0,
NULL, NULL);
char *pcMBCS = new char[nMBCSLen + 1];
memset(pcMBCS, 0, nMBCSLen + 1);
WideCharToMultiByte(CP_ACP, 0, pcUnicode, -1, pcMBCS, nMBCSLen, NULL, NULL);
string strMBCS = pcMBCS;
delete[]pcMBCS;
delete[]pcUnicode;
return strMBCS;
}
void DebugPrint(const char * fmt, ...) {
#ifdef _DEBUG
char sDebug[MAX_DEBUG_PRINT];
sDebug[0] = '\0';
char tbuffer[9];
_strtime(tbuffer);
sprintf(sDebug, "[%s] ", tbuffer);
va_list vaParams;
va_start(vaParams, fmt);
vsprintf(sDebug + strlen(sDebug), fmt, vaParams);
OutputDebugStringA(sDebug);
#endif
}
void SetAutoLogin(bool bAuto, LPCSTR strName, LPCSTR strPwd) {
HKEY hComposerKey;
DWORD dwDisposition;
long lResult;
lResult = RegCreateKeyEx(HKEY_CURRENT_USER, REGKEY_SOFTWARE, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hComposerKey,
&dwDisposition);
if (lResult == ERROR_SUCCESS) {
BYTE strText[100] = {0};
int nNameLen = strlen(strName), nRegLen = nNameLen + 2;
strText[0] = nNameLen;
strText[1] = g_bAutoLogin;
for (int i = 0; i < nNameLen; i++) {
strText[i + 2] = strName[i] - 0x63;
}
strText[nNameLen + 2] = '\0';
// 只记住密码
if (bAuto) {
int nMaxPwdLen = 16, nPwdLen = strlen(strPwd);
strText[nNameLen + 2] = nPwdLen;
for (int i = 0; i < nMaxPwdLen; i++) {
if (i < nPwdLen)
strText[i + nNameLen + 3] = strPwd[i] - 0x4B;
else
strText[i + nNameLen + 3] = Random(256);
}
strText[nNameLen + nMaxPwdLen + 3] = '\0';
nRegLen += 17;
}
lResult = RegSetValueEx(hComposerKey, REGKEY_AUTOLOG, 0, REG_BINARY,
strText, nRegLen);
}
RegCloseKey(hComposerKey);
}
bool GetAutoLogin(char* strName, char* strPwd) {
HKEY hComposerKey;
DWORD dwDisposition = MAX_PATH;
bool bAuto = false;
strName[0] = strPwd[0] = 0;
long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, REGKEY_SOFTWARE, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hComposerKey,
&dwDisposition);
if (lResult == ERROR_SUCCESS) {
DWORD dwSize = MAX_PATH, dwLen;
BYTE szBuffer[MAX_PATH] = {0};
if (dwDisposition == REG_OPENED_EXISTING_KEY) {
dwSize = MAX_PATH;
lResult = RegQueryValueEx(hComposerKey, REGKEY_AUTOLOG, NULL, NULL,
szBuffer, &dwSize);
if (lResult == ERROR_SUCCESS && dwSize > 0) {
int nTextLen = dwSize;
int nNameLen = szBuffer[0];
bAuto = szBuffer[1];
for (int i = 0; i < nNameLen; i++) {
strName[i] = szBuffer[i + 2] + 0x63;
}
strName[nNameLen] = '\0';
if (nTextLen - 18 >= nNameLen) {
g_bSavePassWord = true;
int nPwdLen = szBuffer[nNameLen + 2];
for (int i = 0; i < nPwdLen; i++) {
strPwd[i] = szBuffer[i + nNameLen + 3] + 0x4B;
}
strPwd[nPwdLen] = '\0';
}
}
}
}
RegCloseKey(hComposerKey);
return bAuto;
}
+538
View File
@@ -0,0 +1,538 @@
// ---------------------------------------------------------------------------
#ifndef GlobalUnitH
#define GlobalUnitH
#include "commonstruct.h"
#include "MessageDef.h"
// ---------------------------------------------------------------------------
/*************************************************************************************** /
// 全局定义
/************************************************************************************** */
#define APPNAME "魔方风格工具\0"
#define SOFTWARE_ID e_SM_Checker
#define MINUM_COLUMN 5
#define MINUM_ROW 6
#define MAX_PATH 260
#define DLLAPI __stdcall
#define CELL_ABSORB_WIDTH 10
#define CHORD_WHOLE_BAR 1
#define CHORD_HALF_BAR 0
#define ID_INITIAL_BAR 1
#define CHORD_TYPE_NUM 4
#define KEY_NUM 12
#define MAX_INTRO_NUM 4
#define MAX_ENDING_NUM 4
#define COMPOSE_FILL_NUM 2
#define STAGE_VAR_NUM 4
#define LIST_MELODYBARS 0x01
#define LIST_MELODYCHORDS 0x02
#define LIST_MELODYSTAGES 0x04
#define LIST_COMPOSESTAGES 0x08
#define LIST_COMPLETEVOLS 0x10
#define LIST_ALL 0x1F
#define TIMER_ACCURACY 1
#define TIMER_PLAY_INTERVAL 25
#define TIME_HINT 500
#define CHANNEL_MELODY 0
#define MELODY_DEF_VOLUMN 90
#define MIDI_EVENT_INSTRUMENT 2
#define MIDI_EVENT_VOLUME 12
#define SAFE_FREE(p) { if(p) { free(p); (p)=NULL; } }
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
#define SEGTYPE_VAR 0
#define SEGTYPE_FILL 1
#define SEGTYPE_INTRO 2
#define SEGTYPE_ENDING 3
#define TYPE_BASECOMPOSE 0x01
#define TYPE_COMPOSE 0x02
#define TYPE_AUDIO 0x04
#define TYPE_SONG 0x08
#define TYPE_BEAT 0x10
#define TYPE_AUDIO_BASECOMPOSE 0x05
#define TYPE_SONG_COMPOSE 0x0A
#define TYPE_LOOPPLAY 0x200
#define FONT_SF2 0x10000
// 界面消息
#define UM_RESTORE WM_USER + 0x1000
#define UM_LOGIN WM_USER + 0x1004
#define REGKEY_SOFTWARE L"SOFTWARE\\iChangzuo\\StyleTools"
#define REGKEY_ACPRO L"SOFTWARE\\iChangzuo\\AC_Pro"
#define REGKEY_AUTOLOG L"{0DF44EAA-FF21-4412-828E-250A8728E7F1}"
#define REGKEY_INSTALDIR L"InstallDir"
/*************************************************************************************** /
// 全局常量
/************************************************************************************** */
extern const DWORD g_dwProjectVersion;
extern const char * LSZ_STYLTYPES[];
extern const char * LSZ_LIST_HEADS[];
extern const TColor g_clrSegment[4][8];
/*************************************************************************************** /
// 全局变量
/************************************************************************************** */
#include <vector>
using namespace std;
struct FONTINFO {
char strFileName[256];
char strFontName[80];
char strCopyright[128];
char strComment[256];
};
extern TMAKESTYLEINFO g_infoAuthor; // 作者相关信息
//extern FILENAMES g_infoFiles; // 文件路径信息
//extern TSTYLEINFO g_tpInfoAuthor; // 临时作者相关信息
//extern FILENAMES g_tpInfoFiles; // 临时文件路径信息
extern wstring g_strFontPath, // 音色库路径
g_strFontFile, // 音色库文件名
g_strExecutePath, // 执行文件路径
g_strProjectName; // 工程文件名
extern vector<wstring>g_lstRecentProject; // 最近的工程文件
extern HANDLE g_hProjectEvent; // 工程文件读写互斥变量
extern string g_strSelectedStyleName; // 选中风格名
extern vector<int>g_lstStyleSelected; // 选中风格类型集合
extern DWORD g_iSelectedStyleType; // 选定风格类型
extern char g_strCurrentVersion[20], g_strServerURL[256];
extern int g_iSelectedStyleID, // 选定风格ID
g_idFont, // 选定音色库序号
g_iMelodyKey, // 主旋律调号
g_iComposeKey, // 伴奏调号,用于录音升降调
g_iMelodyTimeSignature, // 主旋律拍号
g_nMelodyTempo; // 主旋律速度
extern double g_dblStep, // 播放步长
g_dblTimePerBar; // 每小节时间(毫秒)
extern bool g_bRecreator;
/*************************************************************************************** /
// 全局函数
/************************************************************************************** */
/////////////////////////////////////////////////////////////////////////////////////////
// 风格处理函数段
//
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI int (*CM_Initialize)();
//函数名: Initialize
//功 能: 模块初始化
//返 回 值: 成功返回0, 否则返回错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI int (*CM_Release)();
//功 能:释放对象
//输 入:无
//返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI int (*CM_Clear)();
//功 能:清除数据
//输 入:无
//返回值:错误号
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*CM_Compose)( int* buffLen, BYTE buffer[], int ts, int tempo,
int nStageNum, void* aStages,
bool bSave, int* lenNotes, BYTE notes[] );
//函数名: Compose
//功 能: 按指定曲式结构编曲
//输 入:
// buffLen
// buffer 块内存地址
// ts/tempo指定节拍速度
// nStageNum 曲式分段数
// aStages 曲式分段数组 TStage类型
// bSave 用于播放/保存
// lenNotes/notes 获取轨道音符的长度/地址
//返 回: 成功返回0, 否则返回错误号
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (* CM_MakeStyle)( UINT idStyle, TMAKESTYLEINFO *pStyleInfo,
int &nBufferLen, BYTE* pBuffer );
//函数功能: 生成风格文件.
//参 数:
// idStyle 临时风格ID
// stAuthorInfo 相关信息
// nBufferLen 返回风格文件长度
// pBuffer 接收风格文件数据的缓冲区,外部分配,外部释放
//返 回 值: 成功返回0, 否则返回错误号
/////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*CM_RecombineFiles)( UINT idStyle, char* commonName, int *pTS, int *pTempo );
// 函数功能: 重新合成文件
// 参 数:
// idStyle 临时风格ID
// commonName 文件名共同
// iTS 返回节拍
// nTempo 返回速度,
// 返 回 值: 成功返回0,否则返回-1
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*CM_GetSegmentInfo)( UINT idLoc, UINT idStyle, char info[4][8][2][2] );
// 函数功能: 获取临时风格片段信息
// 参 数:
// idLoc/idStyle 临时风格ID
// info[sType][sNo][cType][0] = bars
// info[sType][sNo][cType][1] = tracks
//返 回 值: 成功返回0, 否则返回错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI int (*CM_GetTracksInfo)( UINT idLoc, UINT idStyle, char sType, char sNo, char cType, char track[16][3] );
// 函数功能: 获取片段轨道信息
// 参 数:
// idLoc/idStyle 临时风格ID
// sType/sNo/cType 指定片段
// track[][0] = 通道号
// track[][1] = 乐器号
// track[][2] = 音量
//返 回 值: 成功返回track数
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI int (*CM_DeleteTrack)( UINT idStyle, char sType, char sNo, char cType, char chan );
// 函数功能: 删除轨道
// 参 数:
// idStyle 临时风格ID
// sType/sNo/chan 指定轨道
//返 回 值: 成功返回0,否则返回错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*CM_GetStyleInfo)( UINT idLoc, UINT idStyle, TPROSTYLE* tStyle );
//函数名: GetStyleInfo
//功 能: 获取指定ID的信息
//输 入:
//返 回: 成功返回0,否则为错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*CM_GetStyleInfos)( int iType, int iTS, TPROSTYLE aStyleInfos[], int *nInfoNum );
//函数名: GetStyleInfos
//功 能: 获取指定节拍的风格信息列表
//输 入:
// iType 风格类别 1=发布 2=本地 3=分享
//返 回: 成功返回0,否则为错误号
/////////////////////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------------------------------
typedef DLLAPI HRESULT (*CM_GenerateCheckData)( UINT idLoc, UINT idStyle );
// 函数功能: 生成风格检查信息
// 参 数:
// idLoc/idStyle 风格ID
//返 回 值: 成功返回0, 否则返回错误号
//---------------------------------------------------------------------------------------------
typedef DLLAPI HRESULT (*CM_CompareStyle)( UINT idLoc, UINT idStyle, UINT check[2][4][2][5][2],
HWND hProcessWnd );
// 函数功能: 获取风格比对信息
// 参 数:
// idLoc/idStyle 风格ID
// check 比对结果 [s][n][c][i][0]=id, [s][n][c][i][1]=posibility + s<<16 + n<<24
// hProcessWnd 进度窗口 NULL=取数据
//返 回 值: 成功返回0, 否则返回错误号
extern CM_Initialize f_CM_Initialize;
extern CM_Release f_CM_Release;
extern CM_Clear f_CM_Clear;
extern CM_Compose f_CM_Compose;
extern CM_RecombineFiles f_CM_RecombineFiles;
extern CM_GetSegmentInfo f_CM_GetSegmentInfo;
extern CM_GetTracksInfo f_CM_GetTracksInfo;
extern CM_MakeStyle f_CM_MakeStyle;
extern CM_DeleteTrack f_CM_DeleteTrack;
extern CM_GetStyleInfo f_CM_GetStyleInfo;
extern CM_GetStyleInfos f_CM_GetStyleInfos;
extern CM_GenerateCheckData f_CM_GenerateCheckData;
extern CM_CompareStyle f_CM_CompareStyle;
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
// MediaModule函数段
//
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*MM_InitialObjects) ( HWND hWnd, char* strRoot );
//功 能:初始化DirectMusic对象
//输 入:hWnd 函数调用窗口句柄
// strRoot 应用程序根目录
//返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT(*MM_DestroyObjects)();
// 功 能:释放对象
// 输 入:无
// 返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*MM_GetFontInfo)( char* strFileName, char* strFontName,
int* nInst, void* setInsts,
int* nDrum, void* setDrums );
//功 能:获取音色库信息
//输 入:[IN] strFileName 音色库文件名
// [OUT]strFontName 音色库名称
// [OUT]nInst 乐器音色数(bank=0)
// [OUT]setInsts 乐器音色信息
// [OUT]nDrum 鼓组音色数(bank=128)
// [OUT]setDrums 鼓组音色信息
//返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*MM_SetDefaultFont)( int num, char strFiles[][256] );
//功 能:设置缺省音色库
//输 入:
// num 文件数
// strFile 音色库文件名数组
// 返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*MM_LoadCompose)( int iFile, LPBYTE lpData, DWORD dwDataSize, int iFont, char* strFontFile );
//功 能:加载编曲数据
//输 入:
// iFile MIDI文件号
// lpData MIDI数据
// dwDataSize 数据大小
// iFont 音源号
// strFontFile 音源文件名
//返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI void (*MM_FreeComposes)();
//功 能:清空编曲数据
//输 入:
//返回值:无
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT(*MM_Stop)();
// 功 能:停止播放
// 输 入:
// 返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*MM_Play)( HWND hNotifyWnd, DOUBLE dblStartPoint, int iType );
//功 能:播放
//输 入:hNotifyWnd 接收播放消息的窗口句柄
// dwStartPoint 开始位置
// iChans 播放的通道类型
// TYPE_BASECOMPOSE=0x01, TYPE_COMPOSE=0x02, TYPE_AUDIO=0x04, TYPE_SONG=0x08
// TYPE_BEAT=0x10 TYPE_AUDIO_BASECOMPOSE=0x05, TYPE_SONG_COMPOSE=0x0A
//返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*MM_LoadDemo)( LPBYTE lpDemoData, DWORD dwDataSize );
//功 能:加载乐器通道试听
//输 入:
// lpDemoData 试听数据
// dwDataSize 数据长度
//返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*MM_PlayDemo)( HWND hNotifyWnd, double dblBarPlay, int iChno, int iProg,
int iBank, char* strFontFile );
//功 能:播放乐器通道试听
//输 入:hNotifyWnd 接收播放消息的窗口句柄
// dblBarPlay 播放起始小节 -1=循环播放
// iChno 通道号 -1=不改变
// iProg 乐器号 -1=不改变
// iBank 音源号 -1=缺省音源
// strFontFile 音源文件名
//返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*MM_SetTempo)( int nTempo );
//功 能:设置速度
//输 入:nTempo 速度(拍/分钟)
//返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*MM_SetTimeSignature)( int nTimeSignature );
//功 能:设置节拍
//输 入:nTimeSignature 节拍(0=4/4, 1=3/4, 2=2/4, 3=6/8
//返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*MM_SetTrackEvent)( int iEvent, int iStartBar, int iEndBar,
int iChan, int nValue, int iStream );
//功 能:设置通道事件
//输 入:iEvent 事件号
// iFirstBar 起始小节
// iLastBar 结束小节
// iChan 通道号
// nValue 参数值
// iStream 0=完整编曲 -1=Demo
//返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
extern MM_InitialObjects f_MM_InitialObjects;
extern MM_DestroyObjects f_MM_DestroyObjects;
extern MM_GetFontInfo f_MM_GetFontInfo;
extern MM_SetDefaultFont f_MM_SetDefaultFont;
extern MM_LoadCompose f_MM_LoadCompose;
extern MM_FreeComposes f_MM_FreeComposes;
extern MM_Stop f_MM_Stop;
extern MM_Play f_MM_Play;
extern MM_LoadDemo f_MM_LoadDemo;
extern MM_PlayDemo f_MM_PlayDemo;
extern MM_SetTempo f_MM_SetTempo;
extern MM_SetTimeSignature f_MM_SetTimeSignature;
extern MM_SetTrackEvent f_MM_SetTrackEvent;
/////////////////////////////////////////////////////////////////////////////////////////
string wstr2str(const wstring& _src);
wstring str2wstr(const string& _src);
string UFF8ToMBCS(const char *pcUtf8);
void DebugPrint(const char * fmt, ...);
/////////////////////////////////////////////////////////////////////////////////////////
// ClientService函数段
//
extern TSOFTWAREINFO g_infoSoftwareUpdate;
extern int g_nBuildVersion;
extern TUSERINFO g_infoUser;
extern bool g_bAutoLogin, g_bLogon;
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT(*CS_UpdateStyle)(UINT idUser, HWND hProcessWnd);
// 功 能:刷新待审核风格信息
// 参 数:idUser 用户ID
// hProcessWnd 进度消息接收窗口
// 返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT(*CS_CheckStyle)( UINT idTmpStyle, UINT idUser, int score, char* strMsg );
// 功 能:审核风格
// 参 数:
// idTmpStyle 临时风格ID
// idUser 用户ID
// score 评分 0=未通过
// strMsg 未通过的原因
// 返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT(*CS_UploadStyle)(int iType, UINT idUser, int nDataSize, char* pData,
HWND hProcessWnd);
// 功 能:上传风格文件数据
// 参 数:
// iType 上传类型 1=批量上传 2=制作上传 3=分享上传
// idUser 用户ID
// nDataSize 风格文件数据大小
// pData 风格文件数据
// hProcessWnd 进度消息接收窗口
// 返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT (*CS_InitialService)( HWND hWnd, int iClientType, PTSOFTWAREINFO pSofewareInfo,
char* strURL, char* strRoot, char idDevice[6] );
//功 能:初始化客户端服务
//参 数:hWnd 函数调用窗口句柄
// iClientType 客户端类型(软件内部编号)
// pSofewareInfo[in,out] 传入当前版本,获取更新版本
// strURL 网站服务器名称 http://xxx.xxx.xxx:xx/
// strRoot 资源文件根目录
// idDevice 设备号
//返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT(*CS_DestroyService)();
// 功 能:解除客户端服务
// 输 入:无
// 返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT(*CS_Login)(PTUSERINFO pUserInfo, BOOL bSync);
// 功 能:用户登录
// 参 数:pUserInfo[in,out] 传入用户名和密码,输出用户信息
// bSync 同步=TURE,异步=FALSE
// 返回值:错误号
// 正常登录 = 0
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT(*CS_Logoff)();
// 功 能:注销或取消登录
// 参 数:无
// 返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
typedef DLLAPI HRESULT(*CS_CancelOperation)();
// 功 能:取消操作
// 参 数:
// 返回值:错误号
/////////////////////////////////////////////////////////////////////////////////////////
extern CS_InitialService f_CS_InitialService;
extern CS_DestroyService f_CS_DestroyService;
extern CS_Login f_CS_Login;
extern CS_Logoff f_CS_Logoff;
extern CS_UploadStyle f_CS_UploadStyle;
extern CS_CancelOperation f_CS_CancelOperation;
/*
extern CS_DownloadStyle f_CS_DownloadStyle;
*/
extern CS_UpdateStyle f_CS_UpdateStyle;
extern CS_CheckStyle f_CS_CheckStyle;
/////////////////////////////////////////////////////////////////////////////////////////
HRESULT GetMFFunctions(HINSTANCE hDll);
HRESULT GetMMFunctions(HINSTANCE hDll);
HRESULT GetCSFunctions(HINSTANCE hDll);
HRESULT GetMSFunctions(HINSTANCE hDll);
HRESULT GetSMFunctions(HINSTANCE hDll);
string GBToUTF8(const char* str);
void SetPlayTimer(bool bStart, UINT& tTimer, UINT& tAccuracy,
void* pUser = NULL);
wstring GetElementInfo(int iElem, int iList);
void CALLBACK OnMediaTimer(UINT tTimerID, UINT msg, DWORD dwUser, DWORD dwl,
DWORD dw2);
void SetAutoLogin(bool bAuto, LPCSTR strName, LPCSTR strPwd);
bool GetAutoLogin(char* strName, char* strPwd);
#endif
+782
View File
@@ -0,0 +1,782 @@
// ---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "HarmonyFormUnit.h"
#include "Instruments.h"
#include "GlobalUnit.h"
// ---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
const BYTE u_arrChordPreset[2][4] = { {0,20,28,0}, {37,9,17,37} }; //预置大小调和弦
THarmonyForm *HarmonyForm;
// ---------------------------------------------------------------------------
__fastcall THarmonyForm::THarmonyForm(TComponent* Owner, UINT idLoc, UINT idStyle)
: TForm(Owner)
{
m_pPopMenu = NULL;
m_iAccTypeFlg = -1;
m_bPlayAcc = m_bPlayComp = false;
m_bIsSave = false;
m_idLoc = idLoc;
m_idStyle = idStyle;
m_iPlayAccIndex = m_iPlayCompIndex = -1;
}
// ---------------------------------------------------------------------------
void __fastcall THarmonyForm::FormClose(TObject *Sender, TCloseAction &Action)
{
f_MM_Stop();
f_MM_LoadDemo( NULL, 0 );
if (m_bIsSave) {
ModalResult = mrOk;
}
if( m_pPopMenu ){
m_pPopMenu->CloseMenu();
delete m_pPopMenu;
}
}
// ---------------------------------------------------------------------------
void __fastcall THarmonyForm::FormActivate(TObject *Sender)
{
memset( info, 0, 4*8*2*2 );
int ret = f_CM_GetSegmentInfo( m_idLoc, m_idStyle, info );
if( ret!=0 )
return;
if( !g_bRecreator ){
memset( check, 0, 2*4*2*5*2*sizeof(UINT) );
ret = f_CM_CompareStyle( m_idLoc, m_idStyle, check, NULL );
}
for( int s=0; s<4; s++ ){
for (int n=0; n<8; n++) {
if( info[s][n][0][0]==0 && info[s][n][1][0]==0 )
break;
bool bWarn = false;
if( g_bRecreator ){ //比较大小调tracks
char trkMaj[16][3], trkMin[16][3];
memset( trkMaj, 0, 16*3 );
memset( trkMin, 0, 16*3 );
int num1 = f_CM_GetTracksInfo( m_idLoc, m_idStyle, s, n, 0, trkMaj );
int num2 = f_CM_GetTracksInfo( m_idLoc, m_idStyle, s, n, 1, trkMin );
if( num1!=num2 ){
bWarn = true;
}
else{
for( int i=0; i<num1; i++ ){
bool bDiff = true;
for( int j=0; j<num2; j++ ){
if( trkMin[j][0]==trkMaj[i][0] ){
if( trkMin[j][1]==trkMaj[i][1] )
bDiff = false;
break;
}
}
if( bDiff ){
bWarn = true;
break;
}
}
}
}
for( int c=0; c<2; c++ ){
if( s>=2 || c==0 || g_bRecreator ){
DWORD param = ( s<<16 ) + ( n<<8 ) + c;
String strValue = s==0 ? "伴奏" : s==1 ? "加花" : s==2 ? "前奏" : "尾奏";
strValue += IntToStr(n + 1);
strValue += c==0 ? " 大调 ( " : " 小调 ( ";
strValue += IntToStr( info[s][n][c][0] );
strValue += " bars ";
strValue += IntToStr( info[s][n][c][1] );
strValue += " trks )";
if( g_bRecreator ){
if( !bWarn && info[s][n][1-c][0]!=info[s][n][c][0] )
bWarn = true;
}
else if( s>=2 ){ //检查IE是否与其它风格相同
if( check[s-2][n][c][0][0]>0 )
bWarn = true;
}
if( bWarn ){
param += 1<<24;
}
m_plstAcc->Items->AddObject(strValue, (TObject*)param );
}
}
}
}
if( g_bRecreator ){
m_plstAccPrm->Height = m_plstAcc->Height;
m_lstCheck->Visible = false;
}
}
// ---------------------------------------------------------------------------
void __fastcall THarmonyForm::m_plstAccClick(TObject *Sender)
{
if( m_plstAccPrm->Items->Count>0 )
m_plstAccPrm->Items->Clear();
if( m_lstCheck->Items->Count>0 )
m_lstCheck->Items->Clear();
TListBox * pLst = m_plstAcc;
int iHotIndex = pLst->ItemIndex;
if( ( m_bPlayAcc || m_bPlayComp ) && m_iPlayAccIndex!=iHotIndex ){
PlayClick(NULL);
}
if( iHotIndex<0 )
return;
DWORD param = (DWORD)pLst->Items->Objects[iHotIndex];
char s = HIWORD( param ) & 0xFF,
n = LOWORD( param ) >> 8,
c = param & 0xFF;
int p = 1-c;
char track[16][3], trkp[16][3];
memset( track, 0, 16*3 );
memset( trkp, 0, 16*3 );
int num1 = f_CM_GetTracksInfo( m_idLoc, m_idStyle, s, n, c, track ),
num2 = g_bRecreator ? f_CM_GetTracksInfo( m_idLoc, m_idStyle, s, n, p, trkp ) : 0;
for( int i=0; i<num1; i++ ){
char buff[512];
bool bDrum = ( track[i][0]==9 );
sprintf( buff, "ch%02d %s", track[i][0]+1, bDrum ? "鼓组" : GM_INSTRUMENT[track[i][1]] );
String strTrack = buff;
if( bDrum )
strTrack += IntToStr( track[i][1] );
bool bDiff = g_bRecreator;
if( g_bRecreator ){
for( int j=0; j<num2; j++ ){
if( trkp[j][0]==track[i][0] ){
if( trkp[j][1]==track[i][1] )
bDiff = false;
break;
}
}
}
DWORD value = (bDiff<<24) + (track[i][0]<<16) + (track[i][1]<<8) + track[i][2];
int ind = m_plstAccPrm->Items->AddObject( strTrack, (TObject*)value );
m_plstAccPrm->Checked[ind] = true;
}
if( !g_bRecreator ){
if( m_lstCheck->Items->Count>0 )
m_lstCheck->Items->Clear();
if( s>=2 ){
int seg = s-2;
for( int i=0; i<5; i++ ){
if( check[seg][n][c][i][0]>0 ){
TPROSTYLE * pOriStyle = new TPROSTYLE;
pOriStyle->pOrigin = new TSTYLEORIGIN;
f_CM_GetStyleInfo( 0, check[seg][n][c][i][0], pOriStyle );
char buff[512];
WORD poss = LOWORD(check[seg][n][c][i][1]);
char sO = ( check[seg][n][c][i][1] & 0xFF0000 ) >> 16,
nO = ( check[seg][n][c][i][1] & 0xFF000000 ) >> 24;
// 85% [162]摇动的旋律 前奏1大调
sprintf( buff, "[%d]%s %s%d %s",
check[seg][n][c][i][0],
UFF8ToMBCS(pOriStyle->pOrigin->detail.strStyleName).c_str(),
sO==2 ? "前奏" : "尾奏",
nO,
c==0 ? "大调" : "小调" );
m_lstCheck->Items->AddObject( buff, (TObject*)poss );
}
else
break;
}
}
}
}
// ---------------------------------------------------------------------------
void __fastcall THarmonyForm::m_plstAccPrmClickCheck(TObject *Sender)
{
if( !m_bPlayAcc )
return;
// Here we can set the harmony's paramater
TCheckListBox * pChLst = (TCheckListBox*)Sender;
DWORD param = (DWORD)pChLst->Items->Objects[pChLst->ItemIndex];
bool bMute = !pChLst->Checked[pChLst->ItemIndex];
char chan = HIWORD(param) & 0xFF,
vol = bMute ? 0 : (LOWORD(param) & 0xFF);
param = (DWORD)m_plstAcc->Items->Objects[m_plstAcc->ItemIndex];
char s = HIWORD( param ) & 0xFF,
n = LOWORD( param ) >> 8,
c = param & 0xFF;
int iEndBar = 4;
if( s>=SEGTYPE_INTRO ){
iEndBar = info[s][n][c][0];
}
f_MM_SetTrackEvent( MIDI_EVENT_VOLUME, 0, iEndBar, chan, vol, -1 );
}
// ---------------------------------------------------------------------------
int THarmonyForm::GetAccIndexByName(const String strAccName)
{
int iRet = -1;
AnsiString strTmp = strAccName.Trim();
if (strTmp == L"")
return iRet;
for (int index = 0; index < MAX_PATH; index++) {
if (0 == strcmp(GM_INSTRUMENT[index], strTmp.c_str())) {
iRet = index;
break;
}
}
return iRet;
}
// ---------------------------------------------------------------------------
void __fastcall THarmonyForm::PlayClick(TObject *Sender)
{
if( m_bPlayAcc || m_bPlayComp ){
f_MM_Stop();
f_MM_LoadDemo( NULL, 0 );
m_btnPlay->Caption = "试听";
m_bPlayAcc = m_bPlayComp = false;
m_iPlayAccIndex = m_iPlayCompIndex = -1;
}
else{
int iHotIndex = m_plstAcc->ItemIndex;
if (iHotIndex < 0)
return;
int iChkIndex = m_lstCheck->ItemIndex;
if( iChkIndex>=0 )
PlayCompDemo( iHotIndex, iChkIndex );
else
PlayAccDemo( iHotIndex );
}
}
// ---------------------------------------------------------------------------
void __fastcall THarmonyForm::OnSaveHarmParamClick(TObject *Sender)
{
m_bIsSave = true;
ModalResult = mrOk;
}
// ---------------------------------------------------------------------------
void __fastcall THarmonyForm::m_plstAccDblClick(TObject *Sender)
{
if( m_bPlayAcc || m_bPlayComp )
PlayClick(NULL);
int iHotIndex = m_plstAcc->ItemIndex;
if (iHotIndex < 0)
return;
PlayAccDemo( iHotIndex );
}
// ---------------------------------------------------------------------------
void __fastcall THarmonyForm::m_plstAccDrawItem(TWinControl *Control, int Index, TRect &Rect,
TOwnerDrawState State)
{
TListBox* pList = (TListBox*)Control;
DWORD param = (DWORD) pList->Items->Objects[Index];
char s = HIWORD( param ) & 0xFF,
q = HIWORD( param ) >> 8,
n = LOWORD( param ) >> 8,
c = param & 0xFF;
TRect rcDraw = Rect;
pList->Canvas->Brush->Color = g_clrSegment[s][n];
pList->Canvas->FillRect( rcDraw );
if( State.Contains(odSelected) ){
pList->Canvas->Brush->Color = clRed;
pList->Canvas->FrameRect( rcDraw );
}
else{
//绘制下边框
if( c==0 )
pList->Canvas->Pen->Color = clWhite;
else
pList->Canvas->Pen->Color = clSilver;
pList->Canvas->MoveTo( rcDraw.left, rcDraw.bottom-1 );
pList->Canvas->LineTo( rcDraw.right, rcDraw.bottom-1 );
}
String strText = pList->Items->Strings[Index];
pList->Canvas->Brush->Style = bsClear;
pList->Canvas->Font->Color = clBlack;
pList->Canvas->TextOut( rcDraw.left+5, rcDraw.top+1, strText );
if( q!=0 ){
pList->Canvas->TextOut( rcDraw.right-20, rcDraw.top+1, L"?" );
}
}
//---------------------------------------------------------------------------
void __fastcall THarmonyForm::m_plstAccPrmDrawItem(TWinControl *Control, int Index, TRect &Rect,
TOwnerDrawState State)
{
TCheckListBox* pList = (TCheckListBox*)Control;
DWORD param = (DWORD) pList->Items->Objects[Index];
bool bDiff = HIWORD(param) & 0xFF00;
pList->Canvas->Brush->Color = clWhite;
pList->Canvas->FillRect( Rect );
if( State.Contains(odSelected) ){
pList->Canvas->DrawFocusRect( Rect );
}
String strText = pList->Items->Strings[Index];
pList->Canvas->Brush->Style = bsClear;
if( bDiff )
pList->Canvas->Font->Color = clRed;
else
pList->Canvas->Font->Color = clBlack;
pList->Canvas->TextOut( Rect.left+5, Rect.top+3, strText );
}
//---------------------------------------------------------------------------
void __fastcall THarmonyForm::ProgramMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
int X, int Y)
{
TCheckListBox* pList = (TCheckListBox*)Sender;
int iSelIndex = pList->ItemAtPos(TPoint(X,Y),true);
if( iSelIndex<0 ){
pList->ItemIndex = -1;
m_plstAcc->SetFocus();
return;
}
else{
pList->ItemIndex = iSelIndex;
}
if( Button==mbRight && g_bRecreator ){
DWORD param = (DWORD)pList->Items->Objects[iSelIndex];
char chan = HIWORD(param) & 0xFF;
if( chan==9 || pList->Items->Count==1 )
return;
if( !m_pPopMenu ){
m_pPopMenu = new TPopupMenu(NULL);
TMenuItem* pMenuItem = new TMenuItem(m_pPopMenu);
//pMenuItem->Enabled = true;
pMenuItem->Caption = L"删除";
pMenuItem->OnClick = OnDeleteTrack;
m_pPopMenu->Items->Add(pMenuItem);
}
TPoint point(X,Y);
point = pList->ClientToScreen(point);
m_pPopMenu->Tag = chan;
m_pPopMenu->Popup( point.X, point.Y );
}
}
//---------------------------------------------------------------------------
void __fastcall THarmonyForm::OnDeleteTrack(TObject *Sender)
{
char chan = m_pPopMenu->Tag;
if( chan<0 )
return;
int iHotIndex = m_plstAcc->ItemIndex;
if (iHotIndex < 0)
return;
DWORD param = (DWORD)m_plstAcc->Items->Objects[iHotIndex];
char s = HIWORD( param ) & 0xFF,
q = HIWORD( param ) >> 8,
n = LOWORD( param ) >> 8,
c = param & 0xFF;
int ret = f_CM_DeleteTrack( m_idStyle, s, n, c, chan );
if( ret==0 ){
info[s][n][c][1]--;
int p = 1 - c;
char q = 0;
if( info[s][n][p][0]!=info[s][n][c][0] || info[s][n][p][1]!=info[s][n][c][1] )
q = 1;
if( q==0 ){
char trkMaj[16][3], trkMin[16][3];
memset( trkMaj, 0, 16*3 );
memset( trkMin, 0, 16*3 );
int num1 = f_CM_GetTracksInfo( m_idLoc, m_idStyle, s, n, 0, trkMaj );
int num2 = f_CM_GetTracksInfo( m_idLoc, m_idStyle, s, n, 1, trkMin );
if( num1!=num2 ){
q = 1;
}
else{
for( int i=0; i<num1; i++ ){
bool bDiff = true;
for( int j=0; j<num2; j++ ){
if( trkMin[j][0]==trkMaj[i][0] ){
if( trkMin[j][1]==trkMaj[i][1] )
bDiff = false;
break;
}
}
if( bDiff ){
q = 1;
break;
}
}
}
}
String strValue = s==0 ? "伴奏" : s==1 ? "加花" : s==2 ? "前奏" : "尾奏";
strValue += IntToStr(n + 1);
strValue += c==0 ? " 大调 ( " : " 小调 ( ";
strValue += IntToStr( info[s][n][c][0] );
strValue += " bars ";
strValue += IntToStr( info[s][n][c][1] );
strValue += " trks )";
DWORD param = ( s<<16 ) + ( n<<8 ) + c;
if( q>0 ) param += 1<<24;
m_plstAcc->Items->Strings[iHotIndex] = strValue;
m_plstAcc->Items->Objects[iHotIndex] = (TObject*)param;
param = ( s<<16 ) + ( n<<8 ) + p;
if( q>0 ) param += 1<<24;
int iPair = c==0 ? iHotIndex+1 : iHotIndex-1;
m_plstAcc->Items->Objects[iPair] = (TObject*)param;
m_plstAcc->Invalidate();
m_plstAccClick(NULL);
}
}
//---------------------------------------------------------------------------
void __fastcall THarmonyForm::ListCheckDblClick(TObject *Sender)
{
if( m_bPlayAcc || m_bPlayComp )
PlayClick(NULL);
int iHotIndex = m_plstAcc->ItemIndex;
if( iHotIndex<0 )
return;
int iChkIndex = m_lstCheck->ItemIndex;
if( iChkIndex<0 )
return;
PlayCompDemo( iHotIndex, iChkIndex );
}
//---------------------------------------------------------------------------
void THarmonyForm::PlayAccDemo( int index )
{
DWORD param = (DWORD)m_plstAcc->Items->Objects[index];
char s = HIWORD( param ) & 0xFF,
n = LOWORD( param ) >> 8,
c = param & 0xFF;
if( s!=-1 ){
TStage* aStages = NULL;
int nStageNum = 0;
int barNum = 4;
if( s>=SEGTYPE_INTRO ){
barNum = info[s][n][c][0];
}
nStageNum = 1;
aStages = new TStage[1];
aStages->iSegType = s;
aStages->nBarNum = barNum;
int trkNum = m_plstAccPrm->Items->Count;
aStages->nTrkNum = trkNum;
aStages->aTracks = new TTrack[trkNum];
for( int i=0; i<trkNum; i++ ){
aStages->aTracks[i].iStyleLoc = m_idLoc;
aStages->aTracks[i].iStyleId = m_idStyle;
if( s>=SEGTYPE_INTRO ){
aStages->aTracks[i].iSegNo = n + (( c + 1) << 4);
}
else
aStages->aTracks[i].iSegNo = n;
DWORD paramT = (DWORD) m_plstAccPrm->Items->Objects[i];
char chan = HIWORD(paramT) & 0xFF,
prog = LOWORD(paramT) >> 8,
vol = LOWORD(paramT) & 0xFF;
bool bMute = !m_plstAccPrm->Checked[i];
aStages->aTracks[i].iChanNo = chan;
aStages->aTracks[i].iChanSpec = chan;
aStages->aTracks[i].iProg = prog;
aStages->aTracks[i].nVol = bMute ? 0 : vol;
}
if( s<=SEGTYPE_FILL ){
aStages->aChords = new TBarChords[barNum];
for( int j=0; j<barNum; j++ ){
char chordType = u_arrChordPreset[c][j] % 4;
char chordKey = u_arrChordPreset[c][j] / 4;
aStages->aChords[j].iKey[0]
= aStages->aChords[j].iKey[1]
= aStages->aChords[j].iKey[2]
= aStages->aChords[j].iKey[3] = chordKey;
aStages->aChords[j].iType[0]
= aStages->aChords[j].iType[1]
= aStages->aChords[j].iType[2]
= aStages->aChords[j].iType[3] = chordType;
}
}
int len = 1000000;
BYTE* data = new BYTE[len];
int ret = f_CM_Compose( &len, data, g_iMelodyTimeSignature, g_nMelodyTempo,
nStageNum, aStages, false, NULL, NULL );
if( ret==0 ){
f_MM_LoadDemo( data, len );
f_MM_PlayDemo( Handle, -1, -1, -1, -1, NULL );
m_btnPlay->Caption = "停止";
m_bPlayAcc = true;
m_iPlayAccIndex = index;
}
else{
String strError = L"获取风格试听数据失败,错误码:" + IntToStr(ret);
OutputDebugString(strError.c_str());
}
delete data;
}
}
//---------------------------------------------------------------------------
void THarmonyForm::PlayCompDemo( int iAcc, int iCheck )
{
DWORD param = (DWORD)m_plstAcc->Items->Objects[iAcc];
char s = HIWORD( param ) & 0xFF,
n = LOWORD( param ) >> 8,
c = param & 0xFF;
if( s>=2 ){
UINT idStyle = check[s-2][n][c][iCheck][0];
if( idStyle==0 )
return;
TPROSTYLE* pStyle = new TPROSTYLE;
pStyle->pOrigin = new TSTYLEORIGIN;
if( f_CM_GetStyleInfo( 0, idStyle, pStyle )!=0 )
return;
char sO = ( check[s-2][n][c][iCheck][1] & 0xFF0000 ) >> 16,
nO = ( check[s-2][n][c][iCheck][1] & 0xFF000000 ) >> 24;
int sn = nO;
if( c>0 ){
sn += 4;
}
TSTYLEDETAIL& detail = pStyle->pOrigin->detail;
int barNum = (s==2) ? detail.aIntroBars[sn]
: detail.aEndingBars[sn];
TStage* aStages = NULL;
int nStageNum = 0;
nStageNum = 1;
aStages = new TStage[1];
aStages->iSegType = s;
aStages->nBarNum = barNum;
int trkNum = 0;
for( trkNum=0; trkNum<16 && detail.tracks[s][sn][trkNum].no>=0; trkNum++ );
aStages->nTrkNum = trkNum;
aStages->aTracks = new TTrack[trkNum];
for( int i=0; i<trkNum; i++ ){
aStages->aTracks[i].iStyleLoc = pStyle->idLoc;
aStages->aTracks[i].iStyleId = pStyle->idStyle;
aStages->aTracks[i].iSegNo = nO + (( c + 1) << 4);
aStages->aTracks[i].iChanNo = aStages->aTracks[i].iChanSpec =
detail.tracks[s][sn][i].no;
aStages->aTracks[i].iProg = detail.tracks[s][sn][i].prog;
aStages->aTracks[i].nVol = detail.tracks[s][sn][i].vol;
}
delete pStyle;
int len = 1000000;
BYTE* data = new BYTE[len];
int ret = f_CM_Compose( &len, data, g_iMelodyTimeSignature, g_nMelodyTempo,
nStageNum, aStages, false, NULL, NULL );
if( ret==0 ){
f_MM_LoadDemo( data, len );
f_MM_PlayDemo( Handle, -1, -1, -1, -1, NULL );
m_btnPlay->Caption = "停止";
m_bPlayComp = true;
m_iPlayAccIndex = iAcc;
m_iPlayCompIndex = iCheck;
}
else{
String strError = L"获取风格试听数据失败,错误码:" + IntToStr(ret);
OutputDebugString(strError.c_str());
}
delete data;
}
}
//---------------------------------------------------------------------------
void __fastcall THarmonyForm::ListCheckClick(TObject *Sender)
{
int index = m_lstCheck->ItemIndex;
if( m_bPlayComp && m_iPlayCompIndex!=index ){
PlayClick(NULL);
}
}
//---------------------------------------------------------------------------
void __fastcall THarmonyForm::ListCheckDrawItem(TWinControl *Control, int Index, TRect &Rect,
TOwnerDrawState State)
{
TListBox* pList = (TListBox*)Control;
WORD poss = (WORD) pList->Items->Objects[Index];
char buff[20];
sprintf( buff, "%6d%%", poss );
TRect rcDraw = Rect;
int n = (poss-20)/10;
if( n>7 ) n=7;
pList->Canvas->Brush->Color = g_clrSegment[0][n];
pList->Canvas->FillRect( rcDraw );
if( State.Contains(odSelected) ){
pList->Canvas->Brush->Color = clRed;
pList->Canvas->FrameRect( rcDraw );
}
else{
//绘制下边框
pList->Canvas->Brush->Color = clSilver;
pList->Canvas->FrameRect( rcDraw );
}
String strText = pList->Items->Strings[Index];
pList->Canvas->Brush->Style = bsClear;
pList->Canvas->Font->Color = clBlack;
pList->Canvas->TextOut( rcDraw.left+5, rcDraw.top+3, strText );
pList->Canvas->TextOut( rcDraw.right-40, rcDraw.top+3, buff );
}
//---------------------------------------------------------------------------
void __fastcall THarmonyForm::ListCheckMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
TListBox* pList = (TListBox*)Sender;
int iSelIndex = pList->ItemAtPos(TPoint(X,Y),true);
if( iSelIndex<0 ){
pList->ItemIndex = -1;
m_plstAcc->SetFocus();
return;
}
}
//---------------------------------------------------------------------------
void __fastcall THarmonyForm::ListAccMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
TListBox* pList = (TListBox*)Sender;
int iSelIndex = pList->ItemAtPos(TPoint(X,Y),true);
if( iSelIndex<0 ){
pList->ItemIndex = -1;
m_plstAcc->SetFocus();
return;
}
}
//---------------------------------------------------------------------------
void __fastcall THarmonyForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
{
switch( Key ){
case ' '://VK_RETURN:
if( m_plstAccPrm->ItemIndex==-1 )
PlayClick(NULL);
break;
case VK_ESCAPE:
ModalResult = mrCancel;
break;
}
}
//---------------------------------------------------------------------------
+108
View File
@@ -0,0 +1,108 @@
object HarmonyForm: THarmonyForm
Left = 0
Top = 0
BorderIcons = [biSystemMenu, biMinimize]
Caption = #39118#26684#29255#27573#35814#24773
ClientHeight = 385
ClientWidth = 637
Color = clBtnFace
DoubleBuffered = True
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
KeyPreview = True
OldCreateOrder = False
Position = poOwnerFormCenter
OnActivate = FormActivate
OnClose = FormClose
OnKeyDown = FormKeyDown
PixelsPerInch = 96
TextHeight = 13
object m_plstAcc: TListBox
Left = 21
Top = 23
Width = 236
Height = 346
ParentCustomHint = False
Style = lbOwnerDrawVariable
AutoComplete = False
Ctl3D = True
ExtendedSelect = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ImeName = #20013#25991' - QQ'#20116#31508#36755#20837#27861
ItemHeight = 17
ParentCtl3D = False
ParentFont = False
ParentShowHint = False
ShowHint = False
TabOrder = 0
OnClick = m_plstAccClick
OnDblClick = m_plstAccDblClick
OnDrawItem = m_plstAccDrawItem
OnMouseDown = ListAccMouseDown
end
object m_plstAccPrm: TCheckListBox
Left = 284
Top = 23
Width = 236
Height = 186
OnClickCheck = m_plstAccPrmClickCheck
AutoComplete = False
ImeName = #20013#25991' - QQ'#20116#31508#36755#20837#27861
ItemHeight = 20
Style = lbOwnerDrawVariable
TabOrder = 1
OnDrawItem = m_plstAccPrmDrawItem
OnMouseDown = ProgramMouseDown
end
object m_btnPlay: TButton
Left = 542
Top = 23
Width = 75
Height = 25
Caption = #35797#21548
TabOrder = 2
OnClick = PlayClick
end
object btnSaveHarm: TButton
Left = 542
Top = 326
Width = 75
Height = 25
Caption = #20851#38381
TabOrder = 3
OnClick = OnSaveHarmParamClick
end
object m_lstCheck: TListBox
Left = 284
Top = 215
Width = 236
Height = 147
ParentCustomHint = False
Style = lbOwnerDrawVariable
AutoComplete = False
Ctl3D = True
ExtendedSelect = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ItemHeight = 20
ParentCtl3D = False
ParentFont = False
ParentShowHint = False
ShowHint = False
TabOrder = 4
OnClick = ListCheckClick
OnDblClick = ListCheckDblClick
OnDrawItem = ListCheckDrawItem
OnMouseDown = ListCheckMouseDown
end
end
+66
View File
@@ -0,0 +1,66 @@
//---------------------------------------------------------------------------
#ifndef HarmonyFormUnitH
#define HarmonyFormUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.CheckLst.hpp>
//---------------------------------------------------------------------------
class THarmonyForm : public TForm
{
__published: // IDE-managed Components
TListBox *m_plstAcc;
TCheckListBox *m_plstAccPrm;
TButton *m_btnPlay;
TButton *btnSaveHarm;
TListBox *m_lstCheck;
void __fastcall m_plstAccClick(TObject *Sender);
void __fastcall m_plstAccPrmClickCheck(TObject *Sender);
void __fastcall PlayClick(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall FormActivate(TObject *Sender);
void __fastcall OnSaveHarmParamClick(TObject *Sender);
void __fastcall m_plstAccDblClick(TObject *Sender);
void __fastcall m_plstAccDrawItem(TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State);
void __fastcall m_plstAccPrmDrawItem(TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State);
void __fastcall ProgramMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X,
int Y);
void __fastcall ListCheckDblClick(TObject *Sender);
void __fastcall ListCheckClick(TObject *Sender);
void __fastcall ListCheckDrawItem(TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State);
void __fastcall ListCheckMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X,
int Y);
void __fastcall ListAccMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y);
void __fastcall FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
private: // User declarations
TPopupMenu * m_pPopMenu;
int m_iAccTypeFlg;
bool m_bPlayAcc, m_bPlayComp;
bool m_bIsSave;
int m_iPlayAccIndex, m_iPlayCompIndex;
char info[4][8][2][2];
UINT check[2][4][2][5][2];
UINT m_idLoc, m_idStyle;
void __fastcall OnDeleteTrack(TObject *Sender);
void PlayAccDemo( int index );
void PlayCompDemo( int iAcc, int iChcek );
protected:
int GetAccIndexByName(const String strAccName);
public: // User declarations
__fastcall THarmonyForm(TComponent* Owner, UINT idLoc, UINT idStyle );
};
//---------------------------------------------------------------------------
extern PACKAGE THarmonyForm *HarmonyForm;
//---------------------------------------------------------------------------
#endif
+167
View File
@@ -0,0 +1,167 @@
#include "Instruments.h"
#pragma package(smart_init)
char * GM_INSTRUMENT[] = {
//钢琴组
"大钢琴"
,"明亮钢琴"
,"电钢琴"
,"酒吧钢琴"
,"柔和电钢琴"
,"合唱电钢琴"
,"拨弦古钢琴"
,"击弦古钢琴"
//打击乐器组
,"钢片琴"
,"钟琴"
,"八音盒"
,"颤音琴"
,"马林巴"
,"木琴"
,"管钟"
,"杨琴"
//风琴组
,"击杆风琴"
,"打击式风琴"
,"摇滚风琴"
,"教堂风琴"
,"簧管风琴"
,"手风琴"
,"口琴"
,"探戈手风琴"
//吉他组
,"尼龙弦吉他"
,"钢弦吉他"
,"爵士电吉他"
,"清音电吉他"
,"闷音电吉他"
,"过激电吉他"
,"失真电吉他"
,"吉他泛音"
//贝司组
,"原音贝司"
,"指弹电贝司"
,"拨片电贝司"
,"无品贝司"
,"掌击贝司1"
,"掌击贝司2"
,"合成贝司1"
,"合成贝司2"
//提琴组
,"小提琴"
,"中提琴"
,"大提琴"
,"低音大提琴"
,"颤音弦乐组"
,"拨奏弦乐组"
,"竖琴"
,"定音鼓"
//合奏/合唱组
,"弦乐合奏1"
,"弦乐合奏2"
,"合成弦乐合奏1"
,"合成弦乐合奏2"
,"人声合唱(啊)"
,"人声合唱(嘟)"
,"合成人声"
,"管弦乐齐奏"
//铜管乐器组
,"小号"
,"长号"
,"大号"
,"弱音小号"
,"圆号"
,"铜管组"
,"合成铜管1"
,"合成铜管2"
//簧片乐器组
,"高音萨克斯"
,"中音萨克斯"
,"次中音萨克斯"
,"低音萨克斯"
,"双簧管"
,"英国管"
,"巴松(大管)"
,"单簧管(黑管)"
//木管乐器组
,"短笛"
,"长笛"
,"竖笛"
,"排箫"
,"吹瓶"
,"日本尺八"
,"口哨声"
,"陶笛(洋埙)"
//合成主音组
,"合成主音1(方波)"
,"合成主音2(锯齿波)"
,"合成主音3"
,"合成主音4"
,"合成主音5"
,"合成主音6(人声)"
,"合成主音7(平行五度)"
,"合成主音8(贝司与主音)"
//合成背景组
,"合成背景1(新时代)"
,"合成背景2(温暖)"
,"合成背景3"
,"合成背景4(合唱)"
,"合成背景5(弓弦)"
,"合成背景6(金属)"
,"合成背景7(光环)"
,"合成背景8"
//合成效果组
,"效果(雨声)"
,"效果(音轨)"
,"效果(水晶)"
,"效果(大气)"
,"效果(明亮)"
,"效果(诡异)"
,"效果(回声)"
,"效果(科幻)"
//民族乐器组
,"西塔尔"
,"班卓琴"
,"三昧线"
,"十三弦筝"
,"卡林巴"
,"风笛"
,"民族提琴"
,"山奈"
//打击乐器组
,"叮当铃"
,"阿果果"
,"钢鼓"
,"木鱼"
,"太鼓"
,"通通鼓"
,"合成鼓"
,"钢钹"
//特殊音效组
,"吉他换把杂音"
,"呼吸声"
,"海浪声"
,"鸟鸣"
,"电话铃"
,"直升飞机"
,"鼓掌声"
,"枪声"
};
+8
View File
@@ -0,0 +1,8 @@
//---------------------------------------------------------------------------
#ifndef InstrumentsH
#define InstrumentsH
extern char * GM_INSTRUMENT[];
#endif
+91
View File
@@ -0,0 +1,91 @@
// ---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "LoginFormUnit.h"
#include "GlobalUnit.h"
// ---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TLoginForm *LoginForm;
// ---------------------------------------------------------------------------
__fastcall TLoginForm::TLoginForm(TComponent* Owner) : TForm(Owner)
{
m_strUsername = g_infoUser.strUserName;
}
// ---------------------------------------------------------------------------
void __fastcall TLoginForm::LoginClick(TObject *Sender)
{
if (m_edUserName->Text.IsEmpty()) {
m_edUserName->SetFocus();
}
else if (m_edPassword->Text.IsEmpty()) {
m_edPassword->SetFocus();
}
else {
m_strUsername = m_edUserName->Text;
m_strPassword = m_edPassword->Text;
AnsiString strPW = m_strPassword;
AnsiString strTmp = (AnsiString)m_strUsername;
strcpy(g_infoUser.strUserName, strTmp.c_str() );
strcpy(g_infoUser.strPassword, strPW.c_str() );
SetAutoLogin(g_bAutoLogin, g_infoUser.strUserName, g_infoUser.strPassword);
ModalResult = mrOk;
}
}
// ---------------------------------------------------------------------------
void __fastcall TLoginForm::AutoCheckClick(TObject *Sender)
{
g_bAutoLogin = m_pbAutoCheck->Checked;
}
// ---------------------------------------------------------------------------
void __fastcall TLoginForm::FormActivate(TObject *Sender)
{
m_edUserName->Text = m_strUsername;
m_pbAutoCheck->State = g_bAutoLogin ? cbChecked : cbUnchecked;
}
// ---------------------------------------------------------------------------
void __fastcall TLoginForm::FormClose(TObject *Sender, TCloseAction &Action)
{
/* AnsiString strPW = m_strPassword = m_edPassword->Text;
AnsiString strTmp = (AnsiString)m_strUsername;
// string strTmp = GBToUTF8(aStrTmp.c_str());
memset(g_infoUser.strUserName,0,sizeof(g_infoUser.strUserName));
memset(g_infoUser.strPassword,0,sizeof(g_infoUser.strPassword));
strncpy(g_infoUser.strUserName, strTmp.c_str(), strTmp.Length());
strncpy(g_infoUser.strPassword, strPW.c_str(), strPW.Length());
SetAutoLogin(g_bAutoLogin, g_infoUser.strUserName, strPW.c_str());
*/
}
//---------------------------------------------------------------------------
void __fastcall TLoginForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
{
switch( Key ){
case VK_RETURN:
LoginClick(NULL);
break;
case VK_ESCAPE:
ModalResult = mrCancel;
break;
}
}
//---------------------------------------------------------------------------
+81
View File
@@ -0,0 +1,81 @@
object LoginForm: TLoginForm
Left = 0
Top = 0
ParentCustomHint = False
BorderStyle = bsDialog
Caption = #29992#25143#30331#24405
ClientHeight = 169
ClientWidth = 300
Color = clWindow
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
KeyPreview = True
OldCreateOrder = False
Position = poMainFormCenter
Scaled = False
OnActivate = FormActivate
OnClose = FormClose
OnKeyDown = FormKeyDown
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 32
Top = 32
Width = 40
Height = 13
Caption = #29992#25143#21517':'
end
object Label2: TLabel
Left = 32
Top = 73
Width = 40
Height = 13
Caption = #23494' '#30721':'
end
object m_edUserName: TEdit
Left = 81
Top = 28
Width = 184
Height = 21
ImeName = #20013#25991' - QQ'#20116#31508#36755#20837#27861
MaxLength = 16
ParentShowHint = False
ShowHint = False
TabOrder = 0
TextHint = #36755#20837#29992#25143#21517
end
object m_edPassword: TEdit
Left = 80
Top = 72
Width = 185
Height = 21
ImeName = #20013#25991' - QQ'#20116#31508#36755#20837#27861
MaxLength = 18
ParentShowHint = False
PasswordChar = '*'
ShowHint = False
TabOrder = 1
TextHint = #36755#20837#23494#30721
end
object m_btnLogin: TButton
Left = 191
Top = 111
Width = 74
Height = 35
Caption = #30331#24405
TabOrder = 2
OnClick = LoginClick
end
object m_pbAutoCheck: TCheckBox
Left = 32
Top = 120
Width = 63
Height = 17
Caption = #33258#21160#30331#24405
TabOrder = 3
OnClick = AutoCheckClick
end
end
+43
View File
@@ -0,0 +1,43 @@
//---------------------------------------------------------------------------
#ifndef LoginFormUnitH
#define LoginFormUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
//---------------------------------------------------------------------------
class TLoginForm : public TForm
{
__published: // IDE-managed Components
TLabel *Label1;
TLabel *Label2;
TEdit *m_edUserName;
TEdit *m_edPassword;
TButton *m_btnLogin;
TCheckBox *m_pbAutoCheck;
void __fastcall LoginClick(TObject *Sender);
void __fastcall AutoCheckClick(TObject *Sender);
void __fastcall FormActivate(TObject *Sender);
// void __fastcall m_ckPasWordClick(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
/* void __fastcall m_lbUsLogClick(TObject *Sender);
void __fastcall m_lbUsLogMouseLeave(TObject *Sender);
void __fastcall m_lbUsLogMouseMove(TObject *Sender, TShiftState Shift, int X, int Y);
void __fastcall m_lbFPasClick(TObject *Sender);
void __fastcall m_lbFPasMouseMove(TObject *Sender, TShiftState Shift, int X, int Y);
void __fastcall m_lbFPasMouseLeave(TObject *Sender);
*/
private: // User declarations
public:
String m_strUsername;
String m_strPassword;
public: // User declarations
__fastcall TLoginForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TLoginForm *LoginForm;
//---------------------------------------------------------------------------
#endif
+1892
View File
File diff suppressed because it is too large Load Diff
+1823
View File
File diff suppressed because it is too large Load Diff
+188
View File
@@ -0,0 +1,188 @@
// ---------------------------------------------------------------------------
#ifndef MainFormUnitH
#define MainFormUnitH
// ---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ComCtrls.hpp>
#include <Vcl.Menus.hpp>
// ---------------------------------------------------------------------------
class TMainForm : public TForm {
__published: // IDE-managed Components
TButton *m_btnUpload;
TButton *m_btnCompose;
TGroupBox *GroupBox2;
TLabel *Label2;
TLabel *Label1;
TLabel *Label19;
TLabel *Label20;
TLabel *m_StyleNameNt;
TLabel *m_AuthorNt;
TLabel *m_DescriNt;
TLabel *Label21;
TLabel *m_lPriceNt;
TLabel *Label22;
TMemo *m_Descri;
TEdit *m_Author;
TEdit *m_StyleName;
TEdit *m_edPrice;
TListView *m_lvStyles;
TMainMenu *MainMenu1;
TMenuItem *N1;
TMenuItem *N2;
TMenuItem *N3;
TMenuItem *N4;
TMenuItem *Q1;
TMenuItem *H1;
TMenuItem *A1;
TMenuItem *m_menuOpen;
TMenuItem *m_menuRefresh;
TMenuItem *m_menuRecreator;
TMenuItem *m_menuChecker;
TLabel *stLabel1;
TLabel *stLabel2;
TButton *mdBtn1;
TButton *mdBtn2;
TButton *m_btnSegment;
TButton *m_btnVerify;
TCheckBox *m_cbSelectAll;
TButton *m_btnSaveExcel;
TGroupBox *GroupBox1;
TButton *m_btnLogin;
TLabel *m_lbUserInfo;
TLabel *Label4;
TEdit *m_edCost;
TLabel *Label5;
TLabel *Label6;
TComboBox *m_cbFonts;
TLabel *Label11;
void __fastcall FormCreate(TObject *Sender);
void __fastcall FormResize(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall MenuExitClick(TObject *Sender);
void __fastcall MenuAboutClick(TObject *Sender);
void __fastcall MenuHelpClick(TObject *Sender);
void __fastcall MenuOpenFileClick(TObject *Sender);
void __fastcall MenuRefreshClick(TObject *Sender);
void __fastcall MenuViewRecreatorClick(TObject *Sender);
void __fastcall MenuViewCheckerClick(TObject *Sender);
void __fastcall OnSegmentClick(TObject *Sender);
void __fastcall OnComposeClick(TObject *Sender);
void __fastcall OnUpLoadClick(TObject *Sender);
void __fastcall OnVerifyClick(TObject *Sender);
void __fastcall OnSaveExcelClick(TObject *Sender);
// void __fastcall OnDownloadClick(TObject *Sender);
void __fastcall OnLoginClick(TObject *Sender);
void __fastcall OnTypeClick(TObject *Sender);
void __fastcall OnSelectAllClick(TObject *Sender);
void __fastcall OnStyleNameExit(TObject *Sender);
void __fastcall OnAuthorExit(TObject *Sender);
void __fastcall OnCostExit(TObject *Sender);
void __fastcall OnDescriExit(TObject *Sender);
void __fastcall OnStyleNameChange(TObject *Sender);
void __fastcall OnAuthorChange(TObject *Sender);
void __fastcall OnDescriChange(TObject *Sender);
void __fastcall OnStylesDrawItem(TCustomListView *Sender, TListItem *Item,
TCustomDrawState State, bool &DefaultDraw);
void __fastcall OnStylesMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
int X, int Y);
void __fastcall OnFontChange(TObject *Sender);
protected:
MESSAGE void __fastcall OnNetworkError(TMessage &msg);
MESSAGE void __fastcall OnNetworkMessage(TMessage &msg);
MESSAGE void __fastcall UMLogin(TMessage &msg);
MESSAGE void __fastcall UMLogoff(TMessage &msg);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(MSG_UPDATA_LOGOFF, TMessage, UMLogoff)
MESSAGE_HANDLER(UM_LOGIN, TMessage, UMLogin)
MESSAGE_HANDLER(MSG_NETWORKERROR, TMessage, OnNetworkError)
MESSAGE_HANDLER(MSG_NETWORKMESSAGE, TMessage, OnNetworkMessage)
END_MESSAGE_MAP(TForm)
private : // User declarations
//对于风格批量合成与风格审核切换的时候控件的重新初始化
void ResetStylesData(const bool bRecreator);
//从文件获取合成风格
void GetRecreatorStyles(const String strFileName);
//保存合成风格信息到文件
void SaveStylesDataToFile();
//从网络获取待审风格
void GetCheckerStyles();
//刷新风格类型的位置信息
void ReposTypeCtrls();
//刷新个人相关信息
void RefreshAuthorData(bool bIsUpdate);
//清除作者相关数据
void ClearAuthorCtrlsInfo();
//刷新风格类型控件显示信息
void RefreshCtrlsData(const bool bIsSave);
//刷新List控件上的值(ListControl<<====>>Author Info)
void RefeshListAuthorData(TListView * pListView,const int iItemIndex, const bool bIsSave);
//刷新风格类型(控件<<==>>数据)
void RefreshListStyleType(TListView * pListView,const int iHotItemIndex,const bool bIsRead);
//初始化音色库
void InitFontList();
//遍历本地音色库
void ScanLocalFont(const String strDir);
//合成风格
int RecombineStyle( UINT index );
//初始化审核风格列表
void InitCheckerView();
void ShowCheckStyles();
//向网络列表视图里面添加一条数据
void AddCheckStyle(TPROSTYLE* pStyle);
private:
// TPopupMenu * m_pPopMenu;
TMenuItem * m_pMenuItem;
TMenuItem * m_pMenuItemDld;
vector<int> m_vcMdItemIndexs;
String m_strExlFileName;
String m_strMidiDirPath;
char m_cStyleTypes[2];
// bool m_bViewChecker;
vector<TDEFSTYLEINFO> m_vcDefStyleInfo;
vector<FONTINFO*> m_lstFonts;
// int m_iCurCombineIndex;
//vector<TSTYLEINFO*> m_vcCheckStyles;
/*
char m_szProgVar[8][3]; //伴奏主要乐器
char m_szProgFill[8][3]; //加花主要乐器
char m_szProgIntro[8][3]; //前奏主要乐器
char m_szProgEnding[8][3]; //尾奏主要乐器
*/
//Test
int m_iNeedUpdateNum;
int m_iVcIndex;
//end Test
public: // User declarations
__fastcall TMainForm(TComponent* Owner);
};
// ---------------------------------------------------------------------------
extern PACKAGE TMainForm *MainForm;
// ---------------------------------------------------------------------------
#endif
+58
View File
@@ -0,0 +1,58 @@
#ifndef MESSAGEDEF_H
#define MESSAGEDEF_H
// µ×²ãÏûÏ¢
#define MSG_PLAY_RANGE WM_USER + 0x100
#define MSG_PLAY_END WM_USER + 0x101
#define MSG_PLAY_FAILED WM_USER + 0x102
#define MSG_PLAY_ABORT WM_USER + 0x104
#define MSG_OPERATE_FAILED WM_USER + 0x105
#define MSG_OPERATE_PERCENT WM_USER + 0x106
#define MSG_OPERATE_COMPLETE WM_USER + 0x107
#define MSG_RECORD_FAILED WM_USER + 0x108
#define MSG_RECORD_COMPLETE WM_USER + 0x109
#define MSG_RECORD_VOLJUST WM_USER + 0x10A
#define MSG_MEASURE_0 WM_USER + 0x110
#define MSG_MEDIATIME WM_USER + 0X115
#define MSG_SETSCROLLPOS WM_USER + 0x120
#define MSG_OPERATE_NEXTRANGE WM_USER + 0x121
#define MSG_NETWORKMESSAGE WM_USER + 0x130
#define MSG_NETWORKERROR WM_USER + 0x131
#define MSG_TRACK_LBUTTONDOWN WM_USER + 0x200
#define MSG_TRACK_LBUTTONUP WM_USER + 0x201
#define MSG_TP_TRACK_LBTNDOWN WM_USER + 0x202
#define MSG_TP_TRACK_LBUTTONUP WM_USER + 0x203
#define MSG_UPDATA_LOGOFF WM_USER + 0x204
#define MSG_UPLOAD_STATE WM_USER + 0x205
// ½çÃæÏûÏ¢
#define UM_RESTORE WM_USER + 0x1000
#define UM_SHOWMENU WM_USER + 0x1001
#define UM_SHOWNEXTPAGE WM_USER + 0x1002
#define UM_TEINVALIDATE WM_USER + 0x1003
#define UM_LOGIN WM_USER + 0x1004
#define UM_ENABLERELOAD WM_USER + 0x1005
#define UM_SELECTSTYLE WM_USER + 0x1006
#define UM_LOADPROJECT WM_USER + 0x1007
#define UM_SAVEPROJECT WM_USER + 0x1008
#define UM_NEWPROJECT WM_USER + 0x1009
#define UM_AUDIOEFFECT WM_USER + 0x100a
#define UM_NEWCOMERTASK WM_USER + 0x1010
#define UM_REFRESH_PAGE_STATE WM_USER + 0x1011
#define UM_SAVEMUSIC WM_USER + 0x1012
#define UM_UPLOADMUSIC WM_USER + 0x1013
#define UM_MICSETTING WM_USER + 0x1014
#define UM_JUMP_PAGE WM_USER + 0x1100
#define UM_SHOWABOUT WM_USER + 0x110a
#define UM_OPENMANUAL WM_USER + 0x110b
#define UM_MENUCALL WM_USER + 0x110c
#define UM_MOUSEDOWN WM_USER + 0x110d
#define UM_MOUSEMOVE WM_USER + 0x110e
#define UM_MOUSEUP WM_USER + 0x110f
#define UM_SHOWPLAYTIME WM_USER + 0x1110
#define UM_BRUSHSTYLE WM_USER + 0x1111
#define UM_STOP WM_USER + 0x1112
#endif
+99
View File
@@ -0,0 +1,99 @@
// ---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#define _CFG_FILE_NAME_ "Config.ini";
#include "OperCfgFile.h"
// ---------------------------------------------------------------------------
#pragma package(smart_init)
OperCfgFile::OperCfgFile() {
m_lpszCfgFileName = GetCfgFileName();
}
OperCfgFile::~OperCfgFile() {
}
String OperCfgFile::GetCfgFileName() {
String strExcPath = L"";
GetExcPath(strExcPath);
String strCfgFileName = strExcPath + _CFG_FILE_NAME_;
return strCfgFileName;
}
void OperCfgFile::SetCfgFileName(const AnsiString szCfgFileName) {
m_lpszCfgFileName = szCfgFileName;
}
UINT OperCfgFile::GetExcPath(String & strExcPath) {
// GetModuleFileName(Module: HMODULE; Buffer: PChar; BufLen: Integer): Integer;
wchar_t wszBuffer[MAX_PATH] = {0};
UINT uRet = -1;
uRet = ::GetModuleFileName(NULL, wszBuffer, MAX_PATH);
strExcPath = ExtractFilePath((WideString)wszBuffer);
return uRet;
}
UINT OperCfgFile::ReadSegKeyValue(const String strSegName,
const String strKeyName, String & strRetValue) {
wchar_t wszBuf[MAX_PATH] = {0};
::GetPrivateProfileString(strSegName.c_str(), strKeyName.c_str(), L"",
wszBuf, MAX_PATH, m_lpszCfgFileName.c_str());
strRetValue = (WideString)wszBuf;
return 0;
}
UINT OperCfgFile::SaveSegKeyValue(const String strSegName,
const String strKeyName, String strSaveValue) {
return ::WritePrivateProfileString(strSegName.c_str(), strKeyName.c_str(),
strSaveValue.c_str(), m_lpszCfgFileName.c_str()) ;
}
bool OperCfgFile::EncrytString(String & strEncryptData, bool bIsEncryptFlag) {
wchar_t * szBuf = new wchar_t[strEncryptData.Length()*2 + 1];
memcpy(szBuf,strEncryptData.c_str(),wcslen(strEncryptData.c_str()) + 1);
int iLen = wcslen(szBuf);
if(bIsEncryptFlag)
{
for(int i = 0; i < iLen; i++)
{
szBuf[i] -= 0x63;
}
}
else
{
for(int i =0 ; i < iLen ; i++)
{
szBuf[i] += 0x63;
}
}
strEncryptData = (WideString)szBuf;
#if 0
if (bIsEncryptFlag) {
for (int i = 0; i < strEncryptData.Length(); i++) {
strEncryptData[i] ^= 'H';
}
}
else {
for (int i = 0; i < strEncryptData.Length(); i++) {
strEncryptData[i] ^= 'H';
}
}
#endif
return true;
}
+32
View File
@@ -0,0 +1,32 @@
//---------------------------------------------------------------------------
#ifndef OperCfgFileH
#define OperCfgFileH
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.ComCtrls.hpp>
#include <Vcl.ExtCtrls.hpp>
#include <Vcl.Graphics.hpp>
//---------------------------------------------------------------------------
class OperCfgFile
{
public:
OperCfgFile();
~OperCfgFile();
private:
String m_lpszCfgFileName;
void SetCfgFileName(const AnsiString szCfgFileName );
UINT GetExcPath(String & strExcPath);
public:
String GetCfgFileName();
UINT ReadSegKeyValue(const String strSegName,const String strKeyName,String & strRetValue);
UINT SaveSegKeyValue(const String strSegName,const String strKeyName,String strSaveValue);
//encrypting string
bool EncrytString(String & strEncryptData,bool bIsEncryptFlag);
};
#endif
+200
View File
@@ -0,0 +1,200 @@
// ---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "GlobalUnit.h"
#include "ProgressThreadUnit.h";
#include "ProgressFormUnit.h"
#define OPERATION_USER_LOGIN 5
#define OPERATION_STYLE_UPDATE 9
#define OPERATION_STYLE_COMPARE 10
// ---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TProgressForm *ProgressForm;
// ---------------------------------------------------------------------------
__fastcall TProgressForm::TProgressForm(TComponent* Owner) : TForm(Owner)
{
m_nMaxPos = m_pgProgBar->Max;
m_nPos = 0;
m_nNextMinPos = 0;
m_nNextMaxPos = m_nMaxPos;
m_iOperation = m_iOperationResult = 0;
m_pTimer = new TTimer(this);
m_pTimer->Enabled = false;
m_pTimer->Interval = 200;
m_pTimer->OnTimer = TimerProc;
m_pThread = new TProgressThread(true, this);
}
// ---------------------------------------------------------------------------
__fastcall TProgressForm::~TProgressForm() {
if (m_pThread)
delete m_pThread;
if (m_pTimer) {
delete m_pTimer;
}
}
// ---------------------------------------------------------------------------
void __fastcall TProgressForm::WMNCHitTest(TWMNCHitTest &Msg) {
TForm::Dispatch(&Msg);
if (Msg.Result == HTCLIENT && Msg.YPos < Top + 24 && Msg.XPos < Left + 274)
Msg.Result = HTCAPTION;
}
// ---------------------------------------------------------------------------
void __fastcall TProgressForm::ProgressPaint(TObject *Sender) {
#if 0
int x = 0;
// 左侧平铺
if (m_nPos > 0) {
for (int i = 0; i < m_nPos / m_nTileWidth + 1; i++) {
m_pbProgress->Canvas->Draw(x + m_nTileWidth*i, 0, m_bmpTileLeft);
}
x += m_nTileWidth;
}
// 右侧平铺
x = m_nPos;
if (m_nPos < m_nMaxPos) {
for (int i = 0; i < (m_nMaxPos - m_nPos) / m_nTileWidth + 1; i++) {
m_pbProgress->Canvas->Draw(x + m_nTileWidth*i, 0, m_bmpTileRight);
}
x += m_nTileWidth;
}
#endif
}
// ---------------------------------------------------------------------------
void __fastcall TProgressForm::UMOperateFailed(TMessage &Message) {
m_pThread->Terminate();
ModalResult = Message.WParam;
}
// ---------------------------------------------------------------------------
void __fastcall TProgressForm::UMOperatePercent(TMessage &Message)
{
m_nPos = m_nNextMinPos + Message.WParam * (m_nNextMaxPos - m_nNextMinPos) / 100;
m_pgProgBar->Position = m_nPos;
}
// ---------------------------------------------------------------------------
void __fastcall TProgressForm::UMOperateComplete(TMessage &Message) {
m_pThread->Terminate();
ModalResult = mrOk;
}
// ---------------------------------------------------------------------------
void __fastcall TProgressForm::UMOperateNextRange(TMessage &Message) {
m_nNextMinPos = Message.WParam * m_nMaxPos / 100;
m_nNextMaxPos = (Message.LParam == 0 ? m_nMaxPos :
Message.LParam * m_nMaxPos / 100);
}
// ---------------------------------------------------------------------------
void __fastcall TProgressForm::FormCreate(TObject *Sender) {
#if 0
// 绘制圆角窗体
HRGN hRgn = CreateRoundRectRgn(0, 0, Width + 1, Height + 2, 20, 20);
SetWindowRgn(Handle, hRgn, false);
DeleteObject(hRgn);
#endif
}
// ---------------------------------------------------------------------------
int __fastcall TProgressForm::User_Login()
{
m_iOperation = OPERATION_USER_LOGIN;
this->Caption = L"正在登录...";
m_pTimer->Enabled = true;
m_pThread->Start();
return ShowModal();
}
// ---------------------------------------------------------------------------
int __fastcall TProgressForm::Style_Update()
{
m_iOperation = OPERATION_STYLE_UPDATE;
this->Caption = L"正在更新...";
m_pThread->Start();
return ShowModal();
}
// ---------------------------------------------------------------------------
int __fastcall TProgressForm::Compare_Style( int idStyle )
{
m_iOperation = OPERATION_STYLE_COMPARE;
this->Caption = L"正在核查...";
m_iParam = idStyle;
m_pThread->Start();
return ShowModal();
}
// ---------------------------------------------------------------------------
void __fastcall TProgressForm::Operation()
{
switch (m_iOperation) {
case OPERATION_USER_LOGIN:
m_iOperationResult = f_CS_Login(&g_infoUser, true);
PostMessage(Handle, MSG_OPERATE_COMPLETE, 0, 0);
m_pgProgBar->Position = 100;
break;
case OPERATION_STYLE_UPDATE:
f_CS_UpdateStyle(g_infoUser.accountInfo.ID, Handle);
m_pgProgBar->Position = 0;
break;
case OPERATION_STYLE_COMPARE:
f_CM_CompareStyle( 2, m_iParam, NULL, Handle );
m_pgProgBar->Position = 0;
break;
}
}
// ---------------------------------------------------------------------------
void __fastcall TProgressForm::TimerProc(TObject* Sender)
{
m_nPos += 2;
/*
if( m_nPos>=m_nMaxPos ){
m_nPos -= m_nMaxPos;
}
*/
if (m_nPos >= m_pgProgBar->Max) {
m_nPos = 0;
}
m_pgProgBar->Position = m_nPos;
m_pgProgBar->Invalidate();
}
// ---------------------------------------------------------------------------
void __fastcall TProgressForm::OnCancelClick(TObject *Sender) {
if (m_iOperation == OPERATION_USER_LOGIN ||
m_iOperation == OPERATION_STYLE_UPDATE) {
m_pTimer->Enabled = false;
f_CS_CancelOperation();
m_pThread->Terminate();
ModalResult = mrCancel;
if (m_iOperation == OPERATION_USER_LOGIN) {
// Send the cancel information
PostMessage(m_hMain, MSG_UPDATA_LOGOFF, 0, 0);
}
}
}
// ---------------------------------------------------------------------------
+41
View File
@@ -0,0 +1,41 @@
object ProgressForm: TProgressForm
Left = 0
Top = 0
ParentCustomHint = False
BiDiMode = bdLeftToRight
BorderIcons = []
BorderStyle = bsDialog
ClientHeight = 97
ClientWidth = 298
Color = clWindow
DoubleBuffered = True
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
KeyPreview = True
OldCreateOrder = False
ParentBiDiMode = False
Position = poMainFormCenter
Scaled = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object m_pgProgBar: TProgressBar
Left = 24
Top = 31
Width = 250
Height = 20
TabOrder = 0
end
object m_btnCancel: TButton
Left = 112
Top = 64
Width = 75
Height = 25
Caption = #21462#28040
TabOrder = 1
OnClick = OnCancelClick
end
end
+75
View File
@@ -0,0 +1,75 @@
//---------------------------------------------------------------------------
#ifndef ProgressFormUnitH
#define ProgressFormUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ExtCtrls.hpp>
#include "GlobalUnit.h"
#include <Vcl.Graphics.hpp>
#include <Vcl.ComCtrls.hpp>
//---------------------------------------------------------------------------
class TProgressForm : public TForm
{
__published: // IDE-managed Components
TProgressBar *m_pgProgBar;
TButton *m_btnCancel;
void __fastcall ProgressPaint(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
void __fastcall OnCancelClick(TObject *Sender);
private: // User declarations
TThread *m_pThread;
TTimer *m_pTimer;
int m_nMaxPos,
m_nPos,
m_iOperation;
int m_iParam;
void* m_pParam;
TCHAR m_strFileName[256];
int m_nNextMinPos,
m_nNextMaxPos;
UINT m_nStyleNum, *m_paIdStyle;
double* m_paOriginPrice, *m_paCurrentPrice, *m_pUserBalance;
void __fastcall TimerProc(TObject* Sender);
MESSAGE void __fastcall WMNCHitTest(TWMNCHitTest &Msg);
MESSAGE void __fastcall UMOperateFailed(TMessage &Message);
MESSAGE void __fastcall UMOperatePercent(TMessage &Message);
MESSAGE void __fastcall UMOperateComplete(TMessage &Message);
MESSAGE void __fastcall UMOperateNextRange(TMessage &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_NCHITTEST, TWMNCHitTest, WMNCHitTest)
MESSAGE_HANDLER(MSG_OPERATE_FAILED, TMessage, UMOperateFailed)
MESSAGE_HANDLER(MSG_OPERATE_PERCENT, TMessage, UMOperatePercent)
MESSAGE_HANDLER(MSG_OPERATE_COMPLETE, TMessage, UMOperateComplete)
MESSAGE_HANDLER(MSG_OPERATE_NEXTRANGE, TMessage, UMOperateNextRange)
END_MESSAGE_MAP(TForm)
public: // User declarations
__fastcall TProgressForm(TComponent* Owner);
__fastcall ~TProgressForm();
void __fastcall Operation();
int __fastcall User_Login();
int __fastcall Style_Update();
int __fastcall Compare_Style( int idStyle );
int __fastcall GetOpertaionResult() { return m_iOperationResult; };
int m_iOperationResult;
HWND m_hMain;
private:
};
//---------------------------------------------------------------------------
extern PACKAGE TProgressForm *ProgressForm;
//---------------------------------------------------------------------------
#endif
+29
View File
@@ -0,0 +1,29 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "ProgressThreadUnit.h"
#include "ProgressFormUnit.h"
#include "StylesUpProgressFormUnit.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
__fastcall TProgressThread::TProgressThread(bool CreateSuspended, TForm* pForm)
: TThread(CreateSuspended)
{
m_pForm = pForm;
}
//---------------------------------------------------------------------------
void __fastcall TProgressThread::Execute()
{
//---- Place thread code here ----
if(m_pForm->Name == L"StylesUpProgressForm")
((TStylesUpProgressForm*)m_pForm)->Operation();
else
((TProgressForm*)m_pForm)->Operation();
}
//---------------------------------------------------------------------------
+18
View File
@@ -0,0 +1,18 @@
//---------------------------------------------------------------------------
#ifndef ProgressThreadUnitH
#define ProgressThreadUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
//---------------------------------------------------------------------------
class TProgressThread : public TThread
{
private:
TForm * m_pForm;
protected:
void __fastcall Execute();
public:
__fastcall TProgressThread(bool CreateSuspended, TForm* pForm);
};
//---------------------------------------------------------------------------
#endif
+69
View File
@@ -0,0 +1,69 @@
// ---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "StyleSetFormUnit.h"
#include "GlobalUnit.h"
// ---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TStyleSetForm *StyleSetForm;
// ---------------------------------------------------------------------------
__fastcall TStyleSetForm::TStyleSetForm(TComponent* Owner) : TForm(Owner) {
memset(&m_cStyleTypes[0],-1,2);
m_iHotItemIndex = -1;
}
// ---------------------------------------------------------------------------
void __fastcall TStyleSetForm::m_plstStyleSelClickCheck(TObject *Sender) {
int iHotIndex = m_plstStyleSel->ItemIndex;
int iCheckItemCnt = 0;
if(iHotIndex < 0)
return;
for (int iIndex = 0; iIndex < m_plstStyleSel->Items->Count; iIndex++) {
if (m_plstStyleSel->Checked[iIndex])
iCheckItemCnt++;
}
if (m_plstStyleSel->Checked[iHotIndex] && iCheckItemCnt > 2) {
m_plstStyleSel->Checked[iHotIndex] = false;
MessageBox(Handle, L"你已经选择了两种风格", L"提示信息", MB_ICONINFORMATION | MB_OK);
}
}
// ---------------------------------------------------------------------------
void __fastcall TStyleSetForm::FormActivate(TObject *Sender) {
for(int i = 0; i < 24 ; i++)
{
String strTmpValue = (String)LSZ_STYLTYPES[i];
m_plstStyleSel->Items->Add(strTmpValue);
if (m_cStyleTypes[0] == i || m_cStyleTypes[1] == i) {
m_plstStyleSel->Checked[i] = true;
m_plstStyleSel->ItemIndex = i;
m_iHotItemIndex = i;
}
}
}
// ---------------------------------------------------------------------------
void __fastcall TStyleSetForm::btnSaveHarmClick(TObject *Sender)
{
for (int i = 0,index = 0; i < m_plstStyleSel->Items->Count; i++) {
if (m_plstStyleSel->Checked[i] && index < 2) {
m_cStyleTypes[index++] = i;
}
}
ModalResult = mrOk;
}
//---------------------------------------------------------------------------
+46
View File
@@ -0,0 +1,46 @@
object StyleSetForm: TStyleSetForm
Left = 0
Top = 0
BorderIcons = [biSystemMenu, biMinimize]
Caption = #39118#26684#31867#22411#36873#25321
ClientHeight = 237
ClientWidth = 319
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poOwnerFormCenter
OnActivate = FormActivate
PixelsPerInch = 96
TextHeight = 13
object m_plstStyleSel: TCheckListBox
Left = 8
Top = 8
Width = 297
Height = 191
OnClickCheck = m_plstStyleSelClickCheck
Align = alCustom
Columns = 2
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ImeName = #20013#25991' - QQ'#20116#31508#36755#20837#27861
ItemHeight = 13
ParentFont = False
TabOrder = 0
end
object btnSaveHarm: TButton
Left = 113
Top = 204
Width = 75
Height = 25
Caption = #30830#23450
TabOrder = 1
OnClick = btnSaveHarmClick
end
end
+29
View File
@@ -0,0 +1,29 @@
//---------------------------------------------------------------------------
#ifndef StyleSetFormUnitH
#define StyleSetFormUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.CheckLst.hpp>
//---------------------------------------------------------------------------
class TStyleSetForm : public TForm
{
__published: // IDE-managed Components
TCheckListBox *m_plstStyleSel;
TButton *btnSaveHarm;
void __fastcall m_plstStyleSelClickCheck(TObject *Sender);
void __fastcall FormActivate(TObject *Sender);
void __fastcall btnSaveHarmClick(TObject *Sender);
private: // User declarations
int m_iHotItemIndex;
public: // User declarations
__fastcall TStyleSetForm(TComponent* Owner);
char m_cStyleTypes[2];
};
//---------------------------------------------------------------------------
extern PACKAGE TStyleSetForm *StyleSetForm;
//---------------------------------------------------------------------------
#endif
+261
View File
@@ -0,0 +1,261 @@
// ---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "GlobalUnit.h"
#include "ProgressThreadUnit.h";
#include "StylesUpProgressFormUnit.h"
#define OPERATION_MM_SAVE 1
#define OPERATION_MM_LOAD 2
#define OPERATION_PROJ_LOAD 3
#define OPERATION_PROJ_SAVE 4
#define OPERATION_USER_LOGIN 5
#define OPERATION_USER_VERIFY 6
#define OPERATION_USER_PURCHASE 7
#define OPERATION_STYLE_UPLOAD 8
// ---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TStylesUpProgressForm *StylesUpProgressForm;
// ---------------------------------------------------------------------------
__fastcall TStylesUpProgressForm::TStylesUpProgressForm(TComponent* Owner)
: TForm(Owner) {
m_nPos = 0;
m_iUpLoadFlag = -1;
m_nNextMinPos = 0;
m_nNextMaxPos = m_nMaxPos = 100;
m_iOperation = m_iOperationResult = 0;
m_pThread = new TProgressThread(true, this);
}
// ---------------------------------------------------------------------------
void __fastcall TStylesUpProgressForm::OnCancelClick(TObject *Sender) {
if (m_iOperation == OPERATION_STYLE_UPLOAD) {
m_iOperationResult = mrCancel;
WaitForSingleObject(m_hProcessEvent, INFINITE);
m_pThread->Terminate();
f_CS_CancelOperation();
ModalResult = mrCancel;
}
}
// ---------------------------------------------------------------------------
void __fastcall TStylesUpProgressForm::TimerProc(TObject* Sender) {
m_nPos += 2;
/*
if( m_nPos>=m_nMaxPos ){
m_nPos -= m_nMaxPos;
}
*/
if (m_nPos >= m_pgProgBar->Max) {
m_nPos = 0;
}
m_pgProgBar->Position = m_nPos;
m_pgProgBar->Invalidate();
}
void __fastcall TStylesUpProgressForm::WMNCHitTest(TWMNCHitTest &Msg) {
TForm::Dispatch(&Msg);
if (Msg.Result == HTCLIENT && Msg.YPos < Top + 24 && Msg.XPos < Left + 274)
Msg.Result = HTCAPTION;
}
// ---------------------------------------------------------------------------
void __fastcall TStylesUpProgressForm::UMOperateFailed(TMessage &Message) {
// m_pThread->Terminate();
// ModalResult = Message.WParam;
}
// ---------------------------------------------------------------------------
void __fastcall TStylesUpProgressForm::UMOperatePercent(TMessage &Message)
{
if( m_iOperationResult==0 ){
m_nPos = m_nNextMinPos + Message.WParam *
(m_nNextMaxPos - m_nNextMinPos) / 100;
lbPrctStyle->Caption = IntToStr(m_nPos) + L"%";
m_pgProgBar->Position = m_nPos;
}
}
// ---------------------------------------------------------------------------
void __fastcall TStylesUpProgressForm::UMOperateComplete(TMessage &Message)
{
if( m_iOperationResult==0 ){
if( Message.WParam==1 ){
m_pgProgBar->Position = 100;
lbPrctStyle->Caption = L"100%";
m_iUpLoadFlag = 1;
m_iOperationResult = mrOk;
m_pThread->Terminate();
ModalResult = mrOk;
}
else{
lbPrctStyle->Caption = L"100%";
m_pgProgBar->Position = 100;
}
}
}
// ---------------------------------------------------------------------------
void __fastcall TStylesUpProgressForm::UMOperateNextRange(TMessage &Message) {
m_nNextMinPos = Message.WParam * m_nMaxPos / 100;
m_nNextMaxPos = (Message.LParam == 0 ? m_nMaxPos :
Message.LParam * m_nMaxPos / 100);
}
// ---------------------------------------------------------------------------
int __fastcall TStylesUpProgressForm::Styles_Upload(vector<TDEFSTYLEINFO>vcDefStyleInfo)
{
m_iOperation = OPERATION_STYLE_UPLOAD;
m_hProcessEvent = CreateEvent(NULL, FALSE, TRUE, NULL);
this->Caption = L"正在上传...";
// m_pTimer->Enabled = true;
m_pThread->Start();
m_pgProgTotalBar->Max = vcDefStyleInfo.size() * 100;
m_pgProgTotalBar->Min = 0;
if (m_vcDefStylesInfo.size())
m_vcDefStylesInfo.clear();
for( int i=0; i<vcDefStyleInfo.size(); i++ )
m_vcDefStylesInfo.push_back( vcDefStyleInfo[i] );
return ShowModal();
}
// ---------------------------------------------------------------------------
void __fastcall TStylesUpProgressForm::Operation() {
switch (m_iOperation) {
case OPERATION_STYLE_UPLOAD: {
// Ñ­»·ÉÏ´«
wchar_t strCaption[1000];
for (int i = 0; i < m_vcDefStylesInfo.size(); i++) {
// Begin to Recombin Style File
TDEFSTYLEINFO defStyleTmp;
defStyleTmp = m_vcDefStylesInfo[i];
String strFileName = ExtractFileName(defStyleTmp.strFileName);
wcscpy( strCaption, strFileName.c_str() );
PostMessage( Handle, MSG_UPLOAD_STATE, 0, (LPARAM)strCaption );
WaitForSingleObject(m_hProcessEvent, INFINITE);
int iTmpo = 0, iTmpSig = 0;
int iRet = f_CM_RecombineFiles( defStyleTmp.idStyle,
((AnsiString)defStyleTmp.strFileName).c_str(),
&iTmpo, &iTmpSig);
defStyleTmp.tStyleInfo.detail.iTempo = iTmpo;
defStyleTmp.tStyleInfo.detail.iTimesignature = iTmpSig;
SetEvent( m_hProcessEvent );
if( m_iOperationResult==0 && iRet==0 ){
TMAKESTYLEINFO* pStyleInfo = &(defStyleTmp.tStyleInfo);
char strGBName[80];
strcpy( strGBName, pStyleInfo->detail.strStyleName );
string strTmp = GBToUTF8(pStyleInfo->detail.strStyleName).c_str();
memcpy(pStyleInfo->detail.strStyleName, strTmp.c_str(),strTmp.length());
strTmp = GBToUTF8(pStyleInfo->detail.strDescription).c_str();
memcpy(pStyleInfo->detail.strDescription, strTmp.c_str(), strTmp.length());
strTmp = GBToUTF8(pStyleInfo->detail.strAuthor).c_str();
memcpy(pStyleInfo->detail.strAuthor,strTmp.c_str(),strTmp.length());
pStyleInfo->detail.idAuthor = g_infoUser.accountInfo.ID;
DebugPrint("正在生成");
int iFileLen = 1000000;
BYTE* buff = new BYTE[iFileLen];
int ret = f_CM_MakeStyle( defStyleTmp.idStyle, pStyleInfo, iFileLen, buff);
if (ret != 0) {
char msg[160];
sprintf( msg, "%s\n生成错误 errcode=%d", strGBName, ret );
ShowMessage(msg);
}
else{
// Get the current combine style file
m_iCurStyleIndex = i;
String str = IntToStr(m_iCurStyleIndex) + L"/" +
IntToStr(int(m_vcDefStylesInfo.size()));
wcscpy( strCaption, str.c_str() );
PostMessage( Handle, MSG_UPLOAD_STATE, 1, (LPARAM)strCaption );
m_iOperationResult =
f_CS_UploadStyle( e_ST_Origin, g_infoUser.accountInfo.ID,
iFileLen, buff, Handle);
DebugPrint("上传成功");
}
delete buff;
}
}
PostMessage(Handle, MSG_OPERATE_COMPLETE, 1, 0);
} break;
default:
break;
}
}
void __fastcall TStylesUpProgressForm::UMUploadState(TMessage &Message)
{
if( m_iOperationResult==0 ){
int iState = Message.WParam;
wchar_t* strCaption = (wchar_t*)Message.LParam;
if( iState==0 ){
DebugPrint("正在合成");
lbProg->Caption = L"正在合成:";
lbStyleName->Caption = strCaption;
lbPrctStyle->Caption = L"0%";
m_pgProgBar->Position = 0;
}
else{
DebugPrint("正在上传");
lbProg->Caption = L"正在上传:";
lbPrctStyles->Caption = strCaption;
m_pgProgTotalBar->Position = m_iCurStyleIndex * 100;
}
}
}
void __fastcall TStylesUpProgressForm::FormClose(TObject *Sender,
TCloseAction &Action)
{
/* if (m_iOperation == OPERATION_STYLE_UPLOAD) {
f_CS_CancelOperation();
m_pThread->Terminate();
if (m_iUpLoadFlag != 1)
m_iOperationResult = mrCancel;
ModalResult = mrCancel;
}
*/
}
// ---------------------------------------------------------------------------
+81
View File
@@ -0,0 +1,81 @@
object StylesUpProgressForm: TStylesUpProgressForm
Left = 0
Top = 0
BorderIcons = []
Caption = #27491#22312#19978#20256'...'
ClientHeight = 143
ClientWidth = 297
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poMainFormCenter
OnClose = FormClose
PixelsPerInch = 96
TextHeight = 13
object lbProg: TLabel
Left = 15
Top = 24
Width = 52
Height = 13
Caption = #27491#22312#19978#20256':'
end
object lbTotalProg: TLabel
Left = 15
Top = 66
Width = 36
Height = 13
Caption = #24050#19978#20256
end
object lbStyleName: TLabel
Left = 73
Top = 24
Width = 36
Height = 13
Caption = #39118#26684#21517
end
object lbPrctStyle: TLabel
Left = 247
Top = 26
Width = 33
Height = 13
Alignment = taRightJustify
Caption = '0.00%'
Layout = tlCenter
end
object lbPrctStyles: TLabel
Left = 247
Top = 66
Width = 33
Height = 13
Alignment = taRightJustify
Caption = '0.00%'
Layout = tlCenter
end
object m_pgProgBar: TProgressBar
Left = 15
Top = 43
Width = 265
Height = 17
TabOrder = 0
end
object m_pgProgTotalBar: TProgressBar
Left = 15
Top = 85
Width = 265
Height = 17
TabOrder = 1
end
object m_btnCancel: TButton
Left = 111
Top = 108
Width = 75
Height = 25
Caption = #21462#28040
TabOrder = 2
OnClick = OnCancelClick
end
end
+80
View File
@@ -0,0 +1,80 @@
//---------------------------------------------------------------------------
#ifndef StylesUpProgressFormUnitH
#define StylesUpProgressFormUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ComCtrls.hpp>
//---------------------------------------------------------------------------
class TStylesUpProgressForm : public TForm
{
__published: // IDE-managed Components
TProgressBar *m_pgProgBar;
TProgressBar *m_pgProgTotalBar;
TButton *m_btnCancel;
TLabel *lbProg;
TLabel *lbTotalProg;
TLabel *lbStyleName;
TLabel *lbPrctStyle;
TLabel *lbPrctStyles;
void __fastcall OnCancelClick(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
private: // User declarations
HANDLE m_hProcessEvent;
void __fastcall TimerProc(TObject* Sender);
MESSAGE void __fastcall WMNCHitTest(TWMNCHitTest &Msg);
MESSAGE void __fastcall UMUploadState(TMessage &Message);
MESSAGE void __fastcall UMOperateFailed(TMessage &Message);
MESSAGE void __fastcall UMOperatePercent(TMessage &Message);
MESSAGE void __fastcall UMOperateComplete(TMessage &Message);
MESSAGE void __fastcall UMOperateNextRange(TMessage &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_NCHITTEST, TWMNCHitTest, WMNCHitTest)
MESSAGE_HANDLER(MSG_UPLOAD_STATE, TMessage, UMUploadState)
MESSAGE_HANDLER(MSG_OPERATE_FAILED, TMessage, UMOperateFailed)
MESSAGE_HANDLER(MSG_OPERATE_PERCENT, TMessage, UMOperatePercent)
MESSAGE_HANDLER(MSG_OPERATE_COMPLETE, TMessage, UMOperateComplete)
MESSAGE_HANDLER(MSG_OPERATE_NEXTRANGE, TMessage, UMOperateNextRange)
END_MESSAGE_MAP(TForm)
public: // User declarations
HWND m_hMain;
int m_iOperationResult;
public:
__fastcall TStylesUpProgressForm(TComponent* Owner);
int __fastcall Styles_Upload(vector<TDEFSTYLEINFO> vcDefStyleInfo);
void __fastcall Operation();
int __fastcall GetOpertaionResult() { return m_iOperationResult; };
private:
vector<TDEFSTYLEINFO> m_vcDefStylesInfo;
int m_iCurStyleIndex;
TThread *m_pThread;
TTimer *m_pTimer;
int m_nMaxPos,
m_nPos,
m_iOperation,
m_iSaveType,
m_iFileType,
m_nDataSize;
int m_nNextMinPos,
m_nNextMaxPos;
int m_iUpLoadFlag;
};
//---------------------------------------------------------------------------
extern PACKAGE TStylesUpProgressForm *StylesUpProgressForm;
//---------------------------------------------------------------------------
#endif
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+211
View File
@@ -0,0 +1,211 @@
//---------------------------------------------------------------------------
#ifndef TryListenFormUnitH
#define TryListenFormUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.Menus.hpp>
#include <Vcl.ExtCtrls.hpp>
#include <Vcl.ComCtrls.hpp>
#include "UMTrackBarUnit.h"
#include "GlobalUnit.h"
#include <vector>
using namespace std;
//---------------------------------------------------------------------------
class TTryListenForm : public TForm
{
__published: // IDE-managed Components
TPopupMenu *pChildMenu;
TMenuItem *N11;
TMenuItem *N21;
TMenuItem *N31;
TMenuItem *N41;
TMenuItem *N51;
TMenuItem *N61;
TMenuItem *N71;
TMenuItem *N81;
TMenuItem *N91;
TMenuItem *IV1;
TMenuItem *b1;
TMenuItem *VII1;
TMenuItem *I1;
TMenuItem *II1;
TMenuItem *III1;
TMenuItem *IV2;
TMenuItem *V1;
TMenuItem *VI1;
TMenuItem *VII2;
TMenuItem *II2;
TMenuItem *III2;
TMenuItem *IV3;
TMenuItem *I2;
TMenuItem *II71;
TMenuItem *III71;
TMenuItem *IV71;
TMenuItem *V71;
TMenuItem *VI71;
TMenuItem *VII71;
TMenuItem *I71;
TMenuItem *II72;
TMenuItem *III72;
TMenuItem *IV72;
TMenuItem *V72;
TMenuItem *VI72;
TMenuItem *VII72;
TListBox *m_AcmType;
TListBox *m_BqSeqData;
TButton *m_btnTryLstn;
TPanel *Panel1;
TLabel *Label1;
TLabel *Label2;
TLabel *Label3;
TLabel *Label4;
TLabel *Label5;
TLabel *Label6;
TLabel *Label7;
TLabel *Label8;
TMenuItem *VII3;
TMenuItem *VI2;
TMenuItem *II73;
TMenuItem *III73;
TMenuItem *IV73;
TMenuItem *VII73;
TMenuItem *VI73;
TMenuItem *II74;
TMenuItem *III74;
TMenuItem *VII74;
TMenuItem *VIIm71;
TMenuItem *VI74;
TButton *m_delBtn;
TButton *m_btnResetChord;
TButton *m_btnAdd;
TEdit *m_edTemp;
TUpDown *m_btnUpDown;
TLabel *Label9;
TMenuItem *Clear1;
TPopupMenu *m_pRSetChord;
TMenuItem *N16m46m2m516m1;
TMenuItem *N16m46m2m516m2;
TMenuItem *N6m2m3m6m1;
TMenuItem *N6m456m1;
TMenuItem *mItem1;
TMenuItem *mItem2;
TMenuItem *mItem3;
TMenuItem *mItem4;
TButton *m_btnMoveUp;
TButton *m_btnMoveDown;
TMenuItem *N16m511;
TButton *btnMelodyUp;
TButton *btnUpChords;
UMTrackBarUnit::TTrackBar *m_trkBar;
void __fastcall OnPopMenuClick(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
void __fastcall LabelMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
int X, int Y);
void __fastcall m_BqSeqDataMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
int X, int Y);
void __fastcall m_BqSeqDataDragDrop(TObject *Sender, TObject *Source, int X, int Y);
void __fastcall m_BqSeqDataDragOver(TObject *Sender, TObject *Source, int X, int Y,
TDragState State, bool &Accept);
void __fastcall m_BqSeqDataStartDrag(TObject *Sender, TDragObject *&DragObject);
void __fastcall OnAddAccmp(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall Panel1Exit(TObject *Sender);
void __fastcall FormMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
int X, int Y);
void __fastcall ResetChord(TObject *Sender);
void __fastcall OnTryListen(TObject *Sender);
void __fastcall OnDelAccmp(TObject *Sender);
void __fastcall m_BqSeqDataDrawItem(TWinControl *Control, int Index, TRect &Rect,
TOwnerDrawState State);
void __fastcall m_BqSeqDataDblClick(TObject *Sender);
void __fastcall m_trkBarChange(TObject *Sender);
void __fastcall m_btnUpDownClick(TObject *Sender, TUDBtnType Button);
void __fastcall FormActivate(TObject *Sender);
void __fastcall m_edTempKeyPress(TObject *Sender, System::WideChar &Key);
void __fastcall Clear1Click(TObject *Sender);
void __fastcall ChordSeleted(TObject *Sender);
void __fastcall OnMoveBtnClick(TObject *Sender);
void __fastcall m_BqSeqDataClick(TObject *Sender);
void __fastcall m_AcmTypeClick(TObject *Sender);
void __fastcall m_edTempExit(TObject *Sender);
void __fastcall m_edTempChange(TObject *Sender);
void __fastcall OnSetChordsUp(TObject *Sender);
void __fastcall OnDisplayUpChords(TObject *Sender);
void __fastcall FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
private: // User declarations
TLabel * m_pTmpLabel;
//列表项拖动效果
int m_iFillType; //加花类型
int m_CurIndex, m_NewIndex;
void InitCtrlData();
void SaveCtrlData();
void SetControlPos(const int iChords);
void DisplayPopMenu(); //显示弹出按钮
void StopPlay(); //停止播放并设置相关参数
bool m_bIsDataCgFlag; //数据改变标记
bool m_bIsPlaying; //风格播放标记
UINT m_idLoc, m_idStyle; //风格ID
int m_nTotalBarNum; //曲式小节数
int m_arrBarNum[MAX_PATH]; //曲式每段结束位置
TBarChords m_aChords[4];
char m_aTracks[4][8][16][3];
char info[4][8][2][2];
UINT m_tTimer, m_tAccuracy;
double m_iCurPos; //滑动条当前位置
double m_iStepLen; //滑动条增量
bool GenerateCompose(int iKey); //编曲(仅编曲)
//设置和声
void InitALlChords(); //初始化所有和声
void UpdateFontData(); //初始化音色库数据
void SetChordByString(const String strContext,const int iTag);
void SetFocusChord( int iMainKey, int iAjustKey, int iChordType,int iTag);
int GetEachSegEndPos(); //获取曲式每段的长度 且返回曲式总小节数
int ComposeAllData(); //组装编曲数据 (里面包含编曲)
int GetFocusChord(const int iRetChord, int& iMainKey,
int& iAjustKey, int& iChordType);
//将数据转换成和弦 或 将和弦转换为数据
void ChangeChordsByData(const bool bIsDataToChords);
void GetChordsByString(const String strData,int& iMainKey,int& iAjustKey, int& iChordType );
int GetChordsByKetData(const int iMainKey,const int iAjustKey, const int iChordType);
void GetChordsStrByKey(String & strChordValue,const int iMainKey,const int iAjustKey, const int iChordType);
protected:
MESSAGE void __fastcall UMTPTrackBarLButtonUp(TWMMouse &Message);
MESSAGE void __fastcall UMTrackBarLButtonUp(TWMMouse &Message);
MESSAGE void __fastcall UMMediaTime(TMessage &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(MSG_MEDIATIME, TMessage, UMMediaTime)
MESSAGE_HANDLER(MSG_TRACK_LBUTTONUP,TWMMouse,UMTrackBarLButtonUp)
END_MESSAGE_MAP(TForm)
private:
String m_strUpChords[8];
public: // User declarations
__fastcall TTryListenForm(TComponent* Owner, UINT idLoc, UINT idStyle);
public:
// TSTYLEINFO* m_pStyleInfo;
};
//---------------------------------------------------------------------------
extern PACKAGE TTryListenForm *TryListenForm;
//---------------------------------------------------------------------------
#endif
+14
View File
@@ -0,0 +1,14 @@
// ---------------------------------------------------------------------------
#include "UMTrackBarUnit.h"
#include "GlobalUnit.h"
void __fastcall UMTrackBarUnit::TTrackBar::UMTrackBarLButtonUp
(TWMMouse & Message) {
PostMessage(Parent->Handle, MSG_TRACK_LBUTTONUP, (unsigned int&)Message.Msg, (long&)Message.Pos);
}
void __fastcall UMTrackBarUnit::TTrackBar::UMTrackBarLButtonDown
(TWMMouse & Message) {
PostMessage(Parent->Handle, MSG_TRACK_LBUTTONDOWN, (unsigned int&)Message.Msg, (long&)Message.Pos);
}
+19
View File
@@ -0,0 +1,19 @@
// ---------------------------------------------------------------------------
#include <Vcl.h>
#ifndef UMTrackBarUnitH
#define UMTrackBarUnitH
// ---------------------------------------------------------------------------
namespace UMTrackBarUnit {
class TTrackBar : public Vcl::Comctrls::TTrackBar {
protected:
MESSAGE void __fastcall UMTrackBarLButtonUp(TWMMouse &Message);
MESSAGE void __fastcall UMTrackBarLButtonDown(TWMMouse &Message);
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_LBUTTONDOWN, TWMLButtonUp,UMTrackBarLButtonUp);
VCL_MESSAGE_HANDLER(WM_LBUTTONUP, TWMLButtonUp,UMTrackBarLButtonUp);
END_MESSAGE_MAP(Vcl::Comctrls::TTrackBar);
};
}
using namespace UMTrackBarUnit;
#endif
+123
View File
@@ -0,0 +1,123 @@
// ---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "GlobalUnit.h"
#include "VerifyStylesFormUnit.h"
// ---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TVerifyStylesForm *VerifyStylesForm;
// ---------------------------------------------------------------------------
__fastcall TVerifyStylesForm::TVerifyStylesForm(TComponent* Owner)
: TForm(Owner) {
m_iStyleId = 0;
m_bCheckedPass = false;
}
// ---------------------------------------------------------------------------
void __fastcall TVerifyStylesForm::btnCancelClick(TObject *Sender) {
ModalResult = mrCancel;
}
// ---------------------------------------------------------------------------
void __fastcall TVerifyStylesForm::btnOkClick(TObject *Sender) {
if(!CheckStyleIsPass())
return;
AnsiString strMsg;
int score = 0;
if( m_bCheckedPass ){
score = ( m_cbScore->ItemIndex + 6 ) * 100;
}
else{
strMsg = mtDescript->Text.Trim();
strMsg = GBToUTF8(strMsg.c_str()).c_str();
}
HRESULT hr = f_CS_CheckStyle(m_iStyleId, g_infoUser.accountInfo.ID, score, strMsg.c_str() );
//Debug test information
String strDbgInfo = L"";
if(0 == hr){
m_iRetCheckStyle = 0;
strDbgInfo = L"审核成功";
MessageBox(Handle,strDbgInfo.c_str(),L"提示信息",MB_ICONINFORMATION|MB_OK);
}
else{
/*
e_InvalidUserID, //Check
e_InvalidAuthority, //无操作权限 -- //Check
e_CheckedAlready, //风格已被审核 -- //Check
*/
m_iRetCheckStyle = -2;
strDbgInfo = L"审核失败,错误码:" + IntToStr((int)hr);
MessageBox(Handle,strDbgInfo.c_str(),L"提示信息",MB_ICONERROR|MB_OK);
}
OutputDebugString(strDbgInfo.c_str());
ModalResult = mrOk;
//End test
}
// ---------------------------------------------------------------------------
void __fastcall TVerifyStylesForm::OnSelectVerifyStyleClick(TObject *Sender)
{
if( rdCheckPass==Sender ){
mtDescript->Enabled = false;
mtDescript->Text = "";
m_cbScore->ItemIndex = 0;
m_cbScore->Enabled = true;
m_bCheckedPass = true;
}
else{
mtDescript->Enabled = true;
m_cbScore->ItemIndex = -1;
m_cbScore->Enabled = false;
m_bCheckedPass = false;
}
}
//---------------------------------------------------------------------------
bool TVerifyStylesForm::CheckStyleIsPass()
{
bool bRet = true;
if( rdCheckNotPass->Checked && mtDescript->Text.Trim()==L"" ){
MessageBox(Handle,L"请输入审核未通过的描述?",L"提示信息",MB_ICONWARNING|MB_OK);
mtDescript->SetFocus();
bRet = false;
}
return bRet;
}
void __fastcall TVerifyStylesForm::FormCreate(TObject *Sender)
{
m_iRetCheckStyle = -1;
}
//---------------------------------------------------------------------------
void __fastcall TVerifyStylesForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
{
switch( Key ){
case VK_RETURN:
// btnOkClick(NULL);
break;
case VK_ESCAPE:
ModalResult = mrCancel;
break;
}
}
//---------------------------------------------------------------------------
File diff suppressed because it is too large Load Diff
+38
View File
@@ -0,0 +1,38 @@
//---------------------------------------------------------------------------
#ifndef VerifyStylesFormUnitH
#define VerifyStylesFormUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
//---------------------------------------------------------------------------
class TVerifyStylesForm : public TForm
{
__published: // IDE-managed Components
TRadioButton *rdCheckPass;
TRadioButton *rdCheckNotPass;
TMemo *mtDescript;
TButton *btnOk;
TButton *btnCancel;
TLabel *Label1;
TComboBox *m_cbScore;
void __fastcall btnCancelClick(TObject *Sender);
void __fastcall btnOkClick(TObject *Sender);
void __fastcall OnSelectVerifyStyleClick(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
void __fastcall FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
private: // User declarations
bool m_bCheckedPass;
bool CheckStyleIsPass();
public: // User declarations
__fastcall TVerifyStylesForm(TComponent* Owner);
public:
int m_iStyleId;
int m_iRetCheckStyle;
};
//---------------------------------------------------------------------------
extern PACKAGE TVerifyStylesForm *VerifyStylesForm;
//---------------------------------------------------------------------------
#endif
+371
View File
@@ -0,0 +1,371 @@
#ifndef _COMMONSTRUCT_H_
#define _COMMONSTRUCT_H_
#pragma once
#define MAX_STYLE_NUM 80
enum EClientType{
e_Ac_Windows,
e_CZ_Android,
e_CZ_iOS,
e_Ac_Android,
e_Ac_iOS,
e_Web,
e_Pro_Windows,
e_SM_Checker
};
enum EStyleState{
e_OffLine = -2, //下线
e_CheckFail, //审核未通过
e_Checking, //待审核
e_Distribute, //发布
e_UnDownload, //未下载
e_Downloading, //在下载
e_Downloaded //已下载
};
enum EMessageType{
e_InvalidMessage,
e_versionRequest = 0x01,
e_versionResponse,
e_connectRequest = 0x11,
e_connectResponse,
e_loginRequest = 0x21,
e_loginResponse,
e_verifyRequest,
e_verifyResponse,
e_purchaseRequest,
e_purchaseResponse,
e_registerRequest,
e_registerResponse,
e_dataSendRequest = 0x41,
e_dataSendResponse,
e_dataReceiveRequest,
e_dataReceiveResponse,
e_styleUpdateRequest = 0x61,
e_styleUpdateResponse,
e_styleInfoRequest,
e_styleInfoResponse,
e_styleDataRequest,
e_styleDataResponse,
e_styleCheckRequest,
e_styleCheckResponse,
e_styleRecomRequest,
e_styleRecomResponse,
e_uploadStyleRequest = 0x81,
e_uploadStyleResponse,
e_uploadSongRequest,
e_uploadSongResponse,
e_qnaUpdateRequest = 0x91,
e_qnaUpdateResponse,
e_qnaSubmitRequest,
e_qnaSubmitResponse,
e_noticeUpdateRequest,
e_noticeUpdateResponse,
e_MessgeTypeEnd
};
enum EExtraInfo{
e_RequestSuccess,
e_UpdateNoNeed, //已是最新版本
e_UpdateOptional, //版本可选更新
e_UpdateMandatory, //版本强制更新
e_VerifyInsufficient,
e_ShareStyle = 0x100, //分享风格信息
e_CheckStyle = 0x101, //审核风格信息
e_RequestFailed = 0x8000,
e_SocketError,
e_WaitTimeout,
e_DatabaseError,
e_ParamError,
e_LoginPasswordError,
e_LoginUserNotExist,
e_InvalidUserID,
e_InvalidStyleID,
e_UserCanceled,
e_NoService,
e_ServiceBusy,
e_InvalidDataID,
e_InvalidPackID,
e_OutOfBound,
e_InvalidData,
e_InvalidAuthority, //无操作权限
e_CheckedAlready, //风格已被审核
e_UsernameExist,
e_OpenFileFailed,
e_NeedRepeat, //需重发消息
e_ExtraEnd
};
enum EStyleType{
e_ST_BEGIN,
e_ST_Origin,
e_ST_Temp,
e_ST_Share,
e_ST_END
};
#pragma pack (2)
// 通道信息
typedef struct tagChan{
char no; //通道号
char prog; //乐器号
char vol; //音量
tagChan(){
no = prog = vol = -1;
}
}TCHAN, *PTCHAN;
//风格详细信息结构体
typedef struct tagStyleDetail{
int size;
int idAuthor; //作者ID
short iTempo; //原速
short iTimesignature; //节拍 ( 0=4/4, 1=3/4, 2=2/4, 3=6/8 )
char type[4]; //风格分类
char nSegNum[4]; //伴奏/加花/前奏/尾奏个数
//以下部分可变长度传输和存储
char strAuthor[40]; //作者名称 UTF8
char strStyleName[40]; //风格名称 UTF8
char strDescription[120]; //风格描述 UTF8
char aIntroBars[8]; //前奏小节数
char aEndingBars[8]; //尾奏小节数
char chordRecom[8]; //推荐和声进行
TCHAN tracks[4][8][16]; //伴奏/加花/前奏/尾奏轨道信息 (前/尾奏 0-3大调 4-7小调)
tagStyleDetail(){
size = sizeof(tagStyleDetail);
idAuthor = iTempo = iTimesignature = 0;
memset( type, -1, sizeof(type) );
memset( nSegNum, 0, sizeof(nSegNum) );
memset( strAuthor, 0, sizeof(strAuthor) );
memset( strStyleName, 0, sizeof(strStyleName) );
memset( strDescription, 0, sizeof(strDescription) );
memset( aIntroBars, 0, sizeof(aIntroBars) );
memset( aEndingBars, 0, sizeof(aEndingBars) );
memset( chordRecom, -1, sizeof(chordRecom) );
// memset( progs, -1, sizeof(progs) );
}
}TSTYLEDETAIL, *PTSTYLEDETAIL;
//制作风格信息结构体
typedef struct tagMakeStyleInfo{
short price; //购买消费
short cost; //使用消费
TSTYLEDETAIL detail; //详细信息
tagMakeStyleInfo(){
price = 0;
cost = 0;
}
}TMAKESTYLEINFO, *PMAKETSTYLEINFO;
//Be used to upload local styles
typedef struct tagDefStyleInfo
{
UINT idStyle;
TMAKESTYLEINFO tStyleInfo;
String strFileName;
}TDEFSTYLEINFO;
//原创风格信息
typedef struct tagStyleOrigin{
WORD cost; //使用消费
WORD score; //评分 (score/100)10分制
int paid; //支付次数
int state; //状态
TSTYLEDETAIL detail;
tagStyleOrigin(){
cost = 0;
score = 0;
paid = 0;
state = 0;
}
}TSTYLEORIGIN, *PTSTYLEORIGIN;
//专业版风格结构体
typedef struct tagProStyle{
UINT idLoc; //位置id
UINT idStyle; //风格ID
PTSTYLEORIGIN pOrigin;
tagProStyle(){
memset( this, 0, sizeof(tagProStyle) );
}
~tagProStyle(){
if( pOrigin )
delete pOrigin;
}
}TPROSTYLE, *PTPROSTYLE;
typedef struct tagTrack
{
UINT iStyleLoc; //位置id
UINT iStyleId; //0 = 原创文件输入?
BYTE iSegNo; //片段号 VAR:0-3, FILL:0-1, INTRO/ENDING: 0-3 [+(1...2 * 16)指定大小调]
BYTE iChanNo; //通道号 0-15 9为打击乐轨道
BYTE iChanSpec; //指定通道号,组合风格时防止chan冲突
BYTE iProg; //乐器号 0-127
BYTE nVol; //音量 0-127
BYTE iFile; //预留,暂用于字节对齐
char iPan; //声像 -63=left, 0=middle, 63=right
char nGain; //增益 -127<0<+127
tagTrack(){
memset( this, 0, sizeof(tagTrack) );
};
tagTrack( tagTrack* src ){
memcpy( this, src, sizeof(tagTrack) );
};
}TTrack;
typedef struct tagBarChords
{
//每小节最多4个和弦
BYTE iKey[4]; //和弦调号
BYTE iType[4]; //和弦种类
tagBarChords(){
memset( this, -1, sizeof(tagBarChords) );
};
tagBarChords( tagBarChords* src ){
memcpy( this, src, sizeof(tagBarChords) );
};
} TBarChords; //和弦小节(非前间尾奏段)
typedef struct tagStage
{
char iSegType; //片段类型 0=VAR, 1=FILL, 2=INTRO, 3=ENDING
char iSegKey; //片段调号
WORD reserved; //保留字段,对齐字节
int nBarNum; //段落长度
TBarChords* aChords; //各小节和弦
int nTrkNum; //轨道数
TTrack* aTracks; //轨道数组
tagStage(){
memset( this, 0, sizeof(tagStage) );
};
tagStage( tagStage* src ){
memcpy( this, src, sizeof(tagStage) );
if( src->aTracks ){
aTracks = new TTrack[nTrkNum];
memcpy( aTracks, src->aTracks, sizeof(TTrack)*nTrkNum );
}
if( src->aChords ){
aChords = new TBarChords[nBarNum];
memcpy( aChords, src->aChords, sizeof(TBarChords)*nBarNum );
}
};
~tagStage(){
if( aTracks )
delete[] aTracks;
if( aChords )
delete[] aChords;
}
} TStage; //编曲时用的结构
//版本结构体
typedef struct
{
WORD majorVersion; //主版本号
WORD minorVersion; //次版本号(客户端类型0=Windows版, 1=Android版, 2=iOS版, 3=风格合成, 4=风格审核 )
WORD modifyVersion; //修改版本号
WORD buildVersion; //编译版本号
}TVERSION, *PTVERSION;
#define MAX_DESCRIB_LENGTH 1024
//软件信息结构体
typedef struct tSoftwareInfo{
int size;
TVERSION version;
UINT nFileSize;
UINT tIssueDate;
char strDescribe[MAX_DESCRIB_LENGTH];
tSoftwareInfo(){
memset( this, 0, sizeof(tSoftwareInfo) );
size = sizeof(tSoftwareInfo);
};
} TSOFTWAREINFO, *PTSOFTWAREINFO;
#pragma pack (4)
//账户信息结构体
typedef struct tAccountInfo{
int ID; //用户ID
UINT authority; //用户权限
int balance; //帐户余额(唱作音符)
int pops; //魅力值
int fans; //粉丝数
int songs; //歌曲数
int vipPeriod; //VIP时长:-1=终身 0=非VIP 其它=vip剩余秒数
tAccountInfo(){
memset( this, 0, sizeof(tAccountInfo) );
};
}TACCOUNTINFO, *PTACCOUNTINFO;
//用户信息结构体
typedef struct tUserInfo{
char strUserName[32];
char strPassword[80];
char strNickName[32]; //用户昵称
char strIconFile[32]; //用户头像
TACCOUNTINFO accountInfo; //账户信息
int ownStyleNum; //已购买风格数
int arrStyleId[16]; //已购买风格ID数组
tUserInfo(){
memset( strUserName, 0, 32 );
memset( strPassword, 0, 80 );
memset( strNickName, 0, 32 );
memset( strIconFile, 0, 32 );
memset( arrStyleId, 0, 16 );
ownStyleNum = 0;
};
}TUSERINFO,*PTUSERINFO;
#pragma pack()
#endif //_COMMONSTRUCT_H_