Beispiel #1
0
        private void OpenFile(string datafile)
        {
            ReplayStop();

            Task t = new Task(() =>
            {
                try
                {
                    //_logReader = new TelemetryLogReader(datafile);
                    _logReader = new TelemetryLogReplay(datafile);
                    _logReader.Read();
                    while (_logReader.Progress == 0)
                    {
                        ;
                    }
                    while (_logReader.Progress != 1000)
                    {
                        ;
                    }
                    TelemetryFile = datafile;
                    GraphFill();
                    DrawPlotbounds();
                    _logReader.Start();
                }
                catch (Exception ex)
                {
                    _logReader = null;
                }
            });

            t.Start();
        }
        private void OpenFile(string datafile)
        {
            ReplayStop();

            Task t = new Task(() =>
                                  {
                                      try
                                      {
                                          //_logReader = new TelemetryLogReader(datafile);
                                          _logReader = new TelemetryLogReplay(datafile);
                                          _logReader.Read();
                                          while (_logReader.Progress == 0) ;
                                          while (_logReader.Progress != 1000) ;
                                          TelemetryFile = datafile;
                                          GraphFill();
                                          DrawPlotbounds();
                                          _logReader.Start();
                                      }
                                      catch(Exception ex)
                                      {
                                          _logReader = null;
                                      }
                                  });
            t.Start();
        }
Beispiel #3
0
        public ReplaySFX(Form f, TelemetryLogReplay replay)
        {
            _mForm = f;
            MaxEngineRegionVolume = 0;

            //This code is extremely messy. It's functions as a testcase.
            string SFX_File = @"C:\Program Files (x86)\rFactor\GameData\Vehicles\F1_2010_CODEMASTERS\2010\All_Teams\Vodafone McLaren\McLaren_Sounds10.sfx";

            if (!File.Exists(SFX_File))
            {
                MessageBox.Show("Can't find audio file.");
                return;
            }
            string[] data = File.ReadAllLines(SFX_File);
            Dictionary <string, string> keys = new Dictionary <string, string>();

            for (int i = 0; i < data.Length; i++)
            {
                string d = data[i];
                if (d.Trim().Length > 1 && d.Contains("=") && d.StartsWith("//") == false)
                {
                    if (d.Contains("//"))
                    {
                        d = d.Substring(0, d.IndexOf("//")).Trim(); // remove comments
                    }
                    string[] ds = d.Split("=".ToCharArray(), 2);
                    if (i + 4 < data.Length && data[i + 1].Trim() == "{") // next line is { , then it means we get a block.
                    {
                        if (ds[0].Contains("Inside"))                     // we don't do outside noises
                        {
                            EngineRpmRegion r = new EngineRpmRegion();
                            r._mMaster = replay;
                            r.offset   = Convert.ToInt32(ds[1]);
                            r.SFX      = this;
                            r.type     = ((ds[0].Contains("Coast"))
                                          ? EngineRpmRegionType.COAST
                                          : EngineRpmRegionType.POWER);
                            // engine block!
                            // parse this
                            for (int j = i + 1; j < i + 5; j++) // walk through the lines
                            {
                                string sd = data[j];
                                if (sd != "}" && sd != "{")
                                {
                                    if (sd.Contains("//"))
                                    {
                                        sd = sd.Substring(0, sd.IndexOf("//")).Trim();
                                    }
                                    string[] sds = sd.Split("=".ToCharArray());
                                    double   v   = Convert.ToDouble(sds[1]);
                                    switch (sds[0])
                                    {
                                    case "MinimumRPM":
                                        r.Min = v;
                                        break;

                                    case "MaximumRPM":
                                        r.Max = v;
                                        break;

                                    case "NaturalRPM":
                                        r.Nat = v;
                                        break;
                                    }
                                }
                            }
                            FinishRPMRegion(keys, r);
                        }
                        i += 5;
                    }
                    else
                    {
                        if (ds[0].StartsWith("EngRPM") && ds[0].Contains("Inside") && ds[1].Contains("("))
                        {
                            string[] region_data =
                                ds[1].Replace(" ", "").Replace("(", "").Replace(")", "").Split(",".ToCharArray());

                            EngineRpmRegion r = new EngineRpmRegion();
                            r._mMaster = replay;
                            r.offset   = Convert.ToInt32(region_data[0]);
                            r.SFX      = this;
                            r.type     = ((ds[0].Contains("Coast"))
                                          ? EngineRpmRegionType.COAST
                                          : EngineRpmRegionType.POWER);
                            r.Min = Convert.ToDouble(region_data[1]);
                            r.Max = Convert.ToDouble(region_data[2]);
                            r.Nat = Convert.ToDouble(region_data[3]);

                            FinishRPMRegion(keys, r);
                        }
                        if (keys.ContainsKey(ds[0]) == false)
                        {
                            keys.Add(ds[0], ds[1]);
                        }
                        else
                        {
                        }
                    }
                }
            }

            // Do load blend
            string EngineLoadBlendInside = keys["EngineLoadBlendInside"].Replace("(", "").Replace(")", "");

            string[] EngineLoadBlendInside_Split = EngineLoadBlendInside.Split(",".ToCharArray());

            this.Throttle_LoadBlend_Low  = Convert.ToDouble(EngineLoadBlendInside_Split[0]);
            this.Throttle_LoadBlend_High = Convert.ToDouble(EngineLoadBlendInside_Split[1]);

            for (int i = 0; i < Regions.Count; i++)
            {
                Regions[i].VolumeMultiplier /= MaxEngineRegionVolume;
            }

            // shift noises!
            Timer t = new Timer();

            t.Interval = 1;
            t.Tick    += new EventHandler(t_Tick);
            t.Start();

            foreach (KeyValuePair <string, string> k in keys)
            {
                if (k.Key.StartsWith("VS_INSIDE_SHIFT_UP_"))
                {
                    System.Media.SoundPlayer sp = new System.Media.SoundPlayer(Sound_Directory + k.Value);
                    UpShifts.Add(sp);
                }
                if (k.Key.StartsWith("VS_INSIDE_SHIFT_DOWN_"))
                {
                    System.Media.SoundPlayer sp = new System.Media.SoundPlayer(Sound_Directory + k.Value);
                    DownShifts.Add(sp);
                }
                if (k.Key.StartsWith("VS_INSIDE_BACKFIRE_"))
                {
                    System.Media.SoundPlayer sp = new System.Media.SoundPlayer(Sound_Directory + k.Value);
                    Backfire.Add(sp);
                }
            }

            // traction control sound
            if (keys.ContainsKey("VS_INSIDE_TRACTION_CONTROL"))
            {
                TractionControlPlayer = new SoundPlayer(_mForm.Controls[0], SoundPlayer.PullAudio, Sound_Directory + keys["VS_INSIDE_TRACTION_CONTROL"], 1);
                TractionControlPlayer.PullAFrequency = Unity;
                TractionControlPlayer.PullVolume     = GetTractionControlVol;
                TractionControlPlayer.Resume();
            }
        }