public LSVorbis(LSSettings settings, LSPcmFeed pimp) : base() { logger = Logger.ogg; this.pimp = pimp; this.settings = settings; logger.a("creating oggenc object"); proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = Program.tools + "oggenc2.exe"; proc.StartInfo.WorkingDirectory = Program.tools.Trim('\\'); proc.StartInfo.CreateNoWindow = true; proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardInput = true; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.Arguments = string.Format( "-Q -R 44100 {0} {1} {2} " + //.................target params "-r -F 1 -B 16 -C 2 --raw-endianness 0 -", //...source params (settings.ogg.compression == LSSettings.LSCompression.cbr ? "-b" : "-q"), (settings.ogg.compression == LSSettings.LSCompression.cbr ? settings.ogg.bitrate : settings.ogg.quality), (settings.ogg.channels == LSSettings.LSChannels.stereo ? "" : "--downmix")); if (!File.Exists(proc.StartInfo.FileName)) { System.Windows.Forms.MessageBox.Show( "Could not start streaming due to a missing required file:\r\n\r\n" + proc.StartInfo.FileName + "\r\n\r\nThis is usually because whoever made your loopstream.exe f****d up", "Shit wont fly", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); Program.kill(); } logger.a("starting oggenc"); proc.Start(); while (true) { logger.a("waiting for oggenc"); try { proc.Refresh(); if (proc.Modules.Count > 1) { break; } logger.a("modules: " + proc.Modules.Count); System.Threading.Thread.Sleep(10); } catch { } } /*foreach (System.Diagnostics.ProcessModule mod in proc.Modules) * { * Console.WriteLine(mod.ModuleName + " // " + mod.FileName); * }*/ logger.a("oggenc running"); pstdin = proc.StandardInput.BaseStream; pstdout = proc.StandardOutput.BaseStream; dump = settings.recOgg; enc = settings.ogg; makeShouter(); }
public UI_input(LSSettings.LSMeta meta, List<LSSettings.LSMeta> metas) { InitializeComponent(); textBox1.Text = meta.tit; this.metas = metas; this.meta = meta; wasAdded = true; }
public LSMixer(LSSettings settings, LLabel[] bars) { Logger.mix.a("creating"); this.settings = settings; this.bars = bars; isLQ = null; doMagic(); }
public LSVorbis(LSSettings settings, LSPcmFeed pimp) : base() { logger = Logger.ogg; this.pimp = pimp; this.settings = settings; logger.a("creating oggenc object"); proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = Program.tools + "oggenc2.exe"; proc.StartInfo.WorkingDirectory = Program.tools.Trim('\\'); proc.StartInfo.CreateNoWindow = true; proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardInput = true; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.Arguments = string.Format( "-Q -R 44100 {0} {1} {2} " + //.................target params "-r -F 1 -B 16 -C 2 --raw-endianness 0 -", //...source params (settings.ogg.compression == LSSettings.LSCompression.cbr ? "-b" : "-q"), (settings.ogg.compression == LSSettings.LSCompression.cbr ? settings.ogg.bitrate : settings.ogg.quality), (settings.ogg.channels == LSSettings.LSChannels.stereo ? "" : "--downmix")); if (!File.Exists(proc.StartInfo.FileName)) { System.Windows.Forms.MessageBox.Show( "Could not start streaming due to a missing required file:\r\n\r\n" + proc.StartInfo.FileName + "\r\n\r\nThis is usually because whoever made your loopstream.exe f****d up", "Shit wont fly", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); Program.kill(); } logger.a("starting oggenc"); proc.Start(); while (true) { logger.a("waiting for oggenc"); try { proc.Refresh(); if (proc.Modules.Count > 1) break; logger.a("modules: " + proc.Modules.Count); System.Threading.Thread.Sleep(10); } catch { } } /*foreach (System.Diagnostics.ProcessModule mod in proc.Modules) { Console.WriteLine(mod.ModuleName + " // " + mod.FileName); }*/ logger.a("oggenc running"); pstdin = proc.StandardInput.BaseStream; pstdout = proc.StandardOutput.BaseStream; dump = settings.recOgg; enc = settings.ogg; makeShouter(); }
public LSLame(LSSettings settings, LSPcmFeed pimp) { logger = Logger.mp3; this.pimp = pimp; this.settings = settings; logger.a("creating lame object"); proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = Program.tools + "lame.exe"; proc.StartInfo.WorkingDirectory = Program.tools.Trim('\\'); proc.StartInfo.CreateNoWindow = true; proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardInput = true; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.Arguments = string.Format( "{0} {1} -h -m {2} --noreplaygain -S " + //..................target params "-r -s {3} --bitwidth 16 --signed --little-endian - -", //...source params (settings.mp3.compression == LSSettings.LSCompression.cbr ? "--preset cbr" : "-V"), (settings.mp3.compression == LSSettings.LSCompression.cbr ? settings.mp3.bitrate : settings.mp3.quality), (settings.mp3.channels == LSSettings.LSChannels.stereo ? "j" : "s -a"), settings.samplerate); if (!File.Exists(proc.StartInfo.FileName)) { System.Windows.Forms.MessageBox.Show( "Could not start streaming due to a missing required file:\r\n\r\n" + proc.StartInfo.FileName + "\r\n\r\nThis is usually because whoever made your loopstream.exe f****d up", "Shit wont fly", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); Program.kill(); } logger.a("starting lame"); proc.Start(); while (true) { logger.a("waiting for lame"); try { proc.Refresh(); if (proc.Modules.Count > 1) { break; } logger.a("modules: " + proc.Modules.Count); System.Threading.Thread.Sleep(10); } catch { } } logger.a("lame running"); pstdin = proc.StandardInput.BaseStream; pstdout = proc.StandardOutput.BaseStream; dump = settings.recMp3; enc = settings.mp3; makeShouter(); }
public LSOpus(LSSettings settings, LSPcmFeed pimp) : base() { logger = Logger.opus; this.pimp = pimp; this.settings = settings; logger.a("creating opusenc object"); proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = Program.tools + "opusenc.exe"; proc.StartInfo.WorkingDirectory = Program.tools.Trim('\\'); proc.StartInfo.CreateNoWindow = true; proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardInput = true; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.Arguments = string.Format( "--quiet --bitrate {1} --raw --raw-rate {0} {2} - -", settings.samplerate, settings.opus.quality, (settings.opus.channels == LSSettings.LSChannels.stereo ? "--downmix-stereo" : "--downmix-mono")); if (!File.Exists(proc.StartInfo.FileName)) { System.Windows.Forms.MessageBox.Show( "Could not start streaming due to a missing required file:\r\n\r\n" + proc.StartInfo.FileName + "\r\n\r\nThis is usually because whoever made your loopstream.exe f****d up", "Shit wont fly", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); Program.kill(); } logger.a("starting opusenc"); proc.Start(); while (true) { logger.a("waiting for opusenc"); try { proc.Refresh(); if (proc.Modules.Count > 1) { break; } logger.a("modules: " + proc.Modules.Count); System.Threading.Thread.Sleep(10); } catch { } } logger.a("opusenc running"); pstdin = proc.StandardInput.BaseStream; pstdout = proc.StandardOutput.BaseStream; dump = settings.recOpus; enc = settings.opus; makeShouter(); }
public UI_Tagbox(LSSettings settings, LSTag tag) { this.settings = settings; this.tag = tag; cui = null; lastTag = null; lastSize = Size.Empty; InitializeComponent(); gPic.Image = null; }
public void initFinally() { if (metas.Count == 0) { resetMetas(); } if (triggers.Count == 0) { resetTriggers(); } LSSettings.singleton = this; }
public LSLame(LSSettings settings, LSPcmFeed pimp) { logger = Logger.mp3; this.pimp = pimp; this.settings = settings; logger.a("creating lame object"); proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = Program.tools + "lame.exe"; proc.StartInfo.WorkingDirectory = Program.tools.Trim('\\'); proc.StartInfo.CreateNoWindow = true; proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardInput = true; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.Arguments = string.Format( "{0} {1} -h -m {2} --noreplaygain -S " + //..................target params "-r -s {3} --bitwidth 16 --signed --little-endian - -", //...source params (settings.mp3.compression == LSSettings.LSCompression.cbr ? "--preset cbr" : "-V"), (settings.mp3.compression == LSSettings.LSCompression.cbr ? settings.mp3.bitrate : settings.mp3.quality), (settings.mp3.channels == LSSettings.LSChannels.stereo ? "j" : "s -a"), settings.samplerate); if (!File.Exists(proc.StartInfo.FileName)) { System.Windows.Forms.MessageBox.Show( "Could not start streaming due to a missing required file:\r\n\r\n" + proc.StartInfo.FileName + "\r\n\r\nThis is usually because whoever made your loopstream.exe f****d up", "Shit wont fly", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); Program.kill(); } logger.a("starting lame"); proc.Start(); while (true) { logger.a("waiting for lame"); try { proc.Refresh(); if (proc.Modules.Count > 1) break; logger.a("modules: " + proc.Modules.Count); System.Threading.Thread.Sleep(10); } catch { } } logger.a("lame running"); pstdin = proc.StandardInput.BaseStream; pstdout = proc.StandardOutput.BaseStream; dump = settings.recMp3; enc = settings.mp3; makeShouter(); }
void t_Tick(object sender, EventArgs e) { if (serText == null) { return; } var sb = new StringBuilder(serText); sb.AppendLine(); bool ok1, ok2, ok3, oks; ok1 = ok2 = ok3 = oks = false; try { LSSettings s = LSSettings.singleton; ok1 = s.devRec != null && (!(s.devRec is LSDevice)) || ((LSDevice)s.devRec).mm != null; ok2 = s.devMic != null && ((LSDevice)s.devMic).mm != null; ok3 = s.devOut != null && ((LSDevice)s.devOut).mm != null; sb.AppendLine("dev state indicated: " + ok1 + ", " + ok2 + ", " + ok3); LSSettings.singleton.init(); s.runTests(null, true); ok1 = ok1 == (s.devRec != null && (!(s.devRec is LSDevice)) || ((LSDevice)s.devRec).mm != null); ok2 = ok2 == (s.devMic != null && ((LSDevice)s.devMic).mm != null); ok3 = ok3 == (s.devOut != null && ((LSDevice)s.devOut).mm != null); sb.AppendLine("dev state correct: " + ok1 + ", " + ok2 + ", " + ok3); oks = true; } catch { } serText = gi.ToString() + "\r\n" + sb.ToString(); System.IO.File.WriteAllText(serPath + "2.txt", serText, Encoding.UTF8); System.IO.File.Delete(serPath + "1.txt"); linkLabel1.Text = serPath + "2.txt"; gDesc.Enabled = gIgnOnce.Enabled = gIgnAlways.Enabled = gRestart.Enabled = true; gDesc.Text = defaultmsg; gRestart.Focus(); if (oks && (!ok1 || !ok2 || !ok3)) { if (DialogResult.Yes == MessageBox.Show( "The bad news: Loopstream just crashed :(\n" + "The good news: I think I know why!\n\n" + "Did you disconnect or disable your speakers or microphone?\n" + "'cause you need to restart Loopstream when you do that.\n\n" + "Wanna go for a restart?", "Dirty devices detected", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)) { Program.fixWorkingDirectory(); } } }
public LSEncoder() { stdin = stdout = pstdin = pstdout = null; s = null; tc = null; enc = null; proc = null; pimp = null; dump = false; settings = null; crashed = false; locker = new object(); rekick = 0; }
public void LoadFromProfile(LSSettings settings) { settings.host = host; settings.port = port; settings.user = user; settings.pass = pass; settings.mount = mount; settings.relay = relay; settings.title = title; settings.description = description; settings.genre = genre; settings.url = url; settings.pubstream = pubstream; }
public void SaveToProfile(LSSettings settings) { host = settings.host; port = settings.port; user = settings.user; pass = settings.pass; mount = settings.mount; relay = settings.relay; title = settings.title; description = settings.description; genre = settings.genre; url = settings.url; pubstream = settings.pubstream; }
public LSPcmFeed(LSSettings settings, NPatch.Fork.Outlet outlet) { Logger.pcm.a("pcm init"); locker = new object(); shuttingDown = false; quitting = 0; res_cd = 0; makeSilenceFill(); this.outlet = outlet; this.settings = settings; encoders = new List <LSEncoder>(); wp16 = new NAudio.Wave.SampleProviders.SampleToWaveProvider16(outlet); System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(dicks)); t.Name = "LSPcm_Prism"; t.Start(); }
public LSPcmFeed(LSSettings settings, NPatch.Fork.Outlet outlet) { Logger.pcm.a("pcm init"); locker = new object(); shuttingDown = false; quitting = 0; res_cd = 0; makeSilenceFill(); this.outlet = outlet; this.settings = settings; encoders = new List<LSEncoder>(); wp16 = new NAudio.Wave.SampleProviders.SampleToWaveProvider16(outlet); System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(dicks)); t.Name = "LSPcm_Prism"; t.Start(); }
public bool Matches(LSSettings settings) { return( settings.host == host && settings.port == port && settings.user == user && settings.pass == pass && settings.mount == mount && settings.relay == relay && settings.title == title && settings.description == description && settings.genre == genre && settings.url == url && settings.pubstream == pubstream ); }
public LSTag(LSSettings set) { Logger.tag.a("init"); settings = set; quitting = false; haveFailed = false; socket_fallback = false; latin1 = Encoding.GetEncoding("ISO_8859-1"); manual = new LSTD(false, "", "STILL_UNUSED"); tag = new LSTD(false, "", "STILL_UNUSED"); auth = string.Format("{0}:{1}", settings.user, settings.pass); auth = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(auth)); System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(feeder)); t.Name = "LSTag_Feeder"; t.Start(); }
public LSTag(LSSettings set) { Logger.tag.a("init"); settings = set; streaming = false; quitting = false; haveFailed = false; socket_fallback = false; latin1 = Encoding.GetEncoding("ISO_8859-1"); manual = new LSTD(false, "", "STILL_UNUSED"); tag = new LSTD(false, "", "STILL_UNUSED"); Reload(); System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(feeder)); t.Name = "LSTag_Feeder"; t.Start(); }
public Est(string s, LSSettings.LSParams e) { tag = s; enc = e; }
public static LSTD get(LSSettings.LSMeta m, bool getRaw) { if (m.reader == LSSettings.LSMeta.Reader.WindowCaption) { if (m.src.Trim() == "*") { int myId = System.Diagnostics.Process.GetCurrentProcess().Id; int[] handles = EnumHandles.Run(); foreach (int hWnd in handles) { IntPtr ptr = new IntPtr(hWnd); uint proc = WinapiShit.getProcId(ptr); if (proc <= 1) continue; if (proc == myId) continue; string text = WinapiShit.getWinText(ptr); if (string.IsNullOrEmpty(text)) continue; //gList.Items.Add("<" + hWnd + "> // <" + proc + "> // <" + text + ">"); LSTD td = get(m, text); if (td.ok) { return td; } } return new LSTD(false, "(no hits)", "The pattern in this profile did not match any of your windows.\n" + "\n" + "If you are using an in-browser media player (cloud service),\n" + "make sure the media player is in a dedicated browser window.\n" + "\n" + "(you must construct additional windows)"); } string raw = null; if (m.src.Contains('*')) { raw = WinapiShit.getWinText(new IntPtr(Convert.ToInt32(m.src.Split('*')[1], 16))); } if (string.IsNullOrEmpty(raw)) { Process[] proc = Process.GetProcessesByName(m.src.Split('*')[0]); if (proc.Length < 1) { return new LSTD(false, "(no such process)", "The media player «" + m.src + "» could not be found!\n\nAre you sure that it is running?"); } raw = proc[0].MainWindowTitle; } if (string.IsNullOrEmpty(raw)) { return new LSTD(false, "(no such target)", "The media player «" + m.src + "» could not be found!\n\nAre you sure that it is running?"); } return getRaw ? new LSTD(true, raw, "SUCCESS") : get(m, raw); } if (m.reader == LSSettings.LSMeta.Reader.File) { try { string ret = System.IO.File.ReadAllText(m.src, m.enc); return getRaw ? new LSTD(true, ret, "SUCCESS") : get(m, ret); } catch { return new LSTD(false, "(file read failure)", "Something went wrong while reading the provided file.\nAre you sure it exists?\n\nPath: " + m.src); } } if (m.reader == LSSettings.LSMeta.Reader.Website) { byte[] b; try { b = new System.Net.WebClient().DownloadData(m.src); try { string ret = m.enc.GetString(b); return getRaw ? new LSTD(true, ret, "SUCCESS") : get(m, ret); } catch { return new LSTD(false, "(web decode failure)", "I failed to unpack the data from the web server.\nMaybe incorrect address?\n\nLink: " + m.src); } } catch { return new LSTD(false, "(web request failure)", "I failed to download the data from the web server.\nMaybe it is down?\n\nLink: " + m.src); } } if (m.reader == LSSettings.LSMeta.Reader.ProcessMemory) { // this is the fun one Process[] proc = Process.GetProcessesByName(m.src); if (proc.Length < 1) { return new LSTD(false, "(no such process)", "The media player «" + m.src + "» could not be found!\n\nAre you sure that it is running?"); } LSMem mem; try { mem = new LSMem(proc[0]); } catch { return new LSTD(false, "(poke failure)", "I failed to harvest the metadata from inside «" + m.src + "»...\n\nMaybe system permissions blocked the request?\nTry running Loopstream as administrator."); } try { string ret = ""; string lpm = ""; bool hadError = false; ProcessModule pm = null; byte[] raw = new byte[1024]; string[] ad = m.ptn.Split(' '); for (int a = 0; a < ad.Length; a++) { string arg = ad[a].Trim(',', ' '); IntPtr ofs = IntPtr.Zero; if (arg.Contains('+')) { string[] args = arg.Split('+'); if (args[0] != lpm) { pm = null; lpm = null; foreach (ProcessModule mod in proc[0].Modules) { if (mod.ModuleName == args[0]) //if (mod.FileName.EndsWith("\\iTunes.dll")) { pm = mod; lpm = pm.ModuleName; ofs = pm.BaseAddress; break; } } } else { ofs = pm.BaseAddress; } arg = args[1]; } int[] steps = new int[0]; if (arg.Contains('*')) { string[] args = arg.Split('*'); steps = new int[args.Length-1]; for (int b = 1; b < args.Length; b++) { steps[b - 1] = Convert.ToInt32(args[b], 16); } arg = args[0]; } ofs += Convert.ToInt32(arg, 16); ret += a == 0 || ret.Length == 0 ? "" : " - "; int len = mem.read(ofs, raw, steps); if (len < 0) { ret += "(read error)"; hadError = true; } else if (len > 0) { ret += m.enc.GetString(raw); int i = ret.IndexOf('\0'); if (i >= 0) { ret = ret.Substring(0, i); } } } return new LSTD(!hadError, ret, hadError ? "Could not peek into the target application.\n\nThe media player is likely a 32bit process, while\nLoopstream is running in 64bit mode\n(or the other way around)." : "SUCCESS"); } catch { return new LSTD(false, "(peek failure)", "I failed to harvest the metadata from inside «" + m.src + "»...\n\nThis is probably a bug in Loopstream, but it could\nalso be system permissions getting in the way.\n\nYou could try running Loopstream as Administrator."); } } try { return new LSTD(false, "(unexpected metadata reader)", "You somehow managed to select a\nMetaReader which does not exist:\n\n «" + m.reader.ToString() + "»"); } catch { return new LSTD(false, "(unexpected metadata reader)", "You somehow managed to select a\nMetaReader which does not exist. How?"); } }
public static LSTD get(LSSettings.LSMeta m, string raw) { Logger.tag.a("get " + raw); if (m.reader == LSSettings.LSMeta.Reader.ProcessMemory) { return new LSTD(false, "if you are seeing this, go whine to ed", "(this really should not happen)"); } GroupCollection r; try { r = Regex.Match(raw, m.ptn, RegexOptions.Singleline).Groups; } catch { return new LSTD(false, "(bad regex)", "The Pattern in this profile has a typo,\nor is otherwise broken. Call techsupport.\n\nPattern: " + m.ptn); } if (r.Count > m.yi.max) { try { //string ret = r[m.grp].Value.Trim(' ', '\t', '\r', '\n'); // you can never be too sure string ret = m.yi.format(r); if (m.urldecode) { string[] sanitize = { """, "\"", "'", "'", "'", "'", "<", "<", ">", ">", "&", "&" }; for (int a = 0; a < sanitize.Length; a += 2) { ret = ret.Replace(sanitize[a], sanitize[a + 1]); } } return new LSTD(true, ret, "SUCCESS"); } catch { } } return new LSTD(false, "(no match)", ( m.reader == LSSettings.LSMeta.Reader.WindowCaption ? "The window title of «" + m.src + "» " : m.reader == LSSettings.LSMeta.Reader.Website ? "The contents of the provided website" : m.reader == LSSettings.LSMeta.Reader.File ? "The contents in the provided file" : "(something is seriously wrong)" ) + " was not possible to\nunderstand using the Pattern specified in this profile." + ( m.reader != LSSettings.LSMeta.Reader.WindowCaption ? "" : ("\n\nI tried to read from this: " + m.src) )); }
public static LSSettings load() { Logger.app.a("Loading LSSettings"); LSSettings ret; XmlSerializer x = new XmlSerializer(typeof(LSSettings)); if (System.IO.File.Exists("Loopstream.ini")) { Logger.app.a("Found existing .ini"); try { string str = System.IO.File.ReadAllText("Loopstream.ini", Encoding.UTF8); string ver = str.Substring(0, str.IndexOf('\n')); str = str.Substring(ver.Length + 1); System.IO.MemoryStream s = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(str)); int myVer = version(); int iniVer = Convert.ToInt32(ver, 16); //if (myVer != iniVer) if (iniVer < 0x01020600) { byte[] bver = BitConverter.GetBytes(iniVer); Array.Reverse(bver); System.Windows.Forms.MessageBox.Show( "Your configuration file is from version " + BitConverter.ToString(bver) + ", which is rather old.\n\n" + "Don't get your hopes up but I'll try to load it...", "Incompatible config file", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } //using (var s = System.IO.File.OpenRead("Loopstream.ini")) { ret = (LSSettings)x.Deserialize(s); // // Upgrade from v1.2.8.0: // xRec xMic lim_poor lim_drop // // Upgrade from v1.3.7.7: // yRec yMic // if (ret.mixer.xRec < 1) ret.mixer.xRec = 1; if (ret.mixer.xMic < 1) ret.mixer.xMic = 1; if (ret.mixer.yRec < 1) ret.mixer.yRec = -1; if (ret.mixer.yMic < 1) ret.mixer.yMic = -1; foreach (LSSettings.LSPreset pre in ret.presets) { if (pre.xRec < 1) pre.xRec = 1; if (pre.xMic < 1) pre.xMic = 1; if (pre.yRec < 1) pre.yRec = -1; if (pre.yMic < 1) pre.yMic = -1; } if (ret.lim_drop_DEPRECATED <= 0 || ret.lim_poor_DEPRECATED <= 0) { ret.warn_poor_DEPRECATED = ret.warn_drop_DEPRECATED = true; ret.lim_poor_DEPRECATED = 0.9; ret.lim_drop_DEPRECATED = 0.6; } if (ret.reverbS <= 0) ret.reverbS = 90; if (ret.reverbP <= 0) ret.reverbP = 0; } } catch (Exception e) { Logger.app.a("Deserialize failed, fallback to new"); ret = new LSSettings(); System.Windows.Forms.MessageBox.Show( "Failed to load settings:\n«Loopstream.ini» is probably from an old version of the program.\n\nDetailed information:\n" + e.Message + "\n" + e.StackTrace, "Default settings", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } try { Logger.app.a("Calling init()"); ret.init(); ret.mp3.FIXME_kbps = ret.ogg.FIXME_kbps = -1; foreach (var v in ret.metas) { if (v.grp != 1) { v.yield = "{" + v.grp + "}"; v.grp = 1; } } try { ret.metaDec(); } catch { } Logger.app.a("LSSettings deserialize successful"); ret.initFinally(); return ret; } catch (Exception e) { Logger.app.a("LSSettings deserialize postprocessing failed"); System.Windows.Forms.MessageBox.Show( "Failed to initialize settings object:\nPossibly from an outdated version of «Loopstream.ini», though more likely a developer fuckup. Go tell ed this:\n\n" + e.Message + "\n\n" + e.Source + "\n\n" + e.InnerException + "\n\n" + e.StackTrace); } } Logger.app.a("Creating new LSSettings"); ret = new LSSettings(); Logger.app.a("LSSettings OK"); ret.initFinally(); // it is 06:20 am, what are you looking at return ret; }
public UI_Graph(LSSettings settings) { this.settings = settings; InitializeComponent(); }
void genExceptionData() { this.gRestart = null; try { Int32 nix = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; serPath = Program.tools + "loopstream-crash-" + nix + "."; var se = new SerializableException(ex); StringBuilder sb = new StringBuilder(); gi = new GeneralInfo(se, ex); LSSettings s = LSSettings.singleton; try { if (s == null) { LSSettings.singleton = new LSSettings(); s = LSSettings.singleton; s.host = "nullsettings"; } s.serverPresets = new List <LSSettings.LSServerPreset>(); s.metas = new List <LSSettings.LSMeta>(); s.host = "(redacted)"; s.pass = "******"; sb.Append("\r\n// cfg\r\n" + GeneralInfo.ser(s)); } catch (Exception exx) { } try { var devs = new LSDevice[s.devs.Length]; for (var a = 0; a < devs.Length; a++) { devs[a] = s.devs[a] as LSDevice; } sb.Append("\r\n// devs\r\n" + GeneralInfo.ser(devs)); } catch (Exception exx) { } sb.AppendLine(); try { sb.AppendLine("\n\n\n\n\nCache for opus"); sb.AppendLine(Logger.opus.compile()); sb.AppendLine("\n\n\n\n\nCache for ogg"); sb.AppendLine(Logger.ogg.compile()); sb.AppendLine("\n\n\n\n\nCache for mp3"); sb.AppendLine(Logger.mp3.compile()); sb.AppendLine("\n\n\n\n\nCache for pcm"); sb.AppendLine(Logger.pcm.compile()); sb.AppendLine("\n\n\n\n\nCache for med"); sb.AppendLine(Logger.med.compile()); sb.AppendLine("\n\n\n\n\nCache for mix"); sb.AppendLine(Logger.mix.compile()); sb.AppendLine("\n\n\n\n\nCache for tag"); sb.AppendLine(Logger.tag.compile()); sb.AppendLine("\n\n\n\n\nCache for app"); sb.AppendLine(Logger.app.compile()); } catch { } serText = gi.ToString() + "\r\n" + sb.ToString(); System.IO.File.WriteAllText(serPath + "1.txt", serText, Encoding.UTF8); InitializeComponent(); gDesc.Text = "L o a d i n g d e t a i l s . . ."; linkLabel1.Text = serPath + "1.txt"; gDesc.Enabled = gIgnOnce.Enabled = gIgnAlways.Enabled = gRestart.Enabled = false; } catch (Exception exx) { serText = null; string desc = ""; try { var msg = ex.Message + "\r\n\r\n" + ex.StackTrace; desc = "Shit is properly f****d, can't send error information to devs\r\n" + "This is the best I can do:\r\n\r\n" + msg; System.IO.File.WriteAllText(serPath + "0.txt", msg, Encoding.UTF8); linkLabel1.Text = serPath + "0.txt"; } catch { desc = "Shit is properly f****d, can't send error information to devs"; } if (this.gRestart == null) { InitializeComponent(); } gDesc.Text = desc; gDesc.Enabled = gIgnOnce.Enabled = gIgnAlways.Enabled = gRestart.Enabled = true; gRestart.Focus(); } }
public UI_Status(LSSettings settings) { this.settings = settings; InitializeComponent(); }
public bool Matches(LSSettings settings) { return ( settings.host == host && settings.port == port && settings.user == user && settings.pass == pass && settings.mount == mount && settings.relay == relay && settings.title == title && settings.description == description && settings.genre == genre && settings.url == url && settings.pubstream == pubstream ); }
public UI_TagboxCfg(LSSettings settings, UI_Tagbox tbox) { this.settings = settings; this.tbox = tbox; InitializeComponent(); }
void t_Tick(object sender, EventArgs e) { ((Timer)sender).Stop(); wincap = this.Text + " v" + Application.ProductVersion; this.Text = wincap; z("set window title"); DFC.coreTest(); z("dfc core ok"); string toolsBase = @"..\..\tools\"; string[] requiredFiles = { "oggenc2.exe", "lame.exe", "lame_enc.dll" }; if (Directory.Exists(toolsBase) && File.Exists(toolsBase + Program.toolsVer)) { if (DialogResult.Yes == MessageBox.Show( "make .dfc (decent file container) ?\r\n\r\nhint: rename the tools folder\r\n if you don't wanna see this", "new embedded archive", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { splash.vis(); z("dfc maker"); foreach (string filename in requiredFiles) { if (!File.Exists(toolsBase + filename)) { DialogResult reply = MessageBox.Show( "The following file is required in order to build a\r\n" + "working DFC. Would you like to browse for it?\r\n\r\n" + filename, "Missing dependency", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (reply == System.Windows.Forms.DialogResult.Cancel) Program.kill(); if (reply == System.Windows.Forms.DialogResult.No) continue; string ext = filename.Substring(filename.LastIndexOf(".") + 1); OpenFileDialog ofd = new OpenFileDialog(); ofd.CheckFileExists = true; ofd.Title = "I am hungry for " + filename; ofd.Filter = ext + " files|*." + ext; ofd.FileName = filename.Contains("lame") ? "*lame*" : filename.Contains("ogg") ? "*ogg*" : ""; if (DialogResult.OK == ofd.ShowDialog()) File.Copy(ofd.FileName, toolsBase + toolsBase); else Program.kill(); } } new DFC().make(splash.progress); Program.kill(); } } string deleteReason = ""; if (Directory.Exists(Program.tools)) { if (!File.Exists(Program.tools + Program.toolsVer)) deleteReason = "outdated.\r\n\r\nIf you'd like to keep something in there (for example your SFX folder) then create a backup now :)"; foreach (string filename in requiredFiles) if (!File.Exists(Program.tools + filename)) deleteReason = "missing the following required file:\r\n\r\n" + Program.tools + filename + "\r\n\r\n" + "Whoever made your Loopstream.exe probably messed up."; } if (!string.IsNullOrWhiteSpace(deleteReason)) { z("deleting cause its " + deleteReason); if (DialogResult.OK != MessageBox.Show( "I'm about to delete your " + Program.tools.Trim('\\') + " directory since it's " + deleteReason, "Housekeeping", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)) Program.kill(); for (int a = 0; a < 3; a++) { try { Directory.Delete(Program.tools, true); break; } catch (Exception ex) { z("thank you microsoft"); System.Threading.Thread.Sleep(100); } } while (Directory.Exists(Program.tools)) Application.DoEvents(); } if (!Directory.Exists(Program.tools)) { splash.vis(); z("extracting tools"); new DFC().extract(splash.progress); } z("extract sequence done"); foreach (string filename in requiredFiles) if (!File.Exists(Program.tools + filename)) { MessageBox.Show( "The following required file was not found:\r\n\r\n" + Program.tools + filename + "\r\n\r\n" + "Whoever made your copy of Loopstream.exe f****d up.", "pokker", MessageBoxButtons.OK, MessageBoxIcon.Error); Program.kill(); } plowTheFields(); z("traktor test ok"); splash.unvis(); z("splash hidden"); if (++loads > 1) { MessageBox.Show("Critical semantical error, load sequencye fucskdjflks"); return; } z("Settings #1 - LOAD"); settings = LSSettings.load(); z("Settings #2 - TEST"); settings.runTests(splash.progress, false); z("Settings #3 - DONE"); isPresetLoad = true; z("Binding sliders"); gMus.valueChanged += gSlider_valueChanged; gMic.valueChanged += gSlider_valueChanged; gSpd.valueChanged += gSlider_valueChanged; gOut.valueChanged += gSlider_valueChanged; mixerPresetChanged(sender, e); z("Creating ni"); Program.ni = new NotifyIcon(); NotifyIcon ni = Program.ni; ni.Icon = this.Icon; ni.Visible = true; ni.DoubleClick += ni_DoubleClick; MenuItem[] items = { new MenuItem("Hide", ni_DoubleClick), new MenuItem("Connect", gConnect_Click), new MenuItem("---"), new MenuItem("A (1st preset)", gPreset_Click), new MenuItem("B (2nd preset)", gPreset_Click), new MenuItem("C (3nd impact)", gPreset_Click), new MenuItem("D (4th preset)", gPreset_Click), new MenuItem("---"), new MenuItem("Exit", gExit_Click) }; ni.ContextMenu = new ContextMenu(items); z("Binding ni"); gA.preset = settings.presets[0]; gB.preset = settings.presets[1]; gC.preset = settings.presets[2]; gD.preset = settings.presets[3]; popPoor = popDrop = popSign = popQuit = null; assumeConnected = popFilt = false; z("Layout gManualTags"); gManualTags.Font = new System.Drawing.Font(gManualTags.Font.FontFamily, gManualTags.Font.SizeInPoints * 0.8f); gManualTags.Text = gManualTags.Text.ToUpper().Replace(" ", " "); gManualTags.Location = new Point( (int)(pictureBox1.Left + (pictureBox1.Width - gManualTags.Width) / 1.85), (int)(pictureBox1.Top + (pictureBox1.Height - gManualTags.Height) / 1.9)); // sfx psfx_MouseClick(null, null); z("Position form"); this.Bounds = myBounds; splash.Focus(); //splash.BringToFront(); splash.fx = settings.splash; splash.gtfo(); if (settings.autohide) { z("Autohide was true"); this.Visible = false; } if (settings.autoconn) { z("Autoconn was true"); connect(); } // please don't look invals = new Control[] { box_top_graden, box_bottom_graden, gMus.giSlider, gMus.graden1, gMus.graden2, gMic.giSlider, gMic.graden1, gMic.graden2, gSpd.giSlider, gSpd.graden1, gSpd.graden2, gOut.giSlider, gOut.graden1, gOut.graden2, }; invalOnNext = false; lqMessage = null; iKonami = 0; tKonami = new Timer(); cKonami = new Keys[] { Keys.Up, Keys.Up, Keys.Down, Keys.Down, Keys.Left, Keys.Right, Keys.Left, Keys.Right, Keys.B, Keys.A, Keys.Enter }; tKonami.Tick += new EventHandler(tKonami_Tick); tKonami.Interval = 10; //tKonami.Start(); Timer manMachineInterfaceManager = new Timer(); manMachineInterfaceManager.Tick += manMachineInterfaceManager_manageWidgets; manMachineInterfaceManager.Interval = 200; manMachineInterfaceManager.Start(); z("showhide"); showhide(); z("skinner"); hookskinner(this.Controls); //Program.popception(); }
public static LSSettings load() { Logger.app.a("Loading LSSettings"); LSSettings ret; XmlSerializer x = new XmlSerializer(typeof(LSSettings)); if (System.IO.File.Exists("Loopstream.ini")) { Logger.app.a("Found existing .ini"); try { string str = System.IO.File.ReadAllText("Loopstream.ini", Encoding.UTF8); string ver = str.Substring(0, str.IndexOf('\n')); str = str.Substring(ver.Length + 1); System.IO.MemoryStream s = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(str)); int myVer = version(); int iniVer = Convert.ToInt32(ver, 16); //if (myVer != iniVer) if (iniVer < 0x01020600) { byte[] bver = BitConverter.GetBytes(iniVer); Array.Reverse(bver); System.Windows.Forms.MessageBox.Show( "Your configuration file is from version " + BitConverter.ToString(bver) + ", which is rather old.\n\n" + "Don't get your hopes up but I'll try to load it...", "Incompatible config file", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } //using (var s = System.IO.File.OpenRead("Loopstream.ini")) { ret = (LSSettings)x.Deserialize(s); // // Upgrade from v1.2.8.0: // xRec xMic lim_poor lim_drop // // Upgrade from v1.3.7.7: // yRec yMic // if (ret.mixer.xRec < 1) { ret.mixer.xRec = 1; } if (ret.mixer.xMic < 1) { ret.mixer.xMic = 1; } if (ret.mixer.yRec < 1) { ret.mixer.yRec = -1; } if (ret.mixer.yMic < 1) { ret.mixer.yMic = -1; } foreach (LSSettings.LSPreset pre in ret.presets) { if (pre.xRec < 1) { pre.xRec = 1; } if (pre.xMic < 1) { pre.xMic = 1; } if (pre.yRec < 1) { pre.yRec = -1; } if (pre.yMic < 1) { pre.yMic = -1; } } if (ret.lim_drop_DEPRECATED <= 0 || ret.lim_poor_DEPRECATED <= 0) { ret.warn_poor_DEPRECATED = ret.warn_drop_DEPRECATED = true; ret.lim_poor_DEPRECATED = 0.9; ret.lim_drop_DEPRECATED = 0.6; } if (ret.reverbS <= 0) { ret.reverbS = 90; } if (ret.reverbP <= 0) { ret.reverbP = 0; } } } catch (Exception e) { Logger.app.a("Deserialize failed, fallback to new"); ret = new LSSettings(); System.Windows.Forms.MessageBox.Show( "Failed to load settings:\n«Loopstream.ini» is probably from an old version of the program.\n\nDetailed information:\n" + e.Message + "\n" + e.StackTrace, "Default settings", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } try { Logger.app.a("Calling init()"); ret.init(); ret.mp3.FIXME_kbps = ret.ogg.FIXME_kbps = -1; foreach (var v in ret.metas) { if (v.grp != 1) { v.yield = "{" + v.grp + "}"; v.grp = 1; } } try { ret.metaDec(); } catch { } Logger.app.a("LSSettings deserialize successful"); ret.initFinally(); return(ret); } catch (Exception e) { Logger.app.a("LSSettings deserialize postprocessing failed"); System.Windows.Forms.MessageBox.Show( "Failed to initialize settings object:\nPossibly from an outdated version of «Loopstream.ini», though more likely a developer fuckup. Go tell ed this:\n\n" + e.Message + "\n\n" + e.Source + "\n\n" + e.InnerException + "\n\n" + e.StackTrace); } } Logger.app.a("Creating new LSSettings"); ret = new LSSettings(); Logger.app.a("LSSettings OK"); ret.initFinally(); // it is 06:20 am, what are you looking at return(ret); }
private string serialize(LSSettings.LSMeta lsm) { var cfg = new System.Xml.XmlWriterSettings(); cfg.NamespaceHandling = System.Xml.NamespaceHandling.OmitDuplicates; cfg.NewLineHandling = System.Xml.NewLineHandling.None; cfg.NewLineOnAttributes = false; cfg.OmitXmlDeclaration = true; cfg.Indent = false; var sb = new StringBuilder(); var x = new System.Xml.Serialization.XmlSerializer(lsm.GetType()); var w = System.Xml.XmlWriter.Create(sb, cfg); x.Serialize(w, lsm); w.Flush(); w.Close(); return sb.ToString(); }
void t_Tick(object sender, EventArgs e) { ((Timer)sender).Stop(); try { var se = new SerializableException(ex); gi = new GeneralInfo(se, ex); LSSettings s = LSSettings.singleton; try { if (s == null) { s = new LSSettings(); s.host = "nullsettings"; } s.serverPresets = new List <LSSettings.LSServerPreset>(); s.pass = "******"; GeneralInfo.ser(s); } catch { } try { if (s.devs == null) { s.devs = new LSDevice[0]; } GeneralInfo.ser(s.devs); } catch { try { s.devs = new LSDevice[0]; } catch { } } StringBuilder sb = new StringBuilder(); sb.AppendLine(); bool ok1, ok2, ok3, oks; ok1 = ok2 = ok3 = oks = false; try { ok1 = s.devRec != null && s.devRec.mm != null; ok2 = s.devMic != null && s.devMic.mm != null; ok3 = s.devOut != null && s.devOut.mm != null; sb.AppendLine("dev state indicated: " + ok1 + ", " + ok2 + ", " + ok3); LSSettings.singleton.init(); s.runTests(null, true); ok1 = ok1 == (s.devRec != null && s.devRec.mm != null); ok2 = ok2 == (s.devMic != null && s.devMic.mm != null); ok3 = ok3 == (s.devOut != null && s.devOut.mm != null); sb.AppendLine("dev state correct: " + ok1 + ", " + ok2 + ", " + ok3); oks = true; } catch { } try { sb.AppendLine("\n\n\n\n\nCache for ogg"); sb.AppendLine(Logger.ogg.compile()); sb.AppendLine("\n\n\n\n\nCache for mp3"); sb.AppendLine(Logger.mp3.compile()); sb.AppendLine("\n\n\n\n\nCache for pcm"); sb.AppendLine(Logger.pcm.compile()); sb.AppendLine("\n\n\n\n\nCache for med"); sb.AppendLine(Logger.med.compile()); sb.AppendLine("\n\n\n\n\nCache for mix"); sb.AppendLine(Logger.mix.compile()); sb.AppendLine("\n\n\n\n\nCache for tag"); sb.AppendLine(Logger.tag.compile()); sb.AppendLine("\n\n\n\n\nCache for app"); sb.AppendLine(Logger.app.compile()); } catch { } gi.moar = sb.ToString(); string serialized = gi.ToString(); gDesc.Enabled = true; gDesc.Text = defaultmsg; gExit.Enabled = true; gSend.Enabled = true; gSend.Focus(); /*string one = Z.gze(serialized); * string two = Z.lze(serialized); * gDesc.Text = * one.Length + "\n" + * two.Length + "\n\n" + * Convert.FromBase64String(one).Length + "\n" + * Convert.FromBase64String(two).Length + "\n\n" + * serialized; * * System.IO.File.WriteAllBytes("dump.txt", Encoding.UTF8.GetBytes(serialized)); * System.IO.File.WriteAllBytes("dump.gz", Convert.FromBase64String(one)); * System.IO.File.WriteAllBytes("dump.lzma", Convert.FromBase64String(two));*/ if (oks && (!ok1 || !ok2 || !ok3)) { if (DialogResult.Yes == MessageBox.Show( "The bad news: Loopstream just crashed :(\n" + "The good news: I think I know why!\n\n" + "Did you disconnect or disable your speakers or microphone?\n" + "'cause you need to restart Loopstream every time you do that.\n\n" + "Wanna go for a restart?", "Dirty devices detected", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)) { Program.fixWorkingDirectory(); } } } catch (Exception exx) { gDesc.Enabled = true; try { gDesc.Text = "Shit is properly f****d, can't send error information to devs\r\n" + "This is the best I can do:\r\n\r\n" + ex.Message + "\r\n\r\n" + ex.StackTrace; } catch { gDesc.Text = "Shit is properly f****d, can't send error information to devs"; } gExit.Enabled = true; gExit.Focus(); } }
public ConfigSC(LSSettings settings) { this.settings = settings; InitializeComponent(); pTabs.BringToFront(); }