Debian Codegraph @

artsynth/Artword_Speaker_Sound.cpp

raw symbols SCIP
1 /* Artword_Speaker_Sound.cpp
2 *
3 * Copyright (C) 1992-2005,2006,2011,2015-2017,2019 Paul Boersma
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "Artword_Speaker_Sound.h"
20 #include "Artword_Speaker.h"
21 #include "Art_Speaker.h"
22
23 Thing_define (Artword_Speaker_Sound_PlayInfo, Thing) {
24 Artword artword;
25 Speaker speaker;
26 Graphics graphics;
27 };
28
29 Thing_implement (Artword_Speaker_Sound_PlayInfo, Thing, 0);
30
31 static int playCallback (Artword_Speaker_Sound_PlayInfo me, int /* phase */, double /* tmin */, double /* tmax */, double t) {
32 static autoArt art;
33 if (! art)
34 art = Art_create ();
35 Artword_intoArt (my artword, art.get(), t);
36 Graphics_beginMovieFrame (my graphics, & Melder_WHITE);
37 Graphics_setWindow (my graphics, 0.0, 1.0, 0.0, 1.0);
38 Art_Speaker_draw (art.get(), my speaker, my graphics);
39 Graphics_endMovieFrame (my graphics, 0.0);
40 return 1;
41 }
42
43 void Artword_Speaker_Sound_playMovie (Artword artword, Speaker speaker, Sound sound, Graphics graphics) {
44 try {
45 static autoArtword_Speaker_Sound_PlayInfo info;
46 if (! info)
47 info = Thing_new (Artword_Speaker_Sound_PlayInfo);
48 info -> artword = artword;
49 info -> speaker = speaker;
50 info -> graphics = graphics;
51 if (sound) {
52 Sound_play (sound, playCallback, info.get());
53 } else {
54 autoSound silence = Sound_createSimple (1, artword -> totalTime, 44100.0);
55 Sound_play (silence.get(), playCallback, info.get());
56 }
57 } catch (MelderError) {
58 Melder_throw (artword, U" & ", speaker, U": movie not played.");
59 }
60 }
61
62 /* End of file Artword_Speaker_Sound.cpp */