init() public method

public init ( int maxchannels, INITFLAGS flags, IntPtr extradriverdata ) : RESULT
maxchannels int
flags INITFLAGS
extradriverdata IntPtr
return RESULT
Exemplo n.º 1
0
        private CAudioManager()
        {
            FMOD.Factory.System_Create(out FMODSystem);

            FMODSystem.setDSPBufferSize(1024, 10);
            FMODSystem.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)0);
        }
Exemplo n.º 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>();
    }
Exemplo n.º 3
0
    protected virtual void Awake()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        if (instance != null)
        {
            Destroy(gameObject);
            return;
        }

        instance = GetComponent <AFmodAudioSystem>();
        if (!transform.parent)
        {
            DontDestroyOnLoad(gameObject);
        }

        strFilePath = Application.streamingAssetsPath + "/Audio/";
        if (system == null)
        {
            Factory.System_Create(out system);
            system.setSoftwareFormat(48000, SPEAKERMODE.MAX, 0);
            system.init(64, INITFLAGS.NORMAL, (IntPtr)null);
        }

        FmodAudioManager.Init();
        InitSounds();
        DontDestroyOnLoad(gameObject);
    }
Exemplo n.º 4
0
        public LowLevelSystem(int maxChannels = 1024, LowLevelInitFlags flags = LowLevelInitFlags.Normal, AdvancedInitializationSettings advancedSettings = default(AdvancedInitializationSettings), Action <IPreInitilizeLowLevelSystem> preInit = null)
        {
            //Load native dependencies
            Native.Load();

            _listenerCollection = new ListenerCollection(this);
            _disposed           = false;

            _reverbController = new ReverbPropertiesController(_system);

            //Create low level system and mark it for disposal management
            Factory.System_Create(out _system).Check();
            _managedSystem = true;

            if (preInit != null)
            {
                preInit(this);
            }

            //Set advanced settings
            SetAdvancedSettings(advancedSettings);

            //Initialize
            _system.init(maxChannels, EquivalentEnum <LowLevelInitFlags, INITFLAGS> .Cast(flags), IntPtr.Zero).Check();
        }
Exemplo n.º 5
0
    void PlayNewSong()
    {
        string documentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString();
        string path            = documentsFolder + "/AGR2280/Custom Music/";

        string[] availableFiles = Directory.GetFiles(path, "*.mp3");

        // Pick song to stream
        songToPlay = UnityEngine.Random.Range(0, availableFiles.Length);

        if (channel != null)
        {
            channel = null;
        }
        PlayingMusic = null;

        result           = system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
        result           = system.createSound(availableFiles [songToPlay], FMOD.MODE.CREATESTREAM, ref PlayingMusic);
        result           = system.playSound(music, PlayingMusic, false, ref channel);
        result           = system.createDSPByType(FMOD.DSP_TYPE.HIGHPASS, ref musicHighPass);
        result           = system.createDSPByType(FMOD.DSP_TYPE.LOWPASS, ref musicLowPass);
        result           = channel.addDSP(musicHighPass, ref highPassFilter);
        result           = channel.addDSP(musicLowPass, ref lowPassFilter);
        firstSongStarted = true;
    }
Exemplo n.º 6
0
 public static void Initialize(int NbChannel)
 {
     if (ViewerSettings.ActivateSound)
     {
         RESULT result;
         result = Factory.System_Create(ref system);
         if (EngineError != null)
         {
             EngineError(result);
         }
         uint version = 0;
         result = system.getVersion(ref version);
         if (EngineError != null)
         {
             EngineError(result);
         }
         if (version < VERSION.number)
         {
             LogTools.WriteError("Error! You are using an old version of FMOD " + version.ToString("X") + ". This program requires " + VERSION.number.ToString("X") + ".");
             throw new ApplicationException("Error! You are using an old version of FMOD " + version.ToString("X") + ". This program requires " + VERSION.number.ToString("X") + ".");
         }
         result = system.init(NbChannel, INITFLAGS.NORMAL, (IntPtr)null);
         if (EngineError != null)
         {
             EngineError(result);
         }
         channelMusicCallback = new CHANNEL_CALLBACK(OnEndMusic);
         channelSoundCallback = new CHANNEL_CALLBACK(OnEndSound);
         channelVoiceCallback = new CHANNEL_CALLBACK(OnEndVoice);
     }
 }
