A low-latency silence detection method, apparatus, and storage medium based on ALSA

CN115954018BActive Publication Date: 2026-08-11EEASY TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-08
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

这种方法在音频缓冲区appl_ptr与hw_ptr之间有一段音频数据,这段音频数据会影响到静音检测的实时性,增加静音检测结果的延迟,降低静音检测的准确性

Benefits of technology

[0035] The beneficial effects of the low-latency silence detection method, apparatus, and storage medium based on ALSA provided in this application are as follows: The method includes transferring audio data to an audio buffer; a DMA interrupt occurs, and a DMA interrupt callback function is executed; the audio data following the hw_ptr pointer is obtained, and silence detection is performed. Based on ALSA, this application places the silence detection data after the hw_ptr pointer in the audio buffer. When a DMA interrupt occurs, the audio data transferred in this DMA transfer can be obtained through the hw_ptr pointer. Using this data for silence detection can obtain real-time silence detection results, thereby reducing the latency of the silence detection results and improving the accuracy of silence detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115954018B_ABST
    Figure CN115954018B_ABST
Patent Text Reader

Abstract

This application discloses a low-latency silence detection method, apparatus, and storage medium based on ALSA. The method includes transferring audio data to an audio buffer; triggering a DMA interrupt and executing a DMA interrupt callback function; obtaining the audio data following the hw_ptr pointer and performing silence detection. Based on ALSA, this application places the silence detection data after the hw_ptr pointer in the audio buffer. When a DMA interrupt occurs, the audio data transferred in this DMA operation can be obtained through the hw_ptr pointer. Using this data for silence detection allows for real-time silence detection results, thereby reducing the latency of silence detection and improving its accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of silence detection, and in particular to a low-latency silence detection method, apparatus and storage medium based on ALSA. Background Technology

[0002] ALSA (Advanced Linux Sound Architecture) is the audio framework for Linux systems. This framework consists of two parts: the ALSA LIB and the ALSA driver. The ALSA LIB provides an interface for user-space applications, while the ALSA driver manages audio devices. The ALSA framework uses a circular buffer to manage audio data, manipulated by two pointers: appl_ptr and hw_ptr. The appl_ptr pointer is manipulated by the application, while the hw_ptr pointer is manipulated by the DMA hardware. The location where the DMA hardware moves audio data is determined by hw_ptr; the closer the data is to hw_ptr, the higher the real-time performance. During recording, hw_ptr is the pointer to write the audio buffer, and appl_ptr is the pointer to read the audio buffer; during playback, hw_ptr is the pointer to read the audio buffer, and appl_ptr is the pointer to write the audio buffer. Generally, silence detection resides in user space. During recording, silence detection data originates from the kernel audio buffer, while during playback, silence detection data comes from audio files or the network. A silence detection algorithm analyzes the audio data to obtain the silence detection result.

[0003] Traditional ALSA-based silence detection methods place the audio data to be detected after `appl_ptr`. There are multiple periods of audio data between `appl_ptr` and `hw_ptr`. The difference between `hw_ptr` and `appl_ptr` is the cause of the delay in the silence detection result; the larger the difference, the higher the delay. Generally, there are multiple periods of audio data between the two pointers `hw_ptr` and `appl_ptr`, resulting in a delay of several periods in the silence detection result. Specifically, the traditional ALSA-based silence detection method uses a circular buffer to manage audio data in the Linux kernel ALSA framework. The DMA generates an interrupt every time it moves one period of audio data. For playback, `appl_ptr` is the audio buffer write pointer, and `hw_ptr` is the audio buffer read pointer; for recording, `appl_ptr` is the audio buffer read pointer, and `hw_ptr` is the audio buffer write pointer. This method involves audio data between the audio buffer appl_ptr and hw_ptr. This audio data affects the real-time performance of silence detection, increases the latency of silence detection results, and reduces the accuracy of silence detection.

[0004] Therefore, the aforementioned technical problems in the relevant technologies urgently need to be solved. Summary of the Invention

[0005] This application aims to solve one of the technical problems in related technologies. To this end, embodiments of this application provide a low-latency silence detection method, apparatus, and storage medium based on ALSA, which can reduce the latency of silence detection results and improve the accuracy of silence detection.

[0006] According to one aspect of an embodiment of this application, a low-latency silence detection method based on ALSA is provided, the method comprising:

[0007] Move the audio data to the audio buffer;

[0008] When a DMA interrupt occurs, the DMA interrupt callback function is executed.

