comparison src/cs/layer1/audio_cfile/l1audio_back.c @ 234:b870b6a44d31

l1audio and l1tm reconstructed source imported from tcs211-l1-reconst
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 20 Mar 2017 00:51:20 +0000
parents
children
comparison
equal deleted inserted replaced
233:17d79c62e638 234:b870b6a44d31
1 /************* Revision Controle System Header *************
2 * GSM Layer 1 software
3 * L1AUDIO_SRBACK.C
4 *
5 * Filename l1audio_back.c
6 * Copyright 2003 (C) Texas Instruments
7 *
8 ************* Revision Controle System Header *************/
9
10 /************************************/
11 /* Include files... */
12 /************************************/
13
14 #define L1_SRBACK_COM // switch to define the l1_srback_com variable
15 #define L1_AUDIOBACK_MELODYE2 // switch to define the audio background variable
16
17 #include "l1_macro.h"
18 #include "l1_confg.h"
19
20 #if (AUDIO_TASK == 1) && (L1_AUDIO_BACKGROUND_TASK)
21
22 #include "l1_types.h"
23 #include "sys_types.h"
24
25 #if (CODE_VERSION == SIMULATION) && (AUDIO_SIMULATION)
26
27
28 #include <stdlib.h>
29 #include <string.h>
30
31 #include "iq.h" // Debug / Init hardware ("eva3.lib")
32 #include "l1_ver.h"
33 #include "l1_const.h"
34 #include "l1_signa.h"
35
36 #if TESTMODE
37 #include "l1tm_defty.h"
38 #endif
39
40 #include "l1audio_const.h"
41 #include "l1audio_cust.h"
42 #include "l1audio_signa.h"
43 #include "l1audio_defty.h"
44 #include "l1audio_msgty.h"
45 #include "l1audio_varex.h"
46
47 #if (L1_GTT == 1)
48 #include "l1gtt_const.h"
49 #include "l1gtt_defty.h"
50 #endif
51 //added form e-sample for AAC
52 #if (L1_DYN_DSP_DWNLD == 1)
53 #include "l1_dyn_dwl_const.h"
54 #include "l1_dyn_dwl_defty.h"
55 #endif
56 #if (L1_MP3 == 1)
57 #include "l1mp3_defty.h"
58 #endif
59
60 #if (L1_MIDI == 1)
61 #include "l1midi_defty.h"
62 #endif
63 //added form e-sample for AAC
64 #if (L1_AAC == 1)
65 #include "l1aac_defty.h"
66 #endif
67
68 #include "l1_defty.h"
69 #include "cust_os.h"
70 #include "l1_msgty.h"
71 #include "l1_varex.h"
72
73 #include "l1_mftab.h"
74 #include "l1_tabs.h"
75 #include "l1_ctl.h"
76
77
78 #include "l1_time.h"
79 #include "l1_scen.h"
80
81 #else
82 // Layer1 and debug include files.
83
84 #include <ctype.h>
85 #include <math.h>
86 #include "l1_ver.h"
87 #include "l1_const.h"
88 #include "l1_signa.h"
89
90 #if TESTMODE
91 #include "l1tm_defty.h"
92 #endif
93
94 #include "l1audio_const.h"
95 #include "l1audio_cust.h"
96 #include "l1audio_signa.h"
97 #include "l1audio_defty.h"
98 #include "l1audio_msgty.h"
99 #include "l1audio_varex.h"
100
101 #if (L1_GTT == 1)
102 #include "l1gtt_const.h"
103 #include "l1gtt_defty.h"
104 #endif
105 //added form e-sample for AAC
106 #if (L1_DYN_DSP_DWNLD == 1)
107 #include "l1_dyn_dwl_const.h"
108 #include "l1_dyn_dwl_defty.h"
109 #endif
110 #if (L1_MP3 == 1)
111 #include "l1mp3_defty.h"
112 #endif
113
114 #if (L1_MIDI == 1)
115 #include "l1midi_defty.h"
116 #endif
117 //added form e-sample for AAC
118 #if (L1_AAC == 1)
119 #include "l1aac_defty.h"
120 #endif
121
122 #include "l1_defty.h"
123 #include "cust_os.h"
124 #include "l1_msgty.h"
125 #include "tpudrv.h" // TPU drivers. ("eva3.lib")
126 #include "l1_varex.h"
127
128 #include "l1_proto.h"
129 #include "l1_mftab.h"
130 #include "l1_tabs.h"
131 #include "mem.h"
132 #include "armio.h"
133 #include "timer.h"
134 #include "timer1.h"
135 #include "dma.h"
136 #include "inth.h"
137 #include "ulpd.h"
138 #include "rhea_arm.h"
139 #include "clkm.h" // Clockm ("eva3.lib")
140 #include "l1_ctl.h"
141
142 #include "l1_time.h"
143 #if L2_L3_SIMUL
144 #include "l1_scen.h"
145 #endif
146 #endif
147
148 /****************************************/
149 /* Prototypes for audio background task */
150 /****************************************/
151 void l1_audio_background_task (UWORD32 argc, void *argv);
152 #if (SPEECH_RECO)
153 void srback_CTO_algorithm (API *RAM_address);
154 void srback_save_model_temp (API *RAM_address_input, UWORD16 *RAM_address_output);
155 #endif
156 #if (MELODY_E2 && FIR)
157 void audio_background_melody_e2_download_instrument_manager(xSignalHeaderRec *msg);
158 #endif
159 /**************************************/
160 /* External prototypes */
161 /**************************************/
162 #if (SPEECH_RECO)
163 extern void Cust_srback_save_model (UWORD8 database, UWORD8 index, API *RAM_address);
164 extern void Cust_srback_save_speech (UWORD8 database, UWORD8 index, UWORD16 *start_buffer, UWORD16 *stop_buffer, UWORD16 *start_speech, UWORD16 *stop_speech);
165 extern void Cust_srback_load_model (UWORD8 database, UWORD8 index, API *RAM_address);
166 #endif
167 #if (MELODY_E2 && FIR)
168 extern UWORD16 Cust_audio_melody_E2_load_instrument (UWORD8 customer_instrument_id,
169 API *API_address,
170 UWORD16 allowed_size);
171 #endif
172
173 #if (OP_RIV_AUDIO == 0)
174 /*--------------------------------------------------------*/
175 /* l1_audio_background_task() */
176 /*--------------------------------------------------------*/
177 /* */
178 /* Description: */
179 /* ------------ */
180 /* This function is a state machine which handles the */
181 /* audio background feature. */
182 /* */
183 /* Starting messages: L1_SRBACK_SAVE_DATA_REQ */
184 /* L1_SRBACK_TEMP_SAVE_DATA_REQ */
185 /* L1_SRBACK_LOAD_MODEL_REQ */
186 /* L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ */
187 /* L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_REQ */
188 /* */
189 /* Result messages (input): none */
190 /* */
191 /* Result messages (output): L1_SRBACK_SAVE_DATA_CON */
192 /* L1_SRBACK_TEMP_SAVE_DATA_CON */
193 /* L1_SRBACK_LOAD_MODEL_CON */
194 /* L1_BACK_MELODY_E2_LOAD_INSTRUMENT_CON */
195 /* L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_CON */
196 /* */
197 /* Reset messages (input): none */
198 /* */
199 /* Stop message (input): non */
200 /* */
201 /* Stop message (output): L1_SRBACK_SAVE_DATA_CON */
202 /* L1_SRBACK_TEMP_SAVE_DATA_CON */
203 /* L1_SRBACK_LOAD_MODEL_CON */
204 /* L1_BACK_MELODY_E2_LOAD_INSTRUMENT_CON */
205 /* L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_CON */
206 /* */
207 /* Rem: to stop immeditly the speech reco feature a flag */
208 /* ---- is created: l1_srback_com.emergency_stop */
209 /* */
210 /*--------------------------------------------------------*/
211 void l1_audio_background_task(UWORD32 argc, void *argv)
212 {
213 xSignalHeaderRec *receive_msg, *confirm_msg;
214 UWORD8 index;
215
216 while(1)
217 {
218 // Wait until a message is receive
219 receive_msg = os_receive_sig(SRBACK_QUEUE);
220
221 #if (SPEECH_RECO)
222 if (receive_msg->SignalCode == L1_SRBACK_SAVE_DATA_REQ)
223 {
224 if (l1_srback_com.emergency_stop == FALSE)
225 {
226 // Call the customer function to save the model
227 Cust_srback_save_model( ((T_L1_SRBACK_SAVE_DATA_REQ *)(receive_msg->SigP))->database_id,
228 ((T_L1_SRBACK_SAVE_DATA_REQ *)(receive_msg->SigP))->model_index,
229 ((T_L1_SRBACK_SAVE_DATA_REQ *)(receive_msg->SigP))->model_RAM_address );
230 }
231 if ( ((T_L1_SRBACK_SAVE_DATA_REQ *)(receive_msg->SigP))->speech )
232 {
233 if (l1_srback_com.emergency_stop == FALSE)
234 {
235 // Call the customer function to save the speech from a circular buffer to the database
236 Cust_srback_save_speech( ((T_L1_SRBACK_SAVE_DATA_REQ *)(receive_msg->SigP))->database_id,
237 ((T_L1_SRBACK_SAVE_DATA_REQ *)(receive_msg->SigP))->model_index,
238 ((T_L1_SRBACK_SAVE_DATA_REQ *)(receive_msg->SigP))->start_buffer,
239 ((T_L1_SRBACK_SAVE_DATA_REQ *)(receive_msg->SigP))->stop_buffer,
240 ((T_L1_SRBACK_SAVE_DATA_REQ *)(receive_msg->SigP))->start_address,
241 ((T_L1_SRBACK_SAVE_DATA_REQ *)(receive_msg->SigP))->stop_address);
242 }
243 }
244
245 // Send the stop confirmation message
246 confirm_msg = os_alloc_sig(0);
247 DEBUGMSG(status,NU_ALLOC_ERR)
248 confirm_msg->SignalCode = L1_SRBACK_SAVE_DATA_CON;
249 os_send_sig(confirm_msg, L1C1_QUEUE);
250 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
251 } // L1_SRBACK_SAVE_DATA_REQ
252 else
253 if (receive_msg->SignalCode == L1_SRBACK_LOAD_MODEL_REQ)
254 {
255 if ( ( ((T_L1_SRBACK_LOAD_MODEL_REQ *)(receive_msg->SigP))->CTO_enable ) == FALSE )
256 {
257 if (l1_srback_com.emergency_stop == FALSE)
258 {
259 // Call the function to load a model
260 Cust_srback_load_model( ((T_L1_SRBACK_LOAD_MODEL_REQ *)(receive_msg->SigP))->database_id,
261 ((T_L1_SRBACK_LOAD_MODEL_REQ *)(receive_msg->SigP))->model_index,
262 ((T_L1_SRBACK_LOAD_MODEL_REQ *)(receive_msg->SigP))->model_RAM_address );
263 }
264 }
265 else
266 {
267 if (l1_srback_com.emergency_stop == FALSE)
268 {
269 // Calculate the good index
270 index = ((T_L1_SRBACK_LOAD_MODEL_REQ *)(receive_msg->SigP))->model_index>>1;
271
272 // Call the function to load a model with the good index
273 Cust_srback_load_model( ((T_L1_SRBACK_LOAD_MODEL_REQ *)(receive_msg->SigP))->database_id,
274 index,
275 ((T_L1_SRBACK_LOAD_MODEL_REQ *)(receive_msg->SigP))->model_RAM_address );
276 }
277
278 // The CTO algorithm is used and the model index is odd
279 if ( ((T_L1_SRBACK_LOAD_MODEL_REQ *)(receive_msg->SigP))->model_index & 0x01 )
280 {
281 if (l1_srback_com.emergency_stop == FALSE)
282 {
283 // Call the function to apply the CTO algorithm to the loaded model
284 srback_CTO_algorithm( ((T_L1_SRBACK_LOAD_MODEL_REQ *)(receive_msg->SigP))->model_RAM_address );
285 }
286 }
287 }
288
289 // Send the stop confirmation message
290 confirm_msg = os_alloc_sig(0);
291 DEBUGMSG(status,NU_ALLOC_ERR)
292 confirm_msg->SignalCode = L1_SRBACK_LOAD_MODEL_CON;
293 os_send_sig(confirm_msg, L1C1_QUEUE);
294 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
295 } // L1_SRBACK_LOAD_MODEL_REQ
296 else
297 if (receive_msg->SignalCode == L1_SRBACK_TEMP_SAVE_DATA_REQ)
298 {
299 if (l1_srback_com.emergency_stop == FALSE)
300 {
301 // Call the function to save the model in a temporary buffer
302 srback_save_model_temp( ((T_L1_SRBACK_TEMP_SAVE_DATA_REQ *)(receive_msg->SigP))->model_RAM_address_input,
303 ((T_L1_SRBACK_TEMP_SAVE_DATA_REQ *)(receive_msg->SigP))->model_RAM_address_output );
304 }
305
306 // Send the stop confirmation message
307 confirm_msg = os_alloc_sig(0);
308 DEBUGMSG(status,NU_ALLOC_ERR)
309 confirm_msg->SignalCode = L1_SRBACK_TEMP_SAVE_DATA_CON;
310 os_send_sig(confirm_msg, L1C1_QUEUE);
311 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
312 } // L1_SRBACK_TEMP_SAVE_DATA_REQ
313 #endif // SPEECH_RECO
314 #if (MELODY_E2 && FIR)
315 if ( (receive_msg->SignalCode == L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ) ||
316 (receive_msg->SignalCode == L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_REQ) )
317 {
318 audio_background_melody_e2_download_instrument_manager(receive_msg);
319 } // L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ
320 #endif // MELODY_E2
321
322 // Deallocate the received message
323 os_free_sig(receive_msg);
324 DEBUGMSG(status,NU_ALLOC_ERR)
325 } // while(1)
326 }
327 #endif // OP_RIV_AUDIO
328
329 #if (SPEECH_RECO)
330 /*-------------------------------------------------------*/
331 /* srback_CTO_algorithm() */
332 /*-------------------------------------------------------*/
333 /* */
334 /* Parameters : RAM_address */
335 /* */
336 /* Return : none */
337 /* */
338 /* Description : apply the CTO algorithm to the model. */
339 /* */
340 /*-------------------------------------------------------*/
341 void srback_CTO_algorithm (API *RAM_address)
342 {
343 UWORD16 model_size, frame;
344 UWORD8 frame_size;
345
346 // This alogrithm changes the model:
347 // |frame 0|frame 1|frame 2|frame 3|frame 4|frame 5|frame 6|frame 7|...
348 // into a garbage model:
349 // |0000000|frame 1|0000000|0000000|frame 4|0000000|0000000|frame 7|...
350
351 // look the size of the model in model frame unit (16 words unit)
352 model_size = *RAM_address++;
353
354 frame = 0;
355
356 while( (frame <= model_size) &&
357 (l1_srback_com.emergency_stop == FALSE) )
358 {
359 if ((frame % 3) == 1)
360 {
361 // This frame is kept
362 RAM_address += SC_SR_MODEL_FRAME_SIZE;
363 }
364 else
365 {
366 // This frame is set to 0
367 frame_size = SC_SR_MODEL_FRAME_SIZE;
368 while ( (frame_size != 0) &&
369 (l1_srback_com.emergency_stop == FALSE) )
370 {
371 *RAM_address++ = 0;
372 frame_size--;
373 }
374 }
375
376 frame++;
377 }
378 }
379
380 /*-------------------------------------------------------*/
381 /* srback_CTO_algorithm() */
382 /*-------------------------------------------------------*/
383 /* */
384 /* Parameters : RAM_address_input */
385 /* RAM_address_output */
386 /* */
387 /* Return : none */
388 /* */
389 /* Description : apply the CTO algorithm to the model. */
390 /* */
391 /*-------------------------------------------------------*/
392 void srback_save_model_temp (API *RAM_address_input, UWORD16 *RAM_address_output)
393 {
394 UWORD16 model_size;
395 UWORD8 frame_size;
396
397 // look the size of the model in model frame unit (16 words unit)
398 model_size = *RAM_address_input;
399
400 // save the header of the model
401 *RAM_address_output++ = *RAM_address_input++;
402
403 while( (model_size != 0) &&
404 (l1_srback_com.emergency_stop == FALSE) )
405 {
406 frame_size = SC_SR_MODEL_FRAME_SIZE;
407 while ( (frame_size != 0) &&
408 (l1_srback_com.emergency_stop == FALSE) )
409 {
410 *RAM_address_output++ = *RAM_address_input++;
411 frame_size--;
412 }
413 model_size--;
414 }
415 }
416 #endif // SPEECH_RECO
417
418 #if (OP_RIV_AUDIO == 0)
419 #if (MELODY_E2 && FIR)
420 /*--------------------------------------------------------*/
421 /*audio_background_melody_e2_download_instrument_manager()*/
422 /*--------------------------------------------------------*/
423 /* */
424 /* Description: */
425 /* ------------ */
426 /* This function is used to load/unload the instrument of */
427 /* the melodies E2. */
428 /* */
429 /* Starting messages: */
430 /* L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ */
431 /* L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_REQ */
432 /* */
433 /* Result messages (input): none */
434 /* */
435 /* Result messages (output): */
436 /* L1_BACK_MELODY_E2_LOAD_INSTRUMENT_CON */
437 /* L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_CON */
438 /* */
439 /* Reset messages (input): none */
440 /* */
441 /* Stop message (input): none. */
442 /* */
443 /* Stop message (output): */
444 /* L1_BACK_MELODY_E2_LOAD_INSTRUMENT_CON */
445 /* L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_CON */
446 /* */
447 /* Rem: to stop immediatly the instrument download flags */
448 /* ---- is created: */
449 /* l1a_l1s_com.melody0_e2_task.parameters.emergency_stop */
450 /* l1a_l1s_com.melody1_e2_task.parameters.emergency_stop */
451 /* */
452 /*--------------------------------------------------------*/
453 void audio_background_melody_e2_download_instrument_manager(xSignalHeaderRec *msg)
454 {
455 xSignalHeaderRec *confirm_msg;
456 UWORD8 instrument_number, max_number_of_instrument, instrument_id, id;
457 UWORD16 size;
458 UWORD32 address;
459
460 if (msg->SignalCode == L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ)
461 {
462 // Load the instrument
463
464 // Init the first address
465 address = ( ((UWORD32)(l1s_dsp_com.dsp_ndb_ptr->a_melody_e2_instrument_wave))
466 - SC_AUDIO_MCU_API_BEGIN_ADDRESS );
467 l1s_dsp_com.dsp_ndb_ptr->a_melody_e2_instrument_ptr[0] =
468 (API)( (address>>1) + SC_AUDIO_DSP_API_BEGIN_ADDRESS );
469
470 // Download the instrument
471 max_number_of_instrument = ((T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ *)(msg->SigP))->number_of_instrument;
472 for(instrument_number=0; instrument_number < max_number_of_instrument ; instrument_number++)
473 {
474 // No instrument was previously download
475 if (audioback_melody_e2.number_of_user[instrument_number] == 0)
476 {
477 // load the insturment ID
478 instrument_id =
479 ((T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ *)(msg->SigP))->waves_table_id[instrument_number];
480
481 // Find if this instrument was already downloaded
482 id = 0;
483 while ( (id < SC_AUDIO_MELODY_E2_MAX_NUMBER_OF_INSTRUMENT) &&
484 ((instrument_id != audioback_melody_e2.instrument_id[id]) ||
485 (audioback_melody_e2.number_of_user[id] == 0)) )
486 {
487 id++;
488 }
489
490 if (id < SC_AUDIO_MELODY_E2_MAX_NUMBER_OF_INSTRUMENT)
491 {
492 // This insturment was already downloaded
493 // copy the address of this instrument
494 l1s_dsp_com.dsp_ndb_ptr->a_melody_e2_instrument_ptr[instrument_number] =
495 l1s_dsp_com.dsp_ndb_ptr->a_melody_e2_instrument_ptr[id];
496
497 // The size of this instrument is 0
498 audioback_melody_e2.instrument_size[instrument_number] = 0;
499 }
500 else
501 {
502 // Load the customer instrument
503 size = Cust_audio_melody_E2_load_instrument (
504 ((T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ *)(msg->SigP))->waves_table_id[instrument_number],
505 audioback_melody_e2.API_address,
506 audioback_melody_e2.allowed_size);
507
508 // Added to stop the L1 in case of download error
509 if (size == 0)
510 {
511 // Send a message to stop the L1
512 /* send the stop command to the audio L1 */
513 /* allocate the buffer for the message to the L1 */
514 confirm_msg = os_alloc_sig(0);
515 DEBUGMSG(status,NU_ALLOC_ERR)
516
517 if (confirm_msg != NULL)
518 {
519 /* send the stop command to the audio L1 */
520 if ( ((T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ *)(confirm_msg->SigP))->melody_id == 0)
521 {
522 confirm_msg->SignalCode = MMI_MELODY0_E2_STOP_REQ;
523 }
524 else
525 {
526 confirm_msg->SignalCode = MMI_MELODY1_E2_STOP_REQ;
527 }
528 os_send_sig(confirm_msg, L1C1_QUEUE);
529 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
530 }
531 }
532
533 // Save the size of this instrument
534 audioback_melody_e2.instrument_size[instrument_number] = size;
535 }
536
537 // Update the Cust_audio_melody_E2_load_instrument argument
538 audioback_melody_e2.API_address += audioback_melody_e2.instrument_size[instrument_number];
539 audioback_melody_e2.allowed_size -= audioback_melody_e2.instrument_size[instrument_number];
540
541 // Put the DSP address to the NDB API for the next instrument
542 if (instrument_number < SC_AUDIO_MELODY_E2_MAX_NUMBER_OF_INSTRUMENT-1)
543 {
544 address = ( ((UWORD32)(audioback_melody_e2.API_address))
545 - SC_AUDIO_MCU_API_BEGIN_ADDRESS );
546
547 l1s_dsp_com.dsp_ndb_ptr->a_melody_e2_instrument_ptr[instrument_number + 1] =
548 (API)( (address>>1) + SC_AUDIO_DSP_API_BEGIN_ADDRESS );
549 }
550
551 // Save the instrument ID
552 audioback_melody_e2.instrument_id[instrument_number] = instrument_id;
553 }
554
555 // Increase the number of user of this instrument number
556 audioback_melody_e2.number_of_user[instrument_number]++;
557 }
558
559 // Send the load confirmation message
560 confirm_msg = os_alloc_sig(sizeof(T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_CON));
561 DEBUGMSG(status,NU_ALLOC_ERR)
562
563 // Fill the parameter
564 ((T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_CON *)(confirm_msg->SigP))->melody_id =
565 ((T_L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ *)(msg->SigP))->melody_id;
566
567 confirm_msg->SignalCode = L1_BACK_MELODY_E2_LOAD_INSTRUMENT_CON;
568
569 os_send_sig(confirm_msg, L1C1_QUEUE);
570 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
571 }
572 else
573 if (msg->SignalCode == L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_REQ)
574 {
575 // Unload the instrument
576 max_number_of_instrument = ((T_L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_REQ *)(msg->SigP))->number_of_instrument;
577 for(instrument_number = max_number_of_instrument; instrument_number > 0 ; instrument_number--)
578 {
579 // Decrease the number of user of this instrument number
580 audioback_melody_e2.number_of_user[instrument_number-1]--;
581
582 // Check if the instrument must be removed
583 if (audioback_melody_e2.number_of_user[instrument_number-1] == 0)
584 {
585 // Increase the size and decrease the pointer to the API with the size
586 // of the removed instrument
587 // Update the Cust_audio_melody_E2_load_instrument argument
588 audioback_melody_e2.API_address -= audioback_melody_e2.instrument_size[instrument_number-1];
589 audioback_melody_e2.allowed_size += audioback_melody_e2.instrument_size[instrument_number-1];
590 }
591 }
592
593 // Send the unload confirmation message
594 confirm_msg = os_alloc_sig(sizeof(T_L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_CON));
595 DEBUGMSG(status,NU_ALLOC_ERR)
596
597 // Fill the paramter
598 ((T_L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_CON *)(confirm_msg->SigP))->melody_id =
599 ((T_L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_REQ *)(msg->SigP))->melody_id;
600
601 confirm_msg->SignalCode = L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_CON;
602
603 os_send_sig(confirm_msg, L1C1_QUEUE);
604 DEBUGMSG(status,NU_SEND_QUEUE_ERR)
605 }
606 }
607 #endif // MELODY_E2
608 #endif // OP_RIV_AUDIO
609 #endif // AUDIO_TASK == 1 && L1_AUDIO_BACKGROUND_TASK