예제 #1
0
        private EqualizerBand(FMOD.System system, DSP dspParamEq, float centerValue, float gainValue, bool active)
        {
            this.fmodSystem = system;
            this.dspEQ = dspParamEq;

            if (centerValue >= 1000)
            {
                this.BandCaption = string.Format("{0}K", (centerValue / 1000));
            }
            else
            {
                this.BandCaption = centerValue.ToString(CultureInfo.InvariantCulture);
            }

            this.WhenAnyValue(x => x.Gain)
                .Subscribe(newGain => {
                    if (this.IsActive && this.dspEQ != null)
                    {
                        System.Diagnostics.Debug.WriteLine(">> Gain value: " + newGain);

                        this.dspEQ.setActive(false).ERRCHECK();
                        this.dspEQ.setParameterFloat((int)FMOD.DSP_PARAMEQ.GAIN, newGain).ERRCHECK();
                        this.dspEQ.setActive(true).ERRCHECK();
                        this.fmodSystem.update().ERRCHECK();
                    }
                });

            this.Gain = gainValue;
            this.IsActive = active;
        }
예제 #2
0
        /// <summary>
        /// Readcallback
        /// </summary>
        /// <param name="dsp_state"></param>
        /// <param name="inbuf"></param>
        /// <param name="outbuf"></param>
        /// <param name="length"></param>
        /// <param name="inchannels"></param>
        /// <param name="outchannels"></param>
        /// <returns></returns>
        private static FMOD.RESULT READCALLBACK(ref FMOD.DSP_STATE dsp_state, IntPtr inbuf, IntPtr outbuf, uint length, int inchannels, int outchannels)
        {
            uint count = 0;
            int count2 = 0;
            IntPtr thisdspraw = dsp_state.instance;

            thisdsp.setRaw(thisdspraw);

            unsafe
            {
                float* inbuffer = (float*)inbuf.ToPointer();
                float* outbuffer = (float*)outbuf.ToPointer();

                for (count = 0; count < length; count++)
                {
                    for (count2 = 0; count2 < outchannels; count2++)
                    {
                        outbuffer[(count * outchannels) + count2] = inbuffer[(count * inchannels) + count2];
                    }
                    bpm.AddSample(inbuffer[(count * inchannels)] * 32767.0f);
                }
            }

            return FMOD.RESULT.OK;
        }
예제 #3
0
        public SoundGroup(FMOD.SoundGroup fmodSoundGroup)
        {
            if (fmodSoundGroup == null)
                throw new ArgumentNullException("fmodSoundGroup");

            _fmodGroup = fmodSoundGroup;
        }
예제 #4
0
        public System(FMOD.Studio.System system)
        {
            //Load native dependencies
            Native.Load();

            _system = system;
        }
예제 #5
0
 private Equalizer(FMOD.System system, SMPSettings settings) {
   this.smpSettings = settings;
   this.Name = "DefaultEqualizer";
   this.fmodSystem = system;
   this.Bands = new ObservableCollection<EqualizerBand>();
   this.isEnabled = settings.PlayerSettings.EqualizerSettings == null || settings.PlayerSettings.EqualizerSettings.IsEnabled;
 }
예제 #6
0
        private void Init(FMOD.System system, bool setToDefaultValues = false)
        {
            system.lockDSP().ERRCHECK();

            this.Bands.Clear();
            var gainValues = !setToDefaultValues && this.playerSettings.PlayerEngine.EqualizerSettings != null
                ? this.playerSettings.PlayerEngine.EqualizerSettings.GainValues
                : null;
            foreach (var value in EqDefaultValues)
            {
                var band = EqualizerBand.GetEqualizerBand(system, this.IsEnabled, value[0], value[1], value[2]);
                if (band != null)
                {
                    float savedValue;
                    if (gainValues != null && gainValues.TryGetValue(band.BandCaption, out savedValue))
                    {
                        band.Gain = savedValue;
                    }
                    this.Bands.Add(band);
                }
            }

            system.unlockDSP().ERRCHECK();
            system.update().ERRCHECK();
        }
 static void ERRCHECK(FMOD.RESULT result)
 {
     if (result != FMOD.RESULT.OK)
     {
         Debug.Log("FMOD_Unity: FmodEventImportPostProcessor: " + result + " - " + FMOD.Error.String(result));
      }
 }
