-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aab9dfd
commit 6415490
Showing
3 changed files
with
32 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
#include <jni.h> | ||
#include "react-native-pitchy.h" | ||
#include <vector> | ||
#include <cmath> | ||
#include <algorithm> | ||
#include <numeric> | ||
#include <limits> | ||
|
||
extern "C" | ||
JNIEXPORT jdouble JNICALL | ||
Java_com_pitchy_PitchyModule_nativeAutoCorrelate(JNIEnv *env, jclass type, jdoubleArray buf, jdouble sampleRate) { | ||
extern "C" JNIEXPORT jdouble JNICALL | ||
Java_com_pitchy_PitchyModule_nativeAutoCorrelate(JNIEnv *env, jobject /* this */, jdoubleArray buf, jdouble sampleRate) | ||
{ | ||
jsize len = env->GetArrayLength(buf); | ||
jdouble *bufArray = env->GetDoubleArrayElements(buf, 0); | ||
std::vector<double> bufVector(bufArray, bufArray + len); | ||
std::vector<double> vec(bufArray, bufArray + len); | ||
env->ReleaseDoubleArrayElements(buf, bufArray, 0); | ||
return pitchy::autoCorrelate(bufVector, sampleRate); | ||
return pitchy::autoCorrelate(vec, sampleRate); | ||
} | ||
|
||
extern "C" | ||
JNIEXPORT jdouble JNICALL | ||
Java_com_pitchy_PitchyModule_nativeCalculateVolume(JNIEnv *env, jclass type, jdoubleArray buf) { | ||
extern "C" JNIEXPORT jdouble JNICALL | ||
Java_com_pitchy_PitchyModule_nativeCalculateVolume(JNIEnv *env, jobject /* this */, jdoubleArray buf) | ||
{ | ||
jsize len = env->GetArrayLength(buf); | ||
jdouble *bufArray = env->GetDoubleArrayElements(buf, 0); | ||
std::vector<double> bufVector(bufArray, bufArray + len); | ||
std::vector<double> vec(bufArray, bufArray + len); | ||
env->ReleaseDoubleArrayElements(buf, bufArray, 0); | ||
return pitchy::calculateVolume(bufVector); | ||
return pitchy::calculateVolume(vec); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters