private void btnImportSamplesFromMix_Click(object sender, EventArgs e) { var mixSamples = TrackSampleLibrary.GetMixSectionsAsSamples(LibraryTrack); Samples.AddRange(mixSamples); UpdateCurrentSample(); BindSamples(); }
public void UpdateTrackSamples(Track track, List <Sample> trackSamples) { Samples.RemoveAll( x => x.TrackTitle == track.Title && x.TrackArtist == track.Artist && x.TrackLength == track.FullLength); trackSamples.ForEach(x => UpdateSampleFromTrack(x, track)); Samples.AddRange(trackSamples); }
private void _Initialize(string[] dimensions, double[][] samples) { m_dimensions = dimensions; m_pmax = new double[m_dimensions.Length]; Distributions = new UnivariateContinuousDistribution[m_dimensions.Length]; if (samples != null) { Samples.AddRange(samples); } }
private void _Initialize(int dimension, double[][] samples) { m_dimension = dimension; m_pmax = new double[m_dimension]; Distributions = new IFittableDistribution <double> [m_dimension]; if (samples != null) { Samples.AddRange(samples); } }
/// <summary> /// Loads the library from the cache. /// </summary> public void LoadFromCache() { if (!File.Exists(SampleLibraryFilename)) { return; } var samples = SerializationHelper <List <Sample> > .FromXmlFile(SampleLibraryFilename); lock (Samples) { Samples.Clear(); Samples.AddRange(samples.ToArray()); } }
private void Scaner_DataReceived(AbstractScaner scaner, T_BJ_SampleRack sampleRack) { byte?curIndex = null; for (byte i = 0; i < 3; i++) { if (scanerVals[i] == null) { scanerVals[i] = scaner.Read(); curIndex = i; break; } } if (curIndex == 2) { byte i1, i2; if (scanerVals[1].Length > 2 && scanerVals[0].Length <= 2 && scanerVals[2].Length <= 2 && byte.TryParse(scanerVals[0], out i1) && byte.TryParse(scanerVals[2], out i2)) { if (Math.Abs(i1 - i2) == 1) { var w = (byte)(Math.Min(i1, i2) - 1); var sample = Samples.Where(sam => sam.RackIndex == sampleRack.Index && sam.Index == w).FirstOrDefault(); if (sample == null) { sample = new SampleInfo() { RackIndex = sampleRack.Index, Index = w }; Samples.Add(sample); } sample.Barcode = scanerVals[1]; var list = Samples.OrderBy(item => item.RackIndex.ToString() + item.Index.ToString("00")).ToArray(); Samples.Clear(); Samples.AddRange(list); } scanerVals[0] = scanerVals[2]; scanerVals[1] = null; scanerVals[2] = null; } else { scanerVals[0] = scanerVals[1]; scanerVals[1] = scanerVals[2]; scanerVals[2] = null; } } }
public void AddSamples(Sample[] samples) { UpdateTime = DateTime.UtcNow; if (samples == null || samples.Length == 0) { return; } // If the last index of the new samples is the same as the last index seen -- duplicate packet (ignore) if ((int)samples[samples.Length - 1].Index == LastIndex && LastIndex != 0) { Console.WriteLine("WARNING: Duplicate packet detected (last index: " + LastIndex + ") - ignoring."); return; } // If not a duplicate, and the first index of the new samples is earlier than the last index seen -- must be restart if ((int)samples[0].Index < LastIndex && LastIndex != 0) { // Must have re-started broadcast, clear history //if (LastIndex - (int)samples[0].Index > 20) Console.WriteLine("WARNING: Restart detected (index: " + samples[0].Index + ", last index: " + LastIndex + ") - clearing history."); Clear(); LastIndex = (int)samples[0].Index - 1; } // Calculate number of missed packets int numMissed = (int)(samples[0].Index - LastIndex - 1); if (numMissed < 0) { numMissed = 0; } if (numMissed > 1000) { numMissed = 1000; } if (numMissed > 0) { Console.WriteLine("WARNING: Dropped packet(s) detected, missing samples: " + numMissed); } // Add any missing samples Sample[] missedSamples = new Sample[numMissed]; for (int i = 0; i < missedSamples.Length; i++) { missedSamples[i] = new Sample((uint)++LastIndex); } Samples.AddRange(missedSamples); // Add samples int firstIndex = Samples.Count; int length = samples.Length; Samples.AddRange(samples); // Update last index LastIndex = (int)(Samples[Samples.Count - 1].Index); // Trim to maximum samples range if (Samples.Count > MaxHistory) { firstIndex -= Samples.Count - MaxHistory; if (firstIndex < 0) { length += firstIndex; firstIndex = 0; } Samples.RemoveRange(0, Samples.Count - MaxHistory); } }