• R/O
  • SSH
  • HTTPS

cadencii: コミット


コミットメタ情報

リビジョン1985 (tree)
日時2012-02-17 02:47:31
作者haruneko24

ログメッセージ

[StandConverter] 圧縮時DIOのパラメタをいじれるように変更.WORLD周りにクレジットの追加.

変更サマリ

差分

--- vConnect/trunk/stand2.0/StandConverter/utility/Utility.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/utility/Utility.cpp (revision 1985)
@@ -4,10 +4,18 @@
44
55 #include <math.h>
66
7+namespace stand
8+{
9+namespace utility
10+{
11+
712 // 波形の正規化に使う定数群
813 const static unsigned int NUM_NORMALIZE = 2048;
914 const static double VOL_NORMALIZE = 0.06;
1015
16+}
17+}
18+
1119 bool stand::utility::makeDirectory(QWidget *w, const QDir &dir, bool confirm)
1220 {
1321 // 存在する場合は真を返して終了.
--- vConnect/trunk/stand2.0/StandConverter/gui/SpecgramViewer.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/gui/SpecgramViewer.cpp (nonexistent)
@@ -1,37 +0,0 @@
1-#include "SpecgramViewer.h"
2-
3-#include <QImage>
4-
5-using namespace stand::gui;
6-
7-SpecgramViewer::SpecgramViewer(QWidget *parent) :
8- QWidget(parent)
9-{
10- _image = NULL;
11-}
12-
13-SpecgramViewer::~SpecgramViewer()
14-{
15- _destroy();
16-}
17-
18-void SpecgramViewer::_destroy()
19-{
20- delete _image;
21- _image = NULL;
22-}
23-
24-void SpecgramViewer::setSpecgram(double **specgram, int tLen, int fftl)
25-{
26- if(!specgram)
27- {
28- qDebug("SpecgramViewer::setSpecgram(%d, %d %d); // Invalid args", specgram, tLen, fftl);
29- return;
30- }
31-
32- _destroy();
33- _image = new QImage(tLen, fftl, QImage::Format_ARGB32);
34-
35- // 最小の値と最大の値を見つけてくる.
36-// for(int x = 0; x)
37-}
--- vConnect/trunk/stand2.0/StandConverter/gui/SpecgramViewer.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/gui/SpecgramViewer.h (nonexistent)
@@ -1,35 +0,0 @@
1-#ifndef SPECGRAMVIEWER_H
2-#define SPECGRAMVIEWER_H
3-
4-#include <QWidget>
5-
6-class QImage;
7-
8-namespace stand
9-{
10-namespace gui
11-{
12-
13-class SpecgramViewer : public QWidget
14-{
15- Q_OBJECT
16-public:
17- explicit SpecgramViewer(QWidget *parent = NULL);
18- ~SpecgramViewer();
19-
20- void setSpecgram(double **specgram, int tLen, int fftl);
21- //void paintEvent(QPaintEvent *e);
22-signals:
23-
24-public slots:
25- //void specgramDeleted();
26-
27-private:
28- void _destroy();
29- QImage *_image;
30-};
31-
32-}
33-}
34-
35-#endif // SPECGRAMVIEWER_H
--- vConnect/trunk/stand2.0/StandConverter/gui/ConverterWindow.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/gui/ConverterWindow.cpp (revision 1985)
@@ -84,6 +84,8 @@
8484 // Analysis Settings
8585 ui->ThreadNumber->setEnabled(e);
8686 ui->AnalysisFramePeriod->setEnabled(false);
87+ ui->F0Ceil->setEnabled(e);
88+ ui->F0Floor->setEnabled(e);
8789
8890 // ProgressBar Setting
8991 ui->AnalysisProgress->setEnabled(!e);
@@ -193,6 +195,9 @@
193195 setting.phonemeLength = ui->PhonemeLength->value();
194196 setting.numThreads = ui->ThreadNumber->value();
195197
198+ setting.f0Ceil = ui->F0Ceil->value();
199+ setting.f0Floor = ui->F0Floor->value();
200+
196201 setting.framePeriod = ui->AnalysisFramePeriod->value();
197202 setting.outCodec = QTextCodec::codecForName(ui->DestEncodingType->currentText().toLocal8Bit().data());
198203
@@ -252,3 +257,13 @@
252257 isAnalyzing = false;
253258 setEditorEnabled(true);
254259 }
260+
261+void ConverterWindow::ceilChanged(double val)
262+{
263+ ui->F0Floor->setMaximum(val);
264+}
265+
266+void ConverterWindow::floorChanged(double val)
267+{
268+ ui->F0Ceil->setMinimum(val);
269+}
--- vConnect/trunk/stand2.0/StandConverter/gui/ConverterWindow.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/gui/ConverterWindow.h (revision 1985)
@@ -65,6 +65,9 @@
6565 /// <summary> 変換が終了した際に呼ばれるスロット. </summary>
6666 void converterFinished(bool f);
6767
68+ void ceilChanged(double val);
69+ void floorChanged(double val);
70+
6871 private:
6972 bool _setConverterSetting(stand::synthesis::ConverterSetting &setting);
7073 void _errorMessage(const QString &text);
--- vConnect/trunk/stand2.0/StandConverter/gui/WorldWindow.cpp (nonexistent)
+++ vConnect/trunk/stand2.0/StandConverter/gui/WorldWindow.cpp (revision 1985)
@@ -0,0 +1,93 @@
1+#include "WorldWindow.h"
2+#include "ui_WorldWindow.h"
3+
4+#include "math/World.h"
5+#include "math/SpecgramSet.h"
6+#include "io/WaveFile.h"
7+
8+#include <QFileInfo>
9+#include <QMessageBox>
10+#include <QFileDialog>
11+
12+using namespace stand::gui;
13+
14+WorldWindow::WorldWindow(QWidget *parent) :
15+ QMainWindow(parent),
16+ ui(new Ui::WorldWindow)
17+{
18+ ui->setupUi(this);
19+ _s = NULL;
20+ _w = NULL;
21+ _wave = NULL;
22+
23+ ui->ViewerArea->setWidget(new QLabel(""));
24+}
25+
26+WorldWindow::~WorldWindow()
27+{
28+ delete ui;
29+ _destroy();
30+}
31+
32+void WorldWindow::_destroy()
33+{
34+ delete _s;
35+ delete _w;
36+ delete _wave;
37+ _s = NULL;
38+ _w = NULL;
39+ _wave = NULL;
40+}
41+
42+void WorldWindow::beginAnalyze()
43+{
44+ QFileInfo fileInfo(ui->FileNameEdit->text());
45+ if(!fileInfo.exists())
46+ {
47+ QMessageBox::critical(this, tr("Error"), tr("Could not find file: ") + ui->FileNameEdit->text());
48+ return;
49+ }
50+ _destroy();
51+ _wave = new stand::io::WaveFile(fileInfo.absoluteFilePath().toLocal8Bit().data());
52+ _s = new stand::math::SpecgramSet();
53+ _w = new stand::math::world::WorldSet();
54+ // 読み込めていたら.
55+ if(_s && _w)
56+ {
57+ _s->compute(_wave->data(), _wave->length());
58+ _w->compute(_wave->data(), _wave->length());
59+ _imagePowerSpec.set(_s->specgram(), _s->tLen(), _s->fftl() / 2 + 1, _s->samplingFrequency() / 2);
60+ _imageStarSpec.set(_w->specgram(), _w->tLen(), _w->fftl() / 2 + 1, _w->samplingFrequency() / 2);
61+ changeSpectrumType(true);
62+ }
63+}
64+
65+void WorldWindow::changeSpectrumType(bool b)
66+{
67+ if(!b)
68+ {
69+ return;
70+ }
71+ QImage image;
72+ if(ui->TypeFFT->isChecked())
73+ {
74+ image = _imagePowerSpec.image();
75+ }
76+ else if(ui->TypeStar->isChecked())
77+ {
78+ image = _imageStarSpec.image();
79+ }
80+ QLabel *l = dynamic_cast<QLabel *>(ui->ViewerArea->widget());
81+ if(l)
82+ {
83+ l->setPixmap(QPixmap::fromImage(image));
84+ }
85+}
86+
87+void WorldWindow::searchDirectory()
88+{
89+ QString fileName = QFileDialog::getOpenFileName(this, tr("Select Wave File"), "", tr("WaveFile (*.wav)"));
90+ ui->FileNameEdit->setText(fileName);
91+}
92+
93+
--- vConnect/trunk/stand2.0/StandConverter/gui/WorldWindow.h (nonexistent)
+++ vConnect/trunk/stand2.0/StandConverter/gui/WorldWindow.h (revision 1985)
@@ -0,0 +1,54 @@
1+#ifndef WORLDWINDOW_H
2+#define WORLDWINDOW_H
3+
4+#include <QMainWindow>
5+#include "../io/SpecgramImage.h"
6+
7+namespace Ui {
8+class WorldWindow;
9+}
10+
11+namespace stand
12+{
13+namespace math
14+{
15+class SpecgramSet;
16+namespace world
17+{
18+class WorldSet;
19+}
20+}
21+namespace io
22+{
23+class WaveFile;
24+}
25+namespace gui
26+{
27+
28+class WorldWindow : public QMainWindow
29+{
30+ Q_OBJECT
31+public:
32+ explicit WorldWindow(QWidget *parent = 0);
33+ ~WorldWindow();
34+
35+public slots:
36+ void beginAnalyze();
37+ void searchDirectory();
38+ void changeSpectrumType(bool b);
39+
40+private:
41+ void _destroy();
42+ Ui::WorldWindow *ui;
43+ stand::math::SpecgramSet *_s;
44+ stand::math::world::WorldSet *_w;
45+ stand::io::WaveFile *_wave;
46+
47+ stand::io::SpecgramImage _imagePowerSpec;
48+ stand::io::SpecgramImage _imageStarSpec;
49+};
50+
51+}
52+}
53+
54+#endif // WORLDWINDOW_H
--- vConnect/trunk/stand2.0/StandConverter/main.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/main.cpp (revision 1985)
@@ -1,6 +1,7 @@
11 #include <QtGui/QApplication>
22 #include "gui/ConverterWindow.h"
33 #include "gui/TranscriberWindow.h"
4+#include "gui/WorldWindow.h"
45
56 #include <QTextCodec>
67
@@ -18,10 +19,11 @@
1819 QTextCodec::setCodecForTr(codec);
1920
2021 // 実行
21-// ConverterWindow w;
22-// w.setWindowTitle("Compressor");
23- TranscriberWindow w;
24- w.setWindowTitle("Transcriber");
22+ //WorldWindow w;
23+ ConverterWindow w;
24+ w.setWindowTitle("Compressor");
25+// TranscriberWindow w;
26+// w.setWindowTitle("Transcriber");
2527 w.show();
2628
2729 return a.exec();
--- vConnect/trunk/stand2.0/StandConverter/io/StandFile.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/io/StandFile.h (revision 1985)
@@ -37,6 +37,8 @@
3737 /// <param name="minBitrate">Vorbis 圧縮の最小ビットレートの設定.</param>
3838 /// <param name="maxBitrate">Vorbis 圧縮の最大ビットレートの設定.</param>
3939 /// <param name="averageBitrate">Vorbis 圧縮の平均ビットレートの設定.</param>
40+ /// <param name="f0Ceil">DIO による F0 推定値のうち許容する最大値.</param>
41+ /// <param name="f0Floor">DIO による F0 推定値のうち許容する最小値.</param>
4042 /// <returns>計算に成功したときは true, 失敗したときは false を返します.</returns>
4143 bool compute(double *x,
4244 int xLen,
@@ -45,7 +47,9 @@
4547 int cepstrumLength,
4648 int minBitrate,
4749 int maxBitrate,
48- int averageBitrate);
50+ int averageBitrate,
51+ double f0Ceil,
52+ double f0Floor);
4953
5054 static void matching(StandFile *src, StandFile *dst);
5155
--- vConnect/trunk/stand2.0/StandConverter/io/VorbisFile.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/io/VorbisFile.cpp (revision 1985)
@@ -10,8 +10,8 @@
1010 using namespace stand::io;
1111
1212 // OggVorbis のエンコードに必要な定数群
13-const static char ENCODER_TAG[] = "Stand Library";
14-const static int bufSize = 4096;
13+const char VorbisFile::ENCODER_TAG[] = "Stand Library";
14+const int VorbisFile::bufSize = 4096;
1515
1616 // VorbisFile の操作に必要な構造体
1717 struct stand::io::VorbisBuffer
--- vConnect/trunk/stand2.0/StandConverter/io/SpecgramImage.cpp (nonexistent)
+++ vConnect/trunk/stand2.0/StandConverter/io/SpecgramImage.cpp (revision 1985)
@@ -0,0 +1,71 @@
1+#include "SpecgramImage.h"
2+
3+#include <float.h>
4+#include <math.h>
5+
6+using namespace stand::io;
7+
8+SpecgramImage::SpecgramImage()
9+{
10+ _tLen = _fftl = _fs = 0;
11+}
12+
13+SpecgramImage::SpecgramImage(double **specgram, int tLen, int fftl, int fs)
14+{
15+ set(specgram, tLen, fftl, fs);
16+}
17+
18+void SpecgramImage::set(double **specgram, int tLen, int fftl, int fs)
19+{
20+ if(!specgram || tLen <= 0 || fftl <= 0 || fs <= 0)
21+ {
22+ return;
23+ }
24+ _image = SpecgramImage::imageFromSpecgram(specgram, tLen, fftl);
25+ _tLen = tLen;
26+ _fftl = fftl;
27+ _fs = fs;
28+}
29+
30+
31+const QImage &SpecgramImage::image()
32+{
33+ return _image;
34+}
35+
36+QImage SpecgramImage::imageFromSpecgram(double **specgram, int tLen, int fftl)
37+{
38+ if(!specgram)
39+ {
40+ qDebug("SpecgramPixmap::setSpecgram(%d, %d %d); // Invalid args", specgram, tLen, fftl);
41+ return QImage();
42+ }
43+
44+ QImage image(tLen, fftl, QImage::Format_ARGB32);
45+
46+ // 最小の値と最大の値を見つけてくる.
47+ double maxValue = -DBL_MAX;
48+ for(int x = 0; x < tLen; x++)
49+ {
50+ for(int y = 0; y < fftl; y++)
51+ {
52+ maxValue = (specgram[x][y] > maxValue) ? specgram[x][y] : maxValue;
53+ }
54+ }
55+
56+ // 45 dB決め打ち.でいいのかな.
57+ // 点描するよ!
58+ for(int x = 0; x < tLen; x++)
59+ {
60+ for(int y = 0; y < fftl; y++)
61+ {
62+ double dB = log10(specgram[x][y]) - log10(maxValue);
63+ int r, g, b, c = (dB + 10) / 10.0 * 255.0 * 3;
64+ r = (c >= 512) ? (c - 512) : 0;
65+ g = (c >= 512) ? 255 : (c >= 256) ? (c - 256) : 0;
66+ b = (c >= 256) ? 255 : (c >= 0) ? c : 0;
67+ image.setPixel(x, fftl - 1 - y, qRgb(r, g, b));
68+ }
69+ }
70+ return image;
71+}
--- vConnect/trunk/stand2.0/StandConverter/io/StandFile.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/io/StandFile.cpp (revision 1985)
@@ -153,7 +153,7 @@
153153 return true;
154154 }
155155
156-bool StandFile::compute(double *x, int xLen, int fs, double framePeriod, int cepstrumLength, int minBitrate, int maxBitrate, int averageBitrate)
156+bool StandFile::compute(double *x, int xLen, int fs, double framePeriod, int cepstrumLength, int minBitrate, int maxBitrate, int averageBitrate, double f0Ceil, double f0Floor)
157157 {
158158 if(!x || xLen < 0)
159159 {
@@ -169,12 +169,13 @@
169169 this->_fftl = FFTLengthForStar(fs);
170170 this->_fs = fs;
171171
172- World::WorldSetting s = {
172+ stand::math::SpecgramSet::SpecgramSetting s =
173+ {
173174 fs,
174175 framePeriod
175176 };
176177
177- World w(_tLen , _fftl, &s);
178+ WorldSet w(_tLen , _fftl, &s);
178179 MFCCSet mfcc(_fftl);
179180 _create(_tLen, _cLen);
180181
@@ -182,7 +183,7 @@
182183 /* まず WORLD による分析を行う. */
183184 /* ただしスペクトルの代わりにメルケプを使用する. */
184185 /****************************************************/
185- dio(x, xLen, fs, framePeriod, w.t(), w.f0());
186+ dio(x, xLen, fs, framePeriod, w.t(), w.f0(), f0Ceil, f0Floor);
186187 star(x, xLen, fs, w.t(), w.f0(), w.specgram());
187188
188189 for(int i = 0; i < _tLen; i++)
@@ -226,7 +227,7 @@
226227 fftw_complex *in = (fftw_complex *)fft.in();
227228 double *out = (double *)fft.out();
228229
229- World::extractResidual(in, w.residualAt(i), _fftl);
230+ extractResidual(in, w.residualAt(i), _fftl);
230231
231232 fft.execute();
232233
--- vConnect/trunk/stand2.0/StandConverter/io/VorbisFile.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/io/VorbisFile.h (revision 1985)
@@ -73,6 +73,9 @@
7373 int size;
7474 };
7575
76+ const static int bufSize;
77+ const static char ENCODER_TAG[];
78+
7679 static size_t _read(void *dst, size_t size, size_t maxCount, void *vp);
7780 static int _seek(void *vp, ogg_int64_t offset, int flag);
7881 static int _close(void *vp);
--- vConnect/trunk/stand2.0/StandConverter/io/SpecgramImage.h (nonexistent)
+++ vConnect/trunk/stand2.0/StandConverter/io/SpecgramImage.h (revision 1985)
@@ -0,0 +1,32 @@
1+#ifndef SPECGRAMIMAGE_H
2+#define SPECGRAMIMAGE_H
3+
4+#include <QImage>
5+
6+namespace stand
7+{
8+namespace io
9+{
10+
11+class SpecgramImage
12+{
13+public:
14+ explicit SpecgramImage();
15+ explicit SpecgramImage(double **specgram, int tLen, int fftl, int fs);
16+
17+ void set(double **specgram, int tLen, int fftl, int fs);
18+
19+ const QImage &image();
20+
21+ static QImage imageFromSpecgram(double **specgram, int tLen, int fftl);
22+private:
23+ int _tLen;
24+ int _fftl;
25+ int _fs;
26+ QImage _image;
27+};
28+
29+}
30+}
31+
32+#endif // SPECGRAMIMAGE_H
--- vConnect/trunk/stand2.0/StandConverter/math/MatlabFunctions.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/MatlabFunctions.h (revision 1985)
@@ -1,3 +1,18 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file MatlabFunctions.h
10+ * @brief Functions for matlab compatibility.
11+ * Original source codes are below.
12+ * http://www.aspl.is.ritsumei.ac.jp/morise/world/
13+ * This code is redistributed to support thread safety with Qt Library.
14+ * @author HAL@shurabaP
15+ */
116 #ifndef MATLABFUNCTIONS_H
217 #define MATLABFUNCTIONS_H
318
--- vConnect/trunk/stand2.0/StandConverter/math/Platinum.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/Platinum.h (revision 1985)
@@ -1,3 +1,18 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file Platinum.h
10+ * @brief Excitation signal estimation method PLATINUM
11+ * Original source codes are below.
12+ * http://www.aspl.is.ritsumei.ac.jp/morise/world/
13+ * This code is redistributed to support thread safety with Qt Library.
14+ * @author HAL@shurabaP
15+ */
116 #ifndef PLATINUM_H
217 #define PLATINUM_H
318
--- vConnect/trunk/stand2.0/StandConverter/math/FFTSet.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/FFTSet.h (revision 1985)
@@ -1,3 +1,17 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file FFTSet.h
10+ * @brief FFTSet class supports fft calculation
11+ * and keep data for FFT.
12+ * This code supports thread safety with Qt Library.
13+ * @author HAL@shurabaP
14+ */
115 #ifndef FFTSET_H
216 #define FFTSET_H
317
@@ -8,9 +22,13 @@
822 {
923 namespace math
1024 {
25+/*!
26+ * @brief FFTSet class supports FFT by FFTW.
27+ */
1128 class FFTSet
1229 {
1330 public:
31+ //! @brief FFTType
1432 enum FFTtype
1533 {
1634 FFTW_UNKNOWN = -1,
--- vConnect/trunk/stand2.0/StandConverter/math/WorldSynthesis.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/WorldSynthesis.cpp (revision 1985)
@@ -1,3 +1,18 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file WorldSynthesis.cpp
10+ * @brief Synthesis for WORLD data.
11+ * Original source codes are below.
12+ * http://www.aspl.is.ritsumei.ac.jp/morise/world/
13+ * This code is redistributed to support thread safety with Qt Library.
14+ * @author HAL@shurabaP
15+ */
116 #include "WorldSynthesis.h"
217
318 #include "FFTSet.h"
@@ -10,7 +25,7 @@
1025 #include <stdlib.h>
1126
1227 // 特定時刻の応答を取得する.
13-static void oneFrameSegment(double *f0, double **specgram, double **residualSpecgram, int fftl, double framePeriod, double currentTime, int fs, double defaultF0,
28+void stand::math::world::oneFrameSegment(double *f0, double **specgram, double **residualSpecgram, int fftl, double framePeriod, double currentTime, int fs, double defaultF0,
1429 FFTSet *forward, FFTSet *inverse, FFTSet *toWave)
1530 {
1631 double tmp;
--- vConnect/trunk/stand2.0/StandConverter/math/WorldSet.cpp (nonexistent)
+++ vConnect/trunk/stand2.0/StandConverter/math/WorldSet.cpp (revision 1985)
@@ -0,0 +1,169 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file WorldSet.cpp
10+ * @brief WorldSet class supports calculation of WORLD,
11+ * and keep data for WORLD; DIO, STAR and PLATINUM.
12+ * This code is thread safe with Qt Library.
13+ * @author HAL@shurabaP
14+ */
15+#include "WorldSet.h"
16+
17+#include "World.h"
18+
19+using namespace stand::math::world;
20+
21+WorldSet::WorldSet(const SpecgramSet::SpecgramSetting *s) :
22+ SpecgramSet(s)
23+{
24+ _residual = NULL;
25+ _f0 = _t = NULL;
26+}
27+
28+WorldSet::WorldSet(const double *x, int xLen, const SpecgramSet::SpecgramSetting *s) :
29+ SpecgramSet(s)
30+{
31+ _residual = NULL;
32+ _f0 = _t = NULL;
33+ compute(x, xLen, s);
34+}
35+
36+WorldSet::WorldSet(int tLen, int fftl, const SpecgramSet::SpecgramSetting *s) :
37+ SpecgramSet(s)
38+{
39+ _specgram = _residual = NULL;
40+ _f0 = _t = NULL;
41+ _create(tLen, fftl);
42+}
43+
44+WorldSet::~WorldSet()
45+{
46+ _destroy();
47+}
48+
49+void WorldSet::compute(const double *x, int xLen, const SpecgramSet::SpecgramSetting *s)
50+{
51+ if(!x)
52+ {
53+ return;
54+ }
55+ int tLen = samplesForDio(s->fs, xLen, s->framePeriod);
56+ int fftl = FFTLengthForStar(s->fs);
57+ _create(tLen, fftl);
58+
59+ if(!s)
60+ {
61+ s = &SPECGRAM_DEFAULT_SETTING;
62+ }
63+ _setting = *s;
64+
65+ dio(x, xLen, s->fs, s->framePeriod, _t, _f0);
66+ star(x, xLen, s->fs, _t, _f0, _specgram);
67+ platinum(x, xLen, s->fs, _t, _f0, _specgram, _residual);
68+}
69+
70+double *WorldSet::spectrumAt(double t)
71+{
72+ return spectrumAt(_indexAtSec(t));
73+}
74+
75+double *WorldSet::spectrumAt(int i)
76+{
77+ if(i < 0)
78+ {
79+ i = 0;
80+ }
81+ else if(i >= _tLen)
82+ {
83+ i = _tLen - 1;
84+ }
85+ return _specgram[i];
86+}
87+
88+double *WorldSet::residualAt(double t)
89+{
90+ return residualAt(_indexAtSec(t));
91+}
92+
93+double *WorldSet::residualAt(int i)
94+{
95+ if(i < 0)
96+ {
97+ i = 0;
98+ }
99+ else if(i >= _tLen)
100+ {
101+ i = _tLen - 1;
102+ }
103+ return _residual[i];
104+}
105+
106+double WorldSet::f0At(double t)
107+{
108+ return f0At(_indexAtSec(t));
109+}
110+
111+double WorldSet::f0At(int i)
112+{
113+ if(i < 0)
114+ {
115+ i = 0;
116+ }
117+ else if(i >= _tLen)
118+ {
119+ i = _tLen - 1;
120+ }
121+ return _f0[i];
122+}
123+
124+double WorldSet::tAt(double t)
125+{
126+ return tAt(_indexAtSec(t));
127+}
128+
129+double WorldSet::tAt(int i)
130+{
131+ if(i < 0)
132+ {
133+ i = 0;
134+ }
135+ else if(i >= _tLen)
136+ {
137+ i = _tLen - 1;
138+ }
139+ return _t[i];
140+}
141+
142+void WorldSet::_destroy()
143+{
144+ _destroySpecgram();
145+ if(_residual)
146+ {
147+ delete[] _residual[0];
148+ }
149+ delete[] _residual;
150+
151+ delete[] _f0;
152+ delete[] _t;
153+ _residual = NULL;
154+ _f0 = _t = NULL;
155+}
156+
157+void WorldSet::_create(int tLen, int fftl)
158+{
159+ _destroy();
160+ _createSpecgram(tLen, fftl);
161+ _f0 = new double[tLen];
162+ _t = new double[tLen];
163+ _residual = new double*[tLen];
164+ _residual[0] = new double[tLen * fftl];
165+ for(int i = 1; i < tLen; i++)
166+ {
167+ _residual[i] = _residual[0] + i * fftl;
168+ }
169+}
--- vConnect/trunk/stand2.0/StandConverter/math/MathSet.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/MathSet.cpp (revision 1985)
@@ -1,3 +1,14 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file MathSet.cpp
10+ * @author HAL@shurabaP
11+ */
112 #include "MathSet.h"
213
314 double stand::math::interpolateArray( double x, const double *p )
--- vConnect/trunk/stand2.0/StandConverter/math/WorldSynthesis.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/WorldSynthesis.h (revision 1985)
@@ -1,3 +1,18 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file WorldSynthesis.h
10+ * @brief Synthesis for WORLD data.
11+ * Original source codes are below.
12+ * http://www.aspl.is.ritsumei.ac.jp/morise/world/
13+ * This code is redistributed to support thread safety with Qt Library.
14+ * @author HAL@shurabaP
15+ */
116 #ifndef WORLDSYNTHESIS_H
217 #define WORLDSYNTHESIS_H
318
@@ -10,6 +25,8 @@
1025 namespace world
1126 {
1227
28+void oneFrameSegment(double *f0, double **specgram, double **residualSpecgram, int fftl, double framePeriod, double currentTime, int fs, double defaultF0,
29+ FFTSet *forward, FFTSet *inverse, FFTSet *toWave);
1330 void synthesis(double *f0, double **specgram, double **residual, int tLen, int fftl, double framePeriod, int fs,
1431 double *synthesisOut, int xLen);
1532
--- vConnect/trunk/stand2.0/StandConverter/math/WorldSet.h (nonexistent)
+++ vConnect/trunk/stand2.0/StandConverter/math/WorldSet.h (revision 1985)
@@ -0,0 +1,87 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file WorldSet.h
10+ * @brief WorldSet class supports calculation of WORLD,
11+ * and keep data for WORLD; DIO, STAR and PLATINUM.
12+ * This code is thread safe with Qt Library.
13+ * @author HAL@shurabaP
14+ */
15+#ifndef WORLDSET_H
16+#define WORLDSET_H
17+
18+#include "SpecgramSet.h"
19+
20+namespace stand
21+{
22+namespace math
23+{
24+namespace world
25+{
26+
27+/// <summay>
28+/// WORLD による分析に必要なデータを確保します.
29+/// また, WORLD の API を使用した分析機能も提供します.
30+/// </summay>
31+class WorldSet : public SpecgramSet
32+{
33+public:
34+
35+ explicit WorldSet(const SpecgramSet::SpecgramSetting *s = & SPECGRAM_DEFAULT_SETTING);
36+ explicit WorldSet(int tLen, int fftl, const SpecgramSet::SpecgramSetting *s = & SPECGRAM_DEFAULT_SETTING);
37+ explicit WorldSet(const double *x, int xLen, const SpecgramSet::SpecgramSetting *s = & SPECGRAM_DEFAULT_SETTING);
38+
39+ ~WorldSet();
40+
41+ void compute(const double *x, int xLen, const SpecgramSet::SpecgramSetting *s = &SPECGRAM_DEFAULT_SETTING);
42+
43+
44+ double *spectrumAt(int i);
45+ double *spectrumAt(double t);
46+ double *residualAt(int i);
47+ double *residualAt(double t);
48+ double f0At(int i);
49+ double f0At(double t);
50+ double tAt(int i);
51+ double tAt(double t);
52+
53+ double **residual()
54+ {
55+ return _residual;
56+ }
57+
58+ double *f0()
59+ {
60+ return _f0;
61+ }
62+
63+ double *t()
64+ {
65+ return _t;
66+ }
67+
68+private:
69+ void _create(int tLen, int fftl);
70+ void _destroy();
71+ int _indexAtSec(double t)
72+ {
73+ /* 本来は配列 _t の値から算出するのが正しい. */
74+ int ret = t * 1000.0 / _setting.framePeriod;
75+ return ret;
76+ }
77+
78+ double **_residual;
79+ double *_t;
80+ double *_f0;
81+};
82+
83+}
84+}
85+}
86+
87+#endif // WORLDSET_H
--- vConnect/trunk/stand2.0/StandConverter/math/Star.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/Star.cpp (revision 1985)
@@ -1,3 +1,18 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file Star.cpp
10+ * @brief Specgram estimation method STAR
11+ * Original source codes are below.
12+ * http://www.aspl.is.ritsumei.ac.jp/morise/world/
13+ * This code is redistributed to support thread safety with Qt Library.
14+ * @author HAL@shurabaP
15+ */
116 #include "Star.h"
217 #include "World.h"
318 #include "Dio.h"
@@ -15,10 +30,24 @@
1530 #define max(a,b) (((a)<(b))?(b):(a))
1631 #endif
1732
33+namespace stand
34+{
35+namespace math
36+{
37+namespace world
38+{
39+namespace starsup
40+{
41+void starGeneralBody(const double *x, int xLen, int fs, double f0, double t, int fftl, double * sliceSTAR, FFTSet &forward);
42+}
43+}
44+}
45+}
46+
1847 using namespace stand::math;
1948 using namespace stand::math::world;
49+using namespace stand::math::world::starsup;
2050
21-static void starGeneralBody(const double *x, int xLen, int fs, double f0, double t, int fftl, double * sliceSTAR, FFTSet &forward);
2251
2352 int stand::math::world::FFTLengthForStar(int fs)
2453 {
@@ -46,7 +75,7 @@
4675 }
4776
4877
49-void starGeneralBody(const double *x, int xLen, int fs, double f0, double t, int fftl, double * sliceSTAR, FFTSet &forward)
78+void stand::math::world::starsup::starGeneralBody(const double *x, int xLen, int fs, double f0, double t, int fftl, double * sliceSTAR, FFTSet &forward)
5079 {
5180 int i,j;
5281
--- vConnect/trunk/stand2.0/StandConverter/math/MathSet.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/MathSet.h (revision 1985)
@@ -1,3 +1,14 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file MathSet.h
10+ * @author HAL@shurabaP
11+ */
112 #ifndef MATHSET_H
213 #define MATHSET_H
314
--- vConnect/trunk/stand2.0/StandConverter/math/Dio.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/Dio.cpp (revision 1985)
@@ -1,3 +1,18 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file Dio.cpp
10+ * @brief F0 estimation method DIO
11+ * Original source codes are below.
12+ * http://www.aspl.is.ritsumei.ac.jp/morise/world/
13+ * This code is redistributed to support thread safety with Qt Library.
14+ * @author HAL@shurabaP
15+ */
116 #include "Dio.h"
217 #include "FFTSet.h"
318 #include "World.h"
@@ -14,11 +29,16 @@
1429 #define max(a,b) (((a)<(b))?(b):(a))
1530 #endif
1631
17-using namespace stand::math;
18-using namespace stand::math::world;
19-
2032 // These functions are only used for DIO.
2133 // You should not modify them.
34+namespace stand
35+{
36+namespace math
37+{
38+namespace world
39+{
40+namespace diosup
41+{
2242 static void rawEventByDio(double boundaryF0, double fs, fftw_complex *xSpec, int xLength, int fftl, double shiftTime, double f0Floor, double f0Ceil, double *timeAxis, int tLen,
2343 double *f0Deviations, double *interpolatedF0);
2444 static void zeroCrossingEngine(double *x, int xLen, double fs,
@@ -25,19 +45,24 @@
2545 double *eLocations, double *iLocations, double *intervals, int *iLen);
2646 static long decimateForF0(double *x, int xLen, double *y, int r);
2747 static void filterForDecimate(double *x, int xLen, double *y, int r);
28-static void nuttallWindow(int yLen, double *y);
2948 static void postprocessing(double framePeriod, double f0Floor, int candidates, int xLen, int fs,
3049 double **f0Map, double *bestF0, double *f0);
50+static int checkEvent(int x);
51+}
52+}
53+}
54+}
3155
32-void stand::math::world::dio(const double *x, int xLen, int fs, double framePeriod, double *timeAxis, double *f0)
56+using namespace stand::math;
57+using namespace stand::math::world;
58+using namespace stand::math::world::diosup;
59+
60+void stand::math::world::dio(const double *x, int xLen, int fs, double framePeriod, double *timeAxis, double *f0,
61+ double f0Ceil, double f0Floor, double channelsInOctave, double targetFs)
3362 {
3463 int i,j;
3564
36- // 初期条件 (改良したい人はここから頑張って)
37- double f0Floor = DIO_FLOOR_F0;
38- double f0Ceil = DIO_CEIL_F0;
39- double channelsInOctave = DIO_CHANNNELS;
40- double targetFs = DIO_TARGET_FS;
65+ // 初期条件はデフォルト引数へ引き取られました
4166
4267 // 基礎パラメタの計算
4368 int decimationRatio = (int)(fs/targetFs);
@@ -149,7 +174,7 @@
149174
150175 // イベント数があったか判定
151176 // longの範囲を超えてしまったので苦肉の策
152-int checkEvent(int x)
177+int stand::math::world::diosup::checkEvent(int x)
153178 {
154179 if(x > 0) return 1;
155180 return 0;
@@ -156,7 +181,7 @@
156181 }
157182
158183 // 後処理(4ステップ)
159-void postprocessing(double framePeriod, double f0Floor, int candidates, int xLen, int fs, double **f0Map, double *bestF0,
184+void stand::math::world::diosup::postprocessing(double framePeriod, double f0Floor, int candidates, int xLen, int fs, double **f0Map, double *bestF0,
160185 double *f0)
161186 {
162187 int i, j, k;
@@ -314,7 +339,7 @@
314339 }
315340
316341 // イベントを計算する内部関数 (内部変数なので引数・戻り値に手加減なし)
317-void rawEventByDio(double boundaryF0, double fs, fftw_complex *xSpec, int xLength, int fftl, double framePeriod, double f0Floor, double f0Ceil, double *timeAxis, int tLen,
342+void stand::math::world::diosup::rawEventByDio(double boundaryF0, double fs, fftw_complex *xSpec, int xLength, int fftl, double framePeriod, double f0Floor, double f0Ceil, double *timeAxis, int tLen,
318343 double *f0Deviations, double *interpolatedF0)
319344 {
320345 int i;
@@ -439,7 +464,7 @@
439464 }
440465
441466 // ゼロ交差を計算
442-void zeroCrossingEngine(double *x, int xLen, double fs,
467+void stand::math::world::diosup::zeroCrossingEngine(double *x, int xLen, double fs,
443468 double *eLocations, double *iLocations, double *intervals, int *iLen)
444469 {
445470 int i;
@@ -490,7 +515,7 @@
490515 }
491516
492517 // ナットール窓.マジックナンバーのように見えるけどこれが正解.
493-void nuttallWindow(int yLen, double *y)
518+void stand::math::nuttallWindow(int yLen, double *y)
494519 {
495520 int i;
496521 double tmp;
--- vConnect/trunk/stand2.0/StandConverter/math/SmootMatching.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/SmootMatching.cpp (revision 1985)
@@ -1,3 +1,15 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file SmoothMatching.cpp
10+ * @brief Functions that calculates matching between two arrays.
11+ * @author HAL@shurabaP
12+ */
113 #include "SmootMatching.h"
214
315 #include "MathSet.h"
@@ -7,8 +19,12 @@
719 #include <math.h>
820 #include <float.h>
921
10-using namespace stand::math;
11-
22+namespace stand
23+{
24+namespace math
25+{
26+namespace matching
27+{
1228 //! @brief 一回微分と二階微分を計算します.
1329 static void get_graduation(double* src, double* dst, int length,
1430 double *d1s, double *d2s, double *d1d, double *d2d);
@@ -19,12 +35,18 @@
1935 //! @brief 写像関数を DP で求める際の枝の重みを計算します.
2036 static double get_cost( double* src, double* dst, int i, int j, int n, int m,
2137 double *d1d, double *d2d, double *d1s, double *d2s);
22-
2338 /* 許容する傾きの最大値 */
2439 const double GRAD = 2.0;
2540 /* 変形関数の傾きに対する重み */
2641 const double G_WEIGHT = 1.5;
42+}
43+}
44+}
2745
46+using namespace stand::math;
47+using namespace stand::math::matching;
48+
49+
2850 void stand::math::applyStretching( double *T, double *target, int length )
2951 {
3052 int i;
@@ -35,7 +57,7 @@
3557 free(tmp);
3658 }
3759
38-void get_graduation( double* src, double* dst, int length,
60+void stand::math::matching::get_graduation( double* src, double* dst, int length,
3961 double *d1s, double *d2s, double *d1d, double *d2d)
4062 {
4163 /* 導関数の数値を計算 */
@@ -69,7 +91,7 @@
6991 free(temp_spectrum);
7092 }
7193
72-void log_normalize_infinite( double* dst, int length )
94+void stand::math::matching::log_normalize_infinite( double* dst, int length )
7395 {
7496 /* 正規化の結果は0~1の範囲になる. */
7597 int i;
@@ -84,7 +106,7 @@
84106 dst[i] = log( dst[i] / min_v ) / log( max_v );
85107 }
86108
87-double get_cost( double* src, double* dst, int i, int j, int n, int m,
109+double stand::math::matching::get_cost( double* src, double* dst, int i, int j, int n, int m,
88110 double *d1d, double *d2d, double *d1s, double *d2s)
89111 {
90112 int k;
--- vConnect/trunk/stand2.0/StandConverter/math/SpecgramSet.cpp (nonexistent)
+++ vConnect/trunk/stand2.0/StandConverter/math/SpecgramSet.cpp (revision 1985)
@@ -0,0 +1,146 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file SpecgramSet.cpp
10+ * @brief SpecgramSet class supports specgram calculation,
11+ * and keep data for specgram.
12+ * This code is thread safe with Qt Library.
13+ * @author HAL@shurabaP
14+ */
15+#include "SpecgramSet.h"
16+
17+#include "World.h"
18+#include "FFTSet.h"
19+
20+#include <math.h>
21+
22+using namespace stand::math;
23+
24+const SpecgramSet::SpecgramSetting SpecgramSet::SPECGRAM_DEFAULT_SETTING =
25+{
26+ 44100,
27+ 2.0
28+};
29+
30+SpecgramSet::SpecgramSet(const SpecgramSetting *s)
31+{
32+ if(!s)
33+ {
34+ s = &SPECGRAM_DEFAULT_SETTING;
35+ }
36+ _setting = *s;
37+ _specgram = NULL;
38+ _fftl = _tLen = 0;
39+}
40+
41+SpecgramSet::SpecgramSet(int tLen, int fftl, const SpecgramSetting *s)
42+{
43+ if(!s)
44+ {
45+ s = &SPECGRAM_DEFAULT_SETTING;
46+ }
47+ _setting = *s;
48+ _specgram = NULL;
49+ _createSpecgram(tLen , fftl);
50+}
51+
52+SpecgramSet::~SpecgramSet()
53+{
54+ _destroySpecgram();
55+}
56+
57+void SpecgramSet::_destroySpecgram()
58+{
59+ if(_specgram)
60+ {
61+ delete[] _specgram[0];
62+ }
63+ delete[] _specgram;
64+ _specgram = NULL;
65+ _tLen = _fftl = 0;
66+}
67+
68+void SpecgramSet::_createSpecgram(int tLen, int fftl)
69+{
70+ if(tLen <= 0 || fftl <= 0)
71+ {
72+ return;
73+ }
74+ _destroySpecgram();
75+ _specgram = new double*[tLen];
76+ _specgram[0] = new double[tLen * fftl];
77+ for(int i = 1; i < tLen; i++)
78+ {
79+ _specgram[i] = _specgram[0] + i * fftl;
80+ }
81+ _tLen = tLen;
82+ _fftl = fftl;
83+}
84+
85+void SpecgramSet::compute(const double *x, int xLen, const SpecgramSetting *s)
86+{
87+ if(!x || xLen <= 0)
88+ {
89+ return;
90+ }
91+ if(s)
92+ {
93+ _setting = *s;
94+ }
95+ int tLen = (double)xLen / (double)s->fs * 1000.0 / s->framePeriod + 1;
96+ _destroySpecgram();
97+ _createSpecgram(tLen, 2048);
98+
99+ FFTSet forward(2048, FFTSet::FFTW_R2C);
100+ double *in = (double *)forward.in();
101+ fftw_complex *out = (fftw_complex *)forward.out();
102+
103+ for(int i = 0; i < tLen; i++)
104+ {
105+ int begin = i * s->framePeriod / 1000.0 * (double)s->fs - _fftl / 2;
106+ // 時刻 t の前後 1024 点ずつを取り出す
107+ for(int j = begin, k = 0; k < _fftl; j++, k++)
108+ {
109+ if(0 <= j && j < xLen)
110+ {
111+ in[k] = x[j];
112+ }
113+ else
114+ {
115+ in[k] = 0;
116+ }
117+ }
118+ // 窓掛ける
119+ for(int j = 0; j < _fftl; j++)
120+ {
121+ double theta = stand::math::PI * (double)j / (double)_fftl;
122+ in[j] *= sin(theta);
123+ }
124+ // FFT する
125+ forward.execute();
126+ // パワー計算する
127+ for(int j = 0; j <= _fftl / 2; j++)
128+ {
129+ _specgram[i][j] = out[j][0] * out[j][0] + out[j][1] * out[j][1];
130+ }
131+ }
132+}
133+
134+double *SpecgramSet::spectrumAt(int i)
135+{
136+ if(i < 0)
137+ {
138+ i = 0;
139+ }
140+ else if(i >= _tLen)
141+ {
142+ i = _tLen - 1;
143+ }
144+ return _specgram[i];
145+}
146+
--- vConnect/trunk/stand2.0/StandConverter/math/Star.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/Star.h (revision 1985)
@@ -1,3 +1,18 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file Star.h
10+ * @brief Specgram estimation method STAR
11+ * Original source codes are below.
12+ * http://www.aspl.is.ritsumei.ac.jp/morise/world/
13+ * This code is redistributed to support thread safety with Qt Library.
14+ * @author HAL@shurabaP
15+ */
116 #ifndef STAR_H
217 #define STAR_H
318
--- vConnect/trunk/stand2.0/StandConverter/math/MinimumPhaseSpectrum.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/MinimumPhaseSpectrum.cpp (revision 1985)
@@ -1,3 +1,18 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file MinimumPhaseSpectrum.cpp
10+ * @brief Functions that calculates minimum phase spectrum.
11+ * Original source codes are below.
12+ * http://www.aspl.is.ritsumei.ac.jp/morise/world/
13+ * This code is redistributed to support thread safety with Qt Library.
14+ * @author HAL@shurabaP
15+ */
116 #include "MinimumPhaseSpectrum.h"
217 #include "FFTSet.h"
318
--- vConnect/trunk/stand2.0/StandConverter/math/Dio.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/Dio.h (revision 1985)
@@ -1,3 +1,18 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file Dio.h
10+ * @brief F0 estimation method DIO
11+ * Original source codes are below.
12+ * http://www.aspl.is.ritsumei.ac.jp/morise/world/
13+ * This code is redistributed to support thread safety with Qt Library.
14+ * @author HAL@shurabaP
15+ */
116 #ifndef DIO_H
217 #define DIO_H
318
@@ -5,27 +20,41 @@
520 {
621 namespace math
722 {
23+/*!
24+ * @brief ナットール窓
25+ * @param[in] yLen 信号長
26+ * @param[out] y ナットール窓を適用する信号列
27+ */
28+void nuttallWindow(int yLen, double *y);
29+
830 namespace world
931 {
10-/// <summary> F0 estimation by DIO(Distributed Inline filter Operation) </summary>
11-/// <param name = "x"> Input signal. </input>
12-/// <param name = "xLen"> Length of Input [sample]. </param>
13-/// <param name = "f0"> F0 Estimated by DIO. </param>
14-/// <param name = "framePeriod"> Frame shift [msec] </param>
15-/// <param name = "timeAxis"> Time axis; e.g. f0[0] is the F0 estimated at timeAxis[0] sec. </param>
16-/// <param name = "fs"> Sampling frequency [Hz] </param>
17-void dio(const double *x, int xLen, int fs, double framePeriod, double *timeAxis, double *f0);
18-
19-/// <summary> Necessary samples for DIO estimation. </summary>
20-/// <param name = "fs"> Sampling frequency </param>
21-/// <param name = "xLen"> Signal length [samples] </param>
22-/// <param name = "framePeriod"> Frame shift [msec] </param>
23-int samplesForDio(int fs, int xLen, double framePeriod);
24-
2532 const double DIO_FLOOR_F0 = 80;
2633 const double DIO_CEIL_F0 = 640;
2734 const double DIO_CHANNNELS = 2;
2835 const double DIO_TARGET_FS = 4000;
36+
37+/*! @brief F0 estimation by DIO(Distributed Inline filter Operation)
38+ * @param[in] x Input signal.
39+ * @param[in] xLen Length of Input [sample].
40+ * @param[out] f0 F0 Estimated by DIO.
41+ * @param[in] framePeriod Frame shift [msec]
42+ * @param[out] timeAxis Time axis; e.g. f0[0] is the F0 estimated at timeAxis[0] sec.
43+ * @param[in] fs Sampling frequency [Hz]
44+ * @param[in] f0Ceil F0 high-limit
45+ * @param[in] f0Floor F0 low-limit
46+ * @param[in] channnelsInOctave
47+ * @param[in] targetFs Sampling frequency that DIO uses.
48+ */
49+void dio(const double *x, int xLen, int fs, double framePeriod, double *timeAxis, double *f0,
50+ double f0Ceil = DIO_CEIL_F0, double f0Floor = DIO_FLOOR_F0, double channelsInOctave = DIO_CHANNNELS, double targetFs = DIO_TARGET_FS);
51+
52+/*! @brief Necessary samples for DIO estimation.
53+ * @param[in] fs Sampling frequency
54+ * @param[in] xLen Signal length [samples]
55+ * @param[in] framePeriod Frame shift [msec]
56+ */
57+int samplesForDio(int fs, int xLen, double framePeriod);
2958 }
3059 }
3160 }
--- vConnect/trunk/stand2.0/StandConverter/math/SmootMatching.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/SmootMatching.h (revision 1985)
@@ -1,3 +1,15 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file SmoothMatching.h
10+ * @brief Functions that calculates matching between two arrays.
11+ * @author HAL@shurabaP
12+ */
113 #ifndef SMOOTMATCHING_H
214 #define SMOOTMATCHING_H
315
--- vConnect/trunk/stand2.0/StandConverter/math/SpecgramSet.h (nonexistent)
+++ vConnect/trunk/stand2.0/StandConverter/math/SpecgramSet.h (revision 1985)
@@ -0,0 +1,80 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file SpecgramSet.h
10+ * @brief SpecgramSet class supports specgram calculation,
11+ * and keep data for specgram.
12+ * This code is thread safe with Qt Library.
13+ * @author HAL@shurabaP
14+ */
15+#ifndef SPECGRAMSET_H
16+#define SPECGRAMSET_H
17+
18+namespace stand
19+{
20+namespace math
21+{
22+
23+class SpecgramSet
24+{
25+public:
26+ struct SpecgramSetting
27+ {
28+ int fs;
29+ double framePeriod;
30+ };
31+
32+ const static SpecgramSetting SPECGRAM_DEFAULT_SETTING;
33+
34+ explicit SpecgramSet(const SpecgramSetting *s = & SPECGRAM_DEFAULT_SETTING);
35+ explicit SpecgramSet(int tLen, int fftl, const SpecgramSetting *s = & SPECGRAM_DEFAULT_SETTING);
36+ virtual ~SpecgramSet();
37+
38+ virtual void compute(const double *x, int xLen, const SpecgramSetting *s = &SPECGRAM_DEFAULT_SETTING);
39+ double *spectrumAt(int i);
40+
41+ double **specgram()
42+ {
43+ return _specgram;
44+ }
45+ int tLen()
46+ {
47+ return _tLen;
48+ }
49+
50+ int fftl()
51+ {
52+ return _fftl;
53+ }
54+
55+ int samplingFrequency()
56+ {
57+ return _setting.fs;
58+ }
59+
60+ double framePeriod()
61+ {
62+ return _setting.framePeriod;
63+ }
64+
65+protected:
66+ void _createSpecgram(int tLen, int fftl);
67+ void _destroySpecgram();
68+
69+ SpecgramSet::SpecgramSetting _setting;
70+ double **_specgram;
71+ int _tLen;
72+ int _fftl;
73+
74+private:
75+};
76+
77+}
78+}
79+
80+#endif // SPECGRAMSET_H
--- vConnect/trunk/stand2.0/StandConverter/math/MinimumPhaseSpectrum.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/MinimumPhaseSpectrum.h (revision 1985)
@@ -1,3 +1,18 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file MinimumPhaseSpectrum.h
10+ * @brief Functions that calculates minimum phase spectrum.
11+ * Original source codes are below.
12+ * http://www.aspl.is.ritsumei.ac.jp/morise/world/
13+ * This code is redistributed to support thread safety with Qt Library.
14+ * @author HAL@shurabaP
15+ */
116 #ifndef MINIMUMPHASESPECTRUM_H
217 #define MINIMUMPHASESPECTRUM_H
318
--- vConnect/trunk/stand2.0/StandConverter/math/MFCCSet.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/MFCCSet.cpp (revision 1985)
@@ -1,3 +1,17 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file MFCCSet.cpp
10+ * @brief MFCCSet class supports calculation of MFCC,
11+ * and keeps data for MFCC.
12+ * This class is thread safe with Qt Library.
13+ * @author HAL@shurabaP
14+ */
115 #include "MFCCSet.h"
216
317 #include "MathSet.h"
--- vConnect/trunk/stand2.0/StandConverter/math/World.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/World.cpp (revision 1985)
@@ -1,3 +1,14 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file World.cpp
10+ * @author HAL@shurabaP
11+ */
112 #include "World.h"
213
314 #include <stdio.h>
@@ -4,184 +15,8 @@
415
516 using namespace stand::math::world;
617
7-const World::WorldSetting World::WORLD_DEFAULT_SETTING =
18+void stand::math::world::extractResidual(fftw_complex *dst, const double *src, int fftLength)
819 {
9- 44100,
10- 2.0
11-};
12-
13-World::World(const WorldSetting *s)
14-{
15- _specgram = _residual = NULL;
16- _f0 = _t = NULL;
17- if(!s)
18- {
19- s = &WORLD_DEFAULT_SETTING;
20- }
21- setting = *s;
22-}
23-
24-World::World(double *x, int xLen, const WorldSetting *s)
25-{
26- _specgram = _residual = NULL;
27- _f0 = _t = NULL;
28- if(!s)
29- {
30- s = &WORLD_DEFAULT_SETTING;
31- }
32- execute(x, xLen, s);
33-}
34-
35-World::World(int tLen, int fftl, const WorldSetting *s)
36-{
37- _specgram = _residual = NULL;
38- _f0 = _t = NULL;
39- if(!s)
40- {
41- s = &WORLD_DEFAULT_SETTING;
42- }
43- setting = *s;
44- _create(tLen, fftl);
45-}
46-
47-World::~World()
48-{
49- _destroy();
50-}
51-
52-void World::execute(double *x, int xLen, const WorldSetting *s)
53-{
54- if(!x)
55- {
56- return;
57- }
58- int tLen = samplesForDio(s->fs, xLen, s->framePeriod);
59- int fftl = FFTLengthForStar(s->fs);
60- _create(tLen, fftl);
61-
62- if(!s)
63- {
64- s = &WORLD_DEFAULT_SETTING;
65- }
66- setting = *s;
67-
68- dio(x, xLen, s->fs, s->framePeriod, _t, _f0);
69- star(x, xLen, s->fs, _t, _f0, _specgram);
70- platinum(x, xLen, s->fs, _t, _f0, _specgram, _residual);
71-}
72-
73-double *World::spectrumAt(double t)
74-{
75- return spectrumAt(_indexAtSec(t));
76-}
77-
78-double *World::spectrumAt(int i)
79-{
80- if(i < 0)
81- {
82- i = 0;
83- }
84- else if(i >= _tLen)
85- {
86- i = _tLen - 1;
87- }
88- return _specgram[i];
89-}
90-
91-double *World::residualAt(double t)
92-{
93- return residualAt(_indexAtSec(t));
94-}
95-
96-double *World::residualAt(int i)
97-{
98- if(i < 0)
99- {
100- i = 0;
101- }
102- else if(i >= _tLen)
103- {
104- i = _tLen - 1;
105- }
106- return _residual[i];
107-}
108-
109-double World::f0At(double t)
110-{
111- return f0At(_indexAtSec(t));
112-}
113-
114-double World::f0At(int i)
115-{
116- if(i < 0)
117- {
118- i = 0;
119- }
120- else if(i >= _tLen)
121- {
122- i = _tLen - 1;
123- }
124- return _f0[i];
125-}
126-
127-double World::tAt(double t)
128-{
129- return tAt(_indexAtSec(t));
130-}
131-
132-double World::tAt(int i)
133-{
134- if(i < 0)
135- {
136- i = 0;
137- }
138- else if(i >= _tLen)
139- {
140- i = _tLen - 1;
141- }
142- return _t[i];
143-}
144-
145-void World::_destroy()
146-{
147- if(_specgram)
148- {
149- delete[] _specgram[0];
150- }
151- delete[] _specgram;
152-
153- if(_residual)
154- {
155- delete[] _residual[0];
156- }
157- delete[] _residual;
158-
159- delete[] _f0;
160- delete[] _t;
161- _specgram = _residual = NULL;
162- _f0 = _t = NULL;
163-}
164-
165-void World::_create(int tLen, int fftl)
166-{
167- _destroy();
168- _f0 = new double[tLen];
169- _t = new double[tLen];
170- _specgram = new double*[tLen];
171- _specgram[0] = new double[tLen * fftl];
172- _residual = new double*[tLen];
173- _residual[0] = new double[tLen * fftl];
174- for(int i = 1; i < tLen; i++)
175- {
176- _specgram[i] = _specgram[0] + i * fftl;
177- _residual[i] = _residual[0] + i * fftl;
178- }
179- _tLen = tLen;
180- _fftl = fftl;
181-}
182-
183-void World::extractResidual(fftw_complex *dst, const double *src, int fftLength)
184-{
18520 dst[0][0] = src[0];
18621 dst[0][1] = 0.0;
18722 for(int i = 1; i < fftLength / 2; i++) {
--- vConnect/trunk/stand2.0/StandConverter/math/Platinum.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/Platinum.cpp (revision 1985)
@@ -1,3 +1,18 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file Platinum.cpp
10+ * @brief Excitation signal estimation method PLATINUM
11+ * Original source codes are below.
12+ * http://www.aspl.is.ritsumei.ac.jp/morise/world/
13+ * This code is redistributed to support thread safety with Qt Library.
14+ * @author HAL@shurabaP
15+ */
116 #include "Platinum.h"
217 #include "World.h"
318 #include "Dio.h"
@@ -19,6 +34,15 @@
1934 #define max(a,b) (((a)<(b))?(b):(a))
2035 #endif
2136
37+namespace stand
38+{
39+namespace math
40+{
41+namespace world
42+{
43+namespace platinumsup
44+{
45+
2246 static void getOneFrameResidualSpec(const double *x, int xLen, int fs, int positionIndex, double framePeriod, double f0, double *specgram, int fftl, double *pulseLocations, int pCount,
2347 double *residualSpec, FFTSet *forwardR2C, FFTSet *forward, FFTSet *inverse)
2448 {
@@ -150,6 +174,14 @@
150174 free(tmpWav);
151175 }
152176
177+}
178+}
179+}
180+}
181+
182+using namespace stand::math::world::platinumsup;
183+
184+
153185 // PLATINUM Version 0.0.4. 恐らくこの仕様で確定です.
154186 // Aperiodicity estimation by PLATINUM
155187 // x : Input signal
--- vConnect/trunk/stand2.0/StandConverter/math/MatlabFunctions.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/MatlabFunctions.cpp (revision 1985)
@@ -1,3 +1,18 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file MatlabFunctions.cpp
10+ * @brief Functions for matlab compatibility.
11+ * Original source codes are below.
12+ * http://www.aspl.is.ritsumei.ac.jp/morise/world/
13+ * This code is redistributed to support thread safety with Qt Library.
14+ * @author HAL@shurabaP
15+ */
116 #include "MatlabFunctions.h"
217 #include "FFTSet.h"
318 #include "World.h"
--- vConnect/trunk/stand2.0/StandConverter/math/MFCCSet.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/MFCCSet.h (revision 1985)
@@ -1,3 +1,17 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file MFCCSet.h
10+ * @brief MFCCSet class supports calculation of MFCC,
11+ * and keeps data for MFCC.
12+ * This class is thread safe with Qt Library.
13+ * @author HAL@shurabaP
14+ */
115 #ifndef MFCCSET_H
216 #define MFCCSET_H
317
--- vConnect/trunk/stand2.0/StandConverter/math/FFTSet.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/FFTSet.cpp (revision 1985)
@@ -1,3 +1,17 @@
1+/*!
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file FFTSet.cpp
10+ * @brief FFTSet class supports fft calculation
11+ * and keep data for FFT.
12+ * This code supports thread safety with Qt Library.
13+ * @author HAL@shurabaP
14+ */
115 #include "FFTSet.h"
216
317 using namespace stand::math;
--- vConnect/trunk/stand2.0/StandConverter/math/World.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/math/World.h (revision 1985)
@@ -1,6 +1,17 @@
11 /*!
2- * @file World.h
3- * @author HAL
2+ * Stand Library is free software; you can redistribute it and/or
3+ * modify it under the terms of the GNU GPL License
4+ *
5+ * Stand Library is distributed in the hope that it will be useful,
6+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8+ *
9+ * @file World.h
10+ * @brief Voice Analysis and Synthesis System WORLD.
11+ * Original source codes are below.
12+ * http://www.aspl.is.ritsumei.ac.jp/morise/world/
13+ * This code is redistributed to support thread safety with Qt Library.
14+ * @author HAL@shurabaP
415 */
516 #ifndef WORLD_H
617 #define WORLD_H
@@ -12,115 +23,27 @@
1223 #include "Platinum.h"
1324 #include "MinimumPhaseSpectrum.h"
1425 #include "WorldSynthesis.h"
26+#include "WorldSet.h"
1527
1628 namespace stand
1729 {
1830 namespace math
1931 {
32+const double PI = 3.1415926535897932384;
2033 namespace world
2134 {
22-const double PI = 3.1415926535897932384;
2335 const unsigned int MAX_FFT_LENGTH = 2048;
2436 const double FLOOR_F0 = 71.0;
2537 const double DEFAULT_F0 = 150.0;
2638 const double LOW_LIMIT = 65.0;
2739
28-/// <summay>
29-/// WORLD による分析に必要なデータを確保します.
30-/// また, WORLD の API を使用した分析機能も提供します.
31-/// </summay>
32-class World
33-{
34-public:
35- struct WorldSetting
36- {
37- int fs;
38- double framePeriod;
39- };
40- const static WorldSetting WORLD_DEFAULT_SETTING;
40+/// <summary>WORLDの非周期性指標をFFTWで使用する形へ展開します.</summary>
41+/// <param name="dst">FFTWの複素数配列.</param>
42+/// <param name="src">WORLD非周期性指標.</param>
43+/// <param name="fftLength">FFT長.</param>
44+void extractResidual(fftw_complex *dst, const double *src, int fftLength);
4145
42- explicit World(const WorldSetting *s = & WORLD_DEFAULT_SETTING);
43- explicit World(int tLen, int fftl, const WorldSetting *s = & WORLD_DEFAULT_SETTING);
44- explicit World(double *x, int xLen, const WorldSetting *s = & WORLD_DEFAULT_SETTING);
4546
46- ~World();
47-
48- void execute(double *x, int xLen, const WorldSetting *s = &WORLD_DEFAULT_SETTING);
49-
50- double *spectrumAt(int i);
51- double *spectrumAt(double t);
52- double *residualAt(int i);
53- double *residualAt(double t);
54- double f0At(int i);
55- double f0At(double t);
56- double tAt(int i);
57- double tAt(double t);
58-
59- double **specgram()
60- {
61- return _specgram;
62- }
63-
64- double **residual()
65- {
66- return _residual;
67- }
68-
69- double *f0()
70- {
71- return _f0;
72- }
73-
74- double *t()
75- {
76- return _t;
77- }
78-
79- int size()
80- {
81- return _tLen;
82- }
83-
84- int fftl()
85- {
86- return _fftl;
87- }
88-
89- int samplingFrequency()
90- {
91- return setting.fs;
92- }
93-
94- double framePeriod()
95- {
96- return setting.framePeriod;
97- }
98-
99- /// <summary>WORLDの非周期性指標をFFTWで使用する形へ展開します.</summary>
100- /// <param name="dst">FFTWの複素数配列.</param>
101- /// <param name="src">WORLD非周期性指標.</param>
102- /// <param name="fftLength">FFT長.</param>
103- static void extractResidual(fftw_complex *dst, const double *src, int fftLength);
104-
105-private:
106- void _create(int tLen, int fftl);
107- void _destroy();
108- int _indexAtSec(double t)
109- {
110- /* 本来は配列 _t の値から算出するのが正しい. */
111- int ret = t * 1000.0 / setting.framePeriod;
112- return ret;
113- }
114-
115- double **_specgram;
116- double **_residual;
117- double *_t;
118- double *_f0;
119- WorldSetting setting;
120- int _tLen;
121- int _fftl;
122-};
123-
12447 }
12548 }
12649 }
--- vConnect/trunk/stand2.0/StandConverter/synthesis/ConverterElement.cpp (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/ConverterElement.cpp (revision 1985)
@@ -132,7 +132,7 @@
132132 }
133133
134134 // 変数準備
135- stand::math::world::World::WorldSetting s;
135+ stand::math::SpecgramSet::SpecgramSetting s;
136136 s.framePeriod = setting.framePeriod;
137137 s.fs = wave.header()->samplesPerSecond;
138138
@@ -150,7 +150,9 @@
150150
151151 // 波形から 1 ファイルを計算.
152152 stand::io::StandFile stf;
153- stf.compute(x, xLen, s.fs, s.framePeriod, setting.cepstrumLength, -1, -1, setting.vorbisBitrate * 1024);
153+ stf.compute(x, xLen, s.fs, s.framePeriod,
154+ setting.cepstrumLength, -1, -1, setting.vorbisBitrate * 1024,
155+ setting.f0Ceil, setting.f0Floor);
154156
155157 delete[] x;
156158
--- vConnect/trunk/stand2.0/StandConverter/synthesis/ConverterSetting.h (revision 1984)
+++ vConnect/trunk/stand2.0/StandConverter/synthesis/ConverterSetting.h (revision 1985)
@@ -35,6 +35,9 @@
3535 float preUtterance;
3636 float phonemeLength;
3737
38+ double f0Ceil;
39+ double f0Floor;
40+
3841 double framePeriod;
3942
4043 unsigned int numThreads;
旧リポジトリブラウザで表示