LIFsCode / ELOC-3.0

Firmware for ELOC 3.0 Hardware
MIT License
3 stars 3 forks source link

Option to choose between microphone channels #58

Closed EDsteve closed 8 months ago

EDsteve commented 9 months ago

@LIFsCode @OOHehir

As we know the 50pcs ELOC3.3 we ordered from JLCPCB arrived with a broken microphone. Unfortunately all of them defect. The plan is to still use these PCBs, not with the on board microphone but with an external one, which saves money and time. The onboard microphone is the LEFT channel. And the external would be the RIGHT channel.

Therefor there must be an option in the app to choose between LEFT and RIGHT channel for operation. (and if it's not a big thing also add the option for stereo recording (Only IF very easy)).

That should hopefully not take too much time :)

Also adding that in the config.json in the mic section is needed:

{ "device": { "fileHeader": "not_set", "locationCode": "unknown", "locationAccuracy": 99, "nodeName": "ELOC_NONAME" }, "config": { "secondsPerFile": 60, "cpuMaxFrequencyMHZ": 80, "cpuMinFrequencyMHZ": 10, "cpuEnableLightSleep": true, "bluetoothEnableAtStart": true, "bluetoothEnableOnTapping": true, "bluetoothEnableDuringRecord": true, "bluetoothOffTimeoutSeconds": 60, "logConfig": { "logToSdCard": true, "filename": "/sdcard/log/eloc.log", "maxFiles": 10, "maxFileSize": 5120 } }, "mic": { "MicType": "ns", "MicBitShift": 11, "MicSampleRate": 20000, "MicChannel: Left, Right, Stereo, "MicUseAPLL": true, "MicUseTimingFix": true } }

OOHehir commented 9 months ago

@EDsteve I can handle the required changes in main.cpp & the I2SMEMSSampler class to handle this if @LIFsCode you don't mind handling the changes required to allow me to retrieve the setting from the configuration?

LIFsCode commented 9 months ago

@OOHehir thanks, that makes sense. The wavfile writer class has already quite some dependencies to the main system, so I guess it's just consequent to let it directly retrieve it's configuration from Epic config.

I plan to lock config changes while recording or detection is active, so this will guarantee that accessing the config is thread safe. I just delayed this task until Joseph finished the App development to give him more access for testing.

OOHehir commented 9 months ago

@EDsteve @LIFsCode I've just pushed this commit which allows the I2S mic channel to be selected in project_config.h at compilation time. This issue seems to be a temporary issue so @EDsteve do you think meets your requirements?

@EDsteve BTW from what I remember trying to record in stereo will naturally result in double the sample data & probably lead to increase in power & processing requirements.. This is one area already flagged for upgrading from the legacy API.

EDsteve commented 9 months ago

@OOHehir The workaround changing the channel during compilation is fine for now. I actually did that already till now changing .channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT in the config.cpp :)

Still. Later when the ELOCs get firmware updates. It will become problematic because all the firmwares will have LEFT by default. So it makes sense to have it settable from the app. On the other hand. Microphones don't last forever in the jungle. So sooner or later some will get broken due to water damage or similar. The option to connect an external microphone and therefore change the channel in the app is needed.

Stereo recording is not needed for our elephant purposes. I just know that some wildlife acoustic projects use stereo recordings. So it is very low priority.

LIFsCode commented 9 months ago

@OOHehir @EDsteve I can implement the config option today

LIFsCode commented 8 months ago

should be done with c328154

EDsteve commented 8 months ago

Tested and works fine. I will close this now.