[0009] Obtain the audio data following the hw_ptr pointer and perform silence detection.

[0010] In one embodiment, the method further includes, before transferring the audio data to the audio buffer:

[0011] Configure and start the audio device and DMA via the ALSA interface.

[0012] In one embodiment, after retrieving the audio data following hw_ptr and performing silence detection, the method further includes:

[0013] Update the hw_ptr pointer.

[0014] In one embodiment, obtaining the audio data following the hw_ptr pointer includes:

[0015] Get the audio data after the hw_ptr pointer;

[0016] Select any period of audio data following the hw_ptr pointer.

[0017] In one embodiment, obtaining the audio data following the hw_ptr pointer and performing silence detection includes:

[0018] Get the audio data after the hw_ptr pointer;

[0019] Select several period audio data points from the audio data following the hw_ptr pointer;

[0020] Perform silence detection for each period of audio data.

[0021] In one embodiment, performing the silence detection includes:

[0022] Analyze audio data using a silence detection algorithm;

[0023] Obtain the noise level test results.

[0024] According to one aspect of an embodiment of this application, a low-latency silence detection device based on ALSA is provided, the device comprising:

[0025] The first module is used to move audio data to the audio buffer;

[0026] The second module is used to execute the DMA interrupt callback function when a DMA interrupt occurs.

[0027] The third module is used to obtain the audio data after the hw_ptr pointer and perform silence detection.

[0028] In one embodiment, the device further includes:

[0029] The fourth module is used to update the hw_ptr pointer.

[0030] According to one aspect of an embodiment of this application, a low-latency silence detection device based on ALSA is provided, the device comprising:

[0031] At least one processor;

[0032] At least one memory for storing at least one program;

[0033] When at least one of the programs is executed by at least one of the processors, a low-latency silence detection method based on ALSA as described in the preceding embodiments is implemented.

[0034] According to one aspect of the embodiments of this application, a storage medium is provided, the storage medium storing a processor-executable program, which, when executed by a processor, implements a low-latency silence detection method based on ALSA as described in the preceding embodiments.

[0035] The beneficial effects of the low-latency silence detection method, apparatus, and storage medium based on ALSA provided in this application are as follows: The method includes transferring audio data to an audio buffer; a DMA interrupt occurs, and a DMA interrupt callback function is executed; the audio data following the hw_ptr pointer is obtained, and silence detection is performed. Based on ALSA, this application places the silence detection data after the hw_ptr pointer in the audio buffer. When a DMA interrupt occurs, the audio data transferred in this DMA transfer can be obtained through the hw_ptr pointer. Using this data for silence detection can obtain real-time silence detection results, thereby reducing the latency of the silence detection results and improving the accuracy of silence detection.

[0036] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0037] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0038] Figure 1 A flowchart illustrating a low-latency silence detection method based on ALSA provided in this application embodiment;

[0039] Figure 2 The detection process of a low-latency silence detection method based on ALSA is provided for the embodiments of this application;

[0040] Figure 3 A schematic diagram of a low-latency silence detection device based on ALSA provided in an embodiment of this application;

[0041] Figure 4 This is a schematic diagram of another low-latency silence detection device based on ALSA provided in an embodiment of this application. Detailed Implementation

[0042] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0043] The terms "first," "second," "third," and "fourth," etc., used in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.

[0044] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0045] ALSA (Advanced Linux Sound Architecture) is the audio framework for Linux systems. This framework consists of two parts: the ALSA LIB and the ALSA driver. The ALSA LIB provides an interface for user-space applications, while the ALSA driver manages audio devices. The ALSA framework uses a circular buffer to manage audio data, manipulated by two pointers: appl_ptr and hw_ptr. The appl_ptr pointer is manipulated by the application, while the hw_ptr pointer is manipulated by the DMA hardware. The location where the DMA hardware moves audio data is determined by hw_ptr; the closer the data is to hw_ptr, the higher the real-time performance. During recording, hw_ptr is the pointer to write the audio buffer, and appl_ptr is the pointer to read the audio buffer; during playback, hw_ptr is the pointer to read the audio buffer, and appl_ptr is the pointer to write the audio buffer. Generally, silence detection resides in user space. During recording, silence detection data originates from the kernel audio buffer, while during playback, silence detection data comes from audio files or the network. A silence detection algorithm analyzes the audio data to obtain the silence detection result.

