Exemple #1
0
 public HitsoundElement(
     string mapFolderName,
     string[] mapWaveFiles,
     GameMode gameMode,
     double offset,
     int track,
     TimingSamplesetType lineSample,
     HitsoundType hitsound,
     ObjectSamplesetType sample,
     ObjectSamplesetType addition,
     string customFile,
     float volume,
     float balance)
 {
     _mapFolderName = mapFolderName;
     _mapWaveFiles  = mapWaveFiles;
     GameMode       = gameMode;
     Offset         = offset;
     Track          = track;
     LineSample     = lineSample;
     Hitsound       = hitsound;
     Sample         = sample;
     Addition       = addition;
     CustomFile     = customFile;
     Volume         = volume;
     Balance        = balance;
     SetNamesWithoutTrack();
     SetFullPath();
 }
Exemple #2
0
 public static SoundElement CreateSlideSignal(double offset, float volume, float balance,
                                              string filePath, HitsoundType slideType)
 {
     return(new SoundElement
     {
         Offset = offset,
         Volume = volume,
         Balance = balance,
         FilePath = filePath,
         ControlType = SlideControlType.StartNew,
         SlideType = slideType
     });
 }
        private static IEnumerable <(string, HitsoundType)> GetHitsounds(HitsoundType type,
                                                                         string sampleStr, string additionStr)
        {
            if (type == HitsoundType.Tick)
            {
                yield return($"{additionStr}-slidertick", type);

                yield break;
            }

            if (type.HasFlag(HitsoundType.Slide))
            {
                yield return($"{sampleStr}-sliderslide", type);
            }
            if (type.HasFlag(HitsoundType.SlideWhistle))
            {
                yield return($"{additionStr}-sliderwhistle", type);
            }

            if (type.HasFlag(HitsoundType.Slide) || type.HasFlag(HitsoundType.SlideWhistle))
            {
                yield break;
            }

            if (type.HasFlag(HitsoundType.Whistle))
            {
                yield return($"{additionStr}-hitwhistle", type);
            }
            if (type.HasFlag(HitsoundType.Clap))
            {
                yield return($"{additionStr}-hitclap", type);
            }
            if (type.HasFlag(HitsoundType.Finish))
            {
                yield return($"{additionStr}-hitfinish", type);
            }
            if (type.HasFlag(HitsoundType.Normal) ||
                (type & HitsoundType.Normal) == 0)
            {
                yield return($"{sampleStr}-hitnormal", type);
            }
        }
        private IEnumerable <(string, HitsoundType)> AnalyzeHitsoundFiles(
            HitsoundType itemHitsound, ObjectSamplesetType itemSample, ObjectSamplesetType itemAddition,
            TimingPoint timingPoint, RawHitObject hitObject,
            HashSet <string> waves)
        {
            if (!string.IsNullOrEmpty(hitObject.FileName))
            {
                return(new[]
                {
                    ValueTuple.Create(
                        _cache.GetFileUntilFind(_sourceFolder,
                                                Path.GetFileNameWithoutExtension(hitObject.FileName)),
                        itemHitsound
                        )
                });
            }

            var tuples = new List <(string, HitsoundType)>();

            // hitnormal, sliderslide
            var sampleStr = itemSample != ObjectSamplesetType.Auto
                ? itemSample.ToHitsoundString(null)
                : timingPoint.TimingSampleset.ToHitsoundString();

            // hitclap, hitfinish, hitwhistle, slidertick, sliderwhistle
            string additionStr = itemAddition.ToHitsoundString(sampleStr);

            if (hitObject.ObjectType == HitObjectType.Slider && hitObject.SliderInfo.EdgeHitsounds == null)
            {
                var hitsounds = GetHitsounds(itemHitsound, sampleStr, additionStr);
                tuples.AddRange(hitsounds);
            }
            else
            {
                var hitsounds = GetHitsounds(itemHitsound, sampleStr, additionStr);
                tuples.AddRange(_osuFile.General.Mode == GameMode.Mania
                    ? hitsounds.Take(1)
                    : hitsounds);
            }

            for (var i = 0; i < tuples.Count; i++)
            {
                var fileNameWithoutIndex = tuples[i].Item1;
                var hitsoundType         = tuples[i].Item2;

                int    baseIndex = hitObject.CustomIndex > 0 ? hitObject.CustomIndex : timingPoint.Track;
                string indexStr  = baseIndex > 1 ? baseIndex.ToString() : "";

                var fileNameWithoutExt = fileNameWithoutIndex + indexStr;

                string filePath;
                if (timingPoint.Track == 0)
                {
                    filePath = Path.Combine(Domain.DefaultPath, fileNameWithoutExt + Information.WavExtension);
                }
                else if (waves.Contains(fileNameWithoutExt))
                {
                    filePath = _cache.GetFileUntilFind(_sourceFolder, fileNameWithoutExt);
                }
                else
                {
                    filePath = Path.Combine(Domain.DefaultPath, fileNameWithoutIndex + Information.WavExtension);
                }

                tuples[i] = (filePath, hitsoundType);
            }

            return(tuples);
        }