예제 #8
0
    public FmodMusicParameter(FMOD.MUSIC_ENTITY cue, FmodMusicSystem musicSystem)
    {
        m_id = (int)cue.id;
        m_name = cue.name;

        m_musicSystem = musicSystem;
    }
예제 #9
0
 internal Sound(FMOD.Sound sound, string file, string name, float volume = 1.0f)
 {
     _sound = sound;
     _file = file;
     _name = name;
     _volume = volume;
 }
예제 #10
0
 public static void CheckResult(FMOD.RESULT result)
 {
     if (result != FMOD.RESULT.OK)
     {
         UnityEngine.Debug.LogError(string.Format("FMOD Studio: Encounterd Error: {0} {1}", result, FMOD.Error.String(result)));
     }
 }
예제 #11
0
        private static FMOD.RESULT FMOD_EVENT_CALLBACK(IntPtr eventraw, FMOD.EVENT_CALLBACKTYPE type, IntPtr param1, IntPtr param2, IntPtr userdata)
        {
            unsafe
            {
                switch (type)
                {
                    case FMOD.EVENT_CALLBACKTYPE.SOUNDDEF_CREATE :
                    {
                        int entryindex   = *(int*)param2.ToPointer() ;     // [in]  (int) index of sound definition entry
                        uint *realpointer = (uint *)param2.ToPointer();    // [out] (FMOD::Sound *) a valid lower level API FMOD Sound handle

                        FMOD.Sound s = null;
                        fsb.getSubSound(entryindex, ref s);

                        *realpointer = (uint)s.getRaw().ToPointer();

                        break;
                    }

                    case FMOD.EVENT_CALLBACKTYPE.SOUNDDEF_RELEASE :
                    {
                        break;
                    }
                }

            }
            return FMOD.RESULT.OK;
        }
예제 #12
0
 internal static String ERRMSG(FMOD.RESULT result)
 {
     if (result != FMOD.RESULT.OK)
     {
         return FMOD.Error.String(result);
     }
     return "";
 }
예제 #13
0
	public FMOD.RESULT onBeat(FMOD.Studio.EVENT_CALLBACK_TYPE type, IntPtr eventInstance, IntPtr parameters) {
		foreach (FMODCallback function in callbacks) {
			function.Invoke(type, eventInstance, parameters);
		}

	    queue.RemoveAll(callback => callback.Invoke(type, eventInstance, parameters));
		return FMOD.RESULT.OK;
	}
예제 #14
0
 public string GetFmodPath(FMOD.Studio.EventInstance fmodEvent)
 {
     FMOD.Studio.EventDescription ed;
     string path;
     fmodEvent.getDescription(out ed);
     ed.getPath(out path);
     return path;
 }
예제 #15
0
    //FMOD error checking codes
    void ERRCHECK(FMOD.RESULT result)
    {
        if (result != FMOD.RESULT.OK)
            {
                Debug.Log("FMOD error! " + result + " - " + FMOD.Error.String(result));

            }
    }
 public FMODChannel(FMOD.Channel channel, bool looping)
 {
     this.channel = channel;
     FMODManager.Instance.SetChannelMapping(channel.getRaw().ToInt32(), this);
     FMODManager.ERRCHECK(channel.setCallback(ChannelCallback));
     if (looping)
         channel.setMode(FMOD.MODE.LOOP_NORMAL);
 }
예제 #17
0
    public FmodMusicCue(FMOD.MUSIC_ENTITY cue, FmodMusicSystem musicSystem)
    {
        m_id = (int)cue.id;
        m_name = cue.name;

        m_musicSystem = musicSystem;
        loadMusicCue();
    }
예제 #18
0
 private void ERRCHECK(FMOD.RESULT result)
 {
     if (result != FMOD.RESULT.OK)
     {
         MessageBox.Show("FMOD error! " + result + " - " + FMOD.Error.String(result));
         Environment.Exit(-1);
     }
 }
