# How to calculate average from multiple SPL mics?

Member, Employee Posts: 202
✭✭✭✭
edited March 22

Say we have a harmonic acoustic analysis. How can we then add automatically a linear array of far field microphones and evaluate the average result (SPL) from them?

• Member, Employee Posts: 202
✭✭✭✭

below is a mechanical script that does that:

```nrmic=3 # number of mics to place
totspl=0 # total spl
avspl=0 # average spl
stepx=2 # distance between mic. locations in meters
model = ExtAPI.DataModel.Project.Model
analysis=model.Analyses[0]
for i in range(1,nrmic+1):
myacfar.XCoordinate = Quantity(stepx*i, "m") # mics. placed along X every stepx - in meters change if mm
myacfar.EvaluateAllResults()
myspl=str(myacfar.Maximum) # get maximim spl
myspl=myspl.Split("[")[0] # get the number not the dB
avspl=totspl/nrmic # get average
print('Average is: ' + str(avspl))
```
• Member, Employee Posts: 202
✭✭✭✭

for multiple frequencies the below should give the average (from mics.):

```import csv
nrmic=2 # number of mics to place

stepx=5 # distance between mic. locations in meters

model = ExtAPI.DataModel.Project.Model
analysis=model.Analyses[0]
time_steps = len(analysis.GetResultsData().ListTimeFreq)
size=time_steps/2
avsplar=[0]*size# average spl array

for i in range(1,nrmic+1):
myacfar.XCoordinate = Quantity(stepx*i, "m") # mics. placed along X every stepx - in meters change if mm
myacfar.EvaluateAllResults()
myacfar.Activate()
myfile='D:\mysplmic'+str(i)+'.txt'
myacfar.ExportToTextFile(myfile)
r=0
with open(myfile, 'rb') as f: