ofPath and ofxAudioUnit

Hi,
I am trying to play around with the ofxAudioUnit and I am trying to use pfPath instead of ofPolyline but with no success. (specifically the example-4-parameters.)
I also created a Vector of circles as I am trying to have a different shape of the waveform, but no result…
maybe I don’t get the difference between these two classes?
Any suggestion?

Cheers!

This kind of depends on what direction you’d like to go, but here’s some options:

The ofxAudioUnitTap will let you extract the raw samples, which will be a vector<float> where each sample is a number between -1 and 1. These are the samples the ofxAudioUnitTap is using to build the polyline, so you can use the values yourself to do something different. The function for this is tap.getSamples(), used like this:

vector<float> mySamples;
tap.getSamples(mySamples);

After that, mySamples will contain the last 2048 samples to flow through the tap. You can change how many samples the tap stores by calling tap.setBufferLength() in your ofApp’s setup function. The function will just give you the left channel’s samples by default, but you can do tap.getSamples(mySamples, 1) to get the right channel.

Alternatively, you can just get the waveform as an ofPolyline and build a new ofPath by stepping through each of the ofPolyline’s vertices and calling lineTo() on the path. This will probably be a little slower, since you’ll be doing 3-4x as much work, but it may be more straightforward.

Let me know if that helps!

Hi Admsyn,
that was very well explained, infact I managed to sort that out.
I just wanted to play around to understand how I could use the tap data to manipulate the line. so your hint was really useful.
At the beginning I thought that ofPath could be a valid alternative to ofPolyline but to be honest I don’t know these classes yet. I will have to study a bit more. :blush:
Thanks for your help!