/// <summary> /// 取需要播放的音效完整目录 /// </summary> /// <param name="sample">需要处理的sample类型</param> /// <param name="soundtype">需要处理的音效</param> /// <returns>当前需要播放音效的List<string></returns> public List<string> getsamplename(CSample sample, int soundtype) { List<string> tmp = new List<string>(); if (sample.sample == 0) { return tmp; } if (sample.sampleset == 0) { string all = Application.StartupPath + "\\Default\\" + Enum.GetName(typeof(TSample), sample.sample); if (soundtype % 2 == 1 || soundtype == 0) { tmp.Add(all + "-hitnormal.wav"); } soundtype = soundtype >> 2; if (soundtype % 2 == 1) { tmp.Add(all + "-hitwhistle.wav"); } soundtype = soundtype >> 2; if (soundtype % 2 == 1) { tmp.Add(all + "-hitfinish.wav"); } soundtype = soundtype >> 2; if (soundtype % 2 == 1) { tmp.Add(all + "-hitclap.wav"); } return tmp; } string last = ""; if (sample.sampleset == 1) { last = ""; } else { last = sample.sampleset.ToString(); } //normal-sliderslide(loops) //normal-sliderwhistle(loops) //normal-slidertick //不考虑以上 string first = location + "\\"; if (soundtype % 2 == 1 || soundtype == 0) { tmp.Add(check(first, Enum.GetName(typeof(TSample), sample.sample) + "-hitnormal", last)); } soundtype = (int)(soundtype / 2); if (soundtype % 2 == 1) { tmp.Add(check(first, Enum.GetName(typeof(TSample), sample.sample) + "-hitwhistle", last)); } soundtype = (int)(soundtype / 2); if (soundtype % 2 == 1) { tmp.Add(check(first, Enum.GetName(typeof(TSample), sample.sample) + "-hitfinish", last)); } soundtype = (int)(soundtype / 2); if (soundtype % 2 == 1) { tmp.Add(check(first, Enum.GetName(typeof(TSample), sample.sample) + "-hitclap", last)); } return tmp; }
private void Initfx() { fxlist.Clear(); for (int i = 0; i < MaxFxplayer; i++) { fxname[i] = ""; } int currentT = 0; int current = 0; var nowdefault = Map.Timingpoints[currentT].sample; var olddefault = new CSample(0, 0); double bpm = Map.Timingpoints[currentT].bpm; double tbpm = bpm; float volume = Map.Timingpoints[currentT].volume; int player = 0; for (int i = 0; i < uniAudio.Durnation * 1000; i++) { if (currentT + 1 < Map.Timingpoints.Count) { if (Map.Timingpoints[currentT + 1].offset <= i) { currentT++; nowdefault = Map.Timingpoints[currentT].sample; volume = Map.Timingpoints[currentT].volume; if (Map.Timingpoints[currentT].type == 1) { bpm = Map.Timingpoints[currentT].bpm; tbpm = Map.Timingpoints[currentT].bpm; } else { bpm = tbpm * Map.Timingpoints[currentT].bpm; } } } if (current == Map.HitObjects.Count) { break; } if (Map.HitObjects[current].starttime > i) { continue; } var tmpH = Map.HitObjects[current]; var tmpSample = nowdefault; float volumeH = volume; switch (tmpH.type) { case ObjectFlag.Normal: case ObjectFlag.NormalNewCombo: if (tmpH.sample != olddefault) { tmpSample = tmpH.sample; } if (tmpH.S_Volume != 0) { volumeH = tmpH.S_Volume; } fxlist.Add( new Fxlist(tmpH.starttime, Setplayer(ref player, Set.Getsamplename (tmpSample, tmpH.allhitsound)), volumeH)); if (tmpH.A_sample.sample != 0) { fxlist.Add( new Fxlist(tmpH.starttime, Setplayer(ref player, Set.Getsamplename (tmpH.A_sample, tmpH.allhitsound)), volumeH)); } break; case ObjectFlag.Slider: case ObjectFlag.SliderNewCombo: //TODO:每个节点的sampleset //TODO:滑条tick if (tmpH.sample != olddefault) { tmpSample = tmpH.sample; } double deltatime = (600.0 * tmpH.length / bpm / Map.SliderMultiplier); if (tmpH.S_Volume != 0) { volumeH = tmpH.S_Volume / (float)100.0; } for (int j = 0; j <= tmpH.repeatcount; j++) { fxlist.Add( new Fxlist((int)(tmpH.starttime + deltatime * j), Setplayer(ref player, Set.Getsamplename (tmpSample, tmpH.Hitsounds[j])), volumeH)); } break; case ObjectFlag.Spinner: case ObjectFlag.SpinnerNewCombo: if (tmpH.sample != olddefault) { tmpSample = tmpH.sample; } if (tmpH.S_Volume != 0) { volumeH = tmpH.S_Volume; } fxlist.Add( new Fxlist(tmpH.EndTime, Setplayer(ref player, Set.Getsamplename(tmpSample, tmpH.allhitsound)), volumeH)); if (tmpH.A_sample.sample != 0) { fxlist.Add(new Fxlist(tmpH.EndTime, Setplayer(ref player, Set.Getsamplename (tmpH.A_sample, tmpH.allhitsound)), volumeH)); } break; } current++; } fxlist.Sort((a, b) => a.Time.CompareTo(b.Time)); fxlist.Add(new Fxlist(Int32.MaxValue, new List<int>(), 0)); }
/// <summary> /// 取需要播放的音效完整目录 /// </summary> /// <param name="sample">需要处理的sample类型</param> /// <param name="soundtype">需要处理的音效</param> /// <returns>当前需要播放音效的List string </returns> public IEnumerable <string> Getsamplename(CSample sample, int soundtype) { var tmp = new List <string>(); if (sample.sample == 0) { return(tmp); } if (sample.sampleset == 0) { string all = String.Format(@"{0}\Default\{1}", Application.StartupPath, Enum.GetName(typeof(TSample), sample.sample)); if (soundtype % 2 == 1 || soundtype == 0) { tmp.Add(all + "-hitnormal.wav"); } soundtype = soundtype >> 2; if (soundtype % 2 == 1) { tmp.Add(all + "-hitwhistle.wav"); } soundtype = soundtype >> 2; if (soundtype % 2 == 1) { tmp.Add(all + "-hitfinish.wav"); } soundtype = soundtype >> 2; if (soundtype % 2 == 1) { tmp.Add(all + "-hitclap.wav"); } return(tmp); } string last = ""; last = sample.sampleset == 1 ? "" : sample.sampleset.ToString(); //normal-sliderslide(loops) //normal-sliderwhistle(loops) //normal-slidertick //不考虑以上 string first = location + "\\"; if (soundtype % 2 == 1 || soundtype == 0) { tmp.Add(Checksample(first, Enum.GetName(typeof(TSample), sample.sample) + "-hitnormal", last)); } soundtype = soundtype / 2; if (soundtype % 2 == 1) { tmp.Add(Checksample(first, Enum.GetName(typeof(TSample), sample.sample) + "-hitwhistle", last)); } soundtype = soundtype / 2; if (soundtype % 2 == 1) { tmp.Add(Checksample(first, Enum.GetName(typeof(TSample), sample.sample) + "-hitfinish", last)); } soundtype = soundtype / 2; if (soundtype % 2 == 1) { tmp.Add(Checksample(first, Enum.GetName(typeof(TSample), sample.sample) + "-hitclap", last)); } return(tmp); }