Free Electron
Audible.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __intelligence_Audible_h__
8 #define __intelligence_Audible_h__
9 namespace fe
10 {
11 namespace ext
12 {
13 
14 /**************************************************************************//**
15  @brief Audible RecordView
16 
17  @ingroup intelligence
18 
19  To queue a sound, set @em nextSong.
20  To play a new sound immediately, clear @em song and set @em nextSong.
21  To stop, clear both.
22 
23  To queue as looping, set @em nextPlays to 0.
24  Otherwise, set a number of repititions.
25 
26  The @em nextPlays attribute is cleared once a new sound is started.
27 *//***************************************************************************/
28 class FE_DL_EXPORT Audible: public Matter
29 {
30  public:
31  Functor< sp<Component> > voice;
32  Functor<String> song;
33  Functor<String> nextSong;
34  Functor<I32> nextPlays;
35  Functor<F32> gain;
36  Functor<F32> pitch;
37  Functor<F32> nextGain;
38  Functor<F32> nextPitch;
39 
40  Audible(void) { setName("Audible"); }
41 virtual void addFunctors(void)
42  {
44 
45  add(voice, FE_SPEC("snd:voice",
46  "sp<VoiceI> created as needed"));
47  add(song, FE_SPEC("snd:song",
48  "Name of sound emitted"));
49  add(nextSong, FE_SPEC("snd:nextSong",
50  "Next sound to play"));
51  add(nextPlays, FE_SPEC("snd:nextPlays",
52  "Number of times to play next sound (0 for loop)"));
53  add(gain, FE_SPEC("snd:gain",
54  "Fractional volume of sound emitted"));
55  add(pitch, FE_SPEC("snd:pitch",
56  "Relative pitch of sound emitted"));
57  add(nextGain, FE_SPEC("snd:nextGain",
58  "Fractional volume of next sound"));
59  add(nextPitch, FE_SPEC("snd:nextPitch",
60  "Relative pitch of next sound"));
61  }
62 virtual void initializeRecord(void)
63  {
65 
66  voice.attribute()->setSerialize(FALSE);
67 
68  identifier()="Audible";
69 
70  voice()=NULL;
71  song()="";
72  nextSong()="";
73  nextPlays()=0;
74  gain()=1.0f;
75  nextGain()=1.0f;
76  pitch()=1.0f;
77  nextPitch()=1.0f;
78  }
79 };
80 
81 } /* namespace ext */
82 } /* namespace fe */
83 
84 #endif /* __intelligence_Audible_h__ */
virtual void addFunctors(void)
Called at instantiation to add functors.
Definition: Matter.h:36
virtual void initializeRecord(void)
Called at instantiation to initialize attributes.
Definition: Audible.h:62
Matter RecordView.
Definition: Matter.h:19
kernel
Definition: namespace.dox:3
Bound accessor in a RecordView.
Definition: RecordView.h:147
virtual void addFunctors(void)
Called at instantiation to add functors.
Definition: Audible.h:41
Audible RecordView.
Definition: Audible.h:28
sp< Attribute > attribute(void) const
Return the attribute this accessor is for.
Definition: Accessor.cc:151
virtual void initializeRecord(void)
Called at instantiation to initialize attributes.
Definition: Matter.h:53