Ejemplo n.º 1
0
        public GameContainer()
        {
            Graphics = new GraphicsDeviceManager(this);

            Graphics.PreferMultiSampling       = true;
            Graphics.PreferredBackBufferHeight = 600;
            Graphics.PreferredBackBufferWidth  = 800;

            Graphics.MinimumPixelShaderProfile  = ShaderProfile.PS_3_0;
            Graphics.MinimumVertexShaderProfile = ShaderProfile.VS_3_0;

            ContentManager = Content;

            Window.Title = "Shaken, not stirred.     (Jacob H. Hansen @ LD11)";

            this.IsMouseVisible = true;

            // fmod bullshit
            FMOD.Factory.System_Create(ref SoundSystem);
            SoundSystem.init(32, FMOD.INITFLAG.NORMAL, (IntPtr)null);

            SoundSystem.createSound("nectar\\music\\shrt-beat2.ogg", FMOD.MODE.HARDWARE, ref tunes[0]);
            SoundSystem.createSound("nectar\\music\\shrt-vildere_lort.ogg", FMOD.MODE.HARDWARE, ref tunes[1]);
            SoundSystem.createSound("nectar\\music\\shrt-sving_om.ogg", FMOD.MODE.HARDWARE, ref tunes[2]);
            SoundSystem.createSound("nectar\\music\\shrt-beat3.ogg", FMOD.MODE.HARDWARE, ref tunes[3]);

            foreach (FMOD.Sound s in tunes)
            {
                s.setMode(FMOD.MODE.LOOP_NORMAL);
            }
        }
