public int[] Classify(int[] tempBeat, int rr, int noiseLevel, boolean init) { int rhythmClass, beatClass, beatWidth, blShift, diff_onoff; double matchIndex, domIndex, mi2; int shiftAdj, fidAdj; int domType, domWidth, onset, offset, amp, r, rlist; int beatBegin, beatEnd, tempClass; int hfNoise, isoLevel, maxSlope; int flag, beatType; int[] detect = new int[14]; double[] matchSynos = new double[4]; BeatDectAndClassify bdac = new BeatDectAndClassify(); RYTHMCHK rythmchk = new RYTHMCHK(); MATCH match = new MATCH(); POSTCLAS postclas = new POSTCLAS(); NOISECHK noisechk = new NOISECHK(); ANALBEAT analbeat = new ANALBEAT(); if (init) { rythmchk.ResetRhythmChk(); match.ResetMatch(); postclas.ResetPostClassify(); noisechk.ResetNoiseCheck(); morphType = runCount = 0; lastIsoLevel = lastBeatWasNew = 0; lastRhythmClass = UNKNOWN; DomMonitor(0, 0, 0, 0, 1); int[] RecentRRs = new int[8]; int[] RecentTypes = new int[8]; DomType = 0; return detect; } int[] newBeat = bdac.DownSampleBeat(tempBeat); hfNoise = HFNoiseCheck(newBeat); rhythmClass = rythmchk.RhythmChk(rr); detect = analbeat.AnalyzeBeat(newBeat); /* detect[1] = onset; detect[2] = offset; detect[3] = adjustR; detect[4] = amp; detect[5] = flag; // 1: R鍦ㄦ瀬澶� 0: R鍦ㄦ瀬灏� detect[6] = isoLevel; detect[7] = isoStart; detect[8] = isoEnd; detect[9] = maxSlope; detect[10]= fidAdj; detect[11]= beatType; detect[12]= isDomType; */ onset = detect[1]; offset = detect[2]; r = detect[3]; amp = detect[4]; flag = detect[5]; isoLevel = detect[6]; maxSlope = detect[9]; if (flag == 1) // R涓哄彇鏈�澶у�煎 { if (tempBeat[2 * r - 1] > tempBeat[2 * r] && tempBeat[2 * r - 1] > tempBeat[2 * r + 1]) rlist = 2 * r - 1; else if (tempBeat[2 * r] > tempBeat[2 * r - 1] && tempBeat[2 * r] > tempBeat[2 * r + 1]) rlist = 2 * r; else rlist = 2 * r + 1; } else // R涓哄彇鏈�灏忓�煎 { if (tempBeat[2 * r - 1] < tempBeat[2 * r] && tempBeat[2 * r - 1] < tempBeat[2 * r + 1]) rlist = 2 * r - 1; else if (tempBeat[2 * r] < tempBeat[2 * r - 1] && tempBeat[2 * r] < tempBeat[2 * r + 1]) rlist = 2 * r; else rlist = 2 * r + 1; } blShift = Math.abs(lastIsoLevel - isoLevel); lastIsoLevel = isoLevel; for (int i = 0; i < BEATLGTH; ++i) { newBeat[i] -= isoLevel; } if ((blShift > BL_SHIFT_LIMIT) && (lastBeatWasNew == 1) && (lastRhythmClass == NORMAL) && (rhythmClass == NORMAL)) match.ClearLastNewType(); lastBeatWasNew = 0; matchSynos = match.BestMorphMatch(newBeat); morphType = (int) matchSynos[0]; matchIndex = matchSynos[1]; mi2 = matchSynos[2]; shiftAdj = (int) matchSynos[3]; if (matchIndex < MATCH_NOISE_THRESHOLD) hfNoise = noiseLevel = blShift = 0; if ((matchIndex < MATCH_LIMIT) && (rhythmClass == PVC) && match.MinimumBeatVariation(morphType) && (mi2 > PVC_MATCH_WITH_AMP_LIMIT)) { morphType = match.NewBeatType(newBeat); lastBeatWasNew = 1; } else if ((matchIndex < MATCH_LIMIT) && (mi2 <= MATCH_WITH_AMP_LIMIT)) match.UpdateBeatType(morphType, newBeat, mi2, shiftAdj); else if ((blShift < BL_SHIFT_LIMIT) && (noiseLevel < NEW_TYPE_NOISE_THRESHOLD) && (hfNoise < NEW_TYPE_HF_NOISE_LIMIT)) { morphType = match.NewBeatType(newBeat); lastBeatWasNew = 1; } else if ((lastRhythmClass != NORMAL) || (rhythmClass != NORMAL)) { morphType = match.NewBeatType(newBeat); lastBeatWasNew = 1; } else morphType = MAXTYPES; for (int i = 7; i > 0; --i) { RecentRRs[i] = RecentRRs[i - 1]; RecentTypes[i] = RecentTypes[i - 1]; } RecentRRs[0] = rr; RecentTypes[0] = morphType; lastRhythmClass = rhythmClass; lastIsoLevel = isoLevel; if (morphType != MAXTYPES) { beatClass = match.GetBeatClass(morphType); beatWidth = match.GetBeatWidth(morphType); fidAdj = match.GetBeatCenter(morphType) - FIDMARK; if ((beatWidth > offset - onset) && (match.GetBeatTypeCount(morphType) <= 4)) { beatWidth = offset - onset; fidAdj = ((offset + onset) / 2) - FIDMARK; } } else { beatWidth = offset - onset; beatClass = UNKNOWN; fidAdj = ((offset + onset) / 2) - FIDMARK; } detect[10] = fidAdj; DomType = domType = DomMonitor(morphType, rhythmClass, beatWidth, rr, 0); int isDomType = 0; if (morphType == domType) { isDomType = 1; } detect[12] = isDomType; domWidth = match.GetBeatWidth(domType); if ((morphType != domType) && (morphType != 8)) domIndex = match.DomCompare(morphType, domType); else if (morphType == 8) domIndex = match.DomCompare2(newBeat, domType); else domIndex = matchIndex; postclas.PostClassify(RecentTypes, domType, RecentRRs, beatWidth, domIndex, rhythmClass); tempClass = TempClass( rhythmClass, morphType, beatWidth, domWidth, domType, hfNoise, noiseLevel, blShift, domIndex); if ((beatClass == UNKNOWN) && (morphType < MAXTYPES)) { runCount = GetRunCount(); if ((runCount >= 3) && (domType != -1) && (beatWidth < domWidth + 2)) match.SetBeatClass(morphType, NORMAL); else if ((runCount >= 6) && (domType == -1)) match.SetBeatClass(morphType, NORMAL); else if (rythmchk.IsBigeminy() == 1) { if ((rhythmClass == PVC) && (beatWidth > 10)) match.SetBeatClass(morphType, PVC); else if (rhythmClass == NORMAL) match.SetBeatClass(morphType, NORMAL); } } beatClass = match.GetBeatClass(morphType); diff_onoff = Math.abs(newBeat[onset] - newBeat[offset]); if (DomType >= 0 && isDomType == 0) // 褰撳墠蹇冨崥闈炰富瀵煎績鍗� { if (amp < MATCH.BeatAmps[DomType] >> 3 || amp > (7 * MATCH.BeatAmps[DomType]) || diff_onoff > 2 * MATCH.BeatAmps[DomType] || beatWidth > 10 * MATCH.BeatWidths[DomType]) // 鐭鍚庣殑RR闂磋窛濡傛灉灏忎簬200ms锛屽氨鍒犻櫎鍚庝竴涓� on 20151226 { beatType = 100; // heavy noise detect[11] = beatType; return (detect); } } if (DomType >= 0 && MATCH.BeatCounts[DomType] > 10 && isDomType == 0) // 褰撳墠蹇冨崥闈炰富瀵煎績鍗� { if (amp > (4 * MATCH.BeatAmps[DomType])) { beatType = NOISE; detect[11] = beatType; return (detect); } else if (beatWidth > 5 * MATCH.BeatWidths[DomType]) { beatType = NOISE; detect[11] = beatType; return (detect); } else if (diff_onoff > MATCH.BeatAmps[DomType]) { beatType = NOISE; detect[11] = beatType; return (detect); } } if (beatClass != UNKNOWN) { beatType = beatClass; detect[11] = beatType; return (detect); } if (postclas.CheckPostClass(morphType) == PVC && rhythmClass == PVC) { beatType = PVC; detect[11] = beatType; return (detect); } beatType = tempClass; detect[11] = beatType; return detect; }