Hi,
I am looking at drawing a spectrogram, currently I feed in a chunk of samples to my C library which uses FFTW to return a magnitude array for each chunk. I want to draw the output of each magnitude array over time, so in my library I have a linked list which stores the array for each chunk of audio. I then have a callback method from my C++ application. As time increases, there will be more and more arrays to draw to the screen for my spectrogram, and therefore I need to create new VertexArrays on each drawback. I am using the std::vector class to try and add new vertex arrays to a list, however I am having problems with this. Below is my current code:
void ClientCallback(uint8_t *array, int current_array, int total_arrays)
{
if (total_arrays > vertex_array.size())
{
sf::VertexArray vertex_point(sf::LinesStrip, SAMPLE_RATE/2);
vertex_array.push_back(vertex_point);
}
for (unsigned counter = 0; counter < 1024; counter++)
{
vertex_array[current_array][counter].position = sf::Vector2f((float)(array[counter]), counter);
}
}
This method is called by my library to draw the arrays for every chunk of the audio track so far. When total_arrays increases, ie we have moved onto drawing a new chunk then I try to create a new vertex array and add this to my std::vector<sf::VertexArray> vertex_array; object. My error I believe is in how I try to access the vertex arrays from my vector object. I want to be able to do: vertexPoints[counter].position = sf::Vector2f((float)(array[counter]), counter); and so I tried the code vertex_array[current_array][counter].position to try and modify this element but this isn't working.
Any help would be greatly appreciated in knowing how to implement an arraylist of sorts that I can continue to add vertexarrays to before modifying the values of the vertexarrays and then drawing to screen.
Many thanks,
Mark