A storage method, device and storage medium of audio data
By employing a double-buffered ring structure and a data block writing strategy in the recording device, the problem of recording interruption in the prior art is solved, and continuous and stable storage of audio data and high-fidelity recording are achieved.
Patent Information
- Application Number
- CN202610493471.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-14
- Publication Date
- 2026-08-25
AI Technical Summary
In existing technologies, during long-term high-fidelity recording, the switching of volatile memory is not linked to the write state of non-volatile memory, resulting in buffer overflow and recording interruption, and making it impossible to achieve continuous and stable audio data storage.
A dual-buffered ring structure is adopted, in which the first volatile memory and the second volatile memory work alternately in a ring. Combined with a preset threshold to trigger the sequential writing of data blocks into non-volatile memory, and an XOR check mechanism and CRC32 check algorithm are used to ensure data integrity.
It enables continuous and uninterrupted acquisition and stable storage of audio data, avoiding data frame loss and interruption during the recording process, and improving the stability and data integrity of the device in long-term high-fidelity recording scenarios.
Smart Images

Figure CN122633141A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of storage technology, and in particular to a method, apparatus and storage medium for storing audio data. Background Technology
[0002] In the field of audio acquisition technology, especially in scenarios requiring long-term, high-fidelity recording (such as meeting minutes, on-site investigations, voice monitoring, and portable recording devices), real-time acquisition and stable storage of audio data are core technical requirements. Currently, conventional audio acquisition and storage solutions mainly employ a single storage medium or a simple single-buffer storage mode. In practical applications, these solutions have gradually revealed numerous technical shortcomings, making it difficult to meet the demands for efficient and stable recording.
[0003] In the prior art, two independent volatile memories (first and second volatile memories) are set up. The audio data collected by the microphone array is first written to the first volatile memory. When the first volatile memory is full, the writing is switched to the second volatile memory, and at the same time, the data in the first volatile memory is written to the non-volatile memory. After the data in the first volatile memory is written and the second volatile memory is full, the writing is switched back to the first volatile memory, and the cycle repeats.
[0004] However, existing technologies lack a dual-buffered ring structure. The switching between the two volatile memories is triggered only by the memory being full, without being linked to the write state of the non-volatile memory. During long-term high-sampling-rate recording, if the non-volatile memory write speed slows down or takes too long, a situation may arise where one buffer is not fully written while the other is already full, resulting in no buffer available for newly acquired audio, causing frame drops and recording interruptions. Furthermore, the lack of block writing and ring buffer scheduling leads to abrupt switching, is prone to write conflicts, and makes it difficult to achieve continuous and stable high-fidelity recording. Summary of the Invention
[0005] This application discloses an audio data storage method, device, and storage medium, which are used to achieve continuous and uninterrupted acquisition and stable storage of audio data, and avoid data frame loss or interruption during the recording process.
[0006] The first aspect of this application discloses a method for storing audio data, applied to a recording device, comprising:
[0007] In recording mode, audio data is captured through the built-in microphone array; The acquired audio data is written to the device's internal first volatile memory in real time; When the amount of audio data stored in the first volatile memory is detected to reach a preset threshold, the audio data in the first volatile memory is written to an external non-volatile memory in a block order according to a preset size data block. At the same time, the currently acquired audio data is switched and written to the second volatile memory inside the device in real time. The first volatile memory and the second volatile memory form a double-buffered ring structure.
[0008] Optionally, writing the audio data in the first volatile memory into external non-volatile memory in a block-by-block format according to a preset size includes: The data blocks are sequentially written to the main storage partition of the external non-volatile memory, and copies of the data blocks written to the main storage partition are written to the backup partition of the non-volatile memory. An XOR check mechanism is performed on the data of the primary storage partition and the backup partition to generate an XOR check value; When a data block in the primary storage partition is damaged or lost, the damaged or lost data block is automatically recovered based on the corresponding copy of the backup partition and the XOR check value.
[0009] Optionally, after writing the audio data in the first volatile memory into external non-volatile memory in a block-by-block format according to a preset size, the method further includes: The audio data in the non-volatile memory is verified using a verification algorithm to generate a verification result; The verification result is compared with the original audio data in the first volatile memory; If the comparison matches, the audio data is determined to have been written correctly.
[0010] Optionally, after determining that the audio data has been written correctly, the method further includes: Clear the data blocks that have been written into the non-volatile memory in the first volatile memory.
[0011] Optionally, after writing the audio data in the first volatile memory into external non-volatile memory in a block-by-block format according to a preset size, the method further includes: Add metadata to each data block, including timestamps, device identifiers, and microphone array acquisition parameters; The metadata is associated with the corresponding data blocks and stored, and a metadata index library is established; The metadata in the metadata index is stored in encrypted form.
[0012] Optionally, the method further includes: The ambient noise frequency band and the target audio frequency band in the audio data are identified by using multi-channel data from the microphone array. Dynamically adjust the noise reduction parameters for the corresponding frequency band.
[0013] Optionally, the method further includes: The preset threshold is dynamically adjusted based on at least one parameter among the sampling frequency of the audio data, the remaining storage space of the first volatile memory, the write rate of the non-volatile memory, and the encoding format of the audio data.
[0014] Optionally, the method further includes: Based on the sampling rate and number of channels of the currently acquired audio data, the available storage capacity of the first volatile memory and the second volatile memory is adjusted in real time. When the sampling rate increases or the number of channels increases, the available capacity of the volatile memory currently performing write operations is expanded, and the idle capacity of another volatile memory is reduced. When the sampling rate decreases or the number of channels decreases, the available capacity of the volatile memory currently performing write operations is reduced, and the idle capacity of another volatile memory is increased.
[0015] Optionally, the method further includes: During the process of writing audio data from the first volatile memory into the external non-volatile memory in blocks of a preset size, if a power supply abnormality is detected and there is audio data that has not been written, the backup power supply is activated, and the unwritten audio data is continued to be written into the non-volatile memory.
[0016] A second aspect of this application provides a storage device, comprising: The acquisition unit is used to acquire audio data through a built-in microphone array in recording mode; The first writing unit is used to write the acquired audio data to the first volatile memory inside the device in real time. The second writing unit is used to write the audio data in the first volatile memory to an external non-volatile memory in a block order according to a preset size when the amount of audio data stored in the first volatile memory is detected to reach a preset threshold. At the same time, it switches the currently acquired audio data to the second volatile memory inside the device in real time. The first volatile memory and the second volatile memory form a double-buffered ring structure.
[0017] A third aspect of this application provides a storage device, comprising: Processor, memory, input / output units, and bus; The processor is connected to memory, input / output units, and a bus; The memory holds a program, which the processor calls to execute, as in the first aspect and any optional method of the first aspect.
[0018] The fourth aspect of this application provides a computer-readable storage medium on which a program is stored, which, when executed on a computer, performs the methods of the first aspect and any optional methods of the first aspect.
[0019] As can be seen from the above technical solutions, this application has the following advantages: 1. By triggering switching and writing when the amount of data stored in the first volatile memory reaches a preset threshold, the problem of delayed triggering caused by existing technologies is avoided. The buffer space is released in advance to prevent buffer overflow caused by the delay in writing to non-volatile memory, thus solving the problems of audio data frame loss and recording interruption.
[0020] 2. Data blocks of a preset size are written sequentially to non-volatile memory to overcome the defects of excessive overall write time and abrupt switching, reduce the pressure of a single write, reduce write conflicts, and improve storage smoothness.
[0021] 3. The first volatile memory and the second volatile memory form a double-buffered ring structure, which realizes the parallel processing of audio data acquisition and data writing to external memory. This solves the problems of discontinuous buffer scheduling and poor connection, ensures uninterrupted audio acquisition, and improves the stability of the device and the integrity of data in long-term high-fidelity recording scenarios. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the 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.
[0023] Figure 1 A schematic flowchart of an embodiment of an audio data storage method provided in this application; Figure 2 A schematic diagram illustrating an embodiment of writing audio data from a first volatile memory to a non-volatile memory, provided in this application; Figure 3 A schematic diagram of an embodiment of writing audio data from a first volatile memory to a non-volatile memory, provided for the purposes of this application; Figure 4 A schematic diagram of an embodiment of the process of acquiring audio data provided in this application; Figure 5 A schematic flowchart illustrating an embodiment of the double-buffered structure provided in this application; Figure 6 A structural diagram of an embodiment of a storage device provided in this application; Figure 7 This is a structural diagram of another embodiment of a storage device provided in this application. Detailed Implementation
[0024] It should be noted that the audio data storage method provided in this application can be applied to servers, devices, terminals, or other devices with logical processing capabilities, and this application does not limit it. For ease of description, the following description uses a system where the execution subject is a recording device as an example.
[0025] Please see Figure 1 This application provides an embodiment of an audio data storage method, comprising: 101. In recording mode, audio data is acquired through the built-in microphone array; After the device starts recording mode, it uses the built-in microphone array to collect ambient audio signals in real time and converts them into a digital audio data stream. This audio data is generated in PCM (Pulse Code Modulation) or other compression formats (such as ADPCM, OPUS, etc.), and the sampling rate, bit depth, and number of channels are pre-configured according to the specific application scenario.
[0026] 102. The acquired audio data is written to the device's internal first volatile memory in real time; The acquired digital audio data stream is written to the device's internal first volatile memory in real time and continuously. This first volatile memory is typically a dedicated buffer within a high-speed RAM (such as SRAM or DRAM). The process of writing audio data to the first volatile memory ensures low latency in audio acquisition and avoids signal loss or interruption due to storage operations.
[0027] 103. When the amount of audio data stored in the first volatile memory is detected to reach a preset threshold, the audio data in the first volatile memory is written to the external non-volatile memory in a block order according to the preset size data block. At the same time, the currently acquired audio data is switched and written to the second volatile memory inside the device in real time. The first volatile memory and the second volatile memory form a double-buffered ring structure.
[0028] The audio data accumulated in the first volatile memory to a preset threshold is divided into data blocks of a preset size (e.g., each data block is 32KB), and the data blocks are written sequentially to an external non-volatile memory. This non-volatile memory can be a Flash memory chip, eMMC, SD card, or solid-state drive, etc.
[0029] Dividing data into blocks of a preset size aims to adapt to the write characteristics of non-volatile memory, improve write efficiency, and reduce storage fragmentation. Sequential writing to non-volatile memory maintains the temporal continuity of audio data, facilitating subsequent playback or processing. DMA (Direct Memory Access) or a dedicated memory controller are used during the writing process to reduce CPU usage.
[0030] During the process of transferring audio data from the first volatile memory to the non-volatile memory, the audio data currently collected by the multiple microphones is switched and written to the second volatile memory in real time.
[0031] The working mechanism of the double-buffered ring structure formed by the first volatile memory and the second volatile memory is as follows: While the audio data in the first volatile memory is being transferred to the non-volatile memory, the second volatile memory takes over the writing of real-time audio data. Once the audio data in the first volatile memory has been transferred, it becomes idle and waits for the next switch. When the amount of data in the second volatile memory reaches a preset threshold, the audio data in the second volatile memory is transferred to the non-volatile memory. During the process of transferring the audio data in the second volatile memory to the non-volatile memory, the memory that receives the real-time acquired audio data is switched to the first volatile memory. The first volatile memory and the second volatile memory are used in a cyclical manner to form a circular alternation, realizing parallel operation of acquisition and storage, and avoiding audio loss caused by storage waiting.
[0032] The preset threshold is dynamically adjusted based on at least one parameter among the following: the sampling frequency of the audio data, the remaining storage space of the first volatile memory, the write rate of the non-volatile memory, and the encoding format of the audio data.
[0033] The preset threshold is an adaptive variable that is dynamically calculated based on the real-time status of the system. The adjustment can be based on any combination of one or more parameters, including the sampling frequency of the audio data, the remaining storage space of the first volatile memory (the currently active buffer), the real-time write rate of the non-volatile memory, and the encoding format of the audio data.
[0034] Specifically, during recording, the sampling frequency of the audio data, the remaining storage space of the first volatile memory, the write rate of the non-volatile memory, and the encoding format of the audio data are continuously or periodically collected. Based on these parameters, a new preset threshold is calculated using a predetermined strategy, and the calculated new threshold value is immediately updated to the currently used preset threshold. The next time the buffer data volume is checked, the new preset threshold is used to determine whether to trigger a switch.
[0035] To avoid extreme values in threshold calculations due to instantaneous parameter fluctuations (such as too small values causing the system to be overwhelmed with frequent switching, or too large values rendering the buffering mechanism ineffective), a reasonable range of values can be set for the dynamic threshold. The threshold ultimately used by the system will be limited to between this minimum and maximum value.
[0036] If the system detects that the write rate of the external non-volatile memory is abnormally low (close to zero) or that the remaining space in the buffer is abnormal, it can determine that the storage medium is faulty or there is a hardware error. At this point, it will not only stop dynamic adjustment, but also trigger a high-level error alarm and start a security protection process (such as pausing recording and prompting the user).
[0037] Optionally, during the process of writing audio data from the first volatile memory into external non-volatile memory in a block-by-block sequence according to a preset size, if a power supply abnormality is detected and there is audio data that has not been written, the backup power supply is activated, and the unwritten audio data is continued to be written into the non-volatile memory.
[0038] A power-loss protection mechanism for audio data storage is provided to ensure data integrity during sudden power outages. Specifically, during the process of writing audio data in blocks from the first volatile memory to external non-volatile memory, if the real-time power monitoring circuit detects a main power supply anomaly, the system immediately initiates a hardware emergency procedure: the backup power supply unit takes over, providing stable power to the system core. With this power support, the system prioritizes ensuring that currently being written but incomplete data blocks are continued to be written completely and correctly to the non-volatile memory.
[0039] The event information of this power outage is written to a fixed location on the storage medium. After the device is powered on again, the startup process checks the event information and performs consistency repair on the file system to ensure that the final generated audio files are continuous and usable.
[0040] In this embodiment, by triggering the switching and writing when the amount of data stored in the first volatile memory reaches a preset threshold, the problem of delayed triggering caused by the prior art is avoided, the buffer space is released in advance, and buffer overflow is prevented due to the writing delay of the non-volatile memory, thus solving the problem of audio data frame loss and recording interruption.
[0041] By using data blocks of a preset size to write sequentially to non-volatile memory, the defects of excessive overall write time and abrupt switching are overcome, reducing the pressure of a single write, reducing write conflicts, and improving storage smoothness.
[0042] The first and second volatile memories form a double-buffered ring structure, enabling parallel processing of audio data acquisition and data writing to external memory. This solves the problems of discontinuous buffer scheduling and poor connection, ensuring uninterrupted audio acquisition throughout the process and improving the stability of the device and the integrity of the data in long-term high-fidelity recording scenarios.
[0043] In step 103 above, the audio data in the first volatile memory is written to the external non-volatile memory in a block-by-block order according to a preset size. Please refer to [link to relevant documentation]. Figure 2 , Figure 2 An embodiment of writing audio data from a first volatile memory to a non-volatile memory, provided in this application, includes: 201. Write the data blocks sequentially to the main storage partition of the external non-volatile memory, and at the same time write a copy of the data blocks written to the main storage partition to the backup partition of the non-volatile memory. During system operation, when audio data from the first volatile memory needs to be saved to external non-volatile memory, the audio data is divided into contiguous data blocks of fixed or variable size. For each data block, it is written to the main storage partition in the non-volatile memory, which is designated for regular storage, according to logical address order. At the same time, an identical copy of the data block is created and written to a pre-allocated, independent backup partition in the non-volatile memory. This backup partition does not participate in regular file system read / write operations and is used only for data redundancy protection.
[0044] Each piece of valid data has two identical physical storage copies in non-volatile memory: one in the primary partition for normal access; and the other in the backup partition as a security backup.
[0045] 202. Perform an XOR check mechanism on the data in the primary storage partition and the backup partition to generate an XOR check value; After the audio data block and its copy are written to the primary and backup partitions of the non-volatile memory, respectively, the system starts a background verification process. This verification process performs a bitwise XOR operation on each pair of successfully written, identical data blocks (i.e., a data block in the primary partition and its corresponding copy in the backup partition). Specifically, it XORs each bit of the specified data block in the primary partition with the bits at the same position in the corresponding copy data block in the backup partition.
[0046] The system performs an XOR operation on the corresponding data blocks in the primary storage partition and the backup partition, defines the raw result as the XOR checksum, and stores it. The generation of this XOR checksum serves a dual purpose: First, data consistency verification. Ideally, the primary and backup data blocks should be completely consistent, and their XOR checksums should be all zeros. Any checksum that is not all zeros indicates inconsistency between the corresponding data blocks in the two partitions, and the system can trigger a consistency alarm accordingly.
[0047] Second, a mathematical relationship for data recovery is established. The XOR checksum and the primary and backup data blocks form a reversible mathematical relationship group (primary data, backup data, checksum), where any two can be XORed to derive the third. This characteristic provides crucial protection for subsequent possible data recovery scenarios. When data block corruption is detected in any storage partition, the system can use the intact data block from the other partition and the pre-stored XOR checksum to accurately reconstruct the damaged original data through XOR operation.
[0048] 203. When data blocks in the primary storage partition are damaged or lost, the damaged or lost data blocks are automatically recovered based on the corresponding copy in the backup partition and the XOR check value. When a data block in the primary storage partition is detected as unreadable, the system first locates its pre-stored complete copy in the backup partition based on the address information of the corrupted data block. Simultaneously, it retrieves the pre-calculated and stored XOR checksum corresponding to the data block from a protected specific storage area.
[0049] The system performs an XOR operation between the intact backup data block in the backup partition and the stored XOR checksum; the result is the original correct data content. Essentially, this process reverses the process by calculating the backup data block and the checksum to deduce the original primary data block before the corruption. The system then writes the calculated data block to the physical address of the original corrupted data block in the primary storage partition, completing the repair.
[0050] 204. Verify the audio data in the non-volatile memory using a verification algorithm and generate the verification result; After writing the audio data blocks to the main and backup partitions of the non-volatile memory and generating the corresponding XOR checksum values, the system initiates the verification process. The CRC32 checksum algorithm is used to perform verification operations on the audio data in the non-volatile memory.
[0051] Each audio data block in the non-volatile main memory partition is read one by one, extracting the original binary data of each block. The read data is then input byte by byte into the CRC32 checksum algorithm's computation unit. This unit has a built-in standard CRC32 checksum polynomial, which performs a full operation on the input audio data block through iterative operations of bit-by-bit XOR and cyclic shift. During the operation, the computation unit updates the value of the 32-bit checksum register in real time. The checksum register value is updated synchronously after each byte of data is processed, until all bytes of data in the data block have been processed.
[0052] After a single data block is processed, the processing unit uses the resulting 32-bit binary value as the CRC32 check result for that audio data block. This check result is presented as a hexadecimal string for easy system storage, retrieval, and subsequent comparison operations. All audio data blocks in the non-volatile memory are checked one by one according to the above process, generating corresponding data block check results, forming a complete set of check results, and temporarily stored in a designated storage area within the system.
[0053] 205. Compare the verification result with the original audio data in the first volatile memory; After temporarily storing the generated CRC32 check result in the designated internal storage area in step 204, this step retrieves the baseline CRC32 check value of the corresponding original audio data block from the first volatile memory. This baseline check value is pre-calculated and stored by the system for the original audio data block before the audio data is written to the non-volatile memory. The system then compares the generated check result bit by bit with the baseline check value. During the comparison, the system checks each bit of the binary data in the check result to accurately determine whether they match completely, and records relevant information during the comparison process to ensure the traceability of the comparison results.
[0054] 206. If the comparison matches, the audio data is determined to have been written correctly; After comparing the verification result bit by bit with the benchmark verification value, a comprehensive judgment is made on the result. If the comparison result is completely consistent, it is determined that no data corruption or packet loss occurred during the writing of the audio data block to the non-volatile memory, and the writing operation was accurate and error-free. If the comparison result is different, it is determined that the audio data block was written abnormally, triggering an abnormal alarm signal, and recording the identification information of the abnormal data block, including the data block number and storage address.
[0055] 207. Clear the data blocks that have been written to the non-volatile memory in the first volatile memory.
[0056] After confirming that the audio data has been written correctly to the non-volatile memory, a clear command is sent to the first volatile memory. The command explicitly specifies the range of data blocks to be cleared, namely all audio data blocks that have been successfully written to the main storage partition and backup partition of the non-volatile memory and have been verified to be correct. After the clear operation is completed, the system confirms that the target data blocks have been completely cleared, sets the first volatile memory to a write-ready state, and ensures that the double-buffered ring structure can switch normally.
[0057] In this embodiment, a dual-copy storage mechanism of primary and backup partitions is used to avoid unrecoverable audio data due to data corruption or loss in a single storage partition. Simultaneously, the introduction of an XOR check mechanism not only verifies the consistency of data between the primary and backup partitions in real time but also leverages the reversible nature of XOR operations to achieve rapid automatic recovery when primary partition data is corrupted. A CRC32 check algorithm is used to perform secondary verification on the audio data in the non-volatile memory, accurately detecting anomalies such as packet loss and data corruption that may occur during the audio data writing process. Data blocks that have been written to the first volatile memory are promptly cleared to release storage space and ensure continuous reception of subsequently acquired audio data.
[0058] In step 103 above, the audio data in the first volatile memory is written to the external non-volatile memory in a block-by-block order according to a preset size. Please refer to [link to relevant documentation]. Figure 3 , Figure 3 An embodiment of the present application, which involves writing audio data from a first volatile memory to a non-volatile memory, includes: 301. Add metadata to each data block, including timestamp, device identifier, and microphone array acquisition parameters; For each audio data block that has completed write verification, unique metadata is configured for it. The metadata includes three core types of information: timestamp, device identifier, and microphone array acquisition parameters.
[0059] The timestamp is the current time information automatically obtained when the corresponding audio data block is acquired, used to record the generation time of each audio data block; the device identifier is the unique identifier of the recording device, which is pre-configured at the factory and may include information such as device serial number and device model, used to distinguish audio data generated by different recording devices; the microphone array acquisition parameters are the real-time operating parameters of the microphone array when acquiring the audio data block, including the number of microphone array channels, sampling frequency, gain value, noise reduction parameter configuration, etc., to completely restore the acquisition environment of the audio data.
[0060] The system integrates and encapsulates the above three types of information according to the preset metadata format, forming a metadata data package that corresponds one-to-one with each audio data block, ensuring the integrity and parsability of the metadata.
[0061] 302. Associate metadata with corresponding data blocks for storage, and establish a metadata index library; After configuring unique metadata for each audio data block, the first step is to establish the association between the metadata and the audio data block. Specifically, the system assigns a unique association identifier to each audio data block in non-volatile memory. This association identifier is uniquely bound to the storage address of the audio data block. At the same time, the metadata data packet is bound to this association identifier for storage, thus achieving a precise association between the metadata and the audio data block.
[0062] After completing the associated storage, the creation of the metadata index library is initiated. The metadata index library is constructed using a tree structure or hash table structure, with the association identifier of each audio data block as the index key and the corresponding metadata data package as the index value. Metadata information is entered into the index library one by one. Simultaneously, the system categorizes and organizes the index library, creating secondary indexes based on dimensions such as timestamp order and device identifier type to improve metadata retrieval efficiency.
[0063] A complete metadata index is established and stored in an independent index storage area on non-volatile memory. This area is independent of the main storage partition and backup partition of the audio data blocks, ensuring normal access to the audio data blocks and facilitating separate management and maintenance of metadata. The metadata index enables rapid querying, retrieval, and management of metadata for all audio data blocks.
[0064] 303. Encrypt and store the metadata in the metadata index.
[0065] After the metadata index is established, in order to ensure the security of the metadata and prevent it from being illegally tampered with, stolen or leaked, all metadata in the metadata index is encrypted and stored.
[0066] The AES encryption algorithm is selected as the metadata encryption algorithm. This algorithm features high encryption strength and fast computation efficiency, making it suitable for the encrypted storage requirements of metadata. The specific encryption process is as follows: First, a preset encryption key is obtained. This key is pre-configured by the administrator and can be stored in the device's secure storage area, accessible only to authorized system modules. Using the metadata index as the overall encryption unit, all metadata data packets in the index are treated as encrypted data. The AES encryption algorithm is used to perform encryption operations with the preset encryption key to generate encrypted metadata ciphertext data packets.
[0067] After the encryption operation is completed, the system replaces the original plaintext data packet with the encrypted metadata ciphertext data packet and stores it in the original storage area of the metadata index library in non-volatile memory, while retaining encryption-related information such as encryption algorithm identifier and key version.
[0068] Even if an unauthorized user obtains the stored data in the metadata index, they will be unable to extract the true content of the metadata through illegal means. This ensures the security of sensitive data such as device information and acquisition parameters contained in the metadata, and further enhances the information security of the entire audio data storage system.
[0069] In this embodiment, a metadata index is established by adding metadata containing timestamps, device identifiers, and microphone array acquisition parameters to each audio data block. This allows for the complete recording of the source, acquisition time, and acquisition environment of the audio data, enabling the audio data to be traceable and source-traceable, improving the retrieval efficiency of audio data and related information, and enhancing data management and retrieval efficiency.
[0070] Encrypting the storage of metadata indexes can prevent metadata from being illegally read, tampered with, or forged, protect sensitive information such as device information and acquisition parameters from being leaked, and improve the security and confidentiality of the entire audio storage system.
[0071] Metadata corresponds one-to-one with audio data blocks and is managed independently. This does not affect the normal reading and writing of audio data, but also provides reliable auxiliary information during data recovery and verification, thereby enhancing the overall stability and data credibility of the system.
[0072] In step 101 above, audio data is acquired through the built-in microphone array. Please refer to [link / reference]. Figure 4 , Figure 4 An embodiment following the acquisition of audio data provided in this application includes: 401. Identify the ambient noise frequency band and the target audio frequency band in audio data using multi-channel data from a microphone array; During the acquisition of audio data via the built-in microphone array, a multi-channel data parsing process is simultaneously initiated. Leveraging the multi-channel acquisition advantage of the microphone array, accurate identification and differentiation between environmental noise frequency bands and target audio frequency bands are achieved. The microphone array contains multiple independent microphone channels, each simultaneously acquiring audio signals from the surrounding environment. The audio data acquired from each channel is synchronously received and integrated to form a multi-channel audio dataset.
[0073] The built-in frequency band identification algorithm is invoked to perform spectrum analysis on the audio data, convert the audio signal into a frequency-amplitude correspondence, clarify the frequency band distribution range of the entire audio signal, and then perform partition identification on the parsed spectrum based on the preset target audio frequency band threshold.
[0074] Among them, frequency bands that match the preset target audio frequency band and whose amplitude conforms to the target audio characteristics are determined to be the target audio frequency band, and the data corresponding to the frequency band is the valid audio data that the user needs to collect; while frequency bands that exceed the target audio frequency band range, have relatively stable amplitudes, and conform to environmental noise characteristics (such as low-frequency current noise, high-frequency noise, background human voices, etc. in the environment) are determined to be environmental noise frequency bands.
[0075] At the same time, the system will cross-validate the multi-channel data, compare the noise frequency bands identified by each channel with the target audio frequency band, eliminate abnormal identification results, ensure the accuracy of frequency band identification, and avoid identification deviations caused by abnormal acquisition of a single channel.
[0076] 402. Dynamically adjust the noise reduction parameters for the corresponding frequency band.
[0077] After accurately identifying the environmental noise frequency band and the target audio frequency band, the noise reduction parameters for the corresponding frequency band are adjusted accordingly based on the identified frequency band information.
[0078] The system has a pre-stored noise reduction parameter benchmark library, which contains initial noise reduction parameters corresponding to different frequency bands. The initial parameters can be preset according to common recording scenarios. Based on the environmental noise frequency band identified in step 401, the initial noise reduction parameters for the corresponding frequency band in the benchmark library are retrieved. At the same time, the initial parameters are dynamically corrected by combining the noise amplitude and noise change trend collected in real time.
[0079] For identified ambient noise frequency bands, if the noise amplitude is large, the noise reduction intensity of that frequency band will be appropriately increased to enhance the noise suppression effect; if the noise amplitude is small, the noise reduction intensity will be reduced to avoid excessive noise reduction leading to audio distortion. At the same time, the system will adjust the filtering threshold to ensure that the filtering operation only applies to the ambient noise frequency band and does not involve the target audio frequency band, preventing the target audio signal from being mistakenly filtered or damaged.
[0080] During the adjustment process, signal changes in the target audio frequency band are monitored in real time. If abnormal attenuation or distortion of the amplitude of the target audio frequency band is detected, the corresponding noise reduction parameters are called back to balance the noise reduction effect with the integrity of the target audio. In addition, changes in ambient noise are continuously tracked. When the frequency band or amplitude of ambient noise fluctuates (such as when the environment changes from quiet to noisy, or when the noise frequency band shifts), the noise reduction parameters are updated dynamically to ensure that the noise reduction effect always adapts to the current environment, achieving adaptive noise reduction throughout the entire acquisition process.
[0081] In this embodiment, a frequency band identification algorithm accurately identifies the ambient noise frequency band and the target audio frequency band, avoiding confusion between noise and valid audio. This reduces noise interference with the target audio at the source, ensuring that the acquired audio data is clear and pure. Based on the real-time identification of noise frequency bands and amplitude changes, core parameters such as noise reduction intensity and filtering threshold are dynamically adjusted. This allows for flexible adaptation to fluctuations in different noise environments, avoiding incomplete noise reduction when the noise amplitude is high and preventing audio distortion caused by excessive noise reduction when the noise amplitude is low, thus balancing noise reduction effect and audio integrity. During the adjustment of noise reduction parameters, the signal changes of the target audio frequency band are monitored in real time. Once abnormal attenuation or distortion of the target audio is detected, the parameters are immediately reverted to ensure that the filtering operation only applies to the ambient noise frequency band and does not damage the target audio signal.
[0082] In step 103 above, the first volatile memory and the second volatile memory form a double-buffered ring structure. Please refer to [link / reference needed]. Figure 5 , Figure 5 One embodiment of the double-buffered structure provided in this application includes: 501. Adjust the available storage capacity of the first volatile memory and the second volatile memory in real time according to the sampling rate and number of channels of the currently acquired audio data; During the process of audio data acquisition and double buffering, the sampling rate of the currently acquired audio data and the number of channels of the microphone array are monitored in real time. Based on these two core parameters, the available storage capacity of the two volatile memories (such as SRAM memory) is dynamically adjusted to ensure that the storage capacity matches the audio data generation rate, thereby avoiding recording interruptions caused by insufficient storage space or resource waste caused by idle storage space.
[0083] The system pre-establishes a model relating sampling rate, number of channels, and storage capacity. This model, combined with the audio data encoding format, presets the amount of audio data generated per unit time under different sampling rates and number of channels, thereby determining the minimum and maximum allocatable capacity required for each volatile memory. During audio acquisition, the current sampling rate and number of channels are acquired in real time, substituted into the model, and the optimal allocation scheme for the available capacity of the two volatile memories in the current scenario is calculated.
[0084] Meanwhile, the current storage occupancy of the two volatile memories is monitored in real time. Based on the calculated optimal allocation scheme, the available storage capacity is dynamically adjusted. During the adjustment process, the total available capacity of the two volatile memories remains unchanged. Only the capacity allocation ratio between the two is optimized in real time to ensure that the double-buffered ring structure can switch normally and ensure the continuity of audio data storage.
[0085] 502. When the sampling rate increases or the number of channels increases, expand the available capacity of the volatile memory currently performing write operations and reduce the idle capacity of another volatile memory. When the sampling rate of the currently acquired audio data is detected to be increased, or the number of channels of the microphone array is increased, it is determined that the amount of audio data generated per unit time is also increasing. If the original capacity allocation is maintained, the volatile memory currently performing write operations will be quickly filled up, which may easily lead to the risk of recording interruption.
[0086] In response to this situation, the system immediately expands the available capacity of the current write memory according to the corresponding relationship model. The expansion amount is positively correlated with the increase in the sampling rate and the increase in the number of channels. At the same time, the available capacity of another volatile memory that has not performed a write operation is reduced. The reduced capacity is equal to the expanded capacity of the current write memory, ensuring that the total available capacity remains unchanged.
[0087] Assuming an initial system configuration with a sampling rate of 16kHz, 2 channels, and 2MB of audio data generated per unit time, the available capacity of the first volatile memory is 8MB, the available capacity of the second volatile memory is 4MB, and the total available capacity is 12MB. At this point, the first volatile memory is the currently written memory. When the sampling rate is increased to 48kHz (a 3x increase) and the number of channels is increased to 6 channels (a 3x increase), the amount of audio data generated per unit time increases to 6MB. The available capacity of the first volatile memory is increased from 8MB to 24MB, while the available capacity of the second volatile memory is decreased from 4MB to -12MB (this is example logic; in actual adjustments, the total capacity remains 12MB, meaning the available capacity of the second volatile memory is adjusted to 0MB, and the idle capacity is correspondingly increased). This ensures that the first volatile memory can accommodate the increased audio data and prevents recording interruptions.
[0088] 503. When the sampling rate decreases or the number of channels decreases, reduce the available capacity of the volatile memory currently performing write operations and increase the idle capacity of another volatile memory.
[0089] When it is detected that the sampling rate of the currently acquired audio data decreases or the number of channels in the microphone array decreases, it is determined that the amount of audio data generated per unit time decreases accordingly. Then, according to the corresponding relationship model, the available capacity of the current write memory is immediately reduced, and the reduction is positively correlated with the reduction in the sampling rate and the reduction in the number of channels. At the same time, the available capacity of the idle memory is expanded, and the expanded capacity is equal to the reduced capacity of the current write memory. This avoids idle capacity and reserves sufficient storage space for the subsequent recovery of the sampling rate and the number of channels.
[0090] In this embodiment, the available capacity of the two volatile memories is dynamically adjusted according to the real-time changes in the sampling rate and the number of channels, ensuring that the storage capacity is precisely matched with the audio data generation rate. This avoids the problem of insufficient storage when the sampling rate increases and the number of channels increases, and also solves the problem of idle storage when the sampling rate decreases and the number of channels decreases, thus ensuring continuous and stable writing of audio data.
[0091] By flexibly adjusting the capacity allocation ratio of the two volatile memories, storage resources are maximized while keeping the total available capacity constant, avoiding idle waste, and ensuring the normal switching of the dual-buffered ring structure, thereby improving the operating efficiency of the entire storage system.
[0092] Please see Figure 6 This application provides an embodiment of a storage device, comprising: Acquisition unit 601 is used to acquire audio data through a built-in microphone array in recording mode; Optionally, it also includes an identification unit 602, used for: Identify the ambient noise frequency band and the target audio frequency band in the audio data using multi-channel data from a microphone array; Optionally, it also includes a first adjustment unit 603, used for: Dynamically adjust the noise reduction parameters for the corresponding frequency band.
[0093] The first writing unit 604 is used to write the acquired audio data to the first volatile memory inside the device in real time. The second writing unit 605 is used to write the audio data in the first volatile memory to an external non-volatile memory in a block order according to a preset size when the amount of audio data stored in the first volatile memory is detected to reach a preset threshold. At the same time, it switches the currently acquired audio data to the second volatile memory inside the device in real time. The first volatile memory and the second volatile memory form a double-buffered ring structure.
[0094] Optionally, the second write unit 605 is also used for: Data blocks are sequentially written to the main storage partition of external non-volatile memory, while copies of the data blocks written to the main storage partition are written to the backup partition of non-volatile memory. Perform an XOR check mechanism on the data in the primary storage partition and the backup partition to generate an XOR check value; When data blocks in the primary storage partition are damaged or lost, the damaged or lost data blocks are automatically recovered based on the corresponding copy in the backup partition and the XOR checksum.
[0095] Optionally, a generation unit 606 is also included, for: The audio data in the non-volatile memory is verified using a verification algorithm, and the verification result is generated. Optionally, a comparison unit 607 is also included, for: The verification result is compared with the original audio data in the first volatile memory; Optionally, a third write unit 608 is also included, for: If the comparison matches, the audio data is determined to have been written correctly.
[0096] Optionally, a clearing unit 609 is also included, for: Clear the data blocks that have been written to non-volatile memory in the first volatile memory.
[0097] Optionally, it also includes adding unit 610 for: Add metadata to each data block, including timestamps, device identifiers, and microphone array acquisition parameters; Optionally, it also includes a building unit 611, used for: Associate metadata with corresponding data blocks for storage, and establish a metadata index library; Optionally, an encryption unit 612 is also included, for: Encrypt the storage of metadata in the metadata index.
[0098] Optionally, a second adjustment unit 613 is also included, for: The preset threshold is dynamically adjusted based on at least one parameter among the following: the sampling frequency of the audio data, the remaining storage space of the first volatile memory, the write rate of the non-volatile memory, and the encoding format of the audio data.
[0099] Optionally, a third adjustment unit 614 is also included, for: Based on the sampling rate and number of channels of the currently acquired audio data, the available storage capacity of the first volatile memory and the second volatile memory is adjusted in real time. When the sampling rate increases or the number of channels increases, the available capacity of the volatile memory currently performing write operations is expanded, and the idle capacity of another volatile memory is reduced. When the sampling rate decreases or the number of channels decreases, the available capacity of the volatile memory currently performing write operations is reduced, and the idle capacity of another volatile memory is increased.
[0100] Optionally, a detection unit 615 is also included, for: During the process of writing audio data from the first volatile memory into external non-volatile memory in blocks of a preset size, if a power supply abnormality is detected and there is audio data that has not been written, the backup power supply is activated, and the unwritten audio data is continued to be written into the non-volatile memory.
[0101] For detailed implementation methods, please refer to... Figures 1 to 5 Examples are not detailed here.
[0102] Please see Figure 7 This application provides a storage device, comprising: Processor 701, memory 702, input / output unit 703, and bus 704.
[0103] The processor 701 is connected to the memory 702, the input / output unit 703, and the bus 704.
[0104] The memory 702 stores a program, and the processor 701 calls the program to execute it, such as... Figure 1 , Figure 2 , Figure 3 , Figure 4 as well as Figure 5 The method in the middle.
[0105] This application provides a computer-readable storage medium on which a program is stored, and when the program is executed on a computer, it performs the following... Figure 1 , Figure 2 , Figure 3 , Figure 4 as well as Figure 5 The method in the middle.
[0106] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0107] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0108] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0109] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0110] If the integrated unit 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 all or 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 described in 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.
Claims
1. A method for storing audio data, applied to a recording device, characterized in that, include: In recording mode, audio data is captured through the built-in microphone array; The acquired audio data is written to the device's internal first volatile memory in real time; When the amount of audio data stored in the first volatile memory is detected to reach a preset threshold, the audio data in the first volatile memory is written to an external non-volatile memory in a block order according to a preset size data block. At the same time, the currently acquired audio data is switched and written to the second volatile memory inside the device in real time. The first volatile memory and the second volatile memory form a double-buffered ring structure.
2. The storage method according to claim 1, characterized in that, The step of writing the audio data in the first volatile memory into external non-volatile memory in a block-by-block order according to a preset size includes: The data blocks are sequentially written to the main storage partition of the external non-volatile memory, and copies of the data blocks written to the main storage partition are written to the backup partition of the non-volatile memory. An XOR check mechanism is performed on the data of the primary storage partition and the backup partition to generate an XOR check value; When a data block in the primary storage partition is damaged or lost, the damaged or lost data block is automatically recovered based on the corresponding copy of the backup partition and the XOR check value.
3. The storage method according to claim 1, characterized in that, After writing the audio data in the first volatile memory into external non-volatile memory in a block-by-block format according to a preset size, the method further includes: The audio data in the non-volatile memory is verified using a verification algorithm to generate a verification result; The verification result is compared with the original audio data in the first volatile memory; If the comparison matches, the audio data is determined to have been written correctly.
4. The storage method according to claim 3, characterized in that, After determining that the audio data has been written correctly, the method further includes: Clear the data blocks that have been written into the non-volatile memory in the first volatile memory.
5. The storage method according to claim 1, characterized in that, After writing the audio data in the first volatile memory into external non-volatile memory in a block-by-block format according to a preset size, the method further includes: Add metadata to each data block, including timestamps, device identifiers, and microphone array acquisition parameters; The metadata is associated with the corresponding data blocks and stored, and a metadata index library is established; The metadata in the metadata index is stored in encrypted form.
6. The storage method according to claim 1, characterized in that, After acquiring audio data via a built-in microphone array, the method further includes: The ambient noise frequency band and the target audio frequency band in the audio data are identified by using multi-channel data from the microphone array. Dynamically adjust the noise reduction parameters for the corresponding frequency band.
7. The storage method according to any one of claims 1-6, characterized in that, The method further includes: The preset threshold is dynamically adjusted based on at least one parameter among the sampling frequency of the audio data, the remaining storage space of the first volatile memory, the write rate of the non-volatile memory, and the encoding format of the audio data.
8. The storage method according to any one of claims 1-6, characterized in that, The method further includes: Based on the sampling rate and number of channels of the currently acquired audio data, the available storage capacity of the first volatile memory and the second volatile memory is adjusted in real time. When the sampling rate increases or the number of channels increases, the available capacity of the volatile memory currently performing write operations is expanded, and the idle capacity of another volatile memory is reduced. When the sampling rate decreases or the number of channels decreases, the available capacity of the volatile memory currently performing write operations is reduced, and the idle capacity of another volatile memory is increased.
9. The storage method according to any one of claims 1-6, characterized in that, The method further includes: During the process of writing audio data from the first volatile memory into the external non-volatile memory in blocks of a preset size, if a power supply abnormality is detected and there is audio data that has not been written, the backup power supply is activated, and the unwritten audio data is continued to be written into the non-volatile memory.
10. A storage device, characterized in that, The device includes: The acquisition unit is used to acquire audio data through a built-in microphone array in recording mode; The first writing unit is used to write the acquired audio data to the first volatile memory inside the device in real time. The second writing unit is used to write the audio data in the first volatile memory to an external non-volatile memory in a block order according to a preset size when the amount of audio data stored in the first volatile memory is detected to reach a preset threshold. At the same time, it switches the currently acquired audio data to the second volatile memory inside the device in real time. The first volatile memory and the second volatile memory form a double-buffered ring structure.
11. A storage device, characterized in that, The device includes: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, which the processor calls to execute the method for storing audio data as described in any one of claims 1 to 9.
12. A computer-readable storage medium having a program stored thereon, the program executing, when executed on a computer, the method for storing audio data as described in any one of claims 1 to 9.