comparison src/aci2/aci/ati_audio.c @ 226:67fe1b3f4bd7

aci2: added some AT commands for exercising audio functions
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 24 Oct 2016 08:39:11 +0000
parents
children e0b9c21d7908
comparison
equal deleted inserted replaced
225:b16d79c550a2 226:67fe1b3f4bd7
1 /*
2 * This ATI module and the AT commands implemented therein are a FreeCalypso
3 * addition. The purpose of these AT commands is to exercise the audio
4 * capabilities of the firmware - by using these commands, you should be
5 * able to emit sounds from the speaker or record voice from the microphone
6 * without needing to be in a call, and without bringing up GSM at all.
7 */
8
9 #ifndef ATI_AUDIO_C
10 #define ATI_AUDIO_C
11
12 #include "aci_all.h"
13
14 #include <ctype.h>
15 #include <string.h>
16
17 #include "aci_cmh.h"
18 #include "ati_cmd.h"
19 #include "aci_cmd.h"
20 #include "aci_io.h"
21 #include "aci_cmd.h"
22 #include "l4_tim.h"
23 #include "line_edit.h"
24 #include "aci_lst.h"
25
26 #include "pcm.h"
27 #include "audio.h"
28 #include "aci.h"
29 #include "rx.h"
30 #include "pwr.h"
31 #include "l4_tim.h"
32
33 #ifdef GPRS
34 #ifdef DTI
35 #include "dti.h"
36 #include "dti_conn_mng.h"
37 #include "dti_cntrl_mng.h"
38 #endif /* DTI */
39 #include "gaci.h"
40 #include "gaci_cmh.h"
41 #include "gaci_cmd.h"
42 #endif /* GPRS */
43
44 #include "aci_mem.h"
45 #include "aci_prs.h"
46
47 #include "ati_int.h"
48
49 #ifndef _SIMULATION_
50 #include "ffs/ffs.h"
51 #endif
52
53 #ifdef FF_ATI_BAT
54
55 #include "typedefs.h"
56 #include "gdd.h"
57 #include "bat.h"
58
59 #include "ati_bat.h"
60
61 #endif /*FF_ATI_BAT*/
62
63 #include "audio/audio_api.h"
64 #include "audio.h" /* Condat */
65
66 /* AT@SND - emit sound through Condat API */
67 GLOBAL T_ATI_RSLT atAtSND ( char *cl, UBYTE srcId )
68 {
69 UBYTE sound_id = TONES_KEYBEEP;
70
71 cl = parse(cl, "x", &sound_id);
72 audio_PlaySoundID(AUDIO_SPEAKER, sound_id, 0, AUDIO_PLAY_ONCE);
73 return (ATI_CMPL);
74 }
75
76 static void audio_callback(void *event_from_audio)
77 {
78 /* do nothing at this time */
79 }
80
81 /* AT@E1 - play an E1 format melody */
82 GLOBAL T_ATI_RSLT atAtE1 ( char *cl, UBYTE srcId )
83 {
84 T_AUDIO_MELODY_E1_PARAMETER e1_param;
85 T_RV_RETURN return_path;
86
87 e1_param.melody_name[0] = 0;
88 cl = parse(cl, "s", (LONG)(sizeof(e1_param.melody_name) - 1),
89 e1_param.melody_name);
90 if (!e1_param.melody_name[0])
91 return (ATI_FAIL);
92 e1_param.loopback = AUDIO_MELODY_NO_LOOPBACK;
93 e1_param.melody_mode = AUDIO_MELODY_NORMAL_MODE;
94
95 return_path.addr_id = NULL;
96 return_path.callback_func = audio_callback;
97 if (audio_melody_E1_start(&e1_param, return_path) == AUDIO_OK)
98 return (ATI_CMPL);
99 else
100 return (ATI_FAIL);
101 }
102
103 /* AT@E2 - play an E2 format melody */
104 GLOBAL T_ATI_RSLT atAtE2 ( char *cl, UBYTE srcId )
105 {
106 T_AUDIO_MELODY_E2_PARAMETER e2_param;
107 T_RV_RETURN return_path;
108
109 e2_param.melody_E2_name[0] = 0;
110 cl = parse(cl, "s", (LONG)(sizeof(e2_param.melody_E2_name) - 1),
111 e2_param.melody_E2_name);
112 if (!e2_param.melody_E2_name[0])
113 return (ATI_FAIL);
114 e2_param.E2_loopback = AUDIO_MELODY_NO_LOOPBACK;
115 e2_param.melody_E2_mode = AUDIO_MELODY_NORMAL_MODE;
116
117 return_path.addr_id = NULL;
118 return_path.callback_func = audio_callback;
119 if (audio_melody_E2_start(&e2_param, return_path) == AUDIO_OK)
120 return (ATI_CMPL);
121 else
122 return (ATI_FAIL);
123 }
124
125 /* AT@E2LSI - load melody E2 instrument list file */
126 GLOBAL T_ATI_RSLT atAtE2LSI ( char *cl, UBYTE srcId )
127 {
128 T_AUDIO_MELODY_E2_LOAD_FILE_INSTR_PARAMETER e2_lsi_param;
129
130 e2_lsi_param.melody_E2_file_name[0] = 0;
131 cl = parse(cl, "s", (LONG)(sizeof(e2_lsi_param.melody_E2_file_name)-1),
132 e2_lsi_param.melody_E2_file_name);
133 if (!e2_lsi_param.melody_E2_file_name[0])
134 return (ATI_FAIL);
135
136 if (audio_melody_E2_load_file_instruments(&e2_lsi_param) == AUDIO_OK)
137 return (ATI_CMPL);
138 else
139 return (ATI_FAIL);
140 }
141
142 #endif /* ATI_AUDIO_C */