• R/O
  • SSH
  • HTTPS

cadencii: コミット


コミットメタ情報

リビジョン1654 (tree)
日時2011-06-13 01:59:45
作者kbinani

ログメッセージ

[vConnect/trunk/stand2.0] 音源に無い音を合成しようとすると落ちるのを修正,処理時間の計算が正しくできない場合があるのを修正

変更サマリ

差分

--- vConnect/trunk/stand2.0/vcnctd/Server.cpp (revision 1653)
+++ vConnect/trunk/stand2.0/vcnctd/Server.cpp (revision 1654)
@@ -85,6 +85,9 @@
8585 // ポートの再利用をOKにする
8686 int on = 1;
8787 setsockopt( s[0], SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof( on ) );
88+ // SIGPIPEの発生を回避
89+ on = 1;
90+ setsockopt( s[0], SOL_SOCKET, SO_NOSIGPIPE, (char *)&on, sizeof( on ) );
8891
8992 // サーバーのアドレス情報
9093 struct sockaddr_in server_addr;
@@ -214,9 +217,11 @@
214217
215218 sendWave( s[i], wav );
216219 closeSocket( s[i] );
217-
220+
221+#if !defined( _DEBUG )
218222 remove( txt );
219223 remove( wav );
224+#endif
220225
221226 status[i] = 0;
222227 s[i] = 0;
--- vConnect/trunk/stand2.0/stand/vsqMetaText/vsqPhonemeDB.h (revision 1653)
+++ vConnect/trunk/stand2.0/stand/vsqMetaText/vsqPhonemeDB.h (revision 1654)
@@ -1,8 +1,8 @@
11 /*
2+ * vsqPhonemeDB.h
3+ * Copyright (C) 2010- HAL,
4+ * Copyright (C) 2011 kbinani.
25 *
3- * vsqHandle.cpp
4- * (c) HAL 2010-
5- *
66 * This files is a part of v.Connect.
77 * vsqPhonemeDB inherits utauVoiceDataBase class.
88 * This class reads UTAU oto.ini in vsq meta-text extention.
@@ -30,7 +30,7 @@
3030 }
3131
3232 ~vsqPhonemeDB(){
33- UtauDB::dbClear();
33+ //UtauDB::dbClear();
3434 /*for( unsigned int i = 0; i < voiceDBs.size(); i++ ){
3535 SAFE_DELETE( voiceDBs[i] );
3636 }
--- vConnect/trunk/stand2.0/stand/vsqMetaText/vsqFileEx.cpp (revision 1653)
+++ vConnect/trunk/stand2.0/stand/vsqMetaText/vsqFileEx.cpp (revision 1654)
@@ -325,6 +325,7 @@
325325 dumpEvents();
326326 dumpMapIDs();
327327 dumpMapHandles();
328+ cout << "vsqFileEx::readCore; size=" << size << endl;
328329 #endif
329330
330331 return (size > 0);
--- vConnect/trunk/stand2.0/stand/vsqMetaText/vsqFileEx.h (revision 1653)
+++ vConnect/trunk/stand2.0/stand/vsqMetaText/vsqFileEx.h (revision 1654)
@@ -1,7 +1,7 @@
11 /**
22 * vsqFileEx.h
33 * Copyright (C) 2009-2011 HAL,
4- * Copyright (C) 2011 kbinani
4+ * Copyright (C) 2011 kbinani.
55 */
66 #ifndef __vsqFileEx_h__
77 #define __vsqFileEx_h__
@@ -129,6 +129,9 @@
129129
130130 private:
131131
132+#if defined( _DEBUG )
133+public:
134+#endif
132135 /// <summary>
133136 /// eventsの中身をダンプします
134137 /// </summary>
@@ -155,7 +158,8 @@
155158 {
156159 string s;
157160 mb_conv( i->first, s );
158- cout << s << endl;
161+ vsqEventEx *item = i->second;
162+ cout << s << ":" << item->toString() << endl;
159163 }
160164 }
161165
--- vConnect/trunk/stand2.0/stand/vsqMetaText/vsqEventEx.h (revision 1653)
+++ vConnect/trunk/stand2.0/stand/vsqMetaText/vsqEventEx.h (revision 1654)
@@ -1,8 +1,8 @@
11 /*
2+ * vsqEventEx.h
3+ * Copyright (C) 2010- HAL,
4+ * Copyright (C) 2011 kbinani.
25 *
3- * vsqEventEx.h
4- * (c) HAL 2010-
5- *
66 * This files is a part of v.Connect.
77 * vsqEventEx contains vsq-event's properties
88 * and some UTAU properties such as preutterance and voice-overlap.
@@ -44,6 +44,15 @@
4444 }
4545 //void setParameter( string_t left, string_t right );
4646
47+ string toString()
48+ {
49+ char buff[1024];
50+ buff[0] = '\n';
51+ sprintf( buff, "%d", singerIndex );
52+ string str_buff = buff;
53+ return "{singerIndex=" + str_buff + "}";
54+ }
55+
4756 vsqHandle vibratoHandle;
4857 vsqHandle lyricHandle;
4958 vsqHandle iconHandle;
--- vConnect/trunk/stand2.0/stand/vConnect.cpp (revision 1653)
+++ vConnect/trunk/stand2.0/stand/vConnect.cpp (revision 1654)
@@ -167,12 +167,12 @@
167167 if( false == mVsq.read( input, options ) )
168168 {
169169 #ifdef _DEBUG
170- cout << " done, failed" << endl;
170+ cout << "vConnect::synthesize; calling vsq.readVsqFile...done, failed";
171171 #endif
172172 return false;
173173 }
174174 #ifdef _DEBUG
175- cout << " done, successed" << endl;
175+ cout << "vConnect::synthesize; calling vsq.readVsqFile...done, successed";
176176 #endif
177177
178178 // 空のときは空の wave を出力して終了
@@ -205,7 +205,12 @@
205205
206206 // 準備1.先行発音などパラメータの適用,及びコントロールカーブをフレーム時刻へ変換
207207 this->calculateVsqInfo();
208-
208+#if defined( _DEBUG )
209+ cout << "vConnect::synthesize; calling mVsq.dumpMapIDs..." << endl;
210+ mVsq.dumpMapIDs();
211+ cout << "vConnect::synthesize; calling mVsq.dumpMapIDs...done" << endl;
212+#endif
213+
209214 aperiodicityLength = fftLength = getFFTLengthForStar(fs);
210215
211216 // 準備2.合成に必要なローカル変数の初期化
@@ -245,7 +250,7 @@
245250 printf("begin synthesis..\n");
246251 clock_t cl = clock();
247252 synthesizeFromList(&arg);
248- printf("Done: elapsed time = %f[s] for %f[s]'s synthesis.\n", (double)(clock() - cl) / 1000.0, framePeriod * frameLength / 1000.0);
253+ printf("Done: elapsed time = %f[s] for %f[s]'s synthesis.\n", (double)(clock() - cl) / CLOCKS_PER_SEC, framePeriod * frameLength / 1000.0);
249254
250255 // ファイルに書き下す.
251256 waveFileEx waveFile;
@@ -265,31 +270,37 @@
265270 corpusManager::phoneme* vConnect::getPhoneme(string_t lyric, int singerIndex, vector<corpusManager *> *managers)
266271 {
267272 corpusManager::phoneme *ret = NULL;
268- if(singerIndex < managers->size())
273+ if( singerIndex < managers->size() )
269274 {
270- ret = (*managers)[singerIndex]->getPhoneme(lyric);
275+ ret = (*managers)[singerIndex]->getPhoneme( lyric );
271276 }
272277 return ret;
273278 }
274279
275-int getFirstItem(vsqEventEx **p1, vsqEventEx **p2,
276- corpusManager::phoneme **ph1,
277- corpusManager::phoneme **ph2,
278- vsqFileEx *vsq, vector<corpusManager *> &managers, int beginFrame)
280+int getFirstItem(
281+ vsqEventEx **p1,
282+ vsqEventEx **p2,
283+ corpusManager::phoneme **ph1,
284+ corpusManager::phoneme **ph2,
285+ vsqFileEx *vsq,
286+ vector<corpusManager *> &managers,
287+ int beginFrame )
279288 {
280289 int ret = vsq->events.eventList.size();
281- for(int i = 0; i < vsq->events.eventList.size(); i++)
290+ for( int i = 0; i < vsq->events.eventList.size(); i++ )
282291 {
283- if(vsq->events.eventList[i]->beginFrame <= beginFrame
284- && beginFrame < vsq->events.eventList[i]->endFrame)
292+ if( vsq->events.eventList[i]->beginFrame <= beginFrame &&
293+ beginFrame < vsq->events.eventList[i]->endFrame )
285294 {
286295 *p1 = vsq->events.eventList[i];
287296 *p2 = (i + 1 < vsq->events.eventList.size()) ? vsq->events.eventList[i+1] : NULL;
288297 ret = i;
289- if(*p1) {
298+ if( *p1 )
299+ {
290300 *ph1 = managers[(*p1)->singerIndex]->getPhoneme((*p1)->lyricHandle.getLyric());
291301 }
292- if(*p2) {
302+ if( *p2 )
303+ {
293304 *ph2 = managers[(*p2)->singerIndex]->getPhoneme((*p2)->lyricHandle.getLyric());
294305 }
295306 break;
@@ -298,18 +309,21 @@
298309 return ret;
299310 }
300311
301-int calculateMelCepstrum(float *dst, int fftLength, list<vConnectData *> &frames)
312+int calculateMelCepstrum( float *dst, int fftLength, list<vConnectData *> &frames )
302313 {
303314 int ret = 0;
304- memset(dst, 0, sizeof(float) * fftLength);
305- for(list<vConnectData *>::iterator i = frames.begin(); i != frames.end(); i++) {
315+ memset( dst, 0, sizeof( float ) * fftLength );
316+ list<vConnectData *>::iterator i;
317+ for( i = frames.begin(); i != frames.end(); i++ )
318+ {
306319 int length;
307320 float *data;
308- data = (*i)->phoneme->getMelCepstrum((*i)->index, &length);
309- for(int j = 0; j < length; j++) {
321+ data = (*i)->phoneme->getMelCepstrum( (*i)->index, &length );
322+ for( int j = 0; j < length; j++ )
323+ {
310324 dst[j] += (*i)->morphRatio * data[j];
311325 }
312- ret = max(ret, length);
326+ ret = max( ret, length );
313327 }
314328 return ret;
315329 }
@@ -342,7 +356,7 @@
342356
343357 __stnd_thread_start_retval __stnd_declspec synthesizeFromList( void *arg )
344358 {
345- vConnectArg *p = (vConnectArg*)arg;
359+ vConnectArg *p = (vConnectArg *)arg;
346360
347361 // 波形の復元時に FFTW を使う上で必要なメモリの確保.
348362 fftw_complex *spectrum = new fftw_complex[p->fftLength];
@@ -355,28 +369,37 @@
355369
356370 // この処理はスレッドセーフでない.
357371 #ifdef STND_MULTI_THREAD
358- if(hMutex) {
359- stnd_mutex_lock(hMutex);
372+ if( hMutex )
373+ {
374+ stnd_mutex_lock( hMutex );
360375 }
361376 #endif
362- fftw_plan forward = fftw_plan_dft_1d(p->fftLength, spectrum, cepstrum, FFTW_FORWARD, FFTW_ESTIMATE);
377+ fftw_plan forward = fftw_plan_dft_1d( p->fftLength, spectrum, cepstrum, FFTW_FORWARD, FFTW_ESTIMATE);
363378 fftw_plan forward_r2c = fftw_plan_dft_r2c_1d(p->fftLength, starSpec, residual, FFTW_ESTIMATE);
364379 fftw_plan inverse = fftw_plan_dft_1d(p->fftLength, cepstrum, spectrum, FFTW_BACKWARD, FFTW_ESTIMATE);
365380 fftw_plan inverse_c2r = fftw_plan_dft_c2r_1d(p->fftLength, spectrum, impulse, FFTW_ESTIMATE);
366381 #ifdef STND_MULTI_THREAD
367- if(hMutex) {
368- stnd_mutex_unlock(hMutex);
382+ if( hMutex )
383+ {
384+ stnd_mutex_unlock( hMutex );
369385 }
370386 #endif
371387
372388 // 検索用ハッシュ
373389 map_t<vConnectPhoneme *, OggVorbis_File *> vorbisMap;
374- for(int i = 0; i < p->phonemes->size(); i++) {
375- if(!(*(p->phonemes))[i]) { continue; }
390+ for( int i = 0; i < p->phonemes->size(); i++ )
391+ {
392+ if( !(*(p->phonemes))[i] )
393+ {
394+ continue;
395+ }
376396 OggVorbis_File *ovf = new OggVorbis_File;
377- if((*(p->phonemes))[i]->vorbisOpen(ovf)) {
378- vorbisMap.insert(make_pair((*(p->phonemes))[i], ovf));
379- } else {
397+ if( (*(p->phonemes))[i]->vorbisOpen( ovf ) )
398+ {
399+ vorbisMap.insert( make_pair( (*(p->phonemes))[i], ovf ) );
400+ }
401+ else
402+ {
380403 delete ovf;
381404 }
382405 }
@@ -386,7 +409,7 @@
386409 double currentTime = 0.0, T;
387410
388411 // 合成処理
389- while(currentFrame < p->endFrame)
412+ while( currentFrame < p->endFrame )
390413 {
391414 if(p->f0[currentFrame] < 0) {
392415 currentFrame++;
@@ -397,15 +420,42 @@
397420
398421 /* ToDo : MelCepstrum の合成結果を melCepstrum に書き込む.
399422 残差波形の合成結果を starSpec に書き込む. */
400- cepstrumLength = calculateMelCepstrum(melCepstrum, p->fftLength, (*(p->data))[currentFrame]->dataList);
401- calculateResidual(starSpec, p->fftLength, (*(p->data))[currentFrame]->dataList, vorbisMap);
423+ list<vConnectData *> *frames = &(*(p->data))[currentFrame]->dataList;
424+ if( NULL == frames )
425+ {
426+ currentFrame++;
427+ currentTime = (double)currentFrame * framePeriod / 1000.0;
428+ continue;
429+ }
430+ cepstrumLength =
431+ calculateMelCepstrum( melCepstrum,
432+ p->fftLength,
433+ *frames );
434+ calculateResidual( starSpec,
435+ p->fftLength,
436+ *frames,
437+ vorbisMap );
402438
403439 // starSpec -> residual DFT を実行する.
404440 fftw_execute(forward_r2c);
405441 // メルケプストラムをstraSpecに展開.
406- vConnectUtility::extractMelCepstrum(starSpec, p->fftLength, melCepstrum, cepstrumLength, spectrum, impulse, inverse_c2r ,fs);
442+ vConnectUtility::extractMelCepstrum(
443+ starSpec,
444+ p->fftLength,
445+ melCepstrum,
446+ cepstrumLength,
447+ spectrum,
448+ impulse,
449+ inverse_c2r,
450+ fs );
407451 // 合成パワースペクトルから最小位相応答を計算.
408- getMinimumPhaseSpectrum(starSpec, spectrum, cepstrum, p->fftLength, forward, inverse);
452+ getMinimumPhaseSpectrum(
453+ starSpec,
454+ spectrum,
455+ cepstrum,
456+ p->fftLength,
457+ forward,
458+ inverse );
409459
410460 // 励起信号スペクトルと周波数領域での掛け算.
411461 for(int k = 0; k <= p->fftLength / 2; k++)
@@ -419,7 +469,8 @@
419469 // 実波形に直す.
420470 fftw_execute(inverse_c2r);
421471 currentPosition = currentTime * fs;
422- for(int k = 0; k < p->fftLength / 2 && currentPosition < p->waveLength; k++, currentPosition++) {
472+ for( int k = 0; k < p->fftLength / 2 && currentPosition < p->waveLength; k++, currentPosition++ )
473+ {
423474 p->wave[currentPosition] += impulse[k] * p->dynamics[currentFrame];
424475 }
425476
@@ -429,8 +480,9 @@
429480 }
430481
431482 //================================================================================================= ↓後処理
432- for(map_t<vConnectPhoneme *, OggVorbis_File*>::iterator i = vorbisMap.begin(); i != vorbisMap.end(); i++) {
433- ov_clear(i->second);
483+ map_t<vConnectPhoneme *, OggVorbis_File*>::iterator i;
484+ for( i = vorbisMap.begin(); i != vorbisMap.end(); i++) {
485+ ov_clear( i->second );
434486 delete i->second;
435487 }
436488
@@ -443,17 +495,19 @@
443495
444496 // この処理はスレッドセーフでない.
445497 #ifdef STND_MULTI_THREAD
446- if(hMutex) {
447- stnd_mutex_lock(hMutex);
498+ if( hMutex )
499+ {
500+ stnd_mutex_lock( hMutex );
448501 }
449502 #endif
450- fftw_destroy_plan(forward);
451- fftw_destroy_plan(forward_r2c);
452- fftw_destroy_plan(inverse);
453- fftw_destroy_plan(inverse_c2r);
503+ fftw_destroy_plan( forward );
504+ fftw_destroy_plan( forward_r2c );
505+ fftw_destroy_plan( inverse );
506+ fftw_destroy_plan( inverse_c2r );
454507 #ifdef STND_MULTI_THREAD
455- if(hMutex) {
456- stnd_mutex_unlock(hMutex);
508+ if( hMutex )
509+ {
510+ stnd_mutex_unlock( hMutex );
457511 }
458512 #endif
459513
@@ -494,12 +548,14 @@
494548 // 自分を消して
495549 vector<vsqEventEx*>::iterator it = events->begin();
496550 int j = 0;
497- while( it != events->end() ){
551+ while( it != events->end() )
552+ {
498553 if( itemi == (*it) ) break;
499554 j++;
500555 it++;
501556 }
502- if( it != events->end() ){
557+ if( it != events->end() )
558+ {
503559 events->erase( it );
504560 SAFE_DELETE( itemi );
505561 }
@@ -506,7 +562,9 @@
506562
507563 // ( i 番目今消しちゃったから次に進んでるのと一緒だから )
508564 if( i >= events->size() )
565+ {
509566 break;
567+ }
510568 // 次の音符へ
511569 itemi = mVsq.events.eventList[i];
512570 }
旧リポジトリブラウザで表示