兄弟们帮帮忙,帮我将这段vb的程序用C语言写出来,并经那段英文反译成汉语,一定会重谢的!再线等待!!!!!

lengfenghongyu 2003-11-22 01:10:36

请翻译下文并将其用VC改造。传回翻译后的文件,和VC主要语句。

Deciphering(判读) MP3 Tag information with Visual Basic

The Windows Media Player provides an easy, quick way to drop MP3 capability i
nto a Visual Basic application. However, once you have an MP3, you may have wonde
red how to read information about the song, such as the song title and artist's n
ame. If the MP3 file uses the most popular tag encryption, ID3, then you're in lu
ck. This standard stores the Tag information in the last 128 bytes of the file (T
ag:3, Title:30, Artist:30, Album:30, Year:4, Comment:30, Genre:1)

To read this information, first open the MP3 file and grab the last 128 bytes
. With ID3, the first three slots hold the string TAG if the file actually contai
ns information. If the file does contain Tag information, store the last 128 byte
s in a custom variable. After that,cycle through the MP3 file, extracting informa
tion as you go. The following procedure shows the code that extracts this informa
tion as
well as creates several important variables to use later on:

Option Explicit
Private Type TagInfo
Tag As String * 3
Songname As String * 30
artist As String * 30
album As String * 30
year As String * 4
comment As String * 30
genre As String * 1
End Type

Dim FileName As String
Dim CurrentTag As TagInfo

Private Sub Form1_Load()
Dim temp As String
On Error Resume Next

FileName = App.Path & "\myMP3.mp3"
Open FileName For Binary As #1
With CurrentTag
Get #1, FileLen(FileName) - 127, .Tag
If Not .Tag = "TAG" Then
label8.Caption = "No tag"
Close #1
Exit Sub
End If
Get #1, , .Songname
Get #1, , .artist
Get #1, , .album
Get #1, , .year
Get #1, , .comment
Get #1, , .genre
Close #1

txtTitle = RTrim(.Songname)
txtArtist = RTrim(.artist)
txtAlbum = RTrim(.album)
txtYear = RTrim(.year)
txtComment = RTrim(.comment)

Temp = RTrim(.genre)
txtGenreCode = Asc(Temp)
Combo1.ListIndex = CInt(txtGenreCode) - 1
End With
End Sub

Notice that the code has to handle the genre character a little differently.
That's because ID3 stores this data as a single ASCII character. To match up the
actual number with its corresponding description -- say contained in a combobox--
the procedure converts the ASCII to a number, and then looks up that number in th
e combobox.


=============================================================



...全文
95 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
sevencat 2003-11-27
  • 打赏
  • 举报
回复
楼主以后找资料可以多找一点,MP3的中文资料可能也不少了。MP3的C代码可能更多了。
wyfsnn 2003-11-27
  • 打赏
  • 举报
回复
怎么解压具体的内容呀?
蝎子i软件 2003-11-26
  • 打赏
  • 举报
回复
用Borland C++ 5.5 Commandline编译并运行通过。
如果要用combobox的话,把genre数组里的字符串加到comobox里就行了。

另外,我的程序里并没有用到temp。

下面给出一个简单的Windows程序。
蝎子i软件 2003-11-26
  • 打赏
  • 举报
回复
程序:
==================================
#include <stdio.h>
#include <string.h>

struct TagInfo {
char Tag[3];
char Songname[30];
char artist[30];
char album[30];
char year[4];
char comment[30];
char genre;
};

char FileName[30]; //长度可变
struct TagInfo CurrentTag;
char *genres[]={
/* The following genres is defined in ID3v1 */
"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 40", "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",
/* The following genres are Winamp extensions */
"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"
};

void main(){
char temp[20];
FILE *fin;

strcpy( FileName, "myMP3.mp3" ); //当前程序路径可省略
fin = fopen( FileName, "rb" );
if( fin==NULL ) {
printf("Openning %s failed!\n", FileName);
return;
}

fseek( fin, -128, SEEK_END );
fread( ¤tTag, sizeof(struct TagInfo), 1, fin );

if( CurrentTag.Tag[0]!='T' ||
CurrentTag.Tag[1]!='A' ||
CurrentTag.Tag[2]!='G' ) {
printf("No tag\n");
fclose( fin );
return;
}
printf("Tag Information\n");
printf("\tSong Name:\t%s\n", CurrentTag.Songname);
printf("\tArtist:\t%s\n", CurrentTag.artist);
printf("\tAlbum:\t%s\n", CurrentTag.album);
printf("\tYear:\t%.4s\n", CurrentTag.year);
printf("\tComment:\t%s\n", CurrentTag.comment);
printf("\tGenre:\t%s\n", genres[CurrentTag.genre]);
fclose(fin);
}
蝎子i软件 2003-11-26
  • 打赏
  • 举报
