/// Initializes the audio system with the current audio configuration.
    /// @note This should only be called from the main Unity thread.
    public static void Initialize(CardboardAudioListener listener, Quality quality)
    {
        if (!initialized)
        {
            // Initialize the audio system.
#if UNITY_4_5 || UNITY_4_6 || UNITY_4_7
            sampleRate  = AudioSettings.outputSampleRate;
            numChannels = (int)AudioSettings.speakerMode;
            int numBuffers = -1;
            AudioSettings.GetDSPBufferSize(out framesPerBuffer, out numBuffers);
#else
            AudioConfiguration config = AudioSettings.GetConfiguration();
            sampleRate      = config.sampleRate;
            numChannels     = (int)config.speakerMode;
            framesPerBuffer = config.dspBufferSize;
#endif
            if (numChannels != (int)AudioSpeakerMode.Stereo)
            {
                Debug.LogError("Only 'Stereo' speaker mode is supported by Cardboard.");
                return;
            }
            Initialize(quality, sampleRate, numChannels, framesPerBuffer);
            listenerTransform = listener.transform;
            initialized       = true;

            Debug.Log("Cardboard audio system is initialized (Quality: " + quality + ", Sample Rate: " +
                      sampleRate + ", Channels: " + numChannels + ", Frames Per Buffer: " +
                      framesPerBuffer + ").");
        }
        else if (listener.transform != listenerTransform)
        {
            Debug.LogError("Only one CardboardAudioListener component is allowed in the scene.");
            //CardboardAudioListener.Destroy(listener);
        }
    }
  /// Initializes the audio system with the current audio configuration.
  /// @note This should only be called from the main Unity thread.
  public static void Initialize (CardboardAudioListener listener, Quality quality) {
    if (!initialized) {
      // Initialize the audio system.
#if UNITY_4_5 || UNITY_4_6 || UNITY_4_7
      sampleRate = AudioSettings.outputSampleRate;
      numChannels = (int)AudioSettings.speakerMode;
      int numBuffers = -1;
      AudioSettings.GetDSPBufferSize(out framesPerBuffer, out numBuffers);
#else
      AudioConfiguration config = AudioSettings.GetConfiguration();
      sampleRate = config.sampleRate;
      numChannels = (int)config.speakerMode;
      framesPerBuffer = config.dspBufferSize;
#endif
      if (numChannels != (int)AudioSpeakerMode.Stereo) {
        Debug.LogError("Only 'Stereo' speaker mode is supported by Cardboard.");
        return;
      }
      Initialize(quality, sampleRate, numChannels, framesPerBuffer);
      listenerTransform = listener.transform;
      initialized = true;

      Debug.Log("Cardboard audio system is initialized (Quality: " + quality + ", Sample Rate: " +
                sampleRate + ", Channels: " + numChannels + ", Frames Per Buffer: " +
                framesPerBuffer + ").");
    } else if (listener.transform != listenerTransform) {
      Debug.LogError("Only one CardboardAudioListener component is allowed in the scene.");
      CardboardAudioListener.Destroy(listener);
    }
  }
Ejemplo n.º 3
0
    /// Initializes the audio system with the current audio configuration.
    /// @note This should only be called from the main Unity thread.
    public static void Initialize(CardboardAudioListener listener, Quality quality)
    {
        if (!initialized)
        {
#if !UNITY_EDITOR && UNITY_ANDROID
            SetApplicationState();
#endif
            // Initialize the audio system.
            AudioConfiguration config = AudioSettings.GetConfiguration();
            sampleRate      = config.sampleRate;
            numChannels     = (int)config.speakerMode;
            framesPerBuffer = config.dspBufferSize;
            if (numChannels != (int)AudioSpeakerMode.Stereo)
            {
                Debug.LogError("Only 'Stereo' speaker mode is supported by Cardboard.");
                return;
            }
            Initialize(quality, sampleRate, numChannels, framesPerBuffer);
            listenerTransform = listener.transform;

            initialized = true;
        }
        else if (listener.transform != listenerTransform)
        {
            Debug.LogError("Only one CardboardAudioListener component is allowed in the scene.");
            CardboardAudioListener.Destroy(listener);
        }
    }
Ejemplo n.º 4
0
  /// Shuts down the audio system.
  /// @note This should only be called from the main Unity thread.
  public static void Shutdown (CardboardAudioListener listener) {
    if (initialized && listener.transform == listenerTransform) {
      initialized = false;

      Shutdown();
      sampleRate = -1;
      numChannels = -1;
      framesPerBuffer = -1;
    }
  }
Ejemplo n.º 5
0
    /// Shuts down the audio system.
    /// @note This should only be called from the main Unity thread.
    public static void Shutdown(CardboardAudioListener listener)
    {
        if (initialized && listener.transform == listenerTransform)
        {
            initialized = false;

            Shutdown();
            sampleRate      = -1;
            numChannels     = -1;
            framesPerBuffer = -1;
        }
    }
    /// Shuts down the audio system.
    /// @note This should only be called from the main Unity thread.
    public static void Shutdown(CardboardAudioListener listener)
    {
        if (initialized && listener.transform == listenerTransform)
        {
//      initialized = false;
//
//      //Shutdown();
//      sampleRate = -1;
//      numChannels = -1;
//      framesPerBuffer = -1;

            Debug.Log("Cardboard audio system is shutdown.");
        }
    }
Ejemplo n.º 7
0
  /// Initializes the audio system with the current audio configuration.
  /// @note This should only be called from the main Unity thread.
  public static void Initialize (CardboardAudioListener listener, Quality quality) {
    if (!initialized) {
#if !UNITY_EDITOR && UNITY_ANDROID
      SetApplicationState();
#endif
      // Initialize the audio system.
      AudioConfiguration config = AudioSettings.GetConfiguration();
      sampleRate = config.sampleRate;
      numChannels = (int)config.speakerMode;
      framesPerBuffer = config.dspBufferSize;
      if (numChannels != (int)AudioSpeakerMode.Stereo) {
        Debug.LogError("Only 'Stereo' speaker mode is supported by Cardboard.");
        return;
      }
      Initialize(quality, sampleRate, numChannels, framesPerBuffer);
      listenerTransform = listener.transform;

      initialized = true;
    } else if (listener.transform != listenerTransform) {
      Debug.LogError("Only one CardboardAudioListener component is allowed in the scene.");
      CardboardAudioListener.Destroy(listener);
    }
  }