@octoseq/mir 0.1.0-main.994cb4e → 0.1.0-main.c336fba
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/dist/index.d.ts +4 -4
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/dist/{runMir-CWsxri61.d.ts → runMir-8PX3FuZC.d.ts} +1 -1
- package/dist/runner/runMir.d.ts +2 -2
- package/dist/runner/workerProtocol.d.ts +1 -1
- package/dist/{types-D6eBRofe.d.ts → types-uMUczpax.d.ts} +2 -0
- package/package.json +1 -1
- package/src/dsp/bandProposal.ts +29 -2
- package/src/types.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { B as BeatCandidate, T as TempoHypothesis, P as PhaseAlignmentConfig, a as PhaseHypothesis, M as MusicalTimeSegment, b as BeatPosition, c as MusicalTimeStructure, d as BeatGrid, F as FrequencySegment, e as FrequencyBand, f as FrequencyBandStructure, g as FrequencyBoundsAtTime, h as FrequencyKeyframe, i as BandMirFunctionId, j as BandMir1DResult, C as CqtConfig, k as CqtSpectrogram, l as MirRunMeta, m as CqtSignalResult, n as CqtSignalId, o as BandProposalConfig, p as BandProposalResult } from './types-
|
|
2
|
-
export { I as BandMirDiagnostics, K as BandProposal, J as BandProposalSource, y as BeatCandidateSource, z as BeatCandidatesResult, H as FrequencyBandProvenance, G as FrequencyBandTimeScope, s as Mir1DResult, t as Mir2DResult, x as MirAudioPayload, q as MirBackend, v as MirFunctionId, u as MirResult, w as MirRunRequest, r as MirRunTimings, E as MusicalTimeProvenance, D as TempoHypothesesResult, A as TempoHypothesisEvidence } from './types-
|
|
3
|
-
import { S as Spectrogram, M as MirGPU, A as AudioBufferLike$1 } from './runMir-
|
|
4
|
-
export { a as SpectrogramConfig, r as runMir, s as spectrogram } from './runMir-
|
|
1
|
+
import { B as BeatCandidate, T as TempoHypothesis, P as PhaseAlignmentConfig, a as PhaseHypothesis, M as MusicalTimeSegment, b as BeatPosition, c as MusicalTimeStructure, d as BeatGrid, F as FrequencySegment, e as FrequencyBand, f as FrequencyBandStructure, g as FrequencyBoundsAtTime, h as FrequencyKeyframe, i as BandMirFunctionId, j as BandMir1DResult, C as CqtConfig, k as CqtSpectrogram, l as MirRunMeta, m as CqtSignalResult, n as CqtSignalId, o as BandProposalConfig, p as BandProposalResult } from './types-uMUczpax.js';
|
|
2
|
+
export { I as BandMirDiagnostics, K as BandProposal, J as BandProposalSource, y as BeatCandidateSource, z as BeatCandidatesResult, H as FrequencyBandProvenance, G as FrequencyBandTimeScope, s as Mir1DResult, t as Mir2DResult, x as MirAudioPayload, q as MirBackend, v as MirFunctionId, u as MirResult, w as MirRunRequest, r as MirRunTimings, E as MusicalTimeProvenance, D as TempoHypothesesResult, A as TempoHypothesisEvidence } from './types-uMUczpax.js';
|
|
3
|
+
import { S as Spectrogram, M as MirGPU, A as AudioBufferLike$1 } from './runMir-8PX3FuZC.js';
|
|
4
|
+
export { a as SpectrogramConfig, r as runMir, s as spectrogram } from './runMir-8PX3FuZC.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Spectral centroid per frame (Hz).
|
package/dist/index.js
CHANGED
|
@@ -1047,6 +1047,7 @@ var PROPOSAL_DEFAULTS = {
|
|
|
1047
1047
|
maxProposals: 8,
|
|
1048
1048
|
minSalience: 0.3,
|
|
1049
1049
|
minSeparationOctaves: 0.5,
|
|
1050
|
+
minBandwidthHz: 20,
|
|
1050
1051
|
analysisWindow: 0
|
|
1051
1052
|
// 0 = full track
|
|
1052
1053
|
};
|
|
@@ -1090,7 +1091,7 @@ function findLocalMaxima(values, minNeighborDistance = 3) {
|
|
|
1090
1091
|
}
|
|
1091
1092
|
return peaks;
|
|
1092
1093
|
}
|
|
1093
|
-
function computeBandwidth(values, peakBin, cqt) {
|
|
1094
|
+
function computeBandwidth(values, peakBin, cqt, minBandwidthHz) {
|
|
1094
1095
|
const peakMag = values[peakBin] ?? 0;
|
|
1095
1096
|
const threshold = peakMag * 0.707;
|
|
1096
1097
|
let lowBin = peakBin;
|
|
@@ -1101,6 +1102,25 @@ function computeBandwidth(values, peakBin, cqt) {
|
|
|
1101
1102
|
while (highBin < values.length - 1 && (values[highBin + 1] ?? 0) >= threshold) {
|
|
1102
1103
|
highBin++;
|
|
1103
1104
|
}
|
|
1105
|
+
if (minBandwidthHz > 0) {
|
|
1106
|
+
const maxExpansions = values.length;
|
|
1107
|
+
for (let i = 0; i < maxExpansions; i++) {
|
|
1108
|
+
const lowHzTmp = cqtBinToHz(lowBin, cqt.config);
|
|
1109
|
+
const highHzTmp = cqtBinToHz(highBin, cqt.config);
|
|
1110
|
+
if (highHzTmp - lowHzTmp >= minBandwidthHz) break;
|
|
1111
|
+
const canExpandLow = lowBin > 0;
|
|
1112
|
+
const canExpandHigh = highBin < values.length - 1;
|
|
1113
|
+
if (!canExpandLow && !canExpandHigh) break;
|
|
1114
|
+
if (canExpandLow && canExpandHigh) {
|
|
1115
|
+
lowBin--;
|
|
1116
|
+
highBin++;
|
|
1117
|
+
} else if (canExpandLow) {
|
|
1118
|
+
lowBin--;
|
|
1119
|
+
} else {
|
|
1120
|
+
highBin++;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1104
1124
|
const lowHz = cqtBinToHz(lowBin, cqt.config);
|
|
1105
1125
|
const highHz = cqtBinToHz(highBin, cqt.config);
|
|
1106
1126
|
const bandwidthOctaves = Math.log2(highHz / lowHz);
|
|
@@ -1138,7 +1158,7 @@ function detectSpectralPeaks(cqt, config) {
|
|
|
1138
1158
|
const peakIndices = findLocalMaxima(avgSpectrum, Math.max(3, minBinDistance / 2));
|
|
1139
1159
|
const peaks = [];
|
|
1140
1160
|
for (const binIndex of peakIndices) {
|
|
1141
|
-
const bw = computeBandwidth(avgSpectrum, binIndex, cqt);
|
|
1161
|
+
const bw = computeBandwidth(avgSpectrum, binIndex, cqt, config.minBandwidthHz);
|
|
1142
1162
|
peaks.push({
|
|
1143
1163
|
binIndex,
|
|
1144
1164
|
centerHz: cqtBinToHz(binIndex, cqt.config),
|