Sample Index Calculations

In order to calculate the maximum number of samples need for each microphone, we must look at the case in which sound enters the array broadside, or at 0/180 degrees (Figure 1). Since the speed of sound is 340.29 m/s and the distance between each microphone is 3 cm, we can calculate the time it takes sound waves to propagate from one microphone to the next by dividing. Therefore, our delay time for each successive microphone is 3 cm divided by 340.29 m/s, which equals 88.16 microseconds.

Figure 1.

Now, we can use our sample frequency of 48 kHz to calculate how many samples we need in order to pull a valid sample for a sound wave propagating from microphone 8 to microphone 1. Our first sample for each microphone, would be when the sound wave first hits microphone 8. Since the sound has not yet reached all other microphones, the samples for those microphones would be invalid. After the associated delay of 88.16 microseconds, the sound wave would reach microphone 7, and the sample associated with this delay would now be the valid sample for microphone 7, however all of microphone samples at this point would be invalid. Microphone 8’s valid sample is the first one, microphone 7’s valid sample is the one occurring 88.16 microseconds after the initial sample, and all other microphones do not have a valid sample yet. This method cascades down the array as seen in Figure 2 below.

Figure 2.

Since the sample frequency determines how often we take a sample, we can multiply this by the total delay at microphone 1 to give us what sample is valid at microphone 1, or the minimum number of samples needed to achieve valid samples for all microphones. The number of samples needed is 30.

Now, although the number of samples needed is calculated to be 30, we must account for the inability to use exact delay values when programming. A rounding must occur, and therefore we need more samples than calculated. The new value is 32 samples. Each sample will be stored within the RAM of the microcontroller, as 8 bit integers, in 32 consecutive addresses, as seen in Figure 3. These samples will be later pulled according to pre-calculated index values that can be seen in Table 4. These values are easy to determine. Simply take one delay value (88.16 microseconds) and multiply by the sample frequency (48 kHz). This will give you the sample increment for each successive microphone. For example, 88.16 us * 48 kHz = 4.23168, which means in order to “steer” the array towards 0 degrees (broadside as seen in Figure 1), the sample pulled for the first microphone (first one to “hear” the sound, microphone 8 in this case), will be the first sample, then we pull the 1 + 4.23168 = 5.232th sample from microphone 7’s storage, then the 5.232 + 4.23168 = 9.464th sample from microphone 6’s storage, and so on. However, we need to round as stated before. Therefore, after complete calculations, the indices would be [1, 5, 10, 14, 18, 22, 26, 31]. Table 4 shows complete index values for all directions.

Figure 3.

Table 1. Sample Indices

 / 0 / 15 / 30 / 45 / 60 / 75 / 90 / 105 / 120 / 135 / 150 / 165 / 180
M1 / 31 / 30 / 27 / 22 / 16 / 9 / 1 / 1 / 1 / 1 / 1 / 1 / 1
M2 / 26 / 26 / 23 / 19 / 14 / 8 / 1 / 2 / 3 / 4 / 5 / 5 / 5
M3 / 22 / 21 / 19 / 16 / 12 / 6 / 1 / 3 / 5 / 7 / 8 / 9 / 10
M4 / 18 / 17 / 16 / 13 / 10 / 5 / 1 / 4 / 7 / 10 / 12 / 13 / 14
M5 / 14 / 13 / 12 / 10 / 7 / 4 / 1 / 5 / 10 / 13 / 16 / 17 / 18
M6 / 10 / 9 / 8 / 7 / 5 / 3 / 1 / 6 / 12 / 16 / 19 / 21 / 22
M7 / 5 / 5 / 5 / 4 / 3 / 2 / 1 / 8 / 14 / 19 / 23 / 26 / 26
M8 / 1 / 1 / 1 / 1 / 1 / 1 / 1 / 9 / 16 / 22 / 27 / 30 / 31