public Screen48(SpectrumBase machine) : base(machine) { // interrupt InterruptStartTime = 3; InterruptLength = 32; // offsets RenderTableOffset = 56; ContentionOffset = 6; FloatingBusOffset = 1; // timing ClockSpeed = 3500000; FrameCycleLength = 69888; ScanlineTime = 224; BorderLeftTime = 24; BorderRightTime = 24; FirstPaperLine = 64; FirstPaperTState = 64; // screen layout Border4T = true; Border4TStage = 0; ScreenWidth = 256; ScreenHeight = 192; BorderTopHeight = 48; // 55;// 48; BorderBottomHeight = 48; // 56; BorderLeftWidth = 48; BorderRightWidth = 48; ScanLineWidth = BorderLeftWidth + ScreenWidth + BorderRightWidth; RenderingTable = new RenderTable(this, MachineType.ZXSpectrum48); SetupScreenSize(); }
public SpectraContainerBase(IProject parentProject, string name, IModel model, ICollection <string> spectraPaths, ICollection <GroupDefinition> groupsDefinition) { int dataLength = 0; int bufferStart = 0; if (model.SpectrumType.GetInterface("ISpectrum") == null) { throw new SpectrumLoadException("invalid spectrumType. spectrumType must be implementation of ISpectrum"); } this._name = name; this._parentProject = parentProject; this._enabled = true; Assembly ass = Assembly.GetAssembly(model.SpectrumType); model.GroupsDefinition = (GroupDefinition[])groupsDefinition; this._model = model; _spectra = new List <ISpectrum>(); int stat; foreach (string path in spectraPaths) { using (TextReader reader = new StreamReader(path)) { dataLength += SpectrumBase.getSpectrumData(reader, true, null, -1, out stat); } } this._data = new int[dataLength]; this._weights = new double[dataLength]; foreach (string path in spectraPaths) { string typeName = model.SpectrumType.ToString(); BindingFlags bindingFlags = BindingFlags.CreateInstance; object[] args = new object[] { path, this, bufferStart }; SpectrumBase spectrum = (SpectrumBase)ass.CreateInstance(typeName, true, bindingFlags, null, args, null, null); if (spectrum != null) { _spectra.Add(spectrum); } //spectrum.getExperimentalSpectrum( bufferStart = spectrum.BufferEndPos + 1; //progress++; if (OpenProgressChanged != null) { OpenProgressChanged(this, null); //new System.ComponentModel.ProgressChangedEventArgs((int)Math.Round(100 * ((double)progress / (double)spectraPaths.Count)), null)); } } }
public ULA128(SpectrumBase machine) : base(machine) { InterruptPeriod = 36; LongestOperationCycles = 64 + 2; FrameLength = 70908; ClockSpeed = 3546900; contentionTable = new byte[70930]; floatingBusTable = new short[70930]; for (int f = 0; f < 70930; f++) { floatingBusTable[f] = -1; } CharRows = 24; CharCols = 32; ScreenWidth = 256; ScreenHeight = 192; BorderTopHeight = 48; BorderBottomHeight = 56; BorderLeftWidth = 48; BorderRightWidth = 48; DisplayStart = 16384; DisplayLength = 6144; AttributeStart = 22528; AttributeLength = 768; borderColour = 7; ScanLineWidth = BorderLeftWidth + ScreenWidth + BorderRightWidth; TstatesPerScanline = 228; TstateAtTop = BorderTopHeight * TstatesPerScanline; TstateAtBottom = BorderBottomHeight * TstatesPerScanline; tstateToDisp = new short[FrameLength]; ScreenBuffer = new int[ScanLineWidth * BorderTopHeight //48 lines of border + ScanLineWidth * ScreenHeight //border + main + border of 192 lines + ScanLineWidth * BorderBottomHeight]; //56 lines of border attr = new short[DisplayLength]; //6144 bytes of display memory will be mapped SetupScreenSize(); Reset(); }
public void ImportedSpectrums_SelectionChanged(SelectionChangedEventArgs args) { var existingSeries = Plotter.GetExistingSeries("Imported"); if (existingSeries != null) { Plotter.PlotFrame.Series.Remove(existingSeries); } var existingTransition = Transitions.Where(x => x.Name == "Imported"); if (existingTransition != null && existingTransition.Any()) { Transitions.Remove(existingTransition.First()); } existingSeries = Plotter.GetExistingSeries("Imported Peaks"); if (existingSeries != null) { Plotter.PlotFrame.Series.Remove(existingSeries); } existingTransition = Transitions.Where(x => x.Name == "Imported Peaks"); if (existingTransition != null && existingTransition.Any()) { Transitions.Remove(existingTransition.First()); } SelectedImportedSpectrum = args.AddedItems.Cast <object>().Where(x => x is SpectrumBase).Count() == 1 ? args.AddedItems.Cast <SpectrumBase>().First() : null; if (SelectedImportedSpectrum != null) { Spectrum spectrum = new Spectrum(SelectedImportedSpectrum); Plotter.Plot(spectrum, null, SpectrumType.Imported); Transitions.Add(new ListViewTransitionItem() { Name = spectrum.Optimized.Name }); Transitions.Add(new ListViewTransitionItem() { Name = spectrum.Peaks.Name }); } }
public void AddToDatabase(object parameter) { IWindowManager manager = new WindowManager(); var vm = new AddToDatabaseDialogViewModel(Plotter.PlotFrame.Title); var result = manager.ShowDialog(vm, null, null); if (result == true) { SpectrumBase spectrumBase = new SpectrumBase() { Name = vm.SpectrumName, Data = string.Join(";", AnalyzingSpectrum.Optimized.Data.Select(x => x.X + ":" + x.Y).ToArray()), Peaks = string.Join(";", (Plotter.GetExistingSeries("Peaks") as ScatterSeries).Points.Select(x => x.X + ":" + x.Y).ToArray()) }; Database.GetConnection().Insert(spectrumBase); } }
private void Initialize() { if (_capture != null) { Cleanup(); } // This uses the wasapi api to get any sound data played by the computer _capture = new WasapiLoopbackCapture(20); _capture.Initialize(); var source = new SoundInSource(_capture).ToSampleSource(); _capture.DataAvailable += Capture_DataAvailable; var notificationSource = new SingleBlockNotificationStream(source); notificationSource.SingleBlockRead += NotificationSource_SingleBlockRead; _finalSource = notificationSource.ToWaveSource(); _rawBuffer = new byte[_finalSource.WaveFormat.BytesPerSecond / 2]; // Actual fft data _fftBuffer = new float[(int)FftSize]; _spectrum = new SpectrumBase() { SpectrumProvider = new BasicSpectrumProvider( _capture.WaveFormat.Channels, _capture.WaveFormat.SampleRate, FftSize ), UseAverage = UseAverage, IsXLogScale = UseLogScale, ScalingStrategy = ScalingStrategy, MinimumFrequency = MinimumFrequency, MaximumFrequency = MaximumFrequency, SpectrumResolution = FftBinCount, FftSize = FftSize, }; _capture.Start(); }
public Screen128Plus2a(SpectrumBase machine) : base(machine) { // interrupt InterruptStartTime = 0; InterruptLength = 32; // offsets RenderTableOffset = 58; ContentionOffset = 9; FloatingBusOffset = 0; // timing ClockSpeed = 3546900; FrameCycleLength = 70908; ScanlineTime = 228; BorderLeftTime = 24; BorderRightTime = 24; FirstPaperLine = 63; FirstPaperTState = 64; // screen layout Border4T = true; Border4TStage = 2; ScreenWidth = 256; ScreenHeight = 192; BorderTopHeight = 48; // 55; BorderBottomHeight = 48; // 56; BorderLeftWidth = 48; BorderRightWidth = 48; ScanLineWidth = BorderLeftWidth + ScreenWidth + BorderRightWidth; RenderingTable = new RenderTable(this, MachineType.ZXSpectrum128Plus2a); SetupScreenSize(); GenerateP3PortTable(); }
private void getModels(string filePath) { Stream stream = null; ImportedModel currentModel = null; IParameterSet currentSet = null; IGroup group = null; bool parametersXmlArea = true; //int i = 0; try { using (XmlReader reader = ProjectBase.getXmlReader(filePath, out stream)) { string modelClass; string name; //reader.ReadToFollowing("models"); while (reader.Read() && parametersXmlArea) { switch (reader.Name) { case "spectra": if (reader.MoveToFirstAttribute()) { modelClass = String.Empty; name = String.Empty; do { switch (reader.Name) { case "name": name = reader.Value; break; case "class": modelClass = reader.Value; break; // AvailableAssemblies.getModel(reader.Value); break; } } while (reader.MoveToNextAttribute()); if (name != String.Empty && modelClass != String.Empty) { _importedModels.Add(currentModel = new ImportedModel(modelClass, name)); _modelNames.Add(name); } } reader.MoveToElement(); break; case "spectrum": //only start elemement has attributes. end elements are not analysed if (reader.IsStartElement()) { if (currentModel == null) { throw new Exception(); } //if (currentSet != null) // currentModel.parameters.Add(currentSet); if (reader.ReadToFollowing("ps")) { currentSet = new ParameterSet(); } } else { currentModel.parameters.Add(currentSet); reader.MoveToElement(); currentSet = null; } break; case "group": if (reader.HasAttributes) { if (currentSet == null) { throw new Exception(); } //while (reader.Read()) { //groups if (reader.Name == "group") { XmlReader groupReader = reader.ReadSubtree(); group = SpectrumBase.getGroup(groupReader, null, currentModel.model); currentSet.addGroup(group); groupReader.Close(); } } break; case "models": if (!reader.HasAttributes) { parametersXmlArea = false; } break; } } if (_modelNames.Count > 0) { _modelNames.Insert(0, "(none)"); } } } catch (Exception) { throw new ImportException(String.Format("Failed to import parameters from {0}", filePath)); } finally { if (stream != null) { stream.Close(); } } if (_modelNames.Count == 0) { throw new ImportException(String.Format("{0}\ndoesn't contain any importable parameter values.", filePath)); } }
protected void ReadXml(XmlReader reader, string modelDirectory) { int dataBufferPos = 0; object[] args = new object[4]; args[2] = this; //reader.Read(); //declaration //reader.Read(); //root --> spectra node if (!reader.ReadToFollowing("spectra")) { return; } //XmlDocument doc = new XmlDocument(); //doc.Load(filePath); //this._name = doc.DocumentElement.Attributes["name"].Value; string modelClassName = ""; this._enabled = true; this._data = null; while (reader.MoveToNextAttribute()) { switch (reader.Name) { case "name": this._name = reader.Value; break; case "class": modelClassName = reader.Value; break; case "enabled": this._enabled = Convert.ToBoolean(reader.Value); break; case "dataLength": this._data = new int[int.Parse(reader.Value)]; this._weights = new double[this._data.Length]; break; } } if (this._data == null) { throw new SpectrumLoadException("Project files are damaged or this version is no more supported (missing dataLength node)"); } //string modelClassName = doc.DocumentElement.Attributes["class"].Value; //doc.GetElementsByTagName("modelclass")[0].Attributes["name"].Value; this._model = AvailableAssemblies.getModel(modelClassName); if (this._model.SpectrumType.GetInterface("ISpectrum") == null) { throw new SpectrumLoadException("invalid spectrumType. spectrumType must be implementation of ISpectrum"); } Assembly ass = Assembly.GetAssembly(this._model.SpectrumType); _spectra = new List <ISpectrum>(); string typeName = this._model.SpectrumType.ToString(); //int progress = 0; //int spectraCount = Directory.GetFiles(Path.Combine(Path.GetDirectoryName(filePath), "spectra")).Length; while (reader.Read()) //spectrum { if (reader.Name == "spectrum") { XmlReader spectrumReader = reader.ReadSubtree(); BindingFlags bindingFlags = BindingFlags.CreateInstance; // = new object[] { spectrumReader, modelDirectory, this, dataBufferPos }; args[0] = spectrumReader; args[1] = modelDirectory; args[3] = dataBufferPos; SpectrumBase spectrum = (SpectrumBase)ass.CreateInstance(typeName, true, bindingFlags, null, args, null, null); if (spectrum != null) { _spectra.Add(spectrum); } dataBufferPos = spectrum.BufferEndPos + 1; } else { break; } if (OpenProgressChanged != null) { OpenProgressChanged(this, null); //new System.ComponentModel.ProgressChangedEventArgs((int)Math.Round(100 * ((double)++progress / (double)Spectra.Count)), parentProject)); } } }