IEnumerator UpdateData() { yield return(new WaitForSeconds(1f)); Writelog("Start record"); while (beMeasure) { soundSignals = AsioManager.GetAsioSoundSignals(sampleLength); Vector3 IntensityDirection = AcousticMathNew.CrossSpectrumMethod(soundSignals, sampleRate, length_bit, freq_range_min, freq_range_max, atmDensity, interval); float intensityLevel_dB = AcousticMathNew.CalcuIntensityLevel(IntensityDirection); // Debug.Log(soundSignals[0][i]); // Debug.Log(soundSignals[1][i]); // Debug.Log(soundSignals[2][i]); // Debug.Log(soundSignals[3][i]); Debug.Log(intensityLevel_dB); Debug.Log(IntensityDirection.x); Debug.Log(IntensityDirection.y); Debug.Log(IntensityDirection.z); WriteConsole(IntensityDirection.x, IntensityDirection.y, IntensityDirection.z, intensityLevel_dB); client.Send("", IntensityDirection.x, IntensityDirection.y, IntensityDirection.z, intensityLevel_dB); yield return(new WaitForSeconds(measureSpan)); } }
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); }
void Awake() { //ドライバー名デバッグ string[] asioDriverIDNames = AsioManager.GetAsioDriverNames(); foreach (string asioDriverIDName in asioDriverIDNames) { Debug.Log(asioDriverIDName); } //ASIOスタート AsioManager.PrepareAsio(2, sampleRate, sampleLength); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Q)) { AsioManager.startSound(); Debug.Log("再生したよ"); } if (Input.GetKeyDown(KeyCode.W)) { AsioManager.GetAsioSoundSignals(4096); Debug.Log("再生したよ"); } }
private void Awake() { // サンプル数の2の乗数を計算 length_bit = (int)(Mathf.Log(sampleLength, 2f)); //ドライバー名デバッグ string[] asioDriverIDNames = AsioManager.GetAsioDriverNames(); foreach (string asioDriverIDName in asioDriverIDNames) { Debug.Log(asioDriverIDName); } //ASIOスタート //localは1 ドライバー選択可能に string instLog = AsioManager.PrepareAsio(2, sampleRate, sampleLength); }
void RecordIntensity() { var soundSignal = AsioManager.GetAsioSoundSignals(sampleLength); var intensityDirection = AcousticSI.DirectMethod(soundSignal, atmDensity, micInterval); float[] intensityLv = new float[intensityDirection.Length]; for (int i = 0; i < intensityDirection.Length; i++) { intensityLv[i] = AcousticMathNew.CalcuIntensityLevel(intensityDirection[i]); } var intensityObj = Instantiate(prefab);; var parameter = intensityObj.AddComponent <ParameterStorage>(); parameter.PutIntensity(intensityDirection, intensityLv); }
private void Awake() { length_bit = (int)(Mathf.Log(isampleLength, 2f)); //ドライバー名デバッグ string[] asioDriverIDNames = AsioManager.GetAsioDriverNames(); foreach (string asioDriverIDName in asioDriverIDNames) { Debug.Log(asioDriverIDName); } //tsp読込 double[] oSignal = readTsp(); Debug.Log("音源長さ:" + oSignal.Length); Debug.Log("sampleLength:" + osampleLength); //ASIOスタート AsioManager.PrepareAsio2(3, sampleRate, isampleLength, osampleLength, oSignal); }
void Update() { if (Input.GetKeyDown(recButton)) { soundSignals = AsioManager.GetAsioSoundSignals(sampleLength); Vector3 IntensityDirection = AcousticMathNew.CrossSpectrumMethod(soundSignals, sampleRate, 12, 353f, 707f, 1000.4f, 0.05f); float intensityLevel_dB = AcousticMathNew.CalcuIntensityLevel(IntensityDirection); Debug.Log(intensityLevel_dB); //} for (int micID = 0; micID < 4; micID++) { //グラフ書く // DrowLineGraph(soundSignals[micID], lines[micID]); //音圧レベルを出す recSP[micID] = GetSoundPressure(soundSignals[micID]); recSPL[micID] = GetSoundPressureLevel(recSP[micID]); // recTexts[micID].text = string.Format("SP: {0}\nSPL: {1}", recSP[micID], recSPL[micID]); Debug.Log(string.Format("SP: {0}\nSPL: {1}", recSP[micID], recSPL[micID])); } } //recSPLをメモ for (int micId = 0; micId < 4; micId++) { if (Input.GetKeyDown(noteButton[micId])) { SetRecSPSPL(micId); } } // バイナリ保存 if (Input.GetKeyDown(saveBytesButton)) { Debug.Log("Save Bytes Data"); SaveBinaryData(soundSignals, @"C:\Users\acoust\Desktop"); } }
/// <summary> /// 1サンプルごとのデータをバイナリファイルに取得していく /// </summary> public void SaveInstanceBinaryData(Vector3 sendPos, Quaternion sendRot) { //ディレクトリなかったら作成 SafeCreateDirectory(SettingManager.saveDirPath); //もう一つディレクトリを作成 var savePath = SettingManager.saveDirPath + @"\instance"; SafeCreateDirectory(savePath); //録音&マイク位置バイナリファイル保存 string Filteredname = savePath + @"\instancepoint_" + (sNum++).ToString() + ".bytes"; FileStream fs = new FileStream(Filteredname, FileMode.Create); BinaryWriter bw = new BinaryWriter(fs); var soundSignal = AsioManager.GetAsioSoundSignals(256); for (int micID = 0; micID < 4; micID++) { for (int sample = 0; sample < 4096; sample++) { bw.Write(soundSignal[micID][sample]); } } bw.Write((double)sendPos.x); bw.Write((double)sendPos.y); bw.Write((double)sendPos.z); bw.Write((double)sendRot.x); bw.Write((double)sendRot.y); bw.Write((double)sendRot.z); bw.Write((double)sendRot.w); bw.Close(); fs.Close(); }
private void OnApplicationQuit() { AsioManager.StopAsioMain(); }