From: Keiichiro O. <ur...@us...> - 2016-10-12 07:44:50
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv32118 Modified Files: excitation_generation.h excitation_generation.cc excite.cc Log Message: add output func of sample level info in excitation generation Index: excitation_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excitation_generation.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** excitation_generation.h 12 Oct 2016 04:31:24 -0000 1.2 --- excitation_generation.h 12 Oct 2016 07:44:48 -0000 1.3 *************** *** 68,72 **** // ! bool Get(double *excitation); private: --- 68,73 ---- // ! bool Get(double *excitation, double *pulse, double *noise, ! double *pitch); private: Index: excite.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excite.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** excite.cc 12 Oct 2016 04:31:24 -0000 1.2 --- excite.cc 12 Oct 2016 07:44:48 -0000 1.3 *************** *** 191,235 **** // Run excitation generation. ! if (use_normal_distributed_random_value) { ! sptk::NormalDistributedRandomValueGeneration random_generation(seed); ! sptk::ExcitationGeneration excitation_generation( ! &input_source_interpolation_with_magic_number, &random_generation); ! if (!excitation_generation.IsValid()) { ! std::ostringstream error_message; ! error_message << "Failed to set the condition for excitation generation"; ! sptk::PrintErrorMessage("excite", error_message); ! return 1; ! } ! ! double excitation; ! while (excitation_generation.Get(&excitation)) { ! if (!sptk::WriteStream(excitation, &std::cout)) { ! std::ostringstream error_message; ! error_message << "Failed to write an excitation"; ! sptk::PrintErrorMessage("excite", error_message); ! return 1; ! } } - } else { - sptk::MSequenceGeneration random_generation; sptk::ExcitationGeneration excitation_generation( ! &input_source_interpolation_with_magic_number, &random_generation); if (!excitation_generation.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the condition for excitation generation"; sptk::PrintErrorMessage("excite", error_message); return 1; } double excitation; ! while (excitation_generation.Get(&excitation)) { if (!sptk::WriteStream(excitation, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an excitation"; sptk::PrintErrorMessage("excite", error_message); return 1; } } } return 0; --- 191,231 ---- // Run excitation generation. ! sptk::RandomGenerationInterface *random_generation(NULL); ! try { ! if (use_normal_distributed_random_value) { ! random_generation = ! new sptk::NormalDistributedRandomValueGeneration(seed); ! } else { ! random_generation = new sptk::MSequenceGeneration(); } sptk::ExcitationGeneration excitation_generation( ! &input_source_interpolation_with_magic_number, random_generation); ! if (!excitation_generation.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the condition for excitation generation"; sptk::PrintErrorMessage("excite", error_message); + delete random_generation; return 1; } double excitation; ! while (excitation_generation.Get(&excitation, NULL, NULL, NULL)) { if (!sptk::WriteStream(excitation, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an excitation"; sptk::PrintErrorMessage("excite", error_message); + delete random_generation; return 1; } } + } catch (std::exception *e) { + std::ostringstream error_message; + error_message << "Unknown exception"; + sptk::PrintErrorMessage("excite", error_message); + delete random_generation; + return 1; } + delete random_generation; return 0; Index: excitation_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excitation_generation.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** excitation_generation.cc 12 Oct 2016 04:31:24 -0000 1.2 --- excitation_generation.cc 12 Oct 2016 07:44:48 -0000 1.3 *************** *** 62,66 **** } ! bool ExcitationGeneration::Get(double *excitation) { if (!is_valid_) { return false; --- 62,67 ---- } ! bool ExcitationGeneration::Get(double *excitation, ! double *pulse, double *noise, double *pitch) { if (!is_valid_) { return false; *************** *** 77,85 **** } // If unvoiced point, return white noise. if (input_source_->GetMagicNumber() == pitch_in_current_point) { phase_ = 1.0; ! if (!random_generation_->Get(excitation)) { ! return false; } return true; --- 78,102 ---- } + // Get noise. + double noise_in_current_point; + if (!random_generation_->Get(&noise_in_current_point)) { + return false; + } + + if (pitch) { + *pitch = pitch_in_current_point; + } + if (noise) { + *noise = noise_in_current_point; + } + // If unvoiced point, return white noise. if (input_source_->GetMagicNumber() == pitch_in_current_point) { phase_ = 1.0; ! if (excitation) { ! *excitation = noise_in_current_point; ! } ! if (pulse) { ! *pulse = 0.0; } return true; *************** *** 87,95 **** // If voiced point, return pulse or zero. if (1.0 <= phase_) { - *excitation = std::sqrt(pitch_in_current_point); phase_ -= 1.0; } else { ! *excitation = 0.0; } --- 104,120 ---- // If voiced point, return pulse or zero. + double pulse_in_current_point; if (1.0 <= phase_) { phase_ -= 1.0; + pulse_in_current_point = std::sqrt(pitch_in_current_point); } else { ! pulse_in_current_point = 0.0; ! } ! ! if (excitation) { ! *excitation = pulse_in_current_point; ! } ! if (pulse) { ! *pulse = pulse_in_current_point; } |