没有音色库时自动载入Plugins\soundfont目录下的音色库

This commit is contained in:
Zhong Yang
2018-07-28 13:34:23 +08:00
parent 2c0affa230
commit f595ebead7
5 changed files with 34 additions and 6 deletions
+20
View File
@@ -24,6 +24,7 @@ CDataSettingsDlg::~CDataSettingsDlg()
void CDataSettingsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_SF2_PATH_EDIT, m_sf2_path_edit);
}
@@ -36,6 +37,7 @@ BEGIN_MESSAGE_MAP(CDataSettingsDlg, CDialogEx)
ON_BN_CLICKED(IDC_BROWSE_BUTTON, &CDataSettingsDlg::OnBnClickedBrowseButton)
ON_BN_CLICKED(IDC_MIDI_USE_INNER_LYRIC_CHECK, &CDataSettingsDlg::OnBnClickedMidiUseInnerLyricCheck)
ON_BN_CLICKED(IDC_DOWNLOAD_WHEN_TAG_FULL_CHECK, &CDataSettingsDlg::OnBnClickedDownloadWhenTagFullCheck)
ON_EN_CHANGE(IDC_SF2_PATH_EDIT, &CDataSettingsDlg::OnEnChangeSf2PathEdit)
END_MESSAGE_MAP()
@@ -68,6 +70,7 @@ BOOL CDataSettingsDlg::OnInitDialog()
m_toolTip.AddTool(GetDlgItem(IDC_MIDI_USE_INNER_LYRIC_CHECK), _T("有些 MIDI 音乐包含歌词,勾选此项后,会优先显示 MIDI 音乐内嵌的歌词。"));
GetDlgItem(IDC_BROWSE_BUTTON)->EnableWindow(theApp.m_format_convert_dialog_exit); //正在进行格式转换时不允许更改音色库
m_sf2_path_edit.EnableWindow(theApp.m_format_convert_dialog_exit);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
@@ -199,3 +202,20 @@ void CDataSettingsDlg::OnBnClickedDownloadWhenTagFullCheck()
// TODO: 在此添加控件通知处理程序代码
m_data.auto_download_only_tag_full = (((CButton*)GetDlgItem(IDC_DOWNLOAD_WHEN_TAG_FULL_CHECK))->GetCheck() != 0);
}
void CDataSettingsDlg::OnEnChangeSf2PathEdit()
{
// TODO: 如果该控件是 RICHEDIT 控件,它将不
// 发送此通知,除非重写 CDialogEx::OnInitDialog()
// 函数并调用 CRichEditCtrl().SetEventMask(),
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
if (m_sf2_path_edit.GetModify())
{
CString str;
m_sf2_path_edit.GetWindowText(str);
m_data.sf2_path = str;
}
// TODO: 在此添加控件通知处理程序代码
}
+2
View File
@@ -21,6 +21,7 @@ public:
private:
size_t m_data_size; //数据文件的大小
CToolTipCtrl m_toolTip;
CEdit m_sf2_path_edit;
void ShowDataSizeInfo();
@@ -39,4 +40,5 @@ public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnBnClickedMidiUseInnerLyricCheck();
afx_msg void OnBnClickedDownloadWhenTagFullCheck();
afx_msg void OnEnChangeSf2PathEdit();
};
Binary file not shown.
+1 -1
View File
@@ -356,7 +356,7 @@ void CMusicPlayerDlg::LoadConfig()
theApp.m_general_setting_data.auto_download_lyric = ini.GetBool(_T("general"), _T("auto_download_lyric"), 1);
theApp.m_general_setting_data.auto_download_album_cover = ini.GetBool(_T("general"), _T("auto_download_album_cover"), 1);
theApp.m_general_setting_data.auto_download_only_tag_full = ini.GetBool(_T("general"), _T("auto_download_only_tag_full"), 1);
theApp.m_general_setting_data.sf2_path = ini.GetString(L"general", L"sf2_path", L"%localdir%\\Plugins\\soundfont\\TimGM6mb.sf2");
theApp.m_general_setting_data.sf2_path = ini.GetString(L"general", L"sf2_path", L"");
theApp.m_general_setting_data.midi_use_inner_lyric = ini.GetBool(_T("general"), _T("midi_use_inner_lyric"), 0);
}
+11 -5
View File
@@ -88,15 +88,21 @@ void CPlayer::IniBASS()
m_sfont_name = L"<无>";
if (m_bass_midi_lib.IsSuccessed())
{
CString sf2_path = theApp.m_general_setting_data.sf2_path.c_str();
sf2_path.Replace(L"%localdir%\\", theApp.m_local_dir.c_str());
if (CCommon::FileExist(wstring(sf2_path)))
wstring sf2_path = theApp.m_general_setting_data.sf2_path;
if (!CCommon::FileExist(sf2_path)) //如果设置的音色库路径不存在,则从.\Plugins\soundfont\目录下查找音色库文件
{
m_sfont.font = m_bass_midi_lib.BASS_MIDI_FontInit(sf2_path, BASS_UNICODE);
vector<wstring> sf2s;
CCommon::GetFiles(plugin_dir + L"soundfont\\*.sf2", sf2s);
if (!sf2s.empty())
sf2_path = plugin_dir + L"soundfont\\" + sf2s[0];
}
if (CCommon::FileExist(sf2_path))
{
m_sfont.font = m_bass_midi_lib.BASS_MIDI_FontInit(sf2_path.c_str(), BASS_UNICODE);
if (m_sfont.font == 0)
{
CString info;
info.Format(_T("音色库“%s”加载失败!"), sf2_path.GetString());
info.Format(_T("音色库“%s”加载失败!"), sf2_path.c_str());
CCommon::WriteLog((theApp.m_module_dir + L"error.log").c_str(), info.GetString());
m_sfont_name = L"<加载失败>";
}