예제 #1
0
        private void CloseApp_Click(object sender, EventArgs e)
        {
            ModPlayer.Player_Stop();

            ModDriver.MikMod_Exit();
            this.Close();
        }
예제 #2
0
        public BinaryModule(Module mod)
        {
            // Shouldn't need to clone it...
            m_Module = mod;

            m_Samples = new short[m_Module.samples.Length][];

            for (int i = 0; i < m_Module.samples.Length; i++)
            {
                m_Samples[i] = ModDriver.MD_GetSample((short)i);
            }
        }
예제 #3
0
        public MemSharpMikTest()
        {
            ModPlayer.SetFixedRandom = true;
            m_MemDriver = ModDriver.LoadDriver <MemDriver>();
            ModDriver.MikMod_Init("");
            m_Running = true;

            m_Thread          = new Thread(new ThreadStart(WorkThread));
            m_Thread.Name     = "SharpTest";
            m_Thread.Priority = ThreadPriority.Highest;
            m_Thread.Start();
        }
예제 #4
0
        public void Load()
        {
            if (ModDriver.Driver != null)
            {
                for (int i = 0; i < m_Module.samples.Length; i++)
                {
                    m_Module.samples[i].handle = ModDriver.MD_SetSample(m_Samples[i]);
                }

                ModPlayer.Player_Init(m_Module);

                m_Loaded = true;
            }
        }
예제 #5
0
        void WorkThread()
        {
            while (m_Running)
            {
                m_Blocker.WaitOne();
                if (m_FileName != null)
                {
                    DateTime startTime = DateTime.Now;
                    try
                    {
                        mod = ModuleLoader.Load(m_FileName);
                        int iterations = 0;


                        if (mod != null)
                        {
                            mod.loop = false;
                            ModPlayer.Player_Start(mod);

                            // Trap for wrapping mods.
                            while (ModPlayer.Player_Active() && iterations < 5000)
                            {
                                ModDriver.MikMod_Update();
                                iterations++;
                            }

                            ModPlayer.Player_Stop();

                            ModuleLoader.UnLoad(mod);
                        }
                    }
                    catch (System.Exception ex)
                    {
                        m_Error = ex.Message;
                    }

                    TimeSpan span = DateTime.Now - startTime;
                    m_TimeTaken = (float)span.TotalSeconds;
                }
                m_Working = false;
            }
        }
예제 #6
0
        public static Module Load(Stream stream, int maxchan, int curious)
        {
            BuildRegisteredModules();
            Module mod = null;

            ModuleReader modReader = new ModuleReader(stream);
            IModLoader   loader    = null;

            for (int i = 0; i < s_RegistedModuleLoader.Count; i++)
            {
                modReader.Rewind();
                IModLoader tester = (IModLoader)Activator.CreateInstance(s_RegistedModuleLoader[i]);
                tester.ModuleReader = modReader;

                if (tester.Test())
                {
                    loader = tester;
                    tester.Cleanup();
                    break;
                }

                tester.Cleanup();
            }


            if (loader != null)
            {
                int t = 0;
                mod           = new Module();
                loader.Module = mod;

                bool loaded = false;

                munitrk track = new munitrk();
                track.UniInit();
                loader.Tracker = track;

                mod.bpmlimit   = 33;
                mod.initvolume = 128;

                for (t = 0; t < SharpMikCommon.UF_MAXCHAN; t++)
                {
                    mod.chanvol[t] = 64;
                    mod.panning[t] = (ushort)((((t + 1) & 2) == 2) ? SharpMikCommon.PAN_RIGHT : SharpMikCommon.PAN_LEFT);
                }

                if (loader.Init())
                {
                    modReader.Rewind();

                    loaded = loader.Load(curious);

                    if (loaded)
                    {
                        for (t = 0; t < mod.numsmp; t++)
                        {
                            if (mod.samples[t].inflags == 0)
                            {
                                mod.samples[t].inflags = mod.samples[t].flags;
                            }
                        }
                    }
                }

                loader.Cleanup();
                track.UniCleanup();

                if (loaded)
                {
                    ML_LoadSamples(mod, modReader);

                    if (!((mod.flags & SharpMikCommon.UF_PANNING) == SharpMikCommon.UF_PANNING))
                    {
                        for (t = 0; t < mod.numchn; t++)
                        {
                            mod.panning[t] = (ushort)((((t + 1) & 2) == 2) ? SharpMikCommon.PAN_HALFRIGHT : SharpMikCommon.PAN_HALFLEFT);
                        }
                    }

                    if (maxchan > 0)
                    {
                        if (!((mod.flags & SharpMikCommon.UF_NNA) == SharpMikCommon.UF_NNA) && (mod.numchn < maxchan))
                        {
                            maxchan = mod.numchn;
                        }
                        else
                        {
                            if ((mod.numvoices != 0) && (mod.numvoices < maxchan))
                            {
                                maxchan = mod.numvoices;
                            }
                        }

                        if (maxchan < mod.numchn)
                        {
                            mod.flags |= SharpMikCommon.UF_NNA;
                        }

                        if (ModDriver.MikMod_SetNumVoices_internal(maxchan, -1))
                        {
                            mod = null;
                            return(null);
                        }
                    }



                    SampleLoader.SL_LoadSamples();

                    ModPlayer.Player_Init(mod);
                }
                else
                {
                    mod = null;
                    LoadFailed(loader, null);
                }
            }
            else
            {
                throw new Exception("File {0} didn't match any of the loader types");
            }

            return(mod);
        }
