array of pointers

1
2
3
4
5
// create a two channel audio buffer
  int numSamples = 2000;
  float* audioData[2];
  audioData[0] = new float[numSamples];
  audioData[1] = new float[numSamples];


This is the way I'm supposed to be making a two channel buffer.

The problem is that I'm not sure it is working the way I want. When I check the size of audioData[0] for example, it is only 4, but it should be 2000. Below is my code. I already have the audio samples in left and right channel buffers, but the third party library I'm trying to use for signal processing takes an argument which is as above. Any ideas?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
int samplenum=0;
	samplenum=songinfo.frames;

	SystemPause();
	
	double* DSP[2];
	
	DSP[0]=new double[samplenum];
	DSP[1]=new double[samplenum];

	cout << samplenum << endl;
	cout << endl << sizeof(DSP[0]) << endl <<  sizeof(DSP) << endl;

    SystemPause();

	for (n=0 ; n < songinfo.frames; ++n) {

		    DSP[0][n]=sli[n];
			DSP[1][n]=sri[n];
		}

	SystemPause();

	Dsp::SimpleFilter <Dsp::Butterworth::LowPass <10> > f;
        f.setup (10,    // order
             44100,// sample rate
             4000); // center frequency
    
	    f.process (songinfo.frames*songinfo.channels, DSP);

		SystemPause();
Last edited on
The sizeof() operator doesn't tell you what you think it does. It returns the size of the pointer, not the array that it points to.
Just make sure you call delete on these stack allocated arrays before changing audioData data (pointers that is)
Just make sure you call delete on these stack allocated arrays before changing audioData data (pointers that is)


Heap allocated arrays, surely?
Topic archived. No new replies allowed.