public TrackData NewTrackData(
            UserSongClip clip,
            BeatStructureMadmom bsm,
            LocationMode locationMode)
        {
            TrackData trackData = new TrackData();

            trackData.originalFilePath  = clip.originalFilePath;
            trackData.originalTrackName = clip.trackData.originalTrackName;
            trackData.originalArtist    = clip.trackData.originalArtist;
            trackData.trackId           = new TrackId(clip.originalFilePath);
            trackData.bpm = bsm._beatList.AverageBpm;
            trackData.beatStrucureJSON = BeatStructureToJSON(bsm);
            trackData.duration         = clip.trackData.duration;
            trackData.locationMode     = locationMode;
            trackData.firstBeatOffset  = bsm.Beats[0]._triggerTime;
            SaveTrackData(trackData);
            TrackDefinition trackDefinition = new TrackDefinition();

            trackDefinition.locationMode = locationMode;
            trackDefinition.trackId      = trackData.trackId;
            trackDefinition.tagLibTitle  = trackData.originalTrackName;
            trackDefinition.tagLibArtist = trackData.originalArtist;
            trackDefinition.duration     = trackData.duration;
            trackDefinition.bpm          = trackData.bpm;
            trackDefinition.trackData    = trackData;
            trackDefinition.SaveTrackDefinition();
            this.trackDefinitionsPlayer.Add(trackDefinition);
            return(trackData);
        }
        public TrackData LegacyToTrackData(string trackMD5, string originalFilePath)
        {
            TrackData trackData = new TrackData();
            var       file      = new ATL.Track(originalFilePath);

            trackData.originalTrackName = file.Title;
            trackData.trackId           = new TrackId();
            trackData.trackId.trackId   = trackMD5;
            trackData.duration          = (float)file.Duration;
            trackData.locationMode      = LocationMode.PlayerData;
            trackData.originalFilePath  = originalFilePath;
            if (string.IsNullOrEmpty(trackData.originalTrackName))
            {
                trackData.originalTrackName = Path.GetFileNameWithoutExtension(originalFilePath);
            }
            BeatStructureMadmom beatStructure = this.ReadBeatStructureFromFile(trackMD5);

            trackData.bpm = beatStructure.AverageBpm;
            trackData.beatStrucureJSON = this.BeatStructureToJSON(beatStructure);
            this.SaveTrackData(trackData);
            return(trackData);
        }
 public string BeatStructureToJSON(BeatStructureMadmom beatStructure) => JsonConvert.SerializeObject(beatStructure);