public TagModel(string file) { TAG_INFO tagInfo = new TAG_INFO(); tagInfo = BassTags.BASS_TAG_GetFromFile(file); if (tagInfo == null) { BitRate = 0; } else { BitRate = tagInfo.bitrate; Freg = tagInfo.channelinfo.freq; Channels = ChannelsDist[tagInfo.channelinfo.chans]; Artist = tagInfo.artist; Album = tagInfo.album; if (tagInfo.title == "") { Title = main.GetFileName(file); } else { Title = tagInfo.title; } Year = tagInfo.year; } }
public Song(string file) { TAG_INFO tag_inf = new TAG_INFO(); tag_inf = BassTags.BASS_TAG_GetFromFile(file); if (tag_inf.title == "") { Title = MainWindow.GetFileName(file); } else { Title = tag_inf.title; } AlbumName = tag_inf.album; ArtistName = tag_inf.artist; Year = tag_inf.year; Inf = tag_inf.bitrate + "KBps, " + tag_inf.channelinfo.chans; TagLib.File file_TAG = TagLib.File.Create(file); TrackNumber = file_TAG.Tag.Track.ToString(); int minutes = (int)file_TAG.Properties.Duration.TotalMinutes; int seconds = file_TAG.Properties.Duration.Seconds; string sec = seconds.ToString(); if (sec.Length == 1) { sec = "0" + sec; } Lenght = minutes.ToString() + ":" + sec; }
public Tag(string path, bool isRadio) { TAG_INFO tagInfo = null; if (isRadio) { if (CommonInterface.IsValid(path, CommonInterface.URLPattern) && !CommonInterface.IsValid(path, CommonInterface.PathPattern2)) { tagInfo = new TAG_INFO(path); } } else { tagInfo = BassTags.BASS_TAG_GetFromFile(path); } if (tagInfo != null) { bitRate = tagInfo.bitrate; freq = tagInfo.channelinfo.freq; channels = ChannelsDict[tagInfo.channelinfo.chans]; artist = tagInfo.artist; album = tagInfo.album; genre = tagInfo.genre; title = tagInfo.title; year = tagInfo.year; this.path = path; fileName = System.IO.Path.GetFileName(path); image = tagInfo.PictureGetImage(0); error = false; } else { error = true; } }
private void ReadInfoFromFile(Song sInfo) { TAG_INFO tagInfo = new TAG_INFO(sInfo.FileUrl); try { tagInfo = BassTags.BASS_TAG_GetFromFile(sInfo.FileUrl); sInfo.Size = string.Format("{0:F}M", new FileInfo(sInfo.FileUrl).Length / Math.Pow(1024, 2)); sInfo.Album = tagInfo.album; sInfo.Artist = tagInfo.artist; sInfo.Title = tagInfo.title; sInfo.PublicDate = tagInfo.year; sInfo.Company = tagInfo.publisher; sInfo.PicUrl = sInfo.Album == "" ? sInfo.FileName : sInfo.Album; sInfo.Duration = TimeSpan.FromSeconds(tagInfo.duration); if (tagInfo.PictureGetImage(0) != null) { SavePicToLocal(tagInfo.PictureGetImage(0), tagInfo.PictureGetType(0), sInfo.PicUrl); } else { SavePicToLocal(sInfo.FileUrl, sInfo.PicUrl); } } catch (Exception ex) { Debug.Write(ex.Message); } }
/// <summary> /// Recode the file /// </summary> /// <param name = "fileName">Initial file</param> /// <param name = "outFileName">Target file</param> /// <param name = "targetSampleRate">Target sample rate</param> public void RecodeTheFile(string fileName, string outFileName, int targetSampleRate) { int stream = Un4seen.Bass.Bass.BASS_StreamCreateFile(fileName, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_MONO | BASSFlag.BASS_SAMPLE_FLOAT); TAG_INFO tags = new TAG_INFO(); BassTags.BASS_TAG_GetFromFile(stream, tags); int mixerStream = BassMix.BASS_Mixer_StreamCreate(targetSampleRate, 1, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_MONO | BASSFlag.BASS_SAMPLE_FLOAT); if (BassMix.BASS_Mixer_StreamAddChannel(mixerStream, stream, BASSFlag.BASS_MIXER_FILTER)) { WaveWriter waveWriter = new WaveWriter(outFileName, mixerStream, true); const int length = 5512 * 10 * 4; float[] buffer = new float[length]; while (true) { int bytesRead = Un4seen.Bass.Bass.BASS_ChannelGetData(mixerStream, buffer, length); if (bytesRead == 0) { break; } waveWriter.Write(buffer, bytesRead); } waveWriter.Close(); } else { throw new Exception(Un4seen.Bass.Bass.BASS_ErrorGetCode().ToString()); } }
public void PlayId(string id) { if (SoundInitialized) { DataProvider.currentlyPlayed = id; TagInfo = new TAG_INFO(); BassStream = Bass.BASS_StreamCreateFileUser(BASSStreamSystem.STREAMFILE_NOBUFFER, BASSFlag.BASS_STREAM_AUTOFREE, DataProvider.bassStreamingProc, IntPtr.Zero); if (BassStream == 0) { BASSError err = Bass.BASS_ErrorGetCode(); throw new Exception("Cannot create stream: " + err.ToString()); } if (BassTags.BASS_TAG_GetFromFile(BassStream, TagInfo)) { // nop } else { Program.logging.addToLog("Cannot get tags for stream " + BassStream); } BassTimer.Start(); Bass.BASS_ChannelPlay(BassStream, false); } }
/// <summary> /// Считать альбомарт из файла /// если нет данных вернет null /// </summary> /// <param name="path"></param> /// <returns></returns> private Image GetAlbumArt(string path) { Image img = null; if (!path.StartsWith("http")) //если не поток { int _stream = Bass.BASS_StreamCreateFile(path, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN); if (_stream != 0)//если успешно { TAG_INFO tagInfo = new TAG_INFO(path); if (BassTags.BASS_TAG_GetFromFile(_stream, tagInfo)) { img = (Image)tagInfo.PictureGetImage(0); } } Bass.BASS_StreamFree(_stream);//освобождаем поток } else { if (RecordImages.ContainsKey(path)) { img = RecordImages[path]; } } return(img); }
public void Play(string fileName, int vol = 100) { if (_handle != 0) { Stop(); _currentPosition = 0; OnTrackPositionProgressChanged(new TrackPositionProgrressChangedEventHandlerArgs() { PositionSeconds = _currentPosition }); } _handle = Bass.BASS_StreamCreateFile(fileName, 0, 0, BASSFlag.BASS_DEFAULT); if (_handle != 0) { CurrentTrackLength = GetTrackLength(); TAG_INFO tagInfo = BassTags.BASS_TAG_GetFromFile(fileName); OnTrackChanged(new TrackChangedEventHandlerArgs() { TrackLength = CurrentTrackLength, Title = tagInfo.title, Album = tagInfo.album, Artist = tagInfo.artist, Image = tagInfo.PictureCount > 0 ? tagInfo.PictureGetImage(0): null, Year = tagInfo.year }); Bass.BASS_ChannelSetAttribute(_handle, BASSAttribute.BASS_ATTRIB_VOL, vol / 100f); Bass.BASS_ChannelPlay(_handle, false); _timer.Start(); } }
public static void OutputTags(string file) { var tagInfo = BassTags.BASS_TAG_GetFromFile(file); Console.WriteLine(" album: " + tagInfo.album); Console.WriteLine(" artist: " + tagInfo.artist); Console.WriteLine("bitrate: " + tagInfo.bitrate); Console.WriteLine(""); }
public TrackInfo(string filename) { Tags = BassTags.BASS_TAG_GetFromFile(filename); Duration = Tags.duration.ToString(); if (Tags == null) { throw new ArgumentException("File not valid!"); } }
public TAG_INFO FillInputFileTags(string inputFileText) { m_inputFileTags = BassTags.BASS_TAG_GetFromFile(inputFileText); if (m_outputFiles == null) { var sound = new SoundFile(tag: m_inputFileTags); m_outputFiles = new OutputFiles(sound); } return(m_inputFileTags); }
/// <summary> /// Initializes a new instance of the <see cref="BassSongInfo"/> class. /// </summary> /// <param name="Path">The file's path to read</param> public BassSongInfo(string Path) : this() { #region Error checking if (!File.Exists(Path)) { throw new FileNotFoundException($"{Path} does not exists.", Path); } #endregion this.tagInfo = BassTags.BASS_TAG_GetFromFile(Path); }
/// <summary> /// Initializes a new instance of the <see cref="BassSongInfo"/> class. /// </summary> /// <param name="ChannelID">The BASS handle of the channel</param> /// <exception cref="ArgumentException">when ChannelID is 0</exception> public BassSongInfo(int ChannelID) : this() { #region Error checking if (ChannelID == 0) { throw new ArgumentException($"{nameof(ChannelID)} cannot be 0."); } #endregion this.tagInfo = new TAG_INFO(); BassTags.BASS_TAG_GetFromFile(ChannelID, this.tagInfo); }
static public PlaylistItem GetTags(string path) { TAG_INFO tagInfo = new TAG_INFO(path); if (!new System.Text.RegularExpressions.Regex("^(ftp|http)").IsMatch(path)) { string extension = new System.IO.FileInfo(path).Extension; if (!MainForm.supportedExts.Contains("*" + extension.ToLower())) { MessageBox.Show("File \"" + path + "\" is an unsupported file type.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } int type = PlaylistItem.TYPE_STREAM_FILE; if (Bass.SupportedMusicExtensions.Contains("*" + extension)) { type = PlaylistItem.TYPE_MUSIC; } tagInfo = BassTags.BASS_TAG_GetFromFile(path); if (tagInfo == null) { return(new PlaylistItem("?", "?", "?", "?", path, type)); } else { return(new PlaylistItem(tagInfo.track, tagInfo.title, tagInfo.artist, tagInfo.album, path, type)); } } else { if (MainForm.stream != 0) { bool tagsAvailable = BassTags.BASS_TAG_GetFromURL(MainForm.stream, tagInfo); if (tagsAvailable) { return(new PlaylistItem(tagInfo.track, tagInfo.title, tagInfo.artist, tagInfo.album, path, PlaylistItem.TYPE_STREAM_URL)); } else { return(new PlaylistItem("?", "?", "?", "?", path, PlaylistItem.TYPE_STREAM_URL)); } } else { return(new PlaylistItem("?", "?", "?", "?", path, PlaylistItem.TYPE_STREAM_URL)); } } }
public Track(string filename) { Filename = filename; Tags = BassTags.BASS_TAG_GetFromFile(Filename); if (Tags == null) { throw new ArgumentException("File not valid!"); } // we already create a stream handle // might not be the best place here (especially when having a larger playlist), but for the demo this is okay ;) CreateStream(); }
public TagModel(string file) { TAG_INFO tagInfo = new TAG_INFO(); tagInfo = BassTags.BASS_TAG_GetFromFile(file); BitRate = tagInfo.bitrate; Freq = tagInfo.channelinfo.freq; Channels = ChannelsDist[tagInfo.channelinfo.chans]; Artist = tagInfo.artist; Album = tagInfo.album; Title = (tagInfo.title == "") ? Vars.GetFileName(file) : tagInfo.title; Year = (tagInfo.year != "") ? tagInfo.year : DateTime.Now.Year.ToString(); Pictute = (tagInfo.PictureCount > 0) ? tagInfo.PictureGetImage(0) : Properties.Resources.misic; }
/// <summary> ///Теги для аудиофайла /// </summary> /// <param name="file"></param> public TagModel(string file) { TAG_INFO tagInfo = new TAG_INFO(); tagInfo = BassTags.BASS_TAG_GetFromFile(file); Artist = tagInfo.artist; if (tagInfo.title == "") { Title = Vars.GetFileName(file); } else { Title = tagInfo.title; } }
private void buttonPlay_Click(object sender, System.EventArgs e) { this.label1.Text = ""; Bass.BASS_StreamFree(_Stream); this.timerBPM.Stop(); // test PlugIns... // after additional Add-Ons have been loaded, // they will be supported in the standard BASS_StreamCreateFile methods if (_FileName != String.Empty) { // create the stream _Stream = Bass.BASS_StreamCreateFile(_FileName, 0, 0, BASSFlag.BASS_DEFAULT); // update the tags _tagInfo = new TAG_INFO(_FileName); if (BassTags.BASS_TAG_GetFromFile(_Stream, _tagInfo)) { // and display what we get this.textBoxAlbum.Text = _tagInfo.album; this.textBoxArtist.Text = _tagInfo.artist; this.textBoxTitle.Text = _tagInfo.title; this.textBoxComment.Text = _tagInfo.comment; this.textBoxGenre.Text = _tagInfo.genre; this.textBoxYear.Text = _tagInfo.year; } // play the stream if (_Stream != 0 && Bass.BASS_ChannelPlay(_Stream, false)) { //playing... BASS_CHANNELINFO info = new BASS_CHANNELINFO(); if (Bass.BASS_ChannelGetInfo(_Stream, info)) { // start the BPMCounter _bpm.Reset(info.freq); this.timerBPM.Start(); // display the channel info.. this.label1.Text = String.Format("Type={0}, Channels={1}, OrigRes={2}", Utils.BASSChannelTypeToString(info.ctype), info.chans, info.origres); } } else { MessageBox.Show(this, "Error: " + Enum.GetName(typeof(BASSError), Bass.BASS_ErrorGetCode())); } } }
/// <summary> /// Initializes a new instance of the <see cref="BassSongInfo"/> class. /// </summary> /// <param name="Info">A <see cref="RemoteResourceInfo"/> instance that holds informations about the requested URI.</param> public BassSongInfo(RemoteResourceInfo Info) { #region Error checking if (Info == null) { throw new ArgumentNullException(nameof(Info)); } if (!Info.RequestSucceeded) { throw new ArgumentException($"{nameof(Info)} represents a failed request."); } if (Info.IsPlaylist) { throw new ArgumentException($"{nameof(Info)} is a playlist, not a media resource."); } #endregion if (Info.IsInternetRadioStream) { int Channel = Bass.BASS_StreamCreateURL( url: Info.RequestUri.ToString(), offset: 0, flags: BASSFlag.BASS_STREAM_STATUS, proc: null, user: IntPtr.Zero ); if (Channel == 0) { throw new Exception("Could not connect to the radio stream."); } this.tagInfo = new TAG_INFO(); if (!BassTags.BASS_TAG_GetFromURL(Channel, this.tagInfo)) { throw new Exception("Could not retrieve informations about the radio stream."); } } else { this.tagInfo = BassTags.BASS_TAG_GetFromFile(Info.RequestUri.ToString()); } }
public TagModel(string file) { TAG_INFO tagInfo = new TAG_INFO(); tagInfo = BassTags.BASS_TAG_GetFromFile(file); BitRate = tagInfo.bitrate; Freq = tagInfo.channelinfo.freq; Channels = channels[tagInfo.channelinfo.chans]; Artist = tagInfo.artist; Album = tagInfo.album; if (tagInfo.title == "") { Title = TrackList.GetFileName(file); } else { Title = tagInfo.title; } Year = tagInfo.year; }
public TagInfo(string file) { TAG_INFO tag_info = new TAG_INFO(); tag_info = BassTags.BASS_TAG_GetFromFile(file); bitRate = tag_info.bitrate; freq = tag_info.channelinfo.freq; channels = channelDisc[tag_info.channelinfo.chans]; artist = tag_info.artist; album = tag_info.album; if (tag_info.title == "") { title = Vars.GetFileName(file); } else { title = tag_info.title; } years = tag_info.year; }
static public void ParseFilesBass() { if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero, null)) { foreach (string s in m_files) { // Console.WriteLine(s); dtStart3 = DateTime.Now; //TagLib.File trackInfo = TagLib.File.Create(s); TAG_INFO tagInfo = BassTags.BASS_TAG_GetFromFile(s); //if (tagInfo != null) //Console.WriteLine(tagInfo.album + " " + tagInfo.artist + " " + tagInfo.year); //Console.WriteLine(trackInfo.Tag.Album + " " + trackInfo.Tag.FirstArtist + " " + trackInfo.Tag.Year); dtFinish3 = DateTime.Now; dtSpan3 = dtFinish3 - dtStart3; string ms = dtSpan3.TotalMilliseconds.ToString(); Console.WriteLine("Bass: " + ms + "ms"); } } }
public tagModel(string file) { TAG_INFO tagInfo = new TAG_INFO(); tagInfo = BassTags.BASS_TAG_GetFromFile(file); BitRate = tagInfo.bitrate; freq = tagInfo.channelinfo.freq; channels = chanelDict[tagInfo.channelinfo.chans]; artist = tagInfo.artist; album = tagInfo.album; if (tagInfo.title == "") { title = Main.GetFileName(file); } else { title = tagInfo.title; } year = tagInfo.year; }
public static float GetReplayGain(Track Track, ReplayGainMode Type, bool FallBack) { if (Type == ReplayGainMode.Off) { return(0.0f); } switch (Type) { case ReplayGainMode.Album: if (!Track.HasReplayGainInfoAlbum) { if (Track.HasReplayGainInfoTrack) { return(Track.ReplayGainTrack); } else { TrackWriter.LoadReplayGain(Track, BassTags.BASS_TAG_GetFromFile(Track.FilePath, true, false)); } } return(Track.ReplayGainAlbum); case ReplayGainMode.Track: if (!Track.HasReplayGainInfoTrack) { if (Track.HasReplayGainInfoAlbum) { return(Track.ReplayGainAlbum); } else { TrackWriter.LoadReplayGain(Track, BassTags.BASS_TAG_GetFromFile(Track.FilePath, true, false)); } } return(Track.ReplayGainTrack); default: // off return(0.0f); } }
public tagInfo getTagInfo(string path) { tagInfo file = new tagInfo(); TAG_INFO fileTags = BassTags.BASS_TAG_GetFromFile(path, true, true); file.Title = fileTags.title; file.Genre = fileTags.genre; file.Artist = fileTags.artist; file.Album = fileTags.album; file.BitRate = fileTags.bitrate; file.Composer = fileTags.composer; int totalSeconds = (int)fileTags.duration; int seconds = totalSeconds % 60; int minutes = totalSeconds / 60; file.Duration = minutes + ":" + seconds; file.Path = fileTags.filename; return(file); }
public TagModel(string file) { TAG_INFO tagInfo = new TAG_INFO(); tagInfo = BassTags.BASS_TAG_GetFromFile(file); BitRate = tagInfo.bitrate; Freq = tagInfo.channelinfo.freq; Channels = ChannelsDict[tagInfo.channelinfo.chans]; Artist = tagInfo.artist; Album = tagInfo.album; if (tagInfo.title == "") { Title = Vars.GetFileName(file); } else { Title = tagInfo.title; } Year = tagInfo.year; Length = tagInfo.duration; Duration = ((int)Length); }
public MetaModel(string file) { TAG_INFO metaInfo = new TAG_INFO(); File = file; metaInfo = BassTags.BASS_TAG_GetFromFile(file); BitRate = metaInfo.bitrate; Freq = metaInfo.channelinfo.freq; Channels = ChannelsDict[metaInfo.channelinfo.chans]; Artist = metaInfo.artist; Album = metaInfo.album; if (metaInfo.title == "") { Title = DataVars.GetFileName(file); } else { Title = metaInfo.title; } Year = metaInfo.year; }
public TagModel(string file) { //создаем переменную для хранения тегов TAG_INFO tag_info = new TAG_INFO(); //вытаскиваем тег из файла tag_info = BassTags.BASS_TAG_GetFromFile(file); Bitrate = tag_info.bitrate; Freq = tag_info.channelinfo.freq; Channels = ChannelsDict[tag_info.channelinfo.chans]; Artist = tag_info.artist; Album = tag_info.album; //если нет заголовка песни, присваиваем название трека if (tag_info.title == "") { Title = Vars.GetFileName(file); } else { Title = tag_info.title; } Year = tag_info.year; }
public TagClass(string file) { TAG_INFO tagInfo = new TAG_INFO(); tagInfo = BassTags.BASS_TAG_GetFromFile(file); bitRate = tagInfo.bitrate; freq = tagInfo.channelinfo.freq; channels = channelsDict[tagInfo.channelinfo.chans]; artist = tagInfo.artist; album = tagInfo.album; if (tagInfo.title == "" || tagInfo.artist == "") { artist = TrackBase.GetFileArtist(file); title = TrackBase.GetFileTitle(file); } else { artist = tagInfo.artist; title = tagInfo.title; } year = tagInfo.year; }
private void GetTags(int number) { string filePath = Vars.Files[number]; FilePath = filePath; TagLib.File f = TagLib.File.Create(filePath); TBNumber.Text = f.Tag.Track.ToString(); TBSong.Text = f.Tag.Title; TBAlbum.Text = f.Tag.Album; foreach (string Artist in f.Tag.Performers) { TBBand.Text = Artist; } TBYear.Text = f.Tag.Year.ToString(); TAG_INFO tag_inf = new TAG_INFO(); tag_inf = BassTags.BASS_TAG_GetFromFile(filePath); TBBitrate.Text = tag_inf.bitrate + " KBps"; TBChannels.Text = tag_inf.channelinfo.ToString(); }