Exemplo n.º 7
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());
        }
Exemplo n.º 8
0
 public void init()
 {
     result = FMOD.Factory.System_Create(ref system);
     result = system.init(128, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
     result = system.createDSPByType(FMOD.DSP_TYPE.LOWPASS, ref dsplowpass);
     result = system.createDSPByType(FMOD.DSP_TYPE.FLANGE, ref dspflange);
     result = system.createDSPByType(FMOD.DSP_TYPE.DISTORTION, ref dspdistortion);
     result = system.createDSPByType(FMOD.DSP_TYPE.ECHO, ref dspecho);
 }
Exemplo n.º 9
0
        public AudioManager(LogManager log)
        {
            Log = log;
            _channelAssignments = new string[CHANNEL_COUNT];
            Log.AddMessage("Initializing Audio Manager...", LogLevel.INFO);
            CheckFMODErrors(Factory.System_Create(ref _fmodSystem));

            CheckFMODErrors(_fmodSystem.init(CHANNEL_COUNT, INITFLAGS.NORMAL, new IntPtr(0)));
        }
Exemplo n.º 10
0
 private void Init()
 {
     if (system == null)
     {
         result = FMOD.Factory.System_Create(ref system);
         ErrorCheck();
         result = system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
         ErrorCheck();
     }
 }
Exemplo n.º 11
0
        public void SfxInit(int wnd)
        {
            try {
                if (!GlobalVars.Debug_Silent)
                {
                    RESULT result = Factory.System_Create(ref fSystem);
                    if (result != RESULT.OK)
                    {
                        throw new Exception("Create(): " + Error.String(result));
                    }

                    uint ver = 0;
                    result = fSystem.getVersion(ref ver);
                    if (result != RESULT.OK)
                    {
                        throw new Exception("GetVersion(): " + Error.String(result));
                    }
                    if (ver < 279604)
                    {
                        throw new Exception("GetVersion(): You are using an old version of FMOD");
                    }

                    result = fSystem.setOutput(OUTPUTTYPE.AUTODETECT);
                    if (result != RESULT.OK)
                    {
                        throw new Exception("SetOutput(): " + Error.String(result));
                    }
                    result = fSystem.setDriver(0);
                    if (result != RESULT.OK)
                    {
                        throw new Exception("SetDriver(): " + Error.String(result));
                    }
                    result = fSystem.init(MaxSounds, INITFLAGS.NORMAL, IntPtr.Zero);
                    if (result != RESULT.OK)
                    {
                        throw new Exception("Init(): " + Error.String(result));
                    }

                    fSndReady = true;
                    fSndCount = 0;

                    for (int i = 0; i < MaxSounds; i++)
                    {
                        fSndList[i].Stream  = null;
                        fSndList[i].Channel = null;
                    }

                    fSndVolume[0] = 255;
                    fSndVolume[1] = 255;
                    fSndVolume[2] = 255;
                }
            } catch (Exception ex) {
                Logger.Write("SoundEngine.sfxInit(): " + ex.Message);
            }
        }
Exemplo n.º 12
0
    private MusicPlayer()
    {
        FMOD.Factory.System_Create(out FMODSystem);

        FMODSystem.setDSPBufferSize(1024, 10);
        FMODSystem.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)0);

        Songs = new FMOD.Sound[NUM_SONGS];

        LoadSong(JAGUAR, "jaguar");
    }
Exemplo n.º 13
0
            public Walkman()
            {
                //have proper errorchecking and shit
                result = FMOD.Factory.System_Create(out system);
                CHECKERR(result, ErrorType.Init);
                result = system.init(512, FMOD.INITFLAGS.NORMAL, (IntPtr)0);
                CHECKERR(result, ErrorType.Init);
                globalPlaylistList = new List <Playlist>();
                tagMaster          = new TagMaster();

                playlist = new Playlist();
                status   = STATUS.STOP;
            }
Exemplo n.º 14
0
        public Player(Action songEnd)
        {
            songEndAction = songEnd;
            uint version = 0;

            ERRCHECK(FMOD.Factory.System_Create(ref system));
            ERRCHECK(system.getVersion(ref version));
            if (version < FMOD.VERSION.number)
            {
                throw new Exception("Error!  You are using an old version of FMOD " + version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
            }

            ERRCHECK(system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null));
        }
