comparison src/g23m-aci/aci/ati_audio.c @ 136:7d5b412ffb6c

aci: AT%VBAT and melody play enhancements from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 07 Jan 2019 18:47:52 +0000
parents d393cd9bb723
children 8c5d012b9c4d
comparison
equal deleted inserted replaced
135:ac4c0a9bc022 136:7d5b412ffb6c
212 212
213 return (ATI_CMPL); 213 return (ATI_CMPL);
214 } 214 }
215 #endif 215 #endif
216 216
217 static char melody_E1_name[AUDIO_PATH_NAME_MAX_SIZE];
218
217 /* AT@E1 - play an E1 format melody */ 219 /* AT@E1 - play an E1 format melody */
218 GLOBAL T_ATI_RSLT atAtE1 ( char *cl, UBYTE srcId ) 220 GLOBAL T_ATI_RSLT atAtE1 ( char *cl, UBYTE srcId )
219 { 221 {
220 T_AUDIO_MELODY_E1_PARAMETER e1_param; 222 T_AUDIO_MELODY_E1_PARAMETER e1_param;
221 T_RV_RETURN return_path; 223 int loopback = 0;
222 224 T_RV_RETURN return_path;
223 cl = parse(cl, "S", (LONG)(sizeof(e1_param.melody_name)), 225
224 e1_param.melody_name); 226 cl = parse(cl, "Sd", (LONG)(sizeof(e1_param.melody_name)),
227 e1_param.melody_name, &loopback);
225 if (!cl || !e1_param.melody_name[0]) 228 if (!cl || !e1_param.melody_name[0])
226 return (ATI_FAIL); 229 return (ATI_FAIL);
227 e1_param.loopback = AUDIO_MELODY_NO_LOOPBACK; 230 e1_param.loopback = loopback;
228 e1_param.melody_mode = AUDIO_MELODY_NORMAL_MODE; 231 e1_param.melody_mode = AUDIO_MELODY_NORMAL_MODE;
229 232
230 return_path.addr_id = NULL; 233 return_path.addr_id = NULL;
231 return_path.callback_func = audio_callback; 234 return_path.callback_func = audio_callback;
232 if (audio_melody_E1_start(&e1_param, return_path) == AUDIO_OK) 235 if (audio_melody_E1_start(&e1_param, return_path) == AUDIO_OK) {
233 return (ATI_CMPL); 236 strcpy(melody_E1_name, e1_param.melody_name);
234 else 237 return (ATI_CMPL);
235 return (ATI_FAIL); 238 } else
236 } 239 return (ATI_FAIL);
240 }
241
242 /* AT@E1STOP - stop melody started with AT@E1 */
243 GLOBAL T_ATI_RSLT atAtE1STOP ( char *cl, UBYTE srcId )
244 {
245 T_AUDIO_MELODY_E1_STOP_PARAMETER e1stop_param;
246 T_RV_RETURN return_path;
247
248 if (!melody_E1_name[0])
249 return (ATI_FAIL);
250 strcpy(e1stop_param.melody_name, melody_E1_name);
251
252 return_path.addr_id = NULL;
253 return_path.callback_func = audio_callback;
254 if (audio_melody_E1_stop(&e1stop_param, return_path) == AUDIO_OK)
255 return (ATI_CMPL);
256 else
257 return (ATI_FAIL);
258 }
259
260 static char melody_E2_name[AUDIO_PATH_NAME_MAX_SIZE];
237 261
238 /* AT@E2 - play an E2 format melody */ 262 /* AT@E2 - play an E2 format melody */
239 GLOBAL T_ATI_RSLT atAtE2 ( char *cl, UBYTE srcId ) 263 GLOBAL T_ATI_RSLT atAtE2 ( char *cl, UBYTE srcId )
240 { 264 {
241 T_AUDIO_MELODY_E2_PARAMETER e2_param; 265 T_AUDIO_MELODY_E2_PARAMETER e2_param;
242 T_RV_RETURN return_path; 266 int loopback = 0;
243 267 T_RV_RETURN return_path;
244 cl = parse(cl, "S", (LONG)(sizeof(e2_param.melody_E2_name)), 268
245 e2_param.melody_E2_name); 269 cl = parse(cl, "Sd", (LONG)(sizeof(e2_param.melody_E2_name)),
270 e2_param.melody_E2_name, &loopback);
246 if (!cl || !e2_param.melody_E2_name[0]) 271 if (!cl || !e2_param.melody_E2_name[0])
247 return (ATI_FAIL); 272 return (ATI_FAIL);
248 e2_param.E2_loopback = AUDIO_MELODY_NO_LOOPBACK; 273 e2_param.E2_loopback = loopback;
249 e2_param.melody_E2_mode = AUDIO_MELODY_NORMAL_MODE; 274 e2_param.melody_E2_mode = AUDIO_MELODY_NORMAL_MODE;
250 275
251 return_path.addr_id = NULL; 276 return_path.addr_id = NULL;
252 return_path.callback_func = audio_callback; 277 return_path.callback_func = audio_callback;
253 if (audio_melody_E2_start(&e2_param, return_path) == AUDIO_OK) 278 if (audio_melody_E2_start(&e2_param, return_path) == AUDIO_OK) {
254 return (ATI_CMPL); 279 strcpy(melody_E2_name, e2_param.melody_E2_name);
255 else 280 return (ATI_CMPL);
281 } else
256 return (ATI_FAIL); 282 return (ATI_FAIL);
257 } 283 }
258 284
259 /* AT@E2LSI - load melody E2 instrument list file */ 285 /* AT@E2LSI - load melody E2 instrument list file */
260 GLOBAL T_ATI_RSLT atAtE2LSI ( char *cl, UBYTE srcId ) 286 GLOBAL T_ATI_RSLT atAtE2LSI ( char *cl, UBYTE srcId )
265 e2_lsi_param.melody_E2_file_name); 291 e2_lsi_param.melody_E2_file_name);
266 if (!cl || !e2_lsi_param.melody_E2_file_name[0]) 292 if (!cl || !e2_lsi_param.melody_E2_file_name[0])
267 return (ATI_FAIL); 293 return (ATI_FAIL);
268 294
269 if (audio_melody_E2_load_file_instruments(&e2_lsi_param) == AUDIO_OK) 295 if (audio_melody_E2_load_file_instruments(&e2_lsi_param) == AUDIO_OK)
296 return (ATI_CMPL);
297 else
298 return (ATI_FAIL);
299 }
300
301 /* AT@E2STOP - stop melody started with AT@E2 */
302 GLOBAL T_ATI_RSLT atAtE2STOP ( char *cl, UBYTE srcId )
303 {
304 T_AUDIO_MELODY_E2_STOP_PARAMETER e2stop_param;
305 T_RV_RETURN return_path;
306
307 if (!melody_E2_name[0])
308 return (ATI_FAIL);
309 strcpy(e2stop_param.melody_E2_name, melody_E2_name);
310
311 return_path.addr_id = NULL;
312 return_path.callback_func = audio_callback;
313 if (audio_melody_E2_stop(&e2stop_param, return_path) == AUDIO_OK)
270 return (ATI_CMPL); 314 return (ATI_CMPL);
271 else 315 else
272 return (ATI_FAIL); 316 return (ATI_FAIL);
273 } 317 }
274 318