Audio file packaging method and system and electronic equipment

By providing audio file packaging methods in the on-board system, the audio files are automatically parsed, converted and packaged, which solves the problem that audio files cannot be automatically packaged, improves processing efficiency and reduces the probability of errors.

CN119513052APending Publication Date: 2025-02-25CHENGDU CELIS TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411568124.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-05
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

Audio files cannot be automatically packaged in the on-board system, resulting in users needing to manually enter the file address, file name and file length, which is prone to errors.

Method used

Provides an audio file packaging method, which realizes automated processing by obtaining imported audio files, judging their file format, parsing and converting them into suitable formats, sorting and packaging them into bin files.

Benefits of technology

Reduces manual operations, reduces the probability of errors, improves processing efficiency, and realizes automatic import and packaging of audio files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119513052A_ABST
    Figure CN119513052A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of vehicle-mounted systems, and discloses an audio file packaging method and system and electronic equipment. Comprising the steps of judging a file format of an audio file; if the file format is a WAV file, analyzing the WAV file into a PCM file, converting the PCM file into monaural data in a large-end format, and storing the monaural data in a temporary list; if the file format is a PCM file, the file size, the file path and the file format of the PCM file form a first file object, and the first file object is also stored in the temporary list; sorting and analyzing the temporary list by file names, and determining the file size and the file item of each PCM file; determining a start address and an end address of the PCM file according to the data size of the global file list and the file size of the PCM file, and storing each file item in the global file list; and packaging the file items in the global file list to obtain a bin file. According to the method, the slave audio file is automatically imported to generate the bin file, so that full-automatic processing is realized, and the processing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of vehicle-mounted systems, and in particular to an audio file packaging method, system and electronic equipment. Background Art

[0002] As cars enter the intelligent era, smart cockpits are required to have more advanced and richer infotainment functions to meet consumers' user experience. Audio files are the core function of smart cockpits, covering applications such as car audio, voice recognition, e-Call, noise cancellation and echo cancellation.

[0003] In the related technologies, especially in many vehicle systems with external DSP, the sound source (frequency) file (PCM data) of the warning sound is stored in the Flash of the DSP, and the MCU alone can quickly make the instrument sound, without relying on the SOC at all. However, the external sound source file formats are diverse and lack versatility. On the one hand, it is impossible to meet various customization requirements, such as the inability to adjust the file gap and Flash memory; on the other hand, it is impossible to automatically export and package the audio file, and the user needs to manually enter the address, file name, file length, etc., which is prone to errors. Summary of the invention

[0004] In order to provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. The summary is not an extensive review, nor is it intended to identify key / critical components or delineate the scope of protection of these embodiments, but rather serves as a prelude to the detailed description that follows.

[0005] In view of the above-mentioned shortcomings of the prior art, the present application provides an audio file packaging method, system and electronic device to solve the problem that audio files cannot be automatically packaged in a vehicle-mounted system.

[0006] The first aspect of the present application provides an audio file packaging method, including: obtaining an imported audio file and determining the file format of the audio file; if the file format of the audio file is a WAV file, parsing the WAV file into a PCM file, and converting the PCM file into mono data in big-endian format, and saving it in a temporary list; if the file format of the audio file is a PCM file, forming a first file object with the file size, file path, and file format of the PCM file, and also saving it in a temporary list; sorting the PCM files in the temporary list by file name, cyclically parsing the PCM files in the temporary list, and determining the file size and file items of each PCM file; determining the start address and end address of the PCM file according to the data size of the current global file list and the file size of the PCM file, and saving each file item in the global file list; packaging the file items in the global file list to obtain a bin file.

[0007] In some possible embodiments of the present application, it also includes: if the file format of the audio file is a project file, the version number, bin file path and file list of the current interface are cleared, and the version number, bin file path and file list of the project file are imported and displayed.

[0008] In some possible embodiments of the present application, it also includes: if all files in the temporary list are parsed and the project file is not identified, the files in the temporary list are sorted according to the file name, the bin file path where each file is stored is determined, and saved to the global file list.

[0009] In some possible embodiments of the present application, after saving to the global file list, it also includes: if it is detected that the global file list has changed, traverse the global file list, and display the hexadecimal value in the preset interface according to the file name, the location of the file in the flash, and the file size, and adjust the display order of each PCM file through the up, down and delete operations set in the preset interface.

[0010] In some possible embodiments of the present application, the display order of each PCM file is adjusted, and after the global file list is updated, it includes: if the version number is not empty, generating a version number as a default value according to a preset format; if the bin file address is also empty, selecting a folder to store the bin file and the .h file, wherein the file name of the bin file is the version number corresponding to the default value; merging the PCM files into a large buffer according to the size, starting address and PCM file of each PCM file saved in the global file list; calculating the data length and MD5 value of the large buffer to obtain a file header; and writing the file header into the storage path or version number corresponding to the folder.