Exemplo n.º 15
0
        public BGMPlayer()//생성자에서 음악 파일들을 로드함
        {
            FMOD.Factory.System_Create(out FMODSystem);

            FMODSystem.setDSPBufferSize(1024, 10);
            FMODSystem.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)0);

            Songs   = new FMOD.Sound[NUM_SONGS];
            Channel = new FMOD.Channel[NUM_SONGS];

            LoadSong(0, "BGM");
            LoadSong(1, "MAD");
            LoadSong(2, "FRUIT");
            LoadSong(3, "BOMB");
            LoadSong(4, "GAMEOVER");
        }
Exemplo n.º 16
0
        public clsFmodPlayer()
        {
            Init();

            result = FMOD.Factory.System_Create(out system);
            if (result == FMOD.RESULT.OK)
            {
                uint version = 0;
                result = system.getVersion(out version);
                result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
                if (result != FMOD.RESULT.OK)
                {
                    return;
                }
            }
        }
Exemplo n.º 17
0
    void Start()
    {
        uint version = 0;

        FMOD.RESULT result;

        //Create an FMOD System object
        result = FMOD.Factory.System_Create(ref system);
        if (!ERRCHECK(result))
        {
            return;
        }

        //Check FMOD Version
        result = system.getVersion(ref version);
        if (!ERRCHECK(result))
        {
            return;
        }

        if (version < FMOD.VERSION.number)
        {
            Debug.Log(
                "Error!  You are using an old version of FMOD "
                + version.ToString("X")
                + ".  This program requires "
                + FMOD.VERSION.number.ToString("X") + ".");
        }

        //Initialize the FMOD system object
        result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
        if (!ERRCHECK(result))
        {
            return;
        }

        if (result == FMOD.RESULT.OK)
        {
            Debug.Log("FMOD init! " + result);
        }

        // find the song path
        SongFileLocation location = GameObject.FindGameObjectWithTag("SongFileLocation").GetComponent <SongFileLocation>();

        PlaySong(location.FilePath);
    }
Exemplo n.º 18
0
        public static void Init()
        {
            NLVFS.NLVFS.LoadVfsFile("./SoundResource.vfs");

            Factory.System_Create(out _fmod);
            _fmod.setDSPBufferSize(4096, 2);
            var result = _fmod.init(16, FMOD.INITFLAGS.NORMAL, (IntPtr)null);//16个频道

            if (result != RESULT.OK)
            {
                NLog.Error("fmod SoundManager " + result);
            }
            bgmHistory = new Stack <string>();

            soundThread = new Thread(SoundWork);
            soundThread.Start();
            soundThread.IsBackground = true;
        }
Exemplo n.º 19
0
    public static void Init()
    {
        if (Environment.Is64BitProcess)
        {
            Debug.Log("Loading 64bit FMOD Library");
            LoadLibrary("FMOD\\64\\fmod.dll");
        }
        else
        {
            Debug.Log("Loading 32bit FMOD Library");
            LoadLibrary("FMOD\\32\\fmod.dll");
        }

        Debug.Log("Creating System... Result: " + Factory.System_Create(out m_FMODSystem));

        Debug.Log("Setting DSP Buffer Size... Result: " + m_FMODSystem.setDSPBufferSize(1024, 4));
        Debug.Log(
            "Initializing System... Result: " + m_FMODSystem.init(32, INITFLAGS.NORMAL, (IntPtr)0));
    }
Exemplo n.º 20
0
    public void init(int maxChannels, FMOD.INITFLAGS flags, IntPtr extraDriverData, FMOD.EVENT_INITFLAGS eventFlags)
    {
        if (m_eventSystemWasInit == false)
        {
            m_eventSystemWasInit = true;
            FMOD.RESULT result = getEventSystem().init(maxChannels, flags, extraDriverData, eventFlags);
            ERRCHECK(result);

            result = m_system.init(maxChannels, flags, extraDriverData);
            ERRCHECK(result);

            result = m_system.set3DSettings(1.0f, 1.0f, 1.0f);
            ERRCHECK(result);
        }
        else
        {
            Debug.LogWarning("FMOD_Unity: FmodEventSystem: FMOD Event System already init");
        }
    }
