MP3 信息读取
MP3 信息读取
运行环境:Window7 64bit,.NetFramework4.61,C# 7.0; 编者:乌龙哈里 2017-03-13
参考:
章节:
- Mp3 文件结构概述
- ID3V1 标记
- ID3V2 标记
- Mp3 数据头
正文:
一、Mp3文件概述
最近买了个车载mp3播放器,需要下载mp3文件。下载了一堆后发现,很多网上的mp3音质不怎么好,如何来分辨呢。只好研究mp3的文件格式。
从 wiki 上获知,mp3的文件基本有3部分组成:
ID3v2x 标记 |
MP3 音乐数据 |
ID3v1 标记 |
二、ID3v1 标记
Id3v1标记位于 mp3 文件末尾的128 byte,结构如下:
起始 | 长度 | 内容 |
---|---|---|
0 | 3 | 标记 Tag |
3 | 30 | 歌曲名 SongTitle |
33 | 30 | 表演者 Artist |
63 | 30 | 专辑 Album |
93 | 4 | 年份 Year |
97 | 30 | 备注 Comment |
127 | 1 | 歌曲类型 Genre |
1、标记:
标记是以“TAG”3个大写字母为标记。
2、内容:
歌名、表演者、专辑、年份、备注都是以ASCII编码的字符
3、类型:
类型是1位数字,具体见8.1. Appendix A - Genre List from ID3v1
三、ID3v2 标记
Id3v2 标记是放在mp3文件头,具体长度要通过计算才知道。结构分为两部分: Id3v2 Tag Header,Id3v2 Frame。
1、Id3v2Tag Header:
这个头部放在mp3文件最前面,长 10byte,具体结构:
起始 | 长度 | 内容 |
---|---|---|
0 | 3 | 标志 Tag |
3 | 2 | 版本 version |
5 | 1 | Flag |
6 | 4 | Frame长度 |
标志是以“ID3”3个字符为标记;
版本为2个 byte的数字,前面1byte 一般为 03,表示id3v2.3版本,后面1byte的为小版本,一般为0;
Flag具体看ID3 tag version 2.3.0 ,一般为0;
Frame长度是指紧接着 10byte 长的头部数据后的id3v2tag Frame的长度,是4个byte的数字,每byte的二进制位中前面都为0,0xxxxxxxx,具体长度的算法用位计算为:
byte[] data=new byte[10];
//....(从文件中读取前10byte数据放入 data)
int FrameLength=data[6] << 21 | data[7] << 14 | data[8] << 7 | data[9]
2、Tag Frame帧数据。
Tag Frame 是一个以10byte为头,后面不定长的数据帧,结构如下:
部分 | 相对起始 | 长度 | 内容 |
---|---|---|---|
头 | 0 | 4 | 标记 Frame ID |
头 | 5 | 4 | 内容长度 |
头 | 8 | 2 | Flages |
内容 | 10 | 不定长 | 内容 |
FrameID 为4个字符,具体参考ID3 tag version 2.3.0;
内容长度为 4 byte的数据,和上面的不同,它的二进制是全8位的,但和 C# 存储int32不同,它前面的byte表示高位,具体计算如下:
byte[] data=new byte[10];
//....(读取10byte Frame头部数据放入 data)
int ContentLength=data[6] << 24 | data[7] << 16 | data[8] << 8 | data[9]
(1)FrameId 以“T”开头的,除了“TXXX”,都是字符串信息,具体结构为:
起始 | 长度 | 内容 |
---|---|---|
0 | 1 | Text encoding |
1 | Frame头计算出来的长度 | 内容 |
内容以 FF FE 开头的为 C# 里面的 Encoding.Unicode ,以 FE FF 开头的为 C# 里面的 Encoding.BigEndianUnicode;除上外是以 Ascii 编码的。
(2)FrameId为“APIC”的是放 jpeg 或 png 格式的图像数据,具体见4.15. Attached picture。
四、mp3音乐数据头
读完 id3v2tag 的数据后,紧接着下来就是具体的音乐数据。但是并不一定紧挨着 FrameLength+10,不知道是这些mp3录制的时候的软件问题还是其他我还没发现的问题,用ultraEdit看,音乐数据和 id3tag 中间还有一部分全都是0的数据,所以读完 id3v2tag 后还要一个字节一个字节的寻找 FF开头的数据。我只是需要知道mp3的音乐信息,所以只要在id3v2tag 后找到 FF 开头的4个字节的数据就成了。这4个字节全部都是用位来表示信息,具体见MPEG Audio Layer I/II/III frame header。
写了一个程序读写,尚未完全完成,效果如下图:
附练手全程序:
<Window x:Class="Mp3信息.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Mp3信息"
mc:Ignorable="d"
Title="Mp3信息1.0 [乌龙哈里2017-03-13]" Height="650" Width="500">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="32"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="6*"/>
</Grid.ColumnDefinitions>
<Button Name="btnFile" Content="Mp3" Margin="3" Grid.Column="0" Click="btnFile_Click"/>
<TextBox Name="txtFile" Grid.Column="1" Margin="3"/>
</Grid> <TabControl Grid.Row="1"> <TabItem Header="单曲">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="200"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<DataGrid Name="dgShow" AutoGenerateColumns="False" SelectionUnit="CellOrRowHeader" Grid.Row="0" Grid.ColumnSpan="2">
<DataGrid.Columns>
<DataGridTextColumn Header="名称" Binding="{Binding [0]}"/>
<DataGridTextColumn Header="ID3V2" Binding="{Binding [1]}"/>
<DataGridTextColumn Header="ID3V1" Binding="{Binding [2]}"/>
</DataGrid.Columns>
</DataGrid>
<Image Name="imgCover" Grid.Row="1" Grid.Column="0"/>
<Grid Grid.Row="1" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="32"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Name="btnModify2" Content="修改 ID3V2" FontSize="18" Foreground="Navy" Grid.Row="1" Grid.Column="0" Margin="10" Click="btnModify2_Click"/>
<ComboBox Name="cmbGenre" Margin="10,5,10,2" Grid.Row="0" Grid.Column="1" SelectionChanged="cmbGenre_SelectionChanged"/>
<Button Name="btnModify1" Content="修改 ID3V1" FontSize="18" Grid.Row="1" Grid.Column="1" Margin="10" Click="btnModify1_Click"/>
</Grid>
</Grid>
</TabItem>
<TabItem Header="批量">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Name="btnMuti" Content="批量读取" FontSize="16" Margin="5" Grid.Row="0"/>
<DataGrid Name="dgMuti" Grid.Row="1">
<DataGrid.Columns>
<DataGridTextColumn Header="文件" Binding="{Binding [0]}"/>
<DataGridTextColumn Header="Mpeg" Binding="{Binding [1]}"/>
<DataGridTextColumn Header="Layer" Binding="{Binding [2]}"/>
<DataGridTextColumn Header="波特率" Binding="{Binding [3]}"/>
<DataGridTextColumn Header="频率" Binding="{Binding [4]}"/>
<DataGridTextColumn Header="声道" Binding="{Binding [5]}"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</TabItem>
</TabControl>
</Grid>
</Window>
using System.Windows;
using System.Windows.Controls; namespace Mp3信息
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
private string filteStr = "MP3 File|*.mp3|All File|*.*";
private Mp3FileInfo mp3 = new Mp3FileInfo(); public MainWindow()
{
InitializeComponent(); dgShow.ItemsSource = mp3.Mp3Infos;
cmbGenre.ItemsSource = mp3.Genres;
}
//---打开文件按钮
private void btnFile_Click(object sender, RoutedEventArgs e)
{
string filename = GetOpenFilePath(filteStr);
if (!string.IsNullOrEmpty(filename))
{
txtFile.Text = filename;
dgShow.BeginEdit();
mp3.GetMp3Info(filename);
dgShow.EndInit();
if (mp3.CoverExist)
{
imgCover.Source = mp3.CoverPicture;
}
cmbGenre.SelectedIndex =int.Parse(mp3.Mp3Infos[][]);
}
}
//---取得打开文件名
private string GetOpenFilePath(string filterstr)
{
var dlg = new Microsoft.Win32.OpenFileDialog();
dlg.Filter = filterstr;
if (dlg.ShowDialog() == true)
{
return dlg.FileName;
}
return "";
}
//---取得保存文件名
private string GetSaveFilePath(string filterstr)
{
var dlg = new Microsoft.Win32.SaveFileDialog();
//dlg.FileName = Path.GetFileNameWithoutExtension(memoFilePath);
//dlg.DefaultExt = ".memo";
dlg.Filter = filterstr;
if (dlg.ShowDialog() == true)
{
return dlg.FileName;
}
return "";
} private void btnModify1_Click(object sender, RoutedEventArgs e)
{
mp3.SetV1TagInfo(txtFile.Text);
} private void cmbGenre_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
dgShow.BeginInit();
mp3.Mp3Infos[][] = cmbGenre.SelectedIndex.ToString();
dgShow.EndInit();
} private void btnModify2_Click(object sender, RoutedEventArgs e)
{
mp3.SetV2TagInfo(txtFile.Text);
}
}
}
/******************************************************
* MP3 音乐格式文件信息读取
* 作者:乌龙哈里
* 最后修改:2017-03-07
* 参考:
* 1、http://id3.org/d3v2.3.0
* 2、http://blog.csdn.net/alin0725/article/details/1876253
* 3、http://www.mpgedit.org/mpgedit/mpeg%5Fformat/MP3Format.html
* 4、https://en.wikipedia.org/wiki/MP3
******************************************************/
namespace Mp3信息
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging; /// <summary>
/// 主程序class
/// </summary>
class Mp3FileInfo
{
public string Mp3File { get; set; }
//注意:要先建立一个放置音乐类型的txt文件
public string GenreFile { get; set; } = @".\mp3genre.txt"; private int V1TagLength = ;
private int V2TagHeaderLength = ;
private string V1TagSymbol = "TAG";
private string V2TagSymbol = "ID3";
private string V2TagPictureId = "APIC";
private int[] V1TagStruct = new int[];//id3v1数据结构
public string[] Genres;//音乐类型 private string[] Mpeg;
private string[] Layer;
private string[] Bitrate;
private string[] Hz;
private string[] Channel; public ObservableCollection<string[]> Mp3Infos = new ObservableCollection<string[]>();
public BitmapSource CoverPicture;
public bool CoverExist = false;
public int NewCoverType = -;
private string[] V2TagFrameIds; //---初始化
public Mp3FileInfo()
{
FillV1TagStruct();
FillGenres();
FillHeader();
FillV2TagFrameIds();
}
//---批量取得信息(以后再写)
public void GetMutiInfo(string path)
{ }
//---写id3v2信息(有问题,写成功后用windows的播放器播放正常,图片也出现,但歌名等信息不出现)
public void SetV2TagInfo(string path)
{ List<(string frameid, string content)> list = new List<(string, string)>();
int n = ;
for (int i = ; i < V2TagFrameIds.Length; i++)
{
if (Mp3Infos[i][].Length > )
{
list.Add((V2TagFrameIds[i],Mp3Infos[i][]));
n += Mp3Infos[i][].Length* + + ;
}
}
n += ;
byte[] _data = new byte[n];
Encoding.Default.GetBytes(V2TagSymbol,,,_data,);
_data[] = ;
int m = ;
foreach (var info in list)
{
Encoding.Default.GetBytes(info.frameid,,,_data,m);
int k = info.content.Length* + ;
_data[m + ] = (byte)(k >>);
_data[m + ] = (byte)(k >>);
_data[m + ] = (byte)(k >> );
_data[m + ] = (byte)k;
_data[m + ] = ;
_data[m + ] = ;
_data[m + ] = ;
Encoding.Unicode.GetBytes(info.content,,info.content.Length,_data,m+);
m =m+ k + ;
}
m = n;
if (NewCoverType > -)
{ }
else
{
using (FileStream fs=File.OpenRead(path))
{
int _framelength = GetV2TagFrameLength(fs);
byte[] _framedata = new byte[_framelength];
fs.Read(_framedata, , _framedata.Length);
var _frames = GetV2TagFrameInfo(_framedata);
int _index = -;
for (int i = ; i < _frames.Count; i++)
{
if (string.Compare(_frames[i].frameid, V2TagPictureId) == )
{
n += _frames[i].length;
_index = i;
break;
}
}
n = n+ (int)fs.Length - _framelength - ;
Array.Resize(ref _data, n);
int k = m;
if (_index > -)
{
k = m + _frames[_index].length;
for(int i=; i < _frames[_index].length; i++)
{
_data[m++]=_framedata[_frames[_index].start + i];
}
}
_data[] = (byte)((k >> )&0x7F);
_data[] = (byte)((k >> ) & 0x7F);
_data[] = (byte)((k >> ) & 0x7F);
_data[] = (byte)(k & 0x7F); fs.Read(_data, m, (int)fs.Length - _framelength - ); }
}
using (FileStream fs = File.Create(@"d:\test\123.mp3"))
{
fs.Write(_data, , _data.Length);
} }
//---写id3v1信息
public void SetV1TagInfo(string path)
{
byte[] info = new byte[V1TagLength];
info[] = (byte)V1TagSymbol[];
info[] = (byte)V1TagSymbol[];
info[] = (byte)V1TagSymbol[];
for (int i = ; i < ; i++)
{
string s = Mp3Infos[i][].Trim();
Encoding.Default.GetBytes(s, , s.Length, info, V1TagStruct[(i + ) * ]);
}
info[V1TagStruct[]] = byte.Parse(Mp3Infos[][]);
using (FileStream fs = File.OpenWrite(path))
{
fs.Seek(-info.Length, SeekOrigin.End);
fs.Write(info, , info.Length);
}
}
//---读取mp3信息
public void GetMp3Info(string path)
{
Mp3Infos.Clear();
FillMp3Infos();
using (FileStream fs = File.OpenRead(path))
{
GetV1TagInfo(fs);
int _v2TagLength = GetV2TagFrameLength(fs);
if (_v2TagLength > )
{
GetV2TagInfo(fs, _v2TagLength);
int[] _index = new int[];
int n = V2TagFrameIds.Length;
GetMp3HeaderInfo(_index, fs, _v2TagLength);
Mp3Infos[n][] = Mpeg[_index[]];
Mp3Infos[n+][] = Layer[_index[]];
Mp3Infos[n+][] = Bitrate[_index[]];
Mp3Infos[n+][] = Hz[_index[]];
Mp3Infos[n+][] = Channel[_index[]];
}
}
}
//---读取mp3 header 信息
private void GetMp3HeaderInfo(int[] Index, FileStream fs, int Id3v2TagFrameLength)
{
byte[] _header = new byte[];
Func<bool> FindHeader = () =>
{
int m = ;
int start = ;
fs.Seek(Id3v2TagFrameLength + V2TagHeaderLength, SeekOrigin.Begin);
while (start++ < m)
{
if (fs.ReadByte() == )
{
fs.Read(_header, , );
return true;
}
}
return false; };
if (FindHeader())
{
int _mpegIndex = (_header[] >> ) & Convert.ToByte("", );
int _layerIndex = (_header[] >> ) & Convert.ToByte("", );
int _bitrateIndex = _header[] >> ;
int _hzIndex = (_header[] >> ) & Convert.ToByte("", );
int _channelIndex = _header[] >> ;
int _bitrateIndexStep = _mpegIndex * + (_layerIndex - ) * ;
int _hzIndexStep = _mpegIndex * ;
Index[] = _mpegIndex;
Index[] = _layerIndex;
Index[] = _bitrateIndex + _bitrateIndexStep;
Index[] = _hzIndex + _hzIndexStep;
Index[] = _channelIndex;
}
}
//---读取id3v2标记内容
private void GetV2TagInfo(FileStream fs, int Length)
{
CoverExist = false;
NewCoverType = -;
byte[] _v2tag = new byte[Length];
fs.Seek(V2TagHeaderLength, SeekOrigin.Begin);
fs.Read(_v2tag, , _v2tag.Length);
var _frames = GetV2TagFrameInfo(_v2tag);
foreach (var _frame in _frames)
{
int _index = GetV2TagFrameIdIndex(_frame.frameid);
if (_index > -)
{
Mp3Infos[_index][] = GetFrameStrContent(_v2tag, _frame.start + , _frame.length - );
}
else
{
//如果是APIC,则读取图片
if (string.Compare(_frame.frameid, V2TagPictureId) == )
{
GetImage(_v2tag, _frame.start + , _frame.length - );
}
} }
}
//---读取图片
private void GetImage(byte[] source, int start, int contentLength)
{
//寻找图片位置
Func<byte[], (bool found, int startpos)> FindImage = symbol =>
{
int n = start;
int m = start + ;
while (n < m)
{
if (n > m - symbol.Length)
{
return (false, -);
}
if (source[n] == symbol[] && source[n + ] == symbol[] && source[n + ] == symbol[])
{
return (true, n);
}
n++;
}
return (false, -);
};
//取得图片信息
Func<(int ImageKind, int startpos)> GetImageInfo = () =>
{
byte[] _imghead = new byte[];
//jpeg header
_imghead[] = 0xFF;
_imghead[] = 0xD8;
_imghead[] = 0xFF;
var t = FindImage(_imghead);
if (t.found)
{
return (, t.startpos);
}
//png header
_imghead[] = 0x89;
_imghead[] = 0x50;
_imghead[] = 0x4E;
t = FindImage(_imghead);
if (t.found)
{
return (, t.startpos);
}
return (-, -);
};
//读取图片
var p = GetImageInfo();
if (p.ImageKind > -)
{
CoverExist = true;
MemoryStream ms = new MemoryStream();
ms.Write(source, p.startpos, contentLength + start - - p.startpos);
ms.Seek(, SeekOrigin.Begin);
switch (p.ImageKind)
{
case :
JpegBitmapDecoder jpeg = new JpegBitmapDecoder(ms, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
CoverPicture = jpeg.Frames[];
break;
case :
PngBitmapDecoder png = new PngBitmapDecoder(ms, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
CoverPicture = png.Frames[];
break;
}
} }
//---读取v2 Frame string内容
private string GetFrameStrContent(byte[] source, int start, int length)
{
if (source[start + ] == && source[start + ] == )
{
return Encoding.Unicode.GetString(source, start + , length - );
}
if (source[start + ] == && source[start + ] == )
{
return Encoding.BigEndianUnicode.GetString(source, start + , length - );
} return Encoding.Default.GetString(source, start + , length - );
}
//---根据V2TagFrameIds,找出FrameId在mp3infos的index
private int GetV2TagFrameIdIndex(string FrameId)
{
for (int i = ; i < V2TagFrameIds.Length; i++)
{
if (string.Compare(V2TagFrameIds[i], FrameId) == )
{
return i;
}
}
return -;
}
//---读取v2tag frame 信息
private List<(string frameid, int start, int length)> GetV2TagFrameInfo(byte[] FrameData)
{
int n = ;
List<(string frameid, int length, int start)> _frames = new List<(string frameid, int length, int start)>();
while (n < FrameData.Length - )
{
int _length = FrameData[n + ] << | FrameData[n + ] << | FrameData[n + ] << | FrameData[n + ];
if (_length > )
{
_frames.Add((Encoding.Default.GetString(FrameData, n, ), n, _length + ));
n += _length; }
n += ;
}
return _frames;
}
//---判断 id3v2标志是否存在,并计算大小
private int GetV2TagFrameLength(FileStream fs)
{
fs.Seek(, SeekOrigin.Begin);
byte[] _head = new byte[V2TagHeaderLength];
fs.Read(_head, , _head.Length);
if (string.Compare(Encoding.Default.GetString(_head, , ), V2TagSymbol) == )
{
return _head[] << | _head[] << | _head[] << | _head[];
}
return ;
}
//---读取id3v1 Tag 信息
private void GetV1TagInfo(FileStream fs)
{
//取得ascii编码的字符串截止到 0 的数据长度
Func<byte[], int, int, int> GetStringDataLength = (source, start, length) =>
{
for (int i = ; i < length; i++)
{
if (source[start + i] == )
{
return i;
}
}
return length;
}; byte[] _v1Tag = new byte[V1TagLength];
fs.Seek(-_v1Tag.Length, SeekOrigin.End);
fs.Read(_v1Tag, , _v1Tag.Length);
if (string.Compare(Encoding.Default.GetString(_v1Tag, V1TagStruct[], V1TagStruct[]), V1TagSymbol) == )
{
for (int i = ; i < ; i++)
{
Mp3Infos[i][] = Encoding.Default.GetString(_v1Tag, V1TagStruct[(i + ) * ],
GetStringDataLength(_v1Tag, V1TagStruct[(i + ) * ], V1TagStruct[(i + ) * + ])); }
Mp3Infos[][] = _v1Tag[V1TagStruct[]].ToString();
}
}
//---填充id3v2Tag Frame 标志
private void FillV2TagFrameIds()
{
V2TagFrameIds = new string[]{
"TIT2","TPE1","TALB","TYER","COMM","TCON",
"TPE2","TCOM","TPE3","TPE4","TRCK","TCOP"
};
}
//---填充Mp3infos
private void FillMp3Infos()
{ Mp3Infos.Add(new string[] { "歌名", "", "" });
Mp3Infos.Add(new string[] { "表演", "", "" });
Mp3Infos.Add(new string[] { "专辑", "", "" });
Mp3Infos.Add(new string[] { "年份", "", "" });
Mp3Infos.Add(new string[] { "备注", "", "" });
Mp3Infos.Add(new string[] { "种类", "", "" });
//以下为id3v2tag增加
Mp3Infos.Add(new string[] { "乐队", "", "" });
Mp3Infos.Add(new string[] { "作曲", "", "" });
Mp3Infos.Add(new string[] { "指挥", "", "" });
Mp3Infos.Add(new string[] { "重编", "", "" });
Mp3Infos.Add(new string[] { "音轨", "", "" });
Mp3Infos.Add(new string[] { "版权", "", "" }); //以下为mp3数据头
Mp3Infos.Add(new string[] { "Mpeg", "", "" });
Mp3Infos.Add(new string[] { "Layer", "", "" });
Mp3Infos.Add(new string[] { "波特率", "", "" });
Mp3Infos.Add(new string[] { "频率", "", "" });
Mp3Infos.Add(new string[] { "声道", "", "" });
}
//填充mp3数据头的数据表
private void FillHeader()
{
Mpeg = new string[] { "MPEG 2.5", "Reserved", "MPEG 2", "MPEG 1" };
Layer = new string[] { "Reserved", "Layer III", "Layer II", "Layer I" };
Bitrate = new string[]
{
"free","","","","","","","","","","","","","","","bad",
"free","","","","","","","","","","","","","","","bad",
"free","","","","","","","","","","","","","","","bad", "free","","","","","","","","","","","","","","","bad",
"free","","","","","","","","","","","","","","","bad",
"free","","","","","","","","","","","","","","","bad", "free","","","","","","","","","","","","","","","bad",
"free","","","","","","","","","","","","","","","bad",
"free","","","","","","","","","","","","","","","bad", "free","","","","","","","","","","","","","","","bad",
"free","","","","","","","","","","","","","","","bad",
"free","","","","","","","","","","","","","","","bad", }; Hz = new string[]
{
"","","","Reserved",
"","","","Reserved",
"","","","Reserved",
"","","","Reserved"
};
/*“联合立体声模式”是音频编码的立体声模式之一。联合立体声模式充分利用左右声道的相似之处,
* 对于左右声道的相同部分不再重复编码,减少了数据的浪费,这样就可以做到在较低的位率下表现更丰富的细节。
* 对于左右声道差异不大的音频来说,联合立体声编码模式通常在较低的位率下就可以得到不错的效果。
* 而“立体声模式”则使用两个相互独立的声道进行编码,因此它需要较多的位率,但它的左右声道的分离度较高,
* 通常使用在位率较高的场合,用于高质量的音频编码。
*/
Channel = new string[] { "立体声", "联合立体声", "双声道", "单声道" };
}
//---填充音乐类型表
private void FillGenres()
{
string[] str = File.ReadAllText(GenreFile).Split(new char[] { (char), (char), '.' }, StringSplitOptions.RemoveEmptyEntries);
Genres = new string[str.Length / ];
for (int i = ; i < str.Length; i += )
{
Genres[(i - ) / ] = str[i];
}
}
//---填充 Id3v1 数据结构
private void FillV1TagStruct()
{
//symbol
V1TagStruct[] = ;//start pos
V1TagStruct[] = ;//length
//song title
V1TagStruct[] = ;
V1TagStruct[] = ;
//artist
V1TagStruct[] = ;
V1TagStruct[] = ;
//album
V1TagStruct[] = ;
V1TagStruct[] = ;
//year
V1TagStruct[] = ;
V1TagStruct[] = ;
//comment
V1TagStruct[] = ;
V1TagStruct[] = ;
//genre
V1TagStruct[] = ;
V1TagStruct[] = ;
}
}
}
//mp3genre.txt
.Blues
.Classic Rock
.Country
.Dance
.Disco
.Funk
.Grunge
.Hip-Hop
.Jazz
.Metal
.New Age
.Oldies
.Other
.Pop
.R&B
.Rap
.Reggae
.Rock
.Techno
.Industrial
.Alternative
.Ska
.Death Metal
.Pranks
.Soundtrack
.Euro-Techno
.Ambient
.Trip-Hop
.Vocal
.Jazz+Funk
.Fusion
.Trance
.Classical
.Instrumental
.Acid
.House
.Game
.Sound Clip
.Gospel
.Noise
.AlternRock
.Bass
.Soul
.Punk
.Space
.Meditative
.Instrumental Pop
.Instrumental Rock
.Ethnic
.Gothic
.Darkwave
.Techno-Industrial
.Electronic
.Pop-Folk
.Eurodance
.Dream
.Southern Rock
.Comedy
.Cult
.Gangsta
.Top
.Christian Rap
.Pop/Funk
.Jungle
.Native American
.Cabaret
.New Wave
.Psychadelic
.Rave
.Showtunes
.Trailer
.Lo-Fi
.Tribal
.Acid Punk
.Acid Jazz
.Polka
.Retro
.Musical
.Rock & Roll
.Hard Rock
.Folk
.Folk-Rock
.National Folk
.Swing
.Fast Fusion
.Bebob
.Latin
.Revival
.Celtic
.Bluegrass
.Avantgarde
.Gothic Rock
.Progressive Rock
.Psychedelic Rock
.Symphonic Rock
.Slow Rock
.Big Band
.Chorus
.Easy Listening
.Acoustic
.Humour
.Speech
.Chanson
.Opera
.Chamber Music
.Sonata
.Symphony
.Booty Bass
.Primus
.Porn Groove
.Satire
.Slow Jam
.Club
.Tango
.Samba
.Folklore
.Ballad
.Power Ballad
.Rhythmic Soul
.Freestyle
.Duet
.Punk Rock
.Drum Solo
.Acapella
.Euro-House
.Dance Hall
MP3 信息读取的更多相关文章
- Mp3文件标签信息读取和写入(Kotlin)
原文:Mp3文件标签信息读取和写入(Kotlin) - Stars-One的杂货小窝 最近准备抽空完善了自己的星之小说下载器(JavaFx应用 ),发现下载下来的mp3文件没有对应的标签 也是了解可以 ...
- 【Python】 获取MP3信息replica
replica 初衷是想要整理iphone中的音乐.IOS(我自己的手机还是IOS8.3,新版本的系统可能有变化了)自带的音乐软件中所有音乐文件都存放在/var/mobile/Media/iTunes ...
- 创建一个目录info,并在目录中创建一个文件test.txt,把该文件的信息读取出来,并显示出来
/*4.创建一个目录info,并在目录中创建一个文件test.txt,把该文件的信息读取出来,并显示出来*/ #import <Foundation/Foundation.h>#defin ...
- py3nvml实现GPU相关信息读取
技术背景 随着模型运算量的增长和硬件技术的发展,使用GPU来完成各种任务的计算已经渐渐成为算法实现的主流手段.而对于运行期间的一些GPU的占用,比如每一步的显存使用率等诸如此类的信息,就需要一些比较细 ...
- EWS API 2.0读取日历信息-读取内容注意事项
采用模拟账号的方式读取日历信息,注意下日历的内容读取(Body)读取.代码如下:(采用 EWS API 2.0版本) 1.读取内容前必须设置如下属性:否则会提示:You must load or as ...
- jsp配置文件数据信息读取
一.jsp从配置文件*.properties读取信息 <%@ page language="java" import="java.util.*" cont ...
- JPEG图片扩展信息读取与修改
extends:http://www.2cto.com/kf/201405/303813.html 读写均是键值对的方式,需要注意的是值的类型需要严格按照api定义格式. 支持读写节点为: 1.TAG ...
- JPEG图片扩展信息读取与改动
近日项目中须要用到往jpg图片中写入信息(非水印),经调研发现Android中已经封装了读写jpg图片扩展信息的api(ExifInterface). 相应api地址:http://developer ...
- JPEG图像扩展信息读取和修改
最近,项目需要使用jpg图像信息被写入(非水印),经过研究发现,Android已封装的读者jpg图片扩展信息api(ExifInterface). 通讯api住址:http://developer.a ...
随机推荐
- Java策略模式(Strategy模式) 之体验
<JAVA与模式>之策略模式 在阎宏博士的<JAVA与模式>一书中开头是这样描述策略(Strategy)模式的: 策略模式属于对象的行为模式.其用意是针对一组算法,将每一个算法 ...
- 各个浏览器开启CSS Grid Layout的方式
2017年3月,Chrome.Firefox将开启默认支持. 当然对于很多人等不及浏览器默认支持,想提前体验一把,这里提供一些打开方式: 1.Chrome 在浏览器中输入:chrome://flags ...
- jquery 全选 全不选 事件绑定
<td width="82%" colspan="3"><input type="checkbox" id="a ...
- 微信小程序开发系列(二)小程序的全局文件
其实你已经知道了小程序的文件结构 上一节讲到,小程序的页面由三部分组成: 视图(.wxml).逻辑(.js).样式(.wxss). 我们这次重新展开文件结构: 小程序用到的文件类型只有四种,正如你所看 ...
- [CSS3] 学习笔记-背景与边框相关样式
1.与背景相关的新增属性 包括:backgroud-clip,backgroud-origin,backgroud-size <!DOCTYPE html> <html> &l ...
- [html5]学习笔记一 新增的主题结构元素
html5 新增的主体结构元素有:article,section,nav,aside,time,pubdate元素. 1. article元素代表文档.页面或应用程序中独立的.完整的.可以独自被外部引 ...
- JavaScript 语法
一.JavaScript简介 1.JavaScript是个什么东西? 它是个脚本语言,需要有宿主文件,它的宿主文件是HTML文件. 2.它与Java什么关系? 没有什么直接的联系,Java是Sun公司 ...
- 【canvas系列】用canvas实现一个colorpicker
每个浏览器都有自己的特点,比如今天要做的colorpicker就是,一千个浏览器,一千个哈姆雷特,一千个colorpicker.今天canvas系列就用canvas做一个colorpicker. ** ...
- 都能读懂的css3 3D变形效果
css3 3D变形效果 CSS3 transform3D变形 transform的含义是:改变,使-变形:转换 三维变换使用基于二维变换的相同属性,如果您熟悉二维变换,你们发现3D变形的功能和2D变换 ...
- UI进阶 即时通讯之XMPP登录、注册
1.XMPP环境搭建 http://www.cnblogs.com/fearlessyyp/p/5506644.html 第一次打开可能会有点儿慢,图片很多,步骤很详细,祝搭建成功. 2.工程中添加X ...