/** * 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; }
private Loop readLoop(AiffModule module) throws IOException { int playMode = module.readSignedShort(_dstream); int beginLoop = module.readUnsignedShort(_dstream); int endLoop = module.readUnsignedShort(_dstream); return new Loop(playMode, beginLoop, endLoop); }