Exemplo n.º 21
0
    void Awake()
    {
        // FIXME: I do not know what's the best way to do this.
        // I need a way to make sure this is called before any use of
        // AudioMixer.
        // (So FMOD is loaded and initialised)
        // And I also need to be able to call FMODSystem.update at
        // each update (so spatialization works), and
        // FMODSystem.release (because FMOD is not fully reset when
        // editing) when the game closes.
        // This is my current solution. Feel free to improve it.
        if (Instance == null)
        {
            Instance = this;

            // So we do not need to reload FMOD between scenes.
            DontDestroyOnLoad(gameObject);

#if WIN64
            string dll = "fmod64";
#else
            string dll = "fmod";
#endif

            var path = System.IO.Path.GetFullPath("Assets\\" + dll);
            LoadLibrary(path);

            if (FMODUtils.ERRCHECK(FMOD.Factory.System_Create(out FMODSystem)))
            {
                Debug.LogError("Failed to create FMOD system.");
                return;
            }

            // TODO: I do not know what any of these values are! (except
            // FMOD.INITFLAGS.NORMAL)
            FMODSystem.setDSPBufferSize(DSP_BUFFER_SIZE, 10);
            FMODSystem.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)0);
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }
    }
Exemplo n.º 22
0
        public SoundSystem()
        {
            Factory.System_Create(ref soundSystem);
            uint version = 0;

            soundSystem.getVersion(ref version);
            soundSystem.init(32, INITFLAGS.NORMAL, (IntPtr)null);

            AudioManager.Instance.Initialize();
            AudioManager.Instance.Stereo = true;

            updateTimer = new System.Windows.Forms.Timer {
                Interval = 10
            };
            updateTimer.Tick += updateTimer_Tick;

            AudioManager.Instance.SFXPlaybackStopped += InstanceSfxPlaybackStopped;
            CurrentSfxPriority = 255;
        }
Exemplo n.º 23
0
        /*
         *  プロパティ
         */
        #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);
        }
Exemplo n.º 24
0
        public SoundSystem()
        {
            AudioFound       = true;
            sndActiveBGMName = "";

            RESULT result = Factory.System_Create(ref _system);

            if (result != RESULT.OK)
            {
                AudioFound = false;
                return;
            }
            uint version = 0;

            result = System.getVersion(ref version);
            if (result != RESULT.OK || version < VERSION.number)
            {
                AudioFound = false;
                return;
            }

            result = System.init(16, INITFLAGS.NORMAL, (IntPtr)null);
            if (result != RESULT.OK)
            {
                AudioFound = false;
                return;
            }

            ChannelBGM = new Channel();
            ChannelBGM.setRaw(new IntPtr());

            ChannelBackgroundSFX = new Channel();
            ChannelBackgroundSFX.setRaw(new IntPtr());

            ChannelGroupSFX = new ChannelGroup();
        }
