I'm reading a stereo .wav file into a buffer (allocated memory). My question is in regards to:
1. Checking if we've allocated the memory.
2. If so, let's delete it when we're done with it.
Simple enough, but I think I'm screwing the syntax up.
So I've declared a pointer to a pointer to an int:
Then I tell the computer how much memory I'm going to need. I've inserted two integers where typically it would acquire this information from the .wav file format. The "2" represents the number of channels and the "100" represents the number of samples in the .wav file.
for (int = 0; i < 2; i++) buffers[i] = new int ;
Finally lets run a loop that reads the samples data from the .wav into our memory:
for (int j = 0; j < 100; j++)
for (int i = 0; i < 2; i++)
mmioRead(handle, (HPSTR)&buffers[i][j], sizeof(int));
All this works great, but I need to check if the buffer has been filled / created. Would the check be written like this:
if (!(buffer = new int)) // If it hasn't been filled...
//Do something here
Then to free up the memory again, something like this:
This should eliminate all the samples for both channels stored in memory...?