public class ID3v23FrameBodyRelativeVolumeAdjustment extends ID3v23FrameBody
A relative volume adjustment frame body is associated with an ID3v2.3 RVAD
frame
which is used to adjust the volume of .mp3 songs to a consistent level. Since some songs are recorded at higher levels than others, this frame could allow a user to set a desired volume and the .mp3
players would adjust the output volume of the .mp3 song to the level specified by the user.
The relative volume adjustment frame allows the user to specify both relative and peak volume settings for following 6 defined channels:
Once again, the monkey's who came up with the specification made this far more complex than it ever needed to be. Instead of just using 16 bits to specify a volume, they allowed implementers to choose the number of bits. This forces implementers to do a lot of bit manipulation and makes the code incredibly messy. In ID3v2.4, they fixed this and made the volume adjustments 16 bits. Additionally, according to the ID3 v2.3 specification, the bits used for volume adjustments field is normally 0x10 (16 bits) for MPEG 2 layer I, II and III and MPEG 2.5.. For these reasons, Beaglebuddy Software decided to only support 16 bit volumes.
The relative volume adjustment frame body contains the following fields:Field | Description | |
---|---|---|
1. | relative volume adjustment front right channel | amount to adjust the volume of the front right channel. |
2. | relative volume adjustment front left channel | amount to adjust the volume of the front left channel. |
3. | relative volume adjustment back right channel | amount to adjust the volume of the back right channel. |
4. | relative volume adjustment back left channel | amount to adjust the volume of the back left channel. |
5. | relative volume adjustment center channel | amount to adjust the volume of the center channel. |
6. | relative volume adjustment bass channel | amount to adjust the volume of the bass channel. |
7. | peak volume front right channel | the maximum volume allowed for the front right channel. |
8. | peak volume front left channel | the maximum volume allowed for the front left channel. |
9. | peak volume back right channel | the maximum volume allowed for the back right channel. |
10 | peak volume back left channel | the maximum volume allowed for the back left channel. |
11. | peak volume center channel | the maximum volume allowed for the center channel. |
12. | peak volume bass channel | the maximum volume allowed for the bass channel. |
There may only be one relative volume adjustment frame.
Modifier and Type | Class and Description |
---|---|
static class |
ID3v23FrameBodyRelativeVolumeAdjustment.Direction
valid ID3v2.3 volume directions
|
buffer, dirty, frameType
nextNullTerminatorIndex, nullTerminatorIndex
Constructor and Description |
---|
ID3v23FrameBodyRelativeVolumeAdjustment()
The default constructor is called when creating a new frame.
|
ID3v23FrameBodyRelativeVolumeAdjustment(java.io.InputStream inputStream,
int frameBodySize)
This constructor is called when reading in an existing frame from an .mp3 file.
|
ID3v23FrameBodyRelativeVolumeAdjustment(int relativeVolumeAdjustmentFrontRightChannel,
int relativeVolumeAdjustmentFrontLeftChannel,
int relativeVolumeAdjustmentBackRightChannel,
int relativeVolumeAdjustmentBackLeftChannel,
int relativeVolumeAdjustmentCenterChannel,
int relativeVolumeAdjustmentBassChannel,
int peakVolumeFrontRightChannel,
int peakVolumeFrontLeftChannel,
int peakVolumeBackRightChannel,
int peakVolumeBackLeftChannel,
int peakVolumeCenterChannel,
int peakVolumeBassChannel)
The default constructor is called when creating a new frame.
|
Modifier and Type | Method and Description |
---|---|
double |
convertVolumeAdjustmentsToDecibels(int volume)
converts a unitless volume adjustment to decibels (db).
|
int |
getBitsUsedForVolumeAdjustments()
gets the number of bits to use for specifying the volume adjustments for each of the 6 supported channel.
|
int |
getPeakVolumeBackLeftChannel()
gets the peak volume for the back left channel.
|
int |
getPeakVolumeBackRightChannel()
gets the peak volume for the back right channel.
|
int |
getPeakVolumeBassChannel()
gets the peak volume for the bass channel.
|
int |
getPeakVolumeCenterChannel()
gets the peak volume for the center channel.
|
int |
getPeakVolumeFrontLeftChannel()
gets the peak volume for the front left channel.
|
int |
getPeakVolumeFrontRightChannel()
gets the peak volume for the front right channel.
|
int |
getRelativeVolumeAdjustmentBackLeftChannel()
gets the relative volume adjustment for the back left channel.
|
int |
getRelativeVolumeAdjustmentBackRightChannel()
gets the relative volume adjustment for the back right channel.
|
int |
getRelativeVolumeAdjustmentBassChannel()
gets the relative volume adjustment for the bass channel.
|
int |
getRelativeVolumeAdjustmentCenterChannel()
gets the relative volume adjustment for the center channel.
|
int |
getRelativeVolumeAdjustmentFrontLeftChannel()
gets the relative volume adjustment for the front left channel.
|
int |
getRelativeVolumeAdjustmentFrontRightChannel()
gets the relative volume adjustment for the front right channel.
|
void |
parse()
parses the raw bytes of the frame body and stores the parsed values in the frame's fields.
|
void |
setBuffer()
If the frame body's values have been modified, then resize the raw binary buffer and store the new values there.
|
void |
setPeakVolumeBackLeftChannel(int volume)
sets the peak volume for the back left channel.
|
void |
setPeakVolumeBackRightChannel(int volume)
sets the peak volume for the back right channel.
|
void |
setPeakVolumeBassChannel(int volume)
sets the peak volume for the bass channel.
|
void |
setPeakVolumeCenterChannel(int volume)
sets the peak volume for the center channel.
|
void |
setPeakVolumeFrontLeftChannel(int volume)
sets the peak volume for the front left channel.
|
void |
setPeakVolumeFrontRightChannel(int volume)
sets the peak volume for the front right channel.
|
void |
setRelativeVolumeAdjustmentBackLeftChannel(int volume)
sets the relative volume adjustment for the back left channel.
|
void |
setRelativeVolumeAdjustmentBackRightChannel(int volume)
sets the relative volume adjustment for the back right channel.
|
void |
setRelativeVolumeAdjustmentBassChannel(int volume)
sets the relative volume adjustment for the bass channel.
|
void |
setRelativeVolumeAdjustmentCenterChannel(int volume)
sets the relative volume adjustment for the center channel.
|
void |
setRelativeVolumeAdjustmentFrontLeftChannel(int volume)
sets the relative volume adjustment for the front left channel.
|
void |
setRelativeVolumeAdjustmentFrontRightChannel(int volume)
sets the relative volume adjustment for the front right channel.
|
java.lang.String |
toString()
gets a string representation of the relative volume adjustment frame body showing all of the frame's fields and their values.
|
getFrameType, getNextNullTerminator, getSize, isDirty, save, save
getNextNullTerminator, pricesToString, stringToBytes
bytesToInt, bytesToInt, bytesToShort, bytesToShort, bytesToSynchsafeInt, bytesToSynchsafeShort, formateDate, hex, hex, hex, intToBytes, littleEndianBytesToInt, pad, shortToBytes, synchsafeIntToBytes
public ID3v23FrameBodyRelativeVolumeAdjustment()
public ID3v23FrameBodyRelativeVolumeAdjustment(int relativeVolumeAdjustmentFrontRightChannel, int relativeVolumeAdjustmentFrontLeftChannel, int relativeVolumeAdjustmentBackRightChannel, int relativeVolumeAdjustmentBackLeftChannel, int relativeVolumeAdjustmentCenterChannel, int relativeVolumeAdjustmentBassChannel, int peakVolumeFrontRightChannel, int peakVolumeFrontLeftChannel, int peakVolumeBackRightChannel, int peakVolumeBackLeftChannel, int peakVolumeCenterChannel, int peakVolumeBassChannel)
relativeVolumeAdjustmentFrontRightChannel
- relative volume adjustment front right channelrelativeVolumeAdjustmentFrontLeftChannel
- relative volume adjustment front left channelrelativeVolumeAdjustmentBackRightChannel
- relative volume adjustment back right channelrelativeVolumeAdjustmentBackLeftChannel
- relative volume adjustment back left channelrelativeVolumeAdjustmentCenterChannel
- relative volume adjustment center channelrelativeVolumeAdjustmentBassChannel
- relative volume adjustment bass channelpeakVolumeFrontRightChannel
- peak volume front right channelpeakVolumeFrontLeftChannel
- peak volume front left channelpeakVolumeBackRightChannel
- peak volume back right channelpeakVolumeBackLeftChannel
- peak volume back left channelpeakVolumeCenterChannel
- peak volume center channelpeakVolumeBassChannel
- peak volume bass channelpublic ID3v23FrameBodyRelativeVolumeAdjustment(java.io.InputStream inputStream, int frameBodySize) throws java.io.IOException
inputStream
- input stream pointing to a relative volume adjustment frame body in the .mp3 file.frameBodySize
- size (in bytes) of the frame's body.java.io.IOException
- if there is an error while reading the frame body.public void parse() throws java.lang.IllegalArgumentException
parse
in class ID3v23FrameBody
java.lang.IllegalArgumentException
- if an invalid value is detected while parsing the frame body's raw bytes.public double convertVolumeAdjustmentsToDecibels(int volume)
volume (db) = 20 * ln(((volume adjustment / 256) + 255 ) / 255) / ln(10)
Thus, for example, if the relative volume adjustment for the front right channel was -14135, then its volume in db would be:
volume (db) = 20 * ln((-14135 / 256 + 255 ) / 255) / ln(10)
= 20 * ln((-55.215 + 255) / 255) / 2.30
= 20 * ln( 199.78515625 / 255) / 2.30
= 20 * ln(0.7834712) / 2.30
= 20 * -0.244021 / 2.30
= -2.11953925
volume
- the unitless volume adjustment that is to be converted to decibels (db).public int getBitsUsedForVolumeAdjustments()
setBitsUsedForVolumeAdjustments(int)
public int getRelativeVolumeAdjustmentFrontRightChannel()
setRelativeVolumeAdjustmentFrontRightChannel(int)
,
getPeakVolumeFrontRightChannel()
public void setRelativeVolumeAdjustmentFrontRightChannel(int volume)
volume
- the relative volume adjustment for the front right channel.getRelativeVolumeAdjustmentFrontRightChannel()
,
getPeakVolumeFrontRightChannel()
public int getPeakVolumeFrontRightChannel()
setPeakVolumeFrontRightChannel(int)
,
getRelativeVolumeAdjustmentFrontRightChannel()
public void setPeakVolumeFrontRightChannel(int volume)
volume
- the peak volume for the front right channel.getPeakVolumeFrontRightChannel()
,
getRelativeVolumeAdjustmentFrontRightChannel()
public int getRelativeVolumeAdjustmentFrontLeftChannel()
setRelativeVolumeAdjustmentFrontLeftChannel(int)
,
getPeakVolumeFrontLeftChannel()
public void setRelativeVolumeAdjustmentFrontLeftChannel(int volume)
volume
- the relative volume adjustment for the front left channel.getRelativeVolumeAdjustmentFrontLeftChannel()
,
getPeakVolumeFrontLeftChannel()
public int getPeakVolumeFrontLeftChannel()
setPeakVolumeFrontLeftChannel(int)
,
getRelativeVolumeAdjustmentFrontLeftChannel()
public void setPeakVolumeFrontLeftChannel(int volume)
volume
- the peak volume for the front left channel.getPeakVolumeFrontLeftChannel()
,
getRelativeVolumeAdjustmentFrontLeftChannel()
public int getRelativeVolumeAdjustmentBackRightChannel()
setRelativeVolumeAdjustmentBackRightChannel(int)
,
getPeakVolumeBackRightChannel()
public void setRelativeVolumeAdjustmentBackRightChannel(int volume)
volume
- the relative volume adjustment for the back right channel.getRelativeVolumeAdjustmentBackRightChannel()
,
getPeakVolumeBackRightChannel()
public int getPeakVolumeBackRightChannel()
setPeakVolumeBackRightChannel(int)
,
getRelativeVolumeAdjustmentBackRightChannel()
public void setPeakVolumeBackRightChannel(int volume)
volume
- the peak volume for the back right channel.getPeakVolumeBackRightChannel()
,
getRelativeVolumeAdjustmentBackRightChannel()
public int getRelativeVolumeAdjustmentBackLeftChannel()
setRelativeVolumeAdjustmentBackLeftChannel(int)
,
getPeakVolumeBackLeftChannel()
public void setRelativeVolumeAdjustmentBackLeftChannel(int volume)
volume
- the relative volume adjustment for the back left channel.getRelativeVolumeAdjustmentBackLeftChannel()
,
getPeakVolumeBackLeftChannel()
public int getPeakVolumeBackLeftChannel()
setPeakVolumeBackLeftChannel(int)
,
getRelativeVolumeAdjustmentBackLeftChannel()
public void setPeakVolumeBackLeftChannel(int volume)
volume
- the peak volume for the back left channel.getPeakVolumeBackLeftChannel()
,
getRelativeVolumeAdjustmentBackLeftChannel()
public int getRelativeVolumeAdjustmentCenterChannel()
setRelativeVolumeAdjustmentCenterChannel(int)
,
getPeakVolumeCenterChannel()
public void setRelativeVolumeAdjustmentCenterChannel(int volume)
volume
- the relative volume adjustment for the center channel.getRelativeVolumeAdjustmentCenterChannel()
,
getPeakVolumeCenterChannel()
public int getPeakVolumeCenterChannel()
setPeakVolumeCenterChannel(int)
,
getRelativeVolumeAdjustmentCenterChannel()
public void setPeakVolumeCenterChannel(int volume)
volume
- the peak volume for the center channel.getPeakVolumeCenterChannel()
,
getRelativeVolumeAdjustmentCenterChannel()
public int getRelativeVolumeAdjustmentBassChannel()
setRelativeVolumeAdjustmentBassChannel(int)
,
getPeakVolumeBassChannel()
public void setRelativeVolumeAdjustmentBassChannel(int volume)
volume
- the relative volume adjustment for the bass channel.getRelativeVolumeAdjustmentBassChannel()
,
getPeakVolumeBassChannel()
public int getPeakVolumeBassChannel()
setPeakVolumeBassChannel(int)
,
getRelativeVolumeAdjustmentBassChannel()
public void setPeakVolumeBassChannel(int volume)
volume
- the peak volume for the bass channel.getPeakVolumeBassChannel()
,
getRelativeVolumeAdjustmentBassChannel()
public void setBuffer()
setBuffer
in class ID3v23FrameBody
public java.lang.String toString()
toString
in class java.lang.Object