Realize the method for audio mixing in a kind of audio frequency apparatus
[technical field]
The invention belongs to field of audio devices, be meant the method that realizes audio mixing in a kind of audio frequency apparatus especially.
[background technology]
Connecing key sound in the multimedia equipment is its indispensable function, but because system does not possess sound mixing function, so can send keypad tone again when can't realize listening to the music.For example, when listening the MP3 music, can't hear keypad tone this moment.
[summary of the invention]
Technical matters to be solved by this invention is to provide the method that realizes audio mixing in a kind of audio frequency apparatus, has realized the software sound mixing function in multitask system, can hear multiple sound simultaneously.
The present invention solves the problems of the technologies described above by the following technical solutions:
Realize the method for audio mixing in a kind of audio frequency apparatus, comprise the steps:
Step 100: decoding audio data comprises the steps:
Step 101: beginning;
Does step 102: the demoder initialization judge whether success? be to change step 103 over to; , do not change step 111 over to;
Step 103: apply for a FIFO, judge whether success? be to change step 104 over to; , do not change step 111 over to;
Step 104: suspend and play? be to change step 106 over to; , do not change step 105 over to;
Is step 105:FIFO full? be to change step 106 over to; , do not change step 107 over to;
Step 106:OSTIMEDELAY changes step 109 over to;
Step 107: decode, and data are deposited among the FIFO;
Step 108: judge whether decoding successful? be to change step 109 over to; , do not change step 111 over to;
Step 109: judge whether to finish decoding: be to change step 110 over to; , do not change step 104 over to;
Step 110; Anti-initializing decoder discharges the FIFO space;
Step 111: end task;
Step 200: with a plurality of decoded data mixing together, comprise the steps:
Step 201: beginning;
Step 202: apply for a FIFO_A, success? be to change step 203 over to; , do not change step 211 over to;
Step 203: the BUF_A of an X length of application, success? be to change step 204 over to; , do not change step 211 over to;
Step 204: registration DMA interrupt function, and start DMA;
Is not step 205: the FIFO of all audio task empty? be to change step 206 over to; , do not change step 207 over to;
Is step 206:FIFO_A full? be to change step 207 over to; , do not change step 208 over to;
Step 207:OSTIMEDELAY changes step 205 over to;
Step 208: from the FIFO of all audio frequency, take out the data computing that superposes, and deposit among the FIFO_A;
Step 209: judge whether to stop audio mixing? be to change step 210 over to; , do not change step 205 over to;
Step 210: stop DMA, discharge FIFO_A and BUF_A space;
Step 211: end task;
Step 300: by DMA blended data is passed to the IIS controller, comprise the steps:
Step 301: beginning;
Is not step 302: the space that judges whether the FIFO_A that sent released? be to change step 303 over to; , do not change step 304 over to;
Step 303: discharge the space that FIFO_A has been removed data;
Step 304: judge whether the FIFO_A non-NULL? be to change step 305 over to; , do not change step 306 over to;
Step 305: judge that space that FIFO_A used is greater than the X value? be to change step 307 over to; , do not change step 309 over to;
Step 306: BUF_A is filled out 0; Change step 308 over to:
Step 307: the data of reading X length from FIFO_A are to BUF_A, and sign FIFO_A has X length space not to be released;
Step 308: configuration also starts DMA, and the data of the X length of BUF_A are passed to the IIS controller; Change step 310 over to;
Step 309: the length data of reading the space Y of having used from FIFO_A is to BUF_A, and sign FIFO_A has Y length space not to be released, and configuration also starts DMA, and the data of the Y length of BUF_A are passed to the IIS controller;
Step 310: End of Interrupt withdraws from.
The advantage that realizes the method for audio mixing in a kind of audio frequency apparatus of the present invention is: by a plurality of voice datas of decoding, with a plurality of decoded data mixing together, pass to the IIS controller by DMA then, realized audio mixing.Can when listening to the music, send keypad tone.
[description of drawings]
The invention will be further described in conjunction with the embodiments with reference to the accompanying drawings.
Fig. 1 is a workflow synoptic diagram of the present invention.
Fig. 2 is a decoding audio data workflow synoptic diagram among the present invention.
Fig. 3 is an audio mixing task workflow synoptic diagram among the present invention.
Fig. 4 passes to IIS controller workflow synoptic diagram by DMA with blended data among the present invention.
[embodiment]
Realizing the method for audio mixing in a kind of audio frequency apparatus, mainly is the direction of control data stream, and as shown in Figure 1, it comprises the steps: step 100: decoding audio data; Step 200: together with a plurality of decoded data mixing; Step 300: blended data is passed to the IIS controller by DMA.
Seeing also shown in Figure 2ly, is decoding audio data workflow synoptic diagram among the present invention.Comprise the steps:
Step 101: beginning;
Does step 102: the demoder initialization judge whether success? be to change step 103 over to; , do not change step 111 over to;
Step 103: apply for a FIFO, judge whether success? be to change step 104 over to; , do not change step 111 over to;
Step 104: suspend and play? be to change step 106 over to; , do not change step 105 over to;
Is step 105:FIFO full? be to change step 106 over to; , do not change step 107 over to;
Step 106:OSTIMEDELAY changes step 109 over to;
Step 107: decode, and data are deposited among the FIFO;
Step 108: judge whether decoding successful? be to change step 109 over to; , do not change step 111 over to;
Step 109: judge whether to finish decoding: be to change step 110 over to; , do not change step 104 over to;
Step 110; Anti-initializing decoder discharges the FIFO space;
Step 111: end task.
Seeing also shown in Figure 3ly, is audio mixing task workflow synoptic diagram among the present invention, is about to a plurality of decoded data mixing together.Comprise the steps:
Step 201: beginning;
Step 202: apply for a FIFO_A, success? be to change step 203 over to; , do not change step 211 over to;
Step 203: the BUF_A of an X length of application, success? be to change step 204 over to; , do not change step 211 over to;
Step 204: registration DMA interrupt function, and start DMA;
Is not step 205: the FIFO of all audio task empty? be to change step 206 over to; , do not change step 207 over to;
Is step 206:FIFO_A full? be to change step 207 over to; , do not change step 208 over to;
Step 207:OSTIMEDELAY changes step 205 over to;
Step 208: from the FIFO of all audio frequency, take out the data computing that superposes, and deposit among the FIFO_A;
Step 209: judge whether to stop audio mixing? be to change step 210 over to; , do not change step 205 over to;
Step 210: stop DMA, discharge FIFO_A and BUF_A space;
Step 211: end task.
Seeing also shown in Figure 4ly, is by DMA blended data to be passed to IIS controller workflow synoptic diagram among the present invention.Comprise the steps:
Step 301: beginning;
Is not step 302: the space that judges whether the FIFO_A that sent released? be to change step 303 over to; , do not change step 304 over to;
Step 303: discharge the space that FIFO_A has been removed data;
Step 304: judge whether the FIFO_A non-NULL? be to change step 305 over to; , do not change step 306 over to;
Step 305: judge that space that FIFO_A used is greater than the X value? be to change step 307 over to; , do not change step 309 over to;
Step 306: BUF_A is filled out 0; Change step 308 over to:
Step 307: the data of reading X length from FIFO_A are to BUF_A, and sign FIFO_A has X length space not to be released;
Step 308: configuration also starts DMA, and the data of the X length of BUF_A are passed to the IIS controller; Change step 310 over to;
Step 309: the length data of reading the space Y of having used from FIFO_A is to BUF_A, and sign FIFO_A has Y length space not to be released, and configuration also starts DMA, and the data of the Y length of BUF_A are passed to the IIS controller;
Step 310: End of Interrupt withdraws from.
The present invention has realized the software sound mixing function in multitask system, can hear multiple sound simultaneously, when listening to the music, can send keypad tone.