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,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Melody Contour Analyzer
|
|
3
|
+
*
|
|
4
|
+
* Analyzes pitch data to extract melodic contour information for button mapping.
|
|
5
|
+
* This is Phase 1.5 of the Pitch Detection & Button Mapping pipeline.
|
|
6
|
+
*
|
|
7
|
+
* ## What it does
|
|
8
|
+
*
|
|
9
|
+
* 1. **Pitch-to-Pitch Comparison**: Iterates through consecutive beats and compares
|
|
10
|
+
* their pitches to determine direction (up/down/stable/none) and interval distance.
|
|
11
|
+
*
|
|
12
|
+
* 2. **Interval Categorization**: Groups intervals into categories useful for button mapping:
|
|
13
|
+
* - unison: 0 semitones (same note)
|
|
14
|
+
* - small: 1-2 semitones (minor/major 2nd)
|
|
15
|
+
* - medium: 3-4 semitones (minor/major 3rd)
|
|
16
|
+
* - large: 5-7 semitones (4th, tritone, 5th)
|
|
17
|
+
* - very_large: 8+ semitones (6th, 7th, octave+)
|
|
18
|
+
*
|
|
19
|
+
* 3. **Melody Segment Detection**: Groups consecutive beats with the same direction
|
|
20
|
+
* into melody segments (e.g., ascending phrase, descending phrase).
|
|
21
|
+
*
|
|
22
|
+
* 4. **Contour Aggregation**: Calculates overall melody direction and range.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // After running PitchBeatLinker on the composite stream
|
|
27
|
+
* const linker = new PitchBeatLinker();
|
|
28
|
+
* const compositePitches = await linker.linkWithComposite(composite, audioBuffer);
|
|
29
|
+
*
|
|
30
|
+
* // Analyze melody contour
|
|
31
|
+
* const contourAnalyzer = new MelodyContourAnalyzer();
|
|
32
|
+
* const contourResult = contourAnalyzer.analyze(compositePitches);
|
|
33
|
+
*
|
|
34
|
+
* // Access direction and interval for each beat
|
|
35
|
+
* for (const pitchAtBeat of contourResult.pitchByBeat) {
|
|
36
|
+
* console.log(`Beat ${pitchAtBeat.beatIndex}: direction=${pitchAtBeat.direction}, interval=${pitchAtBeat.intervalFromPrevious}`);
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* // Access overall contour
|
|
40
|
+
* console.log('Overall direction:', contourResult.melodyContour.direction);
|
|
41
|
+
* console.log('Range:', contourResult.melodyContour.range);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
import type { PitchAtBeat } from '../generation/PitchBeatLinker.js';
|
|
45
|
+
/**
|
|
46
|
+
* Direction of a melody segment
|
|
47
|
+
*/
|
|
48
|
+
export type MelodySegmentDirection = 'up' | 'down' | 'stable';
|
|
49
|
+
/**
|
|
50
|
+
* Overall direction of a melody contour
|
|
51
|
+
*/
|
|
52
|
+
export type MelodyContourDirection = 'ascending' | 'descending' | 'stable' | 'mixed';
|
|
53
|
+
/**
|
|
54
|
+
* A segment of a melody with consistent direction
|
|
55
|
+
*
|
|
56
|
+
* Part of Phase 1.5 (Melody Contour Analysis)
|
|
57
|
+
*/
|
|
58
|
+
export interface MelodySegment {
|
|
59
|
+
/** Start time in seconds */
|
|
60
|
+
startTime: number;
|
|
61
|
+
/** End time in seconds */
|
|
62
|
+
endTime: number;
|
|
63
|
+
/** Starting pitch (note name, e.g., "C4") */
|
|
64
|
+
startPitch: string;
|
|
65
|
+
/** Ending pitch (note name, e.g., "F#5") */
|
|
66
|
+
endPitch: string;
|
|
67
|
+
/** Direction of this segment */
|
|
68
|
+
direction: MelodySegmentDirection;
|
|
69
|
+
/** Interval in semitones between start and end */
|
|
70
|
+
interval: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Melody contour representing the overall melodic shape
|
|
74
|
+
*
|
|
75
|
+
* Populated by melody contour analysis (Phase 1.5).
|
|
76
|
+
* Used by button mapping (Phase 2) to generate patterns that follow the melody.
|
|
77
|
+
*/
|
|
78
|
+
export interface MelodyContour {
|
|
79
|
+
/** Melody segments grouped by direction */
|
|
80
|
+
segments: MelodySegment[];
|
|
81
|
+
/** Overall direction of the melody */
|
|
82
|
+
direction: MelodyContourDirection;
|
|
83
|
+
/** Pitch range of the melody */
|
|
84
|
+
range: {
|
|
85
|
+
/** Lowest note (e.g., "C4") */
|
|
86
|
+
minNote: string;
|
|
87
|
+
/** Highest note (e.g., "F#5") */
|
|
88
|
+
maxNote: string;
|
|
89
|
+
/** Total span in semitones */
|
|
90
|
+
semitones: number;
|
|
91
|
+
};
|
|
92
|
+
/** Time-window direction analysis (Phase 1.5.3) */
|
|
93
|
+
/** Direction over the last 1-2 beats */
|
|
94
|
+
shortTermDirection: MelodyContourDirection;
|
|
95
|
+
/** Direction over the last 4-8 beats */
|
|
96
|
+
mediumTermDirection: MelodyContourDirection;
|
|
97
|
+
/** Direction over the last 16+ beats */
|
|
98
|
+
longTermDirection: MelodyContourDirection;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Interval category for button mapping
|
|
102
|
+
*
|
|
103
|
+
* Used to determine button jump distances based on musical intervals.
|
|
104
|
+
*/
|
|
105
|
+
export type IntervalCategory = 'unison' | 'small' | 'medium' | 'large' | 'very_large';
|
|
106
|
+
/**
|
|
107
|
+
* Direction of pitch change from previous beat
|
|
108
|
+
*/
|
|
109
|
+
export type PitchDirection = 'up' | 'down' | 'stable' | 'none';
|
|
110
|
+
/**
|
|
111
|
+
* Direction statistics for melody contour metadata
|
|
112
|
+
*/
|
|
113
|
+
export interface DirectionStats {
|
|
114
|
+
/** Count of ascending pitches */
|
|
115
|
+
up: number;
|
|
116
|
+
/** Count of descending pitches */
|
|
117
|
+
down: number;
|
|
118
|
+
/** Count of repeated pitches */
|
|
119
|
+
stable: number;
|
|
120
|
+
/** Count with no pitch detected or no previous pitch */
|
|
121
|
+
none: number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Interval statistics for melody contour metadata
|
|
125
|
+
*/
|
|
126
|
+
export interface IntervalStats {
|
|
127
|
+
/** 0 semitones */
|
|
128
|
+
unison: number;
|
|
129
|
+
/** 1-2 semitones (minor/major 2nd) */
|
|
130
|
+
small: number;
|
|
131
|
+
/** 3-4 semitones (minor/major 3rd) */
|
|
132
|
+
medium: number;
|
|
133
|
+
/** 5-7 semitones (4th, tritone, 5th) */
|
|
134
|
+
large: number;
|
|
135
|
+
/** 8+ semitones (6th, 7th, octave+) */
|
|
136
|
+
very_large: number;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Result of melody contour analysis
|
|
140
|
+
*/
|
|
141
|
+
export interface MelodyContourAnalysisResult {
|
|
142
|
+
/** Updated pitch-by-beat with direction and interval populated */
|
|
143
|
+
pitchByBeat: PitchAtBeat[];
|
|
144
|
+
/** Melody contour from composite pitches */
|
|
145
|
+
melodyContour: MelodyContour;
|
|
146
|
+
/** Direction statistics */
|
|
147
|
+
directionStats: DirectionStats;
|
|
148
|
+
/** Interval statistics */
|
|
149
|
+
intervalStats: IntervalStats;
|
|
150
|
+
/** Analysis metadata */
|
|
151
|
+
metadata: {
|
|
152
|
+
/** Total beats analyzed */
|
|
153
|
+
totalBeats: number;
|
|
154
|
+
/** Beats with voiced pitch */
|
|
155
|
+
voicedBeats: number;
|
|
156
|
+
/** Beats with direction calculated */
|
|
157
|
+
directionCalculatedBeats: number;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Configuration for MelodyContourAnalyzer
|
|
162
|
+
*/
|
|
163
|
+
export interface MelodyContourAnalyzerConfig {
|
|
164
|
+
/** Maximum time gap (in seconds) between beats to consider them consecutive (default: 0.5) */
|
|
165
|
+
maxTimeGapForConsecutive?: number;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Categorize an interval in semitones
|
|
169
|
+
*
|
|
170
|
+
* @param semitones - Number of semitones (absolute value)
|
|
171
|
+
* @returns Interval category
|
|
172
|
+
*/
|
|
173
|
+
export declare function categorizeInterval(semitones: number): IntervalCategory;
|
|
174
|
+
/**
|
|
175
|
+
* Calculate the number of semitones between two MIDI notes
|
|
176
|
+
*
|
|
177
|
+
* @param midi1 - First MIDI note number
|
|
178
|
+
* @param midi2 - Second MIDI note number
|
|
179
|
+
* @returns Absolute difference in semitones
|
|
180
|
+
*/
|
|
181
|
+
export declare function calculateIntervalSemitones(midi1: number, midi2: number): number;
|
|
182
|
+
/**
|
|
183
|
+
* Determine the direction between two MIDI notes
|
|
184
|
+
*
|
|
185
|
+
* @param currentMidi - Current MIDI note
|
|
186
|
+
* @param previousMidi - Previous MIDI note
|
|
187
|
+
* @returns Direction (up, down, stable, or none if invalid)
|
|
188
|
+
*/
|
|
189
|
+
export declare function determineDirection(currentMidi: number | null, previousMidi: number | null): PitchDirection;
|
|
190
|
+
/**
|
|
191
|
+
* Determine overall contour direction from segments
|
|
192
|
+
*
|
|
193
|
+
* @param segments - Melody segments
|
|
194
|
+
* @returns Overall contour direction
|
|
195
|
+
*/
|
|
196
|
+
export declare function determineOverallDirection(segments: MelodySegment[]): MelodyContourDirection;
|
|
197
|
+
/**
|
|
198
|
+
* Convert MIDI note number to note name
|
|
199
|
+
*
|
|
200
|
+
* @param midi - MIDI note number
|
|
201
|
+
* @returns Note name (e.g., "C4", "F#5")
|
|
202
|
+
*/
|
|
203
|
+
export declare function midiToNoteName(midi: number): string;
|
|
204
|
+
/**
|
|
205
|
+
* Melody Contour Analyzer
|
|
206
|
+
*
|
|
207
|
+
* Analyzes pitch data to extract melodic contour information for button mapping.
|
|
208
|
+
*
|
|
209
|
+
* This class performs Phase 1.5 of the pitch detection pipeline:
|
|
210
|
+
* - Pitch-to-pitch comparison to calculate direction and interval
|
|
211
|
+
* - Segment detection for melody phrases
|
|
212
|
+
* - Contour aggregation for overall melody shape
|
|
213
|
+
*/
|
|
214
|
+
export declare class MelodyContourAnalyzer {
|
|
215
|
+
private config;
|
|
216
|
+
/**
|
|
217
|
+
* Create a new MelodyContourAnalyzer
|
|
218
|
+
*
|
|
219
|
+
* @param config - Configuration options
|
|
220
|
+
*/
|
|
221
|
+
constructor(config?: MelodyContourAnalyzerConfig);
|
|
222
|
+
/**
|
|
223
|
+
* Get the current configuration
|
|
224
|
+
*/
|
|
225
|
+
getConfig(): Required<MelodyContourAnalyzerConfig>;
|
|
226
|
+
/**
|
|
227
|
+
* Analyze composite pitch data to extract melody contour
|
|
228
|
+
*
|
|
229
|
+
* This method:
|
|
230
|
+
* 1. Compares consecutive pitches to calculate direction and interval
|
|
231
|
+
* 2. Creates melody segments
|
|
232
|
+
* 3. Calculates overall contour direction and range
|
|
233
|
+
*
|
|
234
|
+
* @param compositePitches - Pitch at each composite beat from PitchBeatLinker.linkWithComposite()
|
|
235
|
+
* @returns Melody contour analysis result with populated direction/interval
|
|
236
|
+
*/
|
|
237
|
+
analyze(compositePitches: PitchAtBeat[]): MelodyContourAnalysisResult;
|
|
238
|
+
/**
|
|
239
|
+
* Analyze pitch-to-pitch comparison for a single band's pitches
|
|
240
|
+
*
|
|
241
|
+
* @param pitches - Array of pitch-at-beat for this band
|
|
242
|
+
* @returns Updated array with direction and interval populated
|
|
243
|
+
*/
|
|
244
|
+
private analyzeBandPitches;
|
|
245
|
+
/**
|
|
246
|
+
* Build melody contour from a band's pitches
|
|
247
|
+
*
|
|
248
|
+
* @param pitches - Array of pitch-at-beat with direction populated
|
|
249
|
+
* @returns Melody contour with segments and overall direction
|
|
250
|
+
*/
|
|
251
|
+
private buildMelodyContour;
|
|
252
|
+
/**
|
|
253
|
+
* Calculate direction over a specific time window
|
|
254
|
+
*
|
|
255
|
+
* Analyzes the last N beats to determine the overall direction trend.
|
|
256
|
+
*
|
|
257
|
+
* @param pitches - All pitches (sorted by timestamp)
|
|
258
|
+
* @param windowSize - Number of beats to look back for direction analysis
|
|
259
|
+
* @returns The overall direction for that window
|
|
260
|
+
*/
|
|
261
|
+
private calculateTimeWindowDirection;
|
|
262
|
+
/**
|
|
263
|
+
* Determine overall direction from direction counts
|
|
264
|
+
*/
|
|
265
|
+
private determineOverallDirectionFromCounts;
|
|
266
|
+
/**
|
|
267
|
+
* Build melody segments from voiced pitches
|
|
268
|
+
*
|
|
269
|
+
* Groups consecutive beats with the same direction into segments.
|
|
270
|
+
*
|
|
271
|
+
* @param pitches - Voiced pitches with direction populated
|
|
272
|
+
* @returns Array of melody segments
|
|
273
|
+
*/
|
|
274
|
+
private buildSegments;
|
|
275
|
+
/**
|
|
276
|
+
* Calculate direction and interval statistics
|
|
277
|
+
*
|
|
278
|
+
* @param pitches - All pitches with direction and interval populated
|
|
279
|
+
* @returns Statistics and metadata
|
|
280
|
+
*/
|
|
281
|
+
private calculateStatistics;
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=MelodyContourAnalyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MelodyContourAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/core/analysis/MelodyContourAnalyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,KAAK,EACR,WAAW,EACd,MAAM,kCAAkC,CAAC;AAM1C;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,WAAW,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC;AAErF;;;;GAIG;AACH,MAAM,WAAW,aAAa;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D;;;;;;;;;GASG;AACH,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,MAAM,CAAwC;IAEtD;;;;OAIG;gBACS,MAAM,GAAE,2BAAgC;IAOpD;;OAEG;IACH,SAAS,IAAI,QAAQ,CAAC,2BAA2B,CAAC;IAIlD;;;;;;;;;;OAUG;IACH,OAAO,CAAC,gBAAgB,EAAE,WAAW,EAAE,GAAG,2BAA2B;IAmBrE;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAmD1B;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAsE1B;;;;;;;;OAQG;IACH,OAAO,CAAC,4BAA4B;IAkCpC;;OAEG;IACH,OAAO,CAAC,mCAAmC;IA6B3C;;;;;;;OAOG;IACH,OAAO,CAAC,aAAa;IAyFrB;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;CAqD9B"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-Band Analyzer for Transient Detection
|
|
3
|
+
*
|
|
4
|
+
* Splits audio into multiple frequency bands and analyzes each band separately
|
|
5
|
+
* for transient detection. This enables detecting different types of rhythmic
|
|
6
|
+
* elements (bass/kick, vocals/snare, hi-hats/cymbals) independently.
|
|
7
|
+
*
|
|
8
|
+
* Part of the Procedural Rhythm Generation pipeline.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Basic usage - analyze an audio buffer
|
|
13
|
+
* const analyzer = new MultiBandAnalyzer();
|
|
14
|
+
* const result = analyzer.analyze(audioBuffer);
|
|
15
|
+
*
|
|
16
|
+
* // Access per-band analysis
|
|
17
|
+
* for (const [bandName, analysis] of result.bands) {
|
|
18
|
+
* console.log(`${bandName}: ${analysis.peaks.length} transients detected`);
|
|
19
|
+
* console.log(` Energy: ${analysis.energy.toFixed(3)}`);
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* // Check which bands have the most activity
|
|
23
|
+
* console.log('Dominant bands:', result.dominantBands);
|
|
24
|
+
*
|
|
25
|
+
* // Custom configuration with adjusted threshold
|
|
26
|
+
* const customAnalyzer = new MultiBandAnalyzer({
|
|
27
|
+
* peakThreshold: 0.4, // Higher threshold = fewer, stronger peaks
|
|
28
|
+
* fftWindowSizeMs: 46, // Larger window = better frequency resolution
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
import { type FrequencyBand } from './beat/utils/audioUtils.js';
|
|
33
|
+
/**
|
|
34
|
+
* Configuration for the Multi-Band Analyzer
|
|
35
|
+
*/
|
|
36
|
+
export interface MultiBandAnalyzerConfig {
|
|
37
|
+
/** Target sample rate for analysis (default: 22050 - good balance of quality and speed) */
|
|
38
|
+
targetSampleRate?: number;
|
|
39
|
+
/** FFT window size in milliseconds (default: 23ms - good for transient detection) */
|
|
40
|
+
fftWindowSizeMs?: number;
|
|
41
|
+
/** Hop size in milliseconds (default: 10ms) */
|
|
42
|
+
hopSizeMs?: number;
|
|
43
|
+
/** Gaussian smoothing window in milliseconds (default: 10ms) */
|
|
44
|
+
smoothWindowMs?: number;
|
|
45
|
+
/** Peak detection threshold (0.0 - 1.0, default: 0.3) */
|
|
46
|
+
peakThreshold?: number;
|
|
47
|
+
/** Custom frequency bands (default: FREQUENCY_BANDS from audioUtils) */
|
|
48
|
+
bands?: FrequencyBand[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Analysis result for a single frequency band
|
|
52
|
+
*/
|
|
53
|
+
export interface BandAnalysis {
|
|
54
|
+
/** Band name identifier ('low', 'mid', 'high') */
|
|
55
|
+
name: string;
|
|
56
|
+
/** Frequency range of this band */
|
|
57
|
+
frequencyRange: {
|
|
58
|
+
lowHz: number;
|
|
59
|
+
highHz: number;
|
|
60
|
+
};
|
|
61
|
+
/** Onset strength envelope for this band (one value per frame) */
|
|
62
|
+
envelope: Float32Array;
|
|
63
|
+
/** Frame indices where peaks (transients) were detected */
|
|
64
|
+
peaks: number[];
|
|
65
|
+
/** Times in seconds where peaks were detected */
|
|
66
|
+
peakTimes: number[];
|
|
67
|
+
/** Average energy in this band (0.0 - 1.0, normalized) */
|
|
68
|
+
energy: number;
|
|
69
|
+
/** Energy over time (one value per frame) */
|
|
70
|
+
energyOverTime: Float32Array;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Result of multi-band analysis
|
|
74
|
+
*/
|
|
75
|
+
export interface MultiBandResult {
|
|
76
|
+
/** Analysis results per band, keyed by band name */
|
|
77
|
+
bands: Map<string, BandAnalysis>;
|
|
78
|
+
/** Bands with the most activity, sorted by energy (highest first) */
|
|
79
|
+
dominantBands: string[];
|
|
80
|
+
/** Combined energy profile across all bands (one value per frame) */
|
|
81
|
+
energyProfile: Float32Array;
|
|
82
|
+
/** Analysis metadata */
|
|
83
|
+
metadata: {
|
|
84
|
+
/** Number of frames in the analysis */
|
|
85
|
+
numFrames: number;
|
|
86
|
+
/** Duration of the audio in seconds */
|
|
87
|
+
duration: number;
|
|
88
|
+
/** Hop size used for analysis in seconds */
|
|
89
|
+
hopSizeSeconds: number;
|
|
90
|
+
/** Effective sample rate after resampling */
|
|
91
|
+
effectiveSampleRate: number;
|
|
92
|
+
/** Bands that were analyzed */
|
|
93
|
+
bandsAnalyzed: string[];
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Multi-Band Analyzer
|
|
98
|
+
*
|
|
99
|
+
* Analyzes audio across multiple frequency bands for transient detection.
|
|
100
|
+
* Each band is processed independently to detect band-specific rhythmic elements.
|
|
101
|
+
*
|
|
102
|
+
* ## Usage
|
|
103
|
+
*
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const analyzer = new MultiBandAnalyzer({
|
|
106
|
+
* targetSampleRate: 22050,
|
|
107
|
+
* peakThreshold: 0.3,
|
|
108
|
+
* });
|
|
109
|
+
*
|
|
110
|
+
* const result = analyzer.analyze(audioBuffer);
|
|
111
|
+
*
|
|
112
|
+
* // Access band-specific analysis
|
|
113
|
+
* const lowBand = result.bands.get('low');
|
|
114
|
+
* console.log(`Low band has ${lowBand?.peaks.length} transients`);
|
|
115
|
+
*
|
|
116
|
+
* // Get dominant bands
|
|
117
|
+
* console.log(`Dominant bands: ${result.dominantBands.join(', ')}`);
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* ## Detection Strategies
|
|
121
|
+
*
|
|
122
|
+
* Different frequency bands contain different rhythmic elements:
|
|
123
|
+
* - **Low (20-500 Hz)**: Bass, kick drums, sub frequencies - use energy-based detection
|
|
124
|
+
* - **Mid (500-2000 Hz)**: Vocals, snare body, lead instruments - use spectral flux
|
|
125
|
+
* - **High (2000-20000 Hz)**: Hi-hats, cymbals, harmonics - use HFC or spectral flux
|
|
126
|
+
*
|
|
127
|
+
* The analyzer uses spectral flux across all bands, which works well for general
|
|
128
|
+
* transient detection. The TransientDetector (next step) will apply band-specific
|
|
129
|
+
* detection strategies.
|
|
130
|
+
*/
|
|
131
|
+
export declare class MultiBandAnalyzer {
|
|
132
|
+
private config;
|
|
133
|
+
/**
|
|
134
|
+
* Create a new Multi-Band Analyzer
|
|
135
|
+
*
|
|
136
|
+
* @param config - Configuration options (all optional, defaults provided)
|
|
137
|
+
*/
|
|
138
|
+
constructor(config?: MultiBandAnalyzerConfig);
|
|
139
|
+
/**
|
|
140
|
+
* Get the current configuration
|
|
141
|
+
*
|
|
142
|
+
* @returns The current configuration
|
|
143
|
+
*/
|
|
144
|
+
getConfig(): Required<MultiBandAnalyzerConfig>;
|
|
145
|
+
/**
|
|
146
|
+
* Analyze an audio buffer across all frequency bands
|
|
147
|
+
*
|
|
148
|
+
* @param audioBuffer - Web Audio API AudioBuffer to analyze
|
|
149
|
+
* @returns Multi-band analysis result
|
|
150
|
+
*/
|
|
151
|
+
analyze(audioBuffer: AudioBuffer): MultiBandResult;
|
|
152
|
+
/**
|
|
153
|
+
* Analyze a single frequency band
|
|
154
|
+
*/
|
|
155
|
+
private analyzeBand;
|
|
156
|
+
/**
|
|
157
|
+
* Calculate onset strength envelope using spectral flux
|
|
158
|
+
*
|
|
159
|
+
* Spectral flux measures the amount of change in the spectrum between
|
|
160
|
+
* consecutive frames. High values indicate likely onset points.
|
|
161
|
+
*
|
|
162
|
+
* ## Algorithm: Spectral Flux for Onset Detection
|
|
163
|
+
*
|
|
164
|
+
* Spectral flux is a widely-used onset detection method that measures the
|
|
165
|
+
* positive change in spectral energy between consecutive STFT frames.
|
|
166
|
+
*
|
|
167
|
+
* ### Mathematical Definition:
|
|
168
|
+
*
|
|
169
|
+
* For each frequency bin `b` at time `t`:
|
|
170
|
+
* ```
|
|
171
|
+
* flux(t, b) = max(0, |X(t, b)| - |X(t-1, b)|)
|
|
172
|
+
* ```
|
|
173
|
+
* Where |X(t, b)| is the magnitude at frequency bin b, time frame t.
|
|
174
|
+
*
|
|
175
|
+
* The total flux at time t is the sum across all frequency bins:
|
|
176
|
+
* ```
|
|
177
|
+
* onset_strength(t) = Σ flux(t, b) for all bins b
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* ### Why Positive Differences Only?
|
|
181
|
+
*
|
|
182
|
+
* We only count increases in energy (positive differences) because:
|
|
183
|
+
* 1. Onsets are characterized by a *rise* in energy, not a fall
|
|
184
|
+
* 2. Including negative differences would cancel out onset peaks
|
|
185
|
+
* 3. This is called "half-wave rectification" in signal processing
|
|
186
|
+
*
|
|
187
|
+
* ### Why This Works for Rhythm Detection:
|
|
188
|
+
*
|
|
189
|
+
* - When a new note/drum hits, its frequency content suddenly appears
|
|
190
|
+
* - This creates a large positive difference in those frequency bins
|
|
191
|
+
* - The sum of all positive differences creates a peak in the envelope
|
|
192
|
+
* - Peaks in the envelope correspond to transients/onsets
|
|
193
|
+
*/
|
|
194
|
+
private calculateOnsetEnvelope;
|
|
195
|
+
/**
|
|
196
|
+
* Find peaks in the onset strength envelope
|
|
197
|
+
*
|
|
198
|
+
* A peak is a local maximum that exceeds the threshold.
|
|
199
|
+
*/
|
|
200
|
+
private findPeaks;
|
|
201
|
+
/**
|
|
202
|
+
* Combine energy profiles from multiple bands
|
|
203
|
+
*
|
|
204
|
+
* Takes the maximum energy at each frame across all bands.
|
|
205
|
+
*/
|
|
206
|
+
private combineEnergyProfiles;
|
|
207
|
+
/**
|
|
208
|
+
* Calculate dominant bands based on average energy
|
|
209
|
+
*
|
|
210
|
+
* Returns band names sorted by energy (highest first).
|
|
211
|
+
*/
|
|
212
|
+
private calculateDominantBands;
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=MultiBandAnalyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiBandAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/core/analysis/MultiBandAnalyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAMH,KAAK,aAAa,EACrB,MAAM,4BAA4B,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,2FAA2F;IAC3F,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qFAAqF;IACrF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,cAAc,EAAE;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,kEAAkE;IAClE,QAAQ,EAAE,YAAY,CAAC;IACvB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,iDAA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