@libraz/libcantus 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -622,18 +622,22 @@ var MAX_DETECTION_PCS = 6;
622
622
  var INEXACT_CONFIDENCE_FACTOR = 0.85;
623
623
  var DIATONIC_BONUS = 0.5;
624
624
  var EXACT_BONUS = 0.5;
625
- var MISMATCH_PENALTY = 0.3;
625
+ var EXTRA_TONE_PENALTY = 0.6;
626
+ var OMITTED_TONE_PENALTY = 0.15;
627
+ var BASS_ROOT_STANDING = 0.95;
626
628
  function scoreMatch(match, weights, maxWeight, key) {
627
629
  const rootWeight = maxWeight > 0 ? (_nullishCoalesce(weights[match.rootPc], () => ( 0))) / maxWeight : 0;
630
+ const rootStanding = match.inversion === 0 ? Math.max(rootWeight, BASS_ROOT_STANDING) : rootWeight;
628
631
  const tones = _chunkUADYAYATcjs.chordPitchClasses.call(void 0, _chunkUADYAYATcjs.makeChord.call(void 0, match.rootPc, match.quality));
629
- let score = rootWeight;
632
+ let score = rootStanding;
630
633
  if (tones.every((pc) => _chunkUADYAYATcjs.isScaleTone.call(void 0, pc, key))) {
631
634
  score += DIATONIC_BONUS;
632
635
  }
633
636
  if (match.exact) {
634
637
  score += EXACT_BONUS;
635
638
  }
636
- score -= MISMATCH_PENALTY * (match.extraPcs.length + match.missingPcs.length);
639
+ score -= EXTRA_TONE_PENALTY * match.extraPcs.length;
640
+ score -= OMITTED_TONE_PENALTY * match.missingPcs.length;
637
641
  return score;
638
642
  }
639
643
  function chordConfidence(chord, weights, totalWeight, exact) {
@@ -3217,4 +3221,4 @@ function reduceProgression(timeline, key, opts = {}) {
3217
3221
 
3218
3222
 
3219
3223
  exports.keyTimelineFromNotes = keyTimelineFromNotes; exports.detectModulations = detectModulations; exports.keyLookup = keyLookup; exports.prevailingKeyOf = prevailingKeyOf; exports.chordTimelineFromChords = chordTimelineFromChords; exports.chordTimelineFromNotes = chordTimelineFromNotes; exports.detectCadences = detectCadences; exports.toVoiceNotes = toVoiceNotes; exports.analyzeVoice = analyzeVoice; exports.analyzeArrangement = analyzeArrangement; exports.createArrangementSession = createArrangementSession; exports.tensionCurve = tensionCurve; exports.tensionCurveFrom = tensionCurveFrom; exports.hypermeter = hypermeter; exports.extractMotifs = extractMotifs; exports.motifFromNotes = motifFromNotes; exports.relateMotifs = relateMotifs; exports.compareMelodies = compareMelodies; exports.melodicSimilarity = melodicSimilarity; exports.melodicContour = melodicContour; exports.phrasesFromTimeline = phrasesFromTimeline; exports.structuralCadences = structuralCadences; exports.sectionsFromNotes = sectionsFromNotes; exports.reduceProgression = reduceProgression;
3220
- //# sourceMappingURL=chunk-3JXCW6DX.cjs.map
3224
+ //# sourceMappingURL=chunk-B6XNKWZV.cjs.map