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,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tempo Detector
|
|
3
|
+
*
|
|
4
|
+
* Implements global tempo estimation using autocorrelation with perceptual weighting
|
|
5
|
+
* as described in Ellis, D.P.W. (2007) "Beat Tracking by Dynamic Programming"
|
|
6
|
+
*
|
|
7
|
+
* Reference: https://www.ee.columbia.edu/~dpwe/pubs/Ellis07-beattrack.pdf
|
|
8
|
+
* Section 3.2: Tempo Estimation
|
|
9
|
+
*
|
|
10
|
+
* ## Meter Resolution Options
|
|
11
|
+
*
|
|
12
|
+
* ### Octave Resolution (TPS2) - Duple Meter
|
|
13
|
+
* The perceptual weighting cannot distinguish between half/double tempo (e.g., 73 BPM vs 146 BPM).
|
|
14
|
+
* When `useOctaveResolution` is enabled, TPS2 (Tempo Period Strength for duple meter) is used
|
|
15
|
+
* to prefer tempos with strong half-period evidence. This improved accuracy from 77% to 84%
|
|
16
|
+
* in the original Ellis paper.
|
|
17
|
+
*
|
|
18
|
+
* ### Triple Meter Resolution (TPS3)
|
|
19
|
+
* When `useTripleMeter` is enabled, TPS3 is used to detect triple meter music (3/4, 6/8).
|
|
20
|
+
* The TPS3 formula combines the main tempo with its third-harmonic:
|
|
21
|
+
* `TPS3(τ) = TPS(τ) + 0.33×TPS(3τ) + 0.33×TPS(3τ-1) + 0.33×TPS(3τ+1)`
|
|
22
|
+
*
|
|
23
|
+
* Both options can be enabled simultaneously as they work independently.
|
|
24
|
+
*/
|
|
25
|
+
import type { TempoDetectorConfig, TempoEstimate } from '../../types/BeatMap.js';
|
|
26
|
+
/**
|
|
27
|
+
* Tempo Detector
|
|
28
|
+
*
|
|
29
|
+
* Estimates the global tempo of an audio track using autocorrelation
|
|
30
|
+
* of the onset strength envelope with perceptual weighting.
|
|
31
|
+
*
|
|
32
|
+
* The algorithm follows Ellis 2007 Section 3.2:
|
|
33
|
+
* 1. Compute autocorrelation of the onset strength envelope
|
|
34
|
+
* 2. Apply perceptual weighting that biases toward 120 BPM
|
|
35
|
+
* 3. Find the peak that maximizes the weighted autocorrelation
|
|
36
|
+
* 4. (Optional) Use TPS2 for octave resolution to prevent half-tempo detection
|
|
37
|
+
* 5. (Optional) Use TPS3 for triple meter resolution to detect 3/4, 6/8 time signatures
|
|
38
|
+
*
|
|
39
|
+
* ## Octave Resolution (TPS2) - Duple Meter
|
|
40
|
+
* The perceptual weighting cannot distinguish between half/double tempo (e.g., 73 BPM vs 146 BPM).
|
|
41
|
+
* When `useOctaveResolution` is enabled, TPS2 (Tempo Period Strength for duple meter) is used
|
|
42
|
+
* to prefer tempos with strong half-period evidence. This improved accuracy from 77% to 84%
|
|
43
|
+
* in the original Ellis paper.
|
|
44
|
+
*
|
|
45
|
+
* ## Triple Meter Resolution (TPS3)
|
|
46
|
+
* When `useTripleMeter` is enabled, TPS3 is used to detect triple meter music (3/4, 6/8).
|
|
47
|
+
* The TPS3 formula combines the main tempo with its third-harmonic:
|
|
48
|
+
* `TPS3(τ) = TPS(τ) + 0.33×TPS(3τ) + 0.33×TPS(3τ-1) + 0.33×TPS(3τ+1)`
|
|
49
|
+
*
|
|
50
|
+
* Both TPS2 and TPS3 can be enabled simultaneously as they work independently.
|
|
51
|
+
*
|
|
52
|
+
* @see {@link https://www.ee.columbia.edu/~dpwe/pubs/Ellis07-beattrack.pdf|Ellis 2007 Paper}
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const detector = new TempoDetector({
|
|
57
|
+
* tempoCenter: 0.5, // 120 BPM
|
|
58
|
+
* tempoWidth: 1.4, // octaves
|
|
59
|
+
* useOctaveResolution: true, // Enable TPS2 octave resolution
|
|
60
|
+
* useTripleMeter: true, // Enable TPS3 triple meter resolution
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* const estimate = detector.estimateTempo(onsetEnvelope, hopSize);
|
|
64
|
+
* console.log(`Estimated BPM: ${estimate.primaryBpm}`);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare class TempoDetector {
|
|
68
|
+
private config;
|
|
69
|
+
/**
|
|
70
|
+
* Create a new Tempo Detector
|
|
71
|
+
*
|
|
72
|
+
* @param config - Configuration options (all optional, defaults provided)
|
|
73
|
+
*/
|
|
74
|
+
constructor(config?: TempoDetectorConfig);
|
|
75
|
+
/**
|
|
76
|
+
* Estimate the tempo from an onset strength envelope
|
|
77
|
+
*
|
|
78
|
+
* Implements Ellis Section 3.2:
|
|
79
|
+
* - Autocorrelation with perceptual weighting
|
|
80
|
+
* - TPS2 for duple meter (octave resolution)
|
|
81
|
+
* - TPS3 for triple meter (3/4, 6/8 detection)
|
|
82
|
+
*
|
|
83
|
+
* ## Octave Resolution (TPS2) - Duple Meter
|
|
84
|
+
* When `useOctaveResolution` is enabled, this method uses TPS2
|
|
85
|
+
* (Tempo Period Strength for duple meter) to resolve tempo octave ambiguity.
|
|
86
|
+
*
|
|
87
|
+
* The problem: the perceptual weighting gives equal preference to tempos at
|
|
88
|
+
* half/double the true tempo (e.g., 73 BPM vs 146 BPM). This causes the
|
|
89
|
+
* algorithm to sometimes lock onto the wrong octave.
|
|
90
|
+
*
|
|
91
|
+
* The solution: TPS2 combines the main tempo with its half-period energy:
|
|
92
|
+
* `TPS2(τ) = TPS(τ) + 0.5×TPS(2τ) + 0.25×TPS(2τ-1) + 0.25×TPS(2τ+1)`
|
|
93
|
+
*
|
|
94
|
+
* Tempos with strong half-period evidence (indicating the correct octave)
|
|
95
|
+
* will have higher TPS2 scores, allowing us to prefer the true tempo.
|
|
96
|
+
*
|
|
97
|
+
* ## Triple Meter Resolution (TPS3)
|
|
98
|
+
* When `useTripleMeter` is enabled, this method uses TPS3 to detect triple
|
|
99
|
+
* meter music (3/4, 6/8 time signatures).
|
|
100
|
+
*
|
|
101
|
+
* The problem: for waltzes and triple meter music, the algorithm may lock onto
|
|
102
|
+
* a slower tempo (1 beat per 3 sub-beats) instead of the actual beat.
|
|
103
|
+
*
|
|
104
|
+
* The solution: TPS3 combines the main tempo with its third-period energy:
|
|
105
|
+
* `TPS3(τ) = TPS(τ) + 0.33×TPS(3τ) + 0.33×TPS(3τ-1) + 0.33×TPS(3τ+1)`
|
|
106
|
+
*
|
|
107
|
+
* Tempos with strong third-period evidence (indicating triple meter)
|
|
108
|
+
* will have higher TPS3 scores, allowing proper beat detection.
|
|
109
|
+
*
|
|
110
|
+
* ## Combining TPS2 and TPS3
|
|
111
|
+
* Both options can be enabled simultaneously. They run independently:
|
|
112
|
+
* - TPS2 runs first, resolving duple meter ambiguity
|
|
113
|
+
* - TPS3 runs second, resolving triple meter ambiguity
|
|
114
|
+
*
|
|
115
|
+
* @param onsetEnvelope - Onset strength envelope from OSE calculation
|
|
116
|
+
* @param hopSizeSeconds - Hop size in seconds (time between envelope frames)
|
|
117
|
+
* @returns Tempo estimate with primary/secondary BPM and meter info
|
|
118
|
+
*/
|
|
119
|
+
estimateTempo(onsetEnvelope: Float32Array, hopSizeSeconds: number): TempoEstimate;
|
|
120
|
+
/**
|
|
121
|
+
* Get the current configuration
|
|
122
|
+
*
|
|
123
|
+
* @returns The current configuration
|
|
124
|
+
*/
|
|
125
|
+
getConfig(): Required<TempoDetectorConfig>;
|
|
126
|
+
/**
|
|
127
|
+
* Compute autocorrelation of the onset strength envelope
|
|
128
|
+
*
|
|
129
|
+
* TPS(τ) = Σ O(t) × O(t-τ)
|
|
130
|
+
*
|
|
131
|
+
* @param envelope - Onset strength envelope
|
|
132
|
+
* @param minLag - Minimum lag to compute
|
|
133
|
+
* @param maxLag - Maximum lag to compute
|
|
134
|
+
* @returns Autocorrelation values and lag range
|
|
135
|
+
*/
|
|
136
|
+
private computeAutocorrelation;
|
|
137
|
+
/**
|
|
138
|
+
* Apply perceptual weighting to autocorrelation values
|
|
139
|
+
*
|
|
140
|
+
* W(τ) = exp(-0.5 × (log₂(τ/τ₀) / στ)²)
|
|
141
|
+
*
|
|
142
|
+
* Where:
|
|
143
|
+
* - τ₀ = tempoCenter (default 0.5s = 120 BPM)
|
|
144
|
+
* - στ = tempoWidth (default 1.4 octaves)
|
|
145
|
+
*
|
|
146
|
+
* This biases toward human tempo perception centered at 120 BPM.
|
|
147
|
+
*
|
|
148
|
+
* @param autocorr - Autocorrelation values
|
|
149
|
+
* @param minLag - Minimum lag in the array
|
|
150
|
+
* @param hopSizeSeconds - Hop size in seconds
|
|
151
|
+
* @returns Weighted autocorrelation values
|
|
152
|
+
*/
|
|
153
|
+
private applyPerceptualWeighting;
|
|
154
|
+
/**
|
|
155
|
+
* Find the index of the maximum value in an array
|
|
156
|
+
*
|
|
157
|
+
* @param array - Input array
|
|
158
|
+
* @param start - Start index (inclusive)
|
|
159
|
+
* @param end - End index (exclusive)
|
|
160
|
+
* @returns Index of maximum value
|
|
161
|
+
*/
|
|
162
|
+
private findPeak;
|
|
163
|
+
/**
|
|
164
|
+
* Convert lag in frames to BPM
|
|
165
|
+
*
|
|
166
|
+
* BPM = 60 / (lag × hopSize)
|
|
167
|
+
*
|
|
168
|
+
* @param lag - Lag in frames
|
|
169
|
+
* @param hopSizeSeconds - Hop size in seconds
|
|
170
|
+
* @returns BPM
|
|
171
|
+
*/
|
|
172
|
+
private lagToBpm;
|
|
173
|
+
/**
|
|
174
|
+
* Calculate TPS2 - Tempo Period Strength for duple meter
|
|
175
|
+
*
|
|
176
|
+
* TPS2(τ) = TPS(τ) + 0.5×TPS(2τ) + 0.25×TPS(2τ-1) + 0.25×TPS(2τ+1)
|
|
177
|
+
*
|
|
178
|
+
* This combines the main tempo with its half-time equivalent,
|
|
179
|
+
* improving accuracy from 77% to 84% per Ellis paper.
|
|
180
|
+
*
|
|
181
|
+
* @param autocorr - Autocorrelation values (indexed from minLag)
|
|
182
|
+
* @param primaryIdx - Index of primary tempo in autocorr array
|
|
183
|
+
* @returns TPS2 value
|
|
184
|
+
*/
|
|
185
|
+
private calculateTPS2;
|
|
186
|
+
/**
|
|
187
|
+
* Calculate TPS3 - Tempo Period Strength for triple meter
|
|
188
|
+
*
|
|
189
|
+
* TPS3(τ) = TPS(τ) + 0.33×TPS(3τ) + 0.33×TPS(3τ-1) + 0.33×TPS(3τ+1)
|
|
190
|
+
*
|
|
191
|
+
* This combines the main tempo with its third-time equivalent,
|
|
192
|
+
* useful for detecting triple meter (3/4, 6/8).
|
|
193
|
+
*
|
|
194
|
+
* @param autocorr - Autocorrelation values
|
|
195
|
+
* @param primaryIdx - Index of primary tempo in autocorr array
|
|
196
|
+
* @returns TPS3 value
|
|
197
|
+
*/
|
|
198
|
+
private calculateTPS3;
|
|
199
|
+
/**
|
|
200
|
+
* Get a default tempo estimate for edge cases
|
|
201
|
+
*
|
|
202
|
+
* @returns Default tempo estimate (120 BPM)
|
|
203
|
+
*/
|
|
204
|
+
private getDefaultEstimate;
|
|
205
|
+
/**
|
|
206
|
+
* Get tempo candidates (for debugging/visualization)
|
|
207
|
+
*
|
|
208
|
+
* Returns the top N tempo candidates with their strengths.
|
|
209
|
+
*
|
|
210
|
+
* @param onsetEnvelope - Onset strength envelope
|
|
211
|
+
* @param hopSizeSeconds - Hop size in seconds
|
|
212
|
+
* @param count - Number of candidates to return
|
|
213
|
+
* @returns Array of BPM candidates with strengths
|
|
214
|
+
*/
|
|
215
|
+
getTempoCandidates(onsetEnvelope: Float32Array, hopSizeSeconds: number, count?: number): Array<{
|
|
216
|
+
bpm: number;
|
|
217
|
+
strength: number;
|
|
218
|
+
}>;
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=TempoDetector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TempoDetector.d.ts","sourceRoot":"","sources":["../../../../src/core/analysis/beat/TempoDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AA0BjF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAgC;IAE9C;;;;OAIG;gBACS,MAAM,GAAE,mBAAwB;IAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACH,aAAa,CAAC,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,GAAG,aAAa;IAgHjF;;;;OAIG;IACH,SAAS,IAAI,QAAQ,CAAC,mBAAmB,CAAC;IAI1C;;;;;;;;;OASG;IACH,OAAO,CAAC,sBAAsB;IAoC9B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,wBAAwB;IA4BhC;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ;IAchB;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAQ;IAOhB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,aAAa;IAerB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,aAAa;IAerB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAU1B;;;;;;;;;OASG;IACH,kBAAkB,CACd,aAAa,EAAE,YAAY,EAC3B,cAAc,EAAE,MAAM,EACtB,KAAK,GAAE,MAAU,GAClB,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAuC9C"}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transient Detector for Multi-Band Rhythm Detection
|
|
3
|
+
*
|
|
4
|
+
* Detects transients (onsets) in audio using band-specific detection strategies.
|
|
5
|
+
* Each frequency band uses a different algorithm optimized for its typical content:
|
|
6
|
+
*
|
|
7
|
+
* Part of the Procedural Rhythm Generation pipeline.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Basic usage - detect transients from multi-band analysis
|
|
12
|
+
* const detector = new TransientDetector();
|
|
13
|
+
* const transients = detector.detect(multiBandResult);
|
|
14
|
+
*
|
|
15
|
+
* // Access all transients across all bands
|
|
16
|
+
* console.log(`Total transients: ${transients.transients.length}`);
|
|
17
|
+
*
|
|
18
|
+
* // Access transients by band
|
|
19
|
+
* for (const [band, bandTransients] of transients.bandTransients) {
|
|
20
|
+
* console.log(`${band}: ${bandTransients.length} transients`);
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* // Custom configuration with higher threshold
|
|
24
|
+
* const customDetector = new TransientDetector({
|
|
25
|
+
* baseThreshold: 0.5, // Higher = fewer transients detected
|
|
26
|
+
* adaptiveThresholding: true, // Adjust based on local energy
|
|
27
|
+
* minTransientInterval: 0.03, // Minimum 30ms between transients
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
import type { MultiBandResult } from '../MultiBandAnalyzer.js';
|
|
32
|
+
import type { FrequencyBand } from './utils/audioUtils.js';
|
|
33
|
+
/**
|
|
34
|
+
* Detection method used for a transient
|
|
35
|
+
*/
|
|
36
|
+
export type TransientDetectionMethod = 'energy' | 'spectral_flux' | 'hfc';
|
|
37
|
+
/**
|
|
38
|
+
* Band identifier type
|
|
39
|
+
*/
|
|
40
|
+
type BandName = 'low' | 'mid' | 'high';
|
|
41
|
+
/**
|
|
42
|
+
* Per-band transient detection configuration.
|
|
43
|
+
* Each frequency band can have different settings optimized for its typical content.
|
|
44
|
+
*/
|
|
45
|
+
export interface BandTransientConfig {
|
|
46
|
+
/**
|
|
47
|
+
* Threshold for peak detection (0.0 - 1.0).
|
|
48
|
+
* Higher values are more selective (fewer transients detected).
|
|
49
|
+
*/
|
|
50
|
+
threshold: number;
|
|
51
|
+
/**
|
|
52
|
+
* Minimum interval between transients in seconds (buffer window).
|
|
53
|
+
* Within this window, only the strongest transient wins (Non-Maximum Suppression).
|
|
54
|
+
*/
|
|
55
|
+
minInterval: number;
|
|
56
|
+
/**
|
|
57
|
+
* Whether to use adaptive thresholding for this band.
|
|
58
|
+
* Adjusts threshold based on local energy/density of the signal.
|
|
59
|
+
*/
|
|
60
|
+
adaptiveThresholding: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Per-band transient detection configuration overrides.
|
|
64
|
+
* Each band can optionally override the global defaults.
|
|
65
|
+
*/
|
|
66
|
+
export interface BandTransientConfigOverrides {
|
|
67
|
+
/** Low frequency band (20-500 Hz) - kick drums, bass */
|
|
68
|
+
low?: Partial<BandTransientConfig>;
|
|
69
|
+
/** Mid frequency band (500-2000 Hz) - vocals, snare body */
|
|
70
|
+
mid?: Partial<BandTransientConfig>;
|
|
71
|
+
/** High frequency band (2000-20000 Hz) - hi-hats, cymbals */
|
|
72
|
+
high?: Partial<BandTransientConfig>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Result of a single detected transient
|
|
76
|
+
*/
|
|
77
|
+
export interface TransientResult {
|
|
78
|
+
/** Timestamp in seconds from the start of the audio */
|
|
79
|
+
timestamp: number;
|
|
80
|
+
/** Strength of the detected transient (0.0 - 1.0, normalized) */
|
|
81
|
+
intensity: number;
|
|
82
|
+
/** Which frequency band detected this: 'low', 'mid', or 'high' */
|
|
83
|
+
band: 'low' | 'mid' | 'high';
|
|
84
|
+
/** Detection method used to find this transient */
|
|
85
|
+
detectionMethod: TransientDetectionMethod;
|
|
86
|
+
/** Information about the nearest beat in the beat map (set during quantization) */
|
|
87
|
+
nearestBeat?: {
|
|
88
|
+
/** Index into UnifiedBeatMap.beats[] */
|
|
89
|
+
index: number;
|
|
90
|
+
/** How far from quarter note grid (in seconds) */
|
|
91
|
+
distance: number;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Configuration for the TransientDetector
|
|
96
|
+
*/
|
|
97
|
+
export interface TransientDetectorConfig {
|
|
98
|
+
/**
|
|
99
|
+
* Base threshold for peak detection (0.0 - 1.0).
|
|
100
|
+
* Lower values detect more transients, higher values are more selective.
|
|
101
|
+
* This is used as a fallback if per-band threshold is not specified.
|
|
102
|
+
* Default: 0.3
|
|
103
|
+
*/
|
|
104
|
+
baseThreshold?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Adaptive thresholding enabled.
|
|
107
|
+
* When true, the detector adjusts thresholds based on the local energy/density of the signal.
|
|
108
|
+
* This is used as a fallback if per-band setting is not specified.
|
|
109
|
+
* Default: true
|
|
110
|
+
*/
|
|
111
|
+
adaptiveThresholding?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Window size for adaptive thresholding (in frames).
|
|
114
|
+
* The local energy is calculated over this window to adjust thresholds.
|
|
115
|
+
* Default: 50 frames (~500ms at 10ms hop size)
|
|
116
|
+
*/
|
|
117
|
+
adaptiveWindowSize?: number;
|
|
118
|
+
/**
|
|
119
|
+
* Minimum distance between transients in seconds (buffer window).
|
|
120
|
+
* Within this window, only the strongest transient wins (Non-Maximum Suppression).
|
|
121
|
+
* This is used as a fallback if per-band interval is not specified.
|
|
122
|
+
* Default: 0.02 (20ms)
|
|
123
|
+
* @deprecated Use per-band config in `bandConfig` instead
|
|
124
|
+
*/
|
|
125
|
+
minTransientInterval?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Custom frequency bands (default: FREQUENCY_BANDS from audioUtils)
|
|
128
|
+
*/
|
|
129
|
+
bands?: FrequencyBand[];
|
|
130
|
+
/**
|
|
131
|
+
* Per-band configuration overrides.
|
|
132
|
+
* Each band can have different thresholds and intervals optimized for its content.
|
|
133
|
+
* Settings here override the global defaults for specific bands.
|
|
134
|
+
*/
|
|
135
|
+
bandConfig?: BandTransientConfigOverrides;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Result of transient analysis
|
|
139
|
+
*/
|
|
140
|
+
export interface TransientAnalysis {
|
|
141
|
+
/** All detected transients across all bands */
|
|
142
|
+
transients: TransientResult[];
|
|
143
|
+
/** Transients grouped by frequency band */
|
|
144
|
+
bandTransients: Map<'low' | 'mid' | 'high', TransientResult[]>;
|
|
145
|
+
/** Analysis metadata */
|
|
146
|
+
metadata: {
|
|
147
|
+
/** Total number of transients detected */
|
|
148
|
+
totalTransients: number;
|
|
149
|
+
/** Number of transients per band */
|
|
150
|
+
transientsPerBand: Map<'low' | 'mid' | 'high', number>;
|
|
151
|
+
/** Duration of the audio in seconds */
|
|
152
|
+
duration: number;
|
|
153
|
+
/** Average transient intensity */
|
|
154
|
+
averageIntensity: number;
|
|
155
|
+
/** Detection methods used */
|
|
156
|
+
detectionMethodsUsed: TransientDetectionMethod[];
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Multi-Band Transient Detector
|
|
161
|
+
*
|
|
162
|
+
* Detects transients (onsets) using band-specific detection strategies.
|
|
163
|
+
* Each frequency band is analyzed with an algorithm optimized for its typical content:
|
|
164
|
+
*
|
|
165
|
+
* - **Low Band (20-500 Hz)**: Energy-based detection
|
|
166
|
+
* - Optimized for kick drums, bass, sub frequencies
|
|
167
|
+
* - Uses the energy envelope directly to detect sharp amplitude changes
|
|
168
|
+
*
|
|
169
|
+
* - **Mid Band (500-2000 Hz)**: Spectral Flux
|
|
170
|
+
* - Optimized for vocals, snare body, lead instruments
|
|
171
|
+
* - Measures spectral change between frames for onset detection
|
|
172
|
+
*
|
|
173
|
+
* - **High Band (2000-20000 Hz)**: High-Frequency Content (HFC)
|
|
174
|
+
* - Optimized for hi-hats, cymbals, harmonics, air
|
|
175
|
+
* - Weights high-frequency bins more heavily for cymbal/percussive detection
|
|
176
|
+
*
|
|
177
|
+
* ## Usage
|
|
178
|
+
*
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const multiBandAnalyzer = new MultiBandAnalyzer();
|
|
181
|
+
* const multiBandResult = multiBandAnalyzer.analyze(audioBuffer);
|
|
182
|
+
*
|
|
183
|
+
* const detector = new TransientDetector();
|
|
184
|
+
* const transients = detector.detect(multiBandResult);
|
|
185
|
+
*
|
|
186
|
+
* // Access per-band transients
|
|
187
|
+
* const lowBandTransients = transients.bandTransients.get('low');
|
|
188
|
+
* const midBandTransients = transients.bandTransients.get('mid');
|
|
189
|
+
* const highBandTransients = transients.bandTransients.get('high');
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* ## Adaptive Thresholding
|
|
193
|
+
*
|
|
194
|
+
* When adaptive thresholding is enabled, the detector adjusts thresholds based on local energy.
|
|
195
|
+
* This helps handle songs with varying dynamics (quiet vs loud sections).
|
|
196
|
+
*/
|
|
197
|
+
export declare class TransientDetector {
|
|
198
|
+
private config;
|
|
199
|
+
/**
|
|
200
|
+
* Create a new TransientDetector
|
|
201
|
+
*
|
|
202
|
+
* @param config - Configuration options (all optional, defaults provided)
|
|
203
|
+
*/
|
|
204
|
+
constructor(config?: TransientDetectorConfig);
|
|
205
|
+
/**
|
|
206
|
+
* Get the current configuration
|
|
207
|
+
*
|
|
208
|
+
* @returns The current configuration
|
|
209
|
+
*/
|
|
210
|
+
getConfig(): TransientDetectorConfig;
|
|
211
|
+
/**
|
|
212
|
+
* Get the per-band configuration
|
|
213
|
+
*
|
|
214
|
+
* @returns The per-band configuration
|
|
215
|
+
*/
|
|
216
|
+
getBandConfig(): Record<BandName, BandTransientConfig>;
|
|
217
|
+
/**
|
|
218
|
+
* Detect transients in multi-band audio analysis
|
|
219
|
+
*
|
|
220
|
+
* @param multiBandResult - Result from MultiBandAnalyzer
|
|
221
|
+
* @returns Transient analysis with per-band results
|
|
222
|
+
*/
|
|
223
|
+
detect(multiBandResult: MultiBandResult): TransientAnalysis;
|
|
224
|
+
/**
|
|
225
|
+
* Detect transients in a specific frequency band
|
|
226
|
+
*
|
|
227
|
+
* Uses band-specific detection strategies:
|
|
228
|
+
* - Low band: Energy-based detection
|
|
229
|
+
* - Mid band: Spectral Flux
|
|
230
|
+
* - High band: High-Frequency Content (HFC)
|
|
231
|
+
*
|
|
232
|
+
* Applies Non-Maximum Suppression (NMS) to ensure only the strongest
|
|
233
|
+
* transient within a buffer window is kept.
|
|
234
|
+
*
|
|
235
|
+
* @param bandName - Name of the frequency band
|
|
236
|
+
* @param bandAnalysis - Analysis result for this band
|
|
237
|
+
* @param hopSizeSeconds - Time between frames in seconds
|
|
238
|
+
* @returns Array of detected transients
|
|
239
|
+
*/
|
|
240
|
+
private detectBandTransients;
|
|
241
|
+
/**
|
|
242
|
+
* Apply Non-Maximum Suppression (NMS) to transients
|
|
243
|
+
*
|
|
244
|
+
* Within a buffer window, only the strongest transient wins.
|
|
245
|
+
* This prevents multiple detections for the same acoustic event.
|
|
246
|
+
*
|
|
247
|
+
* ## Algorithm
|
|
248
|
+
*
|
|
249
|
+
* 1. Sort candidates by intensity (strongest first)
|
|
250
|
+
* 2. For each candidate (starting with strongest):
|
|
251
|
+
* - If not suppressed by an already-accepted transient, accept it
|
|
252
|
+
* - Suppress all weaker candidates within the buffer window
|
|
253
|
+
* 3. Return accepted transients sorted by timestamp
|
|
254
|
+
*
|
|
255
|
+
* @param candidates - All candidate transients (peaks above threshold)
|
|
256
|
+
* @param bufferWindow - Minimum interval in seconds between transients
|
|
257
|
+
* @returns Filtered transients with only the strongest in each window
|
|
258
|
+
*/
|
|
259
|
+
private applyNonMaximumSuppression;
|
|
260
|
+
/**
|
|
261
|
+
* Get the detection method for a specific band
|
|
262
|
+
*
|
|
263
|
+
* @param bandName - Name of the frequency band
|
|
264
|
+
* @returns Detection method to use for this band
|
|
265
|
+
*/
|
|
266
|
+
private getDetectionMethod;
|
|
267
|
+
/**
|
|
268
|
+
* Calculate adaptive threshold based on local energy
|
|
269
|
+
*
|
|
270
|
+
* Uses a sliding window to calculate local energy and adjust threshold accordingly.
|
|
271
|
+
* This helps handle songs with varying dynamics.
|
|
272
|
+
*
|
|
273
|
+
* ## Algorithm: Adaptive Thresholding via Coefficient of Variation
|
|
274
|
+
*
|
|
275
|
+
* The threshold is adjusted based on the signal's dynamic range:
|
|
276
|
+
*
|
|
277
|
+
* 1. **Calculate Mean Energy**: Average onset strength across all frames
|
|
278
|
+
* 2. **Calculate Standard Deviation**: Measure of energy variation
|
|
279
|
+
* 3. **Compute Coefficient of Variation (CV)**: stdDev / mean
|
|
280
|
+
* - CV ≈ 0: Signal is consistent (e.g., electronic dance music)
|
|
281
|
+
* - CV > 1: Signal has high dynamic range (e.g., classical with quiet/loud sections)
|
|
282
|
+
* 4. **Adjust Threshold**: baseThreshold * (1 + CV * 0.5)
|
|
283
|
+
* - High CV → Higher threshold (more selective, fewer false positives in dynamic sections)
|
|
284
|
+
* - Low CV → Lower threshold (catch more transients in consistent sections)
|
|
285
|
+
*
|
|
286
|
+
* @param envelope - The onset strength envelope
|
|
287
|
+
* @param baseThreshold - The base threshold for this band (default: global baseThreshold)
|
|
288
|
+
* @returns Calculated threshold
|
|
289
|
+
*/
|
|
290
|
+
private calculateAdaptiveThreshold;
|
|
291
|
+
/**
|
|
292
|
+
* Find peaks in the onset strength envelope
|
|
293
|
+
*
|
|
294
|
+
* A peak is a local maximum that exceeds the threshold.
|
|
295
|
+
*
|
|
296
|
+
* @param envelope - The onset strength envelope
|
|
297
|
+
* @param threshold - Minimum peak height
|
|
298
|
+
* @returns Array of frame indices where peaks occur
|
|
299
|
+
*/
|
|
300
|
+
private findPeaks;
|
|
301
|
+
}
|
|
302
|
+
export {};
|
|
303
|
+
//# sourceMappingURL=TransientDetector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransientDetector.d.ts","sourceRoot":"","sources":["../../../../src/core/analysis/beat/TransientDetector.ts"],"names":[],"mappings":"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"}
|