getMasterChannelGroup() public méthode

public getMasterChannelGroup ( ChannelGroup &channelgroup ) : RESULT
channelgroup ChannelGroup
Résultat RESULT
Exemple #1
0
        private FMODAudioEngine()
        {
            FMODErr.Check(Factory.System_Create(ref _system));

            uint version = 0;

            FMODErr.Check(_system.getVersion(ref version));
            if (version < VERSION.number)
            {
                throw new ApplicationException(
                          "Error! You are using an old version of FMOD "
                          + version.ToString("X")
                          + ". This program requires "
                          + VERSION.number.ToString("X") + ".");
            }

            FMODErr.Check(_system.init(16, INITFLAG.NORMAL, IntPtr.Zero));
            ChannelGroup channelGroup = null;

            FMODErr.Check(_system.getMasterChannelGroup(ref channelGroup));
            _masterChannelGroup = new FMODGrouping(this, channelGroup);

            _scheduler   = new EventLoopScheduler("AudioEngine");
            _updateTimer = Observable.Interval(TimeSpan.FromMilliseconds(UpdateInterval), _scheduler).Do(_ => Update());
        }
Exemple #2
0
    /// <summary>
    /// Initializes a new instance of the <see cref="AudioManager"/> class.
    /// </summary>
    public AudioManager()
    {
        channelGroups = new Dictionary <string, ChannelGroup>();
        Factory.System_Create(out SoundSystem);
        SoundSystem.setDSPBufferSize(1024, 10);
        SoundSystem.init(32, INITFLAGS.NORMAL, (IntPtr)0);
        SoundSystem.getMasterChannelGroup(out master);
        DSPConnection throwaway;

        channelGroups.Add("UI", null);
        channelGroups.Add("gameSounds", null);
        channelGroups.Add("alerts", null);
        channelGroups.Add("music", null);
        foreach (string key in channelGroups.Keys.ToArray())
        {
            ChannelGroup chanGroup;
            SoundSystem.createChannelGroup(key, out chanGroup);
            master.addGroup(chanGroup, true, out throwaway);
            channelGroups[key] = chanGroup;
        }

        channelGroups.Add("master", master);

        SoundSystem.set3DSettings(1f, 1f, .25f);
        audioClips = new Dictionary <string, SoundClip>();
    }
Exemple #3
0
    // Use this for initialization
    void Start () {
        lowLevelSystem = RuntimeManager.LowlevelSystem;
        channel = new FMOD.Channel();
        lowLevelSystem.getMasterChannelGroup(out channelGroup);

        soundInfo = new FMOD.CREATESOUNDEXINFO();
        soundInfo.cbsize = Marshal.SizeOf(soundInfo);
        soundInfo.decodebuffersize = (uint)sampleRate / 10;
        soundInfo.length = (uint)(sampleRate * numberOfChannels * sizeof(short));
        soundInfo.numchannels = numberOfChannels;
        soundInfo.defaultfrequency = sampleRate;
        soundInfo.format = FMOD.SOUND_FORMAT.PCM16;

        soundInfo.pcmreadcallback = PCMReadCallback;
        soundInfo.pcmsetposcallback = PCMSetPositionCallback;

        lowLevelSystem.setStreamBufferSize(65536, FMOD.TIMEUNIT.RAWBYTES);
        lowLevelSystem.createStream("SoundGeneratorStream", FMOD.MODE.OPENUSER, ref soundInfo, out generatedSound);

        generatedSound.setMode(FMOD.MODE.OPENUSER | FMOD.MODE._3D | FMOD.MODE._3D_LINEARSQUAREROLLOFF);

        lowLevelSystem.playSound(generatedSound, channelGroup, true, out channel);
        channel.setLoopCount(-1);
        channel.setMode(FMOD.MODE.LOOP_NORMAL);
        channel.setPosition(0, FMOD.TIMEUNIT.MS);
        channel.set3DMinMaxDistance(minDistance, maxDistance);
        Update();
        channel.setPaused(false);
    }
Exemple #4
0
        /// <summary>
        /// Adjusts the master volume of the game. All audio, including GameSongs and sound effects
        /// are affected by this volume.
        /// </summary>
        /// <param name="volume">The new master volume to use. 0 to mute, 1.0 for maximum volume.</param>
        public void SetMasterVolume(float volume)
        {
            _masterVolume = volume;

            var masterGroup = new ChannelGroup();

            CheckFMODErrors(_fmodSystem.getMasterChannelGroup(ref masterGroup));
            CheckFMODErrors(masterGroup.setVolume(_masterVolume));
        }
