private void AboutDlg_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Properties.Settings.Default.Mute = this.Mute; Properties.Settings.Default.Save(); ModPlayer.Player_Stop(); m_Player = null; m_Mod = null; }
private void AboutForm_Loaded(object sender, RoutedEventArgs e) { Properties.Settings.Default.Reload(); this.Mute = Properties.Settings.Default.Mute; Музыка.IsChecked = !this.Mute; ModDriver.Mode = (ushort)(ModDriver.Mode | SharpMikCommon.DMODE_NOISEREDUCTION); try { m_Player.Init <NaudioDriver>(""); m_Mod = m_Player.LoadModule(new MemoryStream(Properties.Resources.track)); if (m_Mod != null) { m_Mod.loop = true; m_Mod.wrap = true; if (!this.Mute) { m_Player.Play(m_Mod); } } } catch (System.Exception ex) { MessageBox.Show($"Ошибка загрузки NAudio.\n{ex.Message}", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } Значок.Source = DatalessonMain.IconToImageSource(Properties.Resources.datalesson); Match match = new Regex(@"^([^,]+),\s*Version=([^,]+)").Match(Assembly.GetExecutingAssembly().FullName); if (match.Success) { Версия.Content = $"{match.Groups[1].Value} v{match.Groups[2].Value}"; } else { Версия.Content = $"DatalessonCertificate v{FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion}"; } СайтПрограммы.NavigateUri = new Uri(DatalessonMain.СайтПрограммы); СайтПрограммыХинт.Text = DatalessonMain.СайтПрограммы; УрокЦифры.NavigateUri = new Uri(DatalessonMain.УрокЦифры); УрокЦифрыХинт.Text = DatalessonMain.УрокЦифры; Копирайт.Content = $"Copyright © HEX0x29A, 2019 - {DateTime.Now.Year}"; }
private void Form1_Load(object sender, EventArgs e) { LoadData(); string path = Directory.GetCurrentDirectory(); //File.WriteAllBytes("temp.mod", Properties.Resources.chcknbnk); Stream damod = new MemoryStream(Properties.Resources.chcknbnk); m_Player = new MikMod(); ModDriver.Mode = (ushort)(ModDriver.Mode | SharpMikCommon.DMODE_NOISEREDUCTION); m_Player.Init <NaudioDriver>(""); m_Mod = m_Player.LoadModule(damod); m_Mod.wrap = true; m_Player.Play(m_Mod); System.Timers.Timer atimer = new System.Timers.Timer(); atimer.Interval = 1000.0 / 60.0; atimer.Elapsed += Refresh; atimer.AutoReset = true; atimer.Enabled = true; }
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); }
public static void UnLoad(Module mod) { ModPlayer.Player_Exit_internal(mod); ML_FreeEx(mod); }