OSDN Git Service

Initial control panel for sound volume and disable
authorMojito Sorbet <mojitotech@gmail.com>
Sun, 30 May 2010 03:38:30 +0000 (03:38 +0000)
committerMojito Sorbet <mojitotech@gmail.com>
Sun, 30 May 2010 03:38:30 +0000 (03:38 +0000)
git-svn-id: https://radegast.googlecode.com/svn/branches/sounds@659 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/Core/Media/BufferSound.cs
Radegast/Core/Media/MediaManager.cs
Radegast/Core/Media/MediaObject.cs
Radegast/GUI/Consoles/MediaConsole.Designer.cs
Radegast/GUI/Consoles/MediaConsole.cs
Radegast/GUI/Consoles/MediaConsole.resx

index 00e55a5..11d1e43 100644 (file)
@@ -212,7 +212,7 @@ namespace Radegast.Media
 \r
                     // Allocate a channel and set initial volume.  Initially paused.\r
                     FMODExec(system.playSound(CHANNELINDEX.FREE, sound, true, ref channel));\r
-                    FMODExec(channel.setVolume(volume));\r
+                    FMODExec(channel.setVolume(volume * m_objectVolume ));\r
 \r
                     // Take note of when the sound is finished playing.\r
                     FMODExec(channel.setCallback(endCallback));\r
index ba86781..b9b6f7b 100644 (file)
@@ -73,14 +73,7 @@ namespace Radegast.Media
             listenerThread.Name = "ListenerThread";
             listenerThread.Start();
 
-            // Subscribe to events about inworld sounds
-            instance.Client.Sound.SoundTrigger += new EventHandler<SoundTriggerEventArgs>(Sound_SoundTrigger);
-            instance.Client.Sound.AttachedSound += new EventHandler<AttachedSoundEventArgs>(Sound_AttachedSound);
-            instance.Client.Sound.PreloadSound += new EventHandler<PreloadSoundEventArgs>(Sound_PreloadSound);
-            instance.Client.Objects.ObjectUpdate +=new EventHandler<PrimEventArgs>(Objects_ObjectUpdate);
-            instance.Client.Objects.ObjectPropertiesUpdated += new EventHandler<ObjectPropertiesUpdatedEventArgs>(Objects_ObjectPropertiesUpdated);
-            instance.Client.Objects.KillObject += new EventHandler<KillObjectEventArgs>(Objects_KillObject);
-            instance.Client.Network.SimChanged += new EventHandler<SimChangedEventArgs>(Network_SimChanged);
+            ObjectEnable = true;
         }
 
         /// <summary>
@@ -343,7 +336,7 @@ namespace Radegast.Media
                 false,
                 true,
                 e.Position,
-                e.Gain);
+                e.Gain * ObjectVolume);
         }
 
         /// <summary>
@@ -386,7 +379,7 @@ namespace Radegast.Media
                 (e.Flags & SoundFlags.Loop) == SoundFlags.Loop,
                 true,
                 fullPosition,
-                e.Gain);
+                e.Gain * ObjectVolume);
         }
 
         
@@ -474,7 +467,49 @@ namespace Radegast.Media
                 (p.SoundFlags & SoundFlags.Loop) == SoundFlags.Loop,
                 true,
                 fullPosition, //Instance.State.GlobalPosition(e.Simulator, fullPosition),
