Beispiel #1
0
  private void readGeneralInfo(BufferedInputStream in, Module module) throws IOException {
    // "Extended Module: "
    byte b[] = read(in, 17);

    if (!(new String(b)).equalsIgnoreCase("Extended Module: ")) {
      throw new IOException("This is not a xm file!");
    }

    // Module name
    b = read(in, 20);
    module.setTitle(new String(b));

    in.read();

    // Tracker name
    b = read(in, 20);

    // version
    in.read();
    in.read();

    // Header size
    read(in, 4);

    // Song length (in pattern order table)
    int[] patorder = new int[make16Bit(read(in, 2))];

    // Restart position
    module.setRestartPosition(make16Bit(read(in, 2)));

    // Number of channels (2,4,6,8,10,...,32)
    module.setChannelCount(make16Bit(read(in, 2)));

    // Number of patterns (max 128)
    module.setPatterns(new Pattern[make16Bit(read(in, 2))]);

    // Number of instruments (max 128)
    module.setInstruments(new Instrument[make16Bit(read(in, 2))]);

    // Flags: bit 0: 0 = Amiga frequency table;
    //               1 = Linear frequency table
    if ((make16Bit(read(in, 2)) & 0x1) == 0) module.setAmigaFreqTable(true);

    // Default tempo
    module.setTempo(make16Bit(read(in, 2)));

    // Default BPM
    module.setBpm(make16Bit(read(in, 2)));

    // Pattern order table
    b = read(in, 256);

    for (int i = 0; i < patorder.length; i++) {
      patorder[i] = b[i];
    }
    module.setPatternOrder(patorder);
  }
Beispiel #2
0
  /**
   * Load the file into memory
   *
   * @param is The InputStream to read the file from
   */
  public void load(BufferedInputStream in, Module module) throws IOException {
    readGeneralInfo(in, module);

    Pattern[] pattern = module.getPatterns();
    for (int i = 0; i < pattern.length; i++) {
      pattern[i] = new Pattern();
      readPattern(in, pattern[i]);
    }

    Instrument[] instrument = module.getInstruments();
    for (int i = 0; i < instrument.length; i++) {
      instrument[i] = new Instrument();
      readInstrument(in, instrument[i]);
    }
    in.close();
  }