Hi, I’m an aged engineer.
The electret microphone is an active device, inside there is the microphonic capsule and a FET (field effect transistor).
The correct use consists to connect a load resistor in the range 2 to 10 kOhm to a positive supply V+. The voltage of the supply contribute to settle the working point, a point in the V, I diagram.
The gain is moderately proportional to the V+ supply voltage, and is directly proportional to the load resistor.
The breakdown voltage of the FET is in the range of 10…30 V or more.
A little sophistication is obtained substituting the resistor with a “constant current” diode of about 2 to 5 mA.
See, for example this page:
https://www.mouser.it/Semiconductors/Discrete-Semiconductors/Diodes-Rectifiers/Current-Regulator-Diodes/_/N-ax1ml
This diode is a device that maintains across the circuit the nominal value of current, not depending (with a good approximation) by the supply voltage, if the value is greater than a threshold level.
The advantage of this solution is the greater gain obtained.
Regarding a precedent question about the capability to do a real-time acquisition, I suggest to use (with raspbian 9) the alsa library, that is named alsaaudio in Python.
The python code, e.g. get_audio.py, can be compiled to binary using the python package nuitka:
nuitka --python-version=3.5 --recurse-none get_audio.py
obtaining the output get_audio_exe.
Then get_audio_exe can be executed also with very strong priorities:
sudo ionice -c 1 -n 0 nice --20 chrt -r 99 get_audio_exe
The command uses the highest real-time priority: chrt -r 99
, the highest I/O priority: ionice -c 1 -n 0
, and the most performing “niceness” for the application: nice --20
.
The following procedure illustrate how to obtain the capability to run real-time audio processes:
-
Before modification:
to see the pi user priority enter ulimit -l -r
ulimit -l -r
max locked memory (kbytes, -l) 64
real-time priority (-r) 0
for the root user
su root
ulimit -l -r
max locked memory (kbytes, -l) 64
real-time priority (-r) 0
the root user is not in the audio group, add it to that group:
adduser root audio
-
modify /etc/security/limits.conf
to allow negative “nice” values:
# ADDED --------------------------------------\
pi - nice -20
root - rtprio 95
root - memlock unlimited
# ADDED --------------------------------------/
- modify:
/etc/security/limits.d/audio.conf
remove comment from last line: @audio - nice -19
as follows:
# Provided by the jackd package.
#
# Changes to this file will be preserved.
#
# If you want to enable/disable realtime permissions, run
#
# dpkg-reconfigure -p high jackd
@audio - rtprio 95
@audio - memlock unlimited
@audio - nice -19
-
reboot
-
Check priorities:
user pi:
pi@raspberrypi:~ $ ulimit -l -r
max locked memory (kbytes, -l) unlimited
real-time priority (-r) 95
user root:
su root
root@raspberrypi:/home/pi# ulimit -l -r
max locked memory (kbytes, -l) unlimited
real-time priority (-r) 95
-
Pay attention the command: ionice -c 1 -n 0
as well for: chrt -r 99
are accepted only when operating as root.
nuitka --python-version=3.5 --recurse-none get_audio.py
The resulting complete command is:
sudo ionice -c 1 -n 0 nice --20 chrt -r 99 get_audio_exe
I arrived to the illustrated procedure, because the Raspberry Pi 3B with raspbian 9 gived very frequent buffer overrun, running the get_audio.py
acquisition code, also using a console without the boot into the graphic environment.
Now the code run flawlessy in graphic mode and is insensible to the load of other running code.
(I hope the Devil don’t dropped some mistake reporting the commands to allow real-time. For the lexical consistency I checked and corrected my text translating it with Google to my native language, the italian).
Bye.
Lorenzo