-                p.SoundGain);
+                p.SoundGain * ObjectVolume);
+        }
+
+        public float ObjectVolume
+        {
+            set { m_objectVolume = value; }
+            get { return m_objectVolume; }
+        }
+
+        private bool m_objectEnabled = true;
+        public bool ObjectEnable
+        {
+            set
+            {
+                if (value)
+                {
+                    // Subscribe to events about inworld sounds
+                    Instance.Client.Sound.SoundTrigger += new EventHandler<SoundTriggerEventArgs>(Sound_SoundTrigger);
+                    Instance.Client.Sound.AttachedSound += new EventHandler<AttachedSoundEventArgs>(Sound_AttachedSound);
+                    Instance.Client.Sound.PreloadSound += new EventHandler<PreloadSoundEventArgs>(Sound_PreloadSound);
+                    Instance.Client.Objects.ObjectUpdate += new EventHandler<PrimEventArgs>(Objects_ObjectUpdate);
+                    Instance.Client.Objects.ObjectPropertiesUpdated += new EventHandler<ObjectPropertiesUpdatedEventArgs>(Objects_ObjectPropertiesUpdated);
+                    Instance.Client.Objects.KillObject += new EventHandler<KillObjectEventArgs>(Objects_KillObject);
+                    Instance.Client.Network.SimChanged += new EventHandler<SimChangedEventArgs>(Network_SimChanged);
+
+                }
+                else
+                {
+                    // Subscribe to events about inworld sounds
+                    Instance.Client.Sound.SoundTrigger -= new EventHandler<SoundTriggerEventArgs>(Sound_SoundTrigger);
+                    Instance.Client.Sound.AttachedSound -= new EventHandler<AttachedSoundEventArgs>(Sound_AttachedSound);
+                    Instance.Client.Sound.PreloadSound -= new EventHandler<PreloadSoundEventArgs>(Sound_PreloadSound);
+                    Instance.Client.Objects.ObjectUpdate -= new EventHandler<PrimEventArgs>(Objects_ObjectUpdate);
+                    Instance.Client.Objects.ObjectPropertiesUpdated -= new EventHandler<ObjectPropertiesUpdatedEventArgs>(Objects_ObjectPropertiesUpdated);
+                    Instance.Client.Objects.KillObject -= new EventHandler<KillObjectEventArgs>(Objects_KillObject);
+                    Instance.Client.Network.SimChanged -= new EventHandler<SimChangedEventArgs>(Network_SimChanged);
+
+                    // Stop all running sounds
+                    BufferSound.KillAll();
+                }
+                m_objectEnabled = value;
+            }
+            get { return m_objectEnabled; }
         }
 
         /// <summary>
index dcc998c..97b26cf 100644 (file)
@@ -80,6 +80,7 @@ namespace Radegast.Media
         protected static FMOD.System system = null;
         public FMOD.System FMODSystem { get { return system; } }
 
+        protected static float m_objectVolume = 0.8f;
         public MediaObject()
         {
             // Zero out the extra info structure.
index cd3dbfd..3ad82dc 100644 (file)
@@ -71,8 +71,13 @@ namespace Radegast
             this.label2 = new System.Windows.Forms.Label();
             this.label1 = new System.Windows.Forms.Label();
             this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
+            this.ObjSoundGroup = new System.Windows.Forms.GroupBox();
+            this.ObjVolume = new System.Windows.Forms.TrackBar();
+            this.ObjSoundEnable = new System.Windows.Forms.CheckBox();
             ((System.ComponentModel.ISupportInitialize)(this.volAudioStream)).BeginInit();
             this.pnlParcelAudio.SuspendLayout();
+            this.ObjSoundGroup.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.ObjVolume)).BeginInit();
             this.SuspendLayout();
             // 
             // volAudioStream
@@ -81,7 +86,7 @@ namespace Radegast
             this.volAudioStream.Location = new System.Drawing.Point(6, 19);
             this.volAudioStream.Maximum = 50;
             this.volAudioStream.Name = "volAudioStream";
-            this.volAudioStream.Size = new System.Drawing.Size(347, 45);
+            this.volAudioStream.Size = new System.Drawing.Size(347, 42);
             this.volAudioStream.SmallChange = 2;
             this.volAudioStream.TabIndex = 1;
             this.volAudioStream.Value = 25;
@@ -197,16 +202,55 @@ namespace Radegast
             this.label1.TabIndex = 2;
             this.label1.Text = "Stream";
             // 