[0011] In some possible embodiments of the present application, after writing the file header to the storage path or version number corresponding to the folder, it also includes: traversing the bin files stored in the specified path to generate a file with a version number of .h; converting the file name of the .h file to uppercase format, and calculating the playback duration of each .h file according to a preset sampling rate and a preset sampling depth; determining the playback start address and file length according to a preset playback code format and the playback duration of the .h file, wherein the playback code format includes a sound source sequence number, a playback flag, a starting address of the file in the flash, a file length, a file data pointer, and a number of repetitions.

[0012] In some possible embodiments of the present application, the WAV file is parsed into a PCM file, and the PCM file is converted into monaural data in big-endian format and saved in a temporary list, including: checking the sampling rate and sampling format of the first preset position in the WAV file, and after the check is passed, extracting the monaural data at the second preset position in the WAV file and determining it as the original data body; creating a buffer for caching the original data body; traversing the original data body, exchanging data at the third preset position in the original data body, and jumping to the fourth preset position to process the next frame of data in the original data body, determining it as the buffer in big-endian format, and forming a second file object with the buffer, file path, file format and size of the buffer, and saving it in a temporary list.

[0013] In some possible embodiments of the present application, the file items in the global file list are packaged to obtain a bin file, including: generating a variable definition field in the code through the PCM file name of each file item, saving the PCM file to the variable definition field under the corresponding storage directory in the global file list, and packaging the variable definition field to obtain a bin file.

[0014] In some possible embodiments of the present application, the file items in the global file list are packaged to obtain a bin file, and it also includes: storing the PCM file and the WAV file as a binary bin file in a project file, and when importing the project file, storing the PCM file and the WAV file parsed from the project file in a PCM folder under the same directory as the project file to form a new file path and save it in the global file list.

[0015] The second aspect of the present application also provides an audio file packaging system, including: an acquisition module, used to acquire an imported audio file and determine the file format of the audio file; a first processing module, used to parse the WAV file into a PCM file if the file format of the audio file is a WAV file, and convert the PCM file into mono data in big-endian format, and save it in a temporary list; a second processing module, used to form a first file object with the file size, file path, and file format of the PCM file if the file format of the audio file is a PCM file, and also save it in a temporary list; a parsing module, used to sort the PCM files in the temporary list by file name, cyclically parse the PCM files in the temporary list, and determine the file size and file items of each PCM file; a storage module, used to determine the start address and end address of the PCM file according to the data size of the current global file list and the file size of the PCM file, and save each file item in the global file list; a packaging module, used to package the file items in the global file list to obtain a bin file.

[0016] The third aspect of the present application also provides an electronic device, including: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device performs the above method.

[0017] The beneficial effects of the present application are as follows: by judging the file format of the imported audio file; if the file format of the audio file is a WAV file, parsing the WAV file into a PCM file, and converting the PCM file into mono data in big-endian format, saving it in a temporary list, converting the WAV file into big-endian PCM data, reducing manual operations and reducing the probability of errors; if the file format of the audio file is a PCM file, forming the file size, file path, and file format of the PCM file into a first file object, and also saving it in a temporary list; by creating a temporary list to store PCM files or PCM files, it is convenient to centrally manage audio data; the PCM files in the temporary list are sorted by file name. The PCM files in the temporary list are parsed in a loop, and the file size and file items of each PCM file are determined, thereby ensuring the orderliness of the audio data during the processing, reducing errors and duplications, and improving the overall processing efficiency; according to the data size of the current global file list and the file size of the PCM file, the start address and the end address of the PCM file are determined, and each file item is saved in the global file list; the storage and management of audio data are simplified, the file items in the global file list are packaged, a bin file is obtained, and the audio file is automatically imported to generate a bin file, thereby realizing fully automated processing, greatly reducing the user's operating burden, and improving processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 It is a flowchart of an audio file packaging method in an embodiment of the present application;

[0019] Figure 2 It is a schematic diagram of the WAVE file structure in an audio file packaging method in an embodiment of the present application;

[0020] Figure 3 This is a complete flow chart of an audio file packaging method in an embodiment of the present application;

[0021] Figure 4 This is a schematic diagram of a global file list display interface in an audio file packaging method in an embodiment of the present application;

[0022] Figure 5 It is a structural diagram of an audio file packaging system in an embodiment of the present application;

[0023] Figure 6 It is a structural schematic diagram of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0024] The following describes the embodiments of the present invention through specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and sub-samples in the embodiments can be combined with each other without conflict.

[0025] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0026] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.

[0027] The terms "first", "second", etc. in the specification and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so as to describe the embodiments of the embodiments of the present disclosure described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions.

[0028] Unless otherwise stated, the term "plurality" means two or more.

[0029] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B indicates: A or B.

[0030] The term "and / or" is a description of the association relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or, A and B.

[0031] Combination Figure 1 As shown, the present disclosure provides a flowchart of an audio file packaging method, including:

[0032] Step S101, obtaining an imported audio file and determining the file format of the audio file;