예제 #7
0
        static int Main(string[] args)
        {
            ModPlayer.SetFixedRandom = true;
            int    result     = 0;
            int    iterations = 0;
            String modName    = null;

            try
            {
                DateTime startTime = DateTime.Now;
                Module   mod;

                if (args.Length == 0)
                {
                    ModDriver.LoadDriver <NoAudio>();
                    ModDriver.MikMod_Init("");
                    mod     = ModuleLoader.Load("Music1.mod");
                    modName = "Music1.mod";
                }
                else
                {
                    if (args.Length > 2)
                    {
                        ModDriver.LoadDriver <NoAudio>();
                    }
                    else
                    {
                        ModDriver.LoadDriver <WavDriver>();
                    }

                    ModDriver.MikMod_Init(args[1]);
                    mod     = ModuleLoader.Load(args[0]);
                    modName = args[0];
                }

                int lookingForByte = -1;
                int byteCount      = 44;            // wav header


                DateTime loadTime = DateTime.Now;

                if (mod != null)
                {
                    mod.loop = false;
                    ModPlayer.Player_Start(mod);

                    // Trap for wrapping mods.
                    while (ModPlayer.Player_Active() && iterations < 5000)
                    {
                        if (lookingForByte > 0)
                        {
                            int test = byteCount + (int)WavDriver.BUFFERSIZE;
                            if (test > lookingForByte)
                            {
                                Debug.WriteLine("Will fail on the next pass, at {0} byes in", (lookingForByte - byteCount));
                            }
                        }
                        if (args.Length == 0)
                        {
                            ModPlayer.Player_HandleTick();
                        }
                        else
                        {
                            ModDriver.MikMod_Update();
                        }

                        byteCount += (int)WavDriver.BUFFERSIZE;
                        iterations++;
                    }

                    ModPlayer.Player_Stop();
                    ModDriver.MikMod_Exit();
                }

                TimeSpan span = DateTime.Now - startTime;

                TimeSpan loadSpan = loadTime - startTime;

                while (args.Length == 0)
                {
                    Console.WriteLine("Took {0} seconds in total for mod of {1} seconds", span.TotalSeconds, mod.sngtime / 1024);
                    Console.WriteLine("Took {0} seconds to load and thus {1} seconds to process", loadSpan.TotalSeconds, span.TotalSeconds - loadSpan.TotalSeconds);

                    Thread.Sleep(1000);
                }
            }
            catch (Exception ex)
            {
                result = -1;
                Console.WriteLine("Mod file " + modName + " Hit an execption:\n\titterations till error: " + iterations + "\n\t" + ex.Message);
            }


            return(result);
        }