O'Reilly logo

Cardboard VR Projects for Android by Matt Schoen, Jonathan Linowes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

FFT visualization

For the next visualization, we'll introduce the use of FFT data (instead of waveform data). As in the previous example, we'll dynamically generate a texture from the data and write a material and shaders to render it.

Capture the FFT audio data

To begin with, we need to add that data capture to our VisualizerBox class. We will start by adding the variables we'll need:

    public static byte[] fftBytes, fftNorm;
    public static float[] fftPrep;
    public static int fftTexture = -1;

We need to allocate the FFT data arrays, and to do that we need to know their size. We can ask the Android Visualizer API how much data it's capable of giving us. For now, we'll choose the minimum size and then allocate the arrays as follows:

 public VisualizerBox(final ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required