/**
   * Reads a chunk and puts an Instrument property into the RepInfo object.
   *
   * @return <code>false</code> if the chunk is structurally invalid, otherwise <code>true</code>
   */
  public boolean readChunk(RepInfo info) throws IOException {
    AiffModule module = (AiffModule) _module;
    int baseNote = ModuleBase.readUnsignedByte(_dstream, module);
    int detune = ModuleBase.readSignedByte(_dstream, module);
    int lowNote = ModuleBase.readUnsignedByte(_dstream, module);
    int highNote = ModuleBase.readUnsignedByte(_dstream, module);
    int lowVelocity = ModuleBase.readUnsignedByte(_dstream, module);
    int highVelocity = ModuleBase.readUnsignedByte(_dstream, module);
    int gain = module.readSignedShort(_dstream);
    Loop sustainLoop = readLoop(module);
    Loop releaseLoop = readLoop(module);

    List propList = new ArrayList(9);
    propList.add(new Property("BaseNote", PropertyType.INTEGER, new Integer(baseNote)));
    propList.add(new Property("Detune", PropertyType.INTEGER, new Integer(detune)));
    propList.add(new Property("LowNote", PropertyType.INTEGER, new Integer(lowNote)));
    propList.add(new Property("HighNote", PropertyType.INTEGER, new Integer(highNote)));
    propList.add(new Property("LowVelocity", PropertyType.INTEGER, new Integer(lowVelocity)));
    propList.add(new Property("HighVelocity", PropertyType.INTEGER, new Integer(highVelocity)));
    propList.add(new Property("Gain", PropertyType.INTEGER, new Integer(gain)));
    propList.add(sustainLoop.loopProp("SustainLoop"));
    propList.add(releaseLoop.loopProp("ReleaseLoop"));
    module.addAiffProperty(
        new Property("Instrument", PropertyType.PROPERTY, PropertyArity.LIST, propList));
    return true;
  }
Exemplo n.º 2
0
  /** Initializes the state of the module for parsing. */
  protected void initParse() {
    super.initParse();
    _propList = new LinkedList();
    _notes = new LinkedList();
    _labels = new LinkedList();
    _labeledText = new LinkedList();
    _samples = new LinkedList();
    firstSampleOffsetMarked = false;
    numSamples = 0;

    _metadata = new Property("WAVEMetadata", PropertyType.PROPERTY, PropertyArity.LIST, _propList);
    _aesMetadata = new AESAudioMetadata();
    _aesMetadata.setByteOrder(AESAudioMetadata.LITTLE_ENDIAN);
    _aesMetadata.setAnalogDigitalFlag("FILE_DIGITAL");
    _aesMetadata.setFormat("WAVE");
    _aesMetadata.setUse("OTHER", "JHOVE_validation");
    _aesMetadata.setDirection("NONE");

    _propList.add(new Property("AESAudioMetadata", PropertyType.AESAUDIOMETADATA, _aesMetadata));

    // Most chunk types are allowed to occur only once,
    // and a few must occur exactly once.
    // Clear flags for whether they have been seen.
    formatChunkSeen = false;
    dataChunkSeen = false;
    instrumentChunkSeen = false;
    cartChunkSeen = false;
    mpegChunkSeen = false;
    broadcastExtChunkSeen = false;
    peakChunkSeen = false;
    linkChunkSeen = false;
    cueChunkSeen = false;

    // Initialize profile flags
    flagPCMWaveFormat = false;
    flagWaveFormatEx = false;
    flagWaveFormatExtensible = false;
    flagBroadcastWave = false;
  }
Exemplo n.º 3
0
  /**
   * Reads a chunk and puts a BroadcastAudioExtension Property into the RepInfo object.
   *
   * @return <code>false</code> if the chunk is structurally invalid, otherwise <code>true</code>
   */
  public boolean readChunk(RepInfo info) throws IOException {
    WaveModule module = (WaveModule) _module;
    byte[] buf256 = new byte[256];
    ModuleBase.readByteBuf(_dstream, buf256, module);
    String description = byteBufString(buf256);
    byte[] buf32 = new byte[32];
    ModuleBase.readByteBuf(_dstream, buf32, module);
    String originator = byteBufString(buf32);
    ModuleBase.readByteBuf(_dstream, buf32, module);
    String originatorRef = byteBufString(buf32);
    byte[] buf10 = new byte[10];
    ModuleBase.readByteBuf(_dstream, buf10, module);
    String originationDate = byteBufString(buf10);
    byte[] buf8 = new byte[8];
    ModuleBase.readByteBuf(_dstream, buf8, module);
    String originationTime = byteBufString(buf8);
    // TimeReference is stored as a 64-bit little-endian
    // number -- I think
    long timeReference = module.readSignedLong(_dstream);
    int version = module.readUnsignedShort(_dstream);
    module.setBroadcastVersion(version);
    byte[] smtpe_umid = new byte[64];
    ModuleBase.readByteBuf(_dstream, smtpe_umid, module);
    module.skipBytes(_dstream, 190, module);
    String codingHistory = "";
    if (bytesLeft > 602) {
      byte[] bufCodingHistory = new byte[(int) bytesLeft - 602];
      ModuleBase.readByteBuf(_dstream, bufCodingHistory, module);
      codingHistory = byteBufString(bufCodingHistory);
    }

    // Whew -- we've read the whole thing.  Now make that into a
    // list of Properties.
    List plist = new ArrayList(20);
    if (description.length() > 0) {
      plist.add(new Property("Description", PropertyType.STRING, description));
    }
    if (originator.length() > 0) {
      plist.add(new Property("Originator", PropertyType.STRING, originator));
    }
    if (originationDate.length() > 0) {
      plist.add(new Property("OriginationDate", PropertyType.STRING, originationDate));
    }
    if (originationTime.length() > 0) {
      plist.add(new Property("OriginationTime", PropertyType.STRING, originationTime));
    }
    plist.add(new Property("TimeReference", PropertyType.LONG, new Long(timeReference)));
    plist.add(new Property("Version", PropertyType.INTEGER, new Integer(version)));
    plist.add(new Property("UMID", PropertyType.BYTE, PropertyArity.ARRAY, smtpe_umid));
    if (codingHistory.length() > 0) {
      plist.add(new Property("CodingHistory", PropertyType.STRING, codingHistory));
    }

    module.addWaveProperty(
        new Property("BroadcastAudioExtension", PropertyType.PROPERTY, PropertyArity.LIST, plist));

    // set time reference in AES metadata set @author David Ackerman
    AESAudioMetadata aes = module.getAESMetadata();
    aes.setStartTime(timeReference);

    return true;
  }