/// <summary> /// 条件を変更して再計算 /// </summary> public async void UpdateData() { settingManager.InitParam4Repro(); SettingSender ud_setting = new SettingSender("NewSetting", MeasurementParameter.colormapID, MeasurementParameter.MaxIntensity, MeasurementParameter.MinIntensity, MeasurementParameter.objSize); How2Measure measureType = new How2Measure(nowMeasurementType, MeasurementParameter.i_block); tServer.SendAllClient(transferData.SerializeJson <How2Measure>(measureType)); //更新データをHololensに送信 string json = transferData.SerializeJson <SettingSender>(ud_setting); tServer.SendAllClient(json); UpdateSTFTParam(); //再計算を実行 if (nowAlogrithm == AlgorithmPattern.CrossSpectrum) { ReCalcDataPackage recalcIntensity = await Task.Run(() => AsyncReCalc()); string json2 = transferData.SerializeJson <ReCalcDataPackage>(recalcIntensity); tServer.SendAllClient(json2); logQueue.Enqueue("Update data"); } else { ReCalcTransientDataPackage recalcTransIntensity = await Task.Run(() => AsyncReCalcTrans()); string json2 = transferData.SerializeJson <ReCalcTransientDataPackage>(recalcTransIntensity); tServer.SendAllClient(json2); logQueue.Enqueue("Update data"); } }
/// <summary> /// 更新インテンシティデータをエディタ上でも反映させていくようにする /// </summary> /// <param name="reCalcDataPackage">更新データ</param> /// <returns></returns> private IEnumerator UpdateEditor(ReCalcTransientDataPackage reCalcTransientDataPackage) { int frame = reCalcTransientDataPackage.iintensityList.Count / reCalcTransientDataPackage.storageNum; for (int i = 0; i < reCalcTransientDataPackage.storageNum; i++) { if (intensities.ContainsKey(reCalcTransientDataPackage.sendNums[i])) { var pushObj = intensities[reCalcTransientDataPackage.sendNums[i]]; //色変更を行う pushObj.transform.localRotation = Quaternion.LookRotation(10000000000 * reCalcTransientDataPackage.intensities[i]); var lv = AcousticMathNew.CalcuIntensityLevel(reCalcTransientDataPackage.intensities[i]); pushObj.transform.GetComponent<Renderer>().material.color = ColorBar.DefineColor(MeasurementParameter.colormapID, lv, MeasurementParameter.MinIntensity, MeasurementParameter.MaxIntensity); //瞬時音響インテンシティの変更 var intensityDirection = new Vector3[frame]; float[] intensityLv = new float[frame]; for (int j = 0; j < frame; j++) { intensityDirection[j] = reCalcTransientDataPackage.iintensityList[i * frame + j]; intensityLv[j] = MathFFTW.CalcuIntensityLevel(intensityDirection[j]); } var parameter = pushObj.GetComponent<ParameterStorage>(); parameter.PutIntensity(intensityDirection, intensityLv); yield return null; } } yield return null; }
public async Task<ReCalcTransientDataPackage> RecalcTransientIntensity() { //データの更新 ReCalcTransientDataPackage recalcTransientIntensity = await Task.Run(() => AsyncReCalc()); //送信データの更新 StartCoroutine("UpdateEditor", recalcTransientIntensity); return recalcTransientIntensity; }
/// <summary> /// Updateボタンに紐づけ /// 条件を変え再計算をし表示を更新する /// </summary> public async void UpdateTransientData() { settingManager.InitParam(); SettingSender ud_setting = new SettingSender("NewSetting", MeasurementParameter.colormapID, MeasurementParameter.MaxIntensity, MeasurementParameter.MinIntensity, MeasurementParameter.objSize); //設定データをHoloLens2に送信 string json = transferData.SerializeJson <SettingSender>(ud_setting); tServer.SendAllClient(json); //再計算を実行 ReCalcTransientDataPackage reCalcTransientDataPackage = await tIntensityManager.RecalcTransientIntensity(); string json2 = transferData.SerializeJson <ReCalcTransientDataPackage>(reCalcTransientDataPackage); tServer.SendAllClient(json2); }
private ReCalcTransientDataPackage AsyncReCalcTrans() { ReCalcTransientDataPackage data = new ReCalcTransientDataPackage(dataStorages.Count); List <Vector3> iintensities = new List <Vector3>(); foreach (DataStorage dataStorage in dataStorages) { iintensities.Clear(); //時間変化する音響インテンシティを指定したアルゴリズムを元に計算 switch (nowAlogrithm) { case AlgorithmPattern.instantaneous: //直接法 var intensity = AcousticSI.DirectMethod(dataStorage.soundSignal, MeasurementParameter.AtmDensity, MeasurementParameter.MInterval); data.intensities.Add(AcousticSI.SumIntensity(intensity)); data.iintensityList.AddRange(intensity); break; case AlgorithmPattern.STFT: //STFTを使った時間周波数領域での計算処理 var intensity2 = MathFFTW.STFTmethod(dataStorage.soundSignal, MeasurementParameter.n_overlap, MeasurementParameter.i_block, MeasurementParameter.Fs, MeasurementParameter.FreqMin, MeasurementParameter.FreqMax, MeasurementParameter.AtmDensity, MeasurementParameter.MInterval); data.intensities.Add(AcousticSI.SumIntensity(intensity2)); data.iintensityList.AddRange(intensity2); break; case AlgorithmPattern.AmbisonicsT: //アンビソニックマイクを使った時間領域のpsudoIntensityの推定 var intensity3 = MathAmbisonics.TdomMethod(dataStorage.soundSignal, MeasurementParameter.AtmDensity, 340); data.intensities.Add(AcousticSI.SumIntensity(intensity3)); data.iintensityList.AddRange(intensity3); break; case AlgorithmPattern.AmbisonicsTF: //アンビソニックマイクを使った時間周波数領域のpsudoIntensityの推定 var intensity4 = MathAmbisonics.TFdomMethod(dataStorage.soundSignal, MeasurementParameter.n_overlap, MeasurementParameter.i_block, MeasurementParameter.Fs, MeasurementParameter.FreqMin, MeasurementParameter.FreqMax, MeasurementParameter.AtmDensity, 340); data.intensities.Add(AcousticSI.SumIntensity(intensity4)); data.iintensityList.AddRange(intensity4); break; } intensityLogs.Enqueue(new IntensityLog(dataStorage.measureNo, dataStorage.micLocalPos, data.intensities[data.intensities.Count - 1])); data.sendNums.Add(dataStorage.measureNo); } return(data); }
private ReCalcTransientDataPackage AsyncReCalc() { ReCalcTransientDataPackage data = new ReCalcTransientDataPackage(dataStorages.Count); List<Vector3> iintensities = new List<Vector3>(); foreach (DataStorage dataStorage in dataStorages.Values) { iintensities.Clear(); //時間変化する音響インテンシティを指定したアルゴリズムを元に計算 switch (algorithmList.value) { case 0://直接法 var intensity = AcousticSI.DirectMethod(dataStorage.soundSignal, MeasurementParameter.AtmDensity, MeasurementParameter.MInterval); data.intensities.Add(AcousticSI.SumIntensity(intensity)); data.iintensityList.AddRange(intensity); break; case 1://STFTを使った時間周波数領域での計算処理 var intensity2 = MathFFTW.STFTmethod(dataStorage.soundSignal, MeasurementParameter.n_overlap, MeasurementParameter.i_block, MeasurementParameter.Fs, MeasurementParameter.FreqMin, MeasurementParameter.FreqMax, MeasurementParameter.AtmDensity, MeasurementParameter.MInterval); data.intensities.Add(AcousticSI.SumIntensity(intensity2)); data.iintensityList.AddRange(intensity2); break; case 2://アンビソニックマイクを使った時間領域のpsudoIntensityの推定 var intensity3 = MathAmbisonics.TdomMethod(dataStorage.soundSignal, MeasurementParameter.AtmDensity, 340); data.intensities.Add(AcousticSI.SumIntensity(intensity3)); data.iintensityList.AddRange(intensity3); break; case 3://アンビソニックマイクを使った時間周波数領域のpsudoIntensityの推定 var intensity4 = MathAmbisonics.TFdomMethod(dataStorage.soundSignal, MeasurementParameter.n_overlap, MeasurementParameter.i_block, MeasurementParameter.Fs, MeasurementParameter.FreqMin, MeasurementParameter.FreqMax, MeasurementParameter.AtmDensity, 340); data.intensities.Add(AcousticSI.SumIntensity(intensity4)); data.iintensityList.AddRange(intensity4); break; } data.sendNums.Add(dataStorage.measureNo); } return data; }