Sony's Developer World forum

    • Home
    • Forum guidelines

    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

    Spresense
    2
    6
    2364
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      Larry last edited by

      Hi everyone, I hope to add the SNR calculation based on the audio_recorder example. I meet the following two problems right now.

      1. 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:
      MakeErros.PNG
      I have no idea why it has such errors.

      1. In order to save 250ms data for updating, right now, I defined 3 large arrays
        int16_t leftBufferAll[20250];
        int16_t rightBufferAll[202
        50];
        int16_t throatBufferAll[202*50];

      When running, the following error occurs.
      cb849a67-74c7-496c-8adf-0be9a77f8362-image.png
      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

      C 1 Reply Last reply Reply Quote
      • L
        Larry last edited by

        9c526921-edb2-47d4-b282-5b85a349084a-image.png
        Would someone kindly tell me what's the cause of this issue when running? Is it a run-time issue?

        1 Reply Last reply Reply Quote
        • C
          CamilaSouza DeveloperWorld @Larry last edited by CamilaSouza

          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.

          L 1 Reply Last reply Reply Quote
          • L
            Larry @CamilaSouza last edited by

            @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

            C 2 Replies Last reply Reply Quote
            • C
              CamilaSouza DeveloperWorld @Larry last edited by

              @Larry
              Thanks for sharing detailed information.
              I will take a look at your documents.

              1 Reply Last reply Reply Quote
              • C
                CamilaSouza DeveloperWorld @Larry last edited by

                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_HEADERS

                This 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 -j

                You should be able to use math.h normally after that.
                Please let me know if it worked for you too.

                1 Reply Last reply Reply Quote
                • First post
                  Last post
                Developer World
                Copyright © 2021 Sony Group Corporation. All rights reserved.
                • Contact us
                • Legal