microphone

package
v0.17.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2021 License: BSD-3-Clause Imports: 2 Imported by: 16

Documentation

Overview

Package microphone implements a driver for a PDM microphone. For example, the Adafruit PDM MEMS breakout board (https://www.adafruit.com/product/3492)

Datasheet: https://cdn-learn.adafruit.com/assets/assets/000/049/977/original/MP34DT01-M.pdf

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {

	// SampleCountForSPL is number of samples aka size of data buffer to be used
	// for sound pressure level measurement.
	// Once Configure() is called, changing this value has no effect.
	SampleCountForSPL int

	// Gain setting used to calculate sound pressure level
	Gain float64

	// ReferenceLevel setting used to calculate sound pressure level.
	ReferenceLevel float64
	// contains filtered or unexported fields
}

Device wraps an I2S connection to a PDM microphone device.

func New

func New(bus machine.I2S) Device

New creates a new microphone connection. The I2S bus must already be configured.

This function only creates the Device object, it does not touch the device.

func (*Device) Configure

func (d *Device) Configure()

Configure the microphone.

func (*Device) GetSoundPressure

func (d *Device) GetSoundPressure() (int32, int32)

GetSoundPressure returns the sound pressure in milli-decibels.

func (*Device) Read

func (d *Device) Read(r []int32) (int, error)

Read the raw microphone data.

func (*Device) ReadWithFilter

func (d *Device) ReadWithFilter(r []int32) (int, error)

ReadWithFilter reads the microphone and filters the buffer using the sinc filter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL