public void TestChunking() { List<Int16> data = new List<Int16>(); data.AddRange(Dirty); data.AddRange(Leader); data.AddRange(Data); data.AddRange(Dirty); // Note that this won't be read, as there is no leader. data.AddRange(Data); data.AddRange(Dirty); data.AddRange(Leader); data.AddRange(Data); data.AddRange(Dirty); SoundData audio = new SoundData(data); SoundData[] chunks = Analyzer.SplitChunks(audio); Assert.AreEqual(2, chunks.Length, "The test should produce 2 chunks."); for (int i = 0; i < 2; ++i) { IEnumerator<Int16> ie = chunks[i].GetEnumerator(); for (int j = 0; j < Data.Length; ++j) { ie.MoveNext(); Assert.AreEqual(Data[j], ie.Current); } Assert.IsFalse(ie.MoveNext()); } }
/// <summary> /// Converts audio data into a binary format by squaring off the data. /// </summary> /// /// <param name="data">The data to convert.</param> /// <returns>The converted data.</returns> public BinaryData ConvertToSquare(SoundData data) { Int16[] sample = new Int16[4]; List<bool> binData = new List<bool>(); IEnumerator<Int16> audio = data.GetEnumerator(); bool end = false; while (true) { for (int i = 0; i < 4; ++i) { if (audio.MoveNext()) { sample[i] = audio.Current; } else { end = true; break; } } if (end) { break; } bool[] sizes = NormalizeSample(audio, sample); // After all that, all we really need is the third value. binData.Add(sizes[2]); } return new BinaryData(binData); }
private static void SetSoundList() { // ファイルが選択されている時. if (Selection.assetGUIDs != null && Selection.assetGUIDs.Length > 0) { //サウンドリストを確保 SoundList soundList = AssetDatabase.LoadAssetAtPath(SoundListPass, typeof(SoundList)) as SoundList; // 選択されているファイルの数だけ繰り返す foreach (var file in Selection.assetGUIDs) { var path = AssetDatabase.GUIDToAssetPath(file); //パスの文字列を取得 var fileName = System.IO.Path.GetFileNameWithoutExtension(path); //ファイル名を取得 var fileExtension = System.IO.Path.GetExtension(path); //ファイルの拡張子を取得 //拡張子が違う場合はリスト追加しない if (fileExtension != ".wav") { Debug.Log("<color=blue>" + "Not SoundFile : " + fileName + "</color>"); continue; } bool isUpdated = false; //SoundListを全検索 for(int i=0;i < soundList.SoundDatas.Count;i++) { //すでにリストにあったものを更新 if (soundList.SoundDatas[i].SoundDataKey == fileName) { soundList.SoundDatas[i].Sound = AssetDatabase.LoadAssetAtPath(path,typeof(AudioClip)) as AudioClip; isUpdated = true; Debug.Log("<color=yellow>" + "SoundList Update : " + fileName + "</color>"); break; } } //リストになかったので追加 if (!isUpdated) { SoundData dataSet = new SoundData(); dataSet.SoundDataKey = fileName; dataSet.Type = SoundType.BGM; dataSet.Sound = AssetDatabase.LoadAssetAtPath(path, typeof(AudioClip)) as AudioClip; dataSet.SyncCount = 1; dataSet.Volume = 1; dataSet.Distance = 1000; dataSet.RollOff = AudioRolloffMode.Linear; dataSet.DopplerLevel = 0; dataSet.pitch = 1; soundList.SoundDatas.Add(dataSet); Debug.Log("<color=green>" + "SoundList Add : " + fileName + "</color>"); } } CreateSoundKeyDef(soundList.SoundDatas.Select(c => c.SoundDataKey.ToString()).ToArray()); //サウンドキーを更新 AssetDatabase.SaveAssets(); } }
/// <summary> /// Splits sound data into its loudest chunks, ignoring the ambient noise /// surrounding them. /// </summary> /// /// <remarks> /// This method assumes that the data is a lot louder than the noise around /// it. The first part of every bit sample has to be a large value, so when /// the average on the right of where we're looking jumps radically, we /// know we've found something. /// </remarks> /// /// <param name="data">The data to split up.</param> /// <returns>The resultant chunks.</returns> public SoundData[] SplitChunks(SoundData data) { List<SoundData> chunks = TrimNoise(data.GetSoundEnumerator()); SoundData[] output = new SoundData[chunks.Count]; for (int i = 0; i < chunks.Count; ++i) { output[i] = chunks[i]; } return output; }
public void TestEnumerator() { Int16[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; SoundData audio = new SoundData(new List<Int16>(data)); IEnumerator<Int16> ie = audio.GetEnumerator(); for (int i = 0; i < data.Length; ++i) { ie.MoveNext(); Assert.AreEqual(data[i], ie.Current, "Enumerator values."); } }
public void TestBadData() { Int16[] data = { 50, 50, 50, 50 }; SoundData audio = new SoundData(data, 0, 0, 0, 0, 0, 0); try { BinaryData bin = analyzer.ConvertToSquare(audio); Assert.Fail("An exception was expected, but not thrown."); } catch { } }
public CassetteData[] ChunkData(SoundData data) { IEnumerator<Int16> ie = data.GetEnumerator(); float average = 0; int count = 0; ie.MoveNext(); List<CassetteData> chunks = new List<CassetteData>(); MetaData meta = null; do { Int16 level = ie.Current, abs = Math.Abs(level); int rate; // Eat a little first to even out the average, then start checking. if (count >= IgnoreHead) { if (level > 5 * average && (rate = FindLeader(ie)) > 0) { if (meta == null) { MetaParser parser = new MetaParser(ie, rate); meta = (MetaData) parser.Parse(); } else { ProgramParser parser = new ProgramParser(ie, rate, meta.ProgramSize); ProgramData program = (ProgramData) parser.Parse(); chunks.Add(new CassetteData(meta, program)); meta = null; } rate = count = 0; } } // Don't let data or spikes screw up our noise muffler. if (count < IgnoreHead || !(abs > 5 * average)) { average = (average * count + abs) / ++count; } else { count++; } } while (ie.MoveNext()); CassetteData[] output = new CassetteData[chunks.Count]; for (int i = 0; i < output.Length; ++i) { output[i] = chunks[i]; } return output; }
public MyEffectInstance(MyAudioEffect effect, IMySourceVoice input, MySourceVoice[] cues, float? duration, XAudio2 engine) { m_engine = engine; m_effect = effect; var inputSound = input as MySourceVoice; if (inputSound != null && inputSound.IsValid && inputSound.Voice != null && inputSound.Voice.IsValid()) { Debug.Assert(!inputSound.Voice.IsDisposed); var sd = new SoundData() { Sound = inputSound, Pivot = 0, CurrentEffect = 0, OrigVolume = inputSound.Volume, OrigFrequency = inputSound.FrequencyRatio, }; //FilterParameters fp = new FilterParameters(); m_sounds.Add(sd); } foreach(var sound in cues) { Debug.Assert(!sound.Voice.IsDisposed); sound.Start(false); //jn:todo effect command to start sound m_sounds.Add(new SoundData() { Sound = sound, Pivot = 0, CurrentEffect = 0, OrigVolume = sound.Volume, OrigFrequency = sound.FrequencyRatio, }); } if(OutputSound != null) OutputSound.StoppedPlaying += EffectFinished; ComputeDurationAndScale(duration); Update(0); }
/// <summary> /// Confirms whether the next part of the data is a leader field, meaning /// that data lies afterwards. /// </summary> /// /// <param name="ie">The enumerator of data.</param> /// <returns>Whether the data was a leader field.</returns> private bool IsLeader(SoundData.SoundEnumerator ie) { // Probably the start of some data! Let's just check a couple more // data points to make sure. FrequencyAnalyzer analyzer = new FrequencyAnalyzer(); Int16[] sample = new Int16[4]; try { // The leader field is 3600 bits long. for (int i = 0; i < 3600; ++i) { sample = ie.CurrentFour; if (sample == null) { return false; } // Normalise the sample to check if it fits the leader spec. bool[] sizes = analyzer.NormalizeSample(ie, sample); if (!sizes[2]) { if (sample[0] > 10000) { for (int k = 0; k < 4; ++k) { Console.Write(sample[k] + " "); } Console.WriteLine(); } // The leader field is all 1s. return false; } ie.MoveNextFour(); } // Nothing thrown, so we have data. return true; } catch { // Not data! Oh well, just keep looking. return false; } }
//!!! replace SoundData private void playMusicButton_Click(object sender, RoutedEventArgs e) { SoundData data = (sender as Button)?.DataContext as SoundData; if (data == null) { return; } if (AudioPlayer.CurrentState==Windows.UI.Xaml.Media.MediaElementState.Playing&&data==playingSound) { AudioPlayer.Stop(); return; } playingSound = data; //check if filetypeEnum is uri or custom, if type is custom ---> get file from FutureAccessList, using metadata if (data.fileType == SoundData.FileTypeEnum.Uri) { AudioPlayer.Source = new Uri(data.FilePath, UriKind.RelativeOrAbsolute); } else { if (data.Stream!=null) { AudioPlayer.SetSource(data.Stream, ""); } else { PlayCustomSong(); } } }
public void startBreakActLockEffect() { SoundData.play("uicp_break"); }
public void TestLowQualityData() { Int16[] data = { 5230, 23, 64, 4654, 43, 53, 4987, 5231, 54, 34, 34 }; SoundData audio = new SoundData(data, 0, 0, 0, 0, 0, 0); BinaryData bin = analyzer.ConvertToSquare(audio); IEnumerator<bool> ie = bin.GetEnumerator(); for (int i = 0; i < 2; ++i) { ie.MoveNext(); Assert.AreEqual(i % 2 == 0, ie.Current, "Sample " + i); } }
//----------------------------------------------------------------------------- // サウンド更新 :発音したらtrue //----------------------------------------------------------------------------- bool soundUpdate(int soundId=0) { bool ret = false; if(soundId!=0){ GameObject camObj = GameObject.FindGameObjectWithTag("tagCameraBase"); if(camObj!=null){ SoundManage.SoundData data = new SoundData(); data.parent=gameObject; data.soundstr = "coinHit"; SoundManager smg = camObj.GetComponent<SoundManager>(); smg.SendMessage("queue",data); ret = true; } } return ret; }
public void startPlaySound(SoundData soundsToPlay) { playSound(soundsToPlay); }
void onClickUseHero(GameObject go) { SoundData.play("uihe_changehero"); if (GameDataManager.instance.selectHeroId == nowHero) { return; } if (GameDataManager.instance.selectSubHeroId != null) { switch (nowHero) { case Character.LEO: if (GameDataManager.instance.serverHeroData.ContainsKey(Character.CHLOE)) { EpiServer.instance.sendChangeHero(nowHero, Character.CHLOE); } else if (GameDataManager.instance.serverHeroData.ContainsKey(Character.KILEY)) { EpiServer.instance.sendChangeHero(nowHero, Character.KILEY); } else { EpiServer.instance.sendChangeHero(nowHero, null); } break; case Character.KILEY: if (GameDataManager.instance.serverHeroData.ContainsKey(Character.CHLOE)) { EpiServer.instance.sendChangeHero(nowHero, Character.CHLOE); } else { EpiServer.instance.sendChangeHero(nowHero, Character.LEO); } break; case Character.CHLOE: if (GameDataManager.instance.serverHeroData.ContainsKey(Character.KILEY)) { EpiServer.instance.sendChangeHero(nowHero, Character.KILEY); } else { EpiServer.instance.sendChangeHero(nowHero, Character.LEO); } break; } } else { EpiServer.instance.sendChangeHero(nowHero, GameDataManager.instance.selectHeroId); } }
private static void UpdateVolume(SoundData sData, MyAudioEffect.SoundEffect effect, float effPosition) { if (effect.VolumeCurve != null) sData.Sound.SetVolume(sData.OrigVolume * effect.VolumeCurve.Evaluate(effPosition)); }
public void onReceiveItem(UIMissionListSlotPanel panel) { SoundData.play("uiet_missionrwd"); EpiServer.instance.sendRequestMissionReward(panel.data.id); }
public void startPreCam() { if (HellModeManager.instance.isOpen) { return; } if (GameManager.me.stageManager.nowPlayingGameType == GameType.Mode.Sigong) { return; } if (GameDataManager.instance.canCutScenePlay == false && GameManager.me.stageManager.nowRound.mode != RoundData.MODE.PVP) { return; } if (GameManager.me.playMode == GameManager.PlayMode.replay) { // GameManager.me.uiManager.uiPlay.btnReplayClose.isEnabled = false; //return; } GameManager.setTimeScale = 1.0f; nowSkillEffectCamStatus = SKILL_EFFECT_CAM_STATUS.None; isFollowPlayerWhenSkillEffectCamIdle = false; usePlayerPositionOffsetWhenSkillEffectCam = false; isPlayingPreCam = false; camShotList.Clear(); GameManager.me.characterManager.sort(); List <Monster> l = GameManager.me.characterManager.monsters; PlayCamShotData d0 = new PlayCamShotData(); PlayCamShotData d1 = new PlayCamShotData(); PlayCamShotData d2 = new PlayCamShotData(); PlayCamShotData d3 = new PlayCamShotData(); PlayCamShotData d4 = new PlayCamShotData(); if (l.Count == 0) { return; } cameraTarget = l[l.Count - 1].cTransform; switch (GameManager.me.stageManager.nowRound.mode) { case RoundData.MODE.KILLEMALL: //KILLEMALL -> 먼 곳에서 서서히 히어로쪽으로 줌인하며 원래 카메라 위치로 if (MathUtil.abs(cameraTarget.position.x, GameManager.me.player.cTransform.position.x) > 1500.0f) { isPlayingPreCam = true; GameManager.setTimeScale = 1.0f; GameManager.me.cutSceneManager.useCutSceneCamera = true; d0.init(); d0.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d0.time = 0.5f; d0.setCamPos = true; d0.newCamPos = getCameraCenterPosition(cameraTarget, 0.6f, 0.4f, 15); //20); d0.motionTime = 1.5f; d0.fov = 15; //20; d0.easingType = "EaseOut,Cubic"; d1.init(); d1.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d1.time = d0.motionTime + 0.01f; d1.setCamPos = true; d1.newCamPos = getCameraCenterPosition(cameraTarget, 0.4f, 0.5f, 10); d1.fov = 10; d1.motionTime = 0.6f; d1.easingType = "EaseOut,Sine"; Monster lm = GameManager.me.characterManager.getVeryLeftMonster(false); _v.x = -842 + ((lm != null)?lm.cTransform.localPosition.x:0) - GameManager.me.gameCameraContainer.transform.position.x; _v.y = 1230; _v.z = -2168; lm = null; d2.init(); d2.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d2.time = d1.motionTime + 0.01f; d2.setCamPos = true; d2.newCamPos = _v; //getCameraCenterPosition(GameManager.me.player.cTransform, 0.24f, 0.4f, 15); d2.fov = 15; d2.setCamRot = true; d2.newCamRot = new Vector3(27, 25, 0); d2.motionTime = 3.0f; d2.easingType = "EaseOut,Cubic"; d3.playType = UIPlayCameraEditor.PLAY_TYPE_RESETCAM; d3.time = d2.motionTime + 0.01f; camShotList.Add(d0); camShotList.Add(d1); camShotList.Add(d2); camShotList.Add(d3); camShotEditor.playCodes(camShotList.ToArray()); } break; case RoundData.MODE.SURVIVAL: // SURVIVAL -> 히어로 뒤쪽에서 원래 위치로 isPlayingPreCam = true; GameManager.setTimeScale = 1.0f; GameManager.me.cutSceneManager.useCutSceneCamera = true; Vector3 startPos = GameManager.me.player.cTransform.position; startPos.x += -1358; startPos.y += 411; startPos.z += 6; _v2 = startPos; _v2.x += 1360; _v2.y -= 250.0f; d0.init(); d0.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d0.time = 0.5f; d0.setCamPos = true; d0.newCamPos = _v2; d0.fov = 7; d0.setCamRot = true; d0.newCamRot = new Vector3(1, 90, 0); d0.motionTime = 1.5f; d0.easingType = "EaseOut,Sine"; _v2 = startPos; _v2.x -= 400.0f; d1.init(); d1.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d1.time = d0.motionTime + 0.5f; d1.setCamPos = true; d1.newCamPos = _v2; d1.fov = 18; d1.setCamRot = true; d1.newCamRot = new Vector3(5, 90, 0); d1.motionTime = 0.5f; d1.easingType = "EaseOut,Sine"; d2.init(); d2.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d2.time = d1.motionTime + 0.5f; d2.setCamPos = true; d2.newCamPos = new Vector3(296.5178f, 1165.279f, -2168.0f); d2.fov = 15; d2.setCamRot = true; d2.newCamRot = new Vector3(27, 0, 0); d2.motionTime = 1.0f; d2.easingType = "EaseOut,Cubic"; d3.init(); d3.playType = UIPlayCameraEditor.PLAY_TYPE_RESETCAM_WITHOUT_FADE; d3.time = d1.motionTime + 0.1f; gameCameraPosContainer.localPosition = startPos; _v.x = 16.0f; _v.y = 90.0f; _v.z = 0.0f; _q = gameCamera.transform.localRotation; _q.eulerAngles = _v; gameCamera.transform.localRotation = _q; gameCamera.fieldOfView = 16.0f; camShotList.Add(d0); camShotList.Add(d1); camShotList.Add(d2); camShotList.Add(d3); camShotEditor.playCodes(camShotList.ToArray()); break; case RoundData.MODE.PROTECT: // PROTECT -> 보호 대상과 히어로를 투샷으로 비추고 원래위치로 isPlayingPreCam = true; GameManager.setTimeScale = 1.0f; GameManager.me.cutSceneManager.useCutSceneCameraWithoutClipSetting(); _v = GameManager.me.stageManager.playerProtectObjectMonster[0].cTransform.position; d0.init(); d0.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d0.time = 0.0f; d0.setCamPos = true; d0.newCamPos = getCameraCenterPosition(_v, 0.55f, 0.4f, 8); d0.motionTime = 2.0f; d0.fov = 8; d0.easingType = "EaseOut,Cubic"; d2.init(); d2.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d2.time = d2.motionTime + 2.0f; d2.setCamPos = true; d2.newCamPos = new Vector3(296.5178f, 1165.279f, -2168.0f); d2.fov = 15; d2.motionTime = 1.5f; d2.easingType = "EaseOut,Cubic"; d3.playType = UIPlayCameraEditor.PLAY_TYPE_RESETCAM_WITHOUT_FADE; d3.time = d2.motionTime + 0.01f; camShotList.Add(d0); camShotList.Add(d2); camShotList.Add(d3); camShotEditor.playCodes(camShotList.ToArray()); break; case RoundData.MODE.SNIPING: // SNIPING -> 적 보스를 비춰주다가 원래위치로 isPlayingPreCam = true; GameManager.me.cutSceneManager.useCutSceneCameraWithoutClipSetting(); d0.init(); d0.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d0.time = 0.5f; d0.setCamPos = true; d0.newCamPos = getCameraCenterPosition(GameManager.me.stageManager.heroMonster[0].cTransform, 0.6f, 0.3f, 20); d0.motionTime = 1.5f; d0.setCamRot = true; d0.newCamRot = new Vector3(27, 5, 0); d0.fov = 22; d0.easingType = "EaseOut,Cubic"; d1.init(); d1.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d1.time = d0.motionTime + 0.01f; d1.setCamPos = true; d1.newCamPos = getCameraCenterPosition(GameManager.me.stageManager.heroMonster[0].cTransform, 0.4f, 0.3f, 10); d1.fov = 10; d0.newCamRot = new Vector3(27, 0, 0); d1.motionTime = 1.5f; d1.easingType = "EaseOut,Sine"; d2.init(); d2.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d2.time = d1.motionTime + 0.01f; d2.setCamPos = true; d2.newCamPos = new Vector3(296.5178f, 1165.279f, -2168.0f); d2.fov = 15; d2.motionTime = 3.0f; d2.easingType = "EaseOut,Cubic"; d3.playType = UIPlayCameraEditor.PLAY_TYPE_RESETCAM_WITHOUT_FADE; d3.time = d2.motionTime + 0.01f; camShotList.Add(d0); camShotList.Add(d1); camShotList.Add(d2); camShotList.Add(d3); camShotEditor.playCodes(camShotList.ToArray()); break; case RoundData.MODE.KILLCOUNT: // KILLCOUNT -> 해당 몬스터 3마리를 히어로와 먼 순서대로 샷으로 때려주고 원래위치로 isPlayingPreCam = true; GameManager.me.cutSceneManager.useCutSceneCamera = true; _v.x = 18; _v.y = 90; _v.z = 0; _q.eulerAngles = _v; gameCamera.transform.localRotation = _q; _v.x = -1079; _v.y = 411; _v.z = 0; gameCameraPosContainer.transform.localPosition = _v; gameCamera.fieldOfView = 18; string kid = GameManager.me.stageManager.nowRound.killMonsterIds[0]; //mapManager.leftKilledMonsterNum l.Sort(_sortByTransformX); int nowIndex = 0; for (int i = l.Count - 1; i >= 0; --i) { if (l[i].unitData != null && l[i].unitData.id == kid) { _v = l[i].cTransform.position; _v.x += -1358; _v.y += 411; _v.z += -100; switch (nowIndex) { case 0: d0.init(); d0.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d0.time = 0.5f; d0.setCamPos = true; d0.newCamPos = _v; d0.motionTime = 1.2f; d0.setCamRot = true; d0.newCamRot = new Vector3(18, 84, 0); d0.fov = 18; d0.easingType = "EaseOut,Cubic"; camShotList.Add(d0); break; case 1: d1.init(); d1.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d1.time = 1.5f; d1.setCamPos = true; d1.newCamPos = _v; d1.motionTime = 0.3f; d1.setCamRot = true; d1.newCamRot = new Vector3(18, 84, 0); d1.fov = 18; d1.easingType = "EaseOut,Cubic"; camShotList.Add(d1); break; case 2: d2.init(); d2.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d2.time = 0.6f; d2.setCamPos = true; d2.newCamPos = _v; d2.motionTime = 0.3f; d2.setCamRot = true; d2.newCamRot = new Vector3(18, 84, 0); d2.fov = 18; d2.easingType = "EaseOut,Cubic"; camShotList.Add(d2); break; } ++nowIndex; } } d3.init(); d3.playType = UIPlayCameraEditor.PLAY_TYPE_RESETCAM; d3.time = 0.6f; camShotList.Add(d3); // gameCameraPosContainer.localPosition = startPos; // _v.x = 16.0f; _v.y = 90.0f; _v.z = 0.0f; // _q = gameCamera.transform.localRotation; // _q.eulerAngles = _v; // gameCamera.transform.localRotation = _q; // // gameCamera.fieldOfView = 16.0f; camShotEditor.playCodes(camShotList.ToArray()); break; case RoundData.MODE.ARRIVE: // ARRIVE -> 목적지점에서 그대로 왼쪽으로 (추격몬스터 보여주고) 원래 위치로 이동 isPlayingPreCam = true; GameManager.me.cutSceneManager.useCutSceneCameraWithoutClipSetting(); _v = getCameraCenterPosition(new Vector3(GameManager.me.stageManager.nowRound.targetPos, 0, 0), 0.5f, 0.4f, 15); //18); gameCameraPosContainer.localPosition = _v; if (GameManager.me.stageManager.chaser != null) { d0.init(); d0.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d0.time = 1.0f; d0.setCamPos = true; d0.newCamPos = getCameraCenterPosition(GameManager.me.stageManager.chaser.transform, 0.2f, 0.4f, 15); //18); d0.motionTime = 0.5f; d0.fov = 15; //18; d0.easingType = "EaseOut,Cubic"; camShotList.Add(d0); } d2.init(); d2.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d2.time = 1.5f; d2.setCamPos = true; d2.newCamPos = new Vector3(296.5178f, 1165.279f, -2168.0f); d2.fov = 15; d2.motionTime = 0.5f; d2.easingType = "EaseOut,Cubic"; camShotList.Add(d2); d3.playType = UIPlayCameraEditor.PLAY_TYPE_RESETCAM_WITHOUT_FADE; d3.time = 0.5f; camShotList.Add(d3); camShotEditor.playCodes(camShotList.ToArray()); break; case RoundData.MODE.DESTROY: // DESTROY -> 목표물 전부 샷으로 보여주고, (추격몬스터 보여주고) 원래위치로 이동 isPlayingPreCam = true; GameManager.me.cutSceneManager.useCutSceneCameraWithoutClipSetting(); // d0.init(); // d0.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; // d0.time = 0.0f; // d0.setCamPos = true; // d0.newCamPos = getCameraCenterPosition(cameraTarget, 0.6f, 0.4f, 20); // d0.motionTime = 0.5f; // d0.fov = 20; // d0.easingType = "EaseOut,Cubic"; // // camShotList.Add(d0); // 샷. float prevTile = d0.motionTime; for (int i = GameManager.me.stageManager.playerDestroyObjectMonster.Length - 1; i >= 0; --i) { _sorter.Add(GameManager.me.stageManager.playerDestroyObjectMonster[i]); } _sorter.Sort(_sortByTransformX); int q = 0; for (int i = _sorter.Count - 1; i >= 0; --i) { PlayCamShotData pd = new PlayCamShotData(); pd.init(); pd.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; pd.time = 0.8f; pd.setCamPos = true; pd.newCamPos = getCameraCenterPosition(_sorter[i].cTransform, 0.4f, 0.3f, 11); pd.fov = 11; pd.motionTime = 0.3f; pd.easingType = "EaseOut,Sine"; camShotList.Add(pd); ++q; } _sorter.Clear(); // 샷. d3.playType = UIPlayCameraEditor.PLAY_TYPE_RESETCAM; d3.time = camShotList[camShotList.Count - 1].motionTime + 0.5f; camShotList.Add(d3); camShotEditor.playCodes(camShotList.ToArray()); break; case RoundData.MODE.GETITEM: // GETITEM -> 앞에서 목표 유닛 3마리를 샷으로 때리면서 원래위치로 이동 isPlayingPreCam = true; GameManager.me.cutSceneManager.useCutSceneCamera = true; _v.x = 18; _v.y = 90; _v.z = 0; _q.eulerAngles = _v; gameCamera.transform.localRotation = _q; _v.x = -1079; _v.y = 411; _v.z = 0; gameCameraPosContainer.transform.localPosition = _v; gameCamera.fieldOfView = 18; l.Sort(_sortByTransformX); int j = 0; int mlen = l.Count; for (int i = 0; i < mlen; ++i) { if (l[i].unitData != null && GameManager.me.stageManager.nowRound.getItemData.isCreateItemMonster(l[i].unitData.id)) { _v = l[i].cTransform.position; _v.x += -1358; _v.y += 411; _v.z += -100; switch (j) { case 0: d0.init(); d0.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d0.time = 1.0f; d0.setCamPos = true; d0.newCamPos = _v; d0.motionTime = 1.2f; d0.setCamRot = true; d0.newCamRot = new Vector3(18, 84, 0); d0.fov = 18; d0.easingType = "EaseOut,Cubic"; camShotList.Add(d0); break; case 1: d1.init(); d1.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d1.time = 1.5f; d1.setCamPos = true; d1.newCamPos = _v; d1.motionTime = 0.3f; d1.setCamRot = true; d1.newCamRot = new Vector3(18, 84, 0); d1.fov = 18; d1.easingType = "EaseOut,Cubic"; camShotList.Add(d1); break; case 2: d2.init(); d2.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d2.time = 0.6f; d2.setCamPos = true; d2.newCamPos = _v; d2.motionTime = 0.3f; d2.setCamRot = true; d2.newCamRot = new Vector3(18, 84, 0); d2.fov = 18; d2.easingType = "EaseOut,Cubic"; camShotList.Add(d2); break; } ++j; } } d3.init(); d3.playType = UIPlayCameraEditor.PLAY_TYPE_RESETCAM; d3.time = 0.6f; camShotList.Add(d3); // gameCameraPosContainer.localPosition = startPos; // _v.x = 16.0f; _v.y = 90.0f; _v.z = 0.0f; // _q = gameCamera.transform.localRotation; // _q.eulerAngles = _v; // gameCamera.transform.localRotation = _q; // // gameCamera.fieldOfView = 16.0f; camShotEditor.playCodes(camShotList.ToArray()); break; case RoundData.MODE.PVP: isPlayingPreCam = true; //GameManager.me.cutSceneManager.useCutSceneCameraWithoutClipSetting(); GameManager.me.cutSceneManager.useCutSceneCamera = true; _v.x = 767.6f; _v.y = 2135.43f; _v.z = -3127.116f; gameCameraPosContainer.localPosition = _v; _q.eulerAngles = new Vector3(31.08f, 0, 0); gameCamera.transform.localRotation = _q; gameCamera.fieldOfView = 16.2f; d1.init(); d1.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d1.time = 1.0f; d1.setCamPos = true; d1.newCamPos = new Vector3(767.6f, 854.3f, -2153.043f); d1.setCamRot = true; d1.newCamRot = new Vector3(15.2f, 20.85f, 0.0f); d1.fov = 14.2f; d1.motionTime = 1.0f; d1.easingType = "EaseOut,Cubic"; camShotList.Add(d1); d2.init(); d2.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d2.time = d1.time + 0.1f; d2.setCamRot = true; d2.newCamRot = new Vector3(15.2f, -18.16f, 0.0f); d2.fov = 14.2f; d2.motionTime = 0.5f; d2.easingType = "EaseOut,Cubic"; camShotList.Add(d2); d0.init(); d0.playType = UIPlayCameraEditor.PLAY_TYPE_MOVE; d0.time = 0.6f; d0.setCamPos = true; _v.x = 767.6f; _v.y = 1630.052f; _v.z = -2616.303f; d0.newCamPos = _v; d0.setCamRot = true; d0.newCamRot = new Vector3(29.12f, 0.0f, 0.0f); d0.motionTime = 0.5f; d0.fov = 20.6f; // 22.6f d0.easingType = "EaseOut,Cubic"; camShotList.Add(d0); d3.playType = UIPlayCameraEditor.PLAY_TYPE_RESETCAM; d3.time = 0.51f; camShotList.Add(d3); camShotEditor.playCodes(camShotList.ToArray()); break; default: isPlayingPreCam = false; GameManager.me.cutSceneManager.useCutSceneCamera = false; break; } goEpicPreCamInfo.SetActive(isPlayingPreCam && (GameManager.me.stageManager.nowRound.mode != RoundData.MODE.PVP)); cameraTarget = GameManager.me.player.cTransform; SoundManager.instance.stopTutorialVoice(); SoundData.play("precam_bgm"); }
public void WriteSoundData(SoundData data, string location) { Stream stream = GetStream(location); BinaryWriter writer = new BinaryWriter(stream); int size = (data.Length) * data.BitsPerSample / 8; // The "RIFF" chunk descriptor. writer.Write("RIFF".ToCharArray()); writer.Write((Int32) (36 + size)); writer.Write("WAVE".ToCharArray()); // The "fmt" sub-chunk. writer.Write("fmt ".ToCharArray()); writer.Write((Int32) 16); writer.Write((Int16) 1); writer.Write((Int16) 1); writer.Write((Int32) data.SampleRate); writer.Write((Int32) data.SampleRate * 2); writer.Write((Int16) 16); writer.Write((Int16) 16); // The "data" sub-chunk. writer.Write("data".ToCharArray()); writer.Write((Int32) size); foreach (Int16 sample in data) { writer.Write((Int16) sample); } writer.Close(); stream.Close(); stream.Dispose(); }
public void onSelectSlot(UISummonInvenSlot s, GameIDData data) { if (UIReinforceBarPanel.isReinforceMode) { selectSlot = null; if (s.data == null) { return; } reinforcePanel.onClick(s); } else if (UIComposePanel.isComposeMode) { selectSlot = null; if (s.data == null) { return; } composePanel.onClick(s); } else if (UIMultiSellPanel.isMultiSell) { selectSlot = null; if (s.data == null) { return; } sellPanel.onClick(s); } else if (mode == Mode.Normal) { if (data != null) { selectSlot = s; s.select = false; GameManager.me.uiManager.popupSummonDetail.show(data, RuneInfoPopup.Type.Normal, s.isInventorySlot); } } else if (mode == Mode.PutOn) { if (s.isInventorySlot || _selectSlotData == null) { return; } switch (s.index) { case 0: _slotId = UnitSlot.U1; break; case 1: _slotId = UnitSlot.U2; break; case 2: _slotId = UnitSlot.U3; break; case 3: _slotId = UnitSlot.U4; break; case 4: _slotId = UnitSlot.U5; break; } SoundData.play("uirn_runeattach"); EpiServer.instance.sendChangeUnitRune(tabPlayer.currentTab, _slotId, _selectSlotData.serverId); } }
public void PlayOneShot(string name) { sd = Sounds.Find(s => s.Name == name); Source.PlayOneShot(sd.Clip, sd.Volume); }
private void OnDataChanged(string undoName, SoundData data) { RecordUndo(undoName, data); }
private int ProcessNewSoundData(SoundData data) { if (data.GetSoundCommand().CompareTo("jump") == 0) { KeyboardInputProcessor.KeyboardData newKeyboardData = new KeyboardInputProcessor.KeyboardData(); newKeyboardData.KeyboardAction = (int)KeyboardAction.JUMP; newKeyboardData.KeyPersistance = (int)KeyboardPersistance.PRESS_AND_RELEASE; soundLogger.Debug("Adding Jump sound command to the keyboard queue"); keyboardProcessor.AddToQueue(newKeyboardData); soundLogger.Debug("Successfully added"); } if (data.GetSoundCommand().CompareTo("reload") == 0) { KeyboardInputProcessor.KeyboardData newKeyboardData = new KeyboardInputProcessor.KeyboardData(); newKeyboardData.KeyboardAction = (int)KeyboardAction.RELOAD; newKeyboardData.KeyPersistance = (int)KeyboardPersistance.PRESS_AND_RELEASE; soundLogger.Debug("Adding Jump sound command to the keyboard queue"); keyboardProcessor.AddToQueue(newKeyboardData); soundLogger.Debug("Successfully added"); } if (data.GetSoundCommand().CompareTo("knife") == 0) { KeyboardInputProcessor.KeyboardData newKeyboardData = new KeyboardInputProcessor.KeyboardData(); newKeyboardData.KeyboardAction = (int)KeyboardAction.KNIFE; newKeyboardData.KeyPersistance = (int)KeyboardPersistance.PRESS_AND_RELEASE; soundLogger.Debug("Adding KNIFE sound command to the keyboard queue"); keyboardProcessor.AddToQueue(newKeyboardData); soundLogger.Debug("Successfully added"); } if (data.GetSoundCommand().CompareTo("grenade") == 0) { KeyboardInputProcessor.KeyboardData newKeyboardData = new KeyboardInputProcessor.KeyboardData(); newKeyboardData.KeyboardAction = (int)KeyboardAction.GRENADE; newKeyboardData.KeyPersistance = (int)KeyboardPersistance.PRESS_AND_RELEASE; soundLogger.Debug("Adding grenade sound command to the keyboard queue"); keyboardProcessor.AddToQueue(newKeyboardData); soundLogger.Debug("Successfully added"); } if (data.GetSoundCommand().CompareTo("menu") == 0 || data.GetSoundCommand().CompareTo("pause") == 0) { KeyboardInputProcessor.KeyboardData newKeyboardData = new KeyboardInputProcessor.KeyboardData(); newKeyboardData.KeyboardAction = (int)KeyboardAction.ESC; newKeyboardData.KeyPersistance = (int)KeyboardPersistance.PRESS_AND_RELEASE; soundLogger.Debug("Adding Menu/Pause sound command to the keyboard queue"); keyboardProcessor.AddToQueue(newKeyboardData); soundLogger.Debug("Successfully added"); } if (data.GetSoundCommand().CompareTo("select") == 0 || data.GetSoundCommand().CompareTo("okay") == 0 || data.GetSoundCommand().CompareTo("enter") == 0) { KeyboardInputProcessor.KeyboardData newKeyboardData = new KeyboardInputProcessor.KeyboardData(); newKeyboardData.KeyboardAction = (int)KeyboardAction.ENTER; newKeyboardData.KeyPersistance = (int)KeyboardPersistance.PRESS_AND_RELEASE; soundLogger.Debug("Adding select/okay/enter sound command to the keyboard queue"); keyboardProcessor.AddToQueue(newKeyboardData); soundLogger.Debug("Successfully added"); } if (data.GetSoundCommand().CompareTo("up") == 0) { KeyboardInputProcessor.KeyboardData newKeyboardData = new KeyboardInputProcessor.KeyboardData(); newKeyboardData.KeyboardAction = (int)KeyboardAction.UP_ARROW; newKeyboardData.KeyPersistance = (int)KeyboardPersistance.PRESS_AND_RELEASE; soundLogger.Debug("Adding up sound command to the keyboard queue"); keyboardProcessor.AddToQueue(newKeyboardData); soundLogger.Debug("Successfully added"); } if (data.GetSoundCommand().CompareTo("down") == 0) { KeyboardInputProcessor.KeyboardData newKeyboardData = new KeyboardInputProcessor.KeyboardData(); newKeyboardData.KeyboardAction = (int)KeyboardAction.DOWN_ARROW; newKeyboardData.KeyPersistance = (int)KeyboardPersistance.PRESS_AND_RELEASE; soundLogger.Debug("Adding down sound command to the keyboard queue"); keyboardProcessor.AddToQueue(newKeyboardData); soundLogger.Debug("Successfully added"); } if (data.GetSoundCommand().CompareTo("right") == 0) { KeyboardInputProcessor.KeyboardData newKeyboardData = new KeyboardInputProcessor.KeyboardData(); newKeyboardData.KeyboardAction = (int)KeyboardAction.RIGHT_ARROW; newKeyboardData.KeyPersistance = (int)KeyboardPersistance.PRESS_AND_RELEASE; soundLogger.Debug("Adding right command to the keyboard queue"); keyboardProcessor.AddToQueue(newKeyboardData); soundLogger.Debug("Successfully added"); } if (data.GetSoundCommand().CompareTo("left") == 0) { KeyboardInputProcessor.KeyboardData newKeyboardData = new KeyboardInputProcessor.KeyboardData(); newKeyboardData.KeyboardAction = (int)KeyboardAction.LEFT_ARROW; newKeyboardData.KeyPersistance = (int)KeyboardPersistance.PRESS_AND_RELEASE; soundLogger.Debug("Adding left sound command to the keyboard queue"); keyboardProcessor.AddToQueue(newKeyboardData); soundLogger.Debug("Successfully added"); } return (int)ResultCodes.Success; }
private static void UpdateFilter(SoundData sData, MyAudioEffect.SoundEffect effect) { if (effect.Filter != MyAudioEffect.FilterType.None) { if (!sData.CurrentFilter.HasValue) { sData.CurrentFilter = new FilterParameters() { Frequency = effect.Frequency, OneOverQ = effect.OneOverQ, Type = (FilterType)effect.Filter }; } sData.Sound.Voice.SetFilterParameters(sData.CurrentFilter.Value); } }
public void onSelectSlot(UISkillInvenSlot s, GameIDData data) { if (UIReinforceBarPanel.isReinforceMode) { selectSlot = null; if (s.data == null) { return; } reinforcePanel.onClick(s); } else if (UIComposePanel.isComposeMode) { selectSlot = null; if (s.data == null) { return; } composePanel.onClick(s); } else if (UIMultiSellPanel.isMultiSell) { selectSlot = null; if (s.data == null) { return; } sellPanel.onClick(s); } else if (mode == Mode.Normal) { if (data != null) { selectSlot = s; s.select = false; GamePlayerData selectHeroData = null; GameDataManager.instance.heroes.TryGetValue(tabPlayer.currentTab, out selectHeroData); GameManager.me.uiManager.popupSkillPreview.show(data, RuneInfoPopup.Type.Normal, s.isInventorySlot, true, selectHeroData); } } else if (mode == Mode.PutOn) { if (s.isInventorySlot || _selectSlotData == null) { return; } switch (s.index) { case 0: _slotId = SkillSlot.S1; break; case 1: _slotId = SkillSlot.S2; break; case 2: _slotId = SkillSlot.S3; break; } SoundData.play("uirn_runeattach"); EpiServer.instance.sendChangeSkillRune(tabPlayer.currentTab, _slotId, _selectSlotData.serverId); } }
public void open(bool isFriendly = false) { if (isFriendly) { if (GameManager.me.stageManager.nowPlayingGameResult != Result.Type.Win) { AdviceData.checkAdvice(UISystemPopup.checkLevelupPopupAndReturnToScene); return; } } needGoToMenu = true; base.show(); face.init(UIPlay.pvpImageUrl); face.down(UIPlay.pvpImageUrl); lbName.text = PlayerPrefs.GetString("PVPNAME", ""); if (string.IsNullOrEmpty(lbName.text)) { lbName.text = pvpName; } // lbRewardType.text = ""; if (GameManager.me.stageManager.nowPlayingGameResult == Result.Type.Win) { spResultType.spriteName = "img_result_win"; goWinContainer.SetActive(true); // goMoveContainer.transform.localPosition = new Vector3(-226.3281f,136.8f, -191.1182f); GameManager.soundManager.stopBG(); SoundData.play("bgm_win_b"); } else { spResultType.spriteName = "img_result_lose"; goWinContainer.SetActive(false); // goMoveContainer.transform.localPosition = new Vector3(-226.3281f,104.6f, -191.1f); GameManager.soundManager.stopBG(); SoundData.play("bgm_lose_a"); } spResultType.MakePixelPerfect(); lbWinCnt.gameObject.SetActive(false); lbLoseCnt.gameObject.SetActive(false); if (isFriendly) { goChampionshipPanel.gameObject.SetActive(false); lbWinPoint.gameObject.SetActive(false); // spPrizeIcon.spriteName = WSDefine.ICON_GOLD; //lbRewardType.text = Util.getUIText("RECEIVE_EXP"); lbFriendlyResult.gameObject.SetActive(true); string pName = PlayerPrefs.GetString("CURRENT_FRIENDLY_ENEMY_NAME", ""); if (string.IsNullOrEmpty(pName)) { pName = enemyName; } if (GameManager.me.stageManager.nowPlayingGameResult == Result.Type.Win) { lbFriendlyResult.text = Util.getUIText("WINNING_FRIENDLY_PVP", pName, Util.getUIText("WIN")); // lbFriendlyGuide.text = Util.getUIText("FRIENDLY_REWARD_GUIDE"); lbFriendlyGuide.enabled = false; } else { lbFriendlyResult.text = Util.getUIText("WINNING_FRIENDLY_PVP", pName, Util.getUIText("LOSE")); lbFriendlyGuide.enabled = false; } } else { lbFriendlyResult.gameObject.SetActive(false); // spPrizeIcon.spriteName = WSDefine.ICON_GOLD; lbWinCnt.gameObject.SetActive(true); lbLoseCnt.gameObject.SetActive(true); goChampionshipPanel.gameObject.SetActive(true); int winCnt = 0; int loseCnt = 0; for (int i = 0; i < UIChampionshipListSlotPanel.ROUND_IDS.Length; i++) { if (GameDataManager.instance.championshipData.champions[enemyId].attackRounds[UIChampionshipListSlotPanel.ROUND_IDS[i]].result == "W") { winCnt++; } else if (GameDataManager.instance.championshipData.champions[enemyId].attackRounds[UIChampionshipListSlotPanel.ROUND_IDS[i]].result == "L") { loseCnt++; } } lbWinCnt.text = winCnt.ToString(); lbLoseCnt.text = loseCnt.ToString(); // lbRewardType.text = Util.getUIText("WINNING_PRIZE"); } spPrizeIcon.MakePixelPerfect(); lbWinPoint.gameObject.SetActive(false); if (isFriendly) { lbMatchNumber.text = Util.getUIText("FRIENDLY_MATCH"); } else { lbMatchNumber.text = Util.getUIText("MATCH_NUMBER", matchNumber + ""); //int point = 0; //_v = lbWinPoint.transform.localPosition; /* * if(GameManager.me.stageManager.nowPlayingGameResult == Result.Type.Win) point = 3; * * switch(matchNumber) * { * case 1: * _v = btns[0].transform.localPosition; * break; * case 2: * _v = btns[1].transform.localPosition; * break; * case 3: * _v = btns[2].transform.localPosition; * break; * } */ //_v = lbWinCnt.transform.localPosition; if (score > 0) { //lbWinPoint.gameObject.SetActive(true); //lbWinPoint.text = "+"+score.ToString(); /* * _v.y += 30.0f; * lbWinPoint.transform.localPosition = _v; * lbWinPoint.text = "+"+score.ToString(); * _v.y += 60; * Color c = lbWinPoint.color; * c.a = 1.0f; * lbWinPoint.color = c; * c.a = 0.0f; * StartCoroutine(playWinPointEffect(c)); */ } else { //lbWinPoint.gameObject.SetActive(false); } } lbPrize.text = Util.GetCommaScore(prizeGold); }
private void LongListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e) { LongListSelector selector = sender as LongListSelector; // verifying our sender is actually a LongListSelector if (selector == null) { return; } SoundData data = selector.SelectedItem as SoundData; // verifying our sender is actually SoundData if (data == null) { return; } if (data.IsDownloaded) { this.PlaySound(IsolatedStorageFile.GetUserStoreForApplication().OpenFile(data.SavePath, FileMode.Open, FileAccess.Read, FileShare.Read)); } else { if (!SimpleIoc.Default.GetInstance <INetworkService>().IsConnectionAvailable) { MessageBox.Show("You need an internet connection to download this sound."); } else { WebClient client = new WebClient(); client.DownloadProgressChanged += (senderClient, args) => { SoundData passedData = (SoundData)args.UserState; Dispatcher.BeginInvoke(() => { passedData.DownloadProgress = args.ProgressPercentage; }); }; client.OpenReadCompleted += (senderClient, args) => { if (args.Error != null) { MessageBox.Show("Error downloading sound", args.Error.Message, MessageBoxButton.OK); } else { SoundData passedData = (SoundData)args.UserState; using (IsolatedStorageFileStream fileStream = IsolatedStorageFile.GetUserStoreForApplication().CreateFile(passedData.SavePath)) { args.Result.Seek(0, SeekOrigin.Begin); args.Result.CopyTo(fileStream); this.PlaySound(fileStream); passedData.Status = DownloadStatus.Downloaded; } args.Result.Close(); } }; client.OpenReadAsync(new Uri(data.FilePath), data); data.Status = DownloadStatus.Downloading; } } selector.SelectedItem = null; }
public PlayMusicMessage(SoundData soundData) { this.SoundData = soundData; }
private void OnGUI() { if (SoundTool.soundData == null) { return; } EditorGUILayout.BeginVertical(); { //Add, Copy, Remove Button Area. EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button("Add", GUILayout.Width(widthMiddle))) { SoundTool.soundData.AddSound("NewSound"); selection = SoundTool.soundData.GetDataCount() - 1; soundSource = null; GUI.FocusControl("ID"); } GUI.SetNextControlName("Copy"); if (GUILayout.Button("Copy", GUILayout.Width(widthMiddle))) { GUI.FocusControl("Copy"); SoundTool.soundData.CopyData(selection); soundSource = null; selection = SoundTool.soundData.GetDataCount() - 1; } if (SoundTool.soundData.GetDataCount() > 1) { GUI.SetNextControlName("Remove"); if (GUILayout.Button("Remove", GUILayout.Width(widthMiddle))) { GUI.FocusControl("Remove"); soundSource = null; SoundTool.soundData.RemoveData(selection); } } } EditorGUILayout.EndHorizontal(); //가운데부분 UI영역 EditorGUILayout.BeginHorizontal(); { //soundData List -> selection Grid EditorGUILayout.BeginVertical(GUILayout.Width(widthLarge)); { EditorGUILayout.Separator(); EditorGUILayout.BeginVertical("Box"); { scrollPoint1 = EditorGUILayout.BeginScrollView(scrollPoint1); { if (SoundTool.soundData.GetDataCount() > 0) { int prevSelection = selection; selection = GUILayout.SelectionGrid(selection, SoundTool.soundData.GetNameList(true), 1); if (prevSelection != selection) { soundSource = null; } } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); //상세 설정 수정하는 UI EditorGUILayout.BeginVertical(); { scrollPoint2 = EditorGUILayout.BeginScrollView(scrollPoint2); { if (SoundTool.soundData.GetDataCount() > 0) { EditorGUILayout.BeginVertical(); { EditorGUILayout.Separator(); GUI.SetNextControlName("ID"); EditorGUILayout.LabelField("ID", this.selection.ToString(), GUILayout.Width(widthLarge)); SoundTool.soundData.names[selection] = EditorGUILayout.TextField("Name", SoundTool.soundData.names[selection], GUILayout.Width(widthXLarge)); SoundTool.soundData.soundClips[selection].playType = (SoundPlayType)EditorGUILayout.EnumPopup("PlayType", SoundTool.soundData.soundClips[selection].playType, GUILayout.Width(widthLarge)); SoundTool.soundData.soundClips[selection].maxVolume = EditorGUILayout.FloatField("Volume", SoundTool.soundData.soundClips[selection].maxVolume, GUILayout.Width(widthXLarge)); SoundTool.soundData.soundClips[selection].isLoop = EditorGUILayout.Toggle("Loop Clip", SoundTool.soundData.soundClips[selection].isLoop, GUILayout.Width(widthLarge)); EditorGUILayout.Separator(); if (soundSource == null && SoundTool.soundData.soundClips[selection].clipName != string.Empty) { soundSource = SoundTool.soundData.soundClips[selection].GetClip(); } soundSource = (AudioClip)EditorGUILayout.ObjectField("Audio Clip", this.soundSource, typeof(AudioClip), false, GUILayout.Width(widthLarge)); if (soundSource != null) { SoundTool.soundData.soundClips[selection].clipPath = EditorHelper.GetPath(this.soundSource); SoundTool.soundData.soundClips[selection].clipName = this.soundSource.name; SoundTool.soundData.soundClips[selection].pitch = EditorGUILayout.Slider("Pitch", SoundTool.soundData.soundClips[selection].pitch, -3.0f, 3.0f, GUILayout.Width(widthXLarge)); SoundTool.soundData.soundClips[selection].dopplerLevel = EditorGUILayout.Slider("Doppler Level", SoundTool.soundData.soundClips[selection].dopplerLevel, 0.0f, 5.0f, GUILayout.Width(widthXLarge)); SoundTool.soundData.soundClips[selection].audioRolloffMode = (AudioRolloffMode)EditorGUILayout.EnumPopup("RollOffMode", SoundTool.soundData.soundClips[selection].audioRolloffMode, GUILayout.Width(widthXLarge)); SoundTool.soundData.soundClips[selection].minDistance = EditorGUILayout.FloatField("MinDistance", SoundTool.soundData.soundClips[selection].minDistance, GUILayout.Width(widthXLarge)); SoundTool.soundData.soundClips[selection].maxDistance = EditorGUILayout.FloatField("MaxDistance", SoundTool.soundData.soundClips[selection].maxDistance, GUILayout.Width(widthXLarge)); SoundTool.soundData.soundClips[selection].spatialBlend = EditorGUILayout.Slider("Spatial Blend", SoundTool.soundData.soundClips[selection].spatialBlend, 0.0f, 1.0f, GUILayout.Width(widthXLarge)); } else { SoundTool.soundData.soundClips[selection].clipName = string.Empty; SoundTool.soundData.soundClips[selection].clipPath = string.Empty; } EditorGUILayout.Separator(); if (GUILayout.Button("Add Loop", GUILayout.Width(widthXLarge))) { SoundTool.soundData.soundClips[selection].AddLoop(); } for (int i = 0; i < SoundTool.soundData.soundClips[selection].checkTime.Length; i++) { EditorGUILayout.BeginVertical("box"); { GUILayout.Label("Loop Step " + i, EditorStyles.boldLabel); if (GUILayout.Button("Remove", GUILayout.Width(widthMiddle))) { SoundTool.soundData.soundClips[selection].RemoveLoop(i); return; } SoundTool.soundData.soundClips[selection].checkTime[i] = EditorGUILayout.FloatField("CheckTime " + i.ToString(), SoundTool.soundData.soundClips[selection].checkTime[i], GUILayout.Width(widthXLarge)); SoundTool.soundData.soundClips[selection].setTime[i] = EditorGUILayout.FloatField("SetTime " + i.ToString(), SoundTool.soundData.soundClips[selection].setTime[i], GUILayout.Width(widthXLarge)); } EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); //하단 버튼 영역. EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); { GUI.SetNextControlName("Reload"); if (GUILayout.Button("Reload")) { GUI.FocusControl("Reload"); soundData = ScriptableObject.CreateInstance <SoundData>(); soundData.LoadData(); selection = 0; this.soundSource = null; } GUI.SetNextControlName("Save"); if (GUILayout.Button("Save")) { GUI.FocusControl("Save"); SoundTool.soundData.SaveData(); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } if (SoundTool.soundData.soundClips.Length > 1) { GUI.SetNextControlName("Import"); if (GUILayout.Button("Import")) { GUI.FocusControl("Import"); CreateEnumStructure(); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } } } EditorGUILayout.EndHorizontal(); }
private void AddList(SoundData soundData) { if (soundData == null) { return; } bool isrefresh; SoundList soundList; { SoundList fsoundList = soundLists.Find((x) => x.FileName == soundData.path); if (fsoundList != null) { soundList = fsoundList; isrefresh = true; } else { soundList = new SoundList(); isrefresh = false; } } soundList.FileName = soundData.path; soundList.Size = soundData.bytes.Length / 1024 + "kb"; soundList.soundData = soundData; WaveFormat waveFormat = null; long Samplerate = 0; long Bitrate = 0; try { if (System.IO.Path.GetExtension(soundData.path).ToLower() == ".wav") { WaveFileReader waveFileReader = new WaveFileReader(new MemoryStream(soundData.bytes)); waveFormat = waveFileReader.WaveFormat; soundList.Len = waveFileReader.TotalTime.ToString(); } else if (System.IO.Path.GetExtension(soundData.path).ToLower() == ".ogg") { NAudio.Vorbis.VorbisWaveReader vorbisWaveReader = new NAudio.Vorbis.VorbisWaveReader(new MemoryStream(soundData.bytes)); waveFormat = vorbisWaveReader.WaveFormat; soundList.Len = vorbisWaveReader.TotalTime.ToString(); } Samplerate = waveFormat.SampleRate; Bitrate = Samplerate * waveFormat.BitsPerSample * waveFormat.Channels; } catch (Exception) { } soundList.Samplerate = Samplerate + "Hz"; soundList.Bitrate = Bitrate / 1000 + "kb"; if (!isrefresh) { soundLists.Add(soundList); } MainListbox.ItemsSource = null; MainListbox.ItemsSource = soundLists; }
public override void ReadData(ESPReader reader, long dataEnd) { while (reader.BaseStream.Position < dataEnd) { string subTag = reader.PeekTag(); switch (subTag) { case "EDID": if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadBinary(reader); break; case "OBND": if (ObjectBounds == null) { ObjectBounds = new ObjectBounds(); } ObjectBounds.ReadBinary(reader); break; case "FNAM": if (Filename == null) { Filename = new SimpleSubrecord <String>(); } Filename.ReadBinary(reader); break; case "RNAM": if (RandomChance == null) { RandomChance = new SimpleSubrecord <Byte>(); } RandomChance.ReadBinary(reader); break; case "SNDD": if (SoundData == null) { SoundData = new SoundData(); } SoundData.ReadBinary(reader); break; case "SNDX": if (SoundDataShort == null) { SoundDataShort = new SoundDataShort(); } SoundDataShort.ReadBinary(reader); break; case "ANAM": if (AttenuationCurve == null) { AttenuationCurve = new SoundAttenuation(); } AttenuationCurve.ReadBinary(reader); break; case "GNAM": if (ReverbAttenuationControl == null) { ReverbAttenuationControl = new SimpleSubrecord <Int16>(); } ReverbAttenuationControl.ReadBinary(reader); break; case "HNAM": if (SoundPriority == null) { SoundPriority = new SimpleSubrecord <Int32>(); } SoundPriority.ReadBinary(reader); break; default: throw new Exception(); } } }
public void TestGoodData() { Int16[] data = { 5000, 50, 5000, 50, 5000, 5000, 50, 50, 5000, 50, 5000, 50, 5000, 5000, 50, 50 }; SoundData audio = new SoundData(data, 0, 0, 0, 0, 0, 0); BinaryData bin = analyzer.ConvertToSquare(audio); IEnumerator<bool> ie = bin.GetEnumerator(); for (int i = 0; i < 4; ++i) { ie.MoveNext(); Assert.AreEqual(i % 2 == 0, ie.Current, "Sample " + i); } }
protected void PlayActionSequence ( ArrayList p_actionSequence ) { // check here if cueueble or action is uninteractibe. if( !this.IsInteractible() ) { if( m_bEventIsCueable ) { // Sanity check.. // 1. Should not Add ActionSequence that is currently playing // 2. Should not Add ActionSequence that is already in cue foreach( string action in p_actionSequence ) { bool containsAction = false; foreach( string cuedAction in m_cuedActions ) { if( action.Equals(cuedAction) ) containsAction = true; } if( !containsAction ) { m_cuedActions.Add(action); } #if DEBUG_CUEABLES if( containsAction ) Debug.LogError("Dragon::PlayActionSequence Dragon is not Interactible. adding "+action+" to cue."); else Debug.LogError("Dragon::PlayActionSequence Dragon is not Interactible and already contains cueable "+action+" action."); #else if( containsAction ) Log("Dragon::PlayActionSequence Dragon is not Interactible. adding "+action+" to cue."); else Log("Dragon::PlayActionSequence Dragon is not Interactible and already contains cueable "+action+" action."); #endif } return; } #if DEBUG_CUEABLES Debug.LogError("Dragon::PlayActionSequence Cannot Play this Action because Action is not Interactibe."); //Debug.Break(); #else //Log("Dragon::PlayActionSequence Cannot Play this Action:"+MiniJSON.jsonEncode(p_actionSequence)+" because Action is not Interactibe."); Debug.LogWarning("Dragon::PlayActionSequence Cannot Play this Action:"+MiniJSON.jsonEncode(p_actionSequence)+" because Action is not Interactibe. \n"); #endif return; } // clear actions DragonAnimationQueue.getInstance().ClearAll(); SoundManager.Instance.StopAnimationSound( PettingMain.Instance.HeadSoundContainer ); SoundManager.Instance.StopAnimationSound( PettingMain.Instance.BodySoundContainer ); SoundManager.Instance.StopAnimationSound( PettingMain.Instance.HeadAndBodySoundContainer ); foreach( string action in p_actionSequence ) { // Body Animations ArrayList bodyActionSequence = SequenceReader.GetInstance().ReadBodySequence(action); Log("----------- Playing Reaction:"+action+" -----------"); //LogWarning(">>>>>>> Checking action: \""+action+"\"\n"); if( bodyActionSequence != null ) { // +KJ:06132013 Shared Parameter. this supports the same random value that a cue is sharing foreach( object actionData in bodyActionSequence ) { ArrayList actionDataList = actionData as ArrayList; BodyData bodyData = new BodyData(); bodyData.Action = action; bodyData.Start = Utility.ParseToInt(actionDataList[0]); bodyData.ActionKey = actionDataList[1].ToString(); bodyData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { bodyData.Param = actionDataList[3] as Hashtable; } bodyData.ExtractHashtableValues( bodyData.Param ); bodyData.EventTrigger = this.FormulateEventTriggers( bodyData.Param ); DragonAnimationQueue.getInstance().AddBodyCue( bodyData.GenerateHashtable() ); } } // Head Animations ArrayList headActionSequence = SequenceReader.GetInstance().ReadHeadSequence(action); if( headActionSequence != null ) { foreach( object actionData in headActionSequence ) { ArrayList actionDataList = actionData as ArrayList; HeadData headData = new HeadData(); headData.Action = action; headData.Start = Utility.ParseToInt(actionDataList[0]); headData.ActionKey = actionDataList[1].ToString(); headData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { headData.Param = actionDataList[3] as Hashtable; } headData.ExtractHashtableValues( headData.Param ); headData.EventTrigger = this.FormulateEventTriggers( headData.Param ); DragonAnimationQueue.getInstance().AddHeadCue( headData.GenerateHashtable() ) ; } } // Update Queue ArrayList updateActionQueue = SequenceReader.GetInstance().ReadUpdate(action); if( updateActionQueue != null ) { foreach( object actionData in updateActionQueue ) { ArrayList actionDataList = actionData as ArrayList; UpdateData updateData = new UpdateData(); updateData.Action = action; updateData.Start = Utility.ParseToInt(actionDataList[0]); updateData.ActionKey = actionDataList[1].ToString(); updateData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { updateData.Param = actionDataList[3] as Hashtable; } updateData.EventTrigger = this.FormulateEventTriggers( updateData.Param ); DragonAnimationQueue.getInstance().AddUpdateCue( updateData.GenerateHashtable() ); } } // Transition Queue ArrayList transitionQueue = SequenceReader.GetInstance().ReadTransform(action); if( transitionQueue != null ) { foreach( object actionData in transitionQueue ) { ArrayList actionDataList = actionData as ArrayList; TransformData transformData = new TransformData(); transformData.Action = action; transformData.Start = Utility.ParseToInt(actionDataList[0]); transformData.ActionKey = actionDataList[1].ToString(); transformData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { transformData.Param = actionDataList[3] as Hashtable; } transformData.EventTrigger = this.FormulateEventTriggers( transformData.Param ); DragonAnimationQueue.getInstance().AddTransformCue( transformData.GenerateHashtable() ); } } ArrayList cameraQueue = SequenceReader.GetInstance().ReadCamera(action); if( cameraQueue != null ) { foreach( object actionData in cameraQueue ) { ArrayList actionDataList = actionData as ArrayList; CameraData cameraData = new CameraData(); cameraData.Action = action; cameraData.Start = Utility.ParseToInt(actionDataList[0]); cameraData.ActionKey = actionDataList[1].ToString(); cameraData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { cameraData.Param = actionDataList[3] as Hashtable; } cameraData.EventTrigger = this.FormulateEventTriggers( cameraData.Param ); DragonAnimationQueue.getInstance().AddCameraCue( cameraData.GenerateHashtable() ); } } ArrayList eventQueue = SequenceReader.GetInstance().ReadEventTriggers(action); if( eventQueue != null ) { foreach( object actionData in eventQueue ) { ArrayList actionDataList = actionData as ArrayList; EventData eventData = new EventData(); eventData.Action = action; eventData.Start = Utility.ParseToInt(actionDataList[0]); eventData.ActionKey = actionDataList[1].ToString(); eventData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { eventData.Param = actionDataList[3] as Hashtable; } eventData.EventTrigger = this.FormulateEventTriggers( eventData.Param ); DragonAnimationQueue.getInstance().AddEventCue( eventData.GenerateHashtable() ); } } // + LA 072613 ArrayList soundQueue = SequenceReader.GetInstance().ReadSounds(action); if( soundQueue != null ) { foreach( object actionData in soundQueue ) { ArrayList actionDataList = actionData as ArrayList; SoundData soundData = new SoundData(); soundData.Action = action; soundData.Start = Utility.ParseToInt(actionDataList[0]); soundData.ActionKey = actionDataList[1].ToString(); soundData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { soundData.Param = actionDataList[3] as Hashtable; } soundData.EventTrigger = this.FormulateEventTriggers( soundData.Param ); DragonAnimationQueue.getInstance().AddSoundCue( soundData.GenerateHashtable() ); } } // - LA } DragonAnimationQueue.getInstance().PlayQueuedAnimations(); }
public void WriteSoundData(SoundData data, string location) { WriteSoundData(data, location, 1); }
private void TryParseSoundData(Stream input) { Byte[] b = new Byte[(Int32)(input.Length - input.Position)]; Int64 position = this._dataStream.Position; input.Read(b, 0, b.Length); input.Seek(position, SeekOrigin.Begin); if (_soundstreamhead != null) { switch (this._soundstreamhead.StreamCompression) { case SoundEncoding.uncompressed_native: RawSoundData rawDataN = new RawSoundData(b, false); this._soundData = rawDataN; break; case SoundEncoding.Uncompressed_little_endian: RawSoundData rawDataL = new RawSoundData(b, true); this._soundData = rawDataL; break; case SoundEncoding.ADPCM: AdpcmSoundData ADPCMData = new AdpcmSoundData(); ADPCMData.Parse(input, this._soundstreamhead.StreamType); this._soundData = ADPCMData; break; case SoundEncoding.MP3: Mp3SoundData mp3Data = new Mp3SoundData(); mp3Data.Parse(input); this._soundData = mp3Data; break; case SoundEncoding.Nellymoser: NellymoserSoundData nellySound = new NellymoserSoundData(b); this._soundData = nellySound; break; case SoundEncoding.Nellymoser8kHz: Nellymoser8SoundData nelly8Sound = new Nellymoser8SoundData(b); this._soundData = nelly8Sound; break; case SoundEncoding.Nellymoser16kHz: Nellymoser16SoundData nelly16Sound = new Nellymoser16SoundData(b); this._soundData = nelly16Sound; break; default: SwfFormatException e = new SwfFormatException("Unsupported sound encoding found in sound stream block."); Log.Error(this, e.Message); throw e; } } else { this._soundData = new RawSoundData(b); } }
/// <summary> /// Trims noise off of the front of the given sound data. /// </summary> /// /// <remarks> /// This is also the first method call in the pipeline, so calling this /// method will continue the pipeline, cutting out the desired chunks and /// returning all the way back with them. /// </remarks> /// /// <param name="data">The data to trim.</param> private List<SoundData> TrimNoise(SoundData.SoundEnumerator ie) { List<SoundData> chunks = new List<SoundData>(); float average = 0; int count = 0; ie.MoveNext(); do { Int16 level = ie.Current, abs = Math.Abs(level); // Eat a little first to even out the average, then start checking. if (count >= AVERAGE_COUNT) { if (abs > 5 * average && IsLeader(ie)) { chunks.Add(RipChunk(ie, average)); } } // Don't let data or spikes screw up our noise muffler. if (count < AVERAGE_COUNT || !(abs > 5 * average)) { average = (average * count + abs) / ++count; } else { count++; } } while (ie.MoveNext()); return chunks; }
public override void ReadData(ESPReader reader, long dataEnd) { while (reader.BaseStream.Position < dataEnd) { string subTag = reader.PeekTag(); switch (subTag) { case "EDID": if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadBinary(reader); break; case "OBND": if (ObjectBounds == null) { ObjectBounds = new ObjectBounds(); } ObjectBounds.ReadBinary(reader); break; case "FULL": if (Name == null) { Name = new SimpleSubrecord <String>(); } Name.ReadBinary(reader); break; case "MODL": if (Model == null) { Model = new Model(); } Model.ReadBinary(reader); break; case "SPLO": if (ActorEffects == null) { ActorEffects = new List <RecordReference>(); } RecordReference tempSPLO = new RecordReference(); tempSPLO.ReadBinary(reader); ActorEffects.Add(tempSPLO); break; case "EITM": if (UnarmedAttackEffect == null) { UnarmedAttackEffect = new RecordReference(); } UnarmedAttackEffect.ReadBinary(reader); break; case "EAMT": if (UnarmedAttackAnimation == null) { UnarmedAttackAnimation = new SimpleSubrecord <UInt16>(); } UnarmedAttackAnimation.ReadBinary(reader); break; case "NIFZ": if (Models == null) { Models = new SubNullStringList(); } Models.ReadBinary(reader); break; case "NIFT": if (TextureHashes == null) { TextureHashes = new SimpleSubrecord <Byte[]>(); } TextureHashes.ReadBinary(reader); break; case "ACBS": if (BaseStats == null) { BaseStats = new CreatureBaseStats(); } BaseStats.ReadBinary(reader); break; case "SNAM": if (Factions == null) { Factions = new List <FactionMembership>(); } FactionMembership tempSNAM = new FactionMembership(); tempSNAM.ReadBinary(reader); Factions.Add(tempSNAM); break; case "INAM": if (DeathItem == null) { DeathItem = new RecordReference(); } DeathItem.ReadBinary(reader); break; case "VTCK": if (VoiceType == null) { VoiceType = new RecordReference(); } VoiceType.ReadBinary(reader); break; case "TPLT": if (Template == null) { Template = new RecordReference(); } Template.ReadBinary(reader); break; case "DEST": if (Destructable == null) { Destructable = new Destructable(); } Destructable.ReadBinary(reader); break; case "SCRI": if (Script == null) { Script = new RecordReference(); } Script.ReadBinary(reader); break; case "CNTO": if (Contents == null) { Contents = new List <InventoryItem>(); } InventoryItem tempCNTO = new InventoryItem(); tempCNTO.ReadBinary(reader); Contents.Add(tempCNTO); break; case "AIDT": if (AIData == null) { AIData = new AIData(); } AIData.ReadBinary(reader); break; case "PKID": if (Packages == null) { Packages = new List <RecordReference>(); } RecordReference tempPKID = new RecordReference(); tempPKID.ReadBinary(reader); Packages.Add(tempPKID); break; case "KFFZ": if (Animations == null) { Animations = new SubNullStringList(); } Animations.ReadBinary(reader); break; case "DATA": if (Data == null) { Data = new CreatureData(); } Data.ReadBinary(reader); break; case "RNAM": if (AttackReach == null) { AttackReach = new SimpleSubrecord <Byte>(); } AttackReach.ReadBinary(reader); break; case "ZNAM": if (CombatStyle == null) { CombatStyle = new RecordReference(); } CombatStyle.ReadBinary(reader); break; case "PNAM": if (BodyPartData == null) { BodyPartData = new RecordReference(); } BodyPartData.ReadBinary(reader); break; case "TNAM": if (TurningSpeed == null) { TurningSpeed = new SimpleSubrecord <Single>(); } TurningSpeed.ReadBinary(reader); break; case "BNAM": if (BaseScale == null) { BaseScale = new SimpleSubrecord <Single>(); } BaseScale.ReadBinary(reader); break; case "WNAM": if (FootWeight == null) { FootWeight = new SimpleSubrecord <Single>(); } FootWeight.ReadBinary(reader); break; case "NAM4": if (ImpactMaterialType == null) { ImpactMaterialType = new SimpleSubrecord <MaterialTypeUInt>(); } ImpactMaterialType.ReadBinary(reader); break; case "NAM5": if (SoundLevel == null) { SoundLevel = new SimpleSubrecord <SoundLevel>(); } SoundLevel.ReadBinary(reader); break; case "CSCR": if (SoundTemplate == null) { SoundTemplate = new RecordReference(); } SoundTemplate.ReadBinary(reader); break; case "CSDT": if (SoundData == null) { SoundData = new List <CreatureSoundData>(); } CreatureSoundData tempCSDT = new CreatureSoundData(); tempCSDT.ReadBinary(reader); SoundData.Add(tempCSDT); break; case "CNAM": if (ImpactDataset == null) { ImpactDataset = new RecordReference(); } ImpactDataset.ReadBinary(reader); break; case "LNAM": if (MeleeWeaponList == null) { MeleeWeaponList = new RecordReference(); } MeleeWeaponList.ReadBinary(reader); break; default: throw new Exception(); } } }
public void Play(string clipName, float volume = -1, float delay = -1, bool forceReplay = false) { SoundData sd = GetAudioSource(clipName); if (sd) { if (sd.soundType == SoundType.Music) { sd.Mute = _musicMute; if (SingleMusicOnly) { foreach (var soundData in m_clips[SoundType.Music].Values) { if (soundData != sd) { soundData.Dispose(); } } m_clips[SoundType.Music].Clear(); AddClip(clipName, sd); } } else { sd.Mute = _soundMute; } sd.isForceReplay = forceReplay; if (delay > 0) { sd.delay = delay; } if (volume > 0) { sd.volume = volume; } _playSound(clipName, sd); return; } LoadSoundAsnyc(clipName, (objs) => { if (objs.Length == 0) { return; } sd = GetAudioSource(clipName); if (sd == null) { var go = Instantiate(objs[0]) as GameObject; sd = go.GetComponent <SoundData>(); AddClip(clipName, sd); } if (sd.soundType == SoundType.Music) { sd.isForceReplay = forceReplay; if (SingleMusicOnly) { foreach (var soundData in m_clips[SoundType.Music].Values) { if (soundData != sd) { soundData.Dispose(); } } m_clips[SoundType.Music].Clear(); AddClip(clipName, sd); } } if (delay > 0) { sd.delay = delay; } if (volume > 0) { sd.volume = volume; } _playSound(clipName, sd); }); }
private void Process(SoundData data, string outputDir) { AudioWriter writer = new AudioWriter(); string dir = NormalizeDirectory(outputDir); writer.WriteSoundData(data, dir + "master.wav"); CassetteData[] cassettes = chunker.ChunkData(data); string[] names = new string[cassettes.Length]; for (int i = 0; i < names.Length; ++i) { string name = cassettes[0].Meta.FileName; int adjust = 0; for (int j = 0; j < i; ++j) { if (names[j] == name) { if (adjust == 0) { name += "1"; adjust = 1; } else { name = name.Substring(0, name.Length - 1) + (++adjust); } } } names[i] = name; } for (int i = 0; i < names.Length; ++i) { writer.WriteCassetteData(cassettes[i], dir + names[i] + ".wav"); } }
public Sound(SimpleSubrecord <String> EditorID, ObjectBounds ObjectBounds, SimpleSubrecord <String> Filename, SimpleSubrecord <Byte> RandomChance, SoundData SoundData, SoundDataShort SoundDataShort, SoundAttenuation AttenuationCurve, SimpleSubrecord <Int16> ReverbAttenuationControl, SimpleSubrecord <Int32> SoundPriority) { this.EditorID = EditorID; this.ObjectBounds = ObjectBounds; }
public void WriteSoundData(SoundData data, string location, int rate) { Stream stream = GetStream(location); BinaryWriter writer = new BinaryWriter(stream); int size = (data.Length / rate) * data.BitsPerSample / 8; // The "RIFF" chunk descriptor. writer.Write("RIFF".ToCharArray()); writer.Write((Int32) (36 + size)); writer.Write("WAVE".ToCharArray()); // The "fmt" sub-chunk. writer.Write("fmt ".ToCharArray()); writer.Write((Int32) 16); writer.Write((Int16) data.CompressionCode); writer.Write((Int16) 1); writer.Write((Int32) data.SampleRate / rate); writer.Write((Int32) data.BytesPerSecond); writer.Write((Int16) data.BlockAlign); writer.Write((Int16) data.BitsPerSample); // The "data" sub-chunk. writer.Write("data".ToCharArray()); writer.Write((Int32) size); foreach (Int16 sample in data) { writer.Write((Int16) sample); } //int rateCount = rate; //int posCount = 0; //int negCount = 0; //foreach (Int16 sample in data) { // if (sample > 5000) { // posCount += 1; // } else if (sample < -5000) { // negCount += 1; // } // if (rateCount == 0) { // if (posCount > negCount) { // writer.Write(15000); // } else if (negCount > posCount) { // writer.Write(-15000); // } else { // writer.Write(0); // } // posCount = 0; // negCount = 0; // rateCount = rate; // } // rateCount -= 1; //} writer.Close(); stream.Close(); stream.Dispose(); }
public void open(Dictionary <string, int> rewards) { lbMsg.text = Util.getUIText("TUTO_COMPLETE_REWARD"); int i = 0; foreach (KeyValuePair <string, int> kv in rewards) { priceContainer[i].gameObject.SetActive(true); switch (kv.Key) { case WSDefine.RUBY: sp[i].spriteName = WSDefine.ICON_RUBY; break; case WSDefine.GOLD: sp[i].spriteName = WSDefine.ICON_GOLD; break; case WSDefine.ENERGY: sp[i].spriteName = WSDefine.ICON_ENERGY; break; case WSDefine.EXP: sp[i].spriteName = WSDefine.ICON_EXP; break; } sp[i].MakePixelPerfect(); lb[i].text = Util.GetCommaScore(kv.Value); ++i; if (i >= 3) { break; } } switch (i) { case 1: priceContainer[0].width = 253; _v = priceContainer[0].transform.localPosition; _v.x = -60.0f; priceContainer[0].transform.localPosition = _v; _v = sp[0].cachedTransform.localPosition; _v.x = 226; sp[0].cachedTransform.localPosition = _v; priceContainer[1].gameObject.SetActive(false); priceContainer[2].gameObject.SetActive(false); break; case 2: priceContainer[0].width = 200; priceContainer[1].width = 200; _v = priceContainer[0].transform.localPosition; _v.x = -128.0f; priceContainer[0].transform.localPosition = _v; _v.x = 106.0f; priceContainer[1].transform.localPosition = _v; _v = lb[0].cachedTransform.localPosition; _v.x = 181.74f; lb[0].transform.localPosition = _v; lb[1].transform.localPosition = _v; priceContainer[2].gameObject.SetActive(false); break; case 3: priceContainer[0].width = 161; priceContainer[1].width = 161; _v = priceContainer[0].transform.localPosition; _v.x = -161.0f; priceContainer[0].transform.localPosition = _v; _v.x = 6.0f; priceContainer[1].transform.localPosition = _v; _v.x = 177.0f; priceContainer[2].transform.localPosition = _v; _v = lb[0].cachedTransform.localPosition; _v.x = 142; lb[0].cachedTransform.localPosition = _v; lb[1].cachedTransform.localPosition = _v; break; } // -204 -36 135 // -138 73 // gameObject.SetActive(true); if (popupPanel != null && useScaleTween && Time.timeScale >= 1.0f) { if (ani != null) { ani.Play(); } } effect.Play(); SoundData.play("uiet_tutorialrwd"); }
public override void ReadDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; if (ele.TryPathTo("EditorID", false, out subEle)) { if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadXML(subEle, master); } if (ele.TryPathTo("ObjectBounds", false, out subEle)) { if (ObjectBounds == null) { ObjectBounds = new ObjectBounds(); } ObjectBounds.ReadXML(subEle, master); } if (ele.TryPathTo("Name", false, out subEle)) { if (Name == null) { Name = new SimpleSubrecord <String>(); } Name.ReadXML(subEle, master); } if (ele.TryPathTo("Model", false, out subEle)) { if (Model == null) { Model = new Model(); } Model.ReadXML(subEle, master); } if (ele.TryPathTo("ActorEffects", false, out subEle)) { if (ActorEffects == null) { ActorEffects = new List <RecordReference>(); } foreach (XElement e in subEle.Elements()) { RecordReference tempSPLO = new RecordReference(); tempSPLO.ReadXML(e, master); ActorEffects.Add(tempSPLO); } } if (ele.TryPathTo("Unarmed/AttackEffect", false, out subEle)) { if (UnarmedAttackEffect == null) { UnarmedAttackEffect = new RecordReference(); } UnarmedAttackEffect.ReadXML(subEle, master); } if (ele.TryPathTo("Unarmed/AttackAnimation", false, out subEle)) { if (UnarmedAttackAnimation == null) { UnarmedAttackAnimation = new SimpleSubrecord <UInt16>(); } UnarmedAttackAnimation.ReadXML(subEle, master); } if (ele.TryPathTo("Models", false, out subEle)) { if (Models == null) { Models = new SubNullStringList(); } Models.ReadXML(subEle, master); } if (ele.TryPathTo("TextureHashes", false, out subEle)) { if (TextureHashes == null) { TextureHashes = new SimpleSubrecord <Byte[]>(); } TextureHashes.ReadXML(subEle, master); } if (ele.TryPathTo("BaseStats", false, out subEle)) { if (BaseStats == null) { BaseStats = new CreatureBaseStats(); } BaseStats.ReadXML(subEle, master); } if (ele.TryPathTo("Factions", false, out subEle)) { if (Factions == null) { Factions = new List <FactionMembership>(); } foreach (XElement e in subEle.Elements()) { FactionMembership tempSNAM = new FactionMembership(); tempSNAM.ReadXML(e, master); Factions.Add(tempSNAM); } } if (ele.TryPathTo("DeathItem", false, out subEle)) { if (DeathItem == null) { DeathItem = new RecordReference(); } DeathItem.ReadXML(subEle, master); } if (ele.TryPathTo("VoiceType", false, out subEle)) { if (VoiceType == null) { VoiceType = new RecordReference(); } VoiceType.ReadXML(subEle, master); } if (ele.TryPathTo("Template", false, out subEle)) { if (Template == null) { Template = new RecordReference(); } Template.ReadXML(subEle, master); } if (ele.TryPathTo("Destructable", false, out subEle)) { if (Destructable == null) { Destructable = new Destructable(); } Destructable.ReadXML(subEle, master); } if (ele.TryPathTo("Script", false, out subEle)) { if (Script == null) { Script = new RecordReference(); } Script.ReadXML(subEle, master); } if (ele.TryPathTo("Contents", false, out subEle)) { if (Contents == null) { Contents = new List <InventoryItem>(); } foreach (XElement e in subEle.Elements()) { InventoryItem tempCNTO = new InventoryItem(); tempCNTO.ReadXML(e, master); Contents.Add(tempCNTO); } } if (ele.TryPathTo("AIData", false, out subEle)) { if (AIData == null) { AIData = new AIData(); } AIData.ReadXML(subEle, master); } if (ele.TryPathTo("Packages", false, out subEle)) { if (Packages == null) { Packages = new List <RecordReference>(); } foreach (XElement e in subEle.Elements()) { RecordReference tempPKID = new RecordReference(); tempPKID.ReadXML(e, master); Packages.Add(tempPKID); } } if (ele.TryPathTo("Animations", false, out subEle)) { if (Animations == null) { Animations = new SubNullStringList(); } Animations.ReadXML(subEle, master); } if (ele.TryPathTo("Data", false, out subEle)) { if (Data == null) { Data = new CreatureData(); } Data.ReadXML(subEle, master); } if (ele.TryPathTo("AttackReach", false, out subEle)) { if (AttackReach == null) { AttackReach = new SimpleSubrecord <Byte>(); } AttackReach.ReadXML(subEle, master); } if (ele.TryPathTo("CombatStyle", false, out subEle)) { if (CombatStyle == null) { CombatStyle = new RecordReference(); } CombatStyle.ReadXML(subEle, master); } if (ele.TryPathTo("BodyPartData", false, out subEle)) { if (BodyPartData == null) { BodyPartData = new RecordReference(); } BodyPartData.ReadXML(subEle, master); } if (ele.TryPathTo("TurningSpeed", false, out subEle)) { if (TurningSpeed == null) { TurningSpeed = new SimpleSubrecord <Single>(); } TurningSpeed.ReadXML(subEle, master); } if (ele.TryPathTo("BaseScale", false, out subEle)) { if (BaseScale == null) { BaseScale = new SimpleSubrecord <Single>(); } BaseScale.ReadXML(subEle, master); } if (ele.TryPathTo("FootWeight", false, out subEle)) { if (FootWeight == null) { FootWeight = new SimpleSubrecord <Single>(); } FootWeight.ReadXML(subEle, master); } if (ele.TryPathTo("ImpactMaterialType", false, out subEle)) { if (ImpactMaterialType == null) { ImpactMaterialType = new SimpleSubrecord <MaterialTypeUInt>(); } ImpactMaterialType.ReadXML(subEle, master); } if (ele.TryPathTo("SoundLevel", false, out subEle)) { if (SoundLevel == null) { SoundLevel = new SimpleSubrecord <SoundLevel>(); } SoundLevel.ReadXML(subEle, master); } if (ele.TryPathTo("SoundTemplate", false, out subEle)) { if (SoundTemplate == null) { SoundTemplate = new RecordReference(); } SoundTemplate.ReadXML(subEle, master); } if (ele.TryPathTo("SoundData", false, out subEle)) { if (SoundData == null) { SoundData = new List <CreatureSoundData>(); } foreach (XElement e in subEle.Elements()) { CreatureSoundData tempCSDT = new CreatureSoundData(); tempCSDT.ReadXML(e, master); SoundData.Add(tempCSDT); } } if (ele.TryPathTo("ImpactDataset", false, out subEle)) { if (ImpactDataset == null) { ImpactDataset = new RecordReference(); } ImpactDataset.ReadXML(subEle, master); } if (ele.TryPathTo("MeleeWeaponList", false, out subEle)) { if (MeleeWeaponList == null) { MeleeWeaponList = new RecordReference(); } MeleeWeaponList.ReadXML(subEle, master); } }
public int AddToQueue(SoundData soundData) { //Decrement the semaphore to make sure the spot is available this.requestSoundData.WaitOne(); lock (_threadLock) { dataQueue.Enqueue(soundData); } //Increament the semaphore to indicate there is work to do int previousCount = handleRequests.Release(); return previousCount; }
//绘制窗口时调用 void OnGUI() { data = null; GUILayout.BeginArea(new Rect(5, 5, 200, 20)); GUI.Label(new Rect(0, 0, 50, 18), "搜索名称:"); searchKeyword = GUI.TextField(new Rect(55, 0, 100, 18), searchKeyword); if (GUI.Button(new Rect(160, 0, 30, 18), "搜索")) { selGridInt = 0; fetchData(searchKeyword); } GUILayout.EndArea(); float listStartX = 5; float listStartY = 25; float scrollHeight = Screen.currentResolution.height - 110; if (listNames != null && listNames.Count > 0) { float contextHeight = listNames.Count * 21; //开始滚动视图 scrollPosition = GUI.BeginScrollView(new Rect(listStartX, listStartY, 200, scrollHeight), scrollPosition, new Rect(5, 5, 190, contextHeight), false, scrollHeight < contextHeight); selGridInt = GUILayout.SelectionGrid(selGridInt, listNames.ToArray(), 1, GUILayout.Width(190)); selGridInt = selGridInt >= listNames.Count ? listNames.Count - 1 : selGridInt; data = showListData[selGridInt]; if (selGridInt != oldSelGridInt) { oldSelGridInt = selGridInt; toolState = 0; showId = data.Id; soundName = data.Name; src = data.Src; GameObject getPrefab = Statics.GetPrefabClone(src); audioClip = getPrefab.GetComponent <AudioSource>().clip; DestroyImmediate(getPrefab); pitch = data.Pitch; volume = data.Volume; } //结束滚动视图 GUI.EndScrollView(); if (data != null) { GUILayout.BeginArea(new Rect(listStartX + 205, listStartY, 600, 300)); GUI.Label(new Rect(0, 0, 60, 18), "Id:"); EditorGUI.TextField(new Rect(65, 0, 150, 18), showId); GUI.Label(new Rect(0, 20, 60, 18), "声音名称:"); soundName = EditorGUI.TextField(new Rect(65, 20, 150, 18), soundName); GUI.Label(new Rect(0, 40, 60, 18), "资源路径:"); EditorGUI.TextField(new Rect(65, 40, 255, 18), src); audioClip = EditorGUI.ObjectField(new Rect(0, 60, 320, 18), "选择音频文件", audioClip, typeof(AudioClip), true) as AudioClip; GUI.Label(new Rect(0, 80, 60, 18), "音频速率:"); pitch = EditorGUI.Slider(new Rect(65, 80, 180, 18), pitch, 0.1f, 3); GUI.Label(new Rect(0, 100, 60, 18), "音量:"); volume = EditorGUI.Slider(new Rect(65, 100, 180, 18), volume, 0.1f, 1); if (GUI.Button(new Rect(0, 120, 100, 18), "修改声音参数")) { if (audioClip == null) { this.ShowNotification(new GUIContent("音频不能为空!")); return; } if (soundName == "") { this.ShowNotification(new GUIContent("声音名不能为空!")); return; } data.Name = soundName; data.Pitch = pitch; data.Volume = volume; FileUtil.DeleteFileOrDirectory("Assets/Resources/" + showId + ".prefab"); GameObject newObj = new GameObject(); newObj.name = addId; AudioSource soundSource = newObj.AddComponent <AudioSource>(); soundSource.clip = audioClip; soundSource.loop = false; soundSource.playOnAwake = false; SoundSource source = newObj.AddComponent <SoundSource>(); source.Pitch = data.Pitch; source.Volume = data.Volume; PrefabUtility.CreatePrefab("Assets/Resources/Prefabs/Sounds/" + showId + ".prefab", newObj); DestroyImmediate(newObj); AssetDatabase.Refresh(); writeDataToJson(); oldSelGridInt = -1; getData(); fetchData(searchKeyword); this.ShowNotification(new GUIContent("修改成功")); } if (GUI.Button(new Rect(105, 120, 100, 18), "播放音频")) { PlayerPrefs.SetString("SoundEditorPlaySoundId", showId); EditorApplication.isPlaying = true; } GUILayout.EndArea(); } } else { if (GUI.Button(new Rect(10, 30, 100, 50), "结束播放")) { EditorApplication.isPlaying = false; if (!string.IsNullOrEmpty(PlayerPrefs.GetString("SoundEditorPlaySoundId"))) { addedId = PlayerPrefs.GetString("SoundEditorPlaySoundId"); PlayerPrefs.SetString("SoundEditorPlaySoundId", ""); } oldSelGridInt = -1; getData(); fetchData(searchKeyword); } } GUILayout.BeginArea(new Rect(listStartX + 205, listStartY + 300, 500, 60)); switch (toolState) { case 0: if (GUI.Button(new Rect(0, 0, 80, 18), "添加声音")) { toolState = 1; } if (GUI.Button(new Rect(85, 0, 80, 18), "删除声音")) { toolState = 2; } break; case 1: addAudioClip = EditorGUI.ObjectField(new Rect(0, 0, 420, 18), "添加音频文件", addAudioClip, typeof(AudioClip), true) as AudioClip; GUI.Label(new Rect(0, 20, 30, 18), "Id:"); addId = GUI.TextField(new Rect(35, 20, 80, 18), addId); GUI.Label(new Rect(120, 20, 50, 18), "声音名:"); addSoundName = GUI.TextField(new Rect(175, 20, 80, 18), addSoundName); if (GUI.Button(new Rect(260, 20, 80, 18), "添加")) { if (addAudioClip == null) { this.ShowNotification(new GUIContent("音频不能为空!")); return; } if (addId == "") { this.ShowNotification(new GUIContent("Id不能为空!")); return; } if (addSoundName == "") { this.ShowNotification(new GUIContent("声音名不能为空!")); return; } if (dataMapping.ContainsKey(addId)) { this.ShowNotification(new GUIContent("Id重复!")); return; } SoundData soundData = new SoundData(); GameObject newObj = new GameObject(); newObj.name = addId; AudioSource soundSource = newObj.AddComponent <AudioSource>(); soundSource.clip = addAudioClip; soundSource.loop = false; soundSource.playOnAwake = false; SoundSource source = newObj.AddComponent <SoundSource>(); source.Pitch = soundData.Pitch; source.Volume = soundData.Volume; PrefabUtility.CreatePrefab("Assets/Resources/Prefabs/Sounds/" + addId + ".prefab", newObj); DestroyImmediate(newObj); AssetDatabase.Refresh(); soundData.Id = addId; soundData.Name = addSoundName; soundData.Src = "Prefabs/Sounds/" + addId; dataMapping.Add(soundData.Id, soundData); writeDataToJson(); addedId = addId; getData(); fetchData(searchKeyword); addId = ""; addSoundName = ""; oldSelGridInt = -1; this.ShowNotification(new GUIContent("添加成功")); } if (GUI.Button(new Rect(345, 20, 80, 18), "取消")) { toolState = 0; } break; case 2: if (GUI.Button(new Rect(0, 0, 80, 18), "确定删除")) { toolState = 0; if (data != null && dataMapping.ContainsKey(data.Id)) { dataMapping.Remove(data.Id); writeDataToJson(); getData(); fetchData(searchKeyword); oldSelGridInt = -1; FileUtil.DeleteFileOrDirectory("Assets/Resources/" + data.Src + ".prefab"); AssetDatabase.Refresh(); this.ShowNotification(new GUIContent("删除成功")); } } if (GUI.Button(new Rect(85, 0, 80, 18), "取消")) { toolState = 0; } break; } GUILayout.EndArea(); }
public override void ReadDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; if (ele.TryPathTo("EditorID", false, out subEle)) { if (EditorID == null) { EditorID = new SimpleSubrecord <String>(); } EditorID.ReadXML(subEle, master); } if (ele.TryPathTo("ObjectBounds", false, out subEle)) { if (ObjectBounds == null) { ObjectBounds = new ObjectBounds(); } ObjectBounds.ReadXML(subEle, master); } if (ele.TryPathTo("Filename", false, out subEle)) { if (Filename == null) { Filename = new SimpleSubrecord <String>(); } Filename.ReadXML(subEle, master); } if (ele.TryPathTo("RandomChance", false, out subEle)) { if (RandomChance == null) { RandomChance = new SimpleSubrecord <Byte>(); } RandomChance.ReadXML(subEle, master); } if (ele.TryPathTo("SoundData", false, out subEle)) { if (SoundData == null) { SoundData = new SoundData(); } SoundData.ReadXML(subEle, master); } if (ele.TryPathTo("SoundDataShort", false, out subEle)) { if (SoundDataShort == null) { SoundDataShort = new SoundDataShort(); } SoundDataShort.ReadXML(subEle, master); } if (ele.TryPathTo("AttenuationCurve", false, out subEle)) { if (AttenuationCurve == null) { AttenuationCurve = new SoundAttenuation(); } AttenuationCurve.ReadXML(subEle, master); } if (ele.TryPathTo("ReverbAttenuationControl", false, out subEle)) { if (ReverbAttenuationControl == null) { ReverbAttenuationControl = new SimpleSubrecord <Int16>(); } ReverbAttenuationControl.ReadXML(subEle, master); } if (ele.TryPathTo("SoundPriority", false, out subEle)) { if (SoundPriority == null) { SoundPriority = new SimpleSubrecord <Int32>(); } SoundPriority.ReadXML(subEle, master); } }