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

Extended the API function vtlGetConstants() to return more values #15

Merged
merged 1 commit into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 12 additions & 6 deletions VocalTractLabApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ void vtlGetVersion(char *version)
// ****************************************************************************

int vtlGetConstants(int *audioSamplingRate, int *numTubeSections,
int *numVocalTractParams, int *numGlottisParams)
int *numVocalTractParams, int *numGlottisParams,
int *numAudioSamplesPerTractState, double *internalSamplingRate)
{
if (!vtlApiInitialized)
{
Expand All @@ -337,6 +338,9 @@ int vtlGetConstants(int *audioSamplingRate, int *numTubeSections,
*numTubeSections = Tube::NUM_PHARYNX_MOUTH_SECTIONS;
*numVocalTractParams = VocalTract::NUM_PARAMS;
*numGlottisParams = (int)glottis[selectedGlottis]->controlParam.size();
*numAudioSamplesPerTractState = Synthesizer::NUM_CHUNCK_SAMPLES;
*internalSamplingRate = (double)SAMPLING_RATE / (double)Synthesizer::NUM_CHUNCK_SAMPLES;


return 0;
}
Expand Down Expand Up @@ -1011,12 +1015,14 @@ int vtlApiTest(const char *speakerFileName, double *audio, int *numSamples)
vtlGetVersion(version);
printf("Compile date of the library: %s\n", version);

int audioSamplingRate = 0;
int numTubeSections = 0;
int numVocalTractParams = 0;
int numGlottisParams = 0;
int audioSamplingRate = -1;
int numTubeSections = -1;
int numVocalTractParams = -1;
int numGlottisParams = -1;
int numAudioSamplesPerTractState = -1;
double internalSamplingRate = -1.0;

vtlGetConstants(&audioSamplingRate, &numTubeSections, &numVocalTractParams, &numGlottisParams);
vtlGetConstants(&audioSamplingRate, &numTubeSections, &numVocalTractParams, &numGlottisParams, &numAudioSamplesPerTractState, &internalSamplingRate);

printf("Audio sampling rate = %d\n", audioSamplingRate);
printf("Num. of tube sections = %d\n", numTubeSections);
Expand Down
6 changes: 5 additions & 1 deletion VocalTractLabApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ extern "C"{ /* start extern "C" */
#define C_EXPORT
#endif // WIN32

//typedef enum { false, true } bool; // Important for compilation with cython

// ****************************************************************************
// The exported C-compatible functions.
// IMPORTANT:
Expand Down Expand Up @@ -97,14 +99,16 @@ C_EXPORT void vtlGetVersion(char *version);
// o The number of supraglottal tube sections.
// o The number of vocal tract model parameters.
// o The number of glottis model parameters.
// o The number of audio samples that correspond to a single tract state sample
// o The number of evaluated tract state samples per second (internal sampling rate).
//
// Function return value:
// 0: success.
// 1: The API has not been initialized.
// ****************************************************************************

C_EXPORT int vtlGetConstants(int *audioSamplingRate, int *numTubeSections,
int *numVocalTractParams, int *numGlottisParams);
int *numVocalTractParams, int *numGlottisParams, int *numAudioSamplesPerTractState, double *internalSamplingRate);


// ****************************************************************************
Expand Down