private IEnumerator RecordSignal(Vector3 sendPos, Quaternion sendRot) { //音声再生 //AsioManager.startSound(); //録音のlengthbit分待つ yield return(new WaitForSeconds(4096f / 44100f)); //録音開始 soundSignals = AsioManager.GetAsioSoundSignals(isampleLength); //瞬時音響インテンシティ計算 var intensityDirection = AcousticSI.DirectMethod(soundSignals, SettingManager.AtmDensity, SettingManager.micInterval); //直接法計算 var sumIntensity = AcousticSI.SumIntensity(intensityDirection); sintensities.Add(AcousticMathNew.CalcuIntensityLevel(sumIntensity)); //データ送信 client.Send("ResultSend", sendPos.x, sendPos.y, sendPos.z, sendRot.x, sendRot.y, sendRot.z, sendRot.w, sumIntensity.x, sumIntensity.y, sumIntensity.z, Num); yield return(null); //PCがわ表示 float[] intensityLv = new float[intensityDirection.Length]; for (int i = 0; i < intensityDirection.Length; i++) { intensityLv[i] = AcousticMathNew.CalcuIntensityLevel(intensityDirection[i]); } Color color = ColorBar.DefineColor(SettingManager.colormapID, AcousticMathNew.CalcuIntensityLevel(sumIntensity), SettingManager.lvMin, SettingManager.lvMax); GameObject instant = CreateInstantObj(Num, sendPos, sendRot, sumIntensity, color, intensityDirection, intensityLv); DataStorage data = new DataStorage(Num, sendPos, sendRot, soundSignals, sumIntensity); dataStorages.Add(data); Num++; yield return(null); }
public ReproDataPackage AsyncSendData() { //インテンシティ計算の実行 ReproDataPackage data = new ReproDataPackage(dataStorages.Count, nowAlogrithm); foreach (var datastorage in dataStorages) { data.sendNums.Add(datastorage.measureNo); data.sendPoses.Add(datastorage.micLocalPos); data.sendRots.Add(datastorage.micLocalRot); switch (nowAlogrithm) { case AlgorithmPattern.CrossSpectrum: //時間平均 data.intensities.Add(datastorage.intensityDir); break; case AlgorithmPattern.instantaneous: //瞬時音響インテンシティ var iintensity = AcousticSI.DirectMethod(datastorage.soundSignal, MeasurementParameter.AtmDensity, MeasurementParameter.MInterval); data.intensities.Add(AcousticSI.SumIntensity(iintensity)); data.iintensities.AddRange(iintensity); break; case AlgorithmPattern.STFT: //STFTを使った時間周波数領域での計算処理 var iintensity2 = 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(iintensity2)); data.iintensities.AddRange(iintensity2); break; case AlgorithmPattern.AmbisonicsT: //アンビソニックマイクを使った時間領域のpsudoIntensityの推定 var iintensity3 = MathAmbisonics.TdomMethod(datastorage.soundSignal, MeasurementParameter.AtmDensity, 340); data.intensities.Add(AcousticSI.SumIntensity(iintensity3)); data.iintensities.AddRange(iintensity3); break; case AlgorithmPattern.AmbisonicsTF: //アンビソニックマイクを使った時間周波数領域のpsudoIntensityの推定 var iintensity4 = MathAmbisonics.TFdomMethod(datastorage.soundSignal, MeasurementParameter.n_overlap, MeasurementParameter.i_block, MeasurementParameter.Fs, MeasurementParameter.FreqMin, MeasurementParameter.FreqMax, MeasurementParameter.AtmDensity, 340); data.intensities.Add(AcousticSI.SumIntensity(iintensity4)); data.iintensities.AddRange(iintensity4); break; } intensityLogs.Enqueue(new IntensityLog(datastorage.measureNo, datastorage.micLocalPos, data.intensities[data.intensities.Count - 1])); } return(data); }
// Use this for initialization void Start() { //データの読み込み ReadTestData(); //瞬時音響インテンシティ計算 var intensityDirection = AcousticSI.DirectMethod(signal, atmD, micD); //直接法計算 var sumIntensity = AcousticSI.SumIntensity(intensityDirection); float[] intensityLv = new float[intensityDirection.Length]; for (int i = 0; i < intensityDirection.Length; i++) { intensityLv[i] = AcousticMathNew.CalcuIntensityLevel(intensityDirection[i]); } Color color = ColorBar.DefineColor(2, AcousticMathNew.CalcuIntensityLevel(sumIntensity), 65, 105); GameObject instant = CreateInstantObj(sumIntensity, color, intensityDirection, intensityLv); }
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; }
private IEnumerator RecordSignal(SendPosition sendPosition) { //インテンシティオブジェクト(Server側) GameObject micPoint = new GameObject("measurementPoint" + Num); micPoint.transform.parent = copyStandard.transform; micPoint.transform.localPosition = sendPosition.sendPos; micPoint.transform.localRotation = sendPosition.sendRot; //音声再生 asiocsharpdll.StartSound(); //録音のlengthbit分待つ //yield return new WaitForSeconds(4096f / 44100f); //録音開始 var soundSignals = asiocsharpdll.GetAsioSoundSignals(MeasurementParameter.SampleNum, MeasurementParameter.CalibValue); List<Vector3> intensityList = new List<Vector3>(); //時間変化する音響インテンシティを指定したアルゴリズムを元に計算 switch (algorithmList.value) { case 0://直接法 intensityList.AddRange(AcousticSI.DirectMethod(soundSignals, MeasurementParameter.AtmDensity, MeasurementParameter.MInterval)); break; case 1://STFTを使った時間周波数領域での計算処理 intensityList.AddRange(MathFFTW.STFTmethod(soundSignals, MeasurementParameter.n_overlap, MeasurementParameter.i_block, MeasurementParameter.Fs, MeasurementParameter.FreqMin, MeasurementParameter.FreqMax, MeasurementParameter.AtmDensity, MeasurementParameter.MInterval)); break; case 2://アンビソニックマイクを使った時間領域のpsudoIntensityの推定 intensityList.AddRange(MathAmbisonics.TdomMethod(soundSignals, MeasurementParameter.AtmDensity, 340)); break; case 3://アンビソニックマイクを使った時間周波数領域のpsudoIntensityの推定 intensityList.AddRange(MathAmbisonics.TFdomMethod(soundSignals, MeasurementParameter.n_overlap, MeasurementParameter.i_block, MeasurementParameter.Fs, MeasurementParameter.FreqMin, MeasurementParameter.FreqMax, MeasurementParameter.AtmDensity, 340)); break; } var intensityDirection = intensityList.ToArray(); //直接法計算 var sumIntensity = AcousticSI.SumIntensity(intensityDirection); var sumIntensityLv = MathFFTW.CalcuIntensityLevel(sumIntensity); yield return null; //PCがわ表示 float[] intensityLv = new float[intensityDirection.Length]; for (int i = 0; i < intensityDirection.Length; i++) { intensityLv[i] = MathFFTW.CalcuIntensityLevel(intensityDirection[i]); } yield return null; //オブジェクト作成 var vectorObj = Instantiate(Cone) as GameObject; vectorObj.transform.localScale = new Vector3(MeasurementParameter.objSize, MeasurementParameter.objSize, MeasurementParameter.objSize * 4); vectorObj.transform.parent = micPoint.transform; vectorObj.transform.localPosition = Vector3.zero; vectorObj.transform.localRotation = Quaternion.LookRotation(10000000000 * sumIntensity); var vecColor = ColorBar.DefineColor(MeasurementParameter.colormapID, sumIntensityLv, MeasurementParameter.MinIntensity, MeasurementParameter.MaxIntensity); vectorObj.transform.GetComponent<Renderer>().material.color = vecColor; vectorObj.name = "IntensityObj"; var parameter = vectorObj.AddComponent<ParameterStorage>(); parameter.PutIntensity(intensityDirection, intensityLv); intensities.Add(Num, vectorObj); //データそのものを保管 DataStorage data = new DataStorage(Num, sendPosition.sendPos, sendPosition.sendRot, soundSignals, sumIntensity); dataStorages.Add(Num, data); //送信データを作成 var sendData = new TransIntensityPackage(sendPosition, sumIntensity,intensityDirection, Num); tServerManager.SendIntensity(sendData); Num++; yield return null; }