CN108269596B - Method and system for acquiring audio data - Google Patents
Method and system for acquiring audio data Download PDFInfo
- Publication number
- CN108269596B CN108269596B CN201611259886.7A CN201611259886A CN108269596B CN 108269596 B CN108269596 B CN 108269596B CN 201611259886 A CN201611259886 A CN 201611259886A CN 108269596 B CN108269596 B CN 108269596B
- Authority
- CN
- China
- Prior art keywords
- audio data
- storage array
- data storage
- decoded
- audio
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G11—INFORMATION STORAGE
- G11B—INFORMATION STORAGE BASED ON RELATIVE MOVEMENT BETWEEN RECORD CARRIER AND TRANSDUCER
- G11B20/00—Signal processing not specific to the method of recording or reproducing; Circuits therefor
- G11B20/10—Digital recording or reproducing
- G11B20/10009—Improvement or modification of read or write signals
- G11B20/10018—Improvement or modification of read or write signals analog processing for digital recording or reproduction
Abstract
The invention relates to a method and a system for acquiring audio data, wherein the method comprises the following steps: constructing an audio data storage structure, generating an audio data storage array after initialization, and creating a data extraction thread; when the audio data to be decoded reaches a preset length, giving a unique ID value to the decoded audio data, and storing the unique ID value into an audio data storage array; and performing data extraction thread processing on the audio data storage array and the decoded audio data through the data extraction thread to obtain the audio data. The system comprises: the device comprises a processing module, a storage module and an acquisition module. The invention can neglect the influence on the decoder during the process of obtaining the audio data, and saves the latest data, thereby avoiding the overlarge memory occupation; meanwhile, the extraction of the audio data without locking is realized, and only the latest audio PCM data is reserved, so that the method has the characteristics of less occupied memory and high efficiency.
Description
Technical Field
The invention relates to the technical field of data structure technology and audio processing, in particular to a method and a system for acquiring audio data.
Background
At present, the generation of audio frequency spectrogram needs to capture PCM (pulse code modulation) data generated by an audio decoder, and the extraction method generally adopts the mode of transmitting through a message queue, a shared memory and the like, or locking in a decoding thread, so as to solve the problems of data producer and consumer.
The existing application methods in the fields of data structure technology and audio processing technology require a decoding thread to do a large amount of operations, which affect the decoding speed and cause abnormal playing, and in view of users, the existing spectrogram only extracts part of data at regular time to process, and the excessive data is only wasted in performance.
The data of the function is derived from the extraction of audio PCM data, the PCM data is generated by a decoder thread and distributes data to an application layer, the decoder thread is one of threads with the highest priority of a music player, therefore, the extraction of the data in the decoder thread should avoid using a system kernel-level synchronization tool such as a synchronization lock, the related operations should not affect the normal work of the decoding thread as much as possible, and the drawing of the spectrogram is only required to extract part of the audio data at regular time, and the data is not required to be stored in a memory.
Disclosure of Invention
The invention aims to solve the problems that in the prior art, the use of system kernel-level synchronization tools such as a synchronization lock and the like is avoided when data is extracted, and the normal work of a decoding thread is not influenced as much as possible by related operations; the spectrogram can be drawn by extracting part of audio data at regular time, so that the problem that multiple data are not stored in a memory is solved.
To achieve the above object, in one aspect, the present invention provides a method of acquiring audio data, the method comprising the steps of: constructing an audio data storage structure, generating an audio data storage array after initialization, and creating a data extraction thread; when the audio data to be decoded reaches a preset length, giving a unique ID value to the decoded audio data, and storing the unique ID value into an audio data storage array; and performing data extraction thread processing on the audio data storage array and the decoded audio data through the data extraction thread to obtain the audio data.
Preferably, the size of the audio data storage array is 10.
Preferably, when the audio data to be decoded reaches a preset value length, a unique ID value is given to the decoded audio data, and the step of storing the ID value in the audio data storage array includes: and when the stored decoded audio data reach the preset value length, giving a unique ID value to the decoded audio data, and if the audio data storage array is fully loaded for the first time, updating and storing the decoded audio data from the first array in the audio data storage array until the audio data storage array is fully loaded for the second time.
The calculation formula of the preset length is as follows: the preset length is the number of sampling points and the depth of audio bits and the number of audio channels.
The step of performing data extraction thread processing on the audio data storage array and the decoded audio data by the data extraction thread comprises the following steps: and extracting the decoded audio data from the audio data storage array according to preset time, and reading the decoded audio data according to the time sequence.
In another aspect, the present invention provides a system for acquiring audio data, the system comprising: the device comprises a processing module, a storage module and an acquisition module.
And the processing module is used for constructing an audio data storage structure, generating an audio data storage array after initialization, and creating a data extraction thread.
And the storage module is used for giving a unique ID value to the decoded audio data when the audio data to be decoded reaches a preset length and storing the unique ID value into the audio data storage array.
And the acquisition module is used for performing data extraction thread processing on the audio data storage array and the decoded audio data through the data extraction thread to obtain the audio data.
Preferably, the size of the audio data storage array in the processing module is 10.
Preferably, the storage module is specifically configured to give a unique ID value to the decoded audio data when the stored decoded audio data reaches a preset value length, and if the audio data storage array is fully loaded for the first time, update the stored decoded audio data from the first array in the audio data storage array until the audio data storage array is fully loaded for the second time.
The storage module is specifically configured to calculate the preset length according to the following formula: the preset length is the number of sampling points and the depth of audio bits and the number of audio channels.
In addition, the extracting thread processing in the obtaining module comprises: and extracting the decoded audio data from the audio data storage array according to preset time, and reading the decoded audio data according to the time sequence.
According to the method and the system for acquiring the audio data, the influence on the work of the decoder can be ignored, the latest data is stored, and the overlarge memory occupation is avoided; meanwhile, the extraction of the audio data without locking is realized, and only the latest audio PCM data is reserved, so that the method has the characteristics of less occupied memory and high efficiency.
Drawings
Fig. 1 is a flowchart of a method for acquiring audio data according to an embodiment of the present invention;
FIG. 2 is a flowchart of an audio data storage method according to an embodiment of the present invention;
fig. 3 is a flowchart of an audio data extraction method according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an audio data acquisition system according to an embodiment of the present invention.
Detailed Description
The technical solution of the present invention is further described in detail by the accompanying drawings and embodiments.
Fig. 1 is a flowchart of a method for acquiring audio data according to an embodiment of the present invention. As shown in fig. 1, the method comprises the steps of:
step S101: and constructing an audio data storage structure, generating an audio data storage array after initialization, and creating a data extraction thread.
Preferably, the size of the audio data storage array is 10.
For example, an audio data storage structure is defined, an audio data storage array of fixed size (preferably 10) is initially generated, and a data extraction thread is created.
Step S102: and when the audio data to be decoded reaches the preset length, giving a unique ID value to the decoded audio data, and storing the unique ID value into an audio data storage array.
Specifically, when the audio data to be decoded reaches a preset value length, a unique ID value is given to the decoded audio data, and the unique ID value is stored in the audio data storage array, where the step includes: and when the stored decoded audio data reach the preset value length, giving a unique ID value to the decoded audio data, and if the audio data storage array is fully loaded for the first time, updating and storing the decoded audio data from the first array in the audio data storage array until the audio data storage array is fully loaded for the second time.
The calculation formula of the preset length is as follows: the preset length is the number of sampling points and the depth of audio bits and the number of audio channels.
For example, when the audio data to be decoded in the stored data reaches a preset length (where the preset length is the number of sampling points, the depth of audio bits, and the number of audio channels), a unique ID value is assigned, and the audio data is stored in the audio data storage array in sequence, and because the storage capacity of the audio data storage array is a fixed size 10, if the position of the audio data storage array 10 is filled up, the ID value of the data to be stored again covers the ID value of the position of the original audio data storage array 0 and is stored in the position of the audio data storage array 0, that is, the data is written in a loop, so that the latest data stored in the audio data storage array is ensured.
And performing data extraction thread processing on the audio data storage array and the decoded audio data through the data extraction thread to obtain the audio data.
Specifically, the step of performing data extraction thread processing on the audio data storage array and the decoded audio data by the data extraction thread includes: and extracting the decoded audio data from the audio data storage array according to preset time, and reading the decoded audio data according to a time sequence.
For example, a timer times (a specified duration, e.g., 100 milliseconds, depending on the performance of the device) the data to be fetched from the array, read in sequence, and if the end of the array is read, read from the head of the array again, i.e., read in a loop.
The above operations are performed in an atomic operation index manner without using any system kernel group thread synchronization tool. And judging whether the data is stored or not during the extraction operation, if so, performing corresponding delay, judging whether the data is extracted or not during the storage, and if so, throwing away the data.
Fig. 2 is a flowchart of an audio data storage method according to an embodiment of the present invention. As shown in figure 2 of the drawings, in which,
step S201: and acquiring data, preparing to store, and giving a unique ID value when the audio data to be decoded in the stored data reaches a preset length (wherein the preset length is the number of sampling points and the depth of audio bits and the number of audio channels), and storing the unique ID value in the audio data storage array in sequence.
Step S202: judging the state of the non-read data, and if the state is met, not storing the data; if the condition is satisfied, step S203 is executed.
Step S203: and judging the state of the array, and if the array is not fully written, storing the index into the corresponding empty item.
For example, the storage capacity of the audio data storage array is a fixed size 10, and if the position of the audio data storage array 10 is not filled, the position storage of the audio data storage array 5 is directly indexed.
If the array is full, the index is incremented by 1 and saved to the corresponding entry, i.e. circular writing.
For example, if the position of the audio data storage array 10 is filled, the ID value of the data to be stored again is written in a loop, which is to say, the ID value of the original position of the audio data storage array 0 is overwritten and stored in the position of the audio data storage array 0, so that the latest data is stored in the audio data storage array.
Fig. 3 is a flowchart of an audio data extraction method according to an embodiment of the present invention. As shown in figure 3 of the drawings,
step S301: the timer is used for timing the reading of data.
Step S302: and judging whether the state is a data writing state or not, and if not, adjusting the timer according to the performance specified duration of the equipment.
If the data is not written, step S303 is executed.
For example, a timer times (a specified duration, e.g., 100 milliseconds, depending on the capabilities of the device) the data to be extracted from the array and read in sequence.
Step S303: and judging whether the end of the audio data storage array is read or not, and if not, reading the item corresponding to the index value.
If the end of the audio data storage array is read, adding 1 to the index and reading the corresponding item.
For example, reading the end of the array, and then reading from the head of the array, namely, circularly reading.
Fig. 4 is a schematic structural diagram of an audio data acquisition system according to an embodiment of the present invention. As shown in fig. 4, the system includes: a processing module 401, a storage module 402 and an acquisition module 403.
The processing module 401 is configured to construct an audio data storage structure, generate an audio data storage array after initialization, and create a data extraction thread.
Preferably, the size of the audio data storage array in the processing module 401 is 10.
The storage module 402 is configured to give a unique ID value to the decoded audio data when the audio data to be decoded reaches a preset length, and store the unique ID value in the audio data storage array.
Specifically, the storage module 402 is specifically configured to assign a unique ID value to the decoded audio data when the stored decoded audio data reaches a preset value length, and if the audio data storage array is fully loaded for the first time, update and store the decoded audio data from the first array in the audio data storage array until the audio data storage array is fully loaded for the second time.
Specifically, the storage module 402 is specifically configured to calculate the preset length according to the following formula: the preset length is the number of sampling points and the depth of audio bits and the number of audio channels.
The obtaining module 403 is configured to perform data extraction thread processing on the audio data storage array and the decoded audio data through the data extraction thread, so as to obtain the audio data.
Specifically, the extracting thread processing in the obtaining module 403 includes: and extracting the decoded audio data from the audio data storage array according to preset time, and reading the decoded audio data according to the time sequence.
According to the method and the system for acquiring the audio data, the influence on the work of the decoder can be ignored, the latest data is stored, and the overlarge memory occupation is avoided; meanwhile, the extraction of the audio data without locking is realized, and only the latest audio PCM data is reserved, so that the method has the characteristics of less occupied memory and high efficiency.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are merely exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.
Claims (10)
1. A method of acquiring audio data, comprising the steps of:
constructing an audio data storage structure, generating an audio data storage array after initialization, and creating a data extraction thread;
when the audio data to be decoded reaches a preset length, giving a unique ID value to the audio data to be decoded, and storing the unique ID value into the audio data storage array;
and performing data extraction thread processing on the audio data storage array through the data extraction thread to obtain audio data.
2. The method of claim 1, wherein the size of the audio data storage array is 10.
3. The method of claim 1, wherein the step of assigning a unique ID value to the audio data to be decoded when the audio data to be decoded reaches a preset value length and storing the ID value in the audio data storage array comprises:
and when the stored audio data to be decoded reaches a preset value length, giving a unique ID value to the audio data to be decoded, and if the audio data storage array is fully loaded for the first time, updating and storing the audio data to be decoded from the first array in the audio data storage array until the audio data storage array is fully loaded for the second time.
4. A method according to claim 1 or 3, wherein the preset length is calculated as follows: the preset length is the number of sampling points and the depth of audio bits and the number of audio channels.
5. The method of claim 1, wherein the step of performing data fetch thread processing on the audio data storage array by the data fetch thread comprises: and extracting the audio data to be decoded from the audio data storage array according to preset time, and reading the audio data according to a time sequence.
6. A system for acquiring audio data, comprising:
the processing module is used for constructing an audio data storage structure, generating an audio data storage array after initialization and creating a data extraction thread;
the storage module is used for giving a unique ID value to the audio data to be decoded when the audio data to be decoded reaches a preset length and storing the unique ID value into the audio data storage array;
and the acquisition module is used for performing data extraction thread processing on the audio data storage array through the data extraction thread to acquire audio data.
7. The system of claim 6, wherein the processing module is further configured to size the audio data storage array to 10.
8. The system according to claim 6, wherein the storage module is specifically configured to, when the stored audio data to be decoded reaches a preset length, assign a unique ID value to the audio data to be decoded, and if the audio data storage array is fully loaded for the first time, update and store the audio data to be decoded from the first array in the audio data storage array until the audio data storage array is fully loaded for the second time.
9. The system according to claim 6 or 8, wherein the storage module is specifically configured to calculate the preset length according to the following formula: the preset length is the number of sampling points and the depth of audio bits and the number of audio channels.
10. The system of claim 6, wherein the obtaining module is specifically configured to, the fetch thread processing comprises: and extracting the audio data to be decoded from the audio data storage array according to preset time, and reading the audio data according to a time sequence.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611259886.7A CN108269596B (en) | 2016-12-30 | 2016-12-30 | Method and system for acquiring audio data |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611259886.7A CN108269596B (en) | 2016-12-30 | 2016-12-30 | Method and system for acquiring audio data |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108269596A CN108269596A (en) | 2018-07-10 |
CN108269596B true CN108269596B (en) | 2020-03-31 |
Family
ID=62753692
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611259886.7A Active CN108269596B (en) | 2016-12-30 | 2016-12-30 | Method and system for acquiring audio data |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108269596B (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101404741A (en) * | 2008-11-06 | 2009-04-08 | 北京创毅视讯科技有限公司 | Audio playing apparatus and method, and digital television chip |
CN103065641A (en) * | 2013-02-01 | 2013-04-24 | 飞天诚信科技股份有限公司 | Method for analyzing audio data |
CN106057220A (en) * | 2016-05-19 | 2016-10-26 | Tcl集团股份有限公司 | Audio signal high frequency expansion method and audio frequency player |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030131350A1 (en) * | 2002-01-08 | 2003-07-10 | Peiffer John C. | Method and apparatus for identifying a digital audio signal |
-
2016
- 2016-12-30 CN CN201611259886.7A patent/CN108269596B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101404741A (en) * | 2008-11-06 | 2009-04-08 | 北京创毅视讯科技有限公司 | Audio playing apparatus and method, and digital television chip |
CN103065641A (en) * | 2013-02-01 | 2013-04-24 | 飞天诚信科技股份有限公司 | Method for analyzing audio data |
CN106057220A (en) * | 2016-05-19 | 2016-10-26 | Tcl集团股份有限公司 | Audio signal high frequency expansion method and audio frequency player |
Also Published As
Publication number | Publication date |
---|---|
CN108269596A (en) | 2018-07-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104731569B (en) | A kind of data processing method and relevant device | |
CN110442462B (en) | Multithreading data transmission method and device in TEE system | |
CN102652313B (en) | Flash memory controller and operation method | |
CN108804545A (en) | Distributed globally unique ID generation methods and equipment | |
US9502104B2 (en) | Multi-level cell (MLC) non-volatile memory data reading method and apparatus | |
CN108172249B (en) | NAND Flash access operation method, device and system | |
TW201022935A (en) | Control system for accessing memory and method of the same | |
CN109582598B (en) | Preprocessing method for realizing efficient hash table searching based on external storage | |
CN104572781A (en) | Method and device for generating transaction log | |
TW201346732A (en) | Indicating a length of an instruction of a variable length instruction set | |
CN108664577B (en) | File management method and system based on FLASH idle area | |
CN108269596B (en) | Method and system for acquiring audio data | |
CN103093805A (en) | Address decoding method and semiconductor memory device using the same | |
CN103544076A (en) | Data backup method and device | |
CN102629235A (en) | Method for increasing read-write speed of double data rate (DDR) memory | |
CN112104403B (en) | Multi-line Cheng Yaogan satellite baseband data processing method and device based on message queue | |
CN103532569A (en) | Decoding device and analytic data decoding method | |
JP2008269488A (en) | Rollback method and information processor | |
CN104935975A (en) | Short video record playing method and apparatus | |
WO2018026452A1 (en) | System and method for distributing and replaying trigger packets via a variable latency bus interconnect | |
EP3144934B1 (en) | Audio play method and device | |
CN110908429B (en) | Timer operation method and device | |
CN107239343B (en) | Data processing method and device | |
EP2469858A2 (en) | Apparatus and method for sequentially parsing bitstreams based on removal of emulation prevention byte | |
US9141566B2 (en) | Method of accessing on-chip read only memory and computer system thereof |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |