public void Play(float start, float end) { AudioClip playClip = audioClip.GetAudioClip(start, end); playClip = AudioClipUtils.SetFadeOutCurve(playClip); audioSource.PlayOneShot(playClip); }
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)); }
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 AudioClip GetAudioClip() { return(clipController.GetAudioClip()); }
public virtual void SetAudioClip(AudioClipUtils controller) { audioSource.clip = controller.GetAudioClip(); }