private void AddDetectionMethod(DetectionMethodsTypeDetection_Method detectionMethod) { if (detectionMethod != null) { if (DetectionMethods == null) { DetectionMethods = new List <DetectionMethod>(); } DetectionMethods.Add(new DetectionMethod(detectionMethod.Method.GetXmlEnumLabel(), detectionMethod.Description.ConvertToString(), detectionMethod.Effectiveness.GetXmlEnumLabel())); } }
// The true ResultsToxTimings procedure requiring more parameters, (not compliant with ITransform inteface) public int ResultsToxTimings(string resultsFile, vamps.AlignmentType alignmentType, vamps.LabelTypes labelType, DetectionMethods detectMethod = DetectionMethods.ComplexDomain) { int err = 0; bool redo = true; if (xOnsets == null) { xOnsets = new xTimings("Note Onsets"); } if ((xOnsets.effects.Count > 0) && (!ReuseResults)) { xOnsets.effects.Clear(); } //TODO Fix this so it works correctly //if ((xOnsets == null) || (!ReuseResults)) //if (xOnsets == null) { int onsetCount = 0; string lineIn = ""; int lastBeat = 0; int lastBar = -1; int beatLength = 0; int ppos = 0; int millisecs = 0; int subBeat = 0; int subSubBeat = 0; int subSubSubBeat = 0; int theTime = 0; int milliLen = 0; string noteNum = ""; int midiNum = -1; string label = "1"; int countLines = 0; int countBars = 1; int countBeats = FirstBeat; int countHalves = 1; int countThirds = 1; int countQuarters = 1; int maxBeats = BeatsPerBar; int maxHalves = BeatsPerBar * 2; int maxThirds = BeatsPerBar * 3; int maxQuarters = BeatsPerBar * 4; //int align = seqFunct.GetAlignment(cboAlignBarsBeats.Text); fps = 1000; msPF = 1; switch (alignmentType) { case vamps.AlignmentType.FPS10: fps = 10; msPF = 100; break; case vamps.AlignmentType.FPS20: fps = 20; msPF = 50; break; case vamps.AlignmentType.FPS30: fps = 30; msPF = 33; break; case vamps.AlignmentType.FPS40: fps = 40; msPF = 25; break; case vamps.AlignmentType.FPS60: fps = 60; msPF = 17; break; case vamps.AlignmentType.BeatsFull: Annotator.xAlignTo = Annotator.xBeatsFull; break; case vamps.AlignmentType.BeatsHalf: Annotator.xAlignTo = Annotator.xBeatsHalf; break; case vamps.AlignmentType.BeatsThird: Annotator.xAlignTo = Annotator.xBeatsThird; break; case vamps.AlignmentType.BeatsQuarter: Annotator.xAlignTo = Annotator.xBeatsQuarter; break; } Annotator.alignIdx = 0; // Reset // Pass 1, count lines StreamReader reader = new StreamReader(resultsFile); while (!reader.EndOfStream) { lineIn = reader.ReadLine(); countLines++; } reader.Close(); // Pass 2, read data into arrays reader = new StreamReader(resultsFile); if (!reader.EndOfStream) { lineIn = reader.ReadLine(); ppos = lineIn.IndexOf('.'); if (ppos > xUtils.UNDEFINED) { string[] parts = lineIn.Split(','); millisecs = xUtils.ParseMilliseconds(parts[0]); millisecs = Annotator.AlignTimeTo(millisecs, alignmentType); lastBeat = millisecs; lastBar = millisecs; if (parts.Length > 1) { milliLen = xUtils.ParseMilliseconds(parts[1]); } if (parts.Length > 2) { noteNum = parts[2]; if (noteNum.Length > 0) { midiNum = Int32.Parse(noteNum); if (midiNum > 0) { //label = SequenceFunctions.noteNames[midiNum]; } } } } // end line contains a period } // end while loop more lines remaining while (!reader.EndOfStream) { lineIn = reader.ReadLine(); ppos = lineIn.IndexOf('.'); if (ppos > xUtils.UNDEFINED) { string[] parts = lineIn.Split(','); millisecs = xUtils.ParseMilliseconds(parts[0]); label = countBeats.ToString(); // FULL BEATS - QUARTER NOTES //millisecs = xUtils.RoundTimeTo(millisecs, msPF); // Moved down to below > lastbeat check //millisecs = Annotator.AlignTimeTo(millisecs, alignmentType); beatLength = millisecs - lastBeat; if (parts.Length > 1) { milliLen = xUtils.ParseMilliseconds(parts[1]); } // Has it advanced since the last one? if (millisecs > lastBeat) { // OK, now align it millisecs = Annotator.AlignTimeTo(millisecs, alignmentType); // Is it still past the lastone after alignment? if (millisecs > lastBeat) { // Save it, add it to list xOnsets.Add(label, lastBeat, millisecs, midiNum); // update count countBeats++; // Remember this for next round (in order to skip ones which haven't advanced) lastBeat = millisecs; } } // Get length and midi number for next entry if (parts.Length > 2) { noteNum = parts[2]; if (noteNum.Length > 0) { midiNum = Int32.Parse(noteNum); if (midiNum > 0) { //label = SequenceFunctions.noteNames[midiNum]; } } } onsetCount++; } // end line contains a period } // end while loop more lines remaining xOnsets.Add(label, lastBeat, millisecs, midiNum); reader.Close(); } return(err); } // end Beats