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.

     

     

    Audio Recorder Example not working under 8000 and 16000 sample rate

    Spresense
    2
    13
    3307
    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

      I connect 4 analog mics to the board and the audio recorder example is running successfully when the sampling rate is 48000. However, if I lower the sampling rate to 8000 or 16000, there is an error when running. It shows (print out) set_recording_mode() failure. Please kindly suggest how can I modify the code to make it work under a low sampling rate. Thanks in advance for any help!ErrorOccurs.png

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

        @LarryThe above issues occur when I tried the 8k sample rate. When I use the 16K sample rate, it has the following errors (While this sample rate should work based on the instruction of the sample code, I am not sure whether this is a bug or not):
        16000SampleRateError.jpg

        K 1 Reply Last reply Reply Quote
        • K
          KamilTomaszewski DeveloperWorld @Larry last edited by

          Hi @Larry,

          I have a question. Have you completed this step:

          Screenshot from 2022-04-01 17-43-50.png

          Link to documentation: https://developer.sony.com/develop/spresense/docs/sdk_tutorials_en.html#_build_flash_3

          Best Regards,
          Kamil Tomaszewski

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

            @KamilTomaszewski Hi Kamil, Thank you for your kind reply. I do not think my issue is related to the SD card configuration. I can run the sample code successfully under the 48k and 192k (while somehow the recording time becomes 3.3s for the 192k sample rate, which is also strange) sample rate. If I change the sample rate to 8K and 16K, it has the mentioned errors. Would you please suggest how can I modify the code to make it work under the 8k sample rate? Thank you in advance for any help!

            K 1 Reply Last reply Reply Quote
            • K
              KamilTomaszewski DeveloperWorld @Larry last edited by

              Hi @Larry,

              48kHz and 192kHz are the native sampling rates. For this reason you don't need to use DSP binary as the sampling rate converter is not needed. However, if you want to use other sampling rates such as 8kHz or 16kHz then you need to put the DSP binary on the SD card or flash memory.

              Best Regards,
              Kamil Tomaszewski

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

                @KamilTomaszewski Thanks for your reply. I checked my SD card and I put both 'MP3DEC' and 'WAVDEC' under the BIN folder of the SD card. I still think the SD card configuration is not the issue. If the sample code can support 8k sample rate, I think it should be fully listed here (in the comment part, rather than 3 sample rate listed right now)
                ed760eac-ac89-4cdd-8e31-cbd7c78a1ec0-image.png

                If possible, would you please confirm on your side by simply modifying the main file of this example to: Set sampling_rate to 8000, Set channel_number to AS_CHANNEL_4CH? Please let me know if such modification can run without any errors on your side.

                Thanks in advance for any help.

                Best,

                Larry

                K 1 Reply Last reply Reply Quote
                • K
                  KamilTomaszewski DeveloperWorld @Larry last edited by

                  Hi @Larry,

                  I've checked. Only 16kHz, 48kHz and 192kHz are supported for recording.

                  Best Regards,
                  Kamil Tomaszewski

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

                    @KamilTomaszewski Hi Kamil, is it possible to change the example code to make it works under 8k sample rate? I set it to 4 channels and it is even not working when using the 16k sample rate. Thanks in advance for any help.

                    K 1 Reply Last reply Reply Quote
                    • K
                      KamilTomaszewski DeveloperWorld @Larry last edited by

                      Hi @Larry,

                      What happens when you try to use 16kHz and 4 channels?

                      I will try to see if it is possible to change something to use 8kHz.

                      Best Regards,
                      Kamil Tomaszewski

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

                        @KamilTomaszewski Thank you so much for your kind reply.

                        1. The error when using 16k sample rate, 4 channels, and 100 default_mic_gain is shown below
                          16000SampleRateError.jpg
                        2. The error when using 192k sample rate, 4 channels, and 100 default_mic_gain is shown below
                          192KSampleRate.png
                          3) I sincerely hope to get your feedback/suggestions on how to modify this example to make it work under 8k sample rate with 4 channels and 100 default_mic_gain.

                        Best,

                        Larry

                        K 1 Reply Last reply Reply Quote
                        • K
                          KamilTomaszewski DeveloperWorld @Larry last edited by

                          Hi @Larry,

                          1. For 16kHz, it is necessary to load the DSP binary for encoding. Do you have such a file: "/mnt/sd0/BIN/SRC" on your SD card?

                          2. You get this error because the fifo is overflowing: https://github.com/sonydevworld/spresense/blob/959182b937dccde216fcb8289de0ac9de3367880/sdk/modules/audio/objects/media_recorder/audio_recorder_sink.cpp#L84
                            You get a lot of data and you don't read it quickly enough. For example, a slow SD card may be a problem.

                          Best Regards,
                          Kamil Tomaszewski

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

                            @KamilTomaszewski Hi Kamil, I feel grateful for your kind reply.

                            1. for the 16k sample rate not working issue, right now my SD card has the following folder when using the SD card reader on PC:
                              24d7b91f-82fe-4793-ab82-d28e146978d8-image.png
                              When you mentioned "Do you have such a file: "/mnt/sd0/BIN/SRC" on your SD card?", do you mean that I should put both MP3ENC and SRC under the BIN folder?
                              I need further clarification on this.
                            2. Would you please share with me the link of the SD card (or the exact type of SD card) you use for solving the slow reading rate issue?

                            I am looking forward to your reply. Thanks in advance for any help!

                            Best,

                            Larry

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

                              @KamilTomaszewski Hi Kamil, I find out that the 16k sample rate not working is indeed my fault. The DSP binary is not correctly put in the SD card. And the example code can also be simply modified to support the 8000 sample rate (A small issue is that the recording time becomes 9.8s, not exactly 10s) Thank you for your kind reminder.

                              1. Would you please provide some hints on how can I modify this example to use it for timely calculating the SNR (Signal power to Noise power ratio)?

                              Thank you in advance for any help.

                              Best,

                              Larry

                              1 Reply Last reply Reply Quote
                              • Referenced by  C CamilaSouza 
                              • Referenced by  L Larry 
                              • First post
                                Last post
                              Developer World
                              Copyright © 2021 Sony Group Corporation. All rights reserved.
                              • Contact us
                              • Legal