Compare commits
10 Commits
882cd76fec
...
aacd6bbd81
| Author | SHA1 | Date | |
|---|---|---|---|
| aacd6bbd81 | |||
| 7f419656d8 | |||
| 2493324f1a | |||
| 1d47ef5e69 | |||
| 94fbe994dd | |||
| 3f4260fab7 | |||
| 79ae02f53a | |||
| 481e2b8902 | |||
| a5f0959752 | |||
| fce646065a |
10
AGENTS.md
10
AGENTS.md
@@ -1,10 +0,0 @@
|
||||
# EP133 Tool Agent Guidelines
|
||||
|
||||
- never comment the code, except biome or linter comments
|
||||
- leave MY comments as is
|
||||
- if you detect the changes in the code you've just made - accept it
|
||||
- don't use responsive tailwind selector until I say so
|
||||
- when adding a new library always check the official docs for the installed version
|
||||
- always use brackets for IF statement, even for one line expression
|
||||
- don't rebuild the project after updating the code, check for correct typing
|
||||
- never commit any changes to git
|
||||
@@ -602,31 +602,28 @@ export function collectEffects(files: TarFile[]) {
|
||||
};
|
||||
}
|
||||
|
||||
const effectType = fxFile.data[4];
|
||||
const param1 = bytesToFloat32(
|
||||
fxFile.data.slice(12 + (effectType - 1) * 4, 16 + (effectType - 1) * 4),
|
||||
);
|
||||
const param2 = bytesToFloat32(
|
||||
fxFile.data.slice(76 + (effectType - 1) * 4, 80 + (effectType - 1) * 4),
|
||||
);
|
||||
const fxData = fxFile.data;
|
||||
const effectType = fxData[4];
|
||||
const param1 = bytesToFloat32(fxData.slice(12 + (effectType - 1) * 4, 16 + (effectType - 1) * 4));
|
||||
const param2 = bytesToFloat32(fxData.slice(76 + (effectType - 1) * 4, 80 + (effectType - 1) * 4));
|
||||
const outputCompressor =
|
||||
fxFile.data.length >= 144
|
||||
fxData.length >= 144
|
||||
? {
|
||||
drive: bytesToFloat32(fxFile.data.slice(136, 140)),
|
||||
speed: bytesToFloat32(fxFile.data.slice(140, 144)),
|
||||
drive: bytesToFloat32(fxData.slice(136, 140)),
|
||||
speed: bytesToFloat32(fxData.slice(140, 144)),
|
||||
}
|
||||
: undefined;
|
||||
const sidechain =
|
||||
fxFile.data.length >= 152
|
||||
fxData.length >= 152
|
||||
? {
|
||||
length: bytesToFloat32(fxFile.data.slice(144, 148)),
|
||||
shape: bytesToFloat32(fxFile.data.slice(148, 152)),
|
||||
length: bytesToFloat32(fxData.slice(144, 148)),
|
||||
shape: bytesToFloat32(fxData.slice(148, 152)),
|
||||
routing:
|
||||
fxFile.data.length >= 160
|
||||
fxData.length >= 160
|
||||
? (Object.fromEntries(
|
||||
projectGroups.map((group, index) => {
|
||||
const offset = 152 + index * 2;
|
||||
const rawValue = fxFile.data[offset] | (fxFile.data[offset + 1] << 8);
|
||||
const rawValue = fxData[offset] | (fxData[offset + 1] << 8);
|
||||
const routing: SidechainGroupRouting = {
|
||||
rawValue,
|
||||
sourcePadMask: rawValue & 0x0fff,
|
||||
@@ -640,7 +637,7 @@ export function collectEffects(files: TarFile[]) {
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
rawData: fxFile.data,
|
||||
rawData: fxData,
|
||||
effectType,
|
||||
param1,
|
||||
param2,
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
TimeSignature,
|
||||
} from '../../types/types';
|
||||
import { getSampleName } from '../exporters/utils';
|
||||
import { findPad, findSoundByPad, findSoundIdByPad } from '../utils';
|
||||
import { findPad, findSoundByPad, findSoundIdByPad, padToPadCode } from '../utils';
|
||||
|
||||
const PROJECT_GROUPS: Group[] = ['a', 'b', 'c', 'd'];
|
||||
|
||||
@@ -461,11 +461,11 @@ function abletonTransformer(data: ProjectRawData, exporterParams: ExporterParams
|
||||
|
||||
if (exporterParams.exportAllPadsWithSamples) {
|
||||
PROJECT_GROUPS.forEach((group) => {
|
||||
data.pads[group].forEach((pad, index) => {
|
||||
data.pads[group].forEach((pad) => {
|
||||
if (pad.soundId <= 0) {
|
||||
return;
|
||||
}
|
||||
const padCode = `${group}${index}` as PadCode;
|
||||
const padCode = padToPadCode(pad);
|
||||
if (trackLookup.has(padCode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
TimeSignature,
|
||||
} from '../../types/types';
|
||||
import { getSampleName } from '../exporters/utils';
|
||||
import { findPad, findSoundByPad, findSoundIdByPad } from '../utils';
|
||||
import { findPad, findSoundByPad, findSoundIdByPad, padToPadCode } from '../utils';
|
||||
|
||||
export type DawData = {
|
||||
tracks: DawTrack[];
|
||||
@@ -133,12 +133,12 @@ function dawProjectTransformer(data: ProjectRawData, exporterParams: ExporterPar
|
||||
|
||||
if (exporterParams.exportAllPadsWithSamples) {
|
||||
for (const group in pads) {
|
||||
pads[group].forEach((pad, index) => {
|
||||
pads[group].forEach((pad) => {
|
||||
if (pad.soundId <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const padCode = `${group}${index}` as PadCode;
|
||||
const padCode = padToPadCode(pad);
|
||||
if (tracks.some((t) => t.padCode === padCode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as Sentry from '@sentry/react';
|
||||
import { ExporterParams, Note, ProjectRawData } from '../../types/types';
|
||||
import { getQuarterNotesPerBar, TICKS_PER_BEAT } from '../exporters/utils';
|
||||
import { findSoundByPad } from '../utils';
|
||||
import { findSoundByPad, padToPadCode } from '../utils';
|
||||
|
||||
export type MidiData = {
|
||||
tracks: MidiTrack[];
|
||||
@@ -71,12 +71,12 @@ function midiTransformer(data: ProjectRawData, exporterParams: ExporterParams) {
|
||||
|
||||
if (exporterParams.exportAllPadsWithSamples) {
|
||||
for (const group in pads) {
|
||||
pads[group].forEach((pad, index) => {
|
||||
pads[group].forEach((pad) => {
|
||||
if (pad.soundId <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const padCode = `${group}${index}`;
|
||||
const padCode = padToPadCode(pad);
|
||||
if (midiTracks.some((t) => t.padCode === padCode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
TimeSignature,
|
||||
} from '../../types/types';
|
||||
import { getSampleName } from '../exporters/utils';
|
||||
import { findPad, findSoundByPad, findSoundIdByPad } from '../utils';
|
||||
import { findPad, findSoundByPad, findSoundIdByPad, padToPadCode } from '../utils';
|
||||
|
||||
export type RprData = {
|
||||
tracks: RprTrack[];
|
||||
@@ -91,12 +91,12 @@ export function reaperTransform(data: ProjectRawData, exporterParams: ExporterPa
|
||||
|
||||
if (exporterParams.exportAllPadsWithSamples) {
|
||||
for (const group in pads) {
|
||||
pads[group].forEach((pad, index) => {
|
||||
pads[group].forEach((pad) => {
|
||||
if (pad.soundId <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const padCode = `${group}${index}` as PadCode;
|
||||
const padCode = padToPadCode(pad);
|
||||
if (tracks.some((t) => t.padCode === padCode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as Sentry from '@sentry/react';
|
||||
import { Note, Pad, ProjectRawData } from '../../types/types';
|
||||
import { getSampleName } from '../exporters/utils';
|
||||
import { noteNumberToName } from '../parsers';
|
||||
import { findPad, findSoundByPad, findSoundIdByPad } from '../utils';
|
||||
import { findPad, findSoundByPad, findSoundIdByPad, padToPadCode } from '../utils';
|
||||
|
||||
export type ViewNote = Note & { name: string };
|
||||
|
||||
@@ -62,9 +62,9 @@ function webViewTransformer(data: ProjectRawData): ViewData {
|
||||
|
||||
// also add pads that have samples assigned (even without patterns)
|
||||
for (const group in pads) {
|
||||
pads[group].forEach((pad, index) => {
|
||||
pads[group].forEach((pad) => {
|
||||
if (pad.soundId > 0) {
|
||||
usedPads.add(`${group}${index}`);
|
||||
usedPads.add(padToPadCode(pad));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { Pad, Sound } from '../types/types';
|
||||
import { Pad, PadCode, Sound } from '../types/types';
|
||||
import { PAD_DISPLAY_FROM_INDEX } from './constants';
|
||||
|
||||
export function findPad(pad: string, pads: Record<string, Pad[]>) {
|
||||
const group = pad[0];
|
||||
const padNumber = parseInt(pad.slice(1), 10);
|
||||
const padData = pads[group][padNumber];
|
||||
const source = parseInt(pad.slice(1), 10);
|
||||
const padData = pads[group]?.find((candidate) => candidate.pad === source + 1);
|
||||
|
||||
return padData;
|
||||
}
|
||||
|
||||
export function padToPadCode(pad: Pad): PadCode {
|
||||
return `${pad.group}${pad.pad - 1}` as PadCode;
|
||||
}
|
||||
|
||||
export function findSoundIdByPad(pad: string, pads: Record<string, Pad[]>) {
|
||||
const padData = findPad(pad, pads);
|
||||
|
||||
|
||||
@@ -39,6 +39,16 @@ test('parses output compressor state from a 144-byte file without sidechain stat
|
||||
assert.equal(effects.sidechain, undefined);
|
||||
});
|
||||
|
||||
test('parses sidechain controls from a 152-byte file without inventing routing', () => {
|
||||
const fixture = effectsFile(152);
|
||||
fixture.view.setFloat32(144, 0.25, true);
|
||||
fixture.view.setFloat32(148, 0.75, true);
|
||||
|
||||
const effects = collectEffects([fixture.file]);
|
||||
|
||||
assert.deepEqual(effects.sidechain, { length: 0.25, shape: 0.75, routing: undefined });
|
||||
});
|
||||
|
||||
test('parses P07-like output dynamics and sidechain state from a 160-byte file', () => {
|
||||
const fixture = effectsFile(160);
|
||||
fixture.view.setFloat32(32, 0.5, true);
|
||||
|
||||
85
tests/sparse-pads.test.ts
Normal file
85
tests/sparse-pads.test.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { collectPads } from '../src/lib/parsers';
|
||||
import abletonTransformer from '../src/lib/transformers/ableton';
|
||||
import midiTransformer from '../src/lib/transformers/midi';
|
||||
import { TarFile } from '../src/lib/untar';
|
||||
import { findPad, padToPadCode } from '../src/lib/utils';
|
||||
import { EffectType, FaderParam, Group, GroupFaderParam, ProjectRawData } from '../src/types/types';
|
||||
|
||||
function faderParams(): GroupFaderParam {
|
||||
return Object.fromEntries(
|
||||
(['a', 'b', 'c', 'd'] as Group[]).map((group) => [
|
||||
group,
|
||||
Object.fromEntries(Array.from({ length: 12 }, (_, parameter) => [parameter, -1])),
|
||||
]),
|
||||
) as GroupFaderParam;
|
||||
}
|
||||
|
||||
function sparseProject(): ProjectRawData {
|
||||
const rawPad = new Uint8Array(27);
|
||||
rawPad[1] = 202;
|
||||
rawPad[16] = 100;
|
||||
rawPad[20] = 255;
|
||||
rawPad[24] = 60;
|
||||
const pads = collectPads([new TarFile('pads/a/p02', rawPad.length, rawPad)], []);
|
||||
const params = faderParams();
|
||||
|
||||
return {
|
||||
pads,
|
||||
groupPatterns: [],
|
||||
scenes: [
|
||||
{
|
||||
number: 1,
|
||||
name: '01',
|
||||
patternNumbers: { a: 0, b: 0, c: 0, d: 0 },
|
||||
timeSignature: { numerator: 4, denominator: 4 },
|
||||
patterns: [],
|
||||
patternEvents: {},
|
||||
},
|
||||
],
|
||||
songPositions: [],
|
||||
settings: {
|
||||
bpm: 120,
|
||||
scale: 0,
|
||||
rootNote: 0,
|
||||
groupFaderParams: params,
|
||||
faderAssignment: {
|
||||
a: FaderParam.LVL,
|
||||
b: FaderParam.LVL,
|
||||
c: FaderParam.LVL,
|
||||
d: FaderParam.LVL,
|
||||
},
|
||||
rawData: new Uint8Array(),
|
||||
},
|
||||
effects: {
|
||||
rawData: new Uint8Array(),
|
||||
effectType: EffectType.Off,
|
||||
param1: 0,
|
||||
param2: 0,
|
||||
},
|
||||
sounds: [],
|
||||
projectFile: {} as File,
|
||||
scenesSettings: { timeSignature: { numerator: 4, denominator: 4 } },
|
||||
};
|
||||
}
|
||||
|
||||
test('keeps physical p02 on zero-based pattern source 1 when p01 is omitted', () => {
|
||||
const data = sparseProject();
|
||||
const physicalPad = data.pads.a[0];
|
||||
|
||||
assert.equal(physicalPad.pad, 2);
|
||||
assert.equal(findPad('a0', data.pads), undefined);
|
||||
assert.equal(findPad('a1', data.pads), physicalPad);
|
||||
assert.equal(padToPadCode(physicalPad), 'a1');
|
||||
|
||||
const params = { exportAllPadsWithSamples: true, keepUnusedPatterns: false };
|
||||
assert.deepEqual(
|
||||
abletonTransformer(data, params).tracks.map((track) => track.padCode),
|
||||
['a1'],
|
||||
);
|
||||
assert.deepEqual(
|
||||
midiTransformer(data, params).tracks.map((track) => track.padCode),
|
||||
['a1'],
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user