Parameters of getoutputdata?& detailly analyze and draw waveforms?

Hello, I’ve been trying to draw waves for a while and had some problem with getoutputdata. It appeals that when the array size can’t go above 2^14, is it a limitation of the function or am I doing anything wrong?

if analyzing the audio data live can’t have that much accuracy, is there any work around or is possible to go over the audio track and save the data in a table some or something. And more importantly, do it with more details than evaluating live?

Lastly, what is a good way to draw wave that has great details and changes rapidly? Similar to an oscilloscope? I found a good video example done in unity.

And here is my codeplus a video demoing mine(it’s a very simple approach, but difinatly not a very good one)

using UnityEngine;
using System.Collections;

public class osciParticle : MonoBehaviour {

    public Color particleColor;
    public Color backGround;
    public int resolution;
    public int particleCount;

    private float[] samplesX;
    private float[] samplesY;

    private ParticleSystem.Particle[] points;

    void Start () {
        samplesX = new float[particleCount];
        samplesY = new float[particleCount];
        Draw ();
    }
   
    // Update is called once per frame

    private void Draw(){
        AudioSource audio = GetComponent<AudioSource> ();

        points = new ParticleSystem.Particle[resolution];

        audio.GetOutputData (samplesX, 0);
        audio.GetOutputData (samplesY, 1);
        float increment = 1f/ ( resolution - 1);

        for (int i = 0; i < resolution; i++) {
            float x = i * increment;
            points [i].position = new Vector3((int)(resolution * (samplesX [i] + 1f) / 2) * increment , (int)(resolution * (samplesY [i] + 1f) / 2) * increment, 0);
            points [i].startColor =new Color (x, 0, 0);
            points [i].startSize = .01f;

        }

   
    }

    void Update () {
       
        ParticleSystem particlesys = GetComponent<ParticleSystem> ();


        Draw ();

        particlesys.SetParticles (points, particleCount);

    }
}

It sounds like your approach is to use particles as points in the graph. To get a solid line, your points must be packed more tightly and thus you must have a huge number of points.

Another approach might be to plot a huge number of points, and then make a fewer number of particles ride along the points leaving a trail. I’m not 100% sure it would work, but it is similar to how I solved a sound wave visualization problem for mobile.

I had a particle system moving horizontally, and used the audio amplitude to move the system up and down vertically. The particle system emitted based on distance, so it’s trail was the audio wave form.

Exactly, I dont have enough particles, and that is what one of my question is, when I increase the variable “particleCount” to above 16384, it returns an error. So is there anyway to get around that or, a more vector or vector-like method should be used?

I guess what I was imagining is you create a List of 20,000+ positions, and you have about 1000 particles cycle through those positions. If the particles are leaving a trail, that creates the line between those positions. You may even be able to decrease the position count and still have a line.

In this scenario, the graph would sort of ‘pulse’ where the particle is. I’m using the 5.6 beta, I can’t remember if particle trails are in 5.5 or not…