Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ap command #30

Merged
merged 8 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
minor fix
  • Loading branch information
takenori-y committed Feb 7, 2023
commit e543a6e9a64ab7437560c4d6dd92f860cbfab6e3
5 changes: 3 additions & 2 deletions src/analysis/aperiodicity_extraction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ AperiodicityExtraction::AperiodicityExtraction(
bool AperiodicityExtraction::Run(
const std::vector<double>& waveform, const std::vector<double>& f0,
std::vector<std::vector<double> >* aperiodicity) const {
if (NULL == aperiodicity_extraction_) {
if (NULL == aperiodicity_extraction_ ||
!aperiodicity_extraction_->IsValid()) {
return false;
}

Expand All @@ -64,7 +65,7 @@ bool AperiodicityExtraction::Run(
std::copy(f0.begin(),
f0.begin() + std::min(target_f0_length, given_f0_length),
length_fixed_f0.begin());
if (given_f0_length < target_f0_length) {
if (1 <= given_f0_length && given_f0_length < target_f0_length) {
std::fill(length_fixed_f0.begin() + given_f0_length, length_fixed_f0.end(),
f0.back());
}
Expand Down
7 changes: 5 additions & 2 deletions src/analysis/pitch_extraction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ PitchExtraction::PitchExtraction(int frame_shift, double sampling_rate,
bool PitchExtraction::Run(const std::vector<double>& waveform,
std::vector<double>* f0, std::vector<double>* epochs,
PitchExtractionInterface::Polarity* polarity) const {
return (NULL != pitch_extraction_ &&
pitch_extraction_->Get(waveform, f0, epochs, polarity));
if (NULL == pitch_extraction_ || !pitch_extraction_->IsValid()) {
return false;
}

return pitch_extraction_->Get(waveform, f0, epochs, polarity);
}

} // namespace sptk
2 changes: 1 addition & 1 deletion src/main/ap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ int main(int argc, char* argv[]) {
}
case 'p': {
if (!sptk::ConvertStringToInteger(optarg, &frame_shift) ||
frame_shift <= 0.0) {
frame_shift <= 0) {
std::ostringstream error_message;
error_message
<< "The argument for the -p option must be a positive integer";
Expand Down
2 changes: 1 addition & 1 deletion src/main/pitch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ int main(int argc, char* argv[]) {
}
case 'p': {
if (!sptk::ConvertStringToInteger(optarg, &frame_shift) ||
frame_shift <= 0.0) {
frame_shift <= 0) {
std::ostringstream error_message;
error_message
<< "The argument for the -p option must be a positive integer";
Expand Down