Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**
     * Extract highest value out of pcm data unfortunately this:
     * http://stackoverflow.com/a/8766420 doesn't work.
     * 
     * @param pcmData
     *            the raw audio buffer
     * @return a sound level 0..Short.MAX_VALUE
     */
    public static double pcmToSoundLevel(short[] pcmData) {

        double max = 0;

        for (short s : pcmData) {
            max = Math.max(s, max);
        }

        return max;
    }
}