SaraKIT with thre microphones and ZL38063 enables to analyse sound direction location. ZL38063 beamformer reports the angle of the most significant sound source for linear/triangular microphone configuration. The axis between Mics 1 and 2 defines the main axis, with 0 degrees to the right and +180 degrees to the left, with +90 degrees defined as being at the top of the array (opposite side of main axis from Mic 3)

 

We prepared sample shows how to get sound location information.

Prerequisites

Ensure you have the following installed on your system:

Installation

  1. Clone the repository:

    > git clone https://github.com/SaraEye/SaraKIT-Python-Examples.git

  2. Navigate to the cloned directory:

    > cd SaraKIT-Python-Examples/SaraKIT-Audio

Usage

> python SoundLocator.py

import alsaaudio
import time
import subprocess

def ReadZL38063(register, firstTime=False):
    if firstTime:
        register &= 0xFFFF
        register = (register << 16) | 0x40000000    
        subprocess.run(['amixer', '-c0', 'cset', 'name=Registers', str(register)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
        
    result = subprocess.run(['amixer', '-c0', 'cget', 'name=Registers'], capture_output=True, text=True)
    output = result.stdout
    last_line = output.strip().split('\n')[-1]
    value = last_line.split('=')[-1] if last_line else None
    return value

def WriteZL38063(register,value):
    register &= 0xFFFF
    value &= 0xFFFF
    register = (register << 16) | value | 0x20000000
    subprocess.run(['amixer', '-c0', 'cset', 'name=Registers', str(register)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)     
    return 0
    

#define ZL380xx_SND_LOC_DIR_REG 0x00A0
ReadZL38063(0x00A0,True)

while True:
    print("Angle: %s°" % ReadZL38063(0xA0))
    time.sleep(0.1)
 
You can find C++ and Python code for Raspberry Pi4 in the
SaraKIT Github repository:
https://github.com/SaraEye