[0033] Exemplarily, the audio files include lossy formats and lossless formats, which are not limited here. In this embodiment, according to the application scenario, the audio files on the vehicle side mainly include WAV format, PCM format and AFProj format, and of course, FLAC format, APE format, etc.

[0034] For example, the vehicle end (i.e., the vehicle side) is divided according to the driving energy, including but not limited to fuel vehicles, pure electric vehicles, hybrid vehicles, etc. For example, hybrid vehicles are extended-range electric vehicles or plug-in hybrid vehicles. The vehicle end can also be divided into ordinary passenger vehicles and large vehicles according to their uses, such as trucks or buses.

[0035] Specifically, the file format of the audio file is determined by the file name of the audio file suffix.

[0036] Step S102, if the file format of the audio file is a WAV file, the WAV file is parsed into a PCM file, and the PCM file is converted into monaural data in a big-endian format and stored in a temporary list;

[0037] Optionally, in some embodiments, the WAV file is parsed into a PCM file, and the PCM file is converted into mono data in a big-endian format and stored in a temporary list, including:

[0038] Verifying the sampling rate and sampling format of the first preset position in the WAV file, and after passing the verification, extracting the mono data of the second preset position in the WAV file and determining it as the original data body;

[0039] Creating a buffer for caching the original data body;

[0040] The original data body is traversed, data is exchanged at a third preset position in the original data body, and the data is jumped to a fourth preset position to process the next frame of data in the original data body, and the buffer is determined to be in a big-endian format, and the buffer, file path, file format and size of the buffer are formed into a second file object, which is saved in a temporary list.

[0041] Specifically, the header of a WAV file contains metadata about the audio file, including information such as sampling rate, sampling bit number (sampling format), number of channels, etc. The information in the WAV file header is read to check whether the sampling rate and sampling format are consistent with expectations. For example, the expected sampling rate is 44.1kHz and the sampling format is 16-bit PCM. For example, a WAV file is imported, and by reading its header information, if the sampling rate is 44.1kHz and the sampling format is 16-bit PCM, the verification passes.

[0042] For example, a WAV file includes the starting position of the audio data. Since a WAV file contains multiple channels (such as stereo), it is necessary to extract the data of one of the channels (such as the left channel or the right channel), or mix the dual-channel data into mono data; if the WAV file is in stereo format, choose to extract the mono data as the original data body.

[0043] For another example, a memory buffer is created to store a raw data body extracted from a WAV file, and the audio data in the raw data body is converted into a big-endian format.

[0044] Among them, the third preset position refers to the byte position of each sample data in the original data body. For 16-bit PCM data, each sample consists of two bytes. If the original data is in little-endian format, the positions of these two bytes need to be swapped to convert to big-endian format.

[0045] If the sample data in the original data body is in little-endian format, traverse each sample and swap the positions of the first byte and the second byte to convert it to big-endian format; after converting the current frame data, jump to the starting position of the next frame data to continue processing.

[0046] For another example, the fourth preset position is the starting position of the next sample data calculated according to the audio sampling rate and frame size. If the audio data is stored in frames, after processing the data of the current frame, jump to the starting position of the next frame data according to the frame size. A second file object is created, which contains the converted big-endian format buffer data, the path of the original WAV file, the file format (such as PCM) and the size of the buffer. This file object is added to a temporary list for subsequent processing or packaging.

[0047] In this way, the mono data is extracted from the WAV file, converted to big-endian format, and encapsulated into a file object containing the necessary information.

[0048] Step S103, if the file format of the audio file is a PCM file, the file size, file path, and file format of the PCM file are formed into a first file object, which is also stored in a temporary list;

[0049] Specifically, the file size, file path, file format and other information of the PCM file are directly read to form a first file object (eg, a dictionary or class instance containing such information).

[0050] Step S104, sorting the PCM files in the temporary list by file name, cyclically parsing the PCM files in the temporary list, and determining the file size and file items of each PCM file;

[0051] Specifically, the PCM files in the temporary list are sorted according to the file names by using a sorting function or algorithm in a programming language, such as quick sort, merge sort, etc., to ensure that the order of the files is consistent during subsequent processing, which is convenient for management and search.

[0052] Traverse the sorted temporary list, and for each PCM file in the list, perform the following operations: read the file's metadata (such as file name, extension, etc.); use file operation functions to obtain the actual size of the file; determine the file item information, including but not limited to file name, file size, file type, etc.

[0053] Step S105, determining the start address and the end address of the PCM file according to the data size of the current global file list and the file size of the PCM file, and saving each of the file items into the global file list;

[0054] Specifically, if the global file list is empty or needs to be reinitialized, a new data structure (such as an array, dictionary, etc.) is created to store the file item information.