예제 #19
0
 private void errCheck(FMOD.RESULT result)
 {
     if (result != FMOD.RESULT.OK)
     {
         //timer.Stop();
         //MessageBox.Show("FMOD error! " + result + " - " + FMOD.Error.String(result));
         Environment.Exit(-1);
     }
 }
    public static FMOD.MUSIC_ENTITY getMusicEntity(FMOD.MUSIC_ITERATOR it)
    {
        FMOD.MUSIC_ENTITY ret = new FMOD.MUSIC_ENTITY();

        if (it.value.ToInt32() != 0) {
            Marshal.PtrToStructure(it.value, ret);
        }
        return (ret);
    }
 public static FMOD.Studio.ParameterInstance GetParameter(FMOD.Studio.EventInstance ev, string parameterName)
 {
     FMOD.Studio.ParameterInstance param;
     if(ev.getParameter(parameterName, out param) != FMOD.RESULT.OK)
     {
         Debug.LogWarning(string.Format("Could not find parameter '{0}' in sound bank", parameterName));
     }
     return param;
 }
예제 #22
0
 /**
  * FMOD error checking util function
 * @return true if error found
 */
 internal static bool ERRCHECK(FMOD.RESULT result)
 {
     if (result != FMOD.RESULT.OK)
     {
         Util.Log("FMOD ERR: " + result + " - " + ERRMSG(result) + "\n" );
         return true;
     }
     return false;
 }
예제 #23
0
 public void StopAll(FMOD.Studio.STOP_MODE stopMode)
 {
     foreach (var instance in instances)
     {
         instance.stop(stopMode);
         instance.release();
     }
     instances.Clear();
 }
예제 #24
0
 public static bool ERRCHECK(this FMOD.RESULT result, FMOD.RESULT ignoredResults = FMOD.RESULT.OK)
 {
     if (result != FMOD.RESULT.OK && !ignoredResults.HasFlag(result))
     {
         MessageBox.Show("FMOD error! " + result + " - " + FMOD.Error.String(result));
         // todo : show better error info dialog
         return false;
     }
     return true;
 }
예제 #25
0
 internal SoundManager(FMOD.System system, bool hardware = true)
 {
     _log = Logging.LogManager.GetLogger(this);
     _log.Info("Initializing SoundManager...");
     _system = system;
     _sounds = new List<Sound>();
     _soundMode = hardware ? MODE.HARDWARE : MODE.SOFTWARE;
     _log.DebugFormat("Sound Mode == {0}", _soundMode);
     _log.Debug("SoundManager initialized!");
 }
예제 #26
0
    public FMOD.Studio.EventInstance GetEventCopy(FMOD.Studio.EventInstance fmodEvent)
    {
        FMOD.Studio.EventDescription ev;
        fmodEvent.getDescription (out ev);

        string path;
        ev.getPath (out path);

        return  FMOD_StudioSystem.instance.GetEvent(path);
    }
예제 #27
0
    private void DeInit(FMOD.System system) {
      var result = system.lockDSP();
      result.ERRCHECK();

      foreach (var band in this.Bands) {
        band.Remove();
      }

      result = system.unlockDSP();
      result.ERRCHECK();
    }
예제 #28
0
    public FMOD.RESULT StudioEventCallback(FMOD.Studio.EVENT_CALLBACK_TYPE type, IntPtr eventInstance, IntPtr parameters)
    {
        if (type == FMOD.Studio.EVENT_CALLBACK_TYPE.TIMELINE_BEAT) {
            FMOD.Studio.TIMELINE_BEAT_PROPERTIES beat = (FMOD.Studio.TIMELINE_BEAT_PROPERTIES)Marshal.PtrToStructure (parameters, typeof(FMOD.Studio.TIMELINE_BEAT_PROPERTIES));
            print ("beat");
            beatOn = true;

        }
        else
            beatOn = false;
        return FMOD.RESULT.OK;
    }
예제 #29
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;
        }
예제 #30
0
 public void Update(FMOD.ATTRIBUTES_3D attributes)
 {
     // Cull finished instances
     FMOD.Studio.PLAYBACK_STATE state;
     var finishedInstances = instances.FindAll((x) => { x.getPlaybackState(out state); return state == FMOD.Studio.PLAYBACK_STATE.STOPPED; });
     foreach (var instance in finishedInstances)
     {
         instance.release();
     }
     instances.RemoveAll((x) => !x.isValid());
     
     // Update 3D attributes
     foreach(var instance in instances)
     {
         instance.set3DAttributes(attributes);
     }
 }