aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvoicevisualizer.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:04 -0500
committerJacek Antonelli2008-08-15 23:45:04 -0500
commit117e22047c5752352342d64e3fb7ce00a4eb8113 (patch)
treee32de2cfba0dda8705ae528fcd1fbe23ba075685 /linden/indra/newview/llvoicevisualizer.h
parentSecond Life viewer sources 1.18.0.6 (diff)
downloadmeta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.zip
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.gz
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.bz2
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.xz
Second Life viewer sources 1.18.1.2
Diffstat (limited to 'linden/indra/newview/llvoicevisualizer.h')
-rw-r--r--linden/indra/newview/llvoicevisualizer.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/linden/indra/newview/llvoicevisualizer.h b/linden/indra/newview/llvoicevisualizer.h
new file mode 100644
index 0000000..ea53372
--- /dev/null
+++ b/linden/indra/newview/llvoicevisualizer.h
@@ -0,0 +1,111 @@
1//--------------------------------------------------------------------
2//
3// VOICE VISUALIZER
4// author: JJ Ventrella, Linden Lab
5// (latest update to this info: Jan 18, 2007)
6//
7// The Voice Visualizer is responsible for taking realtime signals from actual users speaking and
8// visualizing this speech in two forms:
9//
10// (1) as a dynamic sound symbol (also referred to as the "voice indicator" that appears over the avatar's head
11// (2) as gesticulation events that are used to trigger avatr gestures
12//
13// The input for the voice visualizer is a continual stream of voice amplitudes.
14
15//-----------------------------------------------------------------------------
16#ifndef LL_VOICE_VISUALIZER_H
17#define LL_VOICE_VISUALIZER_H
18
19#include "llhudeffect.h"
20
21//-----------------------------------------------------------------------------------------------
22// The values of voice gesticulation represent energy levels for avatar animation, based on
23// amplitude surge events parsed from the voice signal. These are made available so that
24// the appropriate kind of avatar animation can be triggered, and thereby simulate the physical
25// motion effects of speech. It is recommended that multiple body parts be animated as well as
26// lips, such as head, shoulders, and hands, with large gestures used when the energy level is high.
27//-----------------------------------------------------------------------------------------------
28enum VoiceGesticulationLevel
29{
30 VOICE_GESTICULATION_LEVEL_OFF = -1,
31 VOICE_GESTICULATION_LEVEL_LOW = 0,
32 VOICE_GESTICULATION_LEVEL_MEDIUM,
33 VOICE_GESTICULATION_LEVEL_HIGH,
34 NUM_VOICE_GESTICULATION_LEVELS
35};
36
37const static int NUM_VOICE_SYMBOL_WAVES = 7;
38
39//----------------------------------------------------
40// LLVoiceVisualizer class
41//----------------------------------------------------
42class LLVoiceVisualizer : public LLHUDEffect
43{
44 //---------------------------------------------------
45 // public methods
46 //---------------------------------------------------
47 public:
48 LLVoiceVisualizer ( const U8 type ); //constructor
49 ~LLVoiceVisualizer(); //destructor
50
51 friend class LLHUDObject;
52
53 void setVoiceSourceWorldPosition( const LLVector3 &p ); // this should be the position of the speaking avatar's head
54 void setMinGesticulationAmplitude( F32 ); // the lower range of meaningful amplitude for setting gesticulation level
55 void setMaxGesticulationAmplitude( F32 ); // the upper range of meaningful amplitude for setting gesticulation level
56 void setStartSpeaking(); // tell me when the av starts speaking
57 void setVoiceEnabled( bool ); // tell me whether or not the user is voice enabled
58 void setSpeakingAmplitude( F32 ); // tell me how loud the av is speaking (ranges from 0 to 1)
59 void setStopSpeaking(); // tell me when the av stops speaking
60 bool getCurrentlySpeaking(); // the get for the above set
61 VoiceGesticulationLevel getCurrentGesticulationLevel(); // based on voice amplitude, I'll give you the current "energy level" of avatar speech
62
63 void render(); // inherited from HUD Effect
64 void packData(LLMessageSystem *mesgsys); // inherited from HUD Effect
65 void unpackData(LLMessageSystem *mesgsys, S32 blocknum); // inherited from HUD Effect
66 void markDead(); // inherited from HUD Effect
67
68 //----------------------------------------------------------------------------------------------
69 // "setMaxGesticulationAmplitude" and "setMinGesticulationAmplitude" allow for the tuning of the
70 // gesticulation level detector to be responsive to different kinds of signals. For instance, we
71 // may find that the average voice amplitude rarely exceeds 0.7 (in a range from 0 to 1), and
72 // therefore we may want to set 0.7 as the max, so we can more easily catch all the variance
73 // within that range. Also, we may find that there is often noise below a certain range like 0.1,
74 // and so we would want to set 0.1 as the min so as not to accidentally use this as signal.
75 //----------------------------------------------------------------------------------------------
76 void setMaxGesticulationAmplitude();
77 void setMinGesticulationAmplitude();
78
79 //---------------------------------------------------
80 // private members
81 //---------------------------------------------------
82 private:
83
84 struct SoundSymbol
85 {
86 F32 mWaveExpansion [ NUM_VOICE_SYMBOL_WAVES ];
87 bool mWaveActive [ NUM_VOICE_SYMBOL_WAVES ];
88 F64 mWaveFadeOutStartTime [ NUM_VOICE_SYMBOL_WAVES ];
89 F32 mWaveOpacity [ NUM_VOICE_SYMBOL_WAVES ];
90 LLPointer<LLImageGL> mTexture [ NUM_VOICE_SYMBOL_WAVES ];
91 bool mActive;
92 LLVector3 mPosition;
93 };
94
95 LLFrameTimer mTimer; // so I can ask the current time in seconds
96 F64 mCurrentTime; // current time in seconds, captured every step
97 F64 mPreviousTime; // copy of "current time" from last frame
98 SoundSymbol mSoundSymbol; // the sound symbol that appears over the avatar's head
99 bool mVoiceEnabled; // if off, no rendering should happen
100 bool mCurrentlySpeaking; // is the user currently speaking?
101 LLVector3 mVoiceSourceWorldPosition; // give this to me every step - I need it to update the sound symbol
102 F32 mSpeakingAmplitude; // this should be set as often as possible when the user is speaking
103 F32 mMaxGesticulationAmplitude; // this is the upper-limit of the envelope of detectable gesticulation leves
104 F32 mMinGesticulationAmplitude; // this is the lower-limit of the envelope of detectable gesticulation leves
105
106};//-----------------------------------------------------------------
107 // end of LLVoiceVisualizer class
108//------------------------------------------------------------------
109
110#endif //LL_VOICE_VISUALIZER_H
111