Exemple #5
0
        void DrawDebugOverlay(int windowID)
        {
            if (lastDebugUpdate + 0.25f < Time.unscaledTime)
            {
                if (initException != null)
                {
                    lastDebugText = initException.Message;
                }
                else
                {
                    if (!mixerHead.hasHandle())
                    {
                        FMOD.ChannelGroup master;
                        lowlevelSystem.getMasterChannelGroup(out master);
                        master.getDSP(0, out mixerHead);
                        mixerHead.setMeteringEnabled(false, true);
                    }

                    StringBuilder debug = new StringBuilder();

                    FMOD.Studio.CPU_USAGE cpuUsage;
                    studioSystem.getCPUUsage(out cpuUsage);
                    debug.AppendFormat("CPU: dsp = {0:F1}%, studio = {1:F1}%\n", cpuUsage.dspusage, cpuUsage.studiousage);

                    int currentAlloc, maxAlloc;
                    FMOD.Memory.GetStats(out currentAlloc, out maxAlloc);
                    debug.AppendFormat("MEMORY: cur = {0}MB, max = {1}MB\n", currentAlloc >> 20, maxAlloc >> 20);

                    int realchannels, channels;
                    lowlevelSystem.getChannelsPlaying(out channels, out realchannels);
                    debug.AppendFormat("CHANNELS: real = {0}, total = {1}\n", realchannels, channels);

                    FMOD.DSP_METERING_INFO outputMetering;
                    mixerHead.getMeteringInfo(IntPtr.Zero, out outputMetering);
                    float rms = 0;
                    for (int i = 0; i < outputMetering.numchannels; i++)
                    {
                        rms += outputMetering.rmslevel[i] * outputMetering.rmslevel[i];
                    }
                    rms = Mathf.Sqrt(rms / (float)outputMetering.numchannels);

                    float db = rms > 0 ? 20.0f * Mathf.Log10(rms * Mathf.Sqrt(2.0f)) : -80.0f;
                    if (db > 10.0f)
                    {
                        db = 10.0f;
                    }

                    debug.AppendFormat("VOLUME: RMS = {0:f2}db\n", db);
                    lastDebugText   = debug.ToString();
                    lastDebugUpdate = Time.unscaledTime;
                }
            }

            GUI.Label(new Rect(10, 20, 290, 100), lastDebugText);
            GUI.DragWindow();
        }
Exemple #6
0
        public static EqualizerBand GetEqualizerBand(FMOD.System system, bool isActive, float centerValue, float bandwithValue, float gainValue)
        {
            FMOD.DSP dspParamEq = null;

            if (isActive)
            {
                if (!system.createDSPByType(FMOD.DSP_TYPE.PARAMEQ, out dspParamEq).ERRCHECK())
                {
                    return(null);
                }

                FMOD.ChannelGroup masterChannelGroup;
                if (!system.getMasterChannelGroup(out masterChannelGroup).ERRCHECK())
                {
                    return(null);
                }

                int numDSPs;
                if (!masterChannelGroup.getNumDSPs(out numDSPs).ERRCHECK())
                {
                    return(null);
                }

                if (!masterChannelGroup.addDSP(numDSPs, dspParamEq).ERRCHECK())
                {
                    return(null);
                }

                if (!dspParamEq.setParameterFloat((int)FMOD.DSP_PARAMEQ.CENTER, centerValue).ERRCHECK())
                {
                    return(null);
                }

                if (!dspParamEq.setParameterFloat((int)FMOD.DSP_PARAMEQ.BANDWIDTH, bandwithValue).ERRCHECK())
                {
                    return(null);
                }

                if (!dspParamEq.setParameterFloat((int)FMOD.DSP_PARAMEQ.GAIN, gainValue).ERRCHECK())
                {
                    return(null);
                }

                if (!dspParamEq.setActive(true).ERRCHECK())
                {
                    return(null);
                }
            }

            var band = new EqualizerBand(system, dspParamEq, centerValue, gainValue, isActive);

            return(band);
        }
Exemple #7
0
 void Start()
 {
     CubeData.globalColor = Color.red;
     dsps           = new List <FMOD.DSP>();
     singleton      = this;
     playerState    = FMODUnity.RuntimeManager.CreateInstance(PlayerStateEvent);
     lowlevelSystem = FMODUnity.RuntimeManager.LowlevelSystem;
     if (!masterDSP.hasHandle())
     {
         FMOD.ChannelGroup master;
         lowlevelSystem.getMasterChannelGroup(out master);
         master.getDSP(0, out masterDSP);
         masterDSP.setMeteringEnabled(false, true);
     }
     setupLeapMotion();
     currentTime = Time.Start;
 }
Exemple #8
0
        void Start()
        {
            var sounds_path = Path.Combine(TerraWaveMod.assets_path, "Sounds");

            system = RuntimeManager.LowlevelSystem;
            system.getMasterChannelGroup(out master);
            foreach (string file in Directory.EnumerateFiles(sounds_path, "*.wav").Union(Directory.EnumerateFiles(sounds_path, "*.mp3")))
            {
                Console.WriteLine(file);
                sounds.Add(LoadSound(file));
            }
            if (sounds.Count == 0)
            {
                GameObject.DestroyImmediate(this);
                return;
            }
            Singleton.Manager <ManGameMode> .inst.ModeStartEvent.Subscribe(OnModeStart);

            Singleton.Manager <ManGameMode> .inst.ModeCleanUpEvent.Subscribe(OnModeCleanUp);

            useGUILayout = false;
        }
        /*
         *  プロパティ
         */
        #region Property



        #endregion

        /*
         * 静的パブリックメソッド
         */
        #region Static Public Method

        /// <summary>
        /// FMODを初期化する
        /// </summary>
        public void init()
        {
            FMOD.RESULT result;

            result = FMOD.Factory.System_Create(ref system);
            FMODEngine.checkFMODError(result);

            result = system.init(2, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
            FMODEngine.checkFMODError(result);

            // defaultでoutputtypeはwasapiになる。

            result = system.getMasterChannelGroup(ref channelGroup);
            FMODEngine.checkFMODError(result);

            result = system.getMasterSoundGroup(ref soundGroup);
            FMODEngine.checkFMODError(result);


            result = system.createDSPByType(FMOD.DSP_TYPE.NORMALIZE, ref dspNormalize);
            FMODEngine.checkFMODError(result);
        }