package org.farng.mp3.id3; import java.io.IOException; import java.io.RandomAccessFile; import org.farng.mp3.InvalidTagException; import org.farng.mp3.object.AbstractMP3Object; import org.farng.mp3.object.ObjectGroupRepeated; import org.farng.mp3.object.ObjectNumberFixedLength; import org.farng.mp3.object.ObjectNumberHashMap; import org.farng.mp3.object.ObjectStringNullTerminated; /** * <h3>4.12.   Equalisation (2)</h3> * <p/> * <p>   This is another subjective, alignment frame. It allows the user to<br> * <p/> *    predefine an equalisation curve within the audio file. There may be<br>    more than one * "EQU2" frame in each tag, but only one with the same<br>    identification string.</p> * <p/> * <p>     <Header of 'Equalisation (2)', ID: "EQU2"><br> * <p/> *      Interpolation method  $xx<br>      * Identification        <text string> $00</p> * <p/> * <p>   The 'interpolation method' describes which method is preferred when<br> * <p/> *    an interpolation between the adjustment point that follows. The<br>    following methods are * currently defined:</p> * <p/> * <p>     $00  Band<br>           No * interpolation is made. A jump from one adjustment level to<br> * <p/> *           another occurs in the middle between two adjustment * points.<br>      $01  Linear<br>           * Interpolation between adjustment points is linear.</p> * <p/> * <p>   The 'identification' string is used to identify the situation and/or<br> * <p/> *    device where this adjustment should apply. The following is then<br>    repeated for every * adjustment point</p> * <p/> * <p>     Frequency          $xx xx<br> *      Volume adjustment  $xx xx</p> * <p/> * <p>   The frequency is stored in units of 1/2 Hz, giving it a range from 0<br>    to 32767 * Hz.</p> * <p/> * <p>   The volume adjustment is encoded as a fixed point decibel value, 16<br>    bit signed * integer representing (adjustment*512), giving +/- 64 dB<br>    with a precision of 0.001953125 dB. E.g. +2 * dB is stored as $04 00<br> * <p/> *    and -2 dB is $FC 00.</p> * <p/> * <p>   Adjustment points should be ordered by frequency and one frequency<br>    should only be * described once in the frame.<br> </p> * * @author Eric Farng * @version $Revision: 2374 $ */ public class FrameBodyEQU2 extends AbstractID3v2FrameBody { /** * Creates a new FrameBodyEQU2 object. */ public FrameBodyEQU2() { super(); } /** * Creates a new FrameBodyEQU2 object. */ public FrameBodyEQU2(final FrameBodyEQU2 body) { super(body); } /** * Creates a new FrameBodyEQU2 object. */ public FrameBodyEQU2(final byte interpolationMethod, final String owner, final short frequency, final short volumeAdjustment) { setObject("Interpolation Method", new Byte(interpolationMethod)); setObject("Owner", owner); this.addGroup(frequency, volumeAdjustment); } /** * Creates a new FrameBodyEQU2 object. */ public FrameBodyEQU2(final RandomAccessFile file) throws IOException, InvalidTagException { this.read(file); } public String getIdentifier() { return "EQU2" + ((char) 0) + getOwner(); } public String getOwner() { return (String) getObject("Owner"); } public void getOwner(final String description) { setObject("Owner", description); } public void addGroup(final short frequency, final short volumeAdjustment) { final ObjectGroupRepeated group = (ObjectGroupRepeated) this.getObject("Data"); final AbstractMP3Object freq = new ObjectNumberFixedLength("Frequency", 2); final AbstractMP3Object volume = new ObjectNumberFixedLength("Volume Adjustment", 2); group.addObject(freq); group.addObject(volume); setObject("Data", group); } protected void setupObjectList() { appendToObjectList(new ObjectNumberHashMap("Interpolation Method", 1)); appendToObjectList(new ObjectStringNullTerminated("Owner")); final ObjectGroupRepeated group = new ObjectGroupRepeated("Data"); group.addProperty(new ObjectNumberFixedLength("Frequency", 2)); group.addProperty(new ObjectNumberFixedLength("Volume Adjustment", 2)); appendToObjectList(group); } }