Exemplo n.º 25
0
 public Player()
 {
     FMOD.Factory.System_Create(ref system);
     system.init(1, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
     volume = 1;
 }
Exemplo n.º 26
0
 static void Main(string[] args)
 {
     //Console.SetBufferSize(80, 500);
     Console.WriteLine("--- SpectralCoding League of Legends FMOD Sound Back Extractor ---");
     Console.WriteLine();
     ParseArgs(args);
     FMOD.RESULT FModResult;					// Set our variable we will keep updating with the FMOD Results
     if ((!Directory.Exists(TargetDir)) && ExtractFSB) {		// Create the target directory if it doesn't exist
         Console.WriteLine("Creating target directory: " + TargetDir + @"\");
         Directory.CreateDirectory(TargetDir);
     }
     FMOD.System FModSys = new FMOD.System();				// Initialize and create a FMOD "System" so
     FModResult = FMOD.Factory.System_Create(ref FModSys);	// we can interface with the FSBs
     // Initialize the FMod System with default flags
     FModResult = FModSys.init(16, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
     foreach (string CurFSB in FSBList) {	// For each file we're going to list or extract
         if (FModSys == null) {
             // Something went wrong, probably didn't have the proper DLL or something.
             Console.WriteLine("Unable to initialize the FMOD System. Did you copy the fmodex.dll into the same folder as LoLFSBExtract.exe?");
             Environment.Exit(1);
         } else {
             if (FModResult != FMOD.RESULT.OK) {
                 // If something went wrong, print the error.
                 Console.WriteLine("ERR FModSys.init(): " + FMOD.Error.String(FModResult));
             } else {
                 // Otherwise, dump the sound bank!
                 Console.WriteLine();
                 FModResult = DumpSoundBank(FModSys, CurFSB);
                 if (FModResult != FMOD.RESULT.OK) {
                     Console.WriteLine("ERR DumpSoundBank: " + FMOD.Error.String(FModResult));
                 }
             }
         }
     }
     Console.WriteLine();
     Console.WriteLine("Finished!");
     //Console.ReadLine();
     Environment.Exit(0);
 }
Exemplo n.º 27
0
        private static void ExportAudioClip(IExportContainer container, Stream fileStream, AudioClip clip)
        {
            CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO();

            FMOD.System system   = null;
            Sound       sound    = null;
            Sound       subsound = null;

            try
            {
                RESULT result = Factory.System_Create(out system);
                if (result != RESULT.OK)
                {
                    Logger.Instance.Log(LogType.Error, LogCategory.Export, $"Can't create factory for AudioClip {clip.Name}");
                    return;
                }

                result = system.init(1, INITFLAGS.NORMAL, IntPtr.Zero);
                if (result != RESULT.OK)
                {
                    Logger.Instance.Log(LogType.Error, LogCategory.Export, $"Can't init system for AudioClip {clip.Name}");
                    return;
                }

                byte[] data;
                using (MemoryStream memStream = new MemoryStream())
                {
                    clip.ExportBinary(container, memStream);
                    data = memStream.ToArray();
                }
                if (data.Length == 0)
                {
                    return;
                }

                exinfo.cbsize = Marshal.SizeOf(exinfo);
                exinfo.length = (uint)data.Length;
                result        = system.createSound(data, MODE.OPENMEMORY, ref exinfo, out sound);
                if (result != RESULT.OK)
                {
                    Logger.Instance.Log(LogType.Error, LogCategory.Export, $"Can't create sound for AudioClip {clip.Name}");
                    return;
                }

                result = sound.getSubSound(0, out subsound);
                if (result != RESULT.OK)
                {
                    Logger.Instance.Log(LogType.Error, LogCategory.Export, $"Can't get subsound for AudioClip {clip.Name}");
                    return;
                }

                result = subsound.getFormat(out SOUND_TYPE type, out SOUND_FORMAT format, out int numChannels, out int bitsPerSample);
                if (result != RESULT.OK)
                {
                    Logger.Instance.Log(LogType.Error, LogCategory.Export, $"Can't get format for AudioClip {clip.Name}");
                    return;
                }

                result = subsound.getDefaults(out float frequency, out int priority);
                if (result != RESULT.OK)
                {
                    Logger.Instance.Log(LogType.Error, LogCategory.Export, $"Can't get defaults for AudioClip {clip.Name}");
                    return;
                }

                int sampleRate = (int)frequency;
                result = subsound.getLength(out uint length, TIMEUNIT.PCMBYTES);
                if (result != RESULT.OK)
                {
                    Logger.Instance.Log(LogType.Error, LogCategory.Export, $"Can't get length for AudioClip {clip.Name}");
                    return;
                }

                result = subsound.@lock(0, length, out IntPtr ptr1, out IntPtr ptr2, out uint len1, out uint len2);
                if (result != RESULT.OK)
                {
                    Logger.Instance.Log(LogType.Error, LogCategory.Export, $"Can't lock for AudioClip {clip.Name}");
                    return;
                }

                using (BinaryWriter writer = new BinaryWriter(fileStream))
                {
                    writer.Write(Encoding.UTF8.GetBytes("RIFF"));
                    writer.Write(len1 + 36);
                    writer.Write(Encoding.UTF8.GetBytes("WAVEfmt "));
                    writer.Write(16);
                    writer.Write((short)1);
                    writer.Write((short)numChannels);
                    writer.Write(sampleRate);
                    writer.Write(sampleRate * numChannels * bitsPerSample / 8);
                    writer.Write((short)(numChannels * bitsPerSample / 8));
                    writer.Write((short)bitsPerSample);
                    writer.Write(Encoding.UTF8.GetBytes("data"));
                    writer.Write(len1);

                    for (int i = 0; i < len1; i++)
                    {
                        byte value = Marshal.ReadByte(ptr1, i);
                        writer.Write(value);
                    }
                }

                result = subsound.unlock(ptr1, ptr2, len1, len2);
                if (result != RESULT.OK)
                {
                    Logger.Instance.Log(LogType.Error, LogCategory.Export, $"Can't unlock for AudioClip {clip.Name}");
                }
            }
            finally
            {
                if (subsound != null)
                {
                    subsound.release();
                }
                if (sound != null)
                {
                    sound.release();
                }
                if (system != null)
                {
                    system.release();
                }
            }
        }
Exemplo n.º 28
0
 public FmodPlayer()
 {
     FMOD.Factory.System_Create(out _fmod);
     _fmod.init(32, INITFLAGS.NORMAL, (IntPtr)0);
 }
Exemplo n.º 29
0
        public DeckControl()
        {
            _mixerBackground = new Image();
            _mixerBackground.Height = 488;
            _mixerBackground.Width = 710;
            BitmapImage bmp = new BitmapImage();
            bmp.BeginInit();
            bmp.UriSource = new Uri("png/deck_background.png", UriKind.Relative);
            bmp.EndInit();
            _mixerBackground.Source = bmp;
            this.Children.Add(_mixerBackground);

            _recordController = new RecordController(RECORD_DIAMETER, RECORD_DIAMETER);
            _recordController.Margin = new Thickness(RECORD_MARGIN_LEFT, RECORD_MARGIN_TOP, 0, 0);
            _recordController.SetBackgroundImage(@"png/record.png");
            _recordController.Width = RECORD_DIAMETER;
            _recordController.Height = RECORD_DIAMETER;
            _recordController.TouchDown += new EventHandler<TouchEventArgs>(RecordTouchDown);
            _recordController.TouchUp += new EventHandler<TouchEventArgs>(RecordTouchUp);
            _recordController.TouchMove += new EventHandler<TouchEventArgs>(RecordTouchMove);
            _recordController.DragEnter += new System.Windows.DragEventHandler(RecordDragEnter);
            _recordController.DragLeave += new System.Windows.DragEventHandler(RecordDragLeave);
            _recordController.Drop += new System.Windows.DragEventHandler(RecordDrop);
            _recordController.AllowDrop = true;
            this.Children.Add(_recordController);

            _highPassKnob = new KnobControl(KNOB_DIAMETER, KNOB_DIAMETER);
            _highPassKnob.Margin = new Thickness(KNOB_MARGIN_LEFT, KNOB_MARGIN_TOP, 0, 0);
            _highPassKnob.SetBackgroundImage(@"png/dial_background.png");
            _highPassKnob.SetCenterImage(@"png/dial_knob.png");
            _highPassKnob.Width = KNOB_DIAMETER;
            _highPassKnob.Height = KNOB_DIAMETER;
            //_highPassKnob.TouchDown += new EventHandler<TouchEventArgs>(HPKnobTouchDown);
            //_highPassKnob.TouchUp += new EventHandler<TouchEventArgs>(HPKnobTouchUp);
            _highPassKnob.TouchMove += new EventHandler<TouchEventArgs>(HPKnobTouchMove);
            this.Children.Add(_highPassKnob);

            _lowPassKnob = new KnobControl(KNOB_DIAMETER, KNOB_DIAMETER);
            _lowPassKnob.Margin = new Thickness(KNOB_MARGIN_LEFT, KNOB_MARGIN_TOP + KNOB_DIAMETER * 1 + KNOB_PADDING * 1, 0, 0);
            _lowPassKnob.SetBackgroundImage(@"png/dial_background.png");
            _lowPassKnob.SetCenterImage(@"png/dial_knob.png");
            _lowPassKnob.Width = KNOB_DIAMETER;
            _lowPassKnob.Height = KNOB_DIAMETER;
            _lowPassKnob.TouchMove += new EventHandler<TouchEventArgs>(LPKnobTouchMove);
            this.Children.Add(_lowPassKnob);

            _reverbKnob = new KnobControl(KNOB_DIAMETER, KNOB_DIAMETER);
            _reverbKnob.Margin = new Thickness(KNOB_MARGIN_LEFT, KNOB_MARGIN_TOP + KNOB_DIAMETER * 2 + KNOB_PADDING * 2, 0, 0);
            _reverbKnob.SetBackgroundImage(@"png/dial_background.png");
            _reverbKnob.SetCenterImage(@"png/dial_knob.png");
            _reverbKnob.Width = KNOB_DIAMETER;
            _reverbKnob.Height = KNOB_DIAMETER;
            this.Children.Add(_reverbKnob);
            

            angle = 1;
            _recordMidPoint = new System.Windows.Point(_recordController.Width / 2 + _recordController.Margin.Left, _recordController.Height / 2 + _recordController.Margin.Top);
            rotate = new RotateTransform(1, _recordController.Width / 2, _recordController.Height / 2);
            transform = new TransformGroup();
            transform.Children.Add(rotate);

            dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 1);
            dispatcherTimer.Start();

            system = new FMOD.System();
            FMOD.RESULT result = Factory.System_Create(ref system);
            system.init(8, INITFLAGS.NORMAL, (IntPtr)null);
            channel = new Channel(system);
            channel.Initialize(0);
            channel.SetHighPass(1.0f);
            _isPlaying = false;
        }
        //This function is called by the loadSystem function. It sets up FMOD for the rest of
        //the program, like an "init" of sorts. Most of this code is boilerplate that is used in
        //every FMOD application.
        private FMOD.System fmodSetup()
        {
            FMOD.System t_system = new FMOD.System();
            FMOD.RESULT result = new FMOD.RESULT();
            uint version = 0;
            int numDrivers = 0;
            FMOD.SPEAKERMODE speakerMode = FMOD.SPEAKERMODE.STEREO;
            FMOD.CAPS caps = FMOD.CAPS.NONE;
            StringBuilder name = null;

            // Create FMOD interface object
            result = FMOD.Factory.System_Create(ref t_system);
            FMODErrorCheck(result);

            // Check version
            result = t_system.getVersion(ref version);
            FMODErrorCheck(result);

            if (version < FMOD.VERSION.number)
            {
                Console.WriteLine("Error! You are using an old version of FMOD " + version + ". This program requires " + FMOD.VERSION.number);
                return null;
            }

            //Check Sound Cards, if none, disable sound
            result = t_system.getNumDrivers(ref numDrivers);
            FMODErrorCheck(result);

            if (numDrivers == 0)
            {
                result = t_system.setOutput(FMOD.OUTPUTTYPE.NOSOUND);
                FMODErrorCheck(result);
            }
            // At least one sound card
            else
            {

                // Get the capabilities of the default (0) sound card
                result = t_system.getDriverCaps(0, ref caps, ref zero, ref speakerMode);
                FMODErrorCheck(result);

                // Set the speaker mode to match that in Control Panel
                result = t_system.setSpeakerMode(speakerMode);
                FMODErrorCheck(result);

                // Increase buffer size if user has Acceleration slider set to off
                if (FMOD.CAPS.HARDWARE_EMULATED.Equals(true))
                {
                    result = t_system.setDSPBufferSize(1024, 10);
                    FMODErrorCheck(result);
                }
                // Get name of driver
                FMOD.GUID temp = new FMOD.GUID();

                result = t_system.getDriverInfo(0, name, 256, ref temp);
                FMODErrorCheck(result);
            }
            System.IntPtr temp2 = new System.IntPtr();
            // Initialise FMOD
            result = t_system.init(100, FMOD.INITFLAGS.NORMAL, temp2);

            // If the selected speaker mode isn't supported by this sound card, switch it back to stereo
            if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER)
            {
                result = t_system.setSpeakerMode(FMOD.SPEAKERMODE.STEREO);
                FMODErrorCheck(result);

                result = t_system.init(100, FMOD.INITFLAGS.NORMAL, temp2);
            }

            FMODErrorCheck(result);

            return t_system;
        }
Exemplo n.º 31
0
        public static fmod GetInstance(int deviceIndex)
        {
            if (m_systems.Count == 0)
            {
                System system = null;
                CreateDeviceList();
                if (m_deviceList.Count > 0)
                {
                    int num;
                    for (num = 0; num < m_deviceList.Count; num++)
                    {
                        if (Factory.System_Create(ref system) == RESULT.ERR_OUTPUT_INIT)
                        {
                            m_deviceList.RemoveRange(num, m_deviceList.Count - num);
                            break;
                        }
                        m_systems.Add(system);
                    }
                    string path           = Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), "sound.params");
                    int    numbuffers     = 0;
                    uint   filebuffersize = 0x8000;
                    if (File.Exists(path))
                    {
                        string       str2;
                        StreamReader reader = new StreamReader(path);
                        while ((str2 = reader.ReadLine()) != null)
                        {
                            string[] strArray = str2.Split(new char[] { '=' });
                            string   str3     = strArray[0].Trim().ToLower();
                            if (str3 != null)
                            {
                                if (!(str3 == "dspbuffercount"))
                                {
                                    if (str3 == "streambuffersize")
                                    {
                                        goto Label_0146;
                                    }
                                }
                                else
                                {
                                    try
                                    {
                                        numbuffers = Convert.ToInt32(strArray[1].Trim());
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                            goto Label_0162;
Label_0146:
                            try
                            {
                                filebuffersize = Convert.ToUInt32(strArray[1].Trim());
                            }
                            catch
                            {
                            }
Label_0162:
                            ;
                        }
                        reader.Close();
                        reader.Dispose();
                    }
                    for (num = 0; num < m_systems.Count; num++)
                    {
                        system = m_systems[num];
                        system.setDriver(num);
                        if (numbuffers > 0)
                        {
                            system.setDSPBufferSize(0x400, numbuffers);
                        }
                        system.init(0x20, INITFLAGS.NORMAL, IntPtr.Zero);
                        system.setStreamBufferSize(filebuffersize, TIMEUNIT.RAWBYTES);
                    }
                }
            }
            if (deviceIndex == -1)
            {
                deviceIndex = 0;
            }
            if (deviceIndex < m_systems.Count)
            {
                m_refCount++;
                return(new fmod(m_systems[deviceIndex], deviceIndex));
            }
            return(new fmod(null, -1));
        }
Exemplo n.º 32
0
        //This function is called by the loadSystem function. It sets up FMOD for the rest of
        //the program, like an "init" of sorts. Most of this code is boilerplate that is used in
        //every FMOD application.
        private FMOD.System fmodSetup()
        {
            FMOD.System t_system   = new FMOD.System();
            FMOD.RESULT result     = new FMOD.RESULT();
            uint        version    = 0;
            int         numDrivers = 0;

            FMOD.SPEAKERMODE speakerMode = FMOD.SPEAKERMODE.STEREO;
            FMOD.CAPS        caps        = FMOD.CAPS.NONE;
            StringBuilder    name        = null;

            // Create FMOD interface object
            result = FMOD.Factory.System_Create(ref t_system);
            FMODErrorCheck(result);

            // Check version
            result = t_system.getVersion(ref version);
            FMODErrorCheck(result);

            if (version < FMOD.VERSION.number)
            {
                Console.WriteLine("Error! You are using an old version of FMOD " + version + ". This program requires " + FMOD.VERSION.number);
                return(null);
            }

            //Check Sound Cards, if none, disable sound
            result = t_system.getNumDrivers(ref numDrivers);
            FMODErrorCheck(result);

            if (numDrivers == 0)
            {
                result = t_system.setOutput(FMOD.OUTPUTTYPE.NOSOUND);
                FMODErrorCheck(result);
            }
            // At least one sound card
            else
            {
                // Get the capabilities of the default (0) sound card
                result = t_system.getDriverCaps(0, ref caps, ref zero, ref speakerMode);
                FMODErrorCheck(result);

                // Set the speaker mode to match that in Control Panel
                result = t_system.setSpeakerMode(speakerMode);
                FMODErrorCheck(result);

                // Increase buffer size if user has Acceleration slider set to off
                if (FMOD.CAPS.HARDWARE_EMULATED.Equals(true))
                {
                    result = t_system.setDSPBufferSize(1024, 10);
                    FMODErrorCheck(result);
                }
                // Get name of driver
                FMOD.GUID temp = new FMOD.GUID();

                result = t_system.getDriverInfo(0, name, 256, ref temp);
                FMODErrorCheck(result);
            }
            System.IntPtr temp2 = new System.IntPtr();
            // Initialise FMOD
            result = t_system.init(100, FMOD.INITFLAGS.NORMAL, temp2);

            // If the selected speaker mode isn't supported by this sound card, switch it back to stereo
            if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER)
            {
                result = t_system.setSpeakerMode(FMOD.SPEAKERMODE.STEREO);
                FMODErrorCheck(result);

                result = t_system.init(100, FMOD.INITFLAGS.NORMAL, temp2);
            }

            FMODErrorCheck(result);

            return(t_system);
        }