public void Play(float start, float end) { AudioClip playClip = audioClip.GetAudioClip(start, end); playClip = AudioClipUtils.SetFadeOutCurve(playClip); audioSource.PlayOneShot(playClip); }
public void SendRecording() { Text messageSendText = tracker.messageSendText; byte[] blendshapesByteBuffer = blendshapeRecorder.BlendshapesByteBuffer; if (!isSendingRecording && blendshapesByteBuffer != null && blendshapesByteBuffer.Length > 0) { if (messageSendText != null) { messageSendText.gameObject.SetActive(true); messageSendText.text = "Sending..."; } Debug.Log("SendRecording blendshapesByteBuffer.length=" + blendshapesByteBuffer.Length); isSendingRecording = true; BlendshapesRecordingMessage message = new BlendshapesRecordingMessage(); message.BlendshapesRecording = new PictoryGramAPIFile(blendshapesByteBuffer); if (audioRecorder.RecordedClip != null && audioRecorder.RecordedClip.length > 0) { message.Recording = new PictoryGramAPIFile() { Data = AudioClipUtils.ToBytes(audioRecorder.RecordedClip) }; message.RecordingIsCompressed = 0; Debug.Log("SendRecording audioRecorder.RecordedClip.length=" + audioRecorder.RecordedClip.length); } string userId = "b9af29e28b5c1203d447adce0c4bbaef"; string auth = "b9af29e28b5c1203d447adce0c4bbaef6e748db181cb90b367721ca75da34806f1de7ae646754c9f80f09fcf69104bed0857d397defecb00914157c0a4edfa41"; this.StartCoroutine(PictoryGramAPIFileUpload.SendFileRoutine(this, message, userId, auth, null, null, OnSendRecordingError, OnSendRecordingSuccess)); } }
public void Slice() { AudioClipUtils audioClip = waveViz.GetAudioClip(); AudioClip clip = audioClip.GetAudioClip(); // データ取得を書く sliceTimes = GetSliceTimes(audioClip); //List<float> sliceTimes = new List<float> { 0, 3, 5 }; List <float> slicePoints = SlicerLibrary.ConvertTimeToPoint(sliceTimes, waveViz); for (int i = 0; i < slicePoints.Count - 1; i++) { if (slicePoints[i + 1] > waveViz.GetWidth()) { break; } GameObject slicedBlockObject = Instantiate(slicedBlockPrefab, Vector2.zero, Quaternion.identity, waveViz.contentRect.transform); SlicedBlock slicedBlock = slicedBlockObject.GetComponent <SlicedBlock>(); slicedBlock.slicer = this; slicedBlock.SetPosition(slicePoints[i], slicePoints[i + 1]); slicedBlock.OnPlayClick.AddListener(waveViz.Play); slicedBlocks.Add(slicedBlock); } }
static public float ConvertPointToTime(float point, UIWaveVisualizer waveViz) { AudioClipUtils audioClip = waveViz.GetAudioClip(); AudioClip clip = audioClip.GetAudioClip(); return(ConvertPointToTime(point, (int)waveViz.GetWidth(), clip.frequency, clip.samples)); }
static public List <float> ConvertTimeToPoint(List <float> times, UIWaveVisualizer waveViz) { AudioClipUtils audioClip = waveViz.GetAudioClip(); AudioClip clip = audioClip.GetAudioClip(); return(ConvertTimeToPoint(times, (int)waveViz.GetWidth(), clip.frequency, clip.samples)); }
public void LoadRecordedClip(string filepath) { if (File.Exists(filepath)) { byte[] audioBytes = File.ReadAllBytes(filepath); recordedClip = AudioClipUtils.ToAudio(audioBytes); } }
public AudioManager(GameObject gameObject, int audioNum = 1) { for (int i = 0; i < audioNum; i++) { AudioSource audioSource = gameObject.AddComponent <AudioSource>(); audioSources.Add(audioSource); } clipController = new AudioClipUtils(); }
async void TestAvaraginDataWithAudioData() { const string DOWN_EFFECT_PATH = "D:/BeatSaberMod/EffectSamples/Down_Effect.wav"; AudioClipUtils audioClip = new AudioClipUtils(); await audioClip.LoadByWebRequest(DOWN_EFFECT_PATH, AudioType.WAV); float[] data = audioClip.GetData(); data = AveragingData(data, 2000); for (int i = 0; i < data.Length; i++) { Debug.Log(data[i]); } }
List <float> GetSliceTimes(AudioClipUtils audioClip) { List <float> sliceTimes = new List <float>(); AudioClip clip = audioClip.GetAudioClip(); float[] data = audioClip.GetData_Mono(); double[] onset = new double[100]; OnsetDetect(data, data.Length, clip.frequency, onset, onset.Length); sliceTimes.Add((float)onset[0]); for (int i = 1; i < onset.Length; i++) { if (onset[i] < onset[i - 1]) { break; } sliceTimes.Add((float)onset[i]); } return(sliceTimes); }
public virtual void SetAudioClip(AudioClipUtils controller) { audioSource.clip = controller.GetAudioClip(); }
public void Render(AudioClipUtils clip) { data = clip.GetData(); Render(data); }