// Set chord pitch mode on or off.  Default is off.
void Java_org_vinuxproject_sonic_Sonic_setChordPitchNative(
    JNIEnv *env,
    jobject thiz,
    jlong sonicID,
    jboolean useChordPitch)
{
    sonicStream stream = getInst(sonicID)->stream;
    LOGV("Set chord pitch to %d", useChordPitch);
    sonicSetChordPitch(stream, useChordPitch);
}
Exemple #2
0
/* Run sonic. */
static void runSonic(
    waveFile inFile,
    waveFile outFile,
    float speed,
    float pitch,
    float rate,
    float volume,
    int emulateChordPitch,
    int quality,
    int sampleRate,
    int numChannels)
{
    sonicStream stream = sonicCreateStream(sampleRate, numChannels);
    short inBuffer[BUFFER_SIZE], outBuffer[BUFFER_SIZE];
    int samplesRead, samplesWritten;

    sonicSetSpeed(stream, speed);
    sonicSetPitch(stream, pitch);
    sonicSetRate(stream, rate);
    sonicSetVolume(stream, volume);
    sonicSetChordPitch(stream, emulateChordPitch);
    sonicSetQuality(stream, quality);
    do {
        samplesRead = readFromWaveFile(inFile, inBuffer, BUFFER_SIZE/numChannels);
        if(samplesRead == 0) {
            sonicFlushStream(stream);
        } else {
            sonicWriteShortToStream(stream, inBuffer, samplesRead);
        }
        do {
            samplesWritten = sonicReadShortFromStream(stream, outBuffer,
                BUFFER_SIZE/numChannels);
            if(samplesWritten > 0) {
                writeToWaveFile(outFile, outBuffer, samplesWritten);
            }
        } while(samplesWritten > 0);
    } while(samplesRead > 0);
    sonicDestroyStream(stream);
}