Beispiel #1
0
 /// <summary>
 ///     Removes the shuffler details for a track
 /// </summary>
 /// <param name="track">The track.</param>
 public void RemoveShufflerDetails(Track track)
 {
     if (!track.IsShufflerTrack)
     {
         return;
     }
     ExtenedAttributesHelper.SaveExtendedAttributes(track.Description, new Dictionary <string, string>());
     LoadTrack(track.Filename);
 }
Beispiel #2
0
        /// <summary>
        ///     Gets the previous track.
        /// </summary>
        /// <returns>The previous track</returns>
        private Track GetPreviousTrack()
        {
            var prevTrack = PlaylistControl.GetPreviousTrack();

            if (prevTrack == null)
            {
                return(null);
            }

            var track = BassPlayer.LoadTrack(prevTrack.Filename);

            BassPlayer.LoadTrackAudioData(track);
            ExtenedAttributesHelper.LoadExtendedAttributes(track);
            return(track);
        }
Beispiel #3
0
        public static void SetRank(List <Track> tracks, int rank)
        {
            foreach (var track in tracks)
            {
                track.Rank = rank;

                if (BassPlayer.IsTrackLoaded(track.Filename))
                {
                    var bassTrack = BassPlayer.LoadTrack(track.Filename);
                    bassTrack.Rank = track.Rank;
                }

                ExtenedAttributesHelper.SetExtendedAttribute(track.Description, "Rank", track.Rank.ToString());
            }
            Task.Run(() => ExtenedAttributesHelper.SaveToDatabase());
        }
Beispiel #4
0
        private void ImportExternalShufflerTrack(string file, string externalFolder)
        {
            var externalTrack  = TrackHelper.LoadTrack(file, false);
            var isShufflerFile = ExtenedAttributesHelper.HasExtendedAttributes(externalTrack.Description);

            if (!isShufflerFile)
            {
                return;
            }
            if (GetTrack(externalTrack.Artist, externalTrack.Title) != null)
            {
                return;
            }

            var newFile = CopyExternalFileToLibraryFolder(file, externalFolder);

            LoadTrack(newFile);
        }
Beispiel #5
0
        private void LoadFromDatabase()
        {
            Library.LoadFromDatabase();
            TrackSampleLibrary.LoadFromCache();

            MixLibrary.AvailableTracks = Library.GetTracks();
            MixLibrary.LoadFromDatabase();

            ExtenedAttributesHelper.ShufflerFolder = Library.ShufflerFolder;
            ExtenedAttributesHelper.LoadFromDatabase();
            Library.LoadAllExtendedAttributes();

            AutomationAttributesHelper.ShufflerFolder = Library.ShufflerFolder;
            AutomationAttributesHelper.LoadFromDatabase();

            CollectionHelper.LoadFromDatabase();

            LoopLibrary.LoadFromCache();
        }
