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
Next Next commit
add ap
  • Loading branch information
takenori-y committed Jan 20, 2023
commit 490f1223b150eeb2beada25e4e71acbfdb5e8f3a
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,18 @@ set(CC_SOURCES
${THIRD_PARTY_DIR}/SWIPE/vector.cc
${THIRD_PARTY_DIR}/Snack/jkGetF0.cc
${THIRD_PARTY_DIR}/Snack/sigproc.cc
${THIRD_PARTY_DIR}/WORLD/aperiodicity.cc
${THIRD_PARTY_DIR}/WORLD/common.cc
${THIRD_PARTY_DIR}/WORLD/d4c.cc
${THIRD_PARTY_DIR}/WORLD/dio.cc
${THIRD_PARTY_DIR}/WORLD/fft_world.cc
${THIRD_PARTY_DIR}/WORLD/matlabfunctions.cc
${SOURCE_DIR}/analysis/adaptive_generalized_cepstral_analysis.cc
${SOURCE_DIR}/analysis/adaptive_mel_cepstral_analysis.cc
${SOURCE_DIR}/analysis/adaptive_mel_generalized_cepstral_analysis.cc
${SOURCE_DIR}/analysis/aperiodicity_extraction.cc
${SOURCE_DIR}/analysis/aperiodicity_extraction_by_tandem.cc
${SOURCE_DIR}/analysis/aperiodicity_extraction_by_world.cc
${SOURCE_DIR}/analysis/autocorrelation_analysis.cc
${SOURCE_DIR}/analysis/fast_fourier_transform_cepstral_analysis.cc
${SOURCE_DIR}/analysis/mel_cepstral_analysis.cc
Expand Down Expand Up @@ -213,6 +218,7 @@ set(MAIN_SOURCES
${SOURCE_DIR}/main/acr2csm.cc
${SOURCE_DIR}/main/aeq.cc
${SOURCE_DIR}/main/amgcep.cc
${SOURCE_DIR}/main/ap.cc
${SOURCE_DIR}/main/average.cc
${SOURCE_DIR}/main/b2mc.cc
${SOURCE_DIR}/main/bcp.cc
Expand Down
90 changes: 90 additions & 0 deletions include/SPTK/analysis/aperiodicity_extraction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// ------------------------------------------------------------------------ //
// Copyright 2021 SPTK Working Group //
// //
// Licensed under the Apache License, Version 2.0 (the "License"); //
// you may not use this file except in compliance with the License. //
// You may obtain a copy of the License at //
// //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
// Unless required by applicable law or agreed to in writing, software //
// distributed under the License is distributed on an "AS IS" BASIS, //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and //
// limitations under the License. //
// ------------------------------------------------------------------------ //

#ifndef SPTK_ANALYSIS_APERIODICITY_EXTRACTION_H_
#define SPTK_ANALYSIS_APERIODICITY_EXTRACTION_H_

#include <vector> // std::vector

#include "SPTK/analysis/aperiodicity_extraction_interface.h"
#include "SPTK/utils/sptk_utils.h"

namespace sptk {

/**
* Extract aperiodicity from waveform.
*
* The input is whole audio waveform and the output is the sequence of the
* aperiodicity measure. The implemented algorithms of the extraction are
* TANDEM-STRAIGHT and D4C.
*
* [1] H. Kawahara et al., &quot;Simplification and extension of non-periodic
* excitation source representations for high-quality speech manipulation
* systems,&quot; Proc. of Interspeech, pp. 38-41, 2010.
*
* [2] M. Morise, &quot;D4C, a band-aperiodicity estimator for high-quality
* speech synthesis,&quot; Proc. of Speech Communication, vol. 84,
* pp. 57-65, 2016.
*/
class AperiodicityExtraction {
public:
/**
* Aperiodicity extraction algorithm type.
*/
enum Algorithms { kTandem = 0, kWorld, kNumAlgorithms };

/**
* @param[in] fft_length FFT length.
* @param[in] frame_shift Frame shift in point.
* @param[in] sampling_rate Sampling rate in Hz.
* @param[in] algorithm Algorithm used for aperiodicity extraction.
*/
AperiodicityExtraction(int fft_length, int frame_shift, double sampling_rate,
Algorithms algorithm);

virtual ~AperiodicityExtraction() {
delete aperiodicity_extraction_;
}

/**
* @return True if this object is valid.
*/
bool IsValid() const {
return (NULL != aperiodicity_extraction_ &&
aperiodicity_extraction_->IsValid());
}

/**
* @param[in] waveform Waveform.
* @param[in] f0 Fundamental frequency in Hz.
* @param[out] aperiodicity Aperiodicity measure.
* @return True on success, false on failure.
*/
bool Run(const std::vector<double>& waveform, const std::vector<double>& f0,
std::vector<std::vector<double> >* aperiodicity) const {
return (NULL != aperiodicity_extraction_ &&
aperiodicity_extraction_->Run(waveform, f0, aperiodicity));
}

private:
AperiodicityExtractionInterface* aperiodicity_extraction_;

DISALLOW_COPY_AND_ASSIGN(AperiodicityExtraction);
};

} // namespace sptk

#endif // SPTK_ANALYSIS_APERIODICITY_EXTRACTION_H_
93 changes: 93 additions & 0 deletions include/SPTK/analysis/aperiodicity_extraction_by_tandem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// ------------------------------------------------------------------------ //
// Copyright 2021 SPTK Working Group //
// //
// Licensed under the Apache License, Version 2.0 (the "License"); //
// you may not use this file except in compliance with the License. //
// You may obtain a copy of the License at //
// //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
// Unless required by applicable law or agreed to in writing, software //
// distributed under the License is distributed on an "AS IS" BASIS, //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and //
// limitations under the License. //
// ------------------------------------------------------------------------ //

#ifndef SPTK_ANALYSIS_APERIODICITY_EXTRACTION_BY_TANDEM_H_
#define SPTK_ANALYSIS_APERIODICITY_EXTRACTION_BY_TANDEM_H_

#include <vector> // std::vector

#include "SPTK/analysis/aperiodicity_extraction_interface.h"
#include "SPTK/utils/sptk_utils.h"

namespace sptk {

/**
* Extract aperiodicity based on TANDEM-STRAIGHT.
*/
class AperiodicityExtractionByTandem : public AperiodicityExtractionInterface {
public:
/**
* @param[in] fft_length FFT length.
* @param[in] frame_shift Frame shift in point.
* @param[in] sampling_rate Sampling rate in Hz.
*/
AperiodicityExtractionByTandem(int fft_length, int frame_shift,
double sampling_rate);

virtual ~AperiodicityExtractionByTandem() {
}

/**
* @return FFT length.
*/
int GetFftLength() const {
return fft_length_;
}

/**
* @return Frame shift.
*/
int GetFrameShift() const {
return frame_shift_;
}

/**
* @return Sampling rate.
*/
double GetSamplingRate() const {
return sampling_rate_;
}

/**
* @return True if this object is valid.
*/
virtual bool IsValid() const {
return is_valid_;
}

/**
* @param[in] waveform Waveform.
* @param[in] f0 Fundamental frequency in Hz.
* @param[out] aperiodicity Aperiodicity measure.
* @return True on success, false on failure.
*/
virtual bool Run(const std::vector<double>& waveform,
const std::vector<double>& f0,
std::vector<std::vector<double> >* aperiodicity) const;

private:
const int fft_length_;
const int frame_shift_;
const double sampling_rate_;

bool is_valid_;

DISALLOW_COPY_AND_ASSIGN(AperiodicityExtractionByTandem);
};

} // namespace sptk

#endif // SPTK_ANALYSIS_APERIODICITY_EXTRACTION_BY_TANDEM_H_
93 changes: 93 additions & 0 deletions include/SPTK/analysis/aperiodicity_extraction_by_world.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// ------------------------------------------------------------------------ //
// Copyright 2021 SPTK Working Group //
// //
// Licensed under the Apache License, Version 2.0 (the "License"); //
// you may not use this file except in compliance with the License. //
// You may obtain a copy of the License at //
// //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
// Unless required by applicable law or agreed to in writing, software //
// distributed under the License is distributed on an "AS IS" BASIS, //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and //
// limitations under the License. //
// ------------------------------------------------------------------------ //

#ifndef SPTK_ANALYSIS_APERIODICITY_EXTRACTION_BY_WORLD_H_
#define SPTK_ANALYSIS_APERIODICITY_EXTRACTION_BY_WORLD_H_

#include <vector> // std::vector

#include "SPTK/analysis/aperiodicity_extraction_interface.h"
#include "SPTK/utils/sptk_utils.h"

namespace sptk {

/**
* Extract aperiodicity based on WORLD (D4C).
*/
class AperiodicityExtractionByWorld : public AperiodicityExtractionInterface {
public:
/**
* @param[in] fft_length FFT length.
* @param[in] frame_shift Frame shift in point.
* @param[in] sampling_rate Sampling rate in Hz.
*/
AperiodicityExtractionByWorld(int fft_length, int frame_shift,
double sampling_rate);

virtual ~AperiodicityExtractionByWorld() {
}

/**
* @return FFT length.
*/
int GetFftLength() const {
return fft_length_;
}

/**
* @return Frame shift.
*/
int GetFrameShift() const {
return frame_shift_;
}

/**
* @return Sampling rate.
*/
double GetSamplingRate() const {
return sampling_rate_;
}

/**
* @return True if this object is valid.
*/
virtual bool IsValid() const {
return is_valid_;
}

/**
* @param[in] waveform Waveform.
* @param[in] f0 Fundamental frequency in Hz.
* @param[out] aperiodicity Aperiodicity measure.
* @return True on success, false on failure.
*/
virtual bool Run(const std::vector<double>& waveform,
const std::vector<double>& f0,
std::vector<std::vector<double> >* aperiodicity) const;

private:
const int fft_length_;
const int frame_shift_;
const double sampling_rate_;

bool is_valid_;

DISALLOW_COPY_AND_ASSIGN(AperiodicityExtractionByWorld);
};

} // namespace sptk

#endif // SPTK_ANALYSIS_APERIODICITY_EXTRACTION_BY_WORLD_H_
50 changes: 50 additions & 0 deletions include/SPTK/analysis/aperiodicity_extraction_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// ------------------------------------------------------------------------ //
// Copyright 2021 SPTK Working Group //
// //
// Licensed under the Apache License, Version 2.0 (the "License"); //
// you may not use this file except in compliance with the License. //
// You may obtain a copy of the License at //
// //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
// Unless required by applicable law or agreed to in writing, software //
// distributed under the License is distributed on an "AS IS" BASIS, //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and //
// limitations under the License. //
// ------------------------------------------------------------------------ //

#ifndef SPTK_ANALYSIS_APERIODICITY_EXTRACTION_INTERFACE_H_
#define SPTK_ANALYSIS_APERIODICITY_EXTRACTION_INTERFACE_H_

#include <vector> // std::vector

namespace sptk {

/**
* An interface of aperiodicity extraction.
*/
class AperiodicityExtractionInterface {
public:
virtual ~AperiodicityExtractionInterface() {
}

/**
* @return True if this object is valid.
*/
virtual bool IsValid() const = 0;

/**
* @param[in] waveform Waveform.
* @param[in] f0 Fundamental frequency in Hz.
* @param[out] aperiodicity Aperiodicity measure.
* @return True on success, false on failure.
*/
virtual bool Run(const std::vector<double>& waveform,
const std::vector<double>& f0,
std::vector<std::vector<double> >* aperiodicity) const = 0;
};

} // namespace sptk

#endif // SPTK_ANALYSIS_APERIODICITY_EXTRACTION_INTERFACE_H_
4 changes: 2 additions & 2 deletions include/SPTK/analysis/pitch_extraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ namespace sptk {
*
* [4] M. Morise, H. Kawahara and H. Katayose, &quot;Fast and reliable F0
* estimation method based on the period extraction of vocal fold vibration
* of singing voice and speech, Proc. of AES 35th International Conference,
* 2009.
* of singing voice and speech,&quot; Proc. of AES 35th International
* Conference, 2009.
*/
class PitchExtraction {
public:
Expand Down
Loading