Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Defsine79

Pages: [1]
1
TNet 3 Support / Re: Sound question
« on: November 14, 2016, 07:25:17 AM »
OK so I guess once audioclip is loaded the best place would be in
 
private IEnumerator LoadSoundFromFileRoutine(string file)
    {
        WWW fileLoad = new WWW(file);
        yield return fileLoad;
        if (!string.IsNullOrEmpty(fileLoad.error))
        {
            Debug.LogError("Failed to load Sound file " + file);
            yield break;
        }
 
        Debug.Log("Done Sound LoadFromFile " + file);
 
        audioClip = fileLoad.GetAudioClip(true);
 
        StartCoroutine(PlayClip());
        tno.Send("PlayClip", Target.AllSaved, audioClip);


       
 
    }

2
TNet 3 Support / Re: Sound question
« on: November 07, 2016, 04:01:45 AM »
Ok thanks, Ill check it out.

3
TNet 3 Support / Re: Sound question
« on: November 07, 2016, 12:46:12 AM »
Thanks Phoenix, ill check that out. 
Im trying to use the same example as the RFC colored cubes to send my audioclip to everyone in the room and everyone that joins 
TNObject tno = GetComponent<TNObject>();
tno.Send("PlayClip", Target.AllSaved, audioClip);

Though I still cant here any audio on my client.
Heres my code :
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.Audio;
  4. using TNet;
  5. [RequireComponent(typeof(TNObject))]
  6. public class SpawnedSoundObject : TNBehaviour
  7.  
  8. {
  9.     private AudioClip audioClip = null;
  10.     private AudioSource audioSource = null;
  11.                                                             //Audio Filters  
  12.     public float distortionLevel = 0.0f;                    //Distortion
  13.     public float lowPassCutoff = 0.0f;                      //Low Pass Filter
  14.     public float lowPassRes = 0.0f;                         //Low Pass Resonance                                                          
  15.     public float highPassCutoff = 0.0f;                     //High Pass Cuttoff                  
  16.     public float highPassRes = 0.0f;                        //High Pass Res
  17.     public int HighPassFilterOff;                           //HighPassFilter On/Off
  18.     public int LowPassFilterOff;                            //LowPassFilter On/Off
  19.     public int ReverbOff = 0;                               //Reverb On/Off
  20.     public int ReverbPreset = 0;                            //Reverb Preset
  21.     public int SpatialBlend = 0;
  22.     public float spread = 0.0f;
  23.     public float pitch = 1.0f;
  24.  
  25.     public float volume = 1.0f;
  26.     public float minDistance = 0.5f;
  27.     public float maxDistance = 80.0f;
  28.     public float dopplerLevel = 0.1f;
  29.     public int loopCount = 0;
  30.     public int RolloffMode = 0;
  31.     public float DelaySound = 0.0f;
  32.  
  33.  
  34.     //AudioMixer
  35.     public int CleanMixer = 0;    
  36.     public int RadioMixer = 0;
  37.     public int AmbienceMixer = 0;
  38.  
  39.     //AudioMixer SnapShots
  40.     //public int Radio = 0;
  41.     //public int Natural = 0;
  42.  
  43.    
  44.  
  45.     private void OnDestroy()
  46.     {
  47.         if (audioClip != null)
  48.         {
  49.             //Set the mixer to be with no effects
  50.             //AudioMixer mixer = Resources.Load("MainGen4Mixer") as AudioMixer;
  51.             //AudioMixerSnapshot DrySnapShot = mixer.FindSnapshot("Dry");
  52.             //DrySnapShot.TransitionTo(0.01f);
  53.             DestroyImmediate(audioClip);
  54.             audioClip = null;
  55.         }
  56.         else
  57.         {
  58.            
  59.         }
  60.     }
  61.    
  62.     public void LoadFromFile(string file)
  63.     {
  64.         Debug.Log("SpawnedSoundObject.LoadFromFile " + file);
  65.         StartCoroutine(LoadSoundFromFileRoutine(file));
  66.        
  67.     }
  68.  
  69.     private IEnumerator LoadSoundFromFileRoutine(string file)
  70.     {
  71.         WWW fileLoad = new WWW(file);
  72.         yield return fileLoad;
  73.         if (!string.IsNullOrEmpty(fileLoad.error))
  74.         {
  75.             Debug.LogError("Failed to load Sound file " + file);
  76.             yield break;
  77.         }
  78.  
  79.         Debug.Log("Done Sound LoadFromFile " + file);
  80.  
  81.         audioClip = fileLoad.GetAudioClip(true);
  82.  
  83.         StartCoroutine(PlayClip());
  84.        
  85.  
  86.     }
  87.  
  88.     void Awake()
  89.     {
  90.         TNObject tno = GetComponent<TNObject>();
  91.         tno.Send("PlayClip", Target.AllSaved, audioClip);
  92.     }
  93.    
  94.     [RFC]
  95.     private IEnumerator PlayClip()
  96.     {
  97.         if (audioClip)
  98.         {
  99.  
  100.  
  101.  
  102.            
  103.  
  104.             //Get a refrence to our audio mixer
  105.             AudioMixer mixer = Resources.Load("MainGen4Mixer") as AudioMixer;
  106.             string _outPutMixer = "MainGen4Group";
  107.             //Refrence to the radio mixer
  108.             AudioMixer radioMixer = Resources.Load("RadioMixer") as AudioMixer;
  109.             string _outPutRadioMixer = "RadioMixer";
  110.             //Refrence to the ambience mixer for ambience sounds
  111.             AudioMixer ambienceMixer = Resources.Load("AmbienceMixer") as AudioMixer;
  112.             string _outPutAmbienceMixer = "AmbienceMixer";
  113.  
  114.  
  115.             audioSource = gameObject.AddComponent<AudioSource>();
  116.             //Plugg audio source into the Mixer Group
  117.             if (CleanMixer == 1)
  118.             {
  119.                 audioSource.outputAudioMixerGroup = mixer.FindMatchingGroups(_outPutMixer)[0];
  120.             }
  121.  
  122.             if (RadioMixer == 1)
  123.             {
  124.                 audioSource.outputAudioMixerGroup = radioMixer.FindMatchingGroups(_outPutRadioMixer)[0];
  125.             }
  126.  
  127.             if (AmbienceMixer == 1)
  128.             {
  129.                 Debug.Log("Ambience mixer is on");
  130.                 audioSource.outputAudioMixerGroup = ambienceMixer.FindMatchingGroups(_outPutAmbienceMixer)[0];
  131.             }
  132.  
  133.  
  134.             //Set our audiomixer update mode to normal
  135.             //mixer.updateMode = AudioMixerUpdateMode.Normal;
  136.  
  137.             audioSource.volume = volume;
  138.             audioSource.rolloffMode = AudioRolloffMode.Linear;
  139.             audioSource.minDistance = minDistance;
  140.             audioSource.maxDistance = maxDistance;
  141.             audioSource.clip = audioClip;
  142.             audioSource.spatialBlend = 1.0f;            
  143.             audioSource.dopplerLevel = dopplerLevel;
  144.             audioSource.PlayDelayed(DelaySound);
  145.             audioSource.spread = spread;
  146.             audioSource.pitch = pitch;
  147.            
  148.  
  149.             if (RolloffMode == 1)
  150.             {
  151.                 audioSource.rolloffMode = AudioRolloffMode.Logarithmic;
  152.                
  153.             }
  154.  
  155.             if(SpatialBlend == 1)
  156.             {
  157.                 audioSource.spatialBlend = 0.0f;
  158.             }
  159.  
  160.            
  161.             //Distortion
  162.             AudioDistortionFilter distortion = gameObject.AddComponent(typeof(AudioDistortionFilter)) as AudioDistortionFilter;
  163.             distortion.distortionLevel = distortionLevel;
  164.             //Low Pass Filter and High Pass Filter
  165.             AudioLowPassFilter lowPassFilter = gameObject.AddComponent(typeof(AudioLowPassFilter)) as AudioLowPassFilter;
  166.             AudioHighPassFilter highPassFilter = gameObject.AddComponent(typeof(AudioHighPassFilter)) as AudioHighPassFilter;
  167.             if (LowPassFilterOff == 0)
  168.             {
  169.                 Debug.Log("LowPassFilter is Off");
  170.                 lowPassFilter.enabled = false;                
  171.             }
  172.             else if (LowPassFilterOff == 1)
  173.             {
  174.                 Debug.Log("LowPassFilter is On");
  175.                 lowPassFilter.enabled = true;
  176.                 lowPassFilter.cutoffFrequency = lowPassCutoff;
  177.                 lowPassFilter.lowpassResonanceQ = lowPassRes;
  178.             }
  179.             if (HighPassFilterOff == 0)
  180.             {
  181.                 Debug.Log("HighPassFilter is Off");
  182.                 highPassFilter.enabled = false;                
  183.             }
  184.             else if (HighPassFilterOff == 1)
  185.             {
  186.                 Debug.Log("HighPassFilter is On");
  187.                 highPassFilter.enabled = true;
  188.                 highPassFilter.cutoffFrequency = highPassCutoff;
  189.                 highPassFilter.highpassResonanceQ = highPassRes;
  190.             }
  191.             //Reverb Filter
  192.             AudioReverbFilter reverFilter = gameObject.AddComponent(typeof(AudioReverbFilter)) as AudioReverbFilter;
  193.             if (ReverbOff == 0)
  194.             {
  195.                 Debug.Log("Reverb Filter is Off");
  196.                 reverFilter.enabled = false;
  197.             }
  198.             else if (ReverbOff == 1)
  199.             {
  200.                 Debug.Log("Reverb Filter is On");
  201.                 reverFilter.enabled = true;
  202.             }
  203.             //Reverb Presets
  204.             if (ReverbPreset == 1)
  205.             {
  206.                 reverFilter.reverbPreset = AudioReverbPreset.Cave;
  207.             }
  208.             if (ReverbPreset == 2)
  209.             {
  210.                 reverFilter.reverbPreset = AudioReverbPreset.Hangar;
  211.             }
  212.             if (ReverbPreset == 3)
  213.             {
  214.                 reverFilter.reverbPreset = AudioReverbPreset.Mountains;
  215.             }
  216.             if (ReverbPreset == 4)
  217.             {
  218.                 reverFilter.reverbPreset = AudioReverbPreset.Stoneroom;
  219.             }
  220.             if (ReverbPreset == 5)
  221.             {
  222.                 reverFilter.reverbPreset = AudioReverbPreset.Quarry;
  223.             }
  224.             if (ReverbPreset == 6)
  225.             {
  226.                 reverFilter.reverbPreset = AudioReverbPreset.Room;
  227.             }
  228.             if (ReverbPreset == 7)
  229.             {
  230.                 reverFilter.reverbPreset = AudioReverbPreset.StoneCorridor;
  231.             }
  232.             if (ReverbPreset == 8)
  233.             {
  234.                 reverFilter.reverbPreset = AudioReverbPreset.Generic;
  235.             }
  236.  
  237.  
  238.  
  239.             //Audio MixerSnap Shots
  240.             // if (Radio == 1)
  241.             //{
  242.             //    AudioMixerSnapshot RadioSnapShot = mixer.FindSnapshot("Radio");
  243.             //    RadioSnapShot.TransitionTo(.01f);
  244.             //    Debug.Log("Radio Sound On");
  245.             // }
  246.  
  247.             if (loopCount < 0)
  248.             {
  249.                 audioSource.loop = true;
  250.                 audioSource.Play();
  251.                 yield break;
  252.             }
  253.             else if (loopCount == 0)
  254.             {
  255.                 audioSource.PlayOneShot(audioClip);
  256.  
  257.                 yield return null;
  258.                 while (audioSource.isPlaying) yield return null;
  259.             }
  260.             else
  261.             {
  262.                 audioSource.loop = true;
  263.                 audioSource.Play();
  264.  
  265.                 yield return new WaitForSeconds((audioClip.length * 0.5f) + (audioClip.length * (loopCount - 1)));
  266.                 audioSource.loop = false;
  267.                 while (audioSource.isPlaying) yield return null;
  268.             }
  269.  
  270.             Destroy(gameObject);
  271.         }
  272.     }
  273. }
   

4
TNet 3 Support / Re: Sound question
« on: November 06, 2016, 06:14:27 AM »
Awesome! is there a tutorial for this ?

5
TNet 3 Support / Re: Sound question
« on: November 03, 2016, 07:18:17 PM »
Thanks for the reply Aren,  is there a way you could stream the audio to the clients from the host ?

6
TNet 3 Support / Re: Sound question
« on: October 28, 2016, 05:17:22 PM »
Thanks for your reply, I understand what your try to say so how would you go about doing that and surely there must be a way to do it some how.

7
TNet 3 Support / Sound question
« on: October 27, 2016, 03:27:42 AM »
Hi this may sound like a bit of a nube question, but when Im playing as the host, I can here the audio I have put in, but when playing as a client there is no sound, can anyone help, Im using Tnet 2.

8
TNet 3 Support / Re: Loading screen
« on: October 27, 2016, 03:18:51 AM »
Ok thsnks ArenMook, Ill give it a try.

9
TNet 3 Support / Loading screen
« on: October 04, 2016, 02:57:35 AM »
Im having a bit of trouble getting my loading screen to work when a scenario file is called.  Are there any good tutorials for this on this forum ?

Pages: [1]