本文整理汇总了Java中ddf.minim.analysis.FFT类的典型用法代码示例。如果您正苦于以下问题:Java FFT类的具体用法?Java FFT怎么用?Java FFT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FFT类属于ddf.minim.analysis包,在下文中一共展示了FFT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import ddf.minim.analysis.FFT; //导入依赖的package包/类
public void setup() {
super.setup();
height3 = height/3;
height23 = 2*height/3;
minim = new Minim(this);
in = minim.getLineIn();
fftLin = new FFT(in.bufferSize(), in.sampleRate());
// calculate the averages by grouping frequency bands linearly. use 30 averages.
fftLin.linAverages( 32 );
// create an FFT object for calculating logarithmically spaced averages
fftLog = new FFT( in.bufferSize(), in.sampleRate() );
// calculate averages based on a miminum octave width of 22 Hz
// split each octave into three bands
// this should result in 30 averages
fftLog.logAverages( 200, 3 );
rectMode(CORNERS);
}
示例2: run
import ddf.minim.analysis.FFT; //导入依赖的package包/类
@Override
public void run() {
while (!Thread.interrupted()) {
FFT fft = Amperfi.playbackController.getPlayerAPI().getFFT();
AudioPlayer currentPlayer = Amperfi.playbackController.getPlayerAPI().getCurrentPlayer();
if (activeVisualizer != null && fft != null && currentPlayer != null && Amperfi.playbackController.getStatus() == PlayerAPI.PlayerStatus.PLAYING) {
fft.forward(currentPlayer.left);
Platform.runLater(() -> activeVisualizer.drawVisualizerFFT(fft));
}
try {
Thread.sleep(17);
} catch (InterruptedException e) {
return;
}
}
}
示例3: setup
import ddf.minim.analysis.FFT; //导入依赖的package包/类
public void setup() {
super.setup();
minim = new Minim(this);
in = minim.getLineIn();
fft = new FFT(in.bufferSize(), in.sampleRate());
spectrumDampened = new float[in.bufferSize()];
spectrumDb = new float[in.bufferSize()];
for(int i = 0; i < fft.specSize(); i++) {
spectrumDampened[i] = 0;
spectrumDb[i] = 0;
}
windowName = "Rectangular Window";
// a beat detection object song SOUND_ENERGY mode with a sensitivity of 10 milliseconds
beat = new BeatDetect();
beat.setSensitivity(300);
ellipseMode(RADIUS);
eRadius = 20;
// in.shiftGain(0, -60f, 5000);
}
示例4: AudioInputMinim
import ddf.minim.analysis.FFT; //导入依赖的package包/类
public AudioInputMinim() {
minim = new Minim( P.p );
audioInput = minim.getLineIn();
fft = new FFT(audioInput.bufferSize(), audioInput.sampleRate());
fft.linAverages( averages );
spectrumAvgDampened = new float[averages];
spectrumDampened = new float[audioInput.bufferSize()];
spectrum = new float[audioInput.bufferSize() / 2];
spectrumDb = new float[audioInput.bufferSize()];
for(int i = 0; i < fft.specSize(); i++) {
spectrumDampened[i] = 0;
if(i < spectrum.length) spectrum[i] = 0;
spectrumDb[i] = 0;
}
// a beat detection object song SOUND_ENERGY mode with a sensitivity of 300 milliseconds
beatDetection = new BeatDetect();
beatDetection.detectMode(BeatDetect.SOUND_ENERGY);
beatDetection.setSensitivity(300);
}
示例5: sampleRateChanged
import ddf.minim.analysis.FFT; //导入依赖的package包/类
protected void sampleRateChanged()
{
m_audioFFT = new FFT( m_windowSize, sampleRate() );
m_audioFFT.window( FFT.HAMMING );
m_modulatorFFT = new FFT( m_windowSize, sampleRate() );
m_modulatorFFT.window( FFT.HAMMING );
}
示例6: analyze
import ddf.minim.analysis.FFT; //导入依赖的package包/类
private void analyze(FFT fft, float[] src)
{
// copy the previous windowSize samples into our analysis window
for ( int i = m_index - m_windowSize, j = 0; i < m_index; ++i, ++j )
{
m_analysisSamples[j] = ( i < 0 ) ? src[src.length + i] : src[i];
}
fft.forward( m_analysisSamples );
}
示例7: startPlayback
import ddf.minim.analysis.FFT; //导入依赖的package包/类
private void startPlayback() {
setStatus(PlayerStatus.PLAYING);
currentPlayer = minim.loadFile(currentPlaylist.get(currentIndex).getPath());
currentPlayer.play();
currentPlayer.setGain(-80 * (1 - volume));
fft = new FFT(currentPlayer.bufferSize(), currentPlayer.sampleRate());
playbackUpdater = new Thread(new PlaybackUpdater(currentPlayer, this::afterPlayback, this));
playbackUpdater.setDaemon(true);
playbackUpdater.start();
}
示例8: PluginHandler
import ddf.minim.analysis.FFT; //导入依赖的package包/类
public PluginHandler( BeatDetect beat, FFT fft )
{
this.beat = beat;
this.fft = fft;
instantiateLEDs( Settings.NUM_LEDS );
}
示例9: init
import ddf.minim.analysis.FFT; //导入依赖的package包/类
public void init() {
_minim = new Minim( p );
_audioInput = _minim.getLineIn();
_fft = new FFT(_audioInput.bufferSize(), _audioInput.sampleRate());
_fft.linAverages( _averages );
spectrumAvgDampened = new float[_averages];
spectrumDampened = new float[_audioInput.bufferSize()];
spectrumDb = new float[_audioInput.bufferSize()];
for(int i = 0; i < _fft.specSize(); i++) {
spectrumDampened[i] = 0;
spectrumDb[i] = 0;
}
windowName = "Rectangular Window";
// a beat detection object song SOUND_ENERGY mode with a sensitivity of 300 milliseconds
_beatDetection = new BeatDetect();
// _beatDetection.detectMode(BeatDetect.FREQ_ENERGY);
_beatDetection.setSensitivity(300);
// TODO: move this into a sketch so audio and renderer are separate
// listen realtime if not rendering
// P.println("AudioInputWrapper._isRendering = "+_isRendering);
if( _isRendering == false ) {
// _myInput.start();
}
_gain = _audioInput.getGain();
setGain(_gain);
}
示例10: AudioPlayerMinim
import ddf.minim.analysis.FFT; //导入依赖的package包/类
public AudioPlayerMinim(Minim m, String audioFile) {
minim = m;
player = minim.loadFile(audioFile, 512);
player.loop();
fft = new FFT( player.bufferSize(), player.sampleRate() );
spectrum = new float[player.bufferSize() / 2];
beatDetection = new BeatDetect();
beatDetection.detectMode(BeatDetect.SOUND_ENERGY);
beatDetection.setSensitivity(300);
}
示例11: SoundControl
import ddf.minim.analysis.FFT; //导入依赖的package包/类
public SoundControl(String s) throws IOException
{
MinimObject minimObj = new MinimObject();
minim = new Minim(minimObj);
maxBass = Constants.MAX_PLAYER_SIZE;
frame = Constants.FRAME_TO_GENERATE_ENEMIES;
fftThreshold = Constants.FFT_THRESHOLD;
fftLeftThreshold = Constants.FFT_LEFT_THRESHOLD;
consecFramesGenned= 0;
song = minim.loadFile(s);
songLength = song.length();
songOver = false;
fadeEnter = false;
fft = new FFT(song.bufferSize(), song.sampleRate());
fft.linAverages(bands);
setFftLog(new FFT(song.bufferSize(), song.sampleRate()));
getFftLog().logAverages(22,12);
fftPrev = new float[bands];
fftDiff = new float[bands];
groupings = new int[120];
beats = new boolean[120];
beat = new BeatDetect(song.bufferSize(), song.sampleRate());
beat.setSensitivity(10);
bl = new BeatListener(beat, song);
}
示例12: uGenerate
import ddf.minim.analysis.FFT; //导入依赖的package包/类
protected void uGenerate(float[] out)
{
m_audioSamples[m_index] = audio.getLastValue();
m_modulatorSamples[m_index] = modulator.getLastValue();
++m_index;
--m_triggerCount;
if ( m_index == m_audioSamples.length )
{
m_index = 0;
}
// we reached the end of our window. analyze and synthesize!
if ( m_triggerCount == 0 )
{
analyze( m_audioFFT, m_audioSamples );
analyze( m_modulatorFFT, m_modulatorSamples );
for ( int i = 0; i < m_audioFFT.specSize(); ++i )
{
m_audioFFT.scaleBand( i, m_modulatorFFT.getBand( i ) );
}
// synthesize
m_audioFFT.inverse( m_analysisSamples );
// window
FFT.HAMMING.apply( m_analysisSamples );
// accumulate
for ( int a = 0; a < m_windowSize; ++a )
{
int outIndex = m_outputIndex + a;
if ( outIndex >= m_outputSamples.length )
{
outIndex -= m_outputSamples.length;
}
m_outputSamples[outIndex] += m_analysisSamples[a] * m_outputScale;
}
m_triggerCount = m_windowSpacing;
}
for ( int i = 0; i < out.length; ++i )
{
out[i] = m_outputSamples[m_outputIndex];
}
// eat it.
m_outputSamples[m_outputIndex] = 0.f;
// next!
++m_outputIndex;
if ( m_outputIndex == m_outputSamples.length )
{
m_outputIndex = 0;
}
}
示例13: getFFT
import ddf.minim.analysis.FFT; //导入依赖的package包/类
public FFT getFFT() {
return fft;
}
示例14: drawVisualizerFFT
import ddf.minim.analysis.FFT; //导入依赖的package包/类
@Override
public void drawVisualizerFFT(FFT fftData) {
long frameTime = System.currentTimeMillis() - lastExec;
lastExec = System.currentTimeMillis();
getGraphicsContext2D().clearRect(0, 0, this.getWidth(), this.getHeight());
// Calculation
double centerX = this.getWidth() / 2;
double centerY = this.getHeight() / 2;
double bass = 0;
for (int i = 0; i < fftData.specSize() / 5; i++) {
double a = fftData.getBand(i) / 4.7;
bass += Math.pow(a, 2);
}
double volume = 0;
for (int i = fftData.specSize() / 5; i < fftData.specSize(); i++) {
volume += fftData.getBand(i);
}
volume = volume / fftData.specSize();
volume = 0.95D / (1 + 10 * Math.exp(-1.25 * volume)) + 0.05;
bass = volume * (175 / (1 + 50 * Math.exp(-0.014 * bass)));
//bass = bass;
double r = Math.min(this.getWidth() / 3, this.getHeight() / 3) + 0.5 * bass;
// Particles
double newParticles = (1 + rand.nextInt(3)) * (bass * 0.005);
for (int i = 0; i < newParticles; i++) {
particles.add(new Particle(1, Math.random() * this.getHeight(), 1 + rand.nextInt(3), 1 + (Math.random()) * 3, (0.5 - Math.random()) * 2, Color.WHITE.deriveColor(0, 1, 1 - (Math.random() / 2), 1)));
}
if (newParticles < 1 && rand.nextInt(12) == 0) {
for (int i = 0; i < rand.nextInt(2); i++) {
particles.add(new Particle(1, Math.random() * this.getHeight(), 1 + rand.nextInt(3), 1 + (Math.random()) * 3, (0.5 - Math.random()) * 2, Color.WHITE.deriveColor(0, 1, 1 - (Math.random() / 2), 1)));
}
}
Iterator<Particle> itParticle = particles.iterator();
while (itParticle.hasNext()) {
Particle p = itParticle.next();
p.update(bass * 0.025);
if (!p.draw(this.getGraphicsContext2D())) {
itParticle.remove();
}
}
// Circle
double offsetX = (Math.random() - 0.5) * (bass * 0.5) * 0.6;
double offsetY = (Math.random() - 0.5) * (bass * 0.5) * 0.6;
centerX += offsetX;
centerY += offsetY;
motionBlur.setAngle(Math.atan2(offsetX, offsetY) * 180 / Math.PI);
motionBlur.setRadius(Math.max(10, 15 * (((Math.abs(offsetX) + Math.abs(offsetY)) / 2))));
this.getGraphicsContext2D().setEffect(motionBlur);
RadialGradient circle = new RadialGradient(90, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop(0, radialInner.deriveColor(1, bass * 0.01, bass * 0.01, 1)), new Stop(1, radialOuter));
this.getGraphicsContext2D().setFill(circle);
this.getGraphicsContext2D().fillOval(centerX - r, centerY - r, r * 2, r * 2);
this.getGraphicsContext2D().setEffect(null);
this.getGraphicsContext2D().setFill(Color.RED);
this.getGraphicsContext2D().fillText("FPS: " + (1000 / frameTime) + "\n" + "Particles: " + particles.size(), 0, 10);
}
示例15: FFTListener
import ddf.minim.analysis.FFT; //导入依赖的package包/类
public FFTListener( FFT fft, AudioInput source )
{
this.source = source;
this.source.addListener( this );
this.fft = fft;
}