@SuppressWarnings("StatementWithEmptyBody")
    public static int readFileHeader(FileInputStream fpi) {
        DataInputStream inStrm = new DataInputStream(fpi);

        byte[] buf = new byte[4];
        try {
            inStrm.readFully(buf, 0, 4);
            String fType = new String(buf, 0, 4);
            if ("RIFF".equals(fType)) {
                byteOrder = ByteOrder.LITTLE_ENDIAN;
                if (readWavHeader(inStrm, fpi.getChannel())) {
                    return 1;
                }
            } else if ("FORM".equals(fType)) {
                byteOrder = ByteOrder.BIG_ENDIAN;
                if (readAiffHeader(inStrm, fpi.getChannel())) {
                    return 2;
                }
            } else if ("fLaC".equals(fType)) {
                /*				fpi.getChannel().position(0);
                 FLACDecoder flacDec = new FLACDecoder(inStrm);
                 StreamInfo strmInfo = flacDec.readStreamInfo();
                 srcSamplingRate = strmInfo.getSampleRate();
                 srcBPS = strmInfo.getBitsPerSample()/8;
                 srcChannels = strmInfo.getChannels();
                 length = strmInfo.getTotalSamples() * srcBPS * srcChannels;
                 fpi.getChannel().position(0);
                 return 3;*/
            }
        } catch (IOException e1) {
            System.err.println("Error reading file header");
        }
        System.err.println("Error: Unsupported file type.");
        return 0;
    }