public static FlacAudioSubFrame create(int type, int channelNumber, int wastedBits,
                                           FlacAudioFrame audioFrame, BitsReader data) throws IOException {
        // Sanity check
        if (type < 0 || type >= 64) {
            throw new IllegalArgumentException("Type must be a un-signed 6 bit number, found " + type);
        }

        // Create the right type
        FlacAudioSubFrame subFrame;
        if (SubFrameConstant.matchesType(type))
            subFrame = new SubFrameConstant(channelNumber, audioFrame, data);
        else if (SubFrameVerbatim.matchesType(type))
            subFrame =  new SubFrameVerbatim(channelNumber, audioFrame, data);
        else if (SubFrameFixed.matchesType(type))
            subFrame =  new SubFrameFixed(type, channelNumber, audioFrame, data);
        else if (SubFrameLPC.matchesType(type))
            subFrame =  new SubFrameLPC(type, channelNumber, audioFrame, data);
        else subFrame =  new SubFrameReserved(audioFrame);

        // Record details, and return
        subFrame.wastedBits = wastedBits;
        return subFrame;
    }