0
0

I know there are a lot of topics about this subject, I have searched through them but could not solve my problem. GetSpectrum keeps returning 0’s. This is my stripped Java code using fmod4java classes.

[code:2r9wzbnc] private void initFMOD() {
try {
// Initialising FMOD
FMOD.init(44100, 32, 0);

    // Opening SoundStream using SW2D (changed it from HW2D, assured it would work then :( )
    activeSoundStream = SoundStream.open("everyday.mp3", Mode.SW2D, 0, 0);

    // Activating the DSP
    DspUnit.getFFTUnit().setActive(true);

    // Start playing
    activeChannel = activeSoundStream.playEx(Channel.FREE, DspUnit.getFFTUnit(), false);
    activeChannel.setVolume(255); // Just in case

    // Start timer
    dspTimer = new Timer(1000, this); // No need to rush it now
    dspTimer.start();

    updateFFT();
} catch (FMODException error) {
    System.out.println("FMODException: "+error);
}

}

public void updateFFT() {
Graphics g = w_oPanel.getGraphics();
g.setColor(Color.WHITE);

  // Getting Spectrum
  dspSpectrum = DspUnit.getSpectrum();

  // Adding all bands
  float bands = 0;
  for(int i=0;i<511;i++) {
      bands += dspSpectrum.getBand(i); // This doesn't make bands useful, but shows it contains 0.0 after adding all getBands together
  }
  g.drawString(""+bands, 150, 150); // Draws 0.0

}

public void actionPerformed(ActionEvent e) {
if (e.getSource() == dspTimer) {
updateFFT();
}
}[/code:2r9wzbnc]

  • You must to post comments
0
0

you have to use FMOD_SOFTWARE when creating sounds to get the spectrum, hardware acceleration doesnt give you this sort of info.

  • You must to post comments
0
0

[code:2e0ninew]activeSoundStream = SoundStream.open("everyday.mp3", Mode.SW2D, 0, 0);[/code:2e0ninew]
Isn’t SW2D what you mean by FMOD_SOFTWARE?

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.