/// <summary> /// 获得DSD音乐信息 /// </summary> /// <param name="path">音乐路径</param> /// <param name="type">获得的信息类型</param> /// <returns></returns> public string GetDSDInfo(string path, GetInfoType type) { int stream = 0; string content = null; stream = Bass.BASS_StreamCreateFile(path, 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT); switch (type) { case GetInfoType.Title: content = Bass.BASS_ChannelGetTagsDSDTitle(stream); break; //标题 case GetInfoType.Artist: content = Bass.BASS_ChannelGetTagsDSDArtist(stream); break; //艺术家 case GetInfoType.Length: { if (Convert.ToInt32(Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetLength(stream))) != -1) { content = Convert.ToString(Convert.ToInt32(Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetLength(stream)))); } else { content = "文件损坏"; MessageBox.Show("异常:不支持的格式或文件已损坏。\n错误路径:" + path); } break; //曲长 } } return(content); }
/// <summary> /// 使用Bass获得歌曲艺术家 /// </summary> /// <param name="stream">Bass音乐流</param> /// <param name="extension">音乐格式(扩展名)</param> /// <returns>艺术家</returns> private string Bass_Artist(string Path, int stream, string extension) { string content = null; switch (extension) { case ".mp3": case ".m4a": case ".flac": case ".aif": case ".aac": { string[] tags = Bass.BASS_ChannelGetTagsID3V2(stream); string[] tags7 = Bass.BASS_ChannelGetTagsID3V1(stream); string[] tags8 = Bass.BASS_ChannelGetTagsArrayNullTermAnsi(stream, BASSTag.BASS_TAG_FLAC_CUE); string[] tags9 = Bass.BASS_ChannelGetTagsArrayNullTermAnsi(stream, BASSTag.BASS_TAG_FLAC_PICTURE); BASS_TAG_FLAC_PICTURE[] tags10 = Bass.BASS_ChannelGetTagsFLACPictures(stream); string[] tags2 = Bass.BASS_ChannelGetTagsMETA(stream); string[] tags3 = Bass.BASS_ChannelGetTagsBWF(stream); string[] tags4 = Bass.BASS_ChannelGetTagsICY(stream); string[] tags5 = Bass.BASS_ChannelGetTagsMF(stream); string[] tags6 = Bass.BASS_ChannelGetTagsRIFF(stream); if (tags != null) { foreach (string x in tags) { if (x.Contains("TPE")) { content = x.Remove(0, 5); break; } } } break; } case ".ogg": { string[] tags = Bass.BASS_ChannelGetTagsOGG(stream); if (tags != null) { foreach (string x in tags) { if (x.Contains("ARTIST")) { content = x.Remove(0, 7); break; } else { content = null; } } } break; } case ".ape": { string[] tags = Bass.BASS_ChannelGetTagsAPE(stream); if (tags != null) { foreach (string x in tags) { if (x.Contains("Artist")) { content = x.Split(new char[] { '=' })[1]; break; } } } break; } case ".dff": case ".dsf": { stream = Bass.BASS_StreamCreateFile(Path, 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT); content = Bass.BASS_ChannelGetTagsDSDArtist(stream); break; } } return(content); }