Close

Microphone Test

A project log for Electronic 6-hole Ocarina

Play without annoying the neighbors

dehipudeʃhipu 01/15/2022 at 20:500 Comments

The board has arrived, as well as the microphones. I moved all the components over, and added the microphone and speaker:

A simple example confirms that the microphone works, and that it's easy to see when it is being blown into:

import board
import array
import audiobusio

mic = audiobusio.PDMIn(board.TX, board.A2, sample_rate=16000, bit_depth=16)
samples = array.array('H', [0] * 160)

while True:
    mic.record(samples, len(samples))
    mean = sum(samples) / len(samples)
    energy = sum(abs(sample - mean) for sample in samples)
    print(energy)

Now to program some output... 

Discussions