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

Waveform data capture

As mentioned earlier, the Android Visualizer class lets us define callbacks to capture audio data. This data comes in two formats: waveform and FFT. We'll add just the waveform data to the VisualizerBox class now.

First, define the variables that we'll use for the captured audio data, as follows:

    Visualizer visualizer;
    public static int captureSize;
    public static byte[] audioBytes;

Using the API, we can determine the minimum capture size available, and then use that as our capture sample size.

Then, initialize them in the constructor as follows. First, instantiate an Android Visualizer. Then set the capture size to use, and allocate our buffers:

 public VisualizerBox(final CardboardView cardboardView){ visualizer = new Visualizer(0); ...

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