@drop-ai/core 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +734 -316
- package/dist/actions/ActionRegistry.d.ts.map +1 -1
- package/dist/actions/ActionRegistry.js +7 -2
- package/dist/actions/ActionRegistry.js.map +1 -1
- package/dist/actions/types.d.ts +7 -1
- package/dist/actions/types.d.ts.map +1 -1
- package/dist/analysis/AudioAnalyzer.d.ts +69 -0
- package/dist/analysis/AudioAnalyzer.d.ts.map +1 -0
- package/dist/analysis/AudioAnalyzer.js +567 -0
- package/dist/analysis/AudioAnalyzer.js.map +1 -0
- package/dist/audio/AudioEngine.d.ts +14 -1
- package/dist/audio/AudioEngine.d.ts.map +1 -1
- package/dist/audio/AudioEngine.js +115 -35
- package/dist/audio/AudioEngine.js.map +1 -1
- package/dist/audio/Auditioner.d.ts +102 -0
- package/dist/audio/Auditioner.d.ts.map +1 -0
- package/dist/audio/Auditioner.js +237 -0
- package/dist/audio/Auditioner.js.map +1 -0
- package/dist/audio/BWFMetadata.d.ts +114 -0
- package/dist/audio/BWFMetadata.d.ts.map +1 -0
- package/dist/audio/BWFMetadata.js +392 -0
- package/dist/audio/BWFMetadata.js.map +1 -0
- package/dist/audio/BufferPool.d.ts +0 -3
- package/dist/audio/BufferPool.d.ts.map +1 -1
- package/dist/audio/BufferPool.js +0 -3
- package/dist/audio/BufferPool.js.map +1 -1
- package/dist/audio/ChannelSplitter.d.ts +36 -0
- package/dist/audio/ChannelSplitter.d.ts.map +1 -0
- package/dist/audio/ChannelSplitter.js +81 -0
- package/dist/audio/ChannelSplitter.js.map +1 -0
- package/dist/audio/ExportAnalyzer.d.ts +38 -0
- package/dist/audio/ExportAnalyzer.d.ts.map +1 -0
- package/dist/audio/ExportAnalyzer.js +75 -0
- package/dist/audio/ExportAnalyzer.js.map +1 -0
- package/dist/audio/LufsNormalizer.d.ts +36 -0
- package/dist/audio/LufsNormalizer.d.ts.map +1 -0
- package/dist/audio/LufsNormalizer.js +216 -0
- package/dist/audio/LufsNormalizer.js.map +1 -0
- package/dist/audio/MeterUtils.d.ts +0 -2
- package/dist/audio/MeterUtils.d.ts.map +1 -1
- package/dist/audio/MeterUtils.js +0 -2
- package/dist/audio/MeterUtils.js.map +1 -1
- package/dist/audio/OfflineExporter.d.ts +1 -7
- package/dist/audio/OfflineExporter.d.ts.map +1 -1
- package/dist/audio/OfflineExporter.js +31 -11
- package/dist/audio/OfflineExporter.js.map +1 -1
- package/dist/audio/ProcessingGraph.d.ts +0 -1
- package/dist/audio/ProcessingGraph.d.ts.map +1 -1
- package/dist/audio/ProcessingGraph.js +0 -1
- package/dist/audio/ProcessingGraph.js.map +1 -1
- package/dist/audio/RoutingGraph.d.ts +134 -0
- package/dist/audio/RoutingGraph.d.ts.map +1 -0
- package/dist/audio/RoutingGraph.js +547 -0
- package/dist/audio/RoutingGraph.js.map +1 -0
- package/dist/audio/SampleRateConverter.d.ts +20 -0
- package/dist/audio/SampleRateConverter.d.ts.map +1 -0
- package/dist/audio/SampleRateConverter.js +83 -0
- package/dist/audio/SampleRateConverter.js.map +1 -0
- package/dist/audio/SilencePadding.d.ts +27 -0
- package/dist/audio/SilencePadding.d.ts.map +1 -0
- package/dist/audio/SilencePadding.js +84 -0
- package/dist/audio/SilencePadding.js.map +1 -0
- package/dist/audio/SourceCache.d.ts +13 -19
- package/dist/audio/SourceCache.d.ts.map +1 -1
- package/dist/audio/SourceCache.js +21 -36
- package/dist/audio/SourceCache.js.map +1 -1
- package/dist/audio/engine/Declick.d.ts +97 -0
- package/dist/audio/engine/Declick.d.ts.map +1 -0
- package/dist/audio/engine/Declick.js +203 -0
- package/dist/audio/engine/Declick.js.map +1 -0
- package/dist/audio/engine/DiskIO.d.ts +170 -0
- package/dist/audio/engine/DiskIO.d.ts.map +1 -0
- package/dist/audio/engine/DiskIO.js +382 -0
- package/dist/audio/engine/DiskIO.js.map +1 -0
- package/dist/audio/engine/LatencyCompensator.d.ts +46 -0
- package/dist/audio/engine/LatencyCompensator.d.ts.map +1 -0
- package/dist/audio/engine/LatencyCompensator.js +84 -0
- package/dist/audio/engine/LatencyCompensator.js.map +1 -0
- package/dist/audio/engine/MultiTrackRecorder.d.ts +144 -0
- package/dist/audio/engine/MultiTrackRecorder.d.ts.map +1 -0
- package/dist/audio/engine/MultiTrackRecorder.js +359 -0
- package/dist/audio/engine/MultiTrackRecorder.js.map +1 -0
- package/dist/audio/engine/PlaylistEngine.d.ts +1 -1
- package/dist/audio/engine/PlaylistEngine.d.ts.map +1 -1
- package/dist/audio/engine/PlaylistEngine.js +10 -3
- package/dist/audio/engine/PlaylistEngine.js.map +1 -1
- package/dist/audio/engine/PunchRecordManager.d.ts +111 -0
- package/dist/audio/engine/PunchRecordManager.d.ts.map +1 -0
- package/dist/audio/engine/PunchRecordManager.js +191 -0
- package/dist/audio/engine/PunchRecordManager.js.map +1 -0
- package/dist/audio/engine/RoutingGraph.d.ts +133 -0
- package/dist/audio/engine/RoutingGraph.d.ts.map +1 -0
- package/dist/audio/engine/RoutingGraph.js +436 -0
- package/dist/audio/engine/RoutingGraph.js.map +1 -0
- package/dist/audio/engine/SidechainRouter.d.ts +137 -0
- package/dist/audio/engine/SidechainRouter.d.ts.map +1 -0
- package/dist/audio/engine/SidechainRouter.js +290 -0
- package/dist/audio/engine/SidechainRouter.js.map +1 -0
- package/dist/audio/engine/XrunTracker.d.ts +71 -0
- package/dist/audio/engine/XrunTracker.d.ts.map +1 -0
- package/dist/audio/engine/XrunTracker.js +118 -0
- package/dist/audio/engine/XrunTracker.js.map +1 -0
- package/dist/audio/export/CDMarkerExporter.d.ts +60 -0
- package/dist/audio/export/CDMarkerExporter.d.ts.map +1 -0
- package/dist/audio/export/CDMarkerExporter.js +162 -0
- package/dist/audio/export/CDMarkerExporter.js.map +1 -0
- package/dist/audio/export/ExportGraphBuilder.d.ts +119 -0
- package/dist/audio/export/ExportGraphBuilder.d.ts.map +1 -0
- package/dist/audio/export/ExportGraphBuilder.js +520 -0
- package/dist/audio/export/ExportGraphBuilder.js.map +1 -0
- package/dist/audio/export/ExportPresetManager.d.ts +85 -0
- package/dist/audio/export/ExportPresetManager.d.ts.map +1 -0
- package/dist/audio/export/ExportPresetManager.js +304 -0
- package/dist/audio/export/ExportPresetManager.js.map +1 -0
- package/dist/automation/AutomationList.d.ts +0 -1
- package/dist/automation/AutomationList.d.ts.map +1 -1
- package/dist/automation/AutomationList.js +0 -1
- package/dist/automation/AutomationList.js.map +1 -1
- package/dist/automation/AutomationMode.d.ts +0 -1
- package/dist/automation/AutomationMode.d.ts.map +1 -1
- package/dist/automation/AutomationMode.js +0 -1
- package/dist/automation/AutomationMode.js.map +1 -1
- package/dist/commands/CommandHistory.d.ts +1 -4
- package/dist/commands/CommandHistory.d.ts.map +1 -1
- package/dist/commands/CommandHistory.js +6 -9
- package/dist/commands/CommandHistory.js.map +1 -1
- package/dist/commands/CommandRegistry.d.ts +1 -2
- package/dist/commands/CommandRegistry.d.ts.map +1 -1
- package/dist/commands/CommandRegistry.js +1 -2
- package/dist/commands/CommandRegistry.js.map +1 -1
- package/dist/commands/UndoTransaction.d.ts +0 -2
- package/dist/commands/UndoTransaction.d.ts.map +1 -1
- package/dist/commands/UndoTransaction.js +1 -3
- package/dist/commands/UndoTransaction.js.map +1 -1
- package/dist/commands/handlers/HistoryHandler.d.ts +5 -5
- package/dist/commands/handlers/HistoryHandler.js +10 -10
- package/dist/commands/handlers/HistoryHandler.js.map +1 -1
- package/dist/commands/handlers/MarkerHandler.d.ts +0 -1
- package/dist/commands/handlers/MarkerHandler.d.ts.map +1 -1
- package/dist/commands/handlers/MarkerHandler.js +0 -1
- package/dist/commands/handlers/MarkerHandler.js.map +1 -1
- package/dist/commands/handlers/RegionHandler.d.ts.map +1 -1
- package/dist/commands/handlers/RegionHandler.js +25 -1
- package/dist/commands/handlers/RegionHandler.js.map +1 -1
- package/dist/commands/handlers/TrackHandler.js +1 -1
- package/dist/commands/handlers/TrackHandler.js.map +1 -1
- package/dist/commands/impl/CopyRegionCommand.d.ts +0 -1
- package/dist/commands/impl/CopyRegionCommand.d.ts.map +1 -1
- package/dist/commands/impl/CopyRegionCommand.js +0 -1
- package/dist/commands/impl/CopyRegionCommand.js.map +1 -1
- package/dist/commands/impl/DuplicateRegionCommand.d.ts +0 -1
- package/dist/commands/impl/DuplicateRegionCommand.d.ts.map +1 -1
- package/dist/commands/impl/DuplicateRegionCommand.js +0 -1
- package/dist/commands/impl/DuplicateRegionCommand.js.map +1 -1
- package/dist/commands/impl/ExportCommand.d.ts +0 -1
- package/dist/commands/impl/ExportCommand.d.ts.map +1 -1
- package/dist/commands/impl/ExportCommand.js +0 -1
- package/dist/commands/impl/ExportCommand.js.map +1 -1
- package/dist/commands/impl/FreezeTrackCommand.d.ts +1 -1
- package/dist/commands/impl/FreezeTrackCommand.d.ts.map +1 -1
- package/dist/commands/impl/FreezeTrackCommand.js +38 -37
- package/dist/commands/impl/FreezeTrackCommand.js.map +1 -1
- package/dist/commands/impl/PasteRegionCommand.d.ts +0 -1
- package/dist/commands/impl/PasteRegionCommand.d.ts.map +1 -1
- package/dist/commands/impl/PasteRegionCommand.js +0 -1
- package/dist/commands/impl/PasteRegionCommand.js.map +1 -1
- package/dist/commands/impl/SaveSnapshotCommand.d.ts +1 -1
- package/dist/commands/impl/SaveSnapshotCommand.js +1 -1
- package/dist/commands/impl/SetLoopRangeCommand.d.ts +0 -1
- package/dist/commands/impl/SetLoopRangeCommand.d.ts.map +1 -1
- package/dist/commands/impl/SetLoopRangeCommand.js +0 -1
- package/dist/commands/impl/SetLoopRangeCommand.js.map +1 -1
- package/dist/commands/impl/SetPunchRangeCommand.d.ts +0 -1
- package/dist/commands/impl/SetPunchRangeCommand.d.ts.map +1 -1
- package/dist/commands/impl/SetPunchRangeCommand.js +0 -1
- package/dist/commands/impl/SetPunchRangeCommand.js.map +1 -1
- package/dist/commands/impl/SetRegionTimeDomainCommand.d.ts.map +1 -1
- package/dist/commands/impl/SetRegionTimeDomainCommand.js +3 -3
- package/dist/commands/impl/SetRegionTimeDomainCommand.js.map +1 -1
- package/dist/commands/impl/SplitAtPlayheadCommand.d.ts +0 -2
- package/dist/commands/impl/SplitAtPlayheadCommand.d.ts.map +1 -1
- package/dist/commands/impl/SplitAtPlayheadCommand.js +0 -2
- package/dist/commands/impl/SplitAtPlayheadCommand.js.map +1 -1
- package/dist/commands/impl/SplitRegionCommand.d.ts +0 -1
- package/dist/commands/impl/SplitRegionCommand.d.ts.map +1 -1
- package/dist/commands/impl/SplitRegionCommand.js +0 -1
- package/dist/commands/impl/SplitRegionCommand.js.map +1 -1
- package/dist/commands/impl/StripSilenceCommand.d.ts +0 -1
- package/dist/commands/impl/StripSilenceCommand.d.ts.map +1 -1
- package/dist/commands/impl/StripSilenceCommand.js +0 -1
- package/dist/commands/impl/StripSilenceCommand.js.map +1 -1
- package/dist/commands/impl/TimeStretchRegionCommand.d.ts +1 -2
- package/dist/commands/impl/TimeStretchRegionCommand.d.ts.map +1 -1
- package/dist/commands/impl/TimeStretchRegionCommand.js +1 -2
- package/dist/commands/impl/TimeStretchRegionCommand.js.map +1 -1
- package/dist/commands/impl/ToggleLoopCommand.d.ts +1 -0
- package/dist/commands/impl/ToggleLoopCommand.d.ts.map +1 -1
- package/dist/commands/impl/ToggleLoopCommand.js +10 -0
- package/dist/commands/impl/ToggleLoopCommand.js.map +1 -1
- package/dist/commands/impl/TrimRegionCommand.d.ts +14 -1
- package/dist/commands/impl/TrimRegionCommand.d.ts.map +1 -1
- package/dist/commands/impl/TrimRegionCommand.js +138 -33
- package/dist/commands/impl/TrimRegionCommand.js.map +1 -1
- package/dist/commands/impl/TrimRegionToPlayheadCommand.d.ts +26 -0
- package/dist/commands/impl/TrimRegionToPlayheadCommand.d.ts.map +1 -0
- package/dist/commands/impl/TrimRegionToPlayheadCommand.js +68 -0
- package/dist/commands/impl/TrimRegionToPlayheadCommand.js.map +1 -0
- package/dist/commands/impl/TrimRegionToRangeCommand.d.ts +27 -0
- package/dist/commands/impl/TrimRegionToRangeCommand.d.ts.map +1 -0
- package/dist/commands/impl/TrimRegionToRangeCommand.js +68 -0
- package/dist/commands/impl/TrimRegionToRangeCommand.js.map +1 -0
- package/dist/commands/impl/TrimToAdjacentRegionCommand.d.ts +26 -0
- package/dist/commands/impl/TrimToAdjacentRegionCommand.d.ts.map +1 -0
- package/dist/commands/impl/TrimToAdjacentRegionCommand.js +76 -0
- package/dist/commands/impl/TrimToAdjacentRegionCommand.js.map +1 -0
- package/dist/commands/types.d.ts +19 -0
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/types.js +21 -0
- package/dist/commands/types.js.map +1 -1
- package/dist/domain/ABComparison.d.ts +0 -1
- package/dist/domain/ABComparison.d.ts.map +1 -1
- package/dist/domain/ABComparison.js +0 -1
- package/dist/domain/ABComparison.js.map +1 -1
- package/dist/domain/CDMarker.d.ts +0 -1
- package/dist/domain/CDMarker.d.ts.map +1 -1
- package/dist/domain/CDMarker.js +0 -1
- package/dist/domain/CDMarker.js.map +1 -1
- package/dist/domain/ClockMode.d.ts +0 -1
- package/dist/domain/ClockMode.d.ts.map +1 -1
- package/dist/domain/ClockMode.js +0 -1
- package/dist/domain/ClockMode.js.map +1 -1
- package/dist/domain/Crossfade.d.ts +78 -0
- package/dist/domain/Crossfade.d.ts.map +1 -0
- package/dist/domain/Crossfade.js +216 -0
- package/dist/domain/Crossfade.js.map +1 -0
- package/dist/domain/DragManager.d.ts +0 -2
- package/dist/domain/DragManager.d.ts.map +1 -1
- package/dist/domain/DragManager.js +0 -2
- package/dist/domain/DragManager.js.map +1 -1
- package/dist/domain/EditMode.d.ts +0 -1
- package/dist/domain/EditMode.d.ts.map +1 -1
- package/dist/domain/EditMode.js +0 -1
- package/dist/domain/EditMode.js.map +1 -1
- package/dist/domain/ExportConfig.d.ts +98 -2
- package/dist/domain/ExportConfig.d.ts.map +1 -1
- package/dist/domain/ExportConfig.js +154 -2
- package/dist/domain/ExportConfig.js.map +1 -1
- package/dist/domain/ExportPreset.d.ts +60 -0
- package/dist/domain/ExportPreset.d.ts.map +1 -0
- package/dist/domain/ExportPreset.js +77 -0
- package/dist/domain/ExportPreset.js.map +1 -0
- package/dist/domain/ExportStatus.d.ts +0 -1
- package/dist/domain/ExportStatus.d.ts.map +1 -1
- package/dist/domain/ExportStatus.js +0 -1
- package/dist/domain/ExportStatus.js.map +1 -1
- package/dist/domain/GridSettings.d.ts +0 -3
- package/dist/domain/GridSettings.d.ts.map +1 -1
- package/dist/domain/GridSettings.js +0 -3
- package/dist/domain/GridSettings.js.map +1 -1
- package/dist/domain/ImportStatus.d.ts +40 -0
- package/dist/domain/ImportStatus.d.ts.map +1 -0
- package/dist/domain/ImportStatus.js +86 -0
- package/dist/domain/ImportStatus.js.map +1 -0
- package/dist/domain/Marker.d.ts +0 -1
- package/dist/domain/Marker.d.ts.map +1 -1
- package/dist/domain/Marker.js +0 -1
- package/dist/domain/Marker.js.map +1 -1
- package/dist/domain/MeterData.d.ts +0 -2
- package/dist/domain/MeterData.d.ts.map +1 -1
- package/dist/domain/MeterType.d.ts +0 -2
- package/dist/domain/MeterType.d.ts.map +1 -1
- package/dist/domain/MeterType.js +0 -2
- package/dist/domain/MeterType.js.map +1 -1
- package/dist/domain/MonitorMode.d.ts +0 -1
- package/dist/domain/MonitorMode.d.ts.map +1 -1
- package/dist/domain/MonitorMode.js +0 -1
- package/dist/domain/MonitorMode.js.map +1 -1
- package/dist/domain/MouseMode.d.ts +0 -1
- package/dist/domain/MouseMode.d.ts.map +1 -1
- package/dist/domain/MouseMode.js +0 -1
- package/dist/domain/MouseMode.js.map +1 -1
- package/dist/domain/OverlapType.d.ts +0 -2
- package/dist/domain/OverlapType.d.ts.map +1 -1
- package/dist/domain/OverlapType.js +0 -2
- package/dist/domain/OverlapType.js.map +1 -1
- package/dist/domain/Playlist.d.ts +72 -0
- package/dist/domain/Playlist.d.ts.map +1 -1
- package/dist/domain/Playlist.js +231 -6
- package/dist/domain/Playlist.js.map +1 -1
- package/dist/domain/Range.d.ts +0 -1
- package/dist/domain/Range.d.ts.map +1 -1
- package/dist/domain/Range.js +0 -1
- package/dist/domain/Range.js.map +1 -1
- package/dist/domain/RecordMode.d.ts +0 -1
- package/dist/domain/RecordMode.d.ts.map +1 -1
- package/dist/domain/RecordMode.js +0 -1
- package/dist/domain/RecordMode.js.map +1 -1
- package/dist/domain/Region.d.ts +76 -0
- package/dist/domain/Region.d.ts.map +1 -1
- package/dist/domain/Region.js +234 -1
- package/dist/domain/Region.js.map +1 -1
- package/dist/domain/RegionClipboard.d.ts +1 -3
- package/dist/domain/RegionClipboard.d.ts.map +1 -1
- package/dist/domain/RegionClipboard.js +1 -2
- package/dist/domain/RegionClipboard.js.map +1 -1
- package/dist/domain/Route.d.ts +43 -3
- package/dist/domain/Route.d.ts.map +1 -1
- package/dist/domain/Route.js +92 -6
- package/dist/domain/Route.js.map +1 -1
- package/dist/domain/RulerType.d.ts +0 -1
- package/dist/domain/RulerType.d.ts.map +1 -1
- package/dist/domain/RulerType.js +0 -1
- package/dist/domain/RulerType.js.map +1 -1
- package/dist/domain/SelectionHistory.d.ts +0 -3
- package/dist/domain/SelectionHistory.d.ts.map +1 -1
- package/dist/domain/SelectionHistory.js +0 -3
- package/dist/domain/SelectionHistory.js.map +1 -1
- package/dist/domain/SendBus.d.ts +0 -1
- package/dist/domain/SendBus.d.ts.map +1 -1
- package/dist/domain/SendBus.js +0 -1
- package/dist/domain/SendBus.js.map +1 -1
- package/dist/domain/Session.d.ts +31 -0
- package/dist/domain/Session.d.ts.map +1 -1
- package/dist/domain/Session.js +70 -0
- package/dist/domain/Session.js.map +1 -1
- package/dist/domain/SidechainConfig.d.ts +0 -1
- package/dist/domain/SidechainConfig.d.ts.map +1 -1
- package/dist/domain/SidechainConfig.js +0 -1
- package/dist/domain/SidechainConfig.js.map +1 -1
- package/dist/domain/Source.d.ts +145 -1
- package/dist/domain/Source.d.ts.map +1 -1
- package/dist/domain/Source.js +144 -1
- package/dist/domain/Source.js.map +1 -1
- package/dist/domain/Take.d.ts +0 -1
- package/dist/domain/Take.d.ts.map +1 -1
- package/dist/domain/Take.js +0 -1
- package/dist/domain/Take.js.map +1 -1
- package/dist/domain/ThawList.d.ts +36 -0
- package/dist/domain/ThawList.d.ts.map +1 -0
- package/dist/domain/ThawList.js +72 -0
- package/dist/domain/ThawList.js.map +1 -0
- package/dist/domain/Track.d.ts +93 -1
- package/dist/domain/Track.d.ts.map +1 -1
- package/dist/domain/Track.js +136 -0
- package/dist/domain/Track.js.map +1 -1
- package/dist/domain/TrackGroup.d.ts +0 -1
- package/dist/domain/TrackGroup.d.ts.map +1 -1
- package/dist/domain/TrackGroup.js +0 -1
- package/dist/domain/TrackGroup.js.map +1 -1
- package/dist/domain/TransportFSM.d.ts +0 -1
- package/dist/domain/TransportFSM.d.ts.map +1 -1
- package/dist/domain/TransportFSM.js +0 -1
- package/dist/domain/TransportFSM.js.map +1 -1
- package/dist/domain/TransportMode.d.ts +0 -1
- package/dist/domain/TransportMode.d.ts.map +1 -1
- package/dist/domain/TransportMode.js +0 -1
- package/dist/domain/TransportMode.js.map +1 -1
- package/dist/domain/TriggerBox.d.ts +121 -0
- package/dist/domain/TriggerBox.d.ts.map +1 -0
- package/dist/domain/TriggerBox.js +428 -0
- package/dist/domain/TriggerBox.js.map +1 -0
- package/dist/domain/VCATrack.d.ts +63 -2
- package/dist/domain/VCATrack.d.ts.map +1 -1
- package/dist/domain/VCATrack.js +127 -2
- package/dist/domain/VCATrack.js.map +1 -1
- package/dist/domain/VideoExportConfig.d.ts +116 -0
- package/dist/domain/VideoExportConfig.d.ts.map +1 -0
- package/dist/domain/VideoExportConfig.js +243 -0
- package/dist/domain/VideoExportConfig.js.map +1 -0
- package/dist/domain/VideoExportStatus.d.ts +89 -0
- package/dist/domain/VideoExportStatus.d.ts.map +1 -0
- package/dist/domain/VideoExportStatus.js +192 -0
- package/dist/domain/VideoExportStatus.js.map +1 -0
- package/dist/domain/VideoMetadata.d.ts +46 -0
- package/dist/domain/VideoMetadata.d.ts.map +1 -0
- package/dist/domain/VideoMetadata.js +2 -0
- package/dist/domain/VideoMetadata.js.map +1 -0
- package/dist/domain/ZoomFocus.d.ts +0 -1
- package/dist/domain/ZoomFocus.d.ts.map +1 -1
- package/dist/domain/ZoomFocus.js +0 -1
- package/dist/domain/ZoomFocus.js.map +1 -1
- package/dist/domain/index.d.ts +5 -0
- package/dist/domain/index.d.ts.map +1 -1
- package/dist/domain/index.js +5 -0
- package/dist/domain/index.js.map +1 -1
- package/dist/domain/temporal/TempoMap.d.ts +198 -2
- package/dist/domain/temporal/TempoMap.d.ts.map +1 -1
- package/dist/domain/temporal/TempoMap.js +464 -30
- package/dist/domain/temporal/TempoMap.js.map +1 -1
- package/dist/domain/temporal/types.d.ts +1 -1
- package/dist/domain/temporal/types.d.ts.map +1 -1
- package/dist/domain/temporal/types.js +1 -1
- package/dist/domain/temporal/types.js.map +1 -1
- package/dist/index.d.ts +43 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/Signal.d.ts +1 -1
- package/dist/lib/ThawList.d.ts +98 -0
- package/dist/lib/ThawList.d.ts.map +1 -0
- package/dist/lib/ThawList.js +151 -0
- package/dist/lib/ThawList.js.map +1 -0
- package/dist/midi/MidiFileParser.d.ts +32 -0
- package/dist/midi/MidiFileParser.d.ts.map +1 -0
- package/dist/midi/MidiFileParser.js +245 -0
- package/dist/midi/MidiFileParser.js.map +1 -0
- package/dist/midi/MidiFileWriter.d.ts +30 -0
- package/dist/midi/MidiFileWriter.d.ts.map +1 -0
- package/dist/midi/MidiFileWriter.js +159 -0
- package/dist/midi/MidiFileWriter.js.map +1 -0
- package/dist/midi/MidiImporter.d.ts +37 -0
- package/dist/midi/MidiImporter.d.ts.map +1 -0
- package/dist/midi/MidiImporter.js +62 -0
- package/dist/midi/MidiImporter.js.map +1 -0
- package/dist/plugins/PluginManager.js +2 -2
- package/dist/plugins/PluginManager.js.map +1 -1
- package/dist/plugins/PluginPresetManager.d.ts +86 -0
- package/dist/plugins/PluginPresetManager.d.ts.map +1 -0
- package/dist/plugins/PluginPresetManager.js +140 -0
- package/dist/plugins/PluginPresetManager.js.map +1 -0
- package/dist/plugins/impl/ExpanderPlugin.d.ts +1 -1
- package/dist/plugins/impl/ExpanderPlugin.js +1 -1
- package/dist/plugins/impl/ParametricEQPlugin.d.ts +1 -1
- package/dist/plugins/impl/ParametricEQPlugin.js +1 -1
- package/dist/processing/IO.d.ts +15 -1
- package/dist/processing/IO.d.ts.map +1 -1
- package/dist/processing/IO.js +29 -1
- package/dist/processing/IO.js.map +1 -1
- package/dist/processing/InternalSend.d.ts +102 -0
- package/dist/processing/InternalSend.d.ts.map +1 -0
- package/dist/processing/InternalSend.js +175 -0
- package/dist/processing/InternalSend.js.map +1 -0
- package/dist/processing/MeterDSP.d.ts +165 -0
- package/dist/processing/MeterDSP.d.ts.map +1 -0
- package/dist/processing/MeterDSP.js +753 -0
- package/dist/processing/MeterDSP.js.map +1 -0
- package/dist/processing/MeterProcessor.d.ts +0 -1
- package/dist/processing/MeterProcessor.d.ts.map +1 -1
- package/dist/processing/MeterProcessor.js +0 -1
- package/dist/processing/MeterProcessor.js.map +1 -1
- package/dist/processing/Panner.d.ts +144 -0
- package/dist/processing/Panner.d.ts.map +1 -0
- package/dist/processing/Panner.js +280 -0
- package/dist/processing/Panner.js.map +1 -0
- package/dist/processing/PluginInsert.d.ts +56 -1
- package/dist/processing/PluginInsert.d.ts.map +1 -1
- package/dist/processing/PluginInsert.js +180 -2
- package/dist/processing/PluginInsert.js.map +1 -1
- package/dist/processing/PolarityProcessor.d.ts +1 -1
- package/dist/processing/PolarityProcessor.js +1 -1
- package/dist/processing/Processor.d.ts +38 -0
- package/dist/processing/Processor.d.ts.map +1 -1
- package/dist/processing/Processor.js +60 -1
- package/dist/processing/Processor.js.map +1 -1
- package/dist/processing/SendProcessor.d.ts +0 -1
- package/dist/processing/SendProcessor.d.ts.map +1 -1
- package/dist/processing/SendProcessor.js +0 -1
- package/dist/processing/SendProcessor.js.map +1 -1
- package/dist/processing/SurroundPanner.d.ts +120 -0
- package/dist/processing/SurroundPanner.d.ts.map +1 -0
- package/dist/processing/SurroundPanner.js +374 -0
- package/dist/processing/SurroundPanner.js.map +1 -0
- package/dist/processing/TruePeakLimiter.d.ts +32 -0
- package/dist/processing/TruePeakLimiter.d.ts.map +1 -0
- package/dist/processing/TruePeakLimiter.js +142 -0
- package/dist/processing/TruePeakLimiter.js.map +1 -0
- package/dist/storage/ExportPresetStorage.d.ts +33 -0
- package/dist/storage/ExportPresetStorage.d.ts.map +1 -0
- package/dist/storage/ExportPresetStorage.js +121 -0
- package/dist/storage/ExportPresetStorage.js.map +1 -0
- package/dist/storage/SessionArchive.d.ts +73 -0
- package/dist/storage/SessionArchive.d.ts.map +1 -0
- package/dist/storage/SessionArchive.js +211 -0
- package/dist/storage/SessionArchive.js.map +1 -0
- package/dist/storage/SessionStorage.d.ts +1 -1
- package/dist/storage/SessionTemplate.d.ts +74 -5
- package/dist/storage/SessionTemplate.d.ts.map +1 -1
- package/dist/storage/SessionTemplate.js +247 -53
- package/dist/storage/SessionTemplate.js.map +1 -1
- package/dist/utils/BwfMetadataWriter.d.ts +41 -0
- package/dist/utils/BwfMetadataWriter.d.ts.map +1 -0
- package/dist/utils/BwfMetadataWriter.js +130 -0
- package/dist/utils/BwfMetadataWriter.js.map +1 -0
- package/dist/utils/DitherProcessor.d.ts +0 -1
- package/dist/utils/DitherProcessor.d.ts.map +1 -1
- package/dist/utils/DitherProcessor.js +0 -1
- package/dist/utils/DitherProcessor.js.map +1 -1
- package/dist/utils/FilenameTemplate.d.ts +39 -0
- package/dist/utils/FilenameTemplate.d.ts.map +1 -0
- package/dist/utils/FilenameTemplate.js +77 -0
- package/dist/utils/FilenameTemplate.js.map +1 -0
- package/dist/utils/FlacEncoder.d.ts +0 -1
- package/dist/utils/FlacEncoder.d.ts.map +1 -1
- package/dist/utils/FlacEncoder.js +0 -1
- package/dist/utils/FlacEncoder.js.map +1 -1
- package/dist/utils/Logger.d.ts +28 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/dist/utils/Logger.js +46 -0
- package/dist/utils/Logger.js.map +1 -0
- package/dist/utils/Mp4ChapterGenerator.d.ts +16 -0
- package/dist/utils/Mp4ChapterGenerator.d.ts.map +1 -0
- package/dist/utils/Mp4ChapterGenerator.js +32 -0
- package/dist/utils/Mp4ChapterGenerator.js.map +1 -0
- package/dist/utils/OggEncoder.d.ts +19 -21
- package/dist/utils/OggEncoder.d.ts.map +1 -1
- package/dist/utils/OggEncoder.js +113 -51
- package/dist/utils/OggEncoder.js.map +1 -1
- package/dist/utils/TocGenerator.d.ts +16 -0
- package/dist/utils/TocGenerator.d.ts.map +1 -0
- package/dist/utils/TocGenerator.js +46 -0
- package/dist/utils/TocGenerator.js.map +1 -0
- package/package.json +7 -8
|
@@ -0,0 +1,753 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Professional metering DSP algorithms implementing broadcast standards.
|
|
3
|
+
*
|
|
4
|
+
* Supported meter types:
|
|
5
|
+
* - Peak (simple sample-peak detection)
|
|
6
|
+
* - IEC 60268-10 Type I (DIN, Nordic)
|
|
7
|
+
* - IEC 60268-10 Type II (BBC PPM, EBU)
|
|
8
|
+
* - K-system (K-12, K-14, K-20)
|
|
9
|
+
* - VU (300ms RMS integration)
|
|
10
|
+
* - LUFS / EBU R128 (momentary, short-term, integrated, loudness range)
|
|
11
|
+
* - ITU-R BS.1770 true peak (4x oversampling)
|
|
12
|
+
*/
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Enums & Interfaces
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
export var MeterType;
|
|
17
|
+
(function (MeterType) {
|
|
18
|
+
MeterType["PEAK"] = "peak";
|
|
19
|
+
MeterType["IEC1_DIN"] = "iec1_din";
|
|
20
|
+
MeterType["IEC1_NORDIC"] = "iec1_nordic";
|
|
21
|
+
MeterType["IEC2_BBC"] = "iec2_bbc";
|
|
22
|
+
MeterType["IEC2_EBU"] = "iec2_ebu";
|
|
23
|
+
MeterType["K_12"] = "k12";
|
|
24
|
+
MeterType["K_14"] = "k14";
|
|
25
|
+
MeterType["K_20"] = "k20";
|
|
26
|
+
MeterType["VU"] = "vu";
|
|
27
|
+
MeterType["LUFS"] = "lufs";
|
|
28
|
+
MeterType["TRUE_PEAK"] = "true_peak";
|
|
29
|
+
})(MeterType || (MeterType = {}));
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
// Constants
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
const NEG_INF = -Infinity;
|
|
34
|
+
const LOG10_20 = 20 / Math.LN10; // pre-computed multiplier for 20*log10
|
|
35
|
+
/**
|
|
36
|
+
* 4x oversampling polyphase FIR coefficients for ITU-R BS.1770 true peak.
|
|
37
|
+
* 12 taps per phase, 4 phases = 48 total coefficients.
|
|
38
|
+
* These approximate a half-band windowed-sinc interpolation filter.
|
|
39
|
+
*/
|
|
40
|
+
const TP_FIR_PHASES = [
|
|
41
|
+
// Phase 0 (original samples, shifted by filter delay)
|
|
42
|
+
new Float64Array([
|
|
43
|
+
0.0017089843750,
|
|
44
|
+
0.0000000000000,
|
|
45
|
+
-0.0189208984375,
|
|
46
|
+
0.0000000000000,
|
|
47
|
+
0.3031005859375,
|
|
48
|
+
0.4736328125000,
|
|
49
|
+
0.3031005859375,
|
|
50
|
+
0.0000000000000,
|
|
51
|
+
-0.0189208984375,
|
|
52
|
+
0.0000000000000,
|
|
53
|
+
0.0017089843750,
|
|
54
|
+
0.0000000000000,
|
|
55
|
+
]),
|
|
56
|
+
// Phase 1
|
|
57
|
+
new Float64Array([
|
|
58
|
+
0.0013427734375,
|
|
59
|
+
-0.0117797851562,
|
|
60
|
+
-0.0245361328125,
|
|
61
|
+
0.0527343750000,
|
|
62
|
+
0.2926025390625,
|
|
63
|
+
0.4694213867188,
|
|
64
|
+
0.2926025390625,
|
|
65
|
+
0.0527343750000,
|
|
66
|
+
-0.0245361328125,
|
|
67
|
+
-0.0117797851562,
|
|
68
|
+
0.0013427734375,
|
|
69
|
+
0.0000000000000,
|
|
70
|
+
]),
|
|
71
|
+
// Phase 2
|
|
72
|
+
new Float64Array([
|
|
73
|
+
0.0008544921875,
|
|
74
|
+
-0.0200805664062,
|
|
75
|
+
-0.0217285156250,
|
|
76
|
+
0.0896606445312,
|
|
77
|
+
0.2593994140625,
|
|
78
|
+
0.4530029296875,
|
|
79
|
+
0.3236083984375,
|
|
80
|
+
0.0896606445312,
|
|
81
|
+
-0.0217285156250,
|
|
82
|
+
-0.0200805664062,
|
|
83
|
+
0.0008544921875,
|
|
84
|
+
0.0000000000000,
|
|
85
|
+
]),
|
|
86
|
+
// Phase 3
|
|
87
|
+
new Float64Array([
|
|
88
|
+
0.0004272460938,
|
|
89
|
+
-0.0254516601562,
|
|
90
|
+
-0.0128173828125,
|
|
91
|
+
0.1141357421875,
|
|
92
|
+
0.2153320312500,
|
|
93
|
+
0.4309082031250,
|
|
94
|
+
0.3472900390625,
|
|
95
|
+
0.1141357421875,
|
|
96
|
+
-0.0128173828125,
|
|
97
|
+
-0.0254516601562,
|
|
98
|
+
0.0004272460938,
|
|
99
|
+
0.0000000000000,
|
|
100
|
+
]),
|
|
101
|
+
];
|
|
102
|
+
const TP_FIR_LEN = 12; // taps per phase
|
|
103
|
+
/**
|
|
104
|
+
* Design the K-weighting high shelf filter (stage 1).
|
|
105
|
+
* f0 = 1681.97 Hz, gain = +3.999 dB, Q = 0.7071968
|
|
106
|
+
*/
|
|
107
|
+
function designKWeightShelf(sr) {
|
|
108
|
+
const f0 = 1681.974450955533;
|
|
109
|
+
const G = 3.999843853973347; // dB
|
|
110
|
+
const Q = 0.7071752369554196;
|
|
111
|
+
const A = Math.pow(10, G / 40); // sqrt of linear gain
|
|
112
|
+
const w0 = 2 * Math.PI * f0 / sr;
|
|
113
|
+
const cosw0 = Math.cos(w0);
|
|
114
|
+
const sinw0 = Math.sin(w0);
|
|
115
|
+
const alpha = sinw0 / (2 * Q);
|
|
116
|
+
const Ap1 = A + 1;
|
|
117
|
+
const Am1 = A - 1;
|
|
118
|
+
const twoSqrtAAlpha = 2 * Math.sqrt(A) * alpha;
|
|
119
|
+
const a0 = Ap1 - Am1 * cosw0 + twoSqrtAAlpha;
|
|
120
|
+
return {
|
|
121
|
+
b0: (A * (Ap1 + Am1 * cosw0 + twoSqrtAAlpha)) / a0,
|
|
122
|
+
b1: (-2 * A * (Am1 + Ap1 * cosw0)) / a0,
|
|
123
|
+
b2: (A * (Ap1 + Am1 * cosw0 - twoSqrtAAlpha)) / a0,
|
|
124
|
+
a1: (2 * (Am1 - Ap1 * cosw0)) / a0,
|
|
125
|
+
a2: (Ap1 - Am1 * cosw0 - twoSqrtAAlpha) / a0,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Design the K-weighting high-pass filter (stage 2).
|
|
130
|
+
* f0 = 38.13547087602444 Hz, Q = 0.5003270373238773
|
|
131
|
+
*/
|
|
132
|
+
function designKWeightHP(sr) {
|
|
133
|
+
const f0 = 38.13547087602444;
|
|
134
|
+
const Q = 0.5003270373238773;
|
|
135
|
+
const w0 = 2 * Math.PI * f0 / sr;
|
|
136
|
+
const cosw0 = Math.cos(w0);
|
|
137
|
+
const sinw0 = Math.sin(w0);
|
|
138
|
+
const alpha = sinw0 / (2 * Q);
|
|
139
|
+
const a0 = 1 + alpha;
|
|
140
|
+
return {
|
|
141
|
+
b0: ((1 + cosw0) / 2) / a0,
|
|
142
|
+
b1: (-(1 + cosw0)) / a0,
|
|
143
|
+
b2: ((1 + cosw0) / 2) / a0,
|
|
144
|
+
a1: (-2 * cosw0) / a0,
|
|
145
|
+
a2: (1 - alpha) / a0,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function makeBiquadState() {
|
|
149
|
+
return { x1: 0, x2: 0, y1: 0, y2: 0 };
|
|
150
|
+
}
|
|
151
|
+
function biquadProcess(c, s, x) {
|
|
152
|
+
const y = c.b0 * x + c.b1 * s.x1 + c.b2 * s.x2
|
|
153
|
+
- c.a1 * s.y1 - c.a2 * s.y2;
|
|
154
|
+
s.x2 = s.x1;
|
|
155
|
+
s.x1 = x;
|
|
156
|
+
s.y2 = s.y1;
|
|
157
|
+
s.y1 = y;
|
|
158
|
+
return y;
|
|
159
|
+
}
|
|
160
|
+
// ---------------------------------------------------------------------------
|
|
161
|
+
// MeterDSP
|
|
162
|
+
// ---------------------------------------------------------------------------
|
|
163
|
+
export class MeterDSP {
|
|
164
|
+
// ── Constructor ─────────────────────────────────────────────────────
|
|
165
|
+
constructor(type, sampleRate, channelCount = 2) {
|
|
166
|
+
this._type = type;
|
|
167
|
+
this._sampleRate = sampleRate;
|
|
168
|
+
this._channelCount = channelCount;
|
|
169
|
+
// Per-channel arrays
|
|
170
|
+
this._peaks = new Float64Array(channelCount);
|
|
171
|
+
this._rms = new Float64Array(channelCount);
|
|
172
|
+
this._peakHold = new Float64Array(channelCount).fill(-Infinity);
|
|
173
|
+
this._peakHoldDecay = 20; // dB/s default
|
|
174
|
+
this._peakHoldTime = Math.round(sampleRate * 2); // 2s hold
|
|
175
|
+
this._peakHoldCounter = new Float64Array(channelCount);
|
|
176
|
+
this._overCount = new Int32Array(channelCount);
|
|
177
|
+
// IEC integrator
|
|
178
|
+
this._iecIntegrator = new Float64Array(channelCount);
|
|
179
|
+
// VU integrator
|
|
180
|
+
this._vuIntegrator = new Float64Array(channelCount);
|
|
181
|
+
// LUFS - K-weighting
|
|
182
|
+
this._kWeightingState = [];
|
|
183
|
+
this._kShelfStates = [];
|
|
184
|
+
this._kHPStates = [];
|
|
185
|
+
for (let ch = 0; ch < channelCount; ch++) {
|
|
186
|
+
this._kWeightingState.push(new Float64Array(4)); // unused legacy slot
|
|
187
|
+
this._kShelfStates.push(makeBiquadState());
|
|
188
|
+
this._kHPStates.push(makeBiquadState());
|
|
189
|
+
}
|
|
190
|
+
this._initKWeighting();
|
|
191
|
+
// LUFS ring buffers (100ms blocks)
|
|
192
|
+
this._blockSize100ms = Math.round(sampleRate * 0.1);
|
|
193
|
+
this._momentaryLen = 4; // 400ms = 4 * 100ms
|
|
194
|
+
this._shortTermLen = 30; // 3s = 30 * 100ms
|
|
195
|
+
this._momentaryBuffer = [];
|
|
196
|
+
this._shortTermBuffer = [];
|
|
197
|
+
this._lufsBlockAccum = new Float64Array(channelCount);
|
|
198
|
+
for (let ch = 0; ch < channelCount; ch++) {
|
|
199
|
+
this._momentaryBuffer.push(new Float64Array(this._momentaryLen));
|
|
200
|
+
this._shortTermBuffer.push(new Float64Array(this._shortTermLen));
|
|
201
|
+
}
|
|
202
|
+
this._lufsBlockSampleCount = 0;
|
|
203
|
+
this._momentaryWriteIdx = 0;
|
|
204
|
+
this._shortTermWriteIdx = 0;
|
|
205
|
+
this._momentaryFilled = 0;
|
|
206
|
+
this._shortTermFilled = 0;
|
|
207
|
+
// Integrated loudness
|
|
208
|
+
this._integratedSum = 0;
|
|
209
|
+
this._integratedCount = 0;
|
|
210
|
+
this._gatingBlocks = [];
|
|
211
|
+
// True peak
|
|
212
|
+
this._truePeakMax = 0;
|
|
213
|
+
this._tpHistory = [];
|
|
214
|
+
for (let ch = 0; ch < channelCount; ch++) {
|
|
215
|
+
this._tpHistory.push(new Float64Array(TP_FIR_LEN));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// ── K-weighting initialisation ──────────────────────────────────────
|
|
219
|
+
_initKWeighting() {
|
|
220
|
+
this._kShelfCoeffs = designKWeightShelf(this._sampleRate);
|
|
221
|
+
this._kHPCoeffs = designKWeightHP(this._sampleRate);
|
|
222
|
+
}
|
|
223
|
+
// ── IEC coefficient helpers ─────────────────────────────────────────
|
|
224
|
+
/**
|
|
225
|
+
* Compute a single-pole IIR coefficient from an integration time.
|
|
226
|
+
* coeff = exp(-2.2 / (time * sampleRate))
|
|
227
|
+
*
|
|
228
|
+
* A coefficient of ~1 means very slow response (long integration);
|
|
229
|
+
* a coefficient close to 0 means instantaneous tracking.
|
|
230
|
+
*/
|
|
231
|
+
_iecCoeff(timeSec) {
|
|
232
|
+
if (timeSec <= 0)
|
|
233
|
+
return 0;
|
|
234
|
+
return Math.exp(-2.2 / (timeSec * this._sampleRate));
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Return rise and fall coefficients for the current IEC type.
|
|
238
|
+
*/
|
|
239
|
+
_getIecCoeffs() {
|
|
240
|
+
switch (this._type) {
|
|
241
|
+
case MeterType.IEC1_DIN:
|
|
242
|
+
// DIN standard: 1.7s rise, 1.7s fall
|
|
243
|
+
return {
|
|
244
|
+
rise: this._iecCoeff(1.7),
|
|
245
|
+
fall: this._iecCoeff(1.7),
|
|
246
|
+
};
|
|
247
|
+
case MeterType.IEC1_NORDIC:
|
|
248
|
+
// Nordic: ~5ms rise, 1.7s fall
|
|
249
|
+
return {
|
|
250
|
+
rise: this._iecCoeff(0.005),
|
|
251
|
+
fall: this._iecCoeff(1.7),
|
|
252
|
+
};
|
|
253
|
+
case MeterType.IEC2_BBC:
|
|
254
|
+
// BBC PPM: 10ms integration, 2.8s return
|
|
255
|
+
return {
|
|
256
|
+
rise: this._iecCoeff(0.01),
|
|
257
|
+
fall: this._iecCoeff(2.8),
|
|
258
|
+
};
|
|
259
|
+
case MeterType.IEC2_EBU:
|
|
260
|
+
// EBU: 10ms integration, 3.0s return (slightly slower fall)
|
|
261
|
+
return {
|
|
262
|
+
rise: this._iecCoeff(0.01),
|
|
263
|
+
fall: this._iecCoeff(3.0),
|
|
264
|
+
};
|
|
265
|
+
default:
|
|
266
|
+
return { rise: 0, fall: 0 };
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// ── Core Processing ─────────────────────────────────────────────────
|
|
270
|
+
/**
|
|
271
|
+
* Process a single channel of audio samples.
|
|
272
|
+
*/
|
|
273
|
+
process(samples, channel) {
|
|
274
|
+
if (channel < 0 || channel >= this._channelCount)
|
|
275
|
+
return;
|
|
276
|
+
const n = samples.length;
|
|
277
|
+
if (n === 0)
|
|
278
|
+
return;
|
|
279
|
+
// ---- Sample peak & RMS & over count ----------------------------
|
|
280
|
+
let peak = 0;
|
|
281
|
+
let sumSq = 0;
|
|
282
|
+
let overs = 0;
|
|
283
|
+
let consecutiveOver = 0;
|
|
284
|
+
for (let i = 0; i < n; i++) {
|
|
285
|
+
const s = samples[i];
|
|
286
|
+
const abs = Math.abs(s);
|
|
287
|
+
if (abs > peak)
|
|
288
|
+
peak = abs;
|
|
289
|
+
sumSq += s * s;
|
|
290
|
+
if (abs >= 1.0) {
|
|
291
|
+
consecutiveOver++;
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
if (consecutiveOver > overs)
|
|
295
|
+
overs = consecutiveOver;
|
|
296
|
+
consecutiveOver = 0;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (consecutiveOver > overs)
|
|
300
|
+
overs = consecutiveOver;
|
|
301
|
+
const rmsLinear = Math.sqrt(sumSq / n);
|
|
302
|
+
const peakDb = peak > 0 ? LOG10_20 * Math.log(peak) : NEG_INF;
|
|
303
|
+
const rmsDb = rmsLinear > 0 ? LOG10_20 * Math.log(rmsLinear) : NEG_INF;
|
|
304
|
+
this._peaks[channel] = peakDb;
|
|
305
|
+
this._rms[channel] = rmsDb;
|
|
306
|
+
this._overCount[channel] = overs;
|
|
307
|
+
// ---- Peak hold -------------------------------------------------
|
|
308
|
+
if (peakDb > this._peakHold[channel]) {
|
|
309
|
+
this._peakHold[channel] = peakDb;
|
|
310
|
+
this._peakHoldCounter[channel] = this._peakHoldTime;
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
if (this._peakHoldCounter[channel] > 0) {
|
|
314
|
+
this._peakHoldCounter[channel] -= n;
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
// Decay
|
|
318
|
+
const decayAmount = this._peakHoldDecay * (n / this._sampleRate);
|
|
319
|
+
this._peakHold[channel] -= decayAmount;
|
|
320
|
+
if (this._peakHold[channel] < NEG_INF) {
|
|
321
|
+
this._peakHold[channel] = NEG_INF;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
// ---- IEC integration -------------------------------------------
|
|
326
|
+
if (this._type === MeterType.IEC1_DIN ||
|
|
327
|
+
this._type === MeterType.IEC1_NORDIC ||
|
|
328
|
+
this._type === MeterType.IEC2_BBC ||
|
|
329
|
+
this._type === MeterType.IEC2_EBU) {
|
|
330
|
+
const { rise, fall } = this._getIecCoeffs();
|
|
331
|
+
// IEC meters track the absolute value through a single-pole filter
|
|
332
|
+
let integrator = this._iecIntegrator[channel];
|
|
333
|
+
for (let i = 0; i < n; i++) {
|
|
334
|
+
const abs = Math.abs(samples[i]);
|
|
335
|
+
const coeff = abs > integrator ? rise : fall;
|
|
336
|
+
integrator = (1 - coeff) * abs + coeff * integrator;
|
|
337
|
+
}
|
|
338
|
+
this._iecIntegrator[channel] = integrator;
|
|
339
|
+
// Override peak with IEC-filtered value
|
|
340
|
+
const iecDb = integrator > 0 ? LOG10_20 * Math.log(integrator) : NEG_INF;
|
|
341
|
+
this._peaks[channel] = iecDb;
|
|
342
|
+
}
|
|
343
|
+
// ---- VU integration (300ms RMS) --------------------------------
|
|
344
|
+
if (this._type === MeterType.VU) {
|
|
345
|
+
// Single-pole IIR on the squared signal ≈ exponential RMS
|
|
346
|
+
const vuCoeff = Math.exp(-2.2 / (0.3 * this._sampleRate));
|
|
347
|
+
let vuInt = this._vuIntegrator[channel];
|
|
348
|
+
for (let i = 0; i < n; i++) {
|
|
349
|
+
const sq = samples[i] * samples[i];
|
|
350
|
+
vuInt = (1 - vuCoeff) * sq + vuCoeff * vuInt;
|
|
351
|
+
}
|
|
352
|
+
this._vuIntegrator[channel] = vuInt;
|
|
353
|
+
const vuRms = Math.sqrt(vuInt);
|
|
354
|
+
// VU meter: overshoot on transients (~1.5%)
|
|
355
|
+
// Modelled by letting peak slightly bleed into the RMS reading
|
|
356
|
+
const vuLevel = vuRms + 0.015 * (peak - vuRms);
|
|
357
|
+
const vuDb = vuLevel > 0 ? LOG10_20 * Math.log(vuLevel) : NEG_INF;
|
|
358
|
+
this._rms[channel] = vuDb;
|
|
359
|
+
this._peaks[channel] = vuDb; // VU uses unified reading
|
|
360
|
+
}
|
|
361
|
+
// ---- K-metering ------------------------------------------------
|
|
362
|
+
if (this._type === MeterType.K_12 ||
|
|
363
|
+
this._type === MeterType.K_14 ||
|
|
364
|
+
this._type === MeterType.K_20) {
|
|
365
|
+
const ref = this.getKReference();
|
|
366
|
+
// Offset the RMS reading by the K reference
|
|
367
|
+
if (rmsDb > NEG_INF) {
|
|
368
|
+
this._rms[channel] = rmsDb - ref;
|
|
369
|
+
}
|
|
370
|
+
if (peakDb > NEG_INF) {
|
|
371
|
+
this._peaks[channel] = peakDb - ref;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
// ---- LUFS accumulation -----------------------------------------
|
|
375
|
+
if (this._type === MeterType.LUFS) {
|
|
376
|
+
this._processLufsChannel(samples, channel);
|
|
377
|
+
}
|
|
378
|
+
// ---- True peak -------------------------------------------------
|
|
379
|
+
if (this._type === MeterType.TRUE_PEAK || this._type === MeterType.LUFS) {
|
|
380
|
+
this._processTruePeak(samples, channel);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Process a multi-channel block at once.
|
|
385
|
+
* buffer[ch] must contain at least blockSize samples.
|
|
386
|
+
*/
|
|
387
|
+
processBlock(buffer, blockSize) {
|
|
388
|
+
const numCh = Math.min(buffer.length, this._channelCount);
|
|
389
|
+
for (let ch = 0; ch < numCh; ch++) {
|
|
390
|
+
const data = buffer[ch];
|
|
391
|
+
// Slice or use directly depending on length
|
|
392
|
+
if (data.length === blockSize) {
|
|
393
|
+
this.process(data, ch);
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
this.process(data.subarray(0, blockSize), ch);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
// ── LUFS Processing (ITU-R BS.1770-4) ──────────────────────────────
|
|
401
|
+
/**
|
|
402
|
+
* Accumulate K-weighted power for one channel into the 100ms block
|
|
403
|
+
* accumulator. When a full 100ms block is completed, push it into
|
|
404
|
+
* the momentary and short-term ring buffers and perform gating.
|
|
405
|
+
*/
|
|
406
|
+
_processLufsChannel(samples, channel) {
|
|
407
|
+
const shelfC = this._kShelfCoeffs;
|
|
408
|
+
const hpC = this._kHPCoeffs;
|
|
409
|
+
const shelfS = this._kShelfStates[channel];
|
|
410
|
+
const hpS = this._kHPStates[channel];
|
|
411
|
+
let remaining = samples.length;
|
|
412
|
+
let offset = 0;
|
|
413
|
+
while (remaining > 0) {
|
|
414
|
+
const spaceInBlock = this._blockSize100ms - this._lufsBlockSampleCount;
|
|
415
|
+
const toProcess = Math.min(remaining, spaceInBlock);
|
|
416
|
+
let sumSq = 0;
|
|
417
|
+
for (let i = 0; i < toProcess; i++) {
|
|
418
|
+
// K-weighting: high shelf then high-pass
|
|
419
|
+
let s = samples[offset + i];
|
|
420
|
+
s = biquadProcess(shelfC, shelfS, s);
|
|
421
|
+
s = biquadProcess(hpC, hpS, s);
|
|
422
|
+
sumSq += s * s;
|
|
423
|
+
}
|
|
424
|
+
this._lufsBlockAccum[channel] += sumSq;
|
|
425
|
+
offset += toProcess;
|
|
426
|
+
remaining -= toProcess;
|
|
427
|
+
// Only advance the block counter on channel 0 to keep channels in sync
|
|
428
|
+
if (channel === 0) {
|
|
429
|
+
this._lufsBlockSampleCount += toProcess;
|
|
430
|
+
}
|
|
431
|
+
// If this is the last channel and the block is full, commit
|
|
432
|
+
if (channel === this._channelCount - 1 &&
|
|
433
|
+
this._lufsBlockSampleCount >= this._blockSize100ms) {
|
|
434
|
+
this._commitLufsBlock();
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Commit a completed 100ms block into the ring buffers and perform gating.
|
|
440
|
+
*/
|
|
441
|
+
_commitLufsBlock() {
|
|
442
|
+
const numCh = this._channelCount;
|
|
443
|
+
// Write per-channel mean-square into ring buffers
|
|
444
|
+
for (let ch = 0; ch < numCh; ch++) {
|
|
445
|
+
const meanSq = this._lufsBlockAccum[ch] / this._blockSize100ms;
|
|
446
|
+
this._momentaryBuffer[ch][this._momentaryWriteIdx] = meanSq;
|
|
447
|
+
this._shortTermBuffer[ch][this._shortTermWriteIdx] = meanSq;
|
|
448
|
+
}
|
|
449
|
+
this._momentaryWriteIdx = (this._momentaryWriteIdx + 1) % this._momentaryLen;
|
|
450
|
+
this._shortTermWriteIdx = (this._shortTermWriteIdx + 1) % this._shortTermLen;
|
|
451
|
+
if (this._momentaryFilled < this._momentaryLen)
|
|
452
|
+
this._momentaryFilled++;
|
|
453
|
+
if (this._shortTermFilled < this._shortTermLen)
|
|
454
|
+
this._shortTermFilled++;
|
|
455
|
+
// Compute this block's loudness for gating
|
|
456
|
+
let blockPower = 0;
|
|
457
|
+
for (let ch = 0; ch < numCh; ch++) {
|
|
458
|
+
const w = this._channelWeight(ch);
|
|
459
|
+
blockPower += w * (this._lufsBlockAccum[ch] / this._blockSize100ms);
|
|
460
|
+
}
|
|
461
|
+
const blockLoudness = blockPower > 0
|
|
462
|
+
? -0.691 + 10 * Math.log10(blockPower)
|
|
463
|
+
: -Infinity;
|
|
464
|
+
this._gatingBlocks.push(blockLoudness);
|
|
465
|
+
// Reset accumulators
|
|
466
|
+
this._lufsBlockAccum.fill(0);
|
|
467
|
+
this._lufsBlockSampleCount = 0;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* ITU-R BS.1770 channel weighting.
|
|
471
|
+
* Front channels = 1.0, surround channels (index >= 3) = 1.41 (~+1.5 dB).
|
|
472
|
+
* For stereo (2 channels) everything is 1.0.
|
|
473
|
+
*/
|
|
474
|
+
_channelWeight(ch) {
|
|
475
|
+
if (this._channelCount <= 3)
|
|
476
|
+
return 1.0;
|
|
477
|
+
// For 5.1 layout: 0=L 1=R 2=C 3=Ls 4=Rs (5=LFE excluded)
|
|
478
|
+
return ch >= 3 ? 1.41 : 1.0;
|
|
479
|
+
}
|
|
480
|
+
// ── True Peak (ITU-R BS.1770, 4x oversampling) ─────────────────────
|
|
481
|
+
_processTruePeak(samples, channel) {
|
|
482
|
+
const history = this._tpHistory[channel];
|
|
483
|
+
let maxPeak = 0;
|
|
484
|
+
for (let i = 0; i < samples.length; i++) {
|
|
485
|
+
// Shift history buffer
|
|
486
|
+
for (let t = TP_FIR_LEN - 1; t > 0; t--) {
|
|
487
|
+
history[t] = history[t - 1];
|
|
488
|
+
}
|
|
489
|
+
history[0] = samples[i];
|
|
490
|
+
// Evaluate 4 polyphase sub-filters
|
|
491
|
+
for (let phase = 0; phase < 4; phase++) {
|
|
492
|
+
const taps = TP_FIR_PHASES[phase];
|
|
493
|
+
let sum = 0;
|
|
494
|
+
for (let t = 0; t < TP_FIR_LEN; t++) {
|
|
495
|
+
sum += history[t] * taps[t];
|
|
496
|
+
}
|
|
497
|
+
const abs = Math.abs(sum);
|
|
498
|
+
if (abs > maxPeak)
|
|
499
|
+
maxPeak = abs;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
if (maxPeak > this._truePeakMax) {
|
|
503
|
+
this._truePeakMax = maxPeak;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
// ── Readings ────────────────────────────────────────────────────────
|
|
507
|
+
getReading(channel) {
|
|
508
|
+
if (channel < 0 || channel >= this._channelCount) {
|
|
509
|
+
return { peak: NEG_INF, rms: NEG_INF, peakHold: NEG_INF, overCount: 0 };
|
|
510
|
+
}
|
|
511
|
+
return {
|
|
512
|
+
peak: this._peaks[channel],
|
|
513
|
+
rms: this._rms[channel],
|
|
514
|
+
peakHold: this._peakHold[channel],
|
|
515
|
+
overCount: this._overCount[channel],
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
getLUFSReading() {
|
|
519
|
+
const momentary = this._computeLufsWindow(this._momentaryBuffer, this._momentaryLen, this._momentaryFilled, this._momentaryWriteIdx);
|
|
520
|
+
const shortTerm = this._computeLufsWindow(this._shortTermBuffer, this._shortTermLen, this._shortTermFilled, this._shortTermWriteIdx);
|
|
521
|
+
const integrated = this._computeIntegratedLoudness();
|
|
522
|
+
const range = this._computeLoudnessRange();
|
|
523
|
+
const truePeak = this._truePeakMax > 0
|
|
524
|
+
? LOG10_20 * Math.log(this._truePeakMax)
|
|
525
|
+
: NEG_INF;
|
|
526
|
+
return { momentary, shortTerm, integrated, range, truePeak };
|
|
527
|
+
}
|
|
528
|
+
getAllChannelReadings() {
|
|
529
|
+
const readings = [];
|
|
530
|
+
for (let ch = 0; ch < this._channelCount; ch++) {
|
|
531
|
+
readings.push(this.getReading(ch));
|
|
532
|
+
}
|
|
533
|
+
return readings;
|
|
534
|
+
}
|
|
535
|
+
// ── LUFS computation helpers ────────────────────────────────────────
|
|
536
|
+
/**
|
|
537
|
+
* Compute the loudness of a sliding window from ring-buffer data.
|
|
538
|
+
*/
|
|
539
|
+
_computeLufsWindow(buffers, windowLen, filled, writeIdx) {
|
|
540
|
+
if (filled === 0)
|
|
541
|
+
return NEG_INF;
|
|
542
|
+
const numBlocks = Math.min(filled, windowLen);
|
|
543
|
+
let totalPower = 0;
|
|
544
|
+
for (let ch = 0; ch < this._channelCount; ch++) {
|
|
545
|
+
const w = this._channelWeight(ch);
|
|
546
|
+
const buf = buffers[ch];
|
|
547
|
+
let chSum = 0;
|
|
548
|
+
for (let b = 0; b < numBlocks; b++) {
|
|
549
|
+
const idx = (writeIdx - 1 - b + windowLen) % windowLen;
|
|
550
|
+
chSum += buf[idx];
|
|
551
|
+
}
|
|
552
|
+
totalPower += w * (chSum / numBlocks);
|
|
553
|
+
}
|
|
554
|
+
return totalPower > 0
|
|
555
|
+
? -0.691 + 10 * Math.log10(totalPower)
|
|
556
|
+
: NEG_INF;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* ITU-R BS.1770-4 gated integrated loudness.
|
|
560
|
+
* 1. Absolute gate at -70 LUFS
|
|
561
|
+
* 2. Relative gate at -10 LU below the absolute-gated mean
|
|
562
|
+
*/
|
|
563
|
+
_computeIntegratedLoudness() {
|
|
564
|
+
const blocks = this._gatingBlocks;
|
|
565
|
+
if (blocks.length === 0)
|
|
566
|
+
return NEG_INF;
|
|
567
|
+
// Step 1: Absolute gate (-70 LUFS)
|
|
568
|
+
const absThreshold = -70;
|
|
569
|
+
let absGatedSum = 0;
|
|
570
|
+
let absGatedCount = 0;
|
|
571
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
572
|
+
if (blocks[i] > absThreshold) {
|
|
573
|
+
absGatedSum += Math.pow(10, blocks[i] / 10);
|
|
574
|
+
absGatedCount++;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
if (absGatedCount === 0)
|
|
578
|
+
return NEG_INF;
|
|
579
|
+
const absGatedMean = -0.691 + 10 * Math.log10(absGatedSum / absGatedCount);
|
|
580
|
+
// Step 2: Relative gate (-10 LU below absolute-gated mean)
|
|
581
|
+
const relThreshold = absGatedMean - 10;
|
|
582
|
+
let relGatedSum = 0;
|
|
583
|
+
let relGatedCount = 0;
|
|
584
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
585
|
+
if (blocks[i] > relThreshold) {
|
|
586
|
+
relGatedSum += Math.pow(10, blocks[i] / 10);
|
|
587
|
+
relGatedCount++;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
if (relGatedCount === 0)
|
|
591
|
+
return NEG_INF;
|
|
592
|
+
return -0.691 + 10 * Math.log10(relGatedSum / relGatedCount);
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* EBU R128 Loudness Range (LRA).
|
|
596
|
+
* Computed as the difference between the 95th and 10th percentiles
|
|
597
|
+
* of the short-term loudness distribution (after gating).
|
|
598
|
+
*/
|
|
599
|
+
_computeLoudnessRange() {
|
|
600
|
+
if (this._gatingBlocks.length < 2)
|
|
601
|
+
return 0;
|
|
602
|
+
// We need short-term loudness values (3s window).
|
|
603
|
+
// Approximate by using overlapping 30-block windows over the gating blocks.
|
|
604
|
+
const stBlocks = [];
|
|
605
|
+
const stLen = this._shortTermLen; // 30 blocks = 3s
|
|
606
|
+
for (let i = stLen - 1; i < this._gatingBlocks.length; i++) {
|
|
607
|
+
let sum = 0;
|
|
608
|
+
let count = 0;
|
|
609
|
+
for (let j = i - stLen + 1; j <= i; j++) {
|
|
610
|
+
sum += Math.pow(10, this._gatingBlocks[j] / 10);
|
|
611
|
+
count++;
|
|
612
|
+
}
|
|
613
|
+
const loudness = count > 0
|
|
614
|
+
? -0.691 + 10 * Math.log10(sum / count)
|
|
615
|
+
: NEG_INF;
|
|
616
|
+
stBlocks.push(loudness);
|
|
617
|
+
}
|
|
618
|
+
if (stBlocks.length < 2)
|
|
619
|
+
return 0;
|
|
620
|
+
// Absolute gate at -70 LUFS
|
|
621
|
+
const absGated = stBlocks.filter(l => l > -70);
|
|
622
|
+
if (absGated.length < 2)
|
|
623
|
+
return 0;
|
|
624
|
+
// Relative gate: mean of absolute-gated, then -20 LU
|
|
625
|
+
let absSum = 0;
|
|
626
|
+
for (const l of absGated)
|
|
627
|
+
absSum += Math.pow(10, l / 10);
|
|
628
|
+
const absMean = -0.691 + 10 * Math.log10(absSum / absGated.length);
|
|
629
|
+
const relThreshold = absMean - 20;
|
|
630
|
+
const relGated = absGated.filter(l => l > relThreshold);
|
|
631
|
+
if (relGated.length < 2)
|
|
632
|
+
return 0;
|
|
633
|
+
relGated.sort((a, b) => a - b);
|
|
634
|
+
// 10th and 95th percentile
|
|
635
|
+
const lo = relGated[Math.floor(relGated.length * 0.10)];
|
|
636
|
+
const hi = relGated[Math.floor(relGated.length * 0.95)];
|
|
637
|
+
return hi - lo;
|
|
638
|
+
}
|
|
639
|
+
// ── Reset ───────────────────────────────────────────────────────────
|
|
640
|
+
reset() {
|
|
641
|
+
this._peaks.fill(0);
|
|
642
|
+
this._rms.fill(0);
|
|
643
|
+
this._peakHold.fill(NEG_INF);
|
|
644
|
+
this._peakHoldCounter.fill(0);
|
|
645
|
+
this._overCount.fill(0);
|
|
646
|
+
this._iecIntegrator.fill(0);
|
|
647
|
+
this._vuIntegrator.fill(0);
|
|
648
|
+
this._truePeakMax = 0;
|
|
649
|
+
for (let ch = 0; ch < this._channelCount; ch++) {
|
|
650
|
+
this._kShelfStates[ch] = makeBiquadState();
|
|
651
|
+
this._kHPStates[ch] = makeBiquadState();
|
|
652
|
+
this._momentaryBuffer[ch].fill(0);
|
|
653
|
+
this._shortTermBuffer[ch].fill(0);
|
|
654
|
+
this._lufsBlockAccum[ch] = 0;
|
|
655
|
+
this._tpHistory[ch].fill(0);
|
|
656
|
+
}
|
|
657
|
+
this._lufsBlockSampleCount = 0;
|
|
658
|
+
this._momentaryWriteIdx = 0;
|
|
659
|
+
this._shortTermWriteIdx = 0;
|
|
660
|
+
this._momentaryFilled = 0;
|
|
661
|
+
this._shortTermFilled = 0;
|
|
662
|
+
this._integratedSum = 0;
|
|
663
|
+
this._integratedCount = 0;
|
|
664
|
+
this._gatingBlocks = [];
|
|
665
|
+
}
|
|
666
|
+
resetPeakHold() {
|
|
667
|
+
this._peakHold.fill(NEG_INF);
|
|
668
|
+
this._peakHoldCounter.fill(0);
|
|
669
|
+
}
|
|
670
|
+
// ── Configuration ───────────────────────────────────────────────────
|
|
671
|
+
setType(type) {
|
|
672
|
+
if (this._type !== type) {
|
|
673
|
+
this._type = type;
|
|
674
|
+
this.reset();
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
setPeakHoldTime(seconds) {
|
|
678
|
+
this._peakHoldTime = Math.round(this._sampleRate * Math.max(0, seconds));
|
|
679
|
+
}
|
|
680
|
+
setPeakHoldDecay(dbPerSecond) {
|
|
681
|
+
this._peakHoldDecay = Math.max(0, dbPerSecond);
|
|
682
|
+
}
|
|
683
|
+
// ── K-meter helpers ─────────────────────────────────────────────────
|
|
684
|
+
/**
|
|
685
|
+
* Returns the reference level offset (in dB) for the current K-type.
|
|
686
|
+
* K-12 => -12, K-14 => -14, K-20 => -20.
|
|
687
|
+
* Non-K types return 0.
|
|
688
|
+
*/
|
|
689
|
+
getKReference() {
|
|
690
|
+
switch (this._type) {
|
|
691
|
+
case MeterType.K_12: return -12;
|
|
692
|
+
case MeterType.K_14: return -14;
|
|
693
|
+
case MeterType.K_20: return -20;
|
|
694
|
+
default: return 0;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
// ── Static Utilities ────────────────────────────────────────────────
|
|
698
|
+
static linearToDb(linear) {
|
|
699
|
+
return linear > 0 ? LOG10_20 * Math.log(linear) : NEG_INF;
|
|
700
|
+
}
|
|
701
|
+
static dbToLinear(db) {
|
|
702
|
+
if (db === NEG_INF)
|
|
703
|
+
return 0;
|
|
704
|
+
return Math.exp(db / LOG10_20);
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* IEC 60268-10 scale mapping: converts a dB value to a 0-1 range
|
|
708
|
+
* suitable for drawing meter graphics.
|
|
709
|
+
*
|
|
710
|
+
* The piecewise curve is defined by the standard breakpoints:
|
|
711
|
+
* -70 dB = 0.0
|
|
712
|
+
* -60 dB = 0.05
|
|
713
|
+
* -50 dB = 0.075
|
|
714
|
+
* -40 dB = 0.15
|
|
715
|
+
* -30 dB = 0.3
|
|
716
|
+
* -20 dB = 0.5
|
|
717
|
+
* -10 dB = 0.75
|
|
718
|
+
* -5 dB = 0.875
|
|
719
|
+
* 0 dB = 1.0
|
|
720
|
+
*
|
|
721
|
+
* The meterType parameter is accepted for future per-type customisation
|
|
722
|
+
* but currently all IEC types share the same display curve.
|
|
723
|
+
*/
|
|
724
|
+
static iecScale(dbValue, _meterType) {
|
|
725
|
+
if (dbValue < -70.0)
|
|
726
|
+
return 0.0;
|
|
727
|
+
if (dbValue > 0.0)
|
|
728
|
+
return 1.0;
|
|
729
|
+
// Breakpoints: [dB, displayValue]
|
|
730
|
+
const bp = [
|
|
731
|
+
[-70, 0.0],
|
|
732
|
+
[-60, 0.05],
|
|
733
|
+
[-50, 0.075],
|
|
734
|
+
[-40, 0.15],
|
|
735
|
+
[-30, 0.3],
|
|
736
|
+
[-20, 0.5],
|
|
737
|
+
[-10, 0.75],
|
|
738
|
+
[-5, 0.875],
|
|
739
|
+
[0, 1.0],
|
|
740
|
+
];
|
|
741
|
+
// Find the two surrounding breakpoints and linearly interpolate
|
|
742
|
+
for (let i = 1; i < bp.length; i++) {
|
|
743
|
+
if (dbValue <= bp[i][0]) {
|
|
744
|
+
const [db0, v0] = bp[i - 1];
|
|
745
|
+
const [db1, v1] = bp[i];
|
|
746
|
+
const t = (dbValue - db0) / (db1 - db0);
|
|
747
|
+
return v0 + t * (v1 - v0);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
return 1.0;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
//# sourceMappingURL=MeterDSP.js.map
|