Exemplo n.º 1
0
// Change the volume.
void Java_org_vinuxproject_sonic_Sonic_setVolumeNative(
    JNIEnv *env,
    jobject thiz,
    jlong sonicID,
    jfloat newVolume)
{
    sonicStream stream = getInst(sonicID)->stream;
    LOGV("Set volume to %f", newVolume);
    sonicSetVolume(stream, newVolume);
}
Exemplo n.º 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);
}