public static void conv(string tspFilePath, string soundFilePath, string outFilePath) { double[] tspSignal, soundSignal, impulseSignal; short[] shortSignal; //TSP読込 WavRead.ReadWave(tspFilePath); tspSignal = EditArray.int2double(WavRead.valuesR); Array.Reverse(tspSignal); //音源読込 WavRead.ReadWave(soundFilePath); soundSignal = EditArray.int2double(WavRead.valuesR); //畳込 double length_bit_do = Math.Log(WavRead.valuesR.Length, 2); int length_bit = (int)length_bit_do; impulseSignal = new double[WavRead.valuesR.Length]; impulseSignal = AcousticMath.Convolution(soundSignal, tspSignal, length_bit); //short変換 shortSignal = EditArray.double2short(impulseSignal); //インパルス応答書出 WavWrite.createWave(shortSignal, outFilePath, channel, sampleRate, bitPerSample); }
public void createWav() { //short[] newWav = noise(wavLength); short[] newWav = yamaha(); string outFilePath = Application.dataPath + inputField.text; WavWrite.createWave(newWav, outFilePath, channel, sampleRate, bitPerSample); }
/// <summary> /// Button押下 /// </summary> public void Rec() { for (int i = 0; i < toneNum; i++) { for (int j = 0; j < chordNum; j++) { if (inputFields[i][j].text == "c") { compose(i * sampleRate / 4, (i + 1) * sampleRate / 4, C); } else if (inputFields[i][j].text == "d") { compose(i * sampleRate / 4, (i + 1) * sampleRate / 4, D); } else if (inputFields[i][j].text == "e") { compose(i * sampleRate / 4, (i + 1) * sampleRate / 4, E); } else if (inputFields[i][j].text == "f") { compose(i * sampleRate / 4, (i + 1) * sampleRate / 4, F); } else if (inputFields[i][j].text == "g") { compose(i * sampleRate / 4, (i + 1) * sampleRate / 4, G); } else if (inputFields[i][j].text == "a") { compose(i * sampleRate / 4, (i + 1) * sampleRate / 4, A); } else if (inputFields[i][j].text == "b") { compose(i * sampleRate / 4, (i + 1) * sampleRate / 4, B); } else { compose(i * sampleRate / 4, (i + 1) * sampleRate / 4, 0); } } } string outFilePath = Application.dataPath + inputField.text; WavWrite.createWave(composition, outFilePath, channel, sampleRate, bitPerSample); }
public void OnClick() { if (pressed == false) { rec = true; Debug.Log("録音中"); pressed = true; } else { rec = false; Debug.Log("完了"); //グラフ表示 float step = 0.005f; Vector3 scale = Vector3.one * step; position.z = 0f; points = new Transform[inputList.Count - 1]; lineGroup = new GameObject("LineGroup"); my2DPoint = new Vector2[points.Length]; for (int i = 0; i < points.Length; i++) { Transform point = Instantiate(pointPrefab); position.x = (i + 0.5f) * step - step * 1000 / 2; position.y = (float)inputList[i] / 100; point.localPosition = position; point.localScale = scale; point.SetParent(transform, false); point.name = "Cube" + i; points[i] = point; my2DPoint[i] = position; } line = new GameObject[my2DPoint.Length - 1]; for (int i = 0; i < my2DPoint.Length - 1; i++) { line[i] = Instantiate(linePrefab); DrawLine(my2DPoint, i); line[i].transform.parent = lineGroup.transform; } //wav書出 string outFilePath = Application.dataPath + "/WavFiles/mic.wav"; short[] inputArray = inputList.ToArray(); //bpsとbaudは違うけどarduinoは同じらし? short channel = 1; //int sampleRate = baudRate / 16; Debug.Log(time); int sampleRate = (int)(inputArray.Length / time); Debug.Log(sampleRate); short bitPerSample = 8; WavWrite.createWave(inputArray, outFilePath, channel, sampleRate, bitPerSample); inputList.Clear(); pressed = false; } }