// Required by ITransform inteface, wrapper to true ResultsToxTimings procedure requiring more parameters public int ResultsToxTimings(string resultsFile, vamps.AlignmentType alignmentType, vamps.LabelTypes labelType) { return(ResultsToxTimings(resultsFile, alignmentType, labelType)); }
// 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
// Required by ITransform inteface, wrapper to true ResultsToxTimings procedure requiring more parameters public int ResultsToxTimings(string resultsFile, vamps.AlignmentType alignmentType, vamps.LabelTypes labelType) { int err = 0; if ((xBars == null) || (xBars.effects.Count < 2) || (!ReuseResults)) { 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 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); if (alignmentType == vamps.AlignmentType.FPS20) { fps = 20; msPF = 50; } else { if (alignmentType == vamps.AlignmentType.FPS40) { fps = 40; msPF = 25; } else { // if (alignmentType == vamps.AlignmentType.None) // or if alignmentType == anything else (which would be invalid!) //{ fps = 1000; msPF = 1; //} } } // Pass 1, count lines StreamReader reader = new StreamReader(resultsFile); while (!reader.EndOfStream) { lineIn = reader.ReadLine(); countLines++; } reader.Close(); xBars = new xTimings("Bars" + " (Whole notes, (" + BeatsPerBar.ToString() + " Quarter notes))"); xBeatsFull = new xTimings("Beats-Full (Quarter notes)"); xBeatsHalf = new xTimings("Beats-Half (Eighth notes)"); xBeatsThird = new xTimings("Beats-Third (Twelth notes)"); xBeatsQuarter = new xTimings("Beats-Quarter (Sixteenth notes)"); // 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 = xUtils.RoundTimeTo(millisecs, msPF); lastBeat = millisecs; lastBar = millisecs; } // 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]); // FULL BEATS - QUARTER NOTES millisecs = xUtils.RoundTimeTo(millisecs, msPF); beatLength = millisecs - lastBeat; xBeatsFull.Add(countBeats.ToString(), lastBeat, millisecs, countBeats); countBeats++; // BARS if (countBeats > maxBeats) { countBeats = 1; xBars.Add(countBars.ToString(), lastBar, millisecs, countBars); countBars++; lastBar = millisecs; } // HALF BEATS - EIGHTH NOTES subBeat = lastBeat + (beatLength / 2); subBeat = xUtils.RoundTimeTo(subBeat, msPF); xBeatsHalf.Add(countHalves.ToString(), lastBeat, subBeat, countHalves); countHalves++; xBeatsHalf.Add(countHalves.ToString(), subBeat, millisecs, countHalves); countHalves++; if (countHalves > maxHalves) { countHalves = 1; } // THIRD BEATS - TWELTH NOTES subBeat = lastBeat + (beatLength / 3); subBeat = xUtils.RoundTimeTo(subBeat, msPF); xBeatsThird.Add(countThirds.ToString(), lastBeat, subBeat, countThirds); countThirds++; subSubBeat = lastBeat + (beatLength * 2 / 3); subSubBeat = xUtils.RoundTimeTo(subSubBeat, msPF); xBeatsThird.Add(countThirds.ToString(), subBeat, subSubBeat, countThirds); countThirds++; xBeatsThird.Add(countThirds.ToString(), subSubBeat, millisecs, countThirds); countThirds++; if (countThirds > maxThirds) { countThirds = 1; } // QUARTER BEATS - SIXTEENTH NOTES subBeat = lastBeat + (beatLength / 4); subBeat = xUtils.RoundTimeTo(subBeat, msPF); xBeatsQuarter.Add(countQuarters.ToString(), lastBeat, subBeat, countQuarters); countQuarters++; subSubBeat = lastBeat + (beatLength / 2); subSubBeat = xUtils.RoundTimeTo(subSubBeat, msPF); xBeatsQuarter.Add(countQuarters.ToString(), subBeat, subSubBeat, countQuarters); countQuarters++; subSubSubBeat = lastBeat + (beatLength * 3 / 4); subSubSubBeat = xUtils.RoundTimeTo(subSubSubBeat, msPF); xBeatsQuarter.Add(countQuarters.ToString(), subSubBeat, subSubSubBeat, countQuarters); countQuarters++; xBeatsQuarter.Add(countQuarters.ToString(), subSubSubBeat, millisecs, countQuarters); countQuarters++; if (countQuarters > maxQuarters) { countQuarters = 1; } lastBeat = millisecs; onsetCount++; } // end line contains a period } // end while loop more lines remaining reader.Close(); totalMilliseconds = lastBeat; totalCentiseconds = lastBeat / 10; //int t = xBars.effects[0].starttime; int t = 0; int f = 1; if (alignmentType == vamps.AlignmentType.FPS10) { xFrames.timingName = "Frames 10FPS, 10cs"; while (t <= totalMilliseconds) { if (t > 0) { xFrames.Add(f.ToString(), t, t + 100); } t += 100; f++; } } if (alignmentType == vamps.AlignmentType.FPS20) { xFrames.timingName = "Frames 20FPS, 5cs"; while (t <= totalMilliseconds) { if (t > 0) { xFrames.Add(f.ToString(), t, t + 50); } t += 50; f++; } } if (alignmentType == vamps.AlignmentType.FPS30) { xFrames.timingName = "Frames 30FPS, 3.33cs"; while (t <= totalMilliseconds) { if (t > 0) { xFrames.Add(f.ToString(), t, t + 33); f++; xFrames.Add(f.ToString(), t + 33, t + 67); f++; xFrames.Add(f.ToString(), t + 67, t + 100); } t += 100; f++; } } if (alignmentType == vamps.AlignmentType.FPS40) { xFrames.timingName = "Frames 40FPS, 2.5cs"; while (t < totalMilliseconds) { if (t > 0) { xFrames.Add(f.ToString(), t, t + 25); } t += 25; f++; } } if (alignmentType == vamps.AlignmentType.FPS60) { xFrames.timingName = "Frames 60FPS, 1.667cs"; while (t <= totalMilliseconds) { if (t > 0) { xFrames.Add(f.ToString(), t, t + 17); f++; xFrames.Add(f.ToString(), t + 17, t + 33); f++; xFrames.Add(f.ToString(), t + 33, t + 50); f++; xFrames.Add(f.ToString(), t + 50, t + 67); f++; xFrames.Add(f.ToString(), t + 67, t + 83); f++; xFrames.Add(f.ToString(), t + 83, t + 100); } t += 100; f++; } } } Annotator.xBars = xBars; Annotator.xBeatsFull = xBeatsFull; Annotator.xBeatsHalf = xBeatsHalf; Annotator.xBeatsThird = xBeatsThird; Annotator.xBeatsQuarter = xBeatsQuarter; return(err); } // end Beats