[0046] Traditional ALSA-based silence detection methods place the audio data to be detected after `appl_ptr`. There are multiple periods of audio data between `appl_ptr` and `hw_ptr`. The difference between `hw_ptr` and `appl_ptr` is the cause of the delay in the silence detection result; the larger the difference, the higher the delay. Generally, there are multiple periods of audio data between the two pointers `hw_ptr` and `appl_ptr`, resulting in a delay of several periods in the silence detection result. Specifically, the traditional ALSA-based silence detection method uses a circular buffer to manage audio data in the Linux kernel ALSA framework. The DMA generates an interrupt every time it moves one period of audio data. For playback, `appl_ptr` is the audio buffer write pointer, and `hw_ptr` is the audio buffer read pointer; for recording, `appl_ptr` is the audio buffer read pointer, and `hw_ptr` is the audio buffer write pointer. This method involves audio data between the audio buffer appl_ptr and hw_ptr. This audio data affects the real-time performance of silence detection, increases the latency of silence detection results, and reduces the accuracy of silence detection.

[0047] To address the aforementioned problems, this application proposes a low-latency silence detection method, apparatus, and storage medium based on ALSA. In the method of this invention, the ALSA-based silence detection data is located after the hw_ptr pointer in the audio buffer. When a DMA interrupt occurs, the audio data of the current DMA transfer can be obtained through the hw_ptr pointer. Using this data for silence detection allows for real-time silence detection results, thereby reducing the latency of the silence detection results and improving the accuracy of silence detection.

[0048] like Figure 1 As shown, the low-latency silence detection method based on ALSA proposed in this application includes:

[0049] S101, Move the audio data to the audio buffer.

[0050] S102, DMA interrupt occurs, execute the DMA interrupt callback function.

[0051] S103. Obtain the audio data after the hw_ptr pointer and perform silence detection.

[0052] This application performs silence detection by retrieving the audio data following hw_ptr. The implementation method is to retrieve the audio data of a period following hw_ptr in the DMA interrupt callback, use the audio data to perform silence detection, and obtain the silence detection result. In this way, the silence detection result is real-time, avoiding the delay problem of silence detection results in traditional methods.

[0053] Specifically, in step S101, before transferring the audio data to the audio buffer, the method further includes: configuring and starting the audio device and DMA through the ALSA interface.

[0054] Optionally, after retrieving the audio data following hw_ptr and performing silence detection, the method further includes updating the hw_ptr pointer.

[0055] Optionally, obtaining the audio data following the hw_ptr pointer includes: obtaining the audio data following the hw_ptr pointer; and selecting any period of audio data from the audio data following the hw_ptr pointer.

[0056] In this embodiment, obtaining the audio data following the hw_ptr pointer and performing silence detection includes: obtaining the audio data following the hw_ptr pointer; selecting several periods of audio data from the audio data following the hw_ptr pointer; and performing silence detection on each period of audio data.

[0057] Specifically, the implementation of silence detection in this embodiment includes: analyzing audio data through a silence detection algorithm; and obtaining silence detection results.

[0058] like Figure 2 As shown, the flow of the ALSA-based silent detection method in this application is as follows:

[0059] (1) The application configures and starts the audio device and DMA through the ALSA interface.

[0060] (2) DMA startup.

[0061] (3) DMA moves data to the audio buffer.

[0062] (4) When a DMA interrupt occurs, the DMA interrupt callback function is executed.

[0063] (5) Take the audio data after hw_ptr and perform silence detection.

[0064] (6) Update the hw_ptr pointer.

[0065] In the current technology, the silence detection audio data based on ALSA is located after the audio buffer appl_ptr pointer. There is a segment of audio data between the audio buffer appl_ptr and hw_ptr. This segment of audio data will affect the real-time performance of silence detection, increase the delay of silence detection results, and reduce the accuracy of silence detection.

[0066] The method of this application is based on the fact that the ALSA silence detection data is located after the hw_ptr pointer in the audio buffer. When a DMA interrupt occurs, the audio data of this DMA transfer can be obtained through the hw_ptr pointer. Using this data for silence detection can obtain real-time silence detection results, thereby reducing the delay of silence detection results and improving the accuracy of silence detection.

[0067] In addition, this application also provides a low-latency silence detection device based on ALSA, such as Figure 3 As shown, the device includes:

[0068] The first module 301 is used to move audio data to the audio buffer.

[0069] The second module 302 is used to execute the DMA interrupt callback function when a DMA interrupt occurs.

[0070] The third module 303 is used to obtain the audio data after the hw_ptr pointer and perform silence detection.

[0071] Furthermore, the ALSA-based low-latency silence detection device of this application also includes a fourth module for updating the hw_ptr pointer.

