Esempio n. 1
0
    public void Play(float start, float end)
    {
        AudioClip playClip = audioClip.GetAudioClip(start, end);

        playClip = AudioClipUtils.SetFadeOutCurve(playClip);
        audioSource.PlayOneShot(playClip);
    }
Esempio n. 2
0
    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);
        }
    }
Esempio n. 3
0
    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));
    }
Esempio n. 4
0
    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));
    }
Esempio n. 5
0
    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);
    }
Esempio n. 6
0
 public AudioClip GetAudioClip()
 {
     return(clipController.GetAudioClip());
 }
Esempio n. 7
0
 public virtual void SetAudioClip(AudioClipUtils controller)
 {
     audioSource.clip = controller.GetAudioClip();
 }