Esempio n. 1
0
        /// <summary>
        /// Sets the hitsound to the <see cref="TimelineObject"/>
        /// </summary>
        /// <param name="hitsound"></param>
        public void SetHitsound(Hitsound hitsound)
        {
            Normal  = false;
            Whistle = false;
            Finish  = false;
            Clap    = false;
            switch (hitsound)
            {
            case Hitsound.Normal:
                Normal = true;
                return;

            case Hitsound.Whistle:
                Whistle = true;
                return;

            case Hitsound.Finish:
                Finish = true;
                return;

            case Hitsound.Clap:
                Clap = true;
                return;

            default:
                throw new ArgumentOutOfRangeException(nameof(hitsound), hitsound, null);
            }
        }
Esempio n. 2
0
        private void AddFirstIdenticalFilename(SampleSet sampleSet, Hitsound hitsound, int index, List <string> samples, GameMode mode, bool useFilename, string mapDir, Dictionary <string, string> firstSamples, bool includeDefaults)
        {
            string filename        = GetFileName(sampleSet, hitsound, index, mode);
            string samplePath      = Path.Combine(mapDir, filename);
            string fullPathExtLess = Path.Combine(
                Path.GetDirectoryName(samplePath) ?? throw new InvalidOperationException(),
                Path.GetFileNameWithoutExtension(samplePath));

            // Get the first occurence of this sound to not get duplicated
            if (firstSamples.Keys.Contains(fullPathExtLess))
            {
                if (!useFilename)
                {
                    samples.Add(Path.GetFileName(firstSamples[fullPathExtLess]));
                }
            }
            else
            {
                // Sample doesn't exist
                if (!useFilename && includeDefaults)
                {
                    samples.Add(GetFileName(sampleSet, hitsound, 0, mode));
                }
            }
        }
Esempio n. 3
0
 public Sample(HitsoundLayer hl)
 {
     _sampleArgs = hl.SampleArgs.Copy();
     _priority   = hl.Priority;
     _sampleSet  = hl.SampleSet;
     _hitsound   = hl.Hitsound;
 }
Esempio n. 4
0
 public Sample(SampleSet sampleSet, Hitsound hitsound, SampleGeneratingArgs sampleArgs, int priority)
 {
     _sampleArgs = sampleArgs;
     _priority   = priority;
     _sampleSet  = sampleSet;
     _hitsound   = hitsound;
 }
Esempio n. 5
0
 public Sample()
 {
     _sampleArgs = new SampleGeneratingArgs();
     _priority   = 0;
     _sampleSet  = SampleSet.Normal;
     _hitsound   = Hitsound.Normal;
 }
Esempio n. 6
0
        private static List <HitsoundLayer> ImportStoryboard(string path, bool volumes, bool removeDuplicates, Beatmap beatmap, string mapDir, string prefix = null)
        {
            var hitsoundLayers = new List <HitsoundLayer>();

            prefix = prefix ?? string.Empty;

            foreach (var sbSample in beatmap.StoryboardSoundSamples)
            {
                var    filepath   = sbSample.FilePath;
                string samplePath = Path.Combine(mapDir, filepath);
                var    filename   = Path.GetFileNameWithoutExtension(filepath);

                var volume = volumes ? sbSample.Volume : 1;

                SampleSet sampleSet = GetSamplesetFromFilename(filename);
                Hitsound  hitsound  = GetHitsoundFromFilename(filename);

                var importArgs = new LayerImportArgs(ImportType.Storyboard)
                {
                    Path = path, SamplePath = samplePath, Volume = volume, DiscriminateVolumes = volumes, RemoveDuplicates = removeDuplicates
                };

                // Find the hitsoundlayer with this path
                HitsoundLayer layer = hitsoundLayers.Find(o => o.ImportArgs == importArgs);

                if (layer != null)
                {
                    // Find hitsound layer with this path and add this time
                    layer.Times.Add(sbSample.StartTime);
                }
                else
                {
                    // Add new hitsound layer with this path
                    HitsoundLayer newLayer = new HitsoundLayer(prefix + filename,
                                                               sampleSet,
                                                               hitsound,
                                                               new SampleGeneratingArgs(samplePath)
                    {
                        Volume = volume
                    },
                                                               importArgs);

                    newLayer.Times.Add(sbSample.StartTime);

                    hitsoundLayers.Add(newLayer);
                }
            }

            if (removeDuplicates)
            {
                foreach (var hitsoundLayer in hitsoundLayers)
                {
                    hitsoundLayer.Times.Sort();
                    hitsoundLayer.RemoveDuplicates();
                }
            }

            return(hitsoundLayers);
        }
