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,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Beat Stream
|
|
3
|
+
*
|
|
4
|
+
* Real-time beat event streaming synchronized with audio playback.
|
|
5
|
+
* Provides precise beat timing with latency compensation and anticipation.
|
|
6
|
+
*
|
|
7
|
+
* Key features:
|
|
8
|
+
* - Sample-accurate timing via AudioContext synchronization
|
|
9
|
+
* - Configurable anticipation time for pre-rendering (default 2.0s)
|
|
10
|
+
* - Latency compensation (output + base + user offset)
|
|
11
|
+
* - Rolling BPM calculation from actual beat intervals
|
|
12
|
+
* - Button press accuracy detection for rhythm games
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const beatStream = new BeatStream(beatMap, audioContext, {
|
|
17
|
+
* anticipationTime: 2.0,
|
|
18
|
+
* userOffsetMs: 0,
|
|
19
|
+
* compensateOutputLatency: true,
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* const unsubscribe = beatStream.subscribe((event) => {
|
|
23
|
+
* if (event.type === 'upcoming') {
|
|
24
|
+
* // Pre-render beat visual
|
|
25
|
+
* } else if (event.type === 'exact') {
|
|
26
|
+
* // Beat is happening now
|
|
27
|
+
* }
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* beatStream.start();
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
import type { Beat, BeatMap, BeatStreamOptions, BeatStreamCallback, AudioSyncState, ButtonPressResult, InterpolatedBeatMap, SubdividedBeatMap } from '../../types/BeatMap.js';
|
|
34
|
+
import type { AccuracyThresholds } from '../../types/BeatMap.js';
|
|
35
|
+
/**
|
|
36
|
+
* Beat Stream - Real-time beat event streaming synchronized with audio playback
|
|
37
|
+
*
|
|
38
|
+
* Emits beat events ('upcoming', 'exact', 'passed') synchronized with audio
|
|
39
|
+
* playback using the Web Audio API for precise timing.
|
|
40
|
+
*
|
|
41
|
+
* Supports BeatMap, InterpolatedBeatMap, and SubdividedBeatMap:
|
|
42
|
+
* - When given a BeatMap, uses the beats array directly
|
|
43
|
+
* - When given an InterpolatedBeatMap with useInterpolatedBeats: true, uses mergedBeats
|
|
44
|
+
* - When given an InterpolatedBeatMap with useInterpolatedBeats: false, uses detectedBeats
|
|
45
|
+
* - When given a SubdividedBeatMap, uses the subdivided beats array directly
|
|
46
|
+
*/
|
|
47
|
+
export declare class BeatStream {
|
|
48
|
+
private beatMap;
|
|
49
|
+
private normalizedBeatMap;
|
|
50
|
+
private audioContext;
|
|
51
|
+
private options;
|
|
52
|
+
private state;
|
|
53
|
+
private subscribers;
|
|
54
|
+
private scheduledBeats;
|
|
55
|
+
private rollingBpmWindowSize;
|
|
56
|
+
/**
|
|
57
|
+
* Create a new BeatStream
|
|
58
|
+
*
|
|
59
|
+
* @param beatMap - The beat map containing beat data (BeatMap, InterpolatedBeatMap, or SubdividedBeatMap)
|
|
60
|
+
* @param audioContext - The Web Audio API AudioContext for timing
|
|
61
|
+
* @param options - Configuration options
|
|
62
|
+
* @param rollingBpmWindowSize - Number of beats for rolling BPM calculation (default: 8)
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* // With a regular BeatMap
|
|
67
|
+
* const beatStream = new BeatStream(beatMap, audioContext);
|
|
68
|
+
*
|
|
69
|
+
* // With an InterpolatedBeatMap using interpolated beats
|
|
70
|
+
* const interpolatedMap = interpolator.interpolate(beatMap);
|
|
71
|
+
* const beatStream = new BeatStream(interpolatedMap, audioContext, {
|
|
72
|
+
* useInterpolatedBeats: true
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* // With a SubdividedBeatMap (e.g., eighth notes)
|
|
76
|
+
* const unifiedMap = unifyBeatMap(interpolatedMap);
|
|
77
|
+
* const subdividedMap = subdivider.subdivide(unifiedMap, {
|
|
78
|
+
* beatSubdivisions: new Map(),
|
|
79
|
+
* defaultSubdivision: 'eighth',
|
|
80
|
+
* });
|
|
81
|
+
* const beatStream = new BeatStream(subdividedMap, audioContext);
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
constructor(beatMap: BeatMap | InterpolatedBeatMap | SubdividedBeatMap, audioContext: AudioContext, options?: BeatStreamOptions, rollingBpmWindowSize?: number);
|
|
85
|
+
/**
|
|
86
|
+
* Create a normalized BeatMap for internal use
|
|
87
|
+
*
|
|
88
|
+
* Handles BeatMap, InterpolatedBeatMap, and SubdividedBeatMap inputs,
|
|
89
|
+
* selecting the appropriate beat array based on the map type and options.
|
|
90
|
+
*/
|
|
91
|
+
private createNormalizedBeatMap;
|
|
92
|
+
/**
|
|
93
|
+
* Initialize scheduled beats array
|
|
94
|
+
*/
|
|
95
|
+
private initializeScheduledBeats;
|
|
96
|
+
/**
|
|
97
|
+
* Get the current configuration
|
|
98
|
+
*/
|
|
99
|
+
getOptions(): Required<BeatStreamOptions>;
|
|
100
|
+
/**
|
|
101
|
+
* Get the current accuracy thresholds being used
|
|
102
|
+
*
|
|
103
|
+
* Returns the resolved thresholds based on the difficulty preset
|
|
104
|
+
* and any custom threshold overrides.
|
|
105
|
+
*
|
|
106
|
+
* @returns The current accuracy thresholds
|
|
107
|
+
*/
|
|
108
|
+
getAccuracyThresholds(): AccuracyThresholds;
|
|
109
|
+
/**
|
|
110
|
+
* Change difficulty settings mid-stream
|
|
111
|
+
*
|
|
112
|
+
* Allows changing the difficulty preset and/or custom thresholds without
|
|
113
|
+
* recreating the BeatStream. Useful for:
|
|
114
|
+
* - Adaptive difficulty (adjust based on player performance)
|
|
115
|
+
* - Practice mode (try different difficulties without restarting)
|
|
116
|
+
* - Accessibility (let players adjust on the fly)
|
|
117
|
+
*
|
|
118
|
+
* @param options - Difficulty options
|
|
119
|
+
* @param options.preset - New difficulty preset ('easy', 'medium', 'hard')
|
|
120
|
+
* @param options.customThresholds - Custom threshold overrides (merged with preset)
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* // Switch to easy mode
|
|
125
|
+
* beatStream.setDifficulty({ preset: 'easy' });
|
|
126
|
+
*
|
|
127
|
+
* // Use custom thresholds
|
|
128
|
+
* beatStream.setDifficulty({
|
|
129
|
+
* preset: 'medium',
|
|
130
|
+
* customThresholds: { perfect: 0.060 } // Looser perfect window
|
|
131
|
+
* });
|
|
132
|
+
*
|
|
133
|
+
* // Clear custom thresholds and use preset only
|
|
134
|
+
* beatStream.setDifficulty({ preset: 'hard', customThresholds: {} });
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
setDifficulty(options: {
|
|
138
|
+
preset?: import('../../types/BeatMap.js').DifficultyPreset;
|
|
139
|
+
customThresholds?: Partial<AccuracyThresholds>;
|
|
140
|
+
}): void;
|
|
141
|
+
/**
|
|
142
|
+
* Subscribe to beat events
|
|
143
|
+
*
|
|
144
|
+
* @param callback - Function to call when beat events occur
|
|
145
|
+
* @returns Unsubscribe function
|
|
146
|
+
*/
|
|
147
|
+
subscribe(callback: BeatStreamCallback): () => void;
|
|
148
|
+
/**
|
|
149
|
+
* Start streaming beat events
|
|
150
|
+
*
|
|
151
|
+
* Begins emitting events synchronized with audio playback.
|
|
152
|
+
* Should be called when audio starts playing.
|
|
153
|
+
*/
|
|
154
|
+
start(): void;
|
|
155
|
+
/**
|
|
156
|
+
* Stop streaming beat events
|
|
157
|
+
*
|
|
158
|
+
* Stops all event emission and resets state.
|
|
159
|
+
*/
|
|
160
|
+
stop(): void;
|
|
161
|
+
/**
|
|
162
|
+
* Pause the beat stream
|
|
163
|
+
*
|
|
164
|
+
* Temporarily stops event emission but preserves position.
|
|
165
|
+
*/
|
|
166
|
+
pause(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Resume a paused beat stream
|
|
169
|
+
*/
|
|
170
|
+
resume(): void;
|
|
171
|
+
/**
|
|
172
|
+
* Seek to a specific time position
|
|
173
|
+
*
|
|
174
|
+
* @param time - Time in seconds to seek to
|
|
175
|
+
*/
|
|
176
|
+
seek(time: number): void;
|
|
177
|
+
/**
|
|
178
|
+
* Get the current audio time with latency compensation
|
|
179
|
+
*
|
|
180
|
+
* @returns Current audio time in seconds
|
|
181
|
+
*/
|
|
182
|
+
private getCurrentAudioTime;
|
|
183
|
+
/**
|
|
184
|
+
* Get total latency compensation in seconds
|
|
185
|
+
*
|
|
186
|
+
* Combines output latency, base latency, and user offset
|
|
187
|
+
*/
|
|
188
|
+
private getTotalLatencyCompensation;
|
|
189
|
+
/**
|
|
190
|
+
* Get the current synchronization state for debugging
|
|
191
|
+
*
|
|
192
|
+
* @returns Current audio sync state
|
|
193
|
+
*/
|
|
194
|
+
getSyncState(): AudioSyncState;
|
|
195
|
+
/**
|
|
196
|
+
* Schedule the next update frame
|
|
197
|
+
*/
|
|
198
|
+
private scheduleUpdate;
|
|
199
|
+
/**
|
|
200
|
+
* Main update loop - checks for beat events to emit
|
|
201
|
+
*/
|
|
202
|
+
private update;
|
|
203
|
+
/**
|
|
204
|
+
* Emit a beat event to all subscribers
|
|
205
|
+
*/
|
|
206
|
+
private emitEvent;
|
|
207
|
+
/**
|
|
208
|
+
* Get upcoming beats for pre-rendering
|
|
209
|
+
*
|
|
210
|
+
* Returns beats that will occur within the anticipation window.
|
|
211
|
+
*
|
|
212
|
+
* @param count - Maximum number of beats to return
|
|
213
|
+
* @returns Array of upcoming beats
|
|
214
|
+
*/
|
|
215
|
+
getUpcomingBeats(count: number): Beat[];
|
|
216
|
+
/**
|
|
217
|
+
* Get the beat at a specific time
|
|
218
|
+
*
|
|
219
|
+
* Returns the beat closest to the given time within the timing tolerance.
|
|
220
|
+
*
|
|
221
|
+
* @param time - Time in seconds
|
|
222
|
+
* @returns Beat at the time, or null if no beat is near
|
|
223
|
+
*/
|
|
224
|
+
getBeatAtTime(time: number): Beat | null;
|
|
225
|
+
/**
|
|
226
|
+
* Get the current beat (the beat that is currently playing or most recently passed)
|
|
227
|
+
*
|
|
228
|
+
* @returns Current beat, or null if before first beat
|
|
229
|
+
*/
|
|
230
|
+
getCurrentBeat(): Beat | null;
|
|
231
|
+
/**
|
|
232
|
+
* Get the next beat (the beat that will occur next)
|
|
233
|
+
*
|
|
234
|
+
* @returns Next beat, or null if after last beat
|
|
235
|
+
*/
|
|
236
|
+
getNextBeat(): Beat | null;
|
|
237
|
+
/**
|
|
238
|
+
* Get the current BPM calculated from recent beat intervals
|
|
239
|
+
*
|
|
240
|
+
* Uses a rolling window of beat intervals to calculate the
|
|
241
|
+
* current tempo, which handles gradual tempo drift.
|
|
242
|
+
*
|
|
243
|
+
* @returns Current BPM, or the beat map's initial BPM if not enough beats
|
|
244
|
+
*/
|
|
245
|
+
getCurrentBpm(): number;
|
|
246
|
+
/**
|
|
247
|
+
* Resolve the effective accuracy thresholds based on options
|
|
248
|
+
*
|
|
249
|
+
* If custom thresholds are provided, they are merged with the base preset.
|
|
250
|
+
* Otherwise, the preset thresholds are used directly.
|
|
251
|
+
*
|
|
252
|
+
* @returns The effective accuracy thresholds
|
|
253
|
+
*/
|
|
254
|
+
private resolveThresholds;
|
|
255
|
+
/**
|
|
256
|
+
* Check the accuracy of a button press
|
|
257
|
+
*
|
|
258
|
+
* Determines how close the button press was to the nearest beat.
|
|
259
|
+
* If the beat has a requiredKey, validates that the pressedKey matches.
|
|
260
|
+
*
|
|
261
|
+
* @param timestamp - The time of the button press (use audioContext.currentTime)
|
|
262
|
+
* @param pressedKey - Optional key that was pressed (for key-matching beats)
|
|
263
|
+
* @returns Button press result with accuracy level and key match info
|
|
264
|
+
*/
|
|
265
|
+
checkButtonPress(timestamp: number, pressedKey?: string): ButtonPressResult;
|
|
266
|
+
/**
|
|
267
|
+
* Get the accuracy of the last button press
|
|
268
|
+
*
|
|
269
|
+
* @returns Last button press result, or null if no button has been pressed
|
|
270
|
+
*/
|
|
271
|
+
getLastBeatAccuracy(): ButtonPressResult | null;
|
|
272
|
+
/**
|
|
273
|
+
* Check if the stream is currently running
|
|
274
|
+
*/
|
|
275
|
+
isRunning(): boolean;
|
|
276
|
+
/**
|
|
277
|
+
* Check if the stream is paused
|
|
278
|
+
*/
|
|
279
|
+
isPaused(): boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Get the current playback position
|
|
282
|
+
*
|
|
283
|
+
* @returns Current time in seconds
|
|
284
|
+
*/
|
|
285
|
+
getCurrentTime(): number;
|
|
286
|
+
/**
|
|
287
|
+
* Get the beat map duration
|
|
288
|
+
*/
|
|
289
|
+
getDuration(): number;
|
|
290
|
+
/**
|
|
291
|
+
* Get the original beat map (may be BeatMap, InterpolatedBeatMap, or SubdividedBeatMap)
|
|
292
|
+
*
|
|
293
|
+
* @returns The original beat map passed to the constructor
|
|
294
|
+
*/
|
|
295
|
+
getBeatMap(): BeatMap | InterpolatedBeatMap | SubdividedBeatMap;
|
|
296
|
+
/**
|
|
297
|
+
* Get the normalized beat map used internally
|
|
298
|
+
*
|
|
299
|
+
* This is always a BeatMap, regardless of whether the original was
|
|
300
|
+
* a BeatMap or InterpolatedBeatMap.
|
|
301
|
+
*
|
|
302
|
+
* @returns The normalized beat map
|
|
303
|
+
*/
|
|
304
|
+
getNormalizedBeatMap(): BeatMap;
|
|
305
|
+
/**
|
|
306
|
+
* Update the beat map (e.g., after manual editing)
|
|
307
|
+
*
|
|
308
|
+
* @param beatMap - New beat map to use (BeatMap, InterpolatedBeatMap, or SubdividedBeatMap)
|
|
309
|
+
*/
|
|
310
|
+
setBeatMap(beatMap: BeatMap | InterpolatedBeatMap | SubdividedBeatMap): void;
|
|
311
|
+
/**
|
|
312
|
+
* Clean up resources
|
|
313
|
+
*/
|
|
314
|
+
dispose(): void;
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=BeatStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BeatStream.d.ts","sourceRoot":"","sources":["../../../../src/core/analysis/beat/BeatStream.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Beat Subdivider
|
|
3
|
+
*
|
|
4
|
+
* Transforms a UnifiedBeatMap into a SubdividedBeatMap by applying rhythmic
|
|
5
|
+
* subdivision patterns. Supports half notes, eighth notes, sixteenth notes,
|
|
6
|
+
* triplets, dotted patterns, and rests.
|
|
7
|
+
*
|
|
8
|
+
* Each beat can have its own subdivision type, enabling fine-grained control
|
|
9
|
+
* for creating complex rhythmic phrases.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const subdivider = new BeatSubdivider();
|
|
14
|
+
*
|
|
15
|
+
* // Subdivide with default config (quarter notes)
|
|
16
|
+
* const subdividedMap = subdivider.subdivide(unifiedMap);
|
|
17
|
+
*
|
|
18
|
+
* // Subdivide with custom per-beat config
|
|
19
|
+
* const customConfig: SubdivisionConfig = {
|
|
20
|
+
* beatSubdivisions: new Map([
|
|
21
|
+
* [0, 'quarter'],
|
|
22
|
+
* [1, 'eighth'],
|
|
23
|
+
* [2, 'eighth'],
|
|
24
|
+
* [3, 'rest'], // No beat on beat 3
|
|
25
|
+
* ]),
|
|
26
|
+
* defaultSubdivision: 'quarter',
|
|
27
|
+
* };
|
|
28
|
+
* const customMap = subdivider.subdivide(unifiedMap, customConfig);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
import type { UnifiedBeatMap, SubdividedBeatMap, SubdivisionConfig } from '../../types/BeatMap.js';
|
|
32
|
+
/**
|
|
33
|
+
* Options for the BeatSubdivider
|
|
34
|
+
*/
|
|
35
|
+
export interface BeatSubdividerOptions {
|
|
36
|
+
/**
|
|
37
|
+
* Tolerance in seconds for aligning beats to detected beats
|
|
38
|
+
* When generating new beats, if a beat falls within this tolerance
|
|
39
|
+
* of a detected beat, it will be marked as detected.
|
|
40
|
+
* @default 0.02 (20ms)
|
|
41
|
+
*/
|
|
42
|
+
tolerance?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Default intensity for newly generated beats (0.0 - 1.0)
|
|
45
|
+
* Used when intensity cannot be interpolated from neighbors.
|
|
46
|
+
* @default 0.5
|
|
47
|
+
*/
|
|
48
|
+
defaultIntensity?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Default confidence for newly generated beats (0.0 - 1.0)
|
|
51
|
+
* Used when confidence cannot be interpolated from neighbors.
|
|
52
|
+
* @default 0.7
|
|
53
|
+
*/
|
|
54
|
+
defaultConfidence?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Beat Subdivider
|
|
58
|
+
*
|
|
59
|
+
* Transforms quarter-note beat grids into various rhythmic subdivisions.
|
|
60
|
+
* Each beat can have its own subdivision type for fine-grained rhythm control.
|
|
61
|
+
*/
|
|
62
|
+
export declare class BeatSubdivider {
|
|
63
|
+
private options;
|
|
64
|
+
/**
|
|
65
|
+
* Create a new BeatSubdivider
|
|
66
|
+
*
|
|
67
|
+
* @param options - Optional configuration options
|
|
68
|
+
*/
|
|
69
|
+
constructor(options?: BeatSubdividerOptions);
|
|
70
|
+
/**
|
|
71
|
+
* Subdivide a unified beat map according to the given configuration
|
|
72
|
+
*
|
|
73
|
+
* Each beat can have its own subdivision type, enabling fine-grained
|
|
74
|
+
* control for creating complex rhythmic phrases.
|
|
75
|
+
*
|
|
76
|
+
* @param unifiedMap - The unified beat map to subdivide
|
|
77
|
+
* @param config - Optional subdivision configuration (defaults to quarter notes)
|
|
78
|
+
* @returns The subdivided beat map
|
|
79
|
+
* @throws Error if configuration is invalid
|
|
80
|
+
*/
|
|
81
|
+
subdivide(unifiedMap: UnifiedBeatMap, config?: SubdivisionConfig): SubdividedBeatMap;
|
|
82
|
+
/**
|
|
83
|
+
* Create interpolated beats for a specific subdivision type
|
|
84
|
+
*
|
|
85
|
+
* @param beat - The current beat
|
|
86
|
+
* @param nextBeat - The next beat
|
|
87
|
+
* @param beatIndex - The global index of the current beat
|
|
88
|
+
* @param subdivision - The subdivision type to apply
|
|
89
|
+
* @param unifiedMap - The unified beat map
|
|
90
|
+
* @param hasMultipleTempos - Whether there are multiple tempo sections
|
|
91
|
+
* @param config - The subdivision configuration (for checking adjacent beat subdivisions)
|
|
92
|
+
* @param triplet4ChainPosition - Position in triplet4 chain (0 = first, 1 = second)
|
|
93
|
+
* @returns Array of interpolated beats (empty for quarter/half subdivisions)
|
|
94
|
+
*/
|
|
95
|
+
private createInterpolatedBeatsForSubdivision;
|
|
96
|
+
/**
|
|
97
|
+
* Create an empty subdivided beat map
|
|
98
|
+
*/
|
|
99
|
+
private createEmptySubdividedBeatMap;
|
|
100
|
+
/**
|
|
101
|
+
* Create an interpolated beat between two beats
|
|
102
|
+
*/
|
|
103
|
+
private createInterpolatedBeat;
|
|
104
|
+
/**
|
|
105
|
+
* Find the closest beat to a given timestamp
|
|
106
|
+
*/
|
|
107
|
+
private findClosestBeat;
|
|
108
|
+
/**
|
|
109
|
+
* Calculate beatInMeasure for a timestamp
|
|
110
|
+
*/
|
|
111
|
+
private calculateBeatInMeasure;
|
|
112
|
+
/**
|
|
113
|
+
* Calculate measure number for a timestamp
|
|
114
|
+
*/
|
|
115
|
+
private calculateMeasureNumber;
|
|
116
|
+
/**
|
|
117
|
+
* Build the detected beat indices array for the result
|
|
118
|
+
*/
|
|
119
|
+
private buildDetectedBeatIndices;
|
|
120
|
+
/**
|
|
121
|
+
* Get the tempo section for a given timestamp
|
|
122
|
+
*
|
|
123
|
+
* @param tempoSections - Array of tempo sections (or undefined)
|
|
124
|
+
* @param timestamp - The timestamp to look up
|
|
125
|
+
* @returns The matching tempo section, or undefined if none
|
|
126
|
+
*/
|
|
127
|
+
private getTempoSectionForTimestamp;
|
|
128
|
+
/**
|
|
129
|
+
* Get the quarter note interval for a given timestamp
|
|
130
|
+
*
|
|
131
|
+
* Returns the interval from the tempo section if available,
|
|
132
|
+
* otherwise falls back to the primary quarterNoteInterval.
|
|
133
|
+
*
|
|
134
|
+
* @param unifiedMap - The unified beat map
|
|
135
|
+
* @param timestamp - The timestamp to get the interval for
|
|
136
|
+
* @returns The quarter note interval in seconds
|
|
137
|
+
*/
|
|
138
|
+
private getQuarterNoteIntervalForTimestamp;
|
|
139
|
+
/**
|
|
140
|
+
* Get the tempo section for a given beat index
|
|
141
|
+
*
|
|
142
|
+
* @param tempoSections - Array of tempo sections (or undefined)
|
|
143
|
+
* @param beatIndex - The beat index to look up
|
|
144
|
+
* @returns The matching tempo section, or undefined if none
|
|
145
|
+
*/
|
|
146
|
+
private getTempoSectionForBeatIndex;
|
|
147
|
+
/**
|
|
148
|
+
* Convert a SubdividedBeatMap to a JSON string
|
|
149
|
+
*
|
|
150
|
+
* @param subdividedBeatMap - Subdivided beat map to serialize
|
|
151
|
+
* @returns JSON string
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const subdividedMap = subdivider.subdivide(unifiedMap, config);
|
|
156
|
+
*
|
|
157
|
+
* // Serialize to JSON for storage
|
|
158
|
+
* const json = BeatSubdivider.toJSON(subdividedMap);
|
|
159
|
+
* localStorage.setItem('subdividedMap', json);
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
static toJSON(subdividedBeatMap: SubdividedBeatMap): string;
|
|
163
|
+
/**
|
|
164
|
+
* Parse a SubdividedBeatMap from a JSON string
|
|
165
|
+
*
|
|
166
|
+
* @param jsonString - JSON string to parse
|
|
167
|
+
* @returns Subdivided beat map
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* // Load from storage
|
|
172
|
+
* const json = localStorage.getItem('subdividedMap');
|
|
173
|
+
* const subdividedMap = BeatSubdivider.fromJSON(json);
|
|
174
|
+
*
|
|
175
|
+
* // Use the loaded beat map
|
|
176
|
+
* console.log(subdividedMap.beats.length);
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
static fromJSON(jsonString: string): SubdividedBeatMap;
|
|
180
|
+
/**
|
|
181
|
+
* Save a SubdividedBeatMap to a file (Node.js only)
|
|
182
|
+
*
|
|
183
|
+
* @param subdividedBeatMap - Subdivided beat map to save
|
|
184
|
+
* @param filePath - Path to save the file
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* await BeatSubdivider.saveToFile(subdividedMap, 'chart.json');
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
static saveToFile(subdividedBeatMap: SubdividedBeatMap, filePath: string): Promise<void>;
|
|
192
|
+
/**
|
|
193
|
+
* Load a SubdividedBeatMap from a file (Node.js only)
|
|
194
|
+
*
|
|
195
|
+
* @param filePath - Path to load the file from
|
|
196
|
+
* @returns Subdivided beat map
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* const subdividedMap = await BeatSubdivider.loadFromFile('chart.json');
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
static loadFromFile(filePath: string): Promise<SubdividedBeatMap>;
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=BeatSubdivider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BeatSubdivider.d.ts","sourceRoot":"","sources":["../../../../src/core/analysis/beat/BeatSubdivider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAER,cAAc,EAEd,iBAAiB,EACjB,iBAAiB,EAMpB,MAAM,wBAAwB,CAAC;AAWhC;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAkCD;;;;;GAKG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,OAAO,CAAkC;IAEjD;;;;OAIG;gBACS,OAAO,CAAC,EAAE,qBAAqB;IAS3C;;;;;;;;;;OAUG;IACH,SAAS,CACL,UAAU,EAAE,cAAc,EAC1B,MAAM,GAAE,iBAA8C,GACvD,iBAAiB;IAkKpB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,qCAAqC;IAmL7C;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAwBpC;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA+B9B;;OAEG;IACH,OAAO,CAAC,eAAe;IAevB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAW9B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAa9B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAgBhC;;;;;;OAMG;IACH,OAAO,CAAC,2BAA2B;IAoBnC;;;;;;;;;OASG;IACH,OAAO,CAAC,kCAAkC;IAgB1C;;;;;;OAMG;IACH,OAAO,CAAC,2BAA2B;IAwBnC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,MAAM;IAkD3D;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB;IAkDtD;;;;;;;;;;OAUG;WACU,UAAU,CACnB,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC;IAYhB;;;;;;;;;;OAUG;WACU,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAW1E"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Beat Tracker using Dynamic Programming
|
|
3
|
+
*
|
|
4
|
+
* Implements the Ellis 2007 beat tracking algorithm using dynamic programming
|
|
5
|
+
* to find the globally optimal beat sequence.
|
|
6
|
+
*
|
|
7
|
+
* Reference: "Beat Tracking by Dynamic Programming" (Ellis, 2007)
|
|
8
|
+
* https://www.ee.columbia.edu/~dpwe/pubs/Ellis07-beattrack.pdf
|
|
9
|
+
*
|
|
10
|
+
* The algorithm finds beat times {t₁, t₂, ..., tₙ} that maximize:
|
|
11
|
+
* C({ti}) = Σ O(ti) + α Σ F(ti - ti-1, τp)
|
|
12
|
+
*
|
|
13
|
+
* Where:
|
|
14
|
+
* O(t) = Onset Strength Envelope (high at moments that make good beats)
|
|
15
|
+
* F(Δt, τ) = Transition cost function (penalizes tempo deviation)
|
|
16
|
+
* α = Balance factor (paper found optimal: 680)
|
|
17
|
+
* τp = Target inter-beat interval (from tempo estimation)
|
|
18
|
+
*/
|
|
19
|
+
import type { Beat, BeatTrackerConfig, TempoEstimate } from '../../types/BeatMap.js';
|
|
20
|
+
/**
|
|
21
|
+
* Internal result of beat tracking
|
|
22
|
+
*/
|
|
23
|
+
export interface BeatTrackingResult {
|
|
24
|
+
/** Detected beats */
|
|
25
|
+
beats: Beat[];
|
|
26
|
+
/** Frame indices of beats */
|
|
27
|
+
beatFrames: number[];
|
|
28
|
+
/** Cumulative scores (for debugging) */
|
|
29
|
+
cumulativeScores: Float32Array;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Beat Tracker using Ellis Dynamic Programming Algorithm
|
|
33
|
+
*
|
|
34
|
+
* Finds the globally optimal beat sequence by:
|
|
35
|
+
* 1. Precomputing transition costs for different inter-beat intervals
|
|
36
|
+
* 2. Forward pass: calculating best cumulative scores with backlinks
|
|
37
|
+
* 3. Backward pass: extracting the optimal beat sequence
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const tracker = new BeatTracker({
|
|
42
|
+
* dpAlpha: 680,
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* const result = tracker.trackBeats(onsetEnvelope, tempoEstimate, hopSizeSeconds);
|
|
46
|
+
* // result.beats contains detected Beat objects
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare class BeatTracker {
|
|
50
|
+
private config;
|
|
51
|
+
/**
|
|
52
|
+
* Create a new Beat Tracker
|
|
53
|
+
*
|
|
54
|
+
* @param config - Configuration options (all optional, defaults provided)
|
|
55
|
+
*/
|
|
56
|
+
constructor(config?: BeatTrackerConfig);
|
|
57
|
+
/**
|
|
58
|
+
* Get the current configuration
|
|
59
|
+
*
|
|
60
|
+
* @returns The current configuration
|
|
61
|
+
*/
|
|
62
|
+
getConfig(): Required<BeatTrackerConfig>;
|
|
63
|
+
/**
|
|
64
|
+
* Track beats in an onset strength envelope
|
|
65
|
+
*
|
|
66
|
+
* Implements the Ellis DP algorithm:
|
|
67
|
+
* 1. Precompute transition costs for all possible intervals
|
|
68
|
+
* 2. Forward pass: find best predecessor for each frame
|
|
69
|
+
* 3. Backward pass: extract optimal beat sequence
|
|
70
|
+
* 4. Convert frame indices to Beat objects
|
|
71
|
+
*
|
|
72
|
+
* @param onsetEnvelope - Onset strength envelope from OSE calculation
|
|
73
|
+
* @param tempoEstimate - Tempo estimate from TempoDetector
|
|
74
|
+
* @param hopSizeSeconds - Hop size in seconds (time between envelope frames)
|
|
75
|
+
* @returns Beat tracking result with detected beats
|
|
76
|
+
*/
|
|
77
|
+
trackBeats(onsetEnvelope: Float32Array, tempoEstimate: TempoEstimate, hopSizeSeconds: number): BeatTrackingResult;
|
|
78
|
+
/**
|
|
79
|
+
* Convert beat frame indices to Beat objects
|
|
80
|
+
*
|
|
81
|
+
* @param beatFrames - Array of frame indices where beats occur
|
|
82
|
+
* @param onsetEnvelope - Original onset strength envelope
|
|
83
|
+
* @param cumscore - Cumulative scores from DP
|
|
84
|
+
* @param hopSizeSeconds - Hop size in seconds
|
|
85
|
+
* @param period - Target period in frames
|
|
86
|
+
* @returns Array of Beat objects
|
|
87
|
+
*/
|
|
88
|
+
private convertToBeats;
|
|
89
|
+
/**
|
|
90
|
+
* Track beats with additional options for fine-tuning
|
|
91
|
+
*
|
|
92
|
+
* This method provides more control over the tracking process,
|
|
93
|
+
* useful for debugging or special cases.
|
|
94
|
+
*
|
|
95
|
+
* @param onsetEnvelope - Onset strength envelope
|
|
96
|
+
* @param tempoEstimate - Tempo estimate
|
|
97
|
+
* @param hopSizeSeconds - Hop size in seconds
|
|
98
|
+
* @param options - Additional options
|
|
99
|
+
* @returns Beat tracking result
|
|
100
|
+
*/
|
|
101
|
+
trackBeatsWithOptions(onsetEnvelope: Float32Array, tempoEstimate: TempoEstimate, hopSizeSeconds: number, options?: {
|
|
102
|
+
/** Minimum score threshold for beat acceptance */
|
|
103
|
+
minScoreThreshold?: number;
|
|
104
|
+
/** Apply discounted score trimming for start/end beats */
|
|
105
|
+
applyTrimming?: boolean;
|
|
106
|
+
}): BeatTrackingResult;
|
|
107
|
+
/**
|
|
108
|
+
* Apply discounted score trimming to find valid beat boundaries
|
|
109
|
+
*
|
|
110
|
+
* Ellis notes that the cumulative score grows steadily, but we can
|
|
111
|
+
* find the first and last valid beats by looking at the difference
|
|
112
|
+
* from a straight line connecting origin to final value.
|
|
113
|
+
*
|
|
114
|
+
* C*(t) - (t/length) * C*(length-1)
|
|
115
|
+
*
|
|
116
|
+
* @param result - Beat tracking result to modify in place
|
|
117
|
+
* @param length - Total number of frames
|
|
118
|
+
* @param period - Target period in frames
|
|
119
|
+
*/
|
|
120
|
+
private applyDiscountedScoreTrimming;
|
|
121
|
+
/**
|
|
122
|
+
* Get beat tracking statistics for debugging
|
|
123
|
+
*
|
|
124
|
+
* @param result - Beat tracking result
|
|
125
|
+
* @param hopSizeSeconds - Hop size in seconds
|
|
126
|
+
* @returns Statistics about the detected beats
|
|
127
|
+
*/
|
|
128
|
+
getTrackingStats(result: BeatTrackingResult, hopSizeSeconds: number): {
|
|
129
|
+
numBeats: number;
|
|
130
|
+
avgInterval: number;
|
|
131
|
+
stdInterval: number;
|
|
132
|
+
avgIntensity: number;
|
|
133
|
+
avgConfidence: number;
|
|
134
|
+
estimatedBpm: number;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=BeatTracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BeatTracker.d.ts","sourceRoot":"","sources":["../../../../src/core/analysis/beat/BeatTracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAerF;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,qBAAqB;IACrB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,6BAA6B;IAC7B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,wCAAwC;IACxC,gBAAgB,EAAE,YAAY,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAA8B;IAE5C;;;;OAIG;gBACS,MAAM,GAAE,iBAAsB;IAI1C;;;;OAIG;IACH,SAAS,IAAI,QAAQ,CAAC,iBAAiB,CAAC;IAIxC;;;;;;;;;;;;;OAaG;IACH,UAAU,CACN,aAAa,EAAE,YAAY,EAC3B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,MAAM,GACvB,kBAAkB;IAoJrB;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAiEtB;;;;;;;;;;;OAWG;IACH,qBAAqB,CACjB,aAAa,EAAE,YAAY,EAC3B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,MAAM,EACtB,OAAO,GAAE;QACL,kDAAkD;QAClD,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,0DAA0D;QAC1D,aAAa,CAAC,EAAE,OAAO,CAAC;KACtB,GACP,kBAAkB;IA6BrB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,4BAA4B;IAyDpC;;;;;;OAMG;IACH,gBAAgB,CACZ,MAAM,EAAE,kBAAkB,EAC1B,cAAc,EAAE,MAAM,GACvB;QACC,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;KACxB;CAgDJ"}
|