Beispiel #6
0
        /// <summary>
        ///     Saves the track.
        /// </summary>
        private void SaveTrack()
        {
            UpdateData();
            UpdateCurrentSample();

            AutomationAttributes.TrackSamples.Clear();
            foreach (var sample in CurrentSamples.Where(sample => sample.Length != 0 || sample.Start != 0))
            {
                AutomationAttributes.TrackSamples.Add(sample);
            }

            ExtenedAttributesHelper.SaveExtendedAttributes(Track);
            AutomationAttributesHelper.SaveAutomationAttributes(Track.Description, AutomationAttributes);
            BassPlayer.ReloadTrack(Track.Filename);

            _saved = true;

            Close();
        }
        /// <summary>
        ///     Loads a track for playing as the raw loop track.
        /// </summary>
        /// <param name="filename">The filename.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception">Cannot find file  + filename</exception>
        public Track LoadRawLoopTrack(string filename)
        {
            if (!File.Exists(filename))
            {
                throw new Exception("Cannot find file " + filename);
            }

            if (RawLoopTrack != null)
            {
                UnloadRawLoopTrack();
            }

            var track = new Track
            {
                Id       = _nextTrackId++,
                Filename = filename
            };

            SetArtistAndTitle(track, "", "");
            LoadTagData(track);
            ExtenedAttributesHelper.LoadExtendedAttributes(track);
            LoadTrackAudioData(track);

            // DebugHelper.WriteLine("Loaded raw loop track " + track.Description);

            // set track sync event
            track.SyncProc         = OnTrackSync;
            track.CurrentStartLoop = 0;
            track.CurrentEndLoop   = 0;
            track.RawLoopStart     = 0;
            track.RawLoopEnd       = track.Length;

            // DebugHelper.WriteLine("Loading raw loop track " + track.Description);

            AudioStreamHelper.AddToMixer(track, _rawLoopMixer);
            RawLoopTrack = track;

            SetRawLoopPositions(0, track.Length, 0);

            return(RawLoopTrack);
        }
        /// <summary>
        ///     Loads the shuffler details for a track
        /// </summary>
        /// <param name="track">The track.</param>
        public static Dictionary <string, string> LoadShufflerDetails(Track track)
        {
            //if(track.Title.Contains("Escobar"))
            //    DebugHelper.WriteLine("Stop");

            track.Key = KeyHelper.ParseKey(track.Key);

            track.IsShufflerTrack = ExtenedAttributesHelper.HasExtendedAttributes(track.Description);

            if (!track.IsShufflerTrack)
            {
                return(null);
            }

            var attributes = ExtenedAttributesHelper.GetExtendedAttributes(track.Description);


            if (attributes.ContainsKey("Rank"))
            {
                track.Rank = ConversionHelper.ToInt(attributes["Rank"], 1);
            }

            decimal start = 0;

            if (attributes.ContainsKey("FadeIn"))
            {
                start = ConversionHelper.ToDecimal(attributes["FadeIn"], start);
            }
            var end = track.Length;

            if (attributes.ContainsKey("FadeOut"))
            {
                end = ConversionHelper.ToDecimal(attributes["FadeOut"], end);
            }
            var length = end - start;

            var inLoopCount = 0;

            if (attributes.ContainsKey("StartLoopCount"))
            {
                inLoopCount = ConversionHelper.ToInt(attributes["StartLoopCount"], inLoopCount);
            }

            decimal inLoopLength = 0;

            if (attributes.ContainsKey("FadeInLengthInSeconds"))
            {
                inLoopLength = ConversionHelper.ToDecimal(attributes["FadeInLengthInSeconds"]);
            }
            if (inLoopLength > 0)
            {
                track.StartBpm = BpmHelper.GetBpmFromLoopLength(Convert.ToDouble(inLoopLength));
            }

            inLoopCount = inLoopCount - 1;
            if (inLoopCount > 0)
            {
                length = length + inLoopCount * inLoopLength;
            }

            decimal skipLength = 0;

            if (attributes.ContainsKey("SkipLengthInSeconds"))
            {
                skipLength = ConversionHelper.ToDecimal(attributes["SkipLengthInSeconds"]);
            }
            if (skipLength > 0)
            {
                length = length - skipLength;
            }

            track.PowerDown = false;
            if (attributes.ContainsKey("PowerDown"))
            {
                track.PowerDown = ConversionHelper.ToBoolean(attributes["PowerDown"]);
            }

            if (attributes.ContainsKey("Key"))
            {
                track.Key = KeyHelper.ParseKey(attributes["Key"]);
            }

            decimal outLoopLength = 0;

            if (attributes.ContainsKey("FadeOutLengthInSeconds"))
            {
                outLoopLength = ConversionHelper.ToDecimal(attributes["FadeOutLengthInSeconds"], 0);
            }
            if (outLoopLength > 0)
            {
                track.EndBpm = BpmHelper.GetBpmFromLoopLength(Convert.ToDouble(outLoopLength));
            }

            track.Length = length;

            if (attributes.ContainsKey("StartBPM"))
            {
                track.StartBpm = BpmHelper.NormaliseBpm(ConversionHelper.ToDecimal(attributes["StartBPM"], track.Bpm));
            }
            if (attributes.ContainsKey("EndBPM"))
            {
                track.EndBpm = BpmHelper.NormaliseBpm(ConversionHelper.ToDecimal(attributes["EndBPM"], track.Bpm));
            }

            track.Bpm = BpmHelper.GetAdjustedBpmAverage(track.StartBpm, track.EndBpm);

            return(attributes);
        }