1 /*
2 * Copyright (C) 2010 DSD Author
3 * GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
16 */
17
18 #include "dsd.h"
19
20 void
playMbeFiles(dsd_opts * opts,dsd_state * state,int argc,char ** argv)21 playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv)
22 {
23
24 int i;
25 char imbe_d[88];
26 char ambe_d[49];
27
28 for (i = state->optind; i < argc; i++)
29 {
30 sprintf (opts->mbe_in_file, "%s", argv[i]);
31 openMbeInFile (opts, state);
32 mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
33 printf ("playing %s\n", opts->mbe_in_file);
34 while (feof (opts->mbe_in_f) == 0)
35 {
36 if (state->mbe_file_type == 0)
37 {
38 readImbe4400Data (opts, state, imbe_d);
39 mbe_processImbe4400Dataf (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
40 processAudio (opts, state);
41 if (opts->wav_out_fd != -1)
42 {
43 writeSynthesizedVoice (opts, state);
44 }
45
46 if (opts->audio_out == 1)
47 {
48 playSynthesizedVoice (opts, state);
49 }
50 }
51 else if (state->mbe_file_type == 1)
52 {
53 readAmbe2450Data (opts, state, ambe_d);
54 mbe_processAmbe2450Dataf (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
55 processAudio (opts, state);
56 if (opts->wav_out_fd != -1)
57 {
58 writeSynthesizedVoice (opts, state);
59 }
60 if (opts->audio_out == 1)
61 {
62 playSynthesizedVoice (opts, state);
63 }
64 }
65 if (exitflag == 1)
66 {
67 cleanupAndExit (opts, state);
68 }
69 }
70 }
71 }
72
73 void
processMbeFrame(dsd_opts * opts,dsd_state * state,char imbe_fr[8][23],char ambe_fr[4][24],char imbe7100_fr[7][24])74 processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char ambe_fr[4][24], char imbe7100_fr[7][24])
75 {
76
77 int i;
78 char imbe_d[88];
79 char ambe_d[49];
80
81 for (i = 0; i < 88; i++)
82 {
83 imbe_d[i] = 0;
84 }
85
86 if ((state->synctype == 0) || (state->synctype == 1))
87 {
88 mbe_processImbe7200x4400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, imbe_fr, imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
89 if (opts->mbe_out_f != NULL)
90 {
91 saveImbe4400Data (opts, state, imbe_d);
92 }
93 }
94 else if ((state->synctype == 14) || (state->synctype == 15))
95 {
96 mbe_processImbe7100x4400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, imbe7100_fr, imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
97 if (opts->mbe_out_f != NULL)
98 {
99 saveImbe4400Data (opts, state, imbe_d);
100 }
101 }
102 else
103 {
104 mbe_processAmbe3600x2450Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_fr, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
105 if (opts->mbe_out_f != NULL)
106 {
107 saveAmbe2450Data (opts, state, ambe_d);
108 }
109 }
110
111 if (opts->errorbars == 1)
112 {
113 printf ("%s", state->err_str);
114 }
115
116 processAudio (opts, state);
117 if (opts->wav_out_fd != -1)
118 {
119 writeSynthesizedVoice (opts, state);
120 }
121
122 if (opts->audio_out == 1)
123 {
124 playSynthesizedVoice (opts, state);
125 }
126 }
127