Esempio n. 7
0
        private static float GetTargetAmount(Hitsound hitsound, Target.TargetBehavior behavior)
        {
            float amount = 0.1f;

            switch (hitsound)
            {
            case Hitsound.ChainNode:
                amount = (maxBrightness / 100f) * 5f;
                break;

            case Hitsound.ChainStart:
                amount = (maxBrightness / 100f) * 15f;
                break;

            case Hitsound.Kick:
                amount = (maxBrightness / 100f) * 25f;
                break;

            case Hitsound.Snare:
                amount = (maxBrightness / 100f) * 40f;
                break;

            case Hitsound.Percussion:
                amount = (maxBrightness / 100f) * 60f;
                break;

            case Hitsound.Melee:
                amount = (maxBrightness / 100f) * 80f;
                break;

            default:
                break;
            }
            if (behavior == Target.TargetBehavior.Melee)
            {
                if (hitsound != Hitsound.Melee)
                {
                    if (hitsound == Hitsound.Snare)
                    {
                        amount = (maxBrightness / 100f) * 60f;
                    }
                    else
                    {
                        amount = (maxBrightness / 100f) * 5f;
                    }
                }
            }
            else
            {
                if (hitsound == Hitsound.Melee)
                {
                    amount = 0f;
                }
            }
            //if (behavior == Target.TargetBehavior.Melee && hitsound == Hitsound.Snare) amount = (maxBrightness / 100f) * 80f;
            return(amount * Config.intensity * .5f);
        }
Esempio n. 8
0
 /// <inheritdoc />
 public HitsoundZone(bool isSelected, string name, string filename, double xPos, double yPos, SampleSet sampleSet, Hitsound hitsound)
 {
     _isSelected = isSelected;
     _name       = name;
     _filename   = filename;
     _xPos       = xPos;
     _yPos       = yPos;
     _sampleSet  = sampleSet;
     _hitsound   = hitsound;
 }
Esempio n. 9
0
 /// <inheritdoc />
 public HitsoundZone()
 {
     _isSelected = false;
     _name       = "";
     _filename   = "";
     _xPos       = -1;
     _yPos       = -1;
     _sampleSet  = SampleSet.Auto;
     _hitsound   = Hitsound.Normal;
 }
Esempio n. 10
0
 public HitsoundZone(bool isSelected, string name, string filename, double xPos, double yPos, Hitsound hitsound, SampleSet sampleSet, SampleSet additionsSet, int customIndex)
 {
     _isSelected   = isSelected;
     _name         = name;
     _filename     = filename;
     _xPos         = xPos;
     _yPos         = yPos;
     _hitsound     = hitsound;
     _sampleSet    = sampleSet;
     _additionsSet = additionsSet;
     _customIndex  = customIndex;
 }
Esempio n. 11
0
 public HitsoundZone()
 {
     _isSelected   = false;
     _name         = "";
     _filename     = "";
     _xPos         = -1;
     _yPos         = -1;
     _hitsound     = Hitsound.Normal;
     _sampleSet    = SampleSet.None;
     _additionsSet = SampleSet.None;
     _customIndex  = 0;
 }
Esempio n. 12
0
        /// <summary>
        /// Grabs the playing file name of the object.
        /// </summary>
        /// <param name="sampleSet"></param>
        /// <param name="hitsound"></param>
        /// <param name="index"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        public static string GetFileName(SampleSet sampleSet, Hitsound hitsound, int index, GameMode mode)
        {
            string taiko = mode == GameMode.Taiko ? "taiko-" : "";

            switch (index)
            {
            case 0:
                return($"{taiko}{sampleSet.ToString().ToLower()}-hit{hitsound.ToString().ToLower()}-default");

            case 1:
                return($"{taiko}{sampleSet.ToString().ToLower()}-hit{hitsound.ToString().ToLower()}");

            default:
                return($"{taiko}{sampleSet.ToString().ToLower()}-hit{hitsound.ToString().ToLower()}{index}");
            }
        }
Esempio n. 13
0
        private void SetNamesWithoutTrack()
        {
            var tracks = new List <string>();

            if (!string.IsNullOrEmpty(CustomFile))
            {
                tracks.Add(CustomFile);
                _fileNamesWithoutTrack = tracks.ToArray();
                return;
            }

            string sample = GetFromLineSample();

            AdjustObjectSample(ref sample);
            string addition = GetObjectAddition(sample);

            if (Hitsound == 0)
            {
                tracks.Add($"{sample}-hitnormal");
            }
            else
            {
                if (Hitsound.HasFlag(HitsoundType.Whistle))
                {
                    tracks.Add($"{addition}-hitwhistle");
                }
                if (Hitsound.HasFlag(HitsoundType.Clap))
                {
                    tracks.Add($"{addition}-hitclap");
                }
                if (Hitsound.HasFlag(HitsoundType.Finish))
                {
                    tracks.Add($"{addition}-hitfinish");
                }
                if (Hitsound.HasFlag(HitsoundType.Normal) ||
                    (Hitsound & HitsoundType.Normal) == 0)
                {
                    if (GameMode != GameMode.Mania)
                    {
                        tracks.Add($"{sample}-hitnormal");
                    }
                }
            }

            _fileNamesWithoutTrack = tracks.ToArray();
        }