回复
译文:
=====================================
用Visual Basic解读MP3标记的信息
Windows Media Player提供了一个简单的、快速的方法,以使Visual Basic应用具备MP3的能力。不过,当你拿到一个MP3,你可能想知道怎样读取该歌曲的信息,例如歌名、

演唱者的名字等。如果该MP3文件使用的是最流行的标记加密标准,ID3,那你就走运了。这个标准将标记信息存储在文件的最后128个字节里(标记:3,标题:30,歌手:30

,专辑:30,年份:4,注释:30,类别:1)。
要读取这些信息,首先,打开该MP3文件,抓取最后128字节。对于ID3,如果该文件确实包含有信息,头3个位置保存了字符串“TAG”。如果文件确实有标记信息,将最后128

个字节保存在一个变量里。然后,循环遍历该MP3文件,同时解压信息。下面的代码解压该信息,并且创建了几个重要的变量,以备后用:

< 程序 >

注意,对于genre包含的字符的处理有点不同。这是因为ID3将该数据保存为一个单字节的ASCII字符。为了将实际的数值和它相应的描述(假设包含在一个下拉对话框里)对应

起来,本程序将该ASCII转换称一个数值,然后在该下拉对话框中查找该数值。

注:原程序用的combobox控件,因为我的程序不是windows程序,所以就该用数组了。
sdudyfrom 2003-11-26
  • 打赏
  • 举报
回复
这个程序好麻烦噢!顶一下吧!
lengfenghongyu 2003-11-22
  • 打赏
  • 举报
回复
怎么大家都在忙吗?
lengfenghongyu 2003-11-22
  • 打赏
  • 举报
回复
帮帮忙,分不是问题!;)
lengfenghongyu 2003-11-22
  • 打赏
  • 举报
回复
主要是程序,帮我用C语言写出来,谢谢各位了!
hcj2002 2003-11-22
  • 打赏
  • 举报
回复
这段话的主要意思是从一个mp3文件中读出相应的信息如名称,长度等并在vb中用空间输出相关信息。
lengfenghongyu 2003-11-22
  • 打赏
  • 举报
回复

请翻译下文并将其用VC改造。传回翻译后的文件,和VC主要语句。

Deciphering(判读) MP3 Tag information with Visual Basic

The Windows Media Player provides an easy, quick way to drop MP3 capability i
nto a Visual Basic application. However, once you have an MP3, you may have wonde
red how to read information about the song, such as the song title and artist's n
ame. If the MP3 file uses the most popular tag encryption, ID3, then you're in lu
ck. This standard stores the Tag information in the last 128 bytes of the file (T
ag:3, Title:30, Artist:30, Album:30, Year:4, Comment:30, Genre:1)

To read this information, first open the MP3 file and grab the last 128 bytes
. With ID3, the first three slots hold the string TAG if the file actually contai
ns information. If the file does contain Tag information, store the last 128 byte
s in a custom variable. After that,cycle through the MP3 file, extracting informa
tion as you go. The following procedure shows the code that extracts this informa
tion as
well as creates several important variables to use later on:

Option Explicit
Private Type TagInfo
Tag As String * 3
Songname As String * 30
artist As String * 30
album As String * 30
year As String * 4
comment As String * 30
genre As String * 1
End Type

Dim FileName As String
Dim CurrentTag As TagInfo

Private Sub Form1_Load()
Dim temp As String
On Error Resume Next

FileName = App.Path & "\myMP3.mp3"
Open FileName For Binary As #1
With CurrentTag
Get #1, FileLen(FileName) - 127, .Tag
If Not .Tag = "TAG" Then
label8.Caption = "No tag"
Close #1
Exit Sub
End If
Get #1, , .Songname
Get #1, , .artist
Get #1, , .album
Get #1, , .year
Get #1, , .comment
Get #1, , .genre
Close #1

txtTitle = RTrim(.Songname)
txtArtist = RTrim(.artist)
txtAlbum = RTrim(.album)
txtYear = RTrim(.year)
txtComment = RTrim(.comment)

Temp = RTrim(.genre)
txtGenreCode = Asc(Temp)
Combo1.ListIndex = CInt(txtGenreCode) - 1
End With
End Sub

Notice that the code has to handle the genre character a little differently.
That's because ID3 stores this data as a single ASCII character. To match up the
actual number with its corresponding description -- say contained in a combobox--
the procedure converts the ASCII to a number, and then looks up that number in th
e combobox.


=============================================================



70,024

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