[0055] For example, traverse the sorted PCM file list, and for each file, calculate its starting address, and calculate the ending address of the file by adding an offset to the total size of the current global file list (that is, the sum of the sizes of all added files), which is usually the starting address plus the file size; save the file item information of each PCM file (including file name, file size, starting address, ending address, etc.) to the global file list. If the global file list is stored in dictionary form, the file name can be used as the key and the file item information as the value.

[0056] Optionally, in some embodiments, the file items in the global file list are packaged to obtain a bin file, including: generating a variable definition field in the code through the PCM file name of each file item, saving the PCM file to the variable definition field under the corresponding storage directory in the global file list, and packaging the variable definition field to obtain a bin file.

[0057] Specifically, the variable name is generated according to the name, path or other attributes of the PCM file, for example, the name of the PCM file (minus the path and extension) is used as the basis of the variable name, and then some prefixes or suffixes are added to ensure uniqueness.

[0058] The global file list may be a data structure (such as an array, a dictionary, etc.), in which each element includes a variable name, a storage path, and other related information of a PCM file.

[0059] Determine the storage directory of the PCM file according to its type, source or other attributes. For example, create subdirectories according to the first letter of the PCM file name, or organize the directory structure according to a certain classification standard, copy the PCM file to the specified storage directory, or read the data of the PCM file and then save it to the specified file in binary format.

[0060] In this embodiment, a new bin file is created and the variable definition fields of each PCM file are written into this bin file in binary format. In order to ensure the correctness and readability of the data, a header information is written before writing the data, including metadata (such as the number of variable definition fields, the size of each field, etc.).

[0061] Optionally, in some embodiments, after the file items in the global file list are packaged to obtain a bin file, it also includes: storing the PCM file and the WAV file as a binary bin file in a project file, and when importing the project file, storing the PCM file and the WAV file parsed from the project file in a PCM folder under the same directory as the project file to form a new file path and save it in the global file list.

[0062] Specifically, all PCM files in the global file list and the metadata of the WAV file (such as variable definition, file path, etc.) are packaged into one or more bin files; the packaged bin files and the original PCM files and WAV files are stored together in the project file so that they can be easily imported and used later; for example, the bin files, PCM files and WAV files are copied to a specified directory of the project file, such as a compressed package or a special project file format.

[0063] In this embodiment, according to the development environment and tools used, the corresponding import function is used to load the project file into the development environment, read the header information of the bin file, parse the metadata of each file item according to the header information, create a folder named PCM, and then copy the parsed PCM file and WAV file to the folder. If the file is stored in the bin file in the form of binary data, it is first extracted and then saved as an actual PCM or WAV file, and the global file list is traversed. For each file item, a new file path is constructed in the PCM folder according to its original file name and extension, and then the new file path is updated to the corresponding position in the global file list.

[0064] Optionally, in some embodiments, it also includes: if the file format of the audio file is a project file, clearing the version number, bin file path and file list of the current interface, and importing the version number, bin file path and file list of the project file, and displaying them.

[0065] Specifically, determine whether the audio file currently being processed is a project file. Before importing a new project file, clear all old information displayed on the current interface to avoid confusion or errors; read the version number, bin file path and file list from the project file, and import this information into the software; display the imported project file information on the software interface so that users can view and use this information.

[0066] Optionally, in some embodiments, it also includes: if all files in the temporary list are parsed and the project file is not identified, sorting the files in the temporary list according to the file name, determining the bin file path where each file is stored, and saving them to the global file list.

[0067] Specifically, confirm whether all files in the temporary list have been parsed, and confirm whether the project file is identified during the parsing process. If the project file is not identified, sort the files in the temporary list for subsequent processing. At the same time, traverse the sorted temporary list, assign a bin file path to each file, and save the sorted file list and the bin file path of each file to the global file list.

[0068] Optionally, in some embodiments, after saving to the global file list, it also includes: if it is monitored that the global file list has changed, traversing the global file list, and displaying the hexadecimal value in a preset interface according to the file name, the location of the file in the flash, and the file size, and adjusting the display order of each PCM file through the up, down and delete operations set in the preset interface.

[0069] Specifically, the global file list is initialized, the information of all PCM files (including file name, location in flash, file size, etc.) is loaded, and a monitoring mechanism is set to detect any changes in the global file list (such as adding, deleting, modifying file information, etc.). When changes are detected in the global file list (such as the user adding a new file or deleting an existing file), the response process is triggered, and the response process traverses the global file list to obtain the latest file information.

[0070] Update the display of the preset interface based on the latest content of the global file list. The displayed information should include the file name, the location of the file in the flash, the file size, and the hexadecimal value of the file. The preset interface should use a clear layout and labels to display this information so that users can easily understand it.

[0071] In the preset interface, buttons or icons for up, down, and delete operations are provided for each PCM file item. When the user clicks these buttons, the corresponding sorting or deletion operations are performed, and the display of the global file list and the preset interface is updated. If the user wants to save the adjusted display order or makes other important changes, a save button can be provided. When the user clicks the save button, the latest state of the global file list is saved to a persistent storage (such as a file, database, etc.). In this way, even if the program is closed and restarted, the previously set display order and file information can be restored.