Esempio n. 14
0
        /// <summary>
        /// Extract every used sample in a beatmap and return them as hitsound layers.
        /// </summary>
        /// <param name="path">The path to the beatmap.</param>
        /// <param name="volumes">Taking the volumes from the map and making different layers for different volumes.</param>
        /// <param name="detectDuplicateSamples">Detect duplicate samples and optimise hitsound layer count with that.</param>
        /// <param name="removeDuplicates">Removes duplicate sounds at the same millisecond.</param>
        /// <param name="includeStoryboard">Also imports storyboarded samples.</param>
        /// <returns>The hitsound layers</returns>
        public static List <HitsoundLayer> ImportHitsounds(string path, bool volumes, bool detectDuplicateSamples, bool removeDuplicates, bool includeStoryboard)
        {
            var      editor   = EditorReaderStuff.GetNewestVersionOrNot(path);
            Beatmap  beatmap  = editor.Beatmap;
            Timeline timeline = beatmap.GetTimeline();

            GameMode mode   = (GameMode)beatmap.General["Mode"].IntValue;
            string   mapDir = editor.GetParentFolder();
            Dictionary <string, string> firstSamples = AnalyzeSamples(mapDir, false, detectDuplicateSamples);

            List <HitsoundLayer> hitsoundLayers = new List <HitsoundLayer>();

            foreach (TimelineObject tlo in timeline.TimelineObjects)
            {
                if (!tlo.HasHitsound)
                {
                    continue;
                }

                double volume = volumes ? tlo.FenoSampleVolume / 100 : 1;

                List <string> samples = tlo.GetPlayingFilenames(mode);

                foreach (string filename in samples)
                {
                    bool isFilename = tlo.UsesFilename;

                    SampleSet sampleSet = isFilename ? tlo.FenoSampleSet : GetSamplesetFromFilename(filename);
                    Hitsound  hitsound  = isFilename ? tlo.GetHitsound() : GetHitsoundFromFilename(filename);

                    string samplePath      = Path.Combine(mapDir, filename);
                    string fullPathExtLess = Path.Combine(
                        Path.GetDirectoryName(samplePath) ?? throw new InvalidOperationException(),
                        Path.GetFileNameWithoutExtension(samplePath));

                    // Get the first occurence of this sound to not get duplicated
                    if (firstSamples.Keys.Contains(fullPathExtLess))
                    {
                        samplePath = firstSamples[fullPathExtLess];
                    }
                    else
                    {
                        // Sample doesn't exist
                        if (!isFilename)
                        {
                            samplePath = Path.Combine(
                                Path.GetDirectoryName(samplePath) ?? throw new InvalidOperationException(),
                                $"{sampleSet.ToString().ToLower()}-hit{hitsound.ToString().ToLower()}-1.wav");
                        }
                    }

                    string extLessFilename = Path.GetFileNameWithoutExtension(samplePath);
                    var    importArgs      = new LayerImportArgs(ImportType.Hitsounds)
                    {
                        Path   = path, SamplePath = samplePath,
                        Volume = volume, DetectDuplicateSamples = detectDuplicateSamples, DiscriminateVolumes = volumes, RemoveDuplicates = removeDuplicates
                    };

                    // Find the hitsoundlayer with this path
                    HitsoundLayer layer = hitsoundLayers.Find(o => o.ImportArgs == importArgs);

                    if (layer != null)
                    {
                        // Find hitsound layer with this path and add this time
                        layer.Times.Add(tlo.Time);
                    }
                    else
                    {
                        // Add new hitsound layer with this path
                        HitsoundLayer newLayer = new HitsoundLayer(extLessFilename,
                                                                   sampleSet,
                                                                   hitsound,
                                                                   new SampleGeneratingArgs(samplePath)
                        {
                            Volume = volume
                        },
                                                                   importArgs);
                        newLayer.Times.Add(tlo.Time);

                        hitsoundLayers.Add(newLayer);
                    }
                }
            }

            if (includeStoryboard)
            {
                hitsoundLayers.AddRange(ImportStoryboard(path, volumes, removeDuplicates, beatmap, mapDir, "SB: "));
            }

            // Sort layers by name
            hitsoundLayers = hitsoundLayers.OrderBy(o => o.Name).ToList();

            if (removeDuplicates)
            {
                foreach (var hitsoundLayer in hitsoundLayers)
                {
                    hitsoundLayer.Times.Sort();
                    hitsoundLayer.RemoveDuplicates();
                }
            }

            return(hitsoundLayers);
        }