Ejemplo n.º 2
0
        private void PlaySound_Load(object sender, System.EventArgs e)
        {
            uint version = 0;

            FMOD.RESULT result;

            /*
             *  Create a System object and initialize.
             */
            result = FMOD.Factory.System_Create(ref system);
            ERRCHECK(result);

            result = system.getVersion(ref version);
            ERRCHECK(result);
            if (version < FMOD.VERSION.number)
            {
                MessageBox.Show("Error!  You are using an old version of FMOD " + version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
                Application.Exit();
            }

            result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
            ERRCHECK(result);

            result = system.createSound("../../../../../examples/media/drumloop.wav", FMOD.MODE.HARDWARE, ref sound1);
            ERRCHECK(result);

            result = sound1.setMode(FMOD.MODE.LOOP_OFF);
            ERRCHECK(result);

            result = system.createSound("../../../../../examples/media/jaguar.wav", FMOD.MODE.SOFTWARE, ref sound2);
            ERRCHECK(result);

            result = system.createSound("../../../../../examples/media/swish.wav", FMOD.MODE.HARDWARE, ref sound3);
            ERRCHECK(result);
        }
Ejemplo n.º 3
0
        private void LoadSounds()
        {
            FMOD.RESULT result;

            sounds[0] = new FMOD.Sound();
            result    = system.createSound("FancyPants.wav", FMOD.MODE.HARDWARE, ref sounds[0]);
            ERRCHECK(result);
        }
Ejemplo n.º 4
0
        public void LoadSounds()
        {
            if (!isInitialized)
            {
                return;
            }

            FMOD.RESULT result;

            this.Volume = InitializationSettings.Instance.SoundVolume;
            if (InitializationSettings.Instance.IsSoundMuted)
            {
                this.Mute();
            }

            FMOD.Sound sound = null;

            foreach (MiscSoundType miscType in Enum.GetValues(typeof(MiscSoundType)))
            {
                sound  = new FMOD.Sound();
                result = system.createSound(Settings.Default.SoundMisc + GetFileName(miscType), FMOD.MODE.HARDWARE, ref sound);
                if (!FMOD.ERROR.ERRCHECK(result))
                {
                    InfoLog.WriteError(GetFileName(miscType) + ": " + FMOD.ERROR.String(result), EPrefix.AudioEngine);
                }
                misc[(short)miscType] = sound;
            }

            foreach (short houseId in GlobalSettings.Instance.GetHouseIDs())
            {
                FMOD.Sound[] tableHouse = new FMOD.Sound[Enum.GetValues(typeof(HouseSoundType)).Length];

                foreach (HouseSoundType houseType in Enum.GetValues(typeof(HouseSoundType)))
                {
                    sound  = new FMOD.Sound();
                    result = system.createSound(Settings.Default.Sound + GlobalSettings.Instance.GetHouseName(houseId) + "/" + GetFileName(houseType), FMOD.MODE.HARDWARE, ref sound);
                    if (!FMOD.ERROR.ERRCHECK(result))
                    {
                        InfoLog.WriteError(GetFileName(houseType) + ": " + FMOD.ERROR.String(result), EPrefix.AudioEngine);
                    }
                    tableHouse[(short)houseType] = sound;
                }

                houses.Add(houseId, tableHouse);
            }

            InfoLog.WriteInfo("Finished loading sounds", EPrefix.AudioEngine);
        }
Ejemplo n.º 5
0
        public void UpdateSound(string name, ref FMOD.Sound s, Boolean Loop)
        {
            FMOD.RESULT result;
            string      strNameSpace =
                System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString();

            Stream str = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(strNameSpace + ".Sounds." + name);

            //Block = new Bitmap(str);
            byte[] Arr = new byte[str.Length];
            str.Read(Arr, 0, (int)str.Length);
            FMOD.CREATESOUNDEXINFO inf = new FMOD.CREATESOUNDEXINFO();
            inf.cbsize = Marshal.SizeOf(inf);
            inf.length = (uint)str.Length;

            result = soundsystem.createSound(Arr, FMOD.MODE.SOFTWARE | FMOD.MODE.OPENMEMORY | FMOD.MODE._3D, ref inf, ref s);
            ERRCHECK(result);

            if (!Loop)
            {
                s.setMode(FMOD.MODE.LOOP_OFF);
            }
            else
            {
                s.setMode(FMOD.MODE.LOOP_NORMAL);
            }

            ERRCHECK(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Play a new BGM in the BGM channel.
        /// </summary>
        /// <param name="file">The file containing the BGM</param>
        public void PlayBGM(string file)
        {
            //If file doesn exist
            if (!FlatRedBall.IO.FileManager.FileExists(Global.BGM_FOLDER + file))
            {
                //Log it then get out
                Global.Logger.AddLine(Global.NOFILE_ERROR + file);
                return;
            }

            //Stop bgm if it exist
            if (m_BGMChannel != null)
            {
                CheckError(m_BGMChannel.stop());
            }

            //Create and play bgm
            #region BGM Playing
            CheckError(m_System.createSound(Global.BGM_FOLDER + file, MODE.LOOP_NORMAL | MODE._2D | MODE.HARDWARE, ref m_BGM));
            CheckError(m_System.playSound(CHANNELINDEX.REUSE, m_BGM, true, ref m_BGMChannel));
            CheckError(m_BGMChannel.setPaused(false));
            #endregion

            //Logging info
            Global.Logger.AddLine("BGM file " + file + " is loaded and played.");
        }
Ejemplo n.º 7
0
        private void PlayStream_Load(object sender, System.EventArgs e)
        {
            uint version = 0;

            FMOD.RESULT result;

            /*
             *  Global Settings
             */
            result = FMOD.Factory.System_Create(ref system);
            ERRCHECK(result);

            result = system.getVersion(ref version);
            ERRCHECK(result);
            if (version < FMOD.VERSION.number)
            {
                MessageBox.Show("Error!  You are using an old version of FMOD " + version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
                Application.Exit();
            }

            result = system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
            ERRCHECK(result);

            result = system.createSound("../../../../../examples/media/wave.mp3", (FMOD.MODE._2D | FMOD.MODE.HARDWARE | FMOD.MODE.CREATESTREAM), ref sound);
            ERRCHECK(result);
        }
        private void Form1_Load(object sender, System.EventArgs e)
        {
            uint version = 0;

            FMOD.RESULT result;
            int         length;

            FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO();

            /*
             *  Global Settings
             */
            result = FMOD.Factory.System_Create(ref system);
            ERRCHECK(result);

            result = system.getVersion(ref version);
            ERRCHECK(result);
            if (version < FMOD.VERSION.number)
            {
                MessageBox.Show("Error!  You are using an old version of FMOD " + version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
                Application.Exit();
            }

            result = system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
            ERRCHECK(result);

            length = LoadFileIntoMemory("../../../../../examples/media/wave.mp3");

            exinfo.cbsize = Marshal.SizeOf(exinfo);
            exinfo.length = (uint)length;

            result = system.createSound(audiodata, (FMOD.MODE.HARDWARE | FMOD.MODE.OPENMEMORY), ref exinfo, ref sound);
            ERRCHECK(result);
        }
        private void playButton_Click(object sender, System.EventArgs e)
        {
            FMOD.RESULT result;

            if (!soundcreated)
            {
                statusBar.Text = "Buffering...";

                url = textBox.Text;

                result = system.createSound(url, (FMOD.MODE.HARDWARE | FMOD.MODE._2D | FMOD.MODE.CREATESTREAM | FMOD.MODE.NONBLOCKING), ref sound);
                ERRCHECK(result);

                soundcreated = true;
            }
        }
Ejemplo n.º 10
0
        private void comboBoxRecord_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO();
            FMOD.RESULT            result;
            selected = comboBoxRecord.SelectedIndex;

            comboBoxOutput.Enabled = false;
            comboBoxRecord.Enabled = false;

            /*
             *  Initialise
             */
            result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
            ERRCHECK(result);

            exinfo.cbsize           = Marshal.SizeOf(exinfo);
            exinfo.numchannels      = 2;
            exinfo.format           = FMOD.SOUND_FORMAT.PCM16;
            exinfo.defaultfrequency = 44100;
            exinfo.length           = (uint)(exinfo.defaultfrequency * 2 * exinfo.numchannels * 2);

            result = system.createSound((string)null, (FMOD.MODE._2D | FMOD.MODE.SOFTWARE | FMOD.MODE.OPENUSER), ref exinfo, ref sound);
            ERRCHECK(result);

            start.Enabled = true;
        }
Ejemplo n.º 11
0
        // ========================================================================================================================================
        #region Start / Stop

        void StartFMODSound(int sampleRate)
        {
            this.StopFMODSound();

            FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO();
            // exinfo.cbsize = sizeof(FMOD.CREATESOUNDEXINFO);
            exinfo.numchannels       = this.unityOAFRChannels;                                                              /* Number of channels in the sound. */
            exinfo.defaultfrequency  = sampleRate;                                                                          /* Default playback rate of sound. */
            exinfo.decodebuffersize  = (uint)this.unityOAFRDataLength;                                                      /* Chunk size of stream update in samples. This will be the amount of data passed to the user callback. */
            exinfo.length            = (uint)(exinfo.defaultfrequency * exinfo.numchannels * this.elementSize);             /* Length of PCM data in bytes of whole song (for Sound::getLength) */
            exinfo.format            = FMOD.SOUND_FORMAT.PCM16;                                                             /* Data format of sound. */
            exinfo.pcmreadcallback   = this.pcmreadcallback;                                                                /* User callback for reading. */
            exinfo.pcmsetposcallback = this.pcmsetposcallback;                                                              /* User callback for seeking. */

            result = system.createSound(""
                                        , FMOD.MODE.OPENUSER
                                        | FMOD.MODE.CREATESTREAM
                                        | FMOD.MODE.LOOP_NORMAL
                                        , ref exinfo
                                        , out sound);
            AudioStreamSupport.ERRCHECK(result, this.logLevel, this.gameObjectName, null, "system.createSound");

            AudioStreamSupport.LOG(LogLevel.DEBUG, this.logLevel, this.gameObjectName, null, "About to play...");

            result = system.playSound(sound, null, false, out channel);
            AudioStreamSupport.ERRCHECK(result, this.logLevel, this.gameObjectName, null, "system.playSound");
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Prepares media for playback
        /// </summary>
        /// <param name="filename"></param>
        private void LoadMedia(PlayListEntry entry)
        {
            FMOD.RESULT result;

            //load a new sound
            result = _system.createSound(entry.FileName, FMOD.MODE._2D | FMOD.MODE.NONBLOCKING | FMOD.MODE.CREATESTREAM, out _sound);
            CheckError(result);

            //how to determine the media is ready? an event perhaps?
            FMOD.OPENSTATE openState;
            uint           percentBuffered;
            bool           starving;
            bool           diskBusy;

            //check to see if it is ready
            _sound.getOpenState(out openState, out percentBuffered, out starving, out diskBusy);

            //check state
            while (openState == FMOD.OPENSTATE.LOADING)
            {
                _sound.getOpenState(out openState, out percentBuffered, out starving, out diskBusy);
                Thread.Sleep(25);
            }

            Length = GetLength();
        }
Ejemplo n.º 13
0
 public void Play(string name, byte[] soundBuf)
 {
     FMOD.CREATESOUNDEXINFO sndInfo = new FMOD.CREATESOUNDEXINFO()
     {
         length = (uint)soundBuf.Length,
     };
     FMOD.RESULT result = system.createSound(soundBuf, FMOD.MODE.OPENMEMORY, ref sndInfo, out sound);
     ERRCHECK(result, "system.createSound");
     if (result == FMOD.RESULT.OK)
     {
         int numSubSounds;
         result = sound.getNumSubSounds(out numSubSounds);
         ERRCHECK(result, "sound.getNumSubSounds");
         if (numSubSounds > 0)
         {
             result = sound.getSubSound(0, out subSound);
             ERRCHECK(result, "sound.getSubSound");
             result = system.playSound(subSound, null, false, out channel);
         }
         else
         {
             result = system.playSound(sound, null, false, out channel);
         }
         ERRCHECK(result, "sound.playSound");
     }
 }
Ejemplo n.º 14
0
        public static void Load(Dictionary <string, string> audioFileNames)
        {
            FMOD.RESULT result;
            FMOD.Sound  tmpSound;

            foreach (KeyValuePair <string, string> file in audioFileNames)
            {
                tmpSound = null;
                //LOAD IN PATHS OF AUDIO FILES
                string soundPath = "../../../../FluxContent/audio/" + file.Value;

                if (File.Exists(soundPath))
                {
                    //RUN FOR EACH SOUND FILE
                    result = system.createSound(soundPath, (FMOD.MODE.SOFTWARE | FMOD.MODE._2D), ref tmpSound);
                    ERRCHECK(result);
                    sounds[file.Key] = tmpSound;
                    result           = sounds[file.Key].setMode(FMOD.MODE.LOOP_OFF);
                    ERRCHECK(result);
                }
                else
                {
                    Console.WriteLine("FILE NOT FOUND: " + file.Value);
                }
            }
        }
Ejemplo n.º 15
0
        /*-----------------------------------------------*/
        /* Load Sound from audio file path and return it */
        /*-----------------------------------------------*/
        public FMOD.Sound LoadSound(string soundPath)
        {
            string soundName = Path.GetFileName(soundPath);

            //If sound is already loaded, returns it
            if (_sounds.ContainsKey(soundName))
            {
                return(_sounds[soundName]);
            }
            //Otherwise, sound creation
            else
            {
                FMOD.Sound sound;

                FMOD.RESULT result;
                result = _fmodSystem.createSound(soundPath, FMOD.MODE._3D, out sound);
                if (result != FMOD.RESULT.OK)
                {
                    Console.WriteLine("[AudioMaster LoadSong] FMOD createStream failed : " + result);
                }

                result = sound.set3DMinMaxDistance(2.0f * distanceFactor, 5000.0f * distanceFactor);
                if (result != FMOD.RESULT.OK)
                {
                    Console.WriteLine("[AudioMaster LoadSound] FMOD set3DMinMaxDistance failed : " + result);
                }

                _sounds.Add(soundName, sound);
                return(sound);
            }
        }
Ejemplo n.º 16
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            FMOD.RESULT result;

            if (!soundcreated)
            {
                result = system.createSound(
                    (string)null,
                    (mode | FMOD.MODE.CREATESTREAM),
                    ref createsoundexinfo,
                    ref sound);
                ERRCHECK(result);

                soundcreated = true;
            }
            system.playSound(FMOD.CHANNELINDEX.FREE, sound, false, ref channel);
        }
Ejemplo n.º 17
0
        public FMOD_SoundBuffer(FMOD_Audio audio, string filename)
        {
            mAudio  = audio;
            mSystem = mAudio.FMODSystem;


            FMOD_Audio.CheckFMODResult(mSystem.createSound(filename, FMOD.MODE.DEFAULT, ref mSound));
        }
Ejemplo n.º 18
0
        private void loadSound(string name)
        {
            FMOD.RESULT res = system.createSound(name, (FMOD.MODE._2D | FMOD.MODE.HARDWARE | FMOD.MODE.CREATESTREAM), ref fsb);

            if (res != FMOD.RESULT.OK)
            {
                MessageBox.Show("Cannot load file.  Reason: " + res.ToString(), "FMOD Load Error", MessageBoxButtons.OK);
            }
        }
Ejemplo n.º 19
0
        private void StreamInit(string connectionUrl, FMOD.SOUND_PCMREADCALLBACK pcmReadCallback, FMOD.SOUND_PCMSETPOSCALLBACK pcmSetPosCallback) // loading stream data
        {
            thisLock        = new Object();
            SoundDataBuffer = new CircularBuffer(defaultSize);

            FMOD.CREATESOUNDEXINFO exInfo = new FMOD.CREATESOUNDEXINFO();
            exInfo.cbsize = Marshal.SizeOf(exInfo);
            //   exInfo.length = (uint)(SoundDataBuffer.Buffer.Length * sizeof(short));
            exInfo.numchannels       = channelCount;
            exInfo.fileoffset        = 0;
            exInfo.format            = FMOD.SOUND_FORMAT.PCM16;
            exInfo.defaultfrequency  = frequency;
            exInfo.pcmreadcallback   = pcmReadCallback;
            exInfo.pcmsetposcallback = pcmSetPosCallback;
            exInfo.dlsname           = null;

            FMOD.RESULT result = system.createSound(connectionUrl, (FMOD.MODE.HARDWARE | FMOD.MODE._2D | FMOD.MODE.CREATESTREAM | FMOD.MODE.NONBLOCKING), ref exInfo, ref sounds);
            ErrorCheck(result);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Load and play a sound at a given location.
        /// </summary>
        /// <param name="p_filename">Path to a supported sound file.</param>
        /// <param name="p_bLooped">Whether or not to loop playback.</param>
        /// <returns></returns>
        public bool LoadSound(string p_filename, bool p_bLooped, out FMOD.Sound o_sound)
        {
            FMOD.RESULT r = m_fmodSystem.createSound(
                p_filename,
                p_bLooped? FMOD.MODE.LOOP_NORMAL : FMOD.MODE.LOOP_OFF,
                out o_sound
                );

            return(r == FMOD.RESULT.OK);
        }
Ejemplo n.º 21
0
        protected FMOD.Sound GetSound(string name, bool ambient, bool local)
        {
            Dictionary <string, FMOD.Sound> soundDict;

            FMOD.Sound sound;
            FMOD.MODE  mode;
            if (ambient)
            {
                soundDict = ambientSounds;
                mode      = FMOD.MODE.DEFAULT;
            }
            else
            {
                soundDict = positionalSounds;
                mode      = FMOD.MODE._3D;
            }

            if (soundDict.ContainsKey(name))
            {
                sound = soundDict[name];
            }
            else
            {
                if (local)
                {
                    // Ask the resource manager where the file is (check any common asset directory)
                    string filename = ResourceManager.ResolveCommonResourceData(name);

                    FileInfo info = new FileInfo(filename);

                    sound = null;
                    if (info.Length > 200000)
                    {
                        FMOD.RESULT result = fmod.createStream(filename, mode, ref sound);
                        CheckResults(result);
                    }
                    else
                    {
                        FMOD.RESULT result = fmod.createSound(filename, mode, ref sound);
                        CheckResults(result);
                    }
                }
                else
                {
                    sound = null;
                    log.DebugFormat("before playing non-local sound: {0}", name);
                    FMOD.RESULT result = fmod.createStream(name, mode, ref sound);
                    log.DebugFormat("after playing non-local sound: {0}", name);
                    CheckResults(result);
                }
                soundDict.Add(name, sound);
            }

            return(sound);
        }
Ejemplo n.º 22
0
        public About()
        {
            img = Properties.Resources.nfo;
            img.MakeTransparent(Color.Black);

            InitializeComponent();

            exInfo.cbsize = Marshal.SizeOf(exInfo);
            exInfo.length = (uint)Properties.Resources.teh.Length;

            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.Opaque, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            int step = 5;

            Color color = Color.FromArgb(255, 0, 0);

            customSpectrum.AddRange(Ext.Interpolate(ColorEnum.Green, ChangeEnum.Higher, color, step));

            color = Color.FromArgb(255, 255, 0);
            customSpectrum.AddRange(Ext.Interpolate(ColorEnum.Red, ChangeEnum.Lower, color, step));

            color = Color.FromArgb(0, 255, 0);
            customSpectrum.AddRange(Ext.Interpolate(ColorEnum.Blue, ChangeEnum.Higher, color, step));

            color = Color.FromArgb(0, 255, 255);
            customSpectrum.AddRange(Ext.Interpolate(ColorEnum.Green, ChangeEnum.Lower, color, step));

            color = Color.FromArgb(0, 0, 255);
            customSpectrum.AddRange(Ext.Interpolate(ColorEnum.Red, ChangeEnum.Higher, color, step));

            color = Color.FromArgb(255, 0, 255);
            customSpectrum.AddRange(Ext.Interpolate(ColorEnum.Blue, ChangeEnum.Lower, color, step));

            DoubleBuffered = true;

            this.Width = img.Width;
            y          = -this.Height;

            FMOD.Factory.System_Create(ref soundSystem);

            soundSystem.init(32, FMOD.INITFLAG.NORMAL | FMOD.INITFLAG.WASAPI_EXCLUSIVE, IntPtr.Zero);
            soundSystem.createSound(Properties.Resources.teh, FMOD.MODE.SOFTWARE | FMOD.MODE._2D | FMOD.MODE.OPENMEMORY | FMOD.MODE.ACCURATETIME | FMOD.MODE.LOOP_NORMAL, ref exInfo, ref sound);
            soundSystem.playSound(FMOD.CHANNELINDEX.REUSE, sound, false, ref soundChannel);

            soundChannel.setVolume(.75f);

            tmr.Interval = 25;
            tmr.Tick    += new EventHandler(tmr_Tick);

            tmr.Start();
        }
Ejemplo n.º 23
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            uint version = 0;

            FMOD.RESULT result;

            /*
             *  Create a System object and initialize.
             */
            result = FMOD.Factory.System_Create(ref system);
            ERRCHECK(result);

            result = system.getVersion(ref version);
            ERRCHECK(result);
            if (version < FMOD.VERSION.number)
            {
                MessageBox.Show("Error!  You are using an old version of FMOD " + version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
                Application.Exit();
            }

            result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
            ERRCHECK(result);

            result = system.createSound("../../../../../examples/media/drumloop.wav", FMOD.MODE.SOFTWARE | FMOD.MODE.LOOP_NORMAL, ref sound);
            ERRCHECK(result);

            result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, false, ref channel);
            ERRCHECK(result);

            /*
             *  Create DSP unit
             */

            cohar[] nameArray = new char[32];
            dspname.ToCharArray().CopyTo(nameArray, 0);

            dspdesc.name     = nameArray;
            dspdesc.channels = 0;
            dspdesc.read     = dspreadcallback;

            result = system.createDSP(ref dspdesc, ref mydsp);
            ERRCHECK(result);

            result = system.addDSP(mydsp, ref dspconnectiontemp);
            ERRCHECK(result);

            result = mydsp.setActive(true);
            ERRCHECK(result);

            result = mydsp.setBypass(true);
            ERRCHECK(result);
        }
Ejemplo n.º 24
0
 public FMOD.Sound LoadSound(string path, FMOD.MODE mode = FMOD.MODE._2D)
 {
     FMOD.Sound  sound;
     FMOD.RESULT res = soundSystem.createSound(path, mode, out sound);
     if (res == FMOD.RESULT.OK)
     {
         return(sound);
     }
     else
     {
         throw new Exceptions.LoadFailException(FMOD.Error.String(res) + "    File name: " + path);
     }
 }
Ejemplo n.º 25
0
        private void MultiSpeakerOutput_Load(object sender, System.EventArgs e)
        {
            uint version = 0;

            FMOD.RESULT result;

            /*
             *  Create a System object and initialize.
             */
            result = FMOD.Factory.System_Create(ref system);
            ERRCHECK(result);

            result = system.getVersion(ref version);
            ERRCHECK(result);
            if (version < FMOD.VERSION.number)
            {
                MessageBox.Show("Error!  You are using an old version of FMOD " + version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
                Application.Exit();
            }

            /*
             * Choose the highest mode possible.
             * If the user doesn't have 7.1 speakers, then only the speakers they have will be audible.
             */
            system.setSpeakerMode(FMOD.SPEAKERMODE._7POINT1);
            ERRCHECK(result);

            result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
            ERRCHECK(result);

            result = system.createSound("../../../../../examples/media/drumloop.wav", (FMOD.MODE.SOFTWARE | FMOD.MODE._2D), ref sound1);
            ERRCHECK(result);
            result = sound1.setMode(FMOD.MODE.LOOP_OFF);
            ERRCHECK(result);

            result = system.createSound("../../../../../examples/media/stereo.ogg", (FMOD.MODE.SOFTWARE | FMOD.MODE._2D), ref sound2);
            ERRCHECK(result);
        }
Ejemplo n.º 26
0
        private void comboBoxRecord_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO();
            FMOD.RESULT            result;
            FMOD.DSP_RESAMPLER     resampler = FMOD.DSP_RESAMPLER.MAX;
            int selected = comboBoxRecord.SelectedIndex;
            int temp     = 0;

            FMOD.SOUND_FORMAT format = FMOD.SOUND_FORMAT.NONE;

            result = system.setSoftwareFormat(OUTPUTRATE, FMOD.SOUND_FORMAT.PCM16, 1, 0, 0);
            ERRCHECK(result);

            result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
            ERRCHECK(result);

            result = system.getSoftwareFormat(ref outputfreq, ref format, ref temp, ref temp, ref resampler, ref temp);
            ERRCHECK(result);

            /*
             *  Create a sound to record to.
             */
            exinfo.cbsize           = Marshal.SizeOf(exinfo);
            exinfo.numchannels      = 1;
            exinfo.format           = FMOD.SOUND_FORMAT.PCM16;
            exinfo.defaultfrequency = OUTPUTRATE;
            exinfo.length           = (uint)(exinfo.defaultfrequency * 2 * exinfo.numchannels * 5);

            result = system.createSound((string)null, (FMOD.MODE._2D | FMOD.MODE.SOFTWARE | FMOD.MODE.LOOP_NORMAL | FMOD.MODE.OPENUSER), ref exinfo, ref sound);
            ERRCHECK(result);

            comboBoxOutput.Enabled   = false;
            comboBoxPlayback.Enabled = false;
            comboBoxRecord.Enabled   = false;

            /*
             *  Start recording
             */
            result = system.recordStart(selected, sound, true);
            ERRCHECK(result);

            Thread.Sleep(200);      /* Give it some time to record something */

            result = system.playSound(FMOD.CHANNELINDEX.REUSE, sound, false, ref channel);
            ERRCHECK(result);

            /* Dont hear what is being recorded otherwise it will feedback.  Spectrum analysis is done before volume scaling in the DSP chain */
            result = channel.setVolume(0);
            ERRCHECK(result);
        }
Ejemplo n.º 27
0
 public FMOD.Sound GetSoundInstance(string filename)
 {
     //if (dcSounds.ContainsKey(filename))
     //    return dcSounds[filename];
     FMOD.Sound  sound  = null;
     FMOD.RESULT result = FModSystem.createSound(filename, FMOD.MODE.HARDWARE | FMOD.MODE.CREATESTREAM | FMOD.MODE._3D, ref sound);
     if (!ERRCHECK(result))
     {
         return(null);
     }
     //dcSounds[filename] = sound;
     Sounds.Add(sound);
     return(sound);
 }
Ejemplo n.º 28
0
        private void effects_Load(object sender, System.EventArgs e)
        {
            uint version = 0;

            FMOD.RESULT result;

            /*
             *  Create a System object and initialize.
             */
            result = FMOD.Factory.System_Create(ref system);
            ERRCHECK(result);

            result = system.getVersion(ref version);
            ERRCHECK(result);
            if (version < FMOD.VERSION.number)
            {
                MessageBox.Show("Error!  You are using an old version of FMOD " + version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
                Application.Exit();
            }

            result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
            ERRCHECK(result);

            result = system.createSound("../../../../../examples/media/drumloop.wav", FMOD.MODE.SOFTWARE, ref sound);
            ERRCHECK(result);

            result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, false, ref channel);
            ERRCHECK(result);

            /*
             *  Create some effects to play with.
             */
            result = system.createDSPByType(FMOD.DSP_TYPE.LOWPASS, ref dsplowpass);
            ERRCHECK(result);
            result = system.createDSPByType(FMOD.DSP_TYPE.HIGHPASS, ref dsphighpass);
            ERRCHECK(result);
            result = system.createDSPByType(FMOD.DSP_TYPE.ECHO, ref dspecho);
            ERRCHECK(result);
            result = system.createDSPByType(FMOD.DSP_TYPE.FLANGE, ref dspflange);
            ERRCHECK(result);
            result = system.createDSPByType(FMOD.DSP_TYPE.DISTORTION, ref dspdistortion);
            ERRCHECK(result);
            result = system.createDSPByType(FMOD.DSP_TYPE.CHORUS, ref dspchorus);
            ERRCHECK(result);
            result = system.createDSPByType(FMOD.DSP_TYPE.PARAMEQ, ref dspparameq);
            ERRCHECK(result);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Loads sound from file.
        /// Use this function to load short sound effects.
        /// </summary>
        public static Sound LoadSound(string path)
        {
            var buffer = FileLoader.LoadFileAsBuffer(path);

            var info = new FMOD.CREATESOUNDEXINFO();

            info.length = (uint)buffer.Length;
            info.cbsize = Marshal.SizeOf(info);

            Native.createSound(
                buffer,
                FMOD.MODE.OPENMEMORY | FMOD.MODE.CREATESAMPLE,
                ref info,
                out FMOD.Sound newSound
                );

            return(new Sound(newSound));
        }
Ejemplo n.º 30
0
        private void comboBox_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            FMOD.RESULT result;

            string selected = drives[comboBox.SelectedIndex].Remove(2, 1);

            result = system.createSound(selected, (FMOD.MODE.HARDWARE | FMOD.MODE._2D | FMOD.MODE.CREATESTREAM | FMOD.MODE.OPENONLY), ref cdsound);
            ERRCHECK(result);
            result = cdsound.getNumSubSounds(ref numtracks);
            ERRCHECK(result);
            result = cdsound.getSubSound(currenttrack, ref sound);
            ERRCHECK(result);

            play.Enabled      = true;
            pause.Enabled     = true;
            nextTrack.Enabled = true;
            comboBox.Enabled  = false;
        }