If you think the Android project voicesmith listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Voicesmith <http://voicesmith.jurihock.de/>
*//www.java2s.com
* Copyright (c) 2011-2014 Juergen Hock
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/package de.jurihock.voicesmith.threads;
import android.content.Context;
import de.jurihock.voicesmith.FrameType;
import de.jurihock.voicesmith.Preferences;
import de.jurihock.voicesmith.Utils;
import de.jurihock.voicesmith.dsp.processors.DetuneProcessor;
import de.jurihock.voicesmith.dsp.stft.StftPostprocessor;
import de.jurihock.voicesmith.dsp.stft.StftPreprocessor;
import de.jurihock.voicesmith.io.AudioDevice;
publicclass DetuneThread extends AudioThread
{
privatefinalfloat[] buffer;
private StftPreprocessor preprocessor = null;
private StftPostprocessor postprocessor = null;
public DetuneThread(Context context, AudioDevice input, AudioDevice output)
{
super(context, input, output);
Preferences preferences = new Preferences(context);
FrameType frameType = FrameType.Medium;
int frameSize = preferences.getFrameSize(
frameType, input.getSampleRate());
int hopSize = preferences.getHopSize(
frameType, input.getSampleRate());
buffer = newfloat[frameSize];
new Utils(context).log("Detune frame size is %s.", buffer.length);
preprocessor = new StftPreprocessor(input, frameSize, hopSize, true);
postprocessor = new StftPostprocessor(output, frameSize, hopSize, true);
}
@Override
publicvoid dispose()
{
super.dispose();
disposeProcessors();
}
privatevoid disposeProcessors()
{
if (preprocessor != null)
{
preprocessor.dispose();
preprocessor = null;
}
if (postprocessor != null)
{
postprocessor.dispose();
postprocessor = null;
}
}
@Override
protectedvoid doProcessing()
{
while (!Thread.interrupted())
{
preprocessor.processFrame(buffer);
DetuneProcessor.processFrame(buffer);
postprocessor.processFrame(buffer);
}
}
}