Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.IOException;
import java.io.RandomAccessFile;

public class Main {
    public static short[] fromAudioFile(RandomAccessFile f) {
        short[] samples = null;

        try {
            samples = new short[(int) (f.length() / 2)];
            f.seek(0); //Seek to start point of file

            for (int i = 0; i < f.length() / 2; i++) {
                samples[i] = f.readShort();
            }
            f.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return samples;
    }
}