[0072] In addition, this application also provides a low-latency silence detection device based on ALSA, such as Figure 4 As shown, the device includes:

[0073] At least one processor 401;

[0074] At least one memory 402, the memory 402 being used to store at least one program;

[0075] When at least one of the programs is executed by at least one of the processors 401, a low-latency silence detection method based on ALSA as described in the preceding embodiments is implemented.

[0076] In addition, this application also provides a storage medium storing a processor-executable program that, when executed by a processor, implements a low-latency silence detection method based on ALSA as described in the preceding embodiments.

[0077] Similarly, the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0078] In some alternative embodiments, the functions / operations mentioned in the block diagrams may not occur in the order shown in the operation diagrams. For example, depending on the functions / operations involved, two consecutively shown blocks may actually be executed substantially simultaneously, or the blocks may sometimes be executed in reverse order. Furthermore, the embodiments presented and described in the flowcharts of this application are provided by way of example to provide a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented herein. Alternative embodiments are contemplated in which the order of various operations is changed and sub-operations described as part of a larger operation are executed independently.

[0079] Furthermore, although this application is described in the context of functional modules, it should be understood that, unless otherwise stated to the contrary, one or more of the functions and / or features may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding this application. Rather, given the properties, functions, and internal relationships of the various functional modules in the apparatus disclosed herein, the actual implementation of the module will be understood within the scope of conventional technology for an engineer. Therefore, those skilled in the art can implement the application set forth in the claims using ordinary techniques without excessive experimentation. It is also understood that the specific concepts disclosed are merely illustrative and not intended to limit the scope of this application, which is determined by the full scope of the appended claims and their equivalents.

[0080] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0081] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.

[0082] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which programs can be printed, because programs can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0083] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0084] In the foregoing description of this specification, the references to terms such as "one embodiment," "another embodiment," or "some embodiments," etc., indicate that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0085] Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and variations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.

[0086] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. An ALSA-based low-latency silence detection method, characterized by, The method includes: Move the audio data to the audio buffer; When a DMA interrupt occurs, the DMA interrupt callback function is executed. Obtain the audio data following the hw_ptr pointer and perform silence detection; The audio data obtained after retrieving the hw_ptr pointer includes: Get the audio data after the hw_ptr pointer; Select any period of audio data following the hw_ptr pointer; Obtain the audio data following the hw_ptr pointer and perform silence detection, including: Get the audio data after the hw_ptr pointer; Select several period audio data points from the audio data following the hw_ptr pointer; Perform silence detection for each period of audio data; The execution of the silence detection includes: Analyze audio data using a silence detection algorithm; Obtain the noise level test results.

2. The low latency silence detection method based on ALSA according to claim 1, wherein, Before transferring the audio data to the audio buffer, the method further includes: Configure and start the audio device and DMA via the ALSA interface.

3. The low latency silence detection method based on ALSA according to claim 1, wherein, After retrieving the audio data following hw_ptr and performing silence detection, the method further includes: Update the hw_ptr pointer.

4. An ALSA-based low-latency silence detection apparatus, characterized by, The device includes: The first module is used to move audio data to the audio buffer; The second module is used to execute the DMA interrupt callback function when a DMA interrupt occurs. The third module is used to obtain the audio data after the hw_ptr pointer and perform silence detection; The audio data obtained after retrieving the hw_ptr pointer includes: Get the audio data after the hw_ptr pointer; Select any period of audio data following the hw_ptr pointer; Obtain the audio data following the hw_ptr pointer and perform silence detection, including: Get the audio data after the hw_ptr pointer; Select several period audio data points from the audio data following the hw_ptr pointer; Perform silence detection for each period of audio data; The execution of the silence detection includes: Analyze audio data using a silence detection algorithm; Obtain the noise level test results.

5. The low latency silence detection apparatus based on ALSA according to claim 4, wherein, The device further includes: The fourth module is used to update the hw_ptr pointer.

6. An ALSA-based low-latency silence detection apparatus, characterized by, The device includes: At least one processor; At least one memory for storing at least one program; When at least one of the programs is executed by at least one of the processors, a low-latency silence detection method based on ALSA as described in any one of claims 1-3 is implemented.

7. Storage medium, characterized in that The storage medium stores a processor-executable program, which, when executed by the processor, implements a low-latency silence detection method based on ALSA as described in any one of claims 1-3.

Citation Information

Patent Citations

  • Audio-data processing method and device

    CN108459837A