[0072] Optionally, in some embodiments, adjusting the display order of each PCM file after updating the global file list includes:

[0073] If the version number is not empty, a default version number is generated according to a preset format;

[0074] If the bin file address is also empty, select a folder to store the bin file and the .h file, wherein the file name of the bin file is the version number corresponding to the default value;

[0075] According to the size and starting address of each PCM file stored in the global file list, the PCM files are merged into a large buffer;

[0076] Calculate the data length and MD5 value of the large buffer to obtain a file header;

[0077] The file header is written into the storage path or version number corresponding to the folder.

[0078] Specifically, the user adjusts the display order of PCM files through the up and down operations in the preset interface, changes the actual order of the files in the global file list, and updates the display order in the global file list after the user completes the sorting. According to the user's operation (such as adding, deleting, modifying file information or adjusting the display order), the global file list is updated, so as to ensure that the information in the global file list is the latest and consistent with the display of the preset interface.

[0079] Check whether the global file list contains version number information. If the version number is not empty, generate a default version number in a preset format (which may be based on the current date, time or other rules); if the version number is empty, you may need to prompt the user to enter a version number, or use a default placeholder.

[0080] Check whether the address of the bin file is specified in the global file list. If the bin file address is also empty, select a folder to store the bin file and the .h file. The file name of the bin file should be named with the version number corresponding to the default value to ensure the uniqueness and identifiability of the file. The .h file can contain metadata related to the bin file, such as version number, file size, start address, etc.

[0081] Traverse the global file list and merge the PCM file sizes, start addresses and PCM file contents saved in the list into a large buffer. This large buffer will contain continuous data of all PCM files, arranged in the order in which they are actually stored in the flash. Calculate the data length of the large buffer, that is, the total size of all PCM files, where the MD5 value of the large buffer is calculated to verify the integrity and consistency of the data; combine the data length and MD5 value into a file header, which may also contain other metadata, such as version number, file format identifier, etc. Write the generated file header to the storage path corresponding to the previously selected folder, or write it to a specific file associated with the version number to ensure that the file header is written correctly and can be read and verified by subsequent programs or tools.

[0082] In this embodiment, the minimum gap size between files can be 0, which can save flash space and reduce hardware costs.

[0083] Optionally, in some embodiments, after writing the file header to the storage path or version number corresponding to the folder, the method further includes:

[0084] Traverse the bin files stored in the specified path and generate a .h file with a version number;

[0085] Convert the file name of the .h file to uppercase format, and calculate the playback time of each .h file according to the preset sampling rate and the preset sampling depth;

[0086] The playback start address and file length are determined according to a preset playback code format and the playback duration of the .h file, wherein the playback code format includes a sound source serial number, a playback flag, a file start address in the flash, a file length, a file data pointer, and a number of repetitions.

[0087] Specifically, a folder path is specified, under which all bin files are stored, and the file traversal function in the programming language is used to list all files under the path, and the files with the file extension .bin are filtered out for subsequent processing. For each filtered bin file, a corresponding .h file is created, and version information is written in the .h file, including but not limited to a fixed version number, which can also be dynamically generated based on the file name, date or other rules, so that the naming of the .h file can be ensured to be consistent with the corresponding bin file.

[0088] Convert each character in the file name to uppercase letters, read the contents of the bin file, understand its data structure (for example, whether it is PCM format, and parameters such as sampling rate and sampling depth), and calculate the playback duration based on the preset sampling rate and sampling depth, as well as the data size in the bin file. Preset a playback code format, which includes fields such as the source number, playback flag, the starting address of the file in the flash, the file length, the file data pointer, and the number of repetitions.

[0089] The starting address is usually determined based on the layout of the flash memory and can be a fixed offset or dynamically calculated based on the size of the previously stored file.

[0090] The file length is the actual size of the bin file (or the data segment referenced in the .h file).

[0091] The file data pointer is a pointer or offset to the actual data location in flash.

[0092] Repeat count is an optional field in the playback code, which is used to specify whether the file needs to be played repeatedly and the number of times.

[0093] Based on the above information, generate playback code for each .h file (or corresponding bin file).

[0094] Through the above method, the bin files under the specified path are traversed, the .h file containing version information is generated, and the playback time of each file is calculated. Finally, the playback code is generated according to the preset playback code format.

[0095] See also Figure 3 , a complete flow chart of an audio file packaging method in an embodiment of the present application is described in detail as follows:

[0096] 1) Import files: For easy import, you can drag and drop multiple files at once, import multiple files at once, sort them by file name, and automatically calculate the address and size of each file based on the sound source (audio) data size, gap, etc. The specific file import process is as follows:

[0097] 1.1) If the file format is recognized as a WAV file, process the file header. The WAV file header is shown in the following 2 figures. Take Byte 24-27 of the file to compare whether the sampling rate is 48K, and take Byte 34-35 to compare whether the sampling format is 16Bit. If it does not meet the format requirements, discard the file and use the Windows pop-up window to provide incorrect format; if the format check is correct, then take the position of Byte 22-23 to get the number of channels, and take the data after Byte 44 as the original data body. Since WAV is a little-endian format, and the underlying DSP only recognizes the big-endian format, the data needs to be processed according to the following logic: Create a new buffer, the length of the buffer is the original data format size divided by the number of channels. Traverse the original data body, swap the data positions of the first byte and the second byte (change to big-endian), then jump to the position of the number of channels * 2 (2 bytes per channel), process the next frame of data, and the final buffer is a big-endian mono buffer. The obtained buffer, file path, file format, and buffer size are formed into a file object, which is added to a temporary drag file list (dragFileList, a temporary list).

[0098] 1.2) If the file format is identified as PCM data, the file format is determined to be correct, and its file size, file path, and file format are formed into a file object (ie, the first file object), which is added to the temporary drag file list (dragFileList).

[0099] 1.3) If the file format is identified as a .AFProj suffix, which means it is a project file, the version number, bin file path, and file list of the existing interface will be cleared, and then the version number, bin file path, and file list corresponding to the imported project file will be displayed. After the import is completed, exit the file import process, and if dragFileList is not empty, clear it.

[0100] 1.4) Until all the dragged files are parsed, no .AFProj project files are identified, and dragFileList (temporary drag file list) is not empty at this time, then sort the files in dragFileList by file name, calculate the storage location of each file in the bin, and then add it to the global file list (gFileList).

[0101] Finally, call the update method to recalculate the display. The key code is as follows.

[0102]

[0103]

[0104] 2) Process the global file list. Every time a global file changes, a unified update method is used to calculate the data and update the interface. First, add a head to the file list, then traverse the global file list (gFileList), and place each item on the interface after identification and calculation according to the file name, the location of the file in the flash, the file size, the hexadecimal display value, etc., and each item has three buttons: delete, move up, and move down. It is used for users to manually change the order of files. When changing the order, first change the position of the file in gFileList, and then update the starting address according to the updated file list.

[0105] like Figure 4 As shown, there is also a new button. In addition to dragging and dropping, you can also add files manually. Double-click to enter the folder and select files.

[0106] 3)Package the files in the global file list into bin

[0107] 3.1) Check if the version number is empty. If it is not empty, a default value is automatically generated in the format (AF_yyMMdd_xx); if the bin file address is also empty, a pop-up window will prompt the user to select a bin file path. The bin file name is the default version number.bin. The rules for generation are as follows: traverse gFileList, get the file path, if it is a wav file, read the pcmBuffer of wav, if it is a pcm file, read the file content directly.

[0108] For example, 100 bytes are reserved for the file header. When calculating the address, the end address of the previous file, the current file size, and the reserved gap (assuming 100 bytes, the minimum can be 0) are used. After all the pcm data is combined into a large buffer, the MD5 value of this buffer is calculated, the total size of this buffer is generated according to the file header format, and then the file header and pcmBuffer are written into the version.bin file. The MD5 value is very important. When upgrading the sound source, after the SOC writes the entire bin into the DSP, it verifies whether the file is written successfully by calculating the MD5 value of the bin file header. The flash places files in the A / B partition mode, and switches partitions when the file passes the MD5 check.

[0109] 3.2) Generate a file with version number .h in the same directory as the bin file. Convert the file name to uppercase, and get the playback time of the sound source according to the following format based on the file sampling rate (48K) and sampling depth (16): time = (bufferLength*1000) / (samplerate*format). According to the code format, you can get the following similar code: audio_ctrl_play_flash_t is the structure of the player, which contains the sound source number, play flag (whether it is playing, the default is 0 if it is not playing), the starting address of the file in the flash, the file length, the file data pointer (reserved for use), and the number of repetitions. The instrument client can directly call AUDIO_CTRL_CHIME_TYPE_E during playback to play the audio_ctrl_play_flash_t of the corresponding file, and set the number of plays to play.

[0110]

[0111] 4) Import and export of projects: After the initial version of the audio source is integrated, subsequent modifications only require a small part and do not need to be imported in full, so the existing project is retained for easy import next time.

[0112] 4.1) In order to make this project available on any computer, you need to put the imported audio source file into the project file and put the pcm / wav file into the project file in binary format.

[0113] 4.2) When importing a project, parse the pcm / wav file from the project file and put it in the pcm folder in the same directory as the project file. After forming a new file path, load it into gFileList and load the file version number, bin path, etc.

[0114] In this embodiment, not only can the code be automatically generated according to the imported file to convert WAV into big-endian PCM data, reducing manual operations and lowering the probability of errors; at the same time, a custom format version number and MD5 verification data header can be added for data verification and upgrade results. All audio source files can be dragged in at one time, or they can be added according to existing projects. The operation steps are few and simple.

