playlist-data-engine 1.1.0
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.
- package/LICENSE +21 -0
- package/README.md +352 -0
- package/dist/__vite-browser-external-DYxpcVy9.js +4 -0
- package/dist/constants/DefaultClasses.d.ts +46 -0
- package/dist/constants/DefaultClasses.d.ts.map +1 -0
- package/dist/constants/DefaultEnchantments.d.ts +337 -0
- package/dist/constants/DefaultEnchantments.d.ts.map +1 -0
- package/dist/constants/DefaultEnemies.d.ts +83 -0
- package/dist/constants/DefaultEnemies.d.ts.map +1 -0
- package/dist/constants/DefaultEquipment.d.ts +23 -0
- package/dist/constants/DefaultEquipment.d.ts.map +1 -0
- package/dist/constants/DefaultFeatures.d.ts +22 -0
- package/dist/constants/DefaultFeatures.d.ts.map +1 -0
- package/dist/constants/DefaultRaces.d.ts +102 -0
- package/dist/constants/DefaultRaces.d.ts.map +1 -0
- package/dist/constants/DefaultSkills.d.ts +26 -0
- package/dist/constants/DefaultSkills.d.ts.map +1 -0
- package/dist/constants/DefaultSpells.d.ts +41 -0
- package/dist/constants/DefaultSpells.d.ts.map +1 -0
- package/dist/constants/EncounterBalance.d.ts +208 -0
- package/dist/constants/EncounterBalance.d.ts.map +1 -0
- package/dist/constants/EnemyEquipment.d.ts +71 -0
- package/dist/constants/EnemyEquipment.d.ts.map +1 -0
- package/dist/constants/EnemyRarity.d.ts +79 -0
- package/dist/constants/EnemyRarity.d.ts.map +1 -0
- package/dist/constants/EnemyTemplates/Construct.d.ts +63 -0
- package/dist/constants/EnemyTemplates/Construct.d.ts.map +1 -0
- package/dist/constants/EnemyTemplates/Dragon.d.ts +68 -0
- package/dist/constants/EnemyTemplates/Dragon.d.ts.map +1 -0
- package/dist/constants/EnemyTemplates/Elemental.d.ts +64 -0
- package/dist/constants/EnemyTemplates/Elemental.d.ts.map +1 -0
- package/dist/constants/EnemyTemplates/Fiend.d.ts +62 -0
- package/dist/constants/EnemyTemplates/Fiend.d.ts.map +1 -0
- package/dist/constants/EnemyTemplates/Monstrosity.d.ts +63 -0
- package/dist/constants/EnemyTemplates/Monstrosity.d.ts.map +1 -0
- package/dist/constants/EnemyTemplates/Undead.d.ts +61 -0
- package/dist/constants/EnemyTemplates/Undead.d.ts.map +1 -0
- package/dist/constants/ItemTemplates.d.ts +40 -0
- package/dist/constants/ItemTemplates.d.ts.map +1 -0
- package/dist/constants/MagicItems.d.ts +30 -0
- package/dist/constants/MagicItems.d.ts.map +1 -0
- package/dist/constants/SpellSlots.d.ts +30 -0
- package/dist/constants/SpellSlots.d.ts.map +1 -0
- package/dist/constants/StatScaling.d.ts +113 -0
- package/dist/constants/StatScaling.d.ts.map +1 -0
- package/dist/core/analysis/AudioAnalyzer.d.ts +599 -0
- package/dist/core/analysis/AudioAnalyzer.d.ts.map +1 -0
- package/dist/core/analysis/ColorExtractor.d.ts +64 -0
- package/dist/core/analysis/ColorExtractor.d.ts.map +1 -0
- package/dist/core/analysis/EssentiaPitchDetector.d.ts +282 -0
- package/dist/core/analysis/EssentiaPitchDetector.d.ts.map +1 -0
- package/dist/core/analysis/LevelSerializer.d.ts +265 -0
- package/dist/core/analysis/LevelSerializer.d.ts.map +1 -0
- package/dist/core/analysis/MelodyContourAnalyzer.d.ts +283 -0
- package/dist/core/analysis/MelodyContourAnalyzer.d.ts.map +1 -0
- package/dist/core/analysis/MultiBandAnalyzer.d.ts +214 -0
- package/dist/core/analysis/MultiBandAnalyzer.d.ts.map +1 -0
- package/dist/core/analysis/MusicClassifier.d.ts +524 -0
- package/dist/core/analysis/MusicClassifier.d.ts.map +1 -0
- package/dist/core/analysis/PitchAnalyzer.d.ts +266 -0
- package/dist/core/analysis/PitchAnalyzer.d.ts.map +1 -0
- package/dist/core/analysis/PitchDetector.d.ts +251 -0
- package/dist/core/analysis/PitchDetector.d.ts.map +1 -0
- package/dist/core/analysis/SpectrumScanner.d.ts +52 -0
- package/dist/core/analysis/SpectrumScanner.d.ts.map +1 -0
- package/dist/core/analysis/beat/BeatInterpolator.d.ts +477 -0
- package/dist/core/analysis/beat/BeatInterpolator.d.ts.map +1 -0
- package/dist/core/analysis/beat/BeatMapGenerator.d.ts +170 -0
- package/dist/core/analysis/beat/BeatMapGenerator.d.ts.map +1 -0
- package/dist/core/analysis/beat/BeatStream.d.ts +316 -0
- package/dist/core/analysis/beat/BeatStream.d.ts.map +1 -0
- package/dist/core/analysis/beat/BeatSubdivider.d.ts +205 -0
- package/dist/core/analysis/beat/BeatSubdivider.d.ts.map +1 -0
- package/dist/core/analysis/beat/BeatTracker.d.ts +137 -0
- package/dist/core/analysis/beat/BeatTracker.d.ts.map +1 -0
- package/dist/core/analysis/beat/CompositeStreamGenerator.d.ts +180 -0
- package/dist/core/analysis/beat/CompositeStreamGenerator.d.ts.map +1 -0
- package/dist/core/analysis/beat/DensityAnalyzer.d.ts +246 -0
- package/dist/core/analysis/beat/DensityAnalyzer.d.ts.map +1 -0
- package/dist/core/analysis/beat/DifficultyVariantGenerator.d.ts +1082 -0
- package/dist/core/analysis/beat/DifficultyVariantGenerator.d.ts.map +1 -0
- package/dist/core/analysis/beat/GrooveAnalyzer.d.ts +192 -0
- package/dist/core/analysis/beat/GrooveAnalyzer.d.ts.map +1 -0
- package/dist/core/analysis/beat/OnsetStrengthEnvelope.d.ts +133 -0
- package/dist/core/analysis/beat/OnsetStrengthEnvelope.d.ts.map +1 -0
- package/dist/core/analysis/beat/PhraseAnalyzer.d.ts +230 -0
- package/dist/core/analysis/beat/PhraseAnalyzer.d.ts.map +1 -0
- package/dist/core/analysis/beat/RhythmQuantizer.d.ts +399 -0
- package/dist/core/analysis/beat/RhythmQuantizer.d.ts.map +1 -0
- package/dist/core/analysis/beat/RhythmicBalancer.d.ts +262 -0
- package/dist/core/analysis/beat/RhythmicBalancer.d.ts.map +1 -0
- package/dist/core/analysis/beat/StreamScorer.d.ts +275 -0
- package/dist/core/analysis/beat/StreamScorer.d.ts.map +1 -0
- package/dist/core/analysis/beat/TempoAwareQuantizer.d.ts +256 -0
- package/dist/core/analysis/beat/TempoAwareQuantizer.d.ts.map +1 -0
- package/dist/core/analysis/beat/TempoDetector.d.ts +220 -0
- package/dist/core/analysis/beat/TempoDetector.d.ts.map +1 -0
- package/dist/core/analysis/beat/TransientDetector.d.ts +303 -0
- package/dist/core/analysis/beat/TransientDetector.d.ts.map +1 -0
- package/dist/core/analysis/beat/beatKeyHelpers.d.ts +180 -0
- package/dist/core/analysis/beat/beatKeyHelpers.d.ts.map +1 -0
- package/dist/core/analysis/beat/index.d.ts +41 -0
- package/dist/core/analysis/beat/index.d.ts.map +1 -0
- package/dist/core/analysis/beat/utils/audioUtils.d.ts +204 -0
- package/dist/core/analysis/beat/utils/audioUtils.d.ts.map +1 -0
- package/dist/core/analysis/beat/utils/beatInterpolationDebug.d.ts +404 -0
- package/dist/core/analysis/beat/utils/beatInterpolationDebug.d.ts.map +1 -0
- package/dist/core/analysis/beat/utils/subdivideBeatMap.d.ts +61 -0
- package/dist/core/analysis/beat/utils/subdivideBeatMap.d.ts.map +1 -0
- package/dist/core/analysis/beat/utils/unifyBeatMap.d.ts +33 -0
- package/dist/core/analysis/beat/utils/unifyBeatMap.d.ts.map +1 -0
- package/dist/core/analysis/index.d.ts +18 -0
- package/dist/core/analysis/index.d.ts.map +1 -0
- package/dist/core/combat/AI/AICombatRunner.d.ts +108 -0
- package/dist/core/combat/AI/AICombatRunner.d.ts.map +1 -0
- package/dist/core/combat/AI/CombatAI.d.ts +179 -0
- package/dist/core/combat/AI/CombatAI.d.ts.map +1 -0
- package/dist/core/combat/AI/CombatMetricsTracker.d.ts +30 -0
- package/dist/core/combat/AI/CombatMetricsTracker.d.ts.map +1 -0
- package/dist/core/combat/Analysis/BalanceValidator.d.ts +170 -0
- package/dist/core/combat/Analysis/BalanceValidator.d.ts.map +1 -0
- package/dist/core/combat/Analysis/ComparativeAnalyzer.d.ts +231 -0
- package/dist/core/combat/Analysis/ComparativeAnalyzer.d.ts.map +1 -0
- package/dist/core/combat/Analysis/DifficultyCalculator.d.ts +203 -0
- package/dist/core/combat/Analysis/DifficultyCalculator.d.ts.map +1 -0
- package/dist/core/combat/Analysis/ParameterSweep.d.ts +201 -0
- package/dist/core/combat/Analysis/ParameterSweep.d.ts.map +1 -0
- package/dist/core/combat/AttackResolver.d.ts +220 -0
- package/dist/core/combat/AttackResolver.d.ts.map +1 -0
- package/dist/core/combat/CombatEngine.d.ts +388 -0
- package/dist/core/combat/CombatEngine.d.ts.map +1 -0
- package/dist/core/combat/DiceRoller.d.ts +115 -0
- package/dist/core/combat/DiceRoller.d.ts.map +1 -0
- package/dist/core/combat/InitiativeRoller.d.ts +62 -0
- package/dist/core/combat/InitiativeRoller.d.ts.map +1 -0
- package/dist/core/combat/PartyAnalyzer.d.ts +215 -0
- package/dist/core/combat/PartyAnalyzer.d.ts.map +1 -0
- package/dist/core/combat/SeededDiceRoller.d.ts +120 -0
- package/dist/core/combat/SeededDiceRoller.d.ts.map +1 -0
- package/dist/core/combat/Simulation/CombatSimulator.d.ts +366 -0
- package/dist/core/combat/Simulation/CombatSimulator.d.ts.map +1 -0
- package/dist/core/combat/SpellCaster.d.ts +113 -0
- package/dist/core/combat/SpellCaster.d.ts.map +1 -0
- package/dist/core/config/index.d.ts +24 -0
- package/dist/core/config/index.d.ts.map +1 -0
- package/dist/core/config/progressionConfig.d.ts +73 -0
- package/dist/core/config/progressionConfig.d.ts.map +1 -0
- package/dist/core/config/sensorConfig.d.ts +134 -0
- package/dist/core/config/sensorConfig.d.ts.map +1 -0
- package/dist/core/equipment/BoxOpener.d.ts +175 -0
- package/dist/core/equipment/BoxOpener.d.ts.map +1 -0
- package/dist/core/equipment/EquipmentEffectApplier.d.ts +189 -0
- package/dist/core/equipment/EquipmentEffectApplier.d.ts.map +1 -0
- package/dist/core/equipment/EquipmentModifier.d.ts +327 -0
- package/dist/core/equipment/EquipmentModifier.d.ts.map +1 -0
- package/dist/core/equipment/EquipmentSpawnHelper.d.ts +246 -0
- package/dist/core/equipment/EquipmentSpawnHelper.d.ts.map +1 -0
- package/dist/core/equipment/EquipmentValidator.d.ts +173 -0
- package/dist/core/equipment/EquipmentValidator.d.ts.map +1 -0
- package/dist/core/extensions/ExtensionManager.d.ts +517 -0
- package/dist/core/extensions/ExtensionManager.d.ts.map +1 -0
- package/dist/core/extensions/WeightedSelector.d.ts +156 -0
- package/dist/core/extensions/WeightedSelector.d.ts.map +1 -0
- package/dist/core/extensions/index.d.ts +11 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/initializeDefaults.d.ts +170 -0
- package/dist/core/extensions/initializeDefaults.d.ts.map +1 -0
- package/dist/core/features/FeatureEffectApplier.d.ts +102 -0
- package/dist/core/features/FeatureEffectApplier.d.ts.map +1 -0
- package/dist/core/features/FeatureQuery.d.ts +368 -0
- package/dist/core/features/FeatureQuery.d.ts.map +1 -0
- package/dist/core/features/FeatureTypes.d.ts +199 -0
- package/dist/core/features/FeatureTypes.d.ts.map +1 -0
- package/dist/core/features/FeatureValidator.d.ts +149 -0
- package/dist/core/features/FeatureValidator.d.ts.map +1 -0
- package/dist/core/features/index.d.ts +12 -0
- package/dist/core/features/index.d.ts.map +1 -0
- package/dist/core/generation/AbilityScoreCalculator.d.ts +83 -0
- package/dist/core/generation/AbilityScoreCalculator.d.ts.map +1 -0
- package/dist/core/generation/AppearanceGenerator.d.ts +32 -0
- package/dist/core/generation/AppearanceGenerator.d.ts.map +1 -0
- package/dist/core/generation/BeatConverter.d.ts +127 -0
- package/dist/core/generation/BeatConverter.d.ts.map +1 -0
- package/dist/core/generation/ButtonMapper.d.ts +346 -0
- package/dist/core/generation/ButtonMapper.d.ts.map +1 -0
- package/dist/core/generation/ButtonPatternLibrary.d.ts +92 -0
- package/dist/core/generation/ButtonPatternLibrary.d.ts.map +1 -0
- package/dist/core/generation/CRLevelConverter.d.ts +242 -0
- package/dist/core/generation/CRLevelConverter.d.ts.map +1 -0
- package/dist/core/generation/CharacterGenerator.d.ts +194 -0
- package/dist/core/generation/CharacterGenerator.d.ts.map +1 -0
- package/dist/core/generation/ClassSuggester.d.ts +184 -0
- package/dist/core/generation/ClassSuggester.d.ts.map +1 -0
- package/dist/core/generation/EnemyEquipmentGenerator.d.ts +151 -0
- package/dist/core/generation/EnemyEquipmentGenerator.d.ts.map +1 -0
- package/dist/core/generation/EnemyGenerator.d.ts +595 -0
- package/dist/core/generation/EnemyGenerator.d.ts.map +1 -0
- package/dist/core/generation/EquipmentGenerator.d.ts +204 -0
- package/dist/core/generation/EquipmentGenerator.d.ts.map +1 -0
- package/dist/core/generation/LegendaryGenerator.d.ts +213 -0
- package/dist/core/generation/LegendaryGenerator.d.ts.map +1 -0
- package/dist/core/generation/LevelGenerator.d.ts +390 -0
- package/dist/core/generation/LevelGenerator.d.ts.map +1 -0
- package/dist/core/generation/NamingEngine.d.ts +136 -0
- package/dist/core/generation/NamingEngine.d.ts.map +1 -0
- package/dist/core/generation/PitchBeatLinker.d.ts +150 -0
- package/dist/core/generation/PitchBeatLinker.d.ts.map +1 -0
- package/dist/core/generation/RaceSelector.d.ts +58 -0
- package/dist/core/generation/RaceSelector.d.ts.map +1 -0
- package/dist/core/generation/RhythmGenerator.d.ts +597 -0
- package/dist/core/generation/RhythmGenerator.d.ts.map +1 -0
- package/dist/core/generation/SkillAssigner.d.ts +78 -0
- package/dist/core/generation/SkillAssigner.d.ts.map +1 -0
- package/dist/core/generation/SpellManager.d.ts +132 -0
- package/dist/core/generation/SpellManager.d.ts.map +1 -0
- package/dist/core/generation/SpellcastingGenerator.d.ts +255 -0
- package/dist/core/generation/SpellcastingGenerator.d.ts.map +1 -0
- package/dist/core/generation/index.d.ts +41 -0
- package/dist/core/generation/index.d.ts.map +1 -0
- package/dist/core/parser/MetadataExtractor.d.ts +66 -0
- package/dist/core/parser/MetadataExtractor.d.ts.map +1 -0
- package/dist/core/parser/PlaylistParser.d.ts +45 -0
- package/dist/core/parser/PlaylistParser.d.ts.map +1 -0
- package/dist/core/playback/SubdivisionPlaybackController.d.ts +333 -0
- package/dist/core/playback/SubdivisionPlaybackController.d.ts.map +1 -0
- package/dist/core/playback/index.d.ts +5 -0
- package/dist/core/playback/index.d.ts.map +1 -0
- package/dist/core/progression/CharacterUpdater.d.ts +203 -0
- package/dist/core/progression/CharacterUpdater.d.ts.map +1 -0
- package/dist/core/progression/LevelUpProcessor.d.ts +234 -0
- package/dist/core/progression/LevelUpProcessor.d.ts.map +1 -0
- package/dist/core/progression/PrestigeSystem.d.ts +217 -0
- package/dist/core/progression/PrestigeSystem.d.ts.map +1 -0
- package/dist/core/progression/RhythmXPCalculator.d.ts +182 -0
- package/dist/core/progression/RhythmXPCalculator.d.ts.map +1 -0
- package/dist/core/progression/SessionTracker.d.ts +169 -0
- package/dist/core/progression/SessionTracker.d.ts.map +1 -0
- package/dist/core/progression/XPCalculator.d.ts +128 -0
- package/dist/core/progression/XPCalculator.d.ts.map +1 -0
- package/dist/core/progression/stat/StatIncreaseStrategy.d.ts +97 -0
- package/dist/core/progression/stat/StatIncreaseStrategy.d.ts.map +1 -0
- package/dist/core/progression/stat/StatManager.d.ts +179 -0
- package/dist/core/progression/stat/StatManager.d.ts.map +1 -0
- package/dist/core/sensors/EnvironmentalSensors.d.ts +301 -0
- package/dist/core/sensors/EnvironmentalSensors.d.ts.map +1 -0
- package/dist/core/sensors/GamingPlatformSensors.d.ts +162 -0
- package/dist/core/sensors/GamingPlatformSensors.d.ts.map +1 -0
- package/dist/core/sensors/GeolocationProvider.d.ts +156 -0
- package/dist/core/sensors/GeolocationProvider.d.ts.map +1 -0
- package/dist/core/sensors/MotionDetector.d.ts +58 -0
- package/dist/core/sensors/MotionDetector.d.ts.map +1 -0
- package/dist/core/sensors/SteamAPIClient.d.ts +108 -0
- package/dist/core/sensors/SteamAPIClient.d.ts.map +1 -0
- package/dist/core/sensors/WeatherAPIClient.d.ts +360 -0
- package/dist/core/sensors/WeatherAPIClient.d.ts.map +1 -0
- package/dist/core/sensors/schemas/weather.schema.d.ts +144 -0
- package/dist/core/sensors/schemas/weather.schema.d.ts.map +1 -0
- package/dist/core/skills/SkillQuery.d.ts +159 -0
- package/dist/core/skills/SkillQuery.d.ts.map +1 -0
- package/dist/core/skills/SkillTypes.d.ts +233 -0
- package/dist/core/skills/SkillTypes.d.ts.map +1 -0
- package/dist/core/skills/SkillValidator.d.ts +146 -0
- package/dist/core/skills/SkillValidator.d.ts.map +1 -0
- package/dist/core/skills/index.d.ts +11 -0
- package/dist/core/skills/index.d.ts.map +1 -0
- package/dist/core/spells/SpellQuery.d.ts +194 -0
- package/dist/core/spells/SpellQuery.d.ts.map +1 -0
- package/dist/core/spells/SpellTypes.d.ts +71 -0
- package/dist/core/spells/SpellTypes.d.ts.map +1 -0
- package/dist/core/spells/SpellValidator.d.ts +129 -0
- package/dist/core/spells/SpellValidator.d.ts.map +1 -0
- package/dist/core/spells/index.d.ts +11 -0
- package/dist/core/spells/index.d.ts.map +1 -0
- package/dist/core/types/AudioProfile.d.ts +143 -0
- package/dist/core/types/AudioProfile.d.ts.map +1 -0
- package/dist/core/types/BeatMap.d.ts +1825 -0
- package/dist/core/types/BeatMap.d.ts.map +1 -0
- package/dist/core/types/ButtonMapping.d.ts +345 -0
- package/dist/core/types/ButtonMapping.d.ts.map +1 -0
- package/dist/core/types/Character.d.ts +397 -0
- package/dist/core/types/Character.d.ts.map +1 -0
- package/dist/core/types/ChartedBeatMap.d.ts +169 -0
- package/dist/core/types/ChartedBeatMap.d.ts.map +1 -0
- package/dist/core/types/Combat.d.ts +268 -0
- package/dist/core/types/Combat.d.ts.map +1 -0
- package/dist/core/types/CombatAI.d.ts +143 -0
- package/dist/core/types/CombatAI.d.ts.map +1 -0
- package/dist/core/types/Enemy.d.ts +447 -0
- package/dist/core/types/Enemy.d.ts.map +1 -0
- package/dist/core/types/Environmental.d.ts +213 -0
- package/dist/core/types/Environmental.d.ts.map +1 -0
- package/dist/core/types/Equipment.d.ts +309 -0
- package/dist/core/types/Equipment.d.ts.map +1 -0
- package/dist/core/types/ISessionTracker.d.ts +48 -0
- package/dist/core/types/ISessionTracker.d.ts.map +1 -0
- package/dist/core/types/LevelExport.d.ts +366 -0
- package/dist/core/types/LevelExport.d.ts.map +1 -0
- package/dist/core/types/Playlist.d.ts +70 -0
- package/dist/core/types/Playlist.d.ts.map +1 -0
- package/dist/core/types/Prestige.d.ts +94 -0
- package/dist/core/types/Prestige.d.ts.map +1 -0
- package/dist/core/types/Progression.d.ts +214 -0
- package/dist/core/types/Progression.d.ts.map +1 -0
- package/dist/core/types/RhythmXP.d.ts +398 -0
- package/dist/core/types/RhythmXP.d.ts.map +1 -0
- package/dist/core/utils/AbilityConstants.d.ts +31 -0
- package/dist/core/utils/AbilityConstants.d.ts.map +1 -0
- package/dist/core/utils/EffectApplierUtils.d.ts +56 -0
- package/dist/core/utils/EffectApplierUtils.d.ts.map +1 -0
- package/dist/core/utils/ImageValidator.d.ts +66 -0
- package/dist/core/utils/ImageValidator.d.ts.map +1 -0
- package/dist/core/utils/PrerequisiteValidator.d.ts +88 -0
- package/dist/core/utils/PrerequisiteValidator.d.ts.map +1 -0
- package/dist/essentia-wasm.es-BUEnKUts.js +2990 -0
- package/dist/essentia.js-model.es-CGA0xotH.js +306 -0
- package/dist/index.d.ts +176 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/playlist-data-engine.js +124 -0
- package/dist/playlist-data-engine.mjs +49251 -0
- package/dist/utils/EnchantmentLibrary.d.ts +378 -0
- package/dist/utils/EnchantmentLibrary.d.ts.map +1 -0
- package/dist/utils/arweaveGatewayManager.d.ts +485 -0
- package/dist/utils/arweaveGatewayManager.d.ts.map +1 -0
- package/dist/utils/arweaveUtils.d.ts +118 -0
- package/dist/utils/arweaveUtils.d.ts.map +1 -0
- package/dist/utils/constants.d.ts +439 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/equipmentConstants.d.ts +60 -0
- package/dist/utils/equipmentConstants.d.ts.map +1 -0
- package/dist/utils/hash.d.ts +33 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +192 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/magicItemExamples.d.ts +46 -0
- package/dist/utils/magicItemExamples.d.ts.map +1 -0
- package/dist/utils/playlistUtils.d.ts +149 -0
- package/dist/utils/playlistUtils.d.ts.map +1 -0
- package/dist/utils/random.d.ts +34 -0
- package/dist/utils/random.d.ts.map +1 -0
- package/dist/utils/sensorDashboard.d.ts +60 -0
- package/dist/utils/sensorDashboard.d.ts.map +1 -0
- package/dist/utils/validators.d.ts +189 -0
- package/dist/utils/validators.d.ts.map +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PitchAnalyzer - Standalone full-track pitch detection
|
|
3
|
+
*
|
|
4
|
+
* Provides per-frame pitch detection and melody contour analysis directly from
|
|
5
|
+
* raw audio, with zero dependency on beat detection or rhythm generation.
|
|
6
|
+
*
|
|
7
|
+
* ## Key Design Decisions
|
|
8
|
+
*
|
|
9
|
+
* - **No `PitchBeatLinker` dependency.** Uses `PitchDetector`/`EssentiaPitchDetector`
|
|
10
|
+
* directly on the audio signal and does not align pitch frames to beats.
|
|
11
|
+
*
|
|
12
|
+
* - **Contour analysis on `PitchResult[]`.** Provides its own contour analysis that
|
|
13
|
+
* works directly on the `PitchResult[]` output from the detectors.
|
|
14
|
+
*
|
|
15
|
+
* - **Same analyzer pattern as `AudioAnalyzer` / `MusicClassifier`.** Accepts a URL,
|
|
16
|
+
* fetches/decodes audio internally, returns a typed profile with metadata.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const analyzer = new PitchAnalyzer({
|
|
21
|
+
* algorithm: 'pitch_melodia',
|
|
22
|
+
* includeContour: true
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* const profile = await analyzer.analyze('https://example.com/audio.mp3');
|
|
26
|
+
*
|
|
27
|
+
* console.log(`Voicing ratio: ${(profile.voicingRatio * 100).toFixed(1)}%`);
|
|
28
|
+
* console.log(`Range: ${profile.lowestNote} - ${profile.highestNote}`);
|
|
29
|
+
* console.log(`Contour direction: ${profile.contour?.direction}`);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
import type { PitchResult } from './PitchDetector.js';
|
|
33
|
+
import type { PitchAlgorithm } from './EssentiaPitchDetector.js';
|
|
34
|
+
import type { DirectionStats, IntervalStats } from './MelodyContourAnalyzer.js';
|
|
35
|
+
/**
|
|
36
|
+
* Configuration for the PitchAnalyzer
|
|
37
|
+
*/
|
|
38
|
+
export interface PitchAnalyzerConfig {
|
|
39
|
+
/**
|
|
40
|
+
* Which pitch detection algorithm to use.
|
|
41
|
+
* @default 'pitch_melodia'
|
|
42
|
+
*/
|
|
43
|
+
algorithm?: PitchAlgorithm;
|
|
44
|
+
/**
|
|
45
|
+
* Minimum frequency to detect in Hz.
|
|
46
|
+
* @default 80
|
|
47
|
+
*/
|
|
48
|
+
minFrequency?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Maximum frequency to detect in Hz.
|
|
51
|
+
* Default varies by algorithm: 1000 for pyin_legacy, 20000 for others.
|
|
52
|
+
*/
|
|
53
|
+
maxFrequency?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Target sample rate for analysis.
|
|
56
|
+
* @default 44100
|
|
57
|
+
*/
|
|
58
|
+
sampleRate?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Hop size in samples between consecutive frames.
|
|
61
|
+
* Larger values = fewer frames = faster analysis, lower time resolution.
|
|
62
|
+
* Default is 1024 (~23ms at 44.1kHz, ~43 frames/sec) for the standalone
|
|
63
|
+
* analyzer. The beat-aligned path (PitchBeatLinker) uses smaller hops
|
|
64
|
+
* internally since it only evaluates at beat positions.
|
|
65
|
+
* @default 1024
|
|
66
|
+
*/
|
|
67
|
+
hopSize?: number;
|
|
68
|
+
/**
|
|
69
|
+
* CREPE model URL (only for 'pitch_crepe' algorithm).
|
|
70
|
+
*/
|
|
71
|
+
crepeModelUrl?: string;
|
|
72
|
+
/**
|
|
73
|
+
* URL resolver for Arweave URLs.
|
|
74
|
+
*/
|
|
75
|
+
resolveUrl?: (url: string) => Promise<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Whether to include melody contour analysis.
|
|
78
|
+
* @default true
|
|
79
|
+
*/
|
|
80
|
+
includeContour?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Optional progress callback.
|
|
83
|
+
* Reports phase name and progress (0-1).
|
|
84
|
+
*/
|
|
85
|
+
onProgress?: (phase: string, progress: number) => void;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Direction of a pitch contour segment
|
|
89
|
+
*/
|
|
90
|
+
export type PitchContourSegmentDirection = 'up' | 'down' | 'stable';
|
|
91
|
+
/**
|
|
92
|
+
* Overall direction of a pitch contour
|
|
93
|
+
*/
|
|
94
|
+
export type PitchContourDirection = 'ascending' | 'descending' | 'stable' | 'mixed';
|
|
95
|
+
/**
|
|
96
|
+
* A segment of a pitch contour with consistent direction
|
|
97
|
+
*/
|
|
98
|
+
export interface PitchContourSegment {
|
|
99
|
+
/** Start time in seconds */
|
|
100
|
+
startTime: number;
|
|
101
|
+
/** End time in seconds */
|
|
102
|
+
endTime: number;
|
|
103
|
+
/** Starting note name (e.g., "C4") */
|
|
104
|
+
startNote: string;
|
|
105
|
+
/** Ending note name (e.g., "G5") */
|
|
106
|
+
endNote: string;
|
|
107
|
+
/** Direction of this segment */
|
|
108
|
+
direction: PitchContourSegmentDirection;
|
|
109
|
+
/** Interval in semitones between start and end */
|
|
110
|
+
interval: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Pitch contour representing the overall melodic shape
|
|
114
|
+
*
|
|
115
|
+
* Populated by pitch contour analysis when `includeContour !== false`.
|
|
116
|
+
* Provides the same depth of analysis as `MelodyContour` from `MelodyContourAnalyzer`.
|
|
117
|
+
*/
|
|
118
|
+
export interface PitchContour {
|
|
119
|
+
/** Overall melody direction */
|
|
120
|
+
direction: PitchContourDirection;
|
|
121
|
+
/** Pitch range information */
|
|
122
|
+
range: {
|
|
123
|
+
/** Lowest note (e.g., "C4") */
|
|
124
|
+
minNote: string;
|
|
125
|
+
/** Highest note (e.g., "F#5") */
|
|
126
|
+
maxNote: string;
|
|
127
|
+
/** Total span in semitones */
|
|
128
|
+
semitones: number;
|
|
129
|
+
};
|
|
130
|
+
/** Melody segments (groups of consecutive frames with same direction) */
|
|
131
|
+
segments: PitchContourSegment[];
|
|
132
|
+
/** Time-window direction analysis */
|
|
133
|
+
shortTermDirection: PitchContourDirection;
|
|
134
|
+
mediumTermDirection: PitchContourDirection;
|
|
135
|
+
longTermDirection: PitchContourDirection;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Result of full-track pitch analysis
|
|
139
|
+
*
|
|
140
|
+
* Contains per-frame pitch detection results, optional melody contour analysis,
|
|
141
|
+
* and summary statistics. Flat structure mirrors `AudioProfile` pattern.
|
|
142
|
+
*/
|
|
143
|
+
export interface PitchAnalysisProfile {
|
|
144
|
+
/** Per-frame pitch detection results */
|
|
145
|
+
pitchResults: PitchResult[];
|
|
146
|
+
/** Melody contour analysis (only populated when includeContour !== false) */
|
|
147
|
+
contour?: PitchContour;
|
|
148
|
+
/** Ratio of voiced to total frames (0.0 - 1.0) */
|
|
149
|
+
voicingRatio: number;
|
|
150
|
+
/** Average frequency of voiced frames in Hz */
|
|
151
|
+
averageFrequency: number;
|
|
152
|
+
/** Median frequency of voiced frames in Hz */
|
|
153
|
+
medianFrequency: number;
|
|
154
|
+
/** Minimum detected frequency in Hz */
|
|
155
|
+
minFrequency: number;
|
|
156
|
+
/** Maximum detected frequency in Hz */
|
|
157
|
+
maxFrequency: number;
|
|
158
|
+
/** Pitch range in semitones */
|
|
159
|
+
pitchRangeSemitones: number;
|
|
160
|
+
/** Lowest detected note name (e.g., "C3"), null if no voiced frames */
|
|
161
|
+
lowestNote: string | null;
|
|
162
|
+
/** Highest detected note name (e.g., "G5"), null if no voiced frames */
|
|
163
|
+
highestNote: string | null;
|
|
164
|
+
/** Most common note names, sorted by frequency */
|
|
165
|
+
noteDistribution: {
|
|
166
|
+
note: string;
|
|
167
|
+
count: number;
|
|
168
|
+
percentage: number;
|
|
169
|
+
}[];
|
|
170
|
+
/** Total frames analyzed */
|
|
171
|
+
totalFrames: number;
|
|
172
|
+
/** Number of voiced frames */
|
|
173
|
+
voicedFrames: number;
|
|
174
|
+
/** Direction statistics from contour analysis (when contour enabled) */
|
|
175
|
+
directionStats?: DirectionStats;
|
|
176
|
+
/** Interval statistics from contour analysis (when contour enabled) */
|
|
177
|
+
intervalStats?: IntervalStats;
|
|
178
|
+
/** Analysis metadata (pipeline info only) */
|
|
179
|
+
analysis_metadata: {
|
|
180
|
+
algorithm_used: string;
|
|
181
|
+
analyzed_at: string;
|
|
182
|
+
duration_analyzed: number;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Standalone full-track pitch analyzer
|
|
187
|
+
*
|
|
188
|
+
* Provides per-frame pitch detection and melody contour analysis directly from
|
|
189
|
+
* raw audio, with zero dependency on beat detection or rhythm generation.
|
|
190
|
+
*
|
|
191
|
+
* Uses the same analyzer pattern as `AudioAnalyzer` and `MusicClassifier`:
|
|
192
|
+
* accepts a URL, fetches/decodes audio internally, returns a typed profile.
|
|
193
|
+
*/
|
|
194
|
+
export declare class PitchAnalyzer {
|
|
195
|
+
private config;
|
|
196
|
+
/**
|
|
197
|
+
* Create a new PitchAnalyzer
|
|
198
|
+
*
|
|
199
|
+
* @param config - Configuration options
|
|
200
|
+
*/
|
|
201
|
+
constructor(config?: PitchAnalyzerConfig);
|
|
202
|
+
/**
|
|
203
|
+
* Get the current configuration
|
|
204
|
+
*/
|
|
205
|
+
getConfig(): Required<Omit<PitchAnalyzerConfig, 'onProgress'>> & {
|
|
206
|
+
onProgress?: (phase: string, progress: number) => void;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Analyze audio from a URL
|
|
210
|
+
*
|
|
211
|
+
* Fetches and decodes the audio, performs pitch detection, computes summary
|
|
212
|
+
* statistics, and optionally computes melody contour analysis.
|
|
213
|
+
*
|
|
214
|
+
* @param audioUrl - URL of the audio file to analyze
|
|
215
|
+
* @returns Promise resolving to the pitch analysis profile
|
|
216
|
+
*/
|
|
217
|
+
analyze(audioUrl: string): Promise<PitchAnalysisProfile>;
|
|
218
|
+
/**
|
|
219
|
+
* Fetch and decode audio from a URL
|
|
220
|
+
*
|
|
221
|
+
* @param url - URL of the audio file
|
|
222
|
+
* @returns Promise resolving to mono signal, sample rate, and duration
|
|
223
|
+
*/
|
|
224
|
+
private fetchAndDecodeAudio;
|
|
225
|
+
/**
|
|
226
|
+
* Resolve algorithm-specific defaults
|
|
227
|
+
*
|
|
228
|
+
* When `algorithm === 'pyin_legacy'` and `maxFrequency` is not explicitly
|
|
229
|
+
* provided, defaults to 1000 Hz (the YIN algorithm's practical ceiling).
|
|
230
|
+
* All other algorithms default to 20000 Hz.
|
|
231
|
+
*/
|
|
232
|
+
private resolveDefaults;
|
|
233
|
+
/**
|
|
234
|
+
* Run pitch detection on the audio signal
|
|
235
|
+
*/
|
|
236
|
+
private detectPitch;
|
|
237
|
+
/**
|
|
238
|
+
* Compute summary statistics from pitch results
|
|
239
|
+
*/
|
|
240
|
+
private computeSummary;
|
|
241
|
+
/**
|
|
242
|
+
* Compute melody contour from pitch results
|
|
243
|
+
*/
|
|
244
|
+
private computeContour;
|
|
245
|
+
/**
|
|
246
|
+
* Determine overall contour direction from segments
|
|
247
|
+
*/
|
|
248
|
+
private determineOverallDirection;
|
|
249
|
+
/**
|
|
250
|
+
* Calculate direction over a specific time window
|
|
251
|
+
*/
|
|
252
|
+
private calculateTimeWindowDirection;
|
|
253
|
+
/**
|
|
254
|
+
* Determine overall direction from direction counts
|
|
255
|
+
*/
|
|
256
|
+
private determineOverallDirectionFromCounts;
|
|
257
|
+
/**
|
|
258
|
+
* Convert frequency in Hz to MIDI note number
|
|
259
|
+
*/
|
|
260
|
+
private frequencyToMidi;
|
|
261
|
+
/**
|
|
262
|
+
* Convert MIDI note number to note name (e.g., "C4", "F#5")
|
|
263
|
+
*/
|
|
264
|
+
private midiToNoteName;
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=PitchAnalyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PitchAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/core/analysis/PitchAnalyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAA0B,MAAM,4BAA4B,CAAC;AAGzF,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAQhF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAE3B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAE9C;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1D;AAED;;GAEG;AACH,M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AAO,CAAC,cAAc;IAyFtB;;OAEG;IACH,OAAO,CAAC,cAAc;IA0JtB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAwCjC;;OAEG;IACH,OAAO,CAAC,4BAA4B;IA0CpC;;OAEG;IACH,OAAO,CAAC,mCAAmC;IAgC3C;;OAEG;IACH,OAAO,CAAC,eAAe;IAIvB;;OAEG;IACH,OAAO,CAAC,cAAc;CAKzB"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pitch Detection using pYIN (Probabilistic YIN) Algorithm
|
|
3
|
+
*
|
|
4
|
+
* Implements the pYIN algorithm for robust pitch detection in polyphonic music.
|
|
5
|
+
* pYIN extends the classic YIN algorithm with probabilistic modeling and
|
|
6
|
+
* Hidden Markov Model (HMM) tracking for smoother, more accurate pitch estimation.
|
|
7
|
+
*
|
|
8
|
+
* ## Algorithm Overview
|
|
9
|
+
*
|
|
10
|
+
* 1. **YIN Difference Function**: Computes the difference between the signal
|
|
11
|
+
* and time-shifted versions of itself at various lags (candidate periods).
|
|
12
|
+
*
|
|
13
|
+
* 2. **Cumulative Mean Normalization**: Normalizes the difference function
|
|
14
|
+
* to make it more robust to amplitude variations.
|
|
15
|
+
*
|
|
16
|
+
* 3. **Pitch Candidates**: For each frame, identifies multiple pitch candidates
|
|
17
|
+
* with associated probabilities based on the normalized difference function.
|
|
18
|
+
*
|
|
19
|
+
* 4. **HMM Tracking**: Uses a Hidden Markov Model to track pitch over time,
|
|
20
|
+
* considering both observation probabilities and transition costs.
|
|
21
|
+
*
|
|
22
|
+
* 5. **Viterbi Decoding**: Finds the optimal sequence of pitch states that
|
|
23
|
+
* maximizes the overall probability, producing smooth pitch trajectories.
|
|
24
|
+
*
|
|
25
|
+
* ## Key Features
|
|
26
|
+
*
|
|
27
|
+
* - **Probabilistic Output**: Provides probability/confidence for each pitch estimate
|
|
28
|
+
* - **Voicing Detection**: Automatically detects voiced (pitched) vs unvoiced segments
|
|
29
|
+
* - **Smooth Transitions**: HMM prevents erratic pitch jumps between frames
|
|
30
|
+
* - **Polyphonic Robustance**: Handles complex audio by tracking the most likely fundamental
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const detector = new PitchDetector({
|
|
35
|
+
* minFrequency: 80,
|
|
36
|
+
* maxFrequency: 1000,
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* const results = detector.detect(audioBuffer);
|
|
40
|
+
*
|
|
41
|
+
* for (const result of results) {
|
|
42
|
+
* if (result.isVoiced) {
|
|
43
|
+
* console.log(`${result.timestamp.toFixed(3)}s: ${result.noteName} (${result.frequency.toFixed(1)} Hz)`);
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* ## References
|
|
49
|
+
*
|
|
50
|
+
* - Mauch, M., & Dixon, S. (2014). pYIN: A Fundamental Frequency Estimator Using
|
|
51
|
+
* Probabilistic Threshold Distributions. IEEE ICASSP.
|
|
52
|
+
* - De Cheveigné, A., & Kawahara, H. (2002). YIN, a fundamental frequency
|
|
53
|
+
* estimator for speech and music. JASA.
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* Configuration for the PitchDetector
|
|
57
|
+
*/
|
|
58
|
+
export interface PitchDetectorConfig {
|
|
59
|
+
/** Minimum frequency to detect in Hz (default: 80Hz, low guitar) */
|
|
60
|
+
minFrequency: number;
|
|
61
|
+
/** Maximum frequency to detect in Hz (default: 1000Hz, high vocals) */
|
|
62
|
+
maxFrequency: number;
|
|
63
|
+
/** Frame size in samples (default: 2048, ~46ms at 44.1kHz) */
|
|
64
|
+
frameSize: number;
|
|
65
|
+
/** Hop size in samples (default: 512, ~12ms at 44.1kHz) */
|
|
66
|
+
hopSize: number;
|
|
67
|
+
/** Probability threshold for voiced/unvoiced decision (default: 0.5) */
|
|
68
|
+
voicingThreshold: number;
|
|
69
|
+
/** Penalty for large pitch jumps in HMM (default: 0.5) */
|
|
70
|
+
transitionPenalty: number;
|
|
71
|
+
/** Probability of staying in the same pitch state (default: 0.99) */
|
|
72
|
+
selfTransitionProbability: number;
|
|
73
|
+
/** Threshold for accepting a pitch candidate (default: 0.1) */
|
|
74
|
+
yinThreshold: number;
|
|
75
|
+
/** Target sample rate for analysis (default: 44100) */
|
|
76
|
+
targetSampleRate: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Result of pitch detection for a single frame
|
|
80
|
+
*/
|
|
81
|
+
export interface PitchResult {
|
|
82
|
+
/** Timestamp in seconds */
|
|
83
|
+
timestamp: number;
|
|
84
|
+
/** Detected frequency in Hz (0 if no pitch detected) */
|
|
85
|
+
frequency: number;
|
|
86
|
+
/** Probability from pYIN HMM (0-1) */
|
|
87
|
+
probability: number;
|
|
88
|
+
/** Whether this frame contains a detectable pitch */
|
|
89
|
+
isVoiced: boolean;
|
|
90
|
+
/** MIDI note number (null if unvoiced) */
|
|
91
|
+
midiNote: number | null;
|
|
92
|
+
/** Note name e.g., "C4", "F#5" (null if unvoiced) */
|
|
93
|
+
noteName: string | null;
|
|
94
|
+
/** Alternative hypotheses for debugging/analysis (optional) */
|
|
95
|
+
alternativeHypotheses?: {
|
|
96
|
+
frequency: number;
|
|
97
|
+
probability: number;
|
|
98
|
+
}[];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Pitch Detector using the pYIN algorithm
|
|
102
|
+
*
|
|
103
|
+
* Detects the fundamental frequency (pitch) of audio signals over time.
|
|
104
|
+
* Uses probabilistic YIN with HMM tracking for robust, smooth pitch estimation.
|
|
105
|
+
*/
|
|
106
|
+
export declare class PitchDetector {
|
|
107
|
+
private config;
|
|
108
|
+
private states;
|
|
109
|
+
private transitionMatrix;
|
|
110
|
+
/**
|
|
111
|
+
* Create a new PitchDetector
|
|
112
|
+
*
|
|
113
|
+
* @param config - Configuration options (partial, defaults applied)
|
|
114
|
+
*/
|
|
115
|
+
constructor(config?: Partial<PitchDetectorConfig>);
|
|
116
|
+
/**
|
|
117
|
+
* Get the current configuration
|
|
118
|
+
*/
|
|
119
|
+
getConfig(): PitchDetectorConfig;
|
|
120
|
+
/**
|
|
121
|
+
* Initialize the HMM states and transition matrix
|
|
122
|
+
*
|
|
123
|
+
* Creates pitch states covering the frequency range with 2 bins per semitone.
|
|
124
|
+
* Pre-computes the transition probabilities between all state pairs.
|
|
125
|
+
*/
|
|
126
|
+
private initializeHMM;
|
|
127
|
+
/**
|
|
128
|
+
* Compute the transition probability matrix for the HMM
|
|
129
|
+
*
|
|
130
|
+
* The transition probability depends on the pitch distance between states.
|
|
131
|
+
* Closer pitches have higher transition probabilities.
|
|
132
|
+
*/
|
|
133
|
+
private computeTransitionMatrix;
|
|
134
|
+
/**
|
|
135
|
+
* Calculate transition probability between two states
|
|
136
|
+
*/
|
|
137
|
+
private transitionProbability;
|
|
138
|
+
/**
|
|
139
|
+
* Convert frequency in Hz to MIDI note number
|
|
140
|
+
*/
|
|
141
|
+
private frequencyToMidi;
|
|
142
|
+
/**
|
|
143
|
+
* Convert MIDI note number to frequency in Hz
|
|
144
|
+
*/
|
|
145
|
+
private midiToFrequency;
|
|
146
|
+
/**
|
|
147
|
+
* Convert MIDI note number to note name (e.g., "C4", "F#5")
|
|
148
|
+
*/
|
|
149
|
+
private midiToNoteName;
|
|
150
|
+
/**
|
|
151
|
+
* Detect pitch in an audio buffer
|
|
152
|
+
*
|
|
153
|
+
* Processes the entire audio buffer and returns pitch estimates for each frame.
|
|
154
|
+
*
|
|
155
|
+
* @param audioBuffer - Audio buffer to analyze
|
|
156
|
+
* @returns Array of pitch results, one per analysis frame
|
|
157
|
+
*/
|
|
158
|
+
detect(audioBuffer: AudioBuffer): PitchResult[];
|
|
159
|
+
/**
|
|
160
|
+
* Detect pitch continuously across a signal (full pYIN with HMM tracking)
|
|
161
|
+
*
|
|
162
|
+
* Same as detect() but accepts a Float32Array directly instead of AudioBuffer.
|
|
163
|
+
* Use this when audio has already been decoded or filtered.
|
|
164
|
+
*
|
|
165
|
+
* Note: The HMM is tuned for clean monophonic signals and may be too conservative
|
|
166
|
+
* for band-pass filtered polyphonic music. For such cases, prefer detectSignalRaw()
|
|
167
|
+
* which uses raw YIN voicing decisions without HMM bias.
|
|
168
|
+
*
|
|
169
|
+
* @param signal - Mono audio signal
|
|
170
|
+
* @param sampleRate - Sample rate of the signal
|
|
171
|
+
* @returns Array of pitch results, one per analysis frame
|
|
172
|
+
*/
|
|
173
|
+
detectSignal(signal: Float32Array, sampleRate: number): PitchResult[];
|
|
174
|
+
/**
|
|
175
|
+
* Detect pitch continuously across a signal using raw YIN (no HMM)
|
|
176
|
+
*
|
|
177
|
+
* Analyzes every frame with YIN and uses raw candidate probability for voicing
|
|
178
|
+
* decisions, without the HMM's unvoiced-state bias. More suitable than detectSignal()
|
|
179
|
+
* for band-pass filtered polyphonic music where the HMM tends to stay stuck in
|
|
180
|
+
* the unvoiced state.
|
|
181
|
+
*
|
|
182
|
+
* @param signal - Mono audio signal
|
|
183
|
+
* @param sampleRate - Sample rate of the signal
|
|
184
|
+
* @returns Array of pitch results, one per analysis frame
|
|
185
|
+
*/
|
|
186
|
+
detectSignalRaw(signal: Float32Array, sampleRate: number): PitchResult[];
|
|
187
|
+
/**
|
|
188
|
+
* Detect pitch at a specific timestamp
|
|
189
|
+
*
|
|
190
|
+
* Analyzes a single frame centered at the given timestamp.
|
|
191
|
+
*
|
|
192
|
+
* @param signal - Mono audio signal
|
|
193
|
+
* @param sampleRate - Sample rate of the signal
|
|
194
|
+
* @param timestamp - Timestamp in seconds to analyze
|
|
195
|
+
* @returns Pitch result for the frame
|
|
196
|
+
*/
|
|
197
|
+
detectAt(signal: Float32Array, sampleRate: number, timestamp: number): PitchResult;
|
|
198
|
+
/**
|
|
199
|
+
* Analyze a single frame and return pitch candidates
|
|
200
|
+
*
|
|
201
|
+
* Implements the core YIN algorithm with probabilistic output.
|
|
202
|
+
* Uses absolute threshold method: prefers the first (highest frequency) candidate
|
|
203
|
+
* below the threshold to avoid octave errors.
|
|
204
|
+
*/
|
|
205
|
+
private analyzeFrame;
|
|
206
|
+
/**
|
|
207
|
+
* Compute the YIN difference function
|
|
208
|
+
*
|
|
209
|
+
* For each lag τ, computes: d(τ) = Σ (x[i] - x[i+τ])²
|
|
210
|
+
*
|
|
211
|
+
* This measures how well the signal correlates with itself at each lag.
|
|
212
|
+
* A low value indicates the signal repeats with that period.
|
|
213
|
+
*/
|
|
214
|
+
private computeDifferenceFunction;
|
|
215
|
+
/**
|
|
216
|
+
* Compute the Cumulative Mean Normalized Difference Function (CMNDF)
|
|
217
|
+
*
|
|
218
|
+
* Normalizes the difference function by dividing by the cumulative mean.
|
|
219
|
+
* This makes the function more robust to amplitude variations.
|
|
220
|
+
*
|
|
221
|
+
* Formula: cmndf(τ) = d(τ) / (1/τ * Σ d(j) for j=1 to τ)
|
|
222
|
+
*/
|
|
223
|
+
private computeCMNDF;
|
|
224
|
+
/**
|
|
225
|
+
* Parabolic interpolation to refine the lag estimate
|
|
226
|
+
*
|
|
227
|
+
* Fits a parabola to three points and finds the minimum.
|
|
228
|
+
* This provides sub-sample accuracy for the pitch estimate.
|
|
229
|
+
*/
|
|
230
|
+
private parabolicInterpolation;
|
|
231
|
+
/**
|
|
232
|
+
* Get the probability for a given state based on frame candidates
|
|
233
|
+
*/
|
|
234
|
+
private getFrameProbability;
|
|
235
|
+
/**
|
|
236
|
+
* Run Viterbi decoding to find the optimal pitch path
|
|
237
|
+
*
|
|
238
|
+
* The Viterbi algorithm finds the most likely sequence of states given
|
|
239
|
+
* the observations (pitch candidates) and the transition model.
|
|
240
|
+
*/
|
|
241
|
+
private viterbiDecode;
|
|
242
|
+
/**
|
|
243
|
+
* Calculate prior log probability for the first frame
|
|
244
|
+
*/
|
|
245
|
+
private priorLogProbability;
|
|
246
|
+
/**
|
|
247
|
+
* Calculate observation log probability for a state given candidates
|
|
248
|
+
*/
|
|
249
|
+
private observationLogProbability;
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=PitchDetector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PitchDetector.d.ts","sourceRoot":"","sources":["../../../src/core/analysis/PitchDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAQH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAEhC,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,YAAY,EAAE,MAAM,CAAC;IAGrB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAGhB,wEAAwE;IACxE,gBAAgB,EAAE,MAAM,CAAC;IACzB,0DAA0D;IAC1D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qEAAqE;IACrE,yBAAyB,EAAE,MAAM,CAAC;IAGlC,+DAA+D;IAC/D,YAAY,EAAE,MAAM,CAAC;IAGrB,uDAAuD;IACvD,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,QAAQ,EAAE,OAAO,CAAC;IAClB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,+DAA+D;IAC/D,qBAAqB,CAAC,EAAE;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACvB,EAAE,CAAC;CACP;AAqED;;;;;GAKG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAA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|
+
* Based on specs/001-core-engine/SPEC.md
|
|
4
|
+
*
|
|
5
|
+
* Previous bands (severely imbalanced):
|
|
6
|
+
* - Bass: 20Hz - 250Hz (230 Hz range, only 3% of spectrum)
|
|
7
|
+
* - Mid: 250Hz - 4kHz (3,750 Hz range, 47% of spectrum)
|
|
8
|
+
* - Treble: 4kHz - 20kHz (16,000 Hz range, 200% of spectrum!)
|
|
9
|
+
*
|
|
10
|
+
* Rebalanced bands (v2):
|
|
11
|
+
* - Bass: 20Hz - 400Hz (380 Hz range, 11% of spectrum) - Expanded from 20-250Hz
|
|
12
|
+
* - Mid: 400Hz - 4kHz (3,600 Hz range, 52% of spectrum) - Expanded from 250-4kHz
|
|
13
|
+
* - Treble: 4kHz - 14kHz (10,000 Hz range, 37% of spectrum) - Narrowed from 4kHz-20kHz
|
|
14
|
+
*
|
|
15
|
+
* This creates a more balanced distribution that prevents treble from dominating
|
|
16
|
+
* class selection (which caused over-representation of Rogues/Rangers/Monks).
|
|
17
|
+
*/
|
|
18
|
+
import type { FrequencyBands } from '../types/AudioProfile.js';
|
|
19
|
+
/** Current frequency band version (used for tracking audio profile format changes) */
|
|
20
|
+
export declare const CURRENT_BAND_VERSION = 2;
|
|
21
|
+
export declare class SpectrumScanner {
|
|
22
|
+
/**
|
|
23
|
+
* Separate frequency data into bass, mid, and treble bands
|
|
24
|
+
*
|
|
25
|
+
* Rebalanced band v2 ranges:
|
|
26
|
+
* - Bass: 20Hz - 400Hz (expanded from 20-250Hz)
|
|
27
|
+
* - Mid: 400Hz - 4kHz (expanded from 250-4kHz)
|
|
28
|
+
* - Treble: 4kHz - 14kHz (narrowed from 4kHz-20kHz)
|
|
29
|
+
*
|
|
30
|
+
* These rebalanced ranges prevent treble dominance that caused over-representation
|
|
31
|
+
* of dexterity-based classes (Rogue, Ranger, Monk).
|
|
32
|
+
*
|
|
33
|
+
* @param frequencyData - Raw FFT frequency data from audio analysis
|
|
34
|
+
* @param sampleRate - Audio sample rate in Hz (typically 44100 or 48000)
|
|
35
|
+
* @returns Frequency bands with normalized amplitude values (0-1)
|
|
36
|
+
*/
|
|
37
|
+
static separateFrequencyBands(frequencyData: Uint8Array, sampleRate: number): FrequencyBands;
|
|
38
|
+
/**
|
|
39
|
+
* Calculate dominance (average amplitude) for a frequency band
|
|
40
|
+
*
|
|
41
|
+
* Bandwidth-aware normalization prevents wider frequency bands from dominating
|
|
42
|
+
* the dominance calculation. Previously, wider bands had more frequency bins,
|
|
43
|
+
* so their averages were naturally higher even if music wasn't louder in those ranges.
|
|
44
|
+
* This version normalizes by bandwidth (per kHz) to create fair comparisons across bands.
|
|
45
|
+
*
|
|
46
|
+
* @param band - Array of amplitude values for a frequency band
|
|
47
|
+
* @param bandWidthHz - Width of the frequency band in Hz (e.g., 380 for bass: 400-20)
|
|
48
|
+
* @returns Normalized dominance value (typically 0-1, may exceed 1 for very loud bands)
|
|
49
|
+
*/
|
|
50
|
+
static calculateDominance(band: number[], bandWidthHz?: number): number;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=SpectrumScanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpectrumScanner.d.ts","sourceRoot":"","sources":["../../../src/core/analysis/SpectrumScanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,qBAAa,eAAe;IACxB;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,sBAAsB,CACzB,aAAa,EAAE,UAAU,EACzB,UAAU,EAAE,MAAM,GACnB,cAAc;IA4BjB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM;CAe1E"}
|