Upcoming maintenance
Dear Customers and Partners.
This website will be undergoing scheduled maintenance on June 14, 2023. Please be aware there may be disruption to the developer portal website and associated services during the scheduled maintenance period.
This upgrade is essential to ensure the continued performance, reliability, and security of Developer World.
We apologize for any inconvenience.
CMath and memory management error when modifying audio recorder example
-
Hi everyone, I hope to add the SNR calculation based on the audio_recorder example. I meet the following two problems right now.
- In order to complete this, I have to use the log10 function defined in <math.h>. In order to call it, right now I just add the inclusion at the top of audio_recorder_main.cxx
#include <math.h>
This is the only change I made to use the log10 function. While when 'make', the following errors occur:
I have no idea why it has such errors.- In order to save 250ms data for updating, right now, I defined 3 large arrays
int16_t leftBufferAll[20250];
int16_t rightBufferAll[20250];
int16_t throatBufferAll[202*50];
When running, the following error occurs.
I think this error is related to the large array defined above. Is it possible to change the system memory management part to make it works?Thank you in advance for any help.
Best,
Larry
-
Would someone kindly tell me what's the cause of this issue when running? Is it a run-time issue? -
Hi, @Larry
Regarding your first question
please include math.h as follows:#include <nuttx/lib/math.h>
Please share the code your trying to run so I can investigate the other issues.
-
@CamilaSouza Hi Camila, Thank you for your kind reply. However, this still not working as it shows log10 is not declared in the scope.
For the code to check other issues, please check the following link:
https://drive.google.com/drive/folders/15myQ_mmQgtlaDka_SNIIRxinf3cz5s-P?usp=sharing
I wrote a detailed debug report for the design goal and issues I have. Please kindly read the word document before looking into the code. I got stuck by those issues for two months and I sincerely hope to get your help in solving these issues. Thank you so much in advance for any help.Best,
Larry
-
@Larry
Thanks for sharing detailed information.
I will take a look at your documents. -
Hey, @Larry
So here is a fix to be able to import the math.h library in the audio recorder example:
Please edit the Makefile inside the audio_recorder example folder and add the following line to the "# Audio Example flags" section:
CXXFLAGS += -D_GLIBCXX_INCLUDE_NEXT_C_HEADERSThis is what that section will look like after this modification:
# Audio Example flags CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(AUDIODIR)"} ifeq ($(CONFIG_EXAMPLES_AUDIO_RECORDER_USEPREPROC),y) CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "worker$(DELIM)userproc$(DELIM)include"} endif CXXFLAGS += -D_POSIX CXXFLAGS += -DUSE_MEMMGR_FENCE CXXFLAGS += -DATTENTION_USE_FILENAME_LINE CXXFLAGS += -D_GLIBCXX_INCLUDE_NEXT_C_HEADERS
After that, in the terminal, do
$ make distclean
$ tools/config.py examples/audio_recorder
$ make -jYou should be able to use math.h normally after that.
Please let me know if it worked for you too.