[0115] See also Figure 5 , is a schematic diagram of the structure of an audio file packaging system in an embodiment of the present application, comprising:

[0116] The acquisition module 501 is used to acquire the imported audio file and determine the file format of the audio file;

[0117] The first processing module 502 is used for parsing the WAV file into a PCM file if the file format of the audio file is a WAV file, and converting the PCM file into mono data in a big-endian format, and storing it in a temporary list;

[0118] The second processing module 503 is used for, if the file format of the audio file is a PCM file, converting the file size, file path and file format of the PCM file into a first file object, and also saving it in a temporary list;

[0119] A parsing module 504, used for sorting the PCM files in the temporary list by file name, cyclically parsing the PCM files in the temporary list, and determining the file size and file items of each PCM file;

[0120] The storage module 505 is used to determine the start address and the end address of the PCM file according to the data size of the current global file list and the file size of the PCM file, and save each file item in the global file list;

[0121] The packaging module 506 is used to package the file items in the global file list to obtain a bin file.

[0122] Among them, the acquisition module 501 is used to execute the aforementioned step 101, the first processing module 502 is used to execute the aforementioned step 102, the second processing module 503 is used to execute the aforementioned step 103, the analysis module 504 is used to execute the aforementioned step 104, the storage module 505 is used to execute the aforementioned step 105, and the packaging module 506 is used to execute the aforementioned step 106. The corresponding technical details and embodiments are exactly the same. Please refer to the above-mentioned audio file packaging method.

[0123] The audio file packaging system provided by the embodiment of the present disclosure is adopted to judge the file format of the imported audio file; if the file format of the audio file is a WAV file, the WAV file is parsed into a PCM file, and the PCM file is converted into mono data in big-endian format and saved in a temporary list, and the WAV file is converted into big-endian PCM data, thereby reducing manual operations and the probability of errors; if the file format of the audio file is a PCM file, the file size, file path, and file format of the PCM file are formed into a first file object, which is also saved in a temporary list; a temporary list is created to store PCM files or PCM files, so as to facilitate centralized management of audio data; the PCM files in the temporary list are stored in a The file names are sorted, the PCM files in the temporary list are parsed in a loop, and the file size and file items of each PCM file are determined, thereby ensuring the orderliness of the audio data during the processing, which is conducive to reducing errors and duplications and improving the overall processing efficiency; the start address and the end address of the PCM file are determined according to the data size of the current global file list and the file size of the PCM file, and each file item is saved in the global file list; the storage and management of audio data are simplified, the file items in the global file list are packaged to obtain a bin file, and the audio file is automatically imported to generate a bin file, thereby realizing fully automated processing, greatly reducing the user's operating burden and improving processing efficiency.

[0124] An embodiment of the present disclosure further provides an electronic device, including: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the above method.

[0125] Figure 6 The structure diagram of the computer system suitable for implementing the electronic device of the embodiment of the present application is shown. It should be noted that: Figure 6 The computer system 600 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0126] like Figure 6As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage part 608 to the random access memory (RAM) 603, such as executing the method in the above embodiment. In the RAM 603, various programs and data required for system operation are also stored. The CPU 601, ROM 602 and RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0127] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed so that a computer program read therefrom is installed into the storage section 608 as needed.

[0128] The electronic device disclosed in this embodiment includes a processor, a memory, a transceiver and a communication interface. The memory and the communication interface are connected to the processor and the transceiver and complete communication with each other. The memory is used to store computer programs, the communication interface is used to communicate, and the processor and the transceiver are used to run the computer program so that the electronic device executes each step of the above method.

[0129] The above description and accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent possible changes only. Unless explicitly required, separate components and functions are optional, and the order of operation may vary. Parts and subsamples of some embodiments may be included in or replace parts and subsamples of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and claims, unless the context clearly indicates, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" used in this application refers to any and all possible combinations listed in association with one or more. In addition, when used in the present application, the term "comprise" and its variants "comprises" and / or comprising refer to the presence of a stated sub-sample, whole, step, operation, element, and / or component, but do not exclude the presence or addition of one or more other sub-samples, wholes, steps, operations, elements, components and / or groups of these. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the presence of other identical elements in the process, method or device comprising the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the various embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.

[0130] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. Technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. Technicians can clearly understand that for the convenience and simplicity of description, the specific working process of the systems, devices and units described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0131] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units can be only a logical function division, and there can be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some sub-samples can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units can be selected according to actual needs to implement this embodiment. In addition, each functional unit in the embodiment of the present disclosure can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit.

[0132] The flowchart and block diagram in the accompanying drawings show the possible architecture, functions and operations of the system, method and computer program product according to the embodiment of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. In the description corresponding to the flowchart and block diagram in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in a different order from the order disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or actions, or may be implemented by a combination of dedicated hardware and computer instructions.

Claims

1. A method for packaging audio files, characterized in that: include: Obtain an imported audio file and determine the file format of the audio file; If the file format of the audio file is a WAV file, the WAV file is parsed into a PCM file, and the PCM file is converted into monaural data in a big-endian format and saved in a temporary list; If the file format of the audio file is a PCM file, the file size, file path, and file format of the PCM file are formed into a first file object, which is also stored in a temporary list; Sort the PCM files in the temporary list by file name, cyclically parse the PCM files in the temporary list, and determine the file size and file items of each PCM file; Determine the start address and the end address of the PCM file according to the data size of the current global file list and the file size of the PCM file, and save each of the file items in the global file list; The file items in the global file list are packaged to obtain a bin file.

2. The method according to claim 1, characterized in that Also includes: If the file format of the audio file is a project file, the version number, bin file path and file list of the current interface are cleared, and the version number, bin file path and file list of the project file are imported and displayed.

3. The method according to claim 2, characterized in that Also includes: If all files in the temporary list are parsed and the project file is not identified, the files in the temporary list are sorted according to the file name, the bin file path where each file is stored is determined, and saved to the global file list.

4. The method according to claim 3, characterized in that After saving to the global file list, it also includes: if it is monitored that the global file list has changed, the global file list is traversed, and the hexadecimal value is displayed in a preset interface according to the file name, the location of the file in the flash, and the file size, and the display order of each PCM file is adjusted through the up, down and delete operations set in the preset interface.

5. The method according to claim 4, characterized in that Adjust the display order of each PCM file, after updating the global file list, including: If the version number is not empty, a default version number is generated according to a preset format; If the bin file address is also empty, select a folder to store the bin file and the .h file, wherein the file name of the bin file is the version number corresponding to the default value; According to the size and starting address of each PCM file stored in the global file list, the PCM files are merged into a large buffer; Calculate the data length and MD5 value of the large buffer to obtain a file header; The file header is written into the storage path or version number corresponding to the folder.

6. The method according to claim 5, characterized in that After writing the file header into the storage path or version number corresponding to the folder, the method further includes: Traverse the bin files stored in the specified path and generate a .h file with a version number; Convert the file name of the .h file to uppercase format, and calculate the playback time of each .h file according to the preset sampling rate and the preset sampling depth; The playback start address and file length are determined according to a preset playback code format and the playback duration of the .h file, wherein the playback code format includes a sound source serial number, a playback flag, a file start address in the flash, a file length, a file data pointer, and a number of repetitions.

7. The method according to any one of claims 1 to 6, characterized in that: Parse the WAV file into a PCM file, and convert the PCM file into mono data in big-endian format and save it in a temporary list, including: Verifying the sampling rate and sampling format of the first preset position in the WAV file, and after passing the verification, extracting the mono data of the second preset position in the WAV file and determining it as the original data body; Creating a buffer for caching the original data body; The original data body is traversed, data is exchanged at a third preset position in the original data body, and the data is jumped to a fourth preset position to process the next frame of data in the original data body, and the buffer is determined to be in a big-endian format, and the buffer, file path, file format and size of the buffer are formed into a second file object, which is saved in a temporary list.

8. The method according to any one of claims 1 to 6, characterized in that: The file items in the global file list are packaged to obtain a bin file, including: generating a variable definition field in a code through a PCM file name of each file item, saving the PCM file to the variable definition field under a corresponding storage directory in the global file list, and packaging the variable definition field to obtain a bin file.

9. The method according to any one of claims 1 to 6, characterized in that: After the file items in the global file list are packaged to obtain a bin file, the method further includes: storing the PCM file and the WAV file as binary bin files in a project file; when the project file is imported, the PCM file and the WAV file parsed from the project file are stored in a PCM folder under the same directory as the project file to form a new file path and save it in the global file list.

10. An audio file packaging system, characterized in that: include: An acquisition module, used to acquire an imported audio file and determine the file format of the audio file; The first processing module is used for parsing the WAV file into a PCM file if the file format of the audio file is a WAV file, and converting the PCM file into mono data in a big-endian format and storing it in a temporary list; A second processing module is used for, if the file format of the audio file is a PCM file, converting the file size, file path and file format of the PCM file into a first file object, and also saving it in a temporary list; A parsing module, used for sorting the PCM files in the temporary list by file name, cyclically parsing the PCM files in the temporary list, and determining the file size and file items of each PCM file; A storage module, used for determining the start address and the end address of the PCM file according to the data size of the current global file list and the file size of the PCM file, and saving each file item in the global file list; The packaging module is used to package the file items in the global file list to obtain a bin file.

11. An electronic device, characterized in that: include: Processor and memory; The memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Audio data decoding method, device and audio player

    CN102385864A

  • Android WeChat based silk_v3 voice file format decoding method

    CN105808651A

  • Audio file data processing method and device

    CN111078930A

  • Method and device for processing source file based on OTA upgrade

    CN117177234A

  • PCM data dynamic analysis method and device based on ALSA framework

    CN117725120A