+            // ObjSoundGroup
+            // 
+            this.ObjSoundGroup.Controls.Add(this.ObjSoundEnable);
+            this.ObjSoundGroup.Controls.Add(this.ObjVolume);
+            this.ObjSoundGroup.Location = new System.Drawing.Point(3, 147);
+            this.ObjSoundGroup.Name = "ObjSoundGroup";
+            this.ObjSoundGroup.Size = new System.Drawing.Size(358, 67);
+            this.ObjSoundGroup.TabIndex = 3;
+            this.ObjSoundGroup.TabStop = false;
+            this.ObjSoundGroup.Text = "Object Sounds";
+            // 
+            // ObjVolume
+            // 
+            this.ObjVolume.LargeChange = 10;
+            this.ObjVolume.Location = new System.Drawing.Point(4, 12);
+            this.ObjVolume.Maximum = 50;
+            this.ObjVolume.Name = "ObjVolume";
+            this.ObjVolume.Size = new System.Drawing.Size(347, 42);
+            this.ObjVolume.SmallChange = 2;
+            this.ObjVolume.TabIndex = 2;
+            this.ObjVolume.Value = 25;
+            // 
+            // ObjSoundEnable
+            // 
+            this.ObjSoundEnable.AutoSize = true;
+            this.ObjSoundEnable.Checked = true;
+            this.ObjSoundEnable.CheckState = System.Windows.Forms.CheckState.Checked;
+            this.ObjSoundEnable.Location = new System.Drawing.Point(10, 44);
+            this.ObjSoundEnable.Name = "ObjSoundEnable";
+            this.ObjSoundEnable.Size = new System.Drawing.Size(59, 17);
+            this.ObjSoundEnable.TabIndex = 5;
+            this.ObjSoundEnable.Text = "Enable";
+            this.toolTip1.SetToolTip(this.ObjSoundEnable, "When checked inworld sounds will play");
+            this.ObjSoundEnable.UseVisualStyleBackColor = true;
+            // 
             // MediaConsole
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.Controls.Add(this.ObjSoundGroup);
             this.Controls.Add(this.pnlParcelAudio);
             this.Name = "MediaConsole";
-            this.Size = new System.Drawing.Size(368, 147);
+            this.Size = new System.Drawing.Size(368, 217);
             ((System.ComponentModel.ISupportInitialize)(this.volAudioStream)).EndInit();
             this.pnlParcelAudio.ResumeLayout(false);
             this.pnlParcelAudio.PerformLayout();
+            this.ObjSoundGroup.ResumeLayout(false);
+            this.ObjSoundGroup.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.ObjVolume)).EndInit();
             this.ResumeLayout(false);
 
         }
@@ -225,6 +269,9 @@ namespace Radegast
         public System.Windows.Forms.Label label2;
         public System.Windows.Forms.ToolTip toolTip1;
         public System.Windows.Forms.Label lblStation;
+        private System.Windows.Forms.GroupBox ObjSoundGroup;
+        public System.Windows.Forms.CheckBox ObjSoundEnable;
+        public System.Windows.Forms.TrackBar ObjVolume;
 
     }
 }
index 3dca62d..86d6459 100644 (file)
@@ -78,6 +78,9 @@ namespace Radegast
             lblStation.Tag = lblStation.Text = string.Empty;
             lblStation.Click += new EventHandler(lblStation_Click);
 
+            ObjVolume.Scroll += new EventHandler(volObject_Scroll);
+            ObjSoundEnable.CheckedChanged += new EventHandler(cbObjEnableChanged);
+
             // Network callbacks
             client.Parcels.ParcelProperties += new EventHandler<ParcelPropertiesEventArgs>(Parcels_ParcelProperties);
         }
@@ -209,6 +212,18 @@ namespace Radegast
                     parcelStream.Volume = volAudioStream.Value/50f;
         }
 
+        private void volObject_Scroll(object sender, EventArgs e)
+        {
+            configTimer.Change(saveConfigTimeout, System.Threading.Timeout.Infinite);
+            instance.MediaManager.ObjectVolume = ObjVolume.Value / 50f;
+        }
+
+        void cbObjEnableChanged(object sender, EventArgs e)
+        {
+            configTimer.Change(saveConfigTimeout, System.Threading.Timeout.Infinite);
+            instance.MediaManager.ObjectEnable = ObjSoundEnable.Checked;
+        }
+
         private void txtAudioURL_TextChanged(object sender, EventArgs e)
         {
             configTimer.Change(saveConfigTimeout, System.Threading.Timeout.Infinite);
index 7ce03af..6dfd76d 100644 (file)
     <value>2.0</value>\r
   </resheader>\r
   <resheader name="reader">\r
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
   </resheader>\r
   <resheader name="writer">\r
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
   </resheader>\r
-  <metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+  <metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>17, 17</value>\r
+  </metadata>\r
+  <metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>17, 17</value>\r
   </metadata>\r
 </root>
\ No newline at end of file