• R/O
  • SSH
  • HTTPS

cadencii: コミット


コミットメタ情報

リビジョン1976 (tree)
日時2012-01-30 02:51:27
作者haruneko24

ログメッセージ

[stand2.0/StandConverter] コネクト音源作成ツール.残りは実際のライブラリでの分析.

変更サマリ

差分

--- vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWindow.cpp (revision 1975)
+++ vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWindow.cpp (revision 1976)
@@ -11,6 +11,7 @@
1111 #include <QMessageBox>
1212 #include <QFileDialog>
1313 #include <QCloseEvent>
14+#include <QTextCodec>
1415
1516 using namespace stand::gui;
1617
@@ -162,6 +163,16 @@
162163 ui->RootDirectory->setText(dirName);
163164 }
164165
166+void TranscriberWindow::pushIcon()
167+{
168+ QString filename = QFileDialog::getOpenFileName(
169+ this,
170+ tr("Select library's icon."),
171+ tr("")
172+ );
173+ ui->LibraryIconPath->setText(filename);
174+}
175+
165176 void TranscriberWindow::_beginAnalyze()
166177 {
167178 stand::synthesis::TranscriberSetting s;
@@ -210,7 +221,18 @@
210221
211222 bool TranscriberWindow::_createSetting(stand::synthesis::TranscriberSetting &s)
212223 {
224+ s.root = ui->RootDirectory->text();
225+ s.libraryAuthor = ui->LibraryAuthor->text();
226+ s.libraryName = ui->LibraryName->text();
227+ s.libraryIconPath = ui->LibraryIconPath->text();
228+ s.libraryWeb = ui->LibraryWeb->text();
229+ qDebug("%s", s.root.absolutePath().toUtf8().data());
213230 s.numThreads = ui->NumThreads->value();
231+ s.codec = QTextCodec::codecForName(ui->RootEncode->currentText().toLocal8Bit().data());
232+ if(!s.codec)
233+ {
234+ s.codec = QTextCodec::codecForLocale();
235+ }
214236
215237 // 指定されたライブラリを全部読み込む.
216238 for(int i = 0; i < ui->SettingTabs->count(); i++)
@@ -270,6 +292,26 @@
270292 s.libraries.replace(index, tmp);
271293 }
272294
295+ // ディレクトリがかぶるのはアウト → 最悪再帰呼び出しでシンセサイザが死ぬ.
296+ for(int i = 0; i < s.libraries.size(); i++)
297+ {
298+ for(int j = i + 1; j < s.libraries.size(); j++)
299+ {
300+ if(s.libraries.at(i).body->directory().absolutePath()
301+ == s.libraries.at(j).body->directory().absolutePath())
302+ {
303+ QMessageBox::critical(this, tr("Error"),
304+ tr("Directory duplicated. You can not use one lib for two or more settings.\n")
305+ + s.libraries.at(i).body->directory().absolutePath());
306+ for(int k = 0; k < s.libraries.size(); k++)
307+ {
308+ delete s.libraries.at(k).body;
309+ }
310+ return false;
311+ }
312+ }
313+ }
314+
273315 return true;
274316 }
275317
@@ -285,6 +327,7 @@
285327
286328 bool TranscriberWindow::_checkSettingAvailability()
287329 {
330+ // ルートからたどれないディレクトリはダメ.
288331 QDir root(ui->RootDirectory->text());
289332 for(int i = 0; i < ui->SettingTabs->count(); i++)
290333 {
@@ -297,6 +340,7 @@
297340 return false;
298341 }
299342 }
343+
300344 return true;
301345 }
302346
--- vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWindow.h (revision 1975)
+++ vConnect/trunk/stand2.0/StandConverter/gui/TranscriberWindow.h (revision 1976)
@@ -32,6 +32,7 @@
3232
3333 void pushAnalyze();
3434 void pushRootDir();
35+ void pushIcon();
3536 void settingChanged();
3637 void transcriptionFinished(bool);
3738
--- vConnect/trunk/stand2.0/StandConverter/io/UtauLibrary.cpp (revision 1975)
+++ vConnect/trunk/stand2.0/StandConverter/io/UtauLibrary.cpp (revision 1976)
@@ -218,3 +218,14 @@
218218 file.close();
219219 return true;
220220 }
221+
222+void UtauLibrary::changeDirectory(const QDir &dst)
223+{
224+ // 相対パスに変えてディレクトリを変更する.
225+ for(int i = 0; i < settingList.size(); i++)
226+ {
227+ // セパレータを変更する必要はあるのかどうなのか.
228+ settingList[i].filename = QDir::toNativeSeparators(dst.relativeFilePath(_directory.absoluteFilePath(settingList.at(i).filename)));
229+ }
230+ _directory = dst;
231+}
--- vConnect/trunk/stand2.0/StandConverter/io/UtauLibrary.h (revision 1975)
+++ vConnect/trunk/stand2.0/StandConverter/io/UtauLibrary.h (revision 1976)
@@ -85,6 +85,8 @@
8585 /// <returns> NULL: 失敗,それ以外: 成功. </returns>
8686 const UtauPhoneme *find(const QString &pronounce);
8787
88+ void changeDirectory(const QDir &dst);
89+
8890 private:
8991 bool _readFromOtoIni(const QString &filename, QTextCodec *codec = NULL);
9092 bool _readOneLine(QString &line, QString &dir);
--- vConnect/trunk/stand2.0/StandConverter/synthesis/Transcriber.cpp (revision 1975)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/Transcriber.cpp (revision 1976)
@@ -3,6 +3,8 @@
33 #include "TranscriberElement.h"
44 #include "../io/UtauLibrary.h"
55
6+#include <QTextStream>
7+
68 using namespace stand::synthesis;
79
810 Transcriber::Transcriber(const TranscriberSetting *s, QObject *parent) :
@@ -10,6 +12,8 @@
1012 {
1113 setting = new TranscriberSetting();
1214 setting->numThreads = s->numThreads;
15+ setting->codec = s->codec;
16+ setting->root = s->root;
1317 for(int i = 0; i < s->libraries.size(); i++)
1418 {
1519 setting->libraries.push_back(s->libraries.at(i));
@@ -36,6 +40,12 @@
3640 {
3741 qDebug("Transcriber::run();");
3842
43+ if(!_writeSettings())
44+ {
45+ emit finish(false);
46+ return;
47+ }
48+
3949 QMutex mutex;
4050 mutex.lock();
4151 elements.clear();
@@ -87,3 +97,57 @@
8797 }
8898 condition.wakeAll();
8999 }
100+
101+bool Transcriber::_writeSettings()
102+{
103+ QDir current = setting->root;
104+ for(int i = 0; i < setting->libraries.size() - 1; i++)
105+ {
106+ QString filename = current.absoluteFilePath("vConnect.ini");
107+ QString base = current.relativeFilePath(setting->libraries.at(i).body->directory().absolutePath()) + QDir::separator();
108+ QString append = current.relativeFilePath(setting->libraries.at(i + 1).body->directory().absolutePath()) + QDir::separator();
109+ QFile file(filename);
110+ if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
111+ {
112+ qDebug(" Could not open file; %s", filename.toUtf8().data());
113+ return false;
114+ }
115+ QTextStream ofs;
116+ ofs.setDevice(&file);
117+ ofs.setCodec(setting->codec);
118+ ofs << "[BaseLibrary]\n"
119+ << "Enable=1\n"
120+ << "Brightness=" << setting->libraries.at(i).brightness << "\n"
121+ << "NoteNumber=" << setting->libraries.at(i).note << "\n"
122+ << "Directory=" << base << "\n"
123+ << "[BrightnessLibrary]\n"
124+ << "Enable=1\n"
125+ << "Brightness=" << setting->libraries.at(i + 1).brightness << "\n"
126+ << "NoteNumber=" << setting->libraries.at(i + 1).note << "\n"
127+ << "Directory=" << append << "\n"
128+ ;
129+ file.close();
130+ // 処理するディレクトリを移動する.
131+ current = QDir(current.absoluteFilePath(append));
132+ }
133+
134+ QString filename = setting->root.absoluteFilePath("character.txt");
135+ QFile file(filename);
136+ if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
137+ {
138+ qDebug(" Could not open file; %s", filename.toUtf8().data());
139+ return false;
140+ }
141+ QTextStream ofs;
142+ ofs.setDevice(&file);
143+ ofs.setCodec(setting->codec);
144+ ofs << "name=" << setting->libraryName << "\n"
145+ << "image=" << QFileInfo(setting->libraryIconPath).fileName() << "\n"
146+ << "author=" << setting->libraryAuthor << "\n"
147+ << "web=" << setting->libraryWeb << "\n"
148+ ;
149+
150+ stand::io::UtauLibrary *rootLib = setting->libraries.at(0).body;
151+ rootLib->changeDirectory(setting->root);
152+ return rootLib->write(setting->root.absoluteFilePath("oto.ini"));
153+}
--- vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberSetting.h (revision 1975)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/TranscriberSetting.h (revision 1976)
@@ -1,9 +1,12 @@
11 #ifndef TRANSCRIBERSETTING_H
22 #define TRANSCRIBERSETTING_H
33
4+#include <QDir>
45 #include <QVector>
56 #include "Transcriber.h"
67
8+class QTextCodec;
9+
710 namespace stand
811 {
912 namespace io
@@ -16,9 +19,15 @@
1619 class TranscriberSetting
1720 {
1821 public:
22+ QString libraryName;
23+ QString libraryIconPath;
24+ QString libraryAuthor;
25+ QString libraryWeb;
1926 QVector<Transcriber::TranscriberItem> libraries;
2027
2128 unsigned int numThreads;
29+ QDir root;
30+ QTextCodec *codec;
2231 };
2332
2433 }
--- vConnect/trunk/stand2.0/StandConverter/synthesis/Transcriber.h (revision 1975)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/Transcriber.h (revision 1976)
@@ -43,6 +43,8 @@
4343 void run();
4444
4545 private:
46+ bool _writeSettings();
47+
4648 TranscriberSetting *setting;
4749 int currentFinished;
4850 int currentIndex;
旧リポジトリブラウザで表示