static void Main() { var ctx = new MusicDbContext(); MusicData dbContext = new MusicData(ctx); for (int i = 0; i < 3; i++) { var artist = new Artist() { Name = "Artist" + i, }; dbContext.Artists.Add(artist); var album = new Album() { Title = "Album" + i}; album.Artists.Add(artist); dbContext.Albums.Add(album); var song = new Song("Song" + i, artist); song.Albums.Add(album); dbContext.Songs.Add(song); } dbContext.SaveChanges(); }
public void Stop(bool fade) { if(mState != State.None) { if(fade) { mNextMusic = null; SetState(State.Changing); } else { mCurMusic.source.Stop(); SetState(State.None); } } }
// ----- ----- ----- Method ----- ----- ----- public MasterData( IList<string> dirs, MusicData music, IList<Revival> revival, IList<Inherit> inherit, IList<Master> masters) { CharaDirs = dirs; Music = music; Revivals = revival; Inherits = inherit; Masters = masters; }
public void Play(string name, bool immediate) { if(immediate) { Stop(false); } if(mCurMusic != null) { mNextMusic = mMusic[name]; SetState(State.Changing); } else { mCurMusic = mMusic[name]; mCurMusic.source.volume = 1.0f; mCurMusic.source.Play(); SetState(State.Playing); } }
public void WriteText() { string name = "Arabesque"; string file = $"{DataPath}/{name}.tja"; var loader = new TjaLoader(); var result = loader.Load(file); var md = new MusicData(name, "6"); md.notes = result; md.audioFileName = $"{name}.ogg"; string json = JsonUtility.ToJson(md); string outputFile = $"{OutputPath}/{name}.msd"; FileUtils.WriteText(outputFile, json); Assert.IsTrue(new FileInfo(outputFile).Exists, "ファイルが作成されていること。"); }
IEnumerator FadeInSound_C(MusicData _musicData) { float duration = _musicData.fadeInDuration; AudioSource newSource = gameObject.AddComponent <AudioSource>(); newSource.clip = _musicData.clip; newSource.Play(); newSource.loop = _musicData.isLooping; for (float i = 0; i < duration; i += Time.deltaTime) { newSource.volume = Mathf.Lerp(0f, volumeMultiplier, i / duration); yield return(null); } MusicInformation newMusicInf = new MusicInformation(); newMusicInf.linkedSource = newSource; newMusicInf.linkedMusicData = _musicData; currentMusicInformations.Add(newMusicInf); }
private void ChangeImage(MusicData musicData) { //TEMP// if (title) { title.text = musicData.desc.name; } if (musicData.desc.previewImgPath == null) { rawImage.texture = defaultImage; return; } var path = Path.Combine(musicData.path, musicData.desc.previewImgPath); StartCoroutine(Serialize.GetTexture(path, (value) => { rawImage.texture = value; })); }
private void LoadWav(string path, byte[] bytes) { try { if (path.StartsWith("Sounds/Music/")) { musics[path] = new MusicData(bytes, false); } else { //SoundEffect.FromStream needs a stream with a length sounds[path] = SoundEffect.FromStream(new MemoryStream(bytes)); } } catch (Exception e) { throw new ResourceLoadException(Language.GetTextValue("tModLoader.LoadErrorWavSoundFailedToLoad", path) + (Main.engine == null ? "\n" + Language.GetTextValue("tModLoader.LoadErrorSoundFailedToLoadAudioDeviceHint") : ""), e); } }
// Update is called once per frame void Update() { switch (mState) { case State.None: break; case State.Playing: if (!mCurMusic.source.isPlaying) { mCurMusic.source.Play((ulong)System.Math.Round(rate * ((double)mCurMusic.loopDelay))); } break; case State.Changing: mCurTime += Time.deltaTime; if (mCurTime >= changeFadeOutDelay) { mCurMusic.source.Stop(); if (mNextMusic != null) { mCurMusic.source.volume = 1.0f; mNextMusic.source.Play(); mCurMusic = mNextMusic; mNextMusic = null; SetState(State.Playing); } else { SetState(State.None); } } else { mCurMusic.source.volume = 1.0f - mCurTime / changeFadeOutDelay; } break; } }
public void Play(string name, bool immediate) { if (immediate) { Stop(false); } if (mCurMusic != null) { mNextMusic = mMusic[name]; SetState(State.Changing); } else { mCurMusic = mMusic[name]; mCurMusic.source.volume = 1.0f; mCurMusic.source.Play(); SetState(State.Playing); } }
// Start is called before the first frame update void Start() { try{ TextAsset file = Resources.Load("Firefly") as TextAsset; string json = file.ToString(); //string json = File.ReadAllText(Application.dataPath + "/SongData/Firefly.json"); //OVRDebugConsole.instance.AddMessage("Hello JSON",Color.white); MusicData md = JsonUtility.FromJson <MusicData>(json); StateHolder.SongName = md.MusicName; StateHolder.BPM = md.BPM; StateHolder.Offset = md.Offset; StateHolder.NotesDataL = md.notesL; StateHolder.NotesDataR = md.notesR; GetComponent <NotesController>().Initialize(); } catch (Exception e) { OVRDebugConsole.instance.AddMessage(e.Message, Color.white); } }
public List <MusicData> Search(Musics musics) { List <MusicData> datas = new List <MusicData>(); Queue <string> directories = new Queue <string>(); string filePath = AssetDatabase.GetAssetPath(musics); string folderPath = Path.GetDirectoryName(filePath); directories.Enqueue(folderPath); while (directories.Count > 0) { string dir = directories.Dequeue(); string[] files = Directory.GetFiles(dir); foreach (string file in files) { if (Path.GetExtension(file) == ".asset") { try { MusicData data = AssetDatabase.LoadAssetAtPath(file, typeof(MusicData)) as MusicData; if (data != null) { datas.Add(data); } } catch { } } } string[] dirs = Directory.GetDirectories(dir); foreach (string str in dirs) { directories.Enqueue(str); } } return(datas); }
public async Task <MusicData> GetMusicData(string Artist, string Title) { MusicData ReturnedMusicData = new MusicData(); try { HttpClient httpClient = new HttpClient(); var response = await httpClient.GetStringAsync($"http://api.musixmatch.com/ws/1.1/matcher.lyrics.get?apikey={ApiKey}&format=json&q_track={Title}&q_artist={Artist}"); ReturnedMusicData = JsonConvert.DeserializeObject <MusicData>(response); if (ReturnedMusicData.message.Body == null) { ReturnedMusicData.message.Body.Lyrics.Lyrics_body = "Could not get the Lyrics of the song"; } } catch (Exception ex) { throw new Exception(ex.Message); } return(ReturnedMusicData); }
void PlayBeatMap() { //foreach(MusicData md in BeatAnalysisManager.BAL) { for (int i = 0; i < BeatAnalysisManager.BAL.Count; i++) { MusicData md = BeatAnalysisManager.BAL [i]; if (md.playtime > _audio.time + showtimeMin && md.playtime < _audio.time + showtimeMax) { //md.OnBeat = true; DrawBeatMapSeed(md); BeatAnalysisManager.BAL.Remove(md); //Debug.Log ("4"); i--; } else if (md.playtime < _audio.time - killtime) { BeatAnalysisManager.BAL.Remove(md); Debug.Log("kill one beat" + i + "//" + md.playtime + "<" + _audio.time + "-" + killtime); i--; } } //} // //同步 // if (CountToSync > 240) { // BeatMapContainer.transform.position=new Vector3 ( 0, 0-speed * _audio.time -speed*offset,0); // CountToSync = 0; // Debug.LogWarning ("sync"); // } else { // BeatMapContainer.transform.position -= new Vector3 (0, speed * Time.deltaTime, 0); // } // //Debug.Log (CountToSync); // CountToSync++; }
public void Play(string name, bool immediate) { MusicData nextMusic; if (!mMusic.TryGetValue(name, out nextMusic)) { Debug.LogWarning("Unknown music: " + name); return; } if (mCurMusic == null || (immediate && mCurMusic != nextMusic)) { Stop(false); mCurMusic = nextMusic; mCurMusic.source.volume = mCurMusic.defaultVolume * UserSettingAudio.instance.musicVolume; mCurMusic.source.Play(); SetState(State.Playing); } else if (mCurMusic != nextMusic) { mNextMusic = nextMusic; SetState(State.Changing); } //determine index for auto playlist if (autoPlay != AutoPlayType.None) { for (int i = 0; i < music.Length; i++) { if (music[i].name == name) { mCurAutoplayInd = i; break; } } } }
public void DrawBeatMapSeed(MusicData MD) { BeatAnalysisManager.BeatmapOffset = offset; // Debug.Log ("BeatAnalysisManager .BAL.Count" + BeatAnalysisManager.BAL.Count); // GameObject tarpos = Instantiate (beatObj [MD.BeatPos]) as GameObject; // tarpos.transform.position = charPos.position ; // tarpos.transform.localScale = new Vector3 (2, 1, 2);//.y = 10; // tarpos.transform.parent = BeatMapContainer.transform; // GameObjBeats = new GameObject[BeatAnalysisManager .BAL.Count ]; // float [] beattimes=new float[BeatAnalysisManager .BAL.Count ] ; for (int i = 0; i < showNum; i++) { // for (int j = 0; j < MD.Average; j++) { GameObject beat = Instantiate(beatObj [MD.BeatPos]) as GameObject; if (!beat.GetComponent <Beat> ()) { beat.AddComponent <Beat> (); } beat.GetComponent <Beat> ().Destorytime = MD.playtime; beat.GetComponent <Beat> ().Borntime = _audio.time; if (beat.GetComponent <Beat> ().AC == null) { beat.GetComponent <Beat> ().AC = beatsoundFX [MD.BeatPos]; } beat.transform.parent = BeatMapContainer.transform; beat.transform.localPosition = nextSeedPos(MD, 0); // beat.transform.localPosition = nextSeedPos (MD,j); // new Vector3 (BeatAnalysisManager.BAL [i].BeatPos * 10, BeatAnalysisManager.BAL [i].playtime * speed, 0); // } } //GameObjBeats[i]=beat; //beattimes [i] = BeatAnalysisManager .BAL[i].playtime; }
public void PlayMusic(int id) { if (Settings.Audio.MusicOn) { if (id < 0) // not a valid id, used to stop music. { StopMusic(); return; } if (!m_Music.ContainsKey(id)) { string name; bool loops; if (MusicData.TryGetMusicData(id, out name, out loops)) { m_Music.Add(id, new UOMusic(id, name, loops)); } else { Tracer.Error("Received unknown music id {0}", id); return; } } ASound toPlay = m_Music[id]; if (toPlay != m_MusicCurrentlyPlaying) { // stop the current song StopMusic(); // play the new song! m_MusicCurrentlyPlaying = toPlay; m_MusicCurrentlyPlaying.Play(false); } } }
IEnumerator PlayMusic(string MusicDataname) { float startTime = Time.time; MusicData musicData = BackgroundMusicDataDict [MusicDataname]; //stop the musicdata at the same rank foreach (MusicData mu in this.BackgroundMusicDataArray) { if (mu != musicData && mu.ExclusiveRank == musicData.ExclusiveRank && mu.audioSource.isPlaying) { StartCoroutine("StopMusic", mu.Name); } } if (musicData.audioSource.enabled) { musicData.audioSource.enabled = true; } musicData.audioSource.Play(); if (musicData.FadeInLength > 0) { while ((Time.time - startTime) <= musicData.FadeInLength) { float _t = (Time.time - startTime) / musicData.FadeInLength; musicData.audioSource.volume = Mathf.Lerp(0, musicData.InitialVolume, _t); yield return(null); } } musicData.audioSource.volume = musicData.InitialVolume; if (musicData.AutoExpire) { yield return(new WaitForSeconds(musicData.ExpireTime)); StartCoroutine("StopMusic", musicData.Name); } }
public override void BeginEdit() { base.BeginEdit(); copyData = currentData; }
public void ParseText(string text) { string[] stringLine = text.Split('\n'); var lineCount = stringLine.Length; var lineNum = 0; var mNum = 0; while (lineNum < lineCount) { if (stringLine[lineNum].Contains("#NAME")) { string[] splitLine = stringLine[lineNum].Split(' '); Common.Log("name : " + splitLine[1]); MusicData.Name = splitLine[1].Trim(); } else if (stringLine[lineNum].Contains("#SOUND")) { string[] splitLine = stringLine[lineNum].Split(' '); Common.Log("sound : " + splitLine[1]); MusicData.FileName = splitLine[1].Trim(); } else if (stringLine[lineNum].Contains("#BPM")) { string[] splitLine = stringLine[lineNum].Split(' '); Common.Log("bpm : " + splitLine[1]); MusicData.Bpm = float.Parse(splitLine[1].Trim()); } else if (stringLine[lineNum].Contains("#PRESET")) { string[] splitLine = stringLine[lineNum].Split(' '); Common.Log("preset : " + splitLine[1]); //MusicData.Preset = float.Parse(splitLine[1].Trim()); } else if (stringLine[lineNum].Contains("#DATA")) { Common.Log("data"); mNum = 0; } else if (stringLine[lineNum].Contains("#FIN")) { Common.Log("fin"); break; } else if (stringLine[lineNum].Contains("-----")) { Common.Log("measure"); mNum++; string noteLine1 = stringLine[lineNum + 1].Trim(); string noteLine2 = stringLine[lineNum + 2].Trim(); string noteLine3 = stringLine[lineNum + 3].Trim(); string noteLine4 = stringLine[lineNum + 4].Trim(); for (int i = 0; i < noteLine1.Length; i++) { if (noteLine1[i] == '1' || noteLine1[i] == '2') { MusicData.addLane1(mNum + (float)i / noteLine1.Length); } } for (int i = 0; i < noteLine2.Length; i++) { if (noteLine2[i] == '1' || noteLine2[i] == '2') { MusicData.addLane2(mNum + (float)i / noteLine2.Length); } } for (int i = 0; i < noteLine3.Length; i++) { if (noteLine3[i] == '1' || noteLine3[i] == '2') { MusicData.addLane3(mNum + (float)i / noteLine3.Length); } } for (int i = 0; i < noteLine4.Length; i++) { if (noteLine4[i] == '1' || noteLine4[i] == '2') { MusicData.addLane4(mNum + (float)i / noteLine4.Length); } } lineNum++; lineNum++; } lineNum++; } }
// Update is called once per frame void Update() { switch (mState) { case State.None: break; case State.Playing: if (!(mCurMusic.source.loop || mCurMusic.source.isPlaying)) { string curName = mCurMusic.name; if (autoPlay != AutoPlayType.None) { AutoPlaylistNext(); } else if (mCurMusic.loop) //loop { mCurMusic.source.volume = mCurMusic.defaultVolume * UserSettingAudio.instance.musicVolume; if (mCurMusic.loopDelay > 0) { mCurMusic.source.Play((ulong)System.Math.Round(rate * ((double)mCurMusic.loopDelay))); } else { mCurMusic.source.Play(); } } else { SetState(State.None); } //callback if (musicFinishCallback != null) { musicFinishCallback(curName); } } break; case State.Changing: mCurTime += Time.deltaTime; if (mCurTime >= changeFadeOutDelay) { mCurMusic.source.Stop(); if (mNextMusic != null) { mCurMusic = mNextMusic; mNextMusic = null; SetState(State.Playing); } else { SetState(State.None); } } else { mCurMusic.source.volume = mCurMusic.defaultVolume * (1.0f - mCurTime / changeFadeOutDelay) * UserSettingAudio.instance.musicVolume; } break; } }
/// <summary> /// Creates the data for the specified row. /// </summary> /// <param name="Row">The row.</param> internal Data Create(Row Row) { Data Data; switch (this.Index) { case 1: { Data = new LocaleData(Row, this); break; } case 2: { Data = new BillingPackageData(Row, this); break; } case 3: case 20: { Data = new GlobalData(Row, this); break; } case 4: { Data = new SoundData(Row, this); break; } case 5: { Data = new ResourceData(Row, this); break; } case 9: { Data = new CharacterBuffData(Row, this); break; } case 10: { Data = new ProjectileData(Row, this); break; } case 11: { Data = new EffectData(Row, this); break; } case 12: { Data = new PredefinedDeckData(Row, this); break; } case 14: { Data = new RarityData(Row, this); break; } case 15: { Data = new LocationData(Row, this); break; } case 16: { Data = new AllianceBadgeData(Row, this); break; } case 18: { Data = new NpcData(Row, this); break; } case 19: { Data = new TreasureChestData(Row, this); break; } case 21: { Data = new ParticleEmitterData(Row, this); break; } case 22: { Data = new AreaEffectObjectData(Row, this); break; } case 26: case 27: case 28: case 29: { Data = new SpellData(Row, this); break; } case 34: case 35: { Data = new CharacterData(Row, this); break; } case 40: { Data = new HealthBarData(Row, this); break; } case 41: { Data = new MusicData(Row, this); break; } case 42: { Data = new DecoData(Row, this); break; } case 43: { Data = new GambleChestData(Row, this); break; } case 45: case 48: { Data = new TutorialData(Row, this); break; } case 46: { Data = new ExpLevelData(Row, this); break; } case 50: { Data = new BackgroundDecoData(Row, this); break; } case 51: { Data = new SpellSetData(Row, this); break; } case 52: { Data = new ChestOrderData(Row, this); break; } case 53: { Data = new TauntData(Row, this); break; } case 54: { Data = new ArenaData(Row, this); break; } case 55: { Data = new ResourcePackData(Row, this); break; } case 56: { Data = new Data(Row, this); break; } case 57: { Data = new RegionData(Row, this); break; } case 58: { Data = new NewsData(Row, this); break; } case 59: { Data = new AllianceRoleData(Row, this); break; } case 60: { Data = new AchievementData(Row, this); break; } case 61: { Data = new HintData(Row, this); break; } case 62: { Data = new HelpshiftData(Row, this); break; } default: { Logging.Info(this.GetType(), "Invalid data table id: " + this.Index + "."); Data = null; break; } } return(Data); }
public void GetData(MusicData data) { }
/// <summary> /// 指定時間分の音声データを返す /// </summary> /// <remarks>オーバーロードを利用して同じ名前でメソッドを定義した</remarks> /// <param name="time_width">指定時間幅[s]</param> /// <returns>音声データクラス</returns> public MusicData Read(double time_width) { MusicData ans = new MusicData(this.Read(GetArrSize(time_width))); return(ans); }
// Update is called once per frame void Update() { switch(mState) { case State.None: break; case State.Playing: if(!mCurMusic.source.isPlaying) { mCurMusic.source.Play((ulong)System.Math.Round(rate*((double)mCurMusic.loopDelay))); } break; case State.Changing: mCurTime += Time.deltaTime; if(mCurTime >= changeFadeOutDelay) { mCurMusic.source.Stop(); if(mNextMusic != null) { mCurMusic.source.volume = 1.0f; mNextMusic.source.Play(); mCurMusic = mNextMusic; mNextMusic = null; SetState(State.Playing); } else { SetState(State.None); } } else { mCurMusic.source.volume = 1.0f - mCurTime/changeFadeOutDelay; } break; } }
/* ============================================================================ Init functions ============================================================================ */ public void Init() { // first init languages languages = new LanguageData(); statusValues = new StatusValueData(); elements = new ElementData(); races = new RaceData(); sizes = new SizeData(); areaNames = new AreaNameData(); armors = new ArmorData(); cameraPositions = new CameraPositionData(); attacks = new BaseAttackData(); characters = new CharacterData(); classes = new ClassData(); colors = new ColorData(); dialoguePositions = new DialoguePositionData(); battleAIs = new BattleAIData(); enemies = new EnemyData(); equipParts = new EquipmentPartData(); formulas = new FormulaData(); gameSettings = new GameSettingsData(); items = new ItemData(); itemTypes = new ItemTypeData(); loadSaveHUD = new LoadSaveHUDData(); mainMenu = new MainMenuData(); skillTypes = new SkillTypeData(); effects = new StatusEffectData(); skills = new SkillData(); weapons = new WeaponData(); music = new MusicData(); huds = new HUDData(); recipes = new ItemRecipeData(); fonts = new FontData(); globalEvents = new GlobalEventData(); teleports = new TeleportData(); difficulties = new DifficultyData(); // battle system battleAnimations = new BattleAnimationData(); battleSystem = new BattleSystemData(); }
public MusicData Music2() { var musicData = new MusicData(); musicData.Inputs.Add(15, new List <ButtonType> { ButtonType.NONE, ButtonType.A, ButtonType.NONE, ButtonType.B, ButtonType.DOG1 }); musicData.Inputs.Add(23, new List <ButtonType> { ButtonType.NONE, ButtonType.A, ButtonType.B, ButtonType.NONE, ButtonType.X, ButtonType.DOG1 }); musicData.Inputs.Add(31, new List <ButtonType> { ButtonType.NONE, ButtonType.A, ButtonType.L, ButtonType.Y, ButtonType.R, ButtonType.DOG1 }); musicData.Inputs.Add(39, new List <ButtonType> { ButtonType.NONE, ButtonType.A, ButtonType.U, ButtonType.B, ButtonType.U, ButtonType.A, ButtonType.NONE, ButtonType.D, ButtonType.DOG1 }); musicData.Inputs.Add(51, new List <ButtonType> { ButtonType.NONE, ButtonType.A, ButtonType.U, ButtonType.B, ButtonType.D, ButtonType.L, ButtonType.X, ButtonType.R, ButtonType.Y, ButtonType.DOG1 }); musicData.Inputs.Add(63, new List <ButtonType> { ButtonType.NONE, ButtonType.A, ButtonType.U, ButtonType.A, ButtonType.D, ButtonType.B, ButtonType.L, ButtonType.B, ButtonType.R, ButtonType.NONE, ButtonType.X, ButtonType.DOG1 }); musicData.Inputs.Add(75, new List <ButtonType> { ButtonType.NONE, ButtonType.X, ButtonType.U, ButtonType.Y, ButtonType.L, ButtonType.A, ButtonType.NONE, ButtonType.Y, ButtonType.NONE, ButtonType.B, ButtonType.U, ButtonType.X, ButtonType.D, ButtonType.DOG1 }); musicData.Inputs.Add(89, new List <ButtonType> { ButtonType.NONE, ButtonType.B, ButtonType.NONE, ButtonType.A, ButtonType.U, ButtonType.Y, ButtonType.R, ButtonType.A, ButtonType.NONE, ButtonType.B, ButtonType.L, ButtonType.U, ButtonType.L, ButtonType.U, ButtonType.D, ButtonType.NONE, ButtonType.B, ButtonType.NONE, ButtonType.A, ButtonType.U, ButtonType.D, ButtonType.DOG1 }); //musicData.BeatUpdate.Add(80, "Transition_110_to_120"); //musicData.BeatUpdate.Add(80, "CoreGame_120BPM"); //musicData.BeatUpdate.Add(160, "Transition_120_to_130"); //musicData.BeatUpdate.Add(176, "CoreGame_130BPM"); musicData.BeatUpdate.Add(110, "Ending"); musicData.ParseData(); return(musicData); }
void Update() { if (Input.GetKey(KeyCode.Escape)) //強制終了 { UnityEngine.Application.Quit(); } speedText.text = speed.ToString(); if (state == State.select) { } if ((state == State.beforeMakeObj)) { //enterが押されたらオブジェクト生成に移行 if (Input.GetKeyDown(KeyCode.Return) || TouchCheck()) { state = State.afterMakeObj; score = 0; great = 0; fast = 0; late = 0; miss = 0; //評価数のリセット judgeText.text = ""; musicData = noteMaker.GetComponent <NoteObjMaker>().NoteDataParse(noteDataName); //譜面データのファイル名からMusicData型に変換してもらう musicSound = (Resources.Load("MusicData/" + musicData.musicName, typeof(AudioClip)) as AudioClip); //解析したMusicData型のデータから曲の名前を抽出し曲設定 Debug.Log("adress is MusicData/" + musicData.musicName); Debug.Log(Resources.Load("MusicData/" + musicData.musicName, typeof(AudioClip))); noteMakeTime = Time.time; //現在の時間を譜面が流れ出す時間に設定 Debug.Log("noteMakeTime = " + noteMakeTime); } } else if (state == State.afterMakeObj && Time.time >= (noteMakeTime + (60 / (musicData.BPM / 4)))) //生成してから1小節分の時間がたったら { state = State.playing; MusicPlay(); } else if (state == State.playing && (Time.time - (noteMakeTime + (60 / (musicData.BPM / 4)))) > musicData.endTime) { state = State.result; noteMakeTime = 0; timeBar.value = 0; timeBar.gameObject.SetActive(false); audioSource.Stop(); //音楽停止 resultImageObject.SetActive(true); //リザルト画像表示 CalcAchievementRate(); //achievementrateを算出 judgeText.enabled = false; String ScoreData = "score:" + score + " great:" + great + " fast:" + fast + " late:" + late + " miss:" + miss + " achievementrate:" + achievementRate; DateTime dt = DateTime.Now; records.Sort((a, b) => a.noteNum - b.noteNum); ResultReporter.SaveText(noteDataName + "\n" + ScoreData + "\n" + RecordsToStr.RecordsToString(records), "Record" + dt.ToString("MMdd_HHmm") + ".txt"); ResultReporter.SaveText(TouchRecordToStr.TouchRecordToString(touchRecords), "Touch" + dt.ToString("MMdd_HHmm") + ".txt"); DestroyNoteList(); //リストの消去 records.Clear(); //レコードのリセット touchRecords.Clear(); } else if (state == State.result) { if (Input.GetKeyDown(KeyCode.Return) || TouchCheck()) //リザルト画面で画面がタッチされたら { state = State.select; speedText.enabled = true; score = 0; great = 0; fast = 0; late = 0; miss = 0; //評価数のリセット resultImageObject.SetActive(false); judgeText.text = "Press Enter\n To Start!"; judgeText.enabled = true; selectImageObject.SetActive(true); ButtonControl(true); //全てのボタンを表示 } } if (state == State.playing) //timeBar処理 { timeBar.value = (Time.time - (noteMakeTime + (60 / (musicData.BPM / 4)))) / musicData.endTime; //経過時間/endTime MissJudge(); } }
// //分频段,实时检测节拍 // void CheckBeatIncInBandold() // { //// strvariance=""; // // if (CurrentIndex < _bufferSize) { // return; // } // // for (int ic = 0; ic < _numBands; ic++) { // //遍历所有频段 // int largeindex = 0; // // // float largeenergy = RecAvgInBandInc [lastbeatindexInBand[ic],ic];//当前频段上一次节拍的位置 // // // float variance=0;//方差 // for (int i = lastbeatindexInBand[ic]+1; i < CurrentIndex-2; i++) { // //遍历当前频段,上一节拍至当前帧的所有平均值增量 // if (RecAvgInBandInc [i,ic] > largeenergy ) { // //// largeindexF = largeindex; // largeindex = i;//最大值在buffersize中所在的位置 // largeenergy = RecAvgInBandInc [i,ic] ;//最大 // // // }//获取平均数增量最大值,及最大值在buffersize中所在的位置 // variance += Mathf.Pow (RecAvgInBandInc [i, ic], 2); // largeenergy *= decay;//衰减 // // // }//end遍历当前频段,上一节拍至当前帧的所有平均值增量,获取最大值及其序号 // variance /= CurrentIndex - lastbeatindexInBand [ic] - 3;//上一个节拍至当前节拍之前的节拍,当前频段,音量的方差 // float tempVarInc;//计算之前帧的方差与当前帧平方的关系 // if (variance != 0) { // tempVarInc = Mathf.Pow (RecAvgInBandInc [CurrentIndex - 1, ic], 2) / variance;//当前帧增量的平方/当前之前的方差 // // } else { // tempVarInc = 1.1f;//Mathf.Pow (AvgInClipInc [CurrentIndex - 1, ic], 2); // } // timestep = tempVarInc; //// tempVarInc = 0.5f + tempVarInc / 5000; // tempVarInc = Mathf.Clamp (tempVarInc, 0.5f, 1.2f); // // // tempVarInc = 1; // // // //判断节拍/////////////////////// // float beatsincelast = CurrentIndex - lastbeatindexInBand[ic];//当前频段与上一节拍之间的帧数 // if (beatsincelast > betweenbeat) {//与上一节拍之间的帧数不够大则不认为此处是节拍 // //&& _bufferSize-largeindexF<4 // if (RecAvgInBandInc [CurrentIndex - 1,ic]/Mathf.Abs( largeenergy * enegryaddup*tempVarInc)>1 && RecAvgInBandInc [CurrentIndex - 1,ic]>0 ) {//当前帧增量为buffersize中最大的,且远大于之前的最大值 // // // // // //ArrayList BeatArrayList = BeatAnalysisManager .BAL;//存beat信息 // //保存鼓点信息 // if (beatArrindex < BeatAnalysisManager .BAL.Count) { // ((MusicData)BeatAnalysisManager .BAL [beatArrindex]).playtime = _audio.time; // ((MusicData)BeatAnalysisManager .BAL [beatArrindex]).OnBeat = true; // ((MusicData)BeatAnalysisManager .BAL [beatArrindex]).BeatPos = ic; // } else { // MusicData md = new MusicData (); // md.playtime = _audio.time; // md.OnBeat = true; // md.BeatPos = ic; // BeatAnalysisManager .BAL.Add (md); // } // beatArrindex++; // //保存鼓点信息 // // //end 保存鼓点信息 // // // //将频段分为高中低音,确定当前节拍属高中低音 // onBeat.Invoke (ic); // Debug.LogWarning ("onbeat time="+_audio.timeSamples +" ic=" + ic + " lastbeat=" + lastbeatindexInBand[ic] + ",curr=" + CurrentIndex + ", vi=" + "---" + RecAvgInBandInc [CurrentIndex - 1,ic]+"tempVarInc old="+tempVarInc ); // // lastbeatindexInBand[ic] = CurrentIndex;//记录当前频段的上一个节拍位置,每帧-1 // // //测试用 // //// timestep = _audio.timeSamples - timelast; //// timelast = _audio.timeSamples; // //end测试用 // //Debug.LogError ("on AvgSuperhigh="+AvgSuperhigh); // // // } else { // // // } // ////end当前帧增量为buffersize中最大的,且远大于之前的最大值 // // // } // // }//end 遍历所有频段 // //Debug.Log (strvariance); // //Debug.LogError ("on"); // //Debug.Log ("oncheck time=" + _audio.timeSamples ); // for (int icc = 0; icc < _numBands; icc++) { // lastbeatindexInBand [icc]--; // if (lastbeatindexInBand [icc] < 0) { // lastbeatindexInBand [icc] = 0; // } // } // // // } // //////////////////**** // float[] largeenergys ; //分频段,实时检测节拍 void CheckBeatInBand() { // strvariance=""; if (CurrentIndex < _bufferSize) { return; } for (int ic = 0; ic < _numBands; ic++) { //遍历所有频段 // int largeindex = 0; /////////////////////////**** //float largeenergy = RecAvgInBand [lastbeatindexInBand[ic],ic];//当前频段上一次节拍的位置 float largeenergy = RAeng [lastbeatindexInBand[ic]][ic]; //当前频段上一次节拍的位置 float variance = 0; //方差 for (int i = lastbeatindexInBand[ic] + 1; i < CurrentIndex - 2; i++) { //遍历当前频段,上一节拍至当前帧的所有平均值 if (RAeng [i][ic] > largeenergy) { // largeindex = i;//最大值在buffersize中所在的位置 largeenergy = RAeng [i][ic]; //最大 //////////////////////**** // if (usethelastbeat) { // largeenergys [ic] = largeenergy; // } //////////////////////**** } //获取平均数增量最大值,及最大值在buffersize中所在的位置 variance += Mathf.Pow(RAeng [i][ic], 2); largeenergy *= _decay; //衰减 } //end遍历当前频段,上一节拍至当前帧的所有平均值增量,获取最大值及其序号 variance /= CurrentIndex - lastbeatindexInBand [ic] - 3; //上一个节拍至当前节拍之前的节拍,当前频段,音量的方差 float tempVarInc; //计算之前帧的方差与当前帧平方的关系 if (variance != 0) { tempVarInc = Mathf.Pow(RAinc [RAinc.Count - 1][ic], 2) / variance; //当前帧增量的平方/当前之前的方差 } else { tempVarInc = 1.1f; //Mathf.Pow (AvgInClipInc [CurrentIndex - 1, ic], 2); } //tempVarInc = 0.5f + tempVarInc / 5000; tempVarInc = Mathf.Clamp(tempVarInc, 0.9f, 1.1f); // strvariance+=variance+",";//显示方差 //判断节拍/////////////////////// float beatsincelast = CurrentIndex - lastbeatindexInBand[ic]; //当前频段与上一节拍之间的帧数 if (beatsincelast > 2 * betweenbeat) //与上一节拍之间的帧数不够大则不认为此处是节拍 //&& _bufferSize-largeindexF<4 { if (RAeng [RAeng.Count - 1][ic] / Mathf.Abs(largeenergy * _enegryaddup * tempVarInc) > 1) //当前帧增量为buffersize中最大的,且远大于之前的最大值 // ArrayList BeatArrayList = BeatAnalysisManager .BeatArrayList;//存beat信息 //保存鼓点信息 { if (beatArrindex < BeatAnalysisManager.BAL.Count) { // ((MusicData)BeatArrayList [beatArrindex]).playtime = _audio.time; // ((MusicData)BeatArrayList [beatArrindex]).OnBeat = true; // ((MusicData)BeatArrayList [beatArrindex]).BeatPos = ic; BeatAnalysisManager.BAL [beatArrindex].playtime = _audio.time; BeatAnalysisManager.BAL [beatArrindex].OnBeat = true; BeatAnalysisManager.BAL [beatArrindex].BeatPos = ic; } else { MusicData md = new MusicData(); md.playtime = _audio.time; md.OnBeat = true; md.BeatPos = ic; // BeatArrayList.Add (md); BeatAnalysisManager.BAL.Add(md); } beatArrindex++; //保存鼓点信息 //end 保存鼓点信息 //将频段分为高中低音,确定当前节拍属高中低音 onBeat.Invoke(ic); lastbeatindexInBand[ic] = CurrentIndex; //记录当前频段的上一个节拍位置,每帧-1 //测试用 // timestep = _audio.timeSamples - timelast; // timelast = _audio.timeSamples; //end测试用 // Debug.LogWarning ("onbeat time="+_audio.timeSamples +" ic=" + ic + " lastbeat=" + lastbeatindexInBand[ic] + ",largeindex=" + largeindex + "," + largeenergy + "---"+ +RAeng[RAeng.count-1][ic]); //Debug.LogError ("on AvgSuperhigh="+AvgSuperhigh); } ////end当前帧增量为buffersize中最大的,且远大于之前的最大值 } if (lastbeatindexInBand [ic] > 0) { lastbeatindexInBand [ic]--; } } //end 遍历所有频段 //Debug.Log (strvariance); //Debug.LogError ("on"); //Debug.Log ("oncheck time=" + _audio.timeSamples ); // for (int icc = 0; icc < _numBands; icc++) { // lastbeatindexInBand [icc]--; // if (lastbeatindexInBand [icc] < 0) { // lastbeatindexInBand [icc] = 0; // } // } }
void Awake() { Setting = GameObject.Find("Setting").GetComponent<Settings>(); _startButton = GameObject.Find("Canvas/Start"); if (_startButton == null || Setting == null) { Debug.Log("Can not find GameObject"); } _buttonText = _startButton.GetComponentInChildren<Text>(); _musicData = new MusicData(); _currentDrawNotes = new List<Note>[9]; for (int i = 0; i < _currentDrawNotes.Length; ++i) { _currentDrawNotes[i] = new List<Note>(); } // _startButton.SetActive(false); State = GameState.WAIT; _startNotePrefab = Resources.Load<GameObject>("startNote"); _endNotePrefab = Resources.Load<GameObject>("endNote"); if (_startNotePrefab == null || _endNotePrefab == null) { Debug.Log("can not find circle image!"); } }
/// <summary> /// ノードが保持している楽曲データを更新する。 /// 画面に表示する楽曲名と、内部の楽曲データを更新する。 /// </summary> /// <param name="md">MusicData。</param> public void UpdateMusicData(MusicData md) { title.text = md.name; Md = md; }
public override void CancelEdit() { base.CancelEdit(); currentData = copyData; }
public override void EndEdit() { base.EndEdit(); copyData = new MusicData(); }
void Awake() { music = this.GetComponentInChildren <MusicData>(); sound = this.GetComponentInChildren <SoundData>(); }
//单频段检测节拍 void CheckBeatInClip(int indBand) { Debug.LogError("band start=" + indBand + " BeatArrayList count " + BeatAnalysisManager.BAL.Count); string temp = ""; int peaktimeindex = 0; int peaktimeindexlast = 0; //上一个峰值的位置 //float peakvalue=RecAvgInBandInc [0,indBand];//第一个用来比较的值 float peakvalue = RecAvgInBand [0, indBand]; //第一个用来比较的值 int startindex = -1; int endindex = -1; int _wavelength = -1; for (int i = 5; i < BeatAnalysisManager.MAL.Count - 5; i++) { float _wavelengthindex = i / (BeatAnalysisManager.MAL.Count / numSubdivide * 1f); _wavelengthindex = Mathf.Clamp(_wavelengthindex, 0, (numSubdivide - 1)); _wavelength = (int)wavelengths [(int)Mathf.Floor(_wavelengthindex)]; startindex = (int)Mathf.Max(0, (_wavelength / 8 + peaktimeindexlast), (i - _wavelength / 2)); startindex = (int)Mathf.Min(startindex, BeatAnalysisManager.MAL.Count - 1); endindex = (int)Mathf.Min((startindex + _wavelength), BeatAnalysisManager.MAL.Count); int finallength = endindex - startindex; temp += i + " ,start=" + startindex + " ,end=" + endindex + " length=" + finallength + " wavelength=" + _wavelength; //peakvalue=RecAvgInBandInc[startindex ,indBand ]; peakvalue = RecAvgInBand[startindex, indBand]; for (int ind = 0; (ind < finallength && ind + startindex < BeatAnalysisManager.MAL.Count); ind++) { //float newvalue=RecAvgInBandInc[startindex +ind,indBand ]; float newvalue = RecAvgInBand[startindex + ind, indBand]; if (peakvalue < newvalue) { peakvalue = newvalue; peaktimeindex = startindex + ind; } peakvalue *= decay; //衰减 //outputs [i] =(1-衰减)*(当前-前帧)+outputs [i] *衰减 } temp += " peaktimeindex=" + peaktimeindex; if (peaktimeindex - peaktimeindexlast > _wavelength / 4) { //保存鼓点信息 MusicData md = new MusicData(); //md= md.playtime = RecAvgInBand [peaktimeindex, numBands]; //_audio.time; md.OnBeat = true; md.BeatPos = indBand; if (beatArrindex < BeatAnalysisManager.BAL.Count) { (BeatAnalysisManager.BAL [beatArrindex]) = md; //.playtime = RecAvgInBand [peaktimeindex, numBands];//_audio.time; } else { //MusicData BeatAnalysisManager.BAL.Add(md); } beatArrindex++; temp += " beat"; //end 保存鼓点信息 peaktimeindexlast = peaktimeindex; } else { peaktimeindexlast += _wavelength / 2; } temp += "\n"; if (i < peaktimeindexlast) { i = peaktimeindexlast; //Debug.LogWarning (">>> i="+i+" last="+peaktimeindexlast+"from"+startindex+" to "+endindex); } } Debug.LogError("band end=" + indBand + " BeatArrayList count " + BeatAnalysisManager.BAL.Count + " ////" + temp); }
private AudioClip GetMusicClip(EMusicType eMusic) { MusicData musicData = _musicList.Find(musicfx => musicfx.eMusic == eMusic); return(musicData?.Clip); }
public void SetValue(MusicData target) { musicData = target; title.text = musicData.desc.name; info.text = $"{musicData.desc.artist} / {musicData.desc.genre}"; }