@r_masseater/song-format 0.2.0 → 0.2.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/dist/als-to-fumx.mjs +525 -0
- package/dist/als-to-fumx.mjs.map +1 -0
- package/dist/convert-als.mjs +30 -22
- package/dist/convert-als.mjs.map +1 -1
- package/dist/convert-midi.mjs +1 -1
- package/dist/fumx-language-server.mjs +1 -1
- package/dist/{fumx-module-CmHFC-eI.mjs → fumx-module-CqxUe07y.mjs} +38 -66
- package/dist/{fumx-module-CmHFC-eI.mjs.map → fumx-module-CqxUe07y.mjs.map} +1 -1
- package/dist/{fumx-module-DJQrnEVm.mjs → fumx-module-CtXvLKU1.mjs} +38 -66
- package/dist/fumx-module-CtXvLKU1.mjs.map +1 -0
- package/dist/index.mjs +1 -1
- package/dist/language.mjs +1 -1
- package/dist/mapper.mjs +1 -1
- package/dist/midi-to-fumx.mjs +10 -947
- package/dist/midi-to-fumx.mjs.map +1 -1
- package/dist/{read-song-CSIhaAEB.mjs → read-song-BzqX5MuZ.mjs} +2 -2
- package/dist/{read-song-CSIhaAEB.mjs.map → read-song-BzqX5MuZ.mjs.map} +1 -1
- package/dist/{read-song-CNrfcHrY.mjs → read-song-CzMPm8u8.mjs} +2 -2
- package/dist/{read-song-CNrfcHrY.mjs.map → read-song-CzMPm8u8.mjs.map} +1 -1
- package/dist/round-trip-Cz8iQlpW.mjs +946 -0
- package/dist/round-trip-Cz8iQlpW.mjs.map +1 -0
- package/dist/song-report.mjs +2 -2
- package/dist/transform-BoSDqqPW.mjs +109 -0
- package/dist/transform-BoSDqqPW.mjs.map +1 -0
- package/dist/vite.mjs +2 -2
- package/dist/{write-CS-ZjoQB.mjs → write-CuDbIkpM.mjs} +4 -3
- package/dist/{write-CS-ZjoQB.mjs.map → write-CuDbIkpM.mjs.map} +1 -1
- package/package.json +6 -11
- package/skills/read-fumx/SKILL.md +0 -1
- package/skills/use-fumx-tools/SKILL.md +0 -1
- package/dist/fumx-module-DJQrnEVm.mjs.map +0 -1
- package/dist/transform-DQm5wTlA.mjs +0 -489
- package/dist/transform-DQm5wTlA.mjs.map +0 -1
package/dist/convert-als.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as microsecondsOf, i as sortedNotes, r as sortedByTick, t as writeFumx } from "./write-
|
|
1
|
+
import { a as microsecondsOf, i as sortedNotes, r as sortedByTick, t as writeFumx } from "./write-CuDbIkpM.mjs";
|
|
2
2
|
import { t as MIXER_PARAMETERS } from "./song-CYFBSTbH.mjs";
|
|
3
3
|
import { t as TICKS_PER_WHOLE } from "./ticks-CXehHP2w.mjs";
|
|
4
4
|
import { Array, Boolean, Effect, Option, Order, Record, Schema, pipe } from "effect";
|
|
@@ -201,15 +201,16 @@ const passesOf = (clip) => {
|
|
|
201
201
|
};
|
|
202
202
|
return walk(NONE$2, first, []);
|
|
203
203
|
};
|
|
204
|
+
const releaseOf = (offVelocity) => pipe(Option.fromUndefinedOr(offVelocity), Option.filter((off) => off !== NONE$2), Option.match({
|
|
205
|
+
onNone: () => DEFAULT_RELEASE,
|
|
206
|
+
onSome: Math.round
|
|
207
|
+
}));
|
|
204
208
|
const sourceNotesOf = (clip) => pipe(clip.Notes.KeyTracks.KeyTrack ?? [], Array.flatMap((keyTrack) => pipe(keyTrack.Notes.MidiNoteEvent ?? [], Array.filter((note) => note.IsEnabled !== "false"), Array.map((note) => ({
|
|
205
209
|
time: note.Time,
|
|
206
210
|
end: note.Time + note.Duration,
|
|
207
211
|
midi: keyTrack.MidiKey.Value,
|
|
208
212
|
velocity: Math.round(note.Velocity),
|
|
209
|
-
release:
|
|
210
|
-
onNone: () => DEFAULT_RELEASE,
|
|
211
|
-
onSome: Math.round
|
|
212
|
-
}))
|
|
213
|
+
release: releaseOf(note.OffVelocity)
|
|
213
214
|
})))));
|
|
214
215
|
const inPass = (notes) => (pass) => pipe(notes, Array.filter((note) => note.time >= pass.from && note.time < pass.to), Array.map((note) => ({
|
|
215
216
|
beat: pass.at + note.time - pass.from,
|
|
@@ -219,8 +220,9 @@ const inPass = (notes) => (pass) => pipe(notes, Array.filter((note) => note.time
|
|
|
219
220
|
release: note.release
|
|
220
221
|
})));
|
|
221
222
|
const byStartThenPitch = Order.combine(Order.mapInput(Order.Number, (note) => note.beat), Order.mapInput(Order.Number, (note) => note.midi));
|
|
223
|
+
const isDisabled = (clip) => Option.exists(Option.fromUndefinedOr(clip.Disabled), (flag) => flag.Value === "true");
|
|
222
224
|
const notesOfClip = (clip) => {
|
|
223
|
-
if (
|
|
225
|
+
if (isDisabled(clip)) return [];
|
|
224
226
|
const notes = sourceNotesOf(clip);
|
|
225
227
|
return pipe(passesOf(clip), Array.flatMap(inPass(notes)), Array.sortBy(byStartThenPitch));
|
|
226
228
|
};
|
|
@@ -240,21 +242,29 @@ const envelopeOf = (owner) => (parameter) => {
|
|
|
240
242
|
};
|
|
241
243
|
const SINGLE = 1;
|
|
242
244
|
const NEXT$2 = 1;
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
const automationOf = (select) => (liveSet) => pipe(masterOf(liveSet), Option.flatMap((master) => pipe(mixerOf(master), Option.map((mixer) => {
|
|
246
|
+
const parameter = select(mixer);
|
|
247
|
+
return {
|
|
248
|
+
events: envelopeOf(master)(parameter),
|
|
249
|
+
manual: pipe(Option.fromUndefinedOr(parameter.Manual), Option.map((manual) => manual.Value))
|
|
250
|
+
};
|
|
251
|
+
}))));
|
|
252
|
+
const tempoAutomationOf = automationOf((mixer) => mixer.Tempo);
|
|
253
|
+
const pointsOf$1 = (events) => pipe(events, Array.map((event) => ({
|
|
248
254
|
beat: event.Time,
|
|
249
255
|
value: Number(event.Value)
|
|
250
|
-
})))
|
|
256
|
+
})));
|
|
257
|
+
const tempoFrom = (resolve) => (liveSet) => pipe(tempoAutomationOf(liveSet), Option.map(resolve), Option.getOrElse(() => []));
|
|
258
|
+
const tempoEnvelopeOf = tempoFrom(({ events }) => pointsOf$1(events));
|
|
259
|
+
const manualPointsOf = tempoFrom(({ manual }) => pipe(manual, Option.map((value) => [{
|
|
260
|
+
beat: 0,
|
|
261
|
+
value
|
|
262
|
+
}]), Option.getOrElse(() => [])));
|
|
251
263
|
const tempoPointsOf = (liveSet) => {
|
|
252
264
|
const envelope = tempoEnvelopeOf(liveSet);
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
value: manual.Value
|
|
257
|
-
}]), Option.getOrElse(() => envelope));
|
|
265
|
+
const manual = manualPointsOf(liveSet);
|
|
266
|
+
if (envelope.length > SINGLE || !Array.isReadonlyArrayNonEmpty(manual)) return envelope;
|
|
267
|
+
return manual;
|
|
258
268
|
};
|
|
259
269
|
const valueAt = (from, to) => (beat) => {
|
|
260
270
|
if (to.beat === from.beat) return to.value;
|
|
@@ -308,12 +318,10 @@ const meterOfId = (beat, id) => pipe(Option.fromNullishOr(decodeTimeSignatureId(
|
|
|
308
318
|
numerator: signature.num,
|
|
309
319
|
denominator: signature.den
|
|
310
320
|
})));
|
|
311
|
-
const metersOf = (liveSet) => pipe(
|
|
312
|
-
const events = envelopeOf(master)(mixer.TimeSignature);
|
|
313
|
-
const manual = Option.fromUndefinedOr(mixer.TimeSignature.Manual);
|
|
321
|
+
const metersOf = (liveSet) => pipe(automationOf((mixer) => mixer.TimeSignature)(liveSet), Option.map(({ events, manual }) => {
|
|
314
322
|
if (events.length > SINGLE || Option.isNone(manual)) return pipe(events, Array.map((event) => meterOfId(event.Time, Number(event.Value))), Array.getSomes, Array.reverse, Array.dedupeAdjacentWith((later, earlier) => later.beat === earlier.beat), Array.reverse);
|
|
315
|
-
return Option.toArray(meterOfId(0, manual.value
|
|
316
|
-
})
|
|
323
|
+
return Option.toArray(meterOfId(0, manual.value));
|
|
324
|
+
}), Option.getOrElse(() => []));
|
|
317
325
|
const byBeat = Order.mapInput(Order.Number, (locator) => locator.beat);
|
|
318
326
|
const locatorsOf = (liveSet) => pipe(Option.fromUndefinedOr(liveSet.Locators), Option.flatMap((locators) => Option.fromUndefinedOr(locators.Locators.Locator)), Option.getOrElse(() => []), Array.map((locator) => ({
|
|
319
327
|
beat: locator.Time.Value,
|
package/dist/convert-als.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-als.mjs","names":["Arr","Rec","NONE","Arr","Arr","NEXT","NONE","NEXT","Arr","Arr","Bool"],"sources":["../src/features/convert-als/model/live-set.ts","../src/features/convert-als/model/clips.ts","../src/features/convert-als/model/tempo-map.ts","../src/features/convert-als/model/ticks.ts","../src/features/convert-als/model/mix.ts","../src/features/convert-als/model/timeline.ts","../src/features/convert-als/model/convert.ts"],"sourcesContent":["import { Array as Arr, Effect, Option, Record as Rec, Schema, pipe } from \"effect\";\nimport { XMLParser } from \"fast-xml-parser\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class UnreadableAls extends taggedError<UnreadableAls, { readonly brand: unique symbol }>()(\n \"UnreadableAls\",\n { message: Schema.String },\n { identifier: \"UnreadableAls\" },\n) {}\n\nconst REPEATED = new Set([\n \"MidiTrack\",\n \"AudioTrack\",\n \"GroupTrack\",\n \"ReturnTrack\",\n \"MidiClip\",\n \"AudioClip\",\n \"KeyTrack\",\n \"MidiNoteEvent\",\n \"Locator\",\n \"AutomationEnvelope\",\n \"FloatEvent\",\n \"EnumEvent\",\n \"BoolEvent\",\n \"TrackSendHolder\",\n]);\n\nconst ATTRIBUTES = \"@\";\n\nconst parser = new XMLParser({\n ignoreAttributes: false,\n attributeNamePrefix: \"\",\n attributesGroupName: ATTRIBUTES,\n parseTagValue: false,\n parseAttributeValue: false,\n jPath: false,\n isArray: (name: string): boolean => REPEATED.has(name),\n});\n\nconst Num = Schema.Struct({ Value: Schema.FiniteFromString });\nconst Text = Schema.Struct({ Value: Schema.String });\nconst Flag = Schema.Struct({ Value: Schema.Literals([\"true\", \"false\"]) });\n\nconst EventSchema = Schema.Struct({ Time: Schema.FiniteFromString, Value: Schema.String });\n\nexport type AutomationEvent = typeof EventSchema.Type;\n\nconst EventsSchema = Schema.Struct({\n FloatEvent: EventSchema.pipe(Schema.Array, Schema.optionalKey),\n EnumEvent: EventSchema.pipe(Schema.Array, Schema.optionalKey),\n BoolEvent: EventSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst EnvelopeSchema = Schema.Struct({\n EnvelopeTarget: Schema.Struct({ PointeeId: Num }),\n Automation: Schema.Struct({ Events: EventsSchema }),\n});\n\nexport type AutomationEnvelope = typeof EnvelopeSchema.Type;\n\nconst EnvelopeListSchema = Schema.Struct({\n AutomationEnvelope: EnvelopeSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst EnvelopesSchema = Schema.Struct({ Envelopes: EnvelopeListSchema });\n\nconst TargetSchema = Schema.Struct({ Id: Schema.FiniteFromString });\n\nconst ParameterSchema = Schema.Struct({\n Manual: Schema.optionalKey(Num),\n AutomationTarget: Schema.optionalKey(TargetSchema),\n ArrangerAutomation: Schema.optionalKey(Schema.Struct({ Events: EventsSchema })),\n});\n\nexport type Parameter = typeof ParameterSchema.Type;\n\nconst NoteSchema = Schema.Struct({\n Time: Schema.FiniteFromString,\n Duration: Schema.FiniteFromString,\n Velocity: Schema.FiniteFromString,\n OffVelocity: Schema.optionalKey(Schema.FiniteFromString),\n IsEnabled: Schema.optionalKey(Schema.Literals([\"true\", \"false\"])),\n Probability: Schema.optionalKey(Schema.FiniteFromString),\n VelocityDeviation: Schema.optionalKey(Schema.FiniteFromString),\n});\n\nconst NoteListSchema = Schema.Struct({\n MidiNoteEvent: NoteSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst KeyTrackSchema = Schema.Struct({ Notes: NoteListSchema, MidiKey: Num });\n\nconst LoopSchema = Schema.Struct({\n LoopStart: Num,\n LoopEnd: Num,\n StartRelative: Num,\n LoopOn: Flag,\n});\n\nconst KeyTracksSchema = Schema.Struct({\n KeyTrack: KeyTrackSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst ClipSchema = Schema.Struct({\n CurrentStart: Num,\n CurrentEnd: Num,\n Loop: LoopSchema,\n Disabled: Schema.optionalKey(Flag),\n Notes: Schema.Struct({ KeyTracks: KeyTracksSchema }),\n});\n\nexport type AlsClip = typeof ClipSchema.Type;\n\nconst NameSchema = Schema.Struct({\n EffectiveName: Schema.optionalKey(Text),\n UserName: Schema.optionalKey(Text),\n});\n\nconst DrumsSchema = Schema.Struct({ DrumGroupDevice: Schema.optionalKey(Schema.Unknown) });\n\nconst DevicesSchema = Schema.Struct({ Devices: Schema.optionalKey(DrumsSchema) });\n\nconst ClipEventsSchema = Schema.Struct({\n MidiClip: ClipSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst ArrangementSchema = Schema.Struct({\n ArrangerAutomation: Schema.Struct({ Events: ClipEventsSchema }),\n});\n\nconst SendHolderSchema = Schema.Struct({ Send: ParameterSchema });\n\nconst SendsSchema = Schema.Struct({\n TrackSendHolder: SendHolderSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst SpeakerSchema = Schema.Struct({ Manual: Schema.optionalKey(Flag) });\n\nconst TrackMixerSchema = Schema.Struct({\n Volume: ParameterSchema,\n Pan: ParameterSchema,\n Speaker: Schema.optionalKey(SpeakerSchema),\n Sends: Schema.optionalKey(SendsSchema),\n});\n\nexport type AlsMixer = typeof TrackMixerSchema.Type;\n\nconst TrackChainSchema = Schema.Struct({\n DeviceChain: Schema.optionalKey(DevicesSchema),\n Mixer: Schema.optionalKey(TrackMixerSchema),\n MainSequencer: Schema.Struct({ ClipTimeable: ArrangementSchema }),\n});\n\nconst MidiTrackSchema = Schema.Struct({\n Id: Schema.String,\n Name: NameSchema,\n AutomationEnvelopes: Schema.optionalKey(EnvelopesSchema),\n DeviceChain: TrackChainSchema,\n});\n\nexport type AlsMidiTrack = typeof MidiTrackSchema.Type;\n\nconst ReturnTrackSchema = Schema.Struct({\n Name: NameSchema,\n DeviceChain: Schema.Struct({ Mixer: Schema.optionalKey(TrackMixerSchema) }),\n});\n\nexport type AlsReturnTrack = typeof ReturnTrackSchema.Type;\n\nconst MixerSchema = Schema.Struct({ Tempo: ParameterSchema, TimeSignature: ParameterSchema });\n\nconst MasterSchema = Schema.Struct({\n AutomationEnvelopes: Schema.optionalKey(EnvelopesSchema),\n DeviceChain: Schema.optionalKey(Schema.Struct({ Mixer: MixerSchema })),\n MasterChain: Schema.optionalKey(Schema.Struct({ Mixer: MixerSchema })),\n});\n\nexport type AlsMaster = typeof MasterSchema.Type;\n\nconst LocatorSchema = Schema.Struct({ Time: Num, Name: Text });\n\nexport type AlsLocator = typeof LocatorSchema.Type;\n\nconst TracksSchema = Schema.Struct({\n MidiTrack: MidiTrackSchema.pipe(Schema.Array, Schema.optionalKey),\n ReturnTrack: ReturnTrackSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst LocatorListSchema = Schema.Struct({\n Locator: LocatorSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst LiveSetSchema = Schema.Struct({\n Tracks: TracksSchema,\n MasterTrack: Schema.optionalKey(MasterSchema),\n MainTrack: Schema.optionalKey(MasterSchema),\n Locators: Schema.optionalKey(Schema.Struct({ Locators: LocatorListSchema })),\n});\n\nexport type LiveSet = typeof LiveSetSchema.Type;\n\nconst DocumentSchema = Schema.Struct({\n Ableton: Schema.Struct({\n MajorVersion: Schema.String,\n MinorVersion: Schema.String,\n Creator: Schema.optionalKey(Schema.String),\n LiveSet: LiveSetSchema,\n }),\n});\n\nconst decodeDocument = Schema.decodeUnknownEffect(DocumentSchema);\n\nconst isElement = Schema.is(Schema.Record(Schema.String, Schema.Unknown));\nconst isAttributes = Schema.is(Schema.Record(Schema.String, Schema.String));\n\nconst flattened = (node: unknown): unknown => {\n if (node === \"\") {\n return {};\n }\n if (Arr.isArray(node)) {\n return pipe(\n node,\n Arr.map((child) => flattened(child)),\n );\n }\n if (isElement(node)) {\n const { [ATTRIBUTES]: attributes, ...children } = node;\n const own = pipe(\n Option.liftPredicate(attributes, isAttributes),\n Option.getOrElse((): Readonly<Record<string, string>> => ({})),\n );\n return {\n ...pipe(\n children,\n Rec.map((child) => flattened(child)),\n ),\n ...own,\n };\n }\n return node;\n};\n\nconst gunzip = (bytes: Uint8Array): Effect.Effect<string, UnreadableAls> =>\n Effect.tryPromise({\n try: () =>\n new Response(\n new Blob([Uint8Array.from(bytes)]).stream().pipeThrough(new DecompressionStream(\"gzip\")),\n ).text(),\n catch: (cause) => UnreadableAls.make({ message: `Not a gzipped Live Set: ${String(cause)}` }),\n });\n\nexport type AlsDocument = typeof DocumentSchema.Type;\n\nexport const readAlsDocument: (bytes: Uint8Array) => Effect.Effect<AlsDocument, UnreadableAls> =\n Effect.fn(\"readAlsDocument\")(function* read(\n bytes: Uint8Array,\n ): Effect.fn.Return<AlsDocument, UnreadableAls> {\n const xml = yield* gunzip(bytes);\n const parsed = yield* Effect.try({\n try: () => flattened(parser.parse(xml)),\n catch: (cause) => UnreadableAls.make({ message: `Not XML: ${String(cause)}` }),\n });\n return yield* decodeDocument(parsed).pipe(\n Effect.mapError((issue) =>\n UnreadableAls.make({ message: `Not a Live Set this converter reads: ${String(issue)}` }),\n ),\n );\n });\n","import { Array as Arr, Option, Order, pipe } from \"effect\";\n\nimport type { From } from \"#/shared/lib/from.ts\";\n\nimport type { AlsClip } from \"./live-set.ts\";\n\nconst NONE = 0;\n\nexport interface PlayedNote {\n readonly beat: number;\n readonly length: number;\n readonly midi: number;\n readonly velocity: number;\n readonly release: number;\n}\n\ninterface Pass {\n readonly at: number;\n readonly from: number;\n readonly to: number;\n}\n\ninterface SourceNote {\n readonly time: number;\n readonly end: number;\n readonly midi: number;\n readonly velocity: number;\n readonly release: number;\n}\n\nconst DEFAULT_RELEASE = 64;\n\nconst modulo = (value: number, size: number): number => ((value % size) + size) % size;\n\nconst passesOf: From<AlsClip, readonly Pass[]> = (clip) => {\n const start = clip.CurrentStart.Value;\n const length = clip.CurrentEnd.Value - start;\n const loopStart = clip.Loop.LoopStart.Value;\n const loopLength = clip.Loop.LoopEnd.Value - loopStart;\n if (clip.Loop.LoopOn.Value === \"false\" || loopLength <= NONE) {\n return [{ at: start, from: loopStart, to: loopStart + length }];\n }\n const first = loopStart + modulo(clip.Loop.StartRelative.Value, loopLength);\n const walk = (elapsed: number, from: number, passes: readonly Pass[]): readonly Pass[] => {\n if (elapsed >= length) {\n return passes;\n }\n const span = Math.min(clip.Loop.LoopEnd.Value - from, length - elapsed);\n return walk(elapsed + span, loopStart, [\n ...passes,\n { at: start + elapsed, from, to: from + span },\n ]);\n };\n return walk(NONE, first, []);\n};\n\nconst sourceNotesOf: From<AlsClip, readonly SourceNote[]> = (clip) =>\n pipe(\n clip.Notes.KeyTracks.KeyTrack ?? [],\n Arr.flatMap((keyTrack) =>\n pipe(\n keyTrack.Notes.MidiNoteEvent ?? [],\n Arr.filter((note) => note.IsEnabled !== \"false\"),\n Arr.map((note): SourceNote => ({\n time: note.Time,\n end: note.Time + note.Duration,\n midi: keyTrack.MidiKey.Value,\n velocity: Math.round(note.Velocity),\n release: pipe(\n Option.fromUndefinedOr(note.OffVelocity),\n Option.filter((off) => off !== NONE),\n Option.match({ onNone: () => DEFAULT_RELEASE, onSome: Math.round }),\n ),\n })),\n ),\n ),\n );\n\nconst inPass =\n (notes: readonly SourceNote[]): From<Pass, readonly PlayedNote[]> =>\n (pass) =>\n pipe(\n notes,\n Arr.filter((note) => note.time >= pass.from && note.time < pass.to),\n Arr.map((note): PlayedNote => ({\n beat: pass.at + note.time - pass.from,\n length: Math.min(note.end, pass.to) - note.time,\n midi: note.midi,\n velocity: note.velocity,\n release: note.release,\n })),\n );\n\nconst byStartThenPitch = Order.combine(\n Order.mapInput(Order.Number, (note: PlayedNote) => note.beat),\n Order.mapInput(Order.Number, (note: PlayedNote) => note.midi),\n);\n\nexport const notesOfClip: From<AlsClip, readonly PlayedNote[]> = (clip) => {\n const disabled = pipe(\n Option.fromUndefinedOr(clip.Disabled),\n Option.exists((flag) => flag.Value === \"true\"),\n );\n if (disabled) {\n return [];\n }\n const notes = sourceNotesOf(clip);\n return pipe(passesOf(clip), Arr.flatMap(inPass(notes)), Arr.sortBy(byStartThenPitch));\n};\n","import { decodeTimeSignatureId } from \"ableton-als\";\nimport { Array as Arr, Option, Order, pipe } from \"effect\";\n\nimport type { From } from \"#/shared/lib/from.ts\";\n\nimport type {\n AlsLocator,\n AlsMaster,\n AutomationEnvelope,\n AutomationEvent,\n LiveSet,\n Parameter,\n} from \"./live-set.ts\";\n\nexport const SONG_START = 0;\n\nexport interface Point {\n readonly beat: number;\n readonly value: number;\n}\n\nexport interface TempoSegment {\n readonly beat: number;\n readonly bpm: number;\n readonly target: Option.Option<number>;\n}\n\nexport interface MeterChange {\n readonly beat: number;\n readonly numerator: number;\n readonly denominator: number;\n}\n\nexport interface Locator {\n readonly beat: number;\n readonly name: string;\n}\n\nconst masterOf: From<LiveSet, Option.Option<AlsMaster>> = (liveSet) =>\n Option.orElse(Option.fromUndefinedOr(liveSet.MasterTrack), () =>\n Option.fromUndefinedOr(liveSet.MainTrack),\n );\n\nconst mixerOf: From<\n AlsMaster,\n Option.Option<{ readonly Tempo: Parameter; readonly TimeSignature: Parameter }>\n> = (master) =>\n pipe(\n Option.fromUndefinedOr(master.DeviceChain),\n Option.orElse(() => Option.fromUndefinedOr(master.MasterChain)),\n Option.map((chain) => chain.Mixer),\n );\n\nconst eventsOf = (events: {\n readonly FloatEvent?: readonly AutomationEvent[];\n readonly EnumEvent?: readonly AutomationEvent[];\n readonly BoolEvent?: readonly AutomationEvent[];\n}): readonly AutomationEvent[] => [\n ...(events.FloatEvent ?? []),\n ...(events.EnumEvent ?? []),\n ...(events.BoolEvent ?? []),\n];\n\nexport type Automated = Pick<AlsMaster, \"AutomationEnvelopes\">;\n\nconst automationEnvelopesOf = (owner: Automated): readonly AutomationEnvelope[] =>\n pipe(\n Option.fromUndefinedOr(owner.AutomationEnvelopes),\n Option.flatMap((envelopes) => Option.fromUndefinedOr(envelopes.Envelopes.AutomationEnvelope)),\n Option.getOrElse((): readonly AutomationEnvelope[] => []),\n );\n\nconst byTime = Order.mapInput(Order.Number, (event: AutomationEvent) => event.Time);\n\nexport const envelopeOf =\n (owner: Automated): From<Parameter, readonly AutomationEvent[]> =>\n (parameter) => {\n const inline = pipe(\n Option.fromUndefinedOr(parameter.ArrangerAutomation),\n Option.map((automation) => automation.Events),\n );\n const pointed = pipe(\n Option.fromUndefinedOr(parameter.AutomationTarget),\n Option.flatMap((target) =>\n pipe(\n automationEnvelopesOf(owner),\n Arr.findFirst((envelope) => envelope.EnvelopeTarget.PointeeId.Value === target.Id),\n ),\n ),\n Option.map((envelope) => envelope.Automation.Events),\n );\n return pipe(\n Option.orElse(pointed, () => inline),\n Option.map(eventsOf),\n Option.getOrElse((): readonly AutomationEvent[] => []),\n Arr.sortBy(byTime),\n );\n };\n\nconst SINGLE = 1;\nconst NEXT = 1;\n\nconst tempoOf: From<\n LiveSet,\n Option.Option<{ readonly master: AlsMaster; readonly tempo: Parameter }>\n> = (liveSet) =>\n pipe(\n masterOf(liveSet),\n Option.flatMap((master) =>\n pipe(\n mixerOf(master),\n Option.map((mixer) => ({ master, tempo: mixer.Tempo })),\n ),\n ),\n );\n\nexport const tempoEnvelopeOf: From<LiveSet, readonly Point[]> = (liveSet) =>\n pipe(\n tempoOf(liveSet),\n Option.map(({ master, tempo }) =>\n pipe(\n envelopeOf(master)(tempo),\n Arr.map((event): Point => ({ beat: event.Time, value: Number(event.Value) })),\n ),\n ),\n Option.getOrElse((): readonly Point[] => []),\n );\n\nexport const tempoPointsOf: From<LiveSet, readonly Point[]> = (liveSet) => {\n const envelope = tempoEnvelopeOf(liveSet);\n if (envelope.length > SINGLE) {\n return envelope;\n }\n return pipe(\n tempoOf(liveSet),\n Option.flatMap(({ tempo }) => Option.fromUndefinedOr(tempo.Manual)),\n Option.map((manual): readonly Point[] => [{ beat: SONG_START, value: manual.Value }]),\n Option.getOrElse(() => envelope),\n );\n};\n\nconst valueAt =\n (from: Point, to: Point): From<number, number> =>\n (beat) => {\n if (to.beat === from.beat) {\n return to.value;\n }\n return from.value + ((to.value - from.value) * (beat - from.beat)) / (to.beat - from.beat);\n };\n\nconst segmentOf = (from: Point, next: Option.Option<Point>): TempoSegment => {\n const start = Math.max(from.beat, SONG_START);\n return Option.match(next, {\n onNone: () => ({ beat: start, bpm: from.value, target: Option.none() }),\n onSome: (to) => {\n const bpm = valueAt(from, to)(start);\n if (to.beat <= start || to.value === bpm) {\n return { beat: start, bpm, target: Option.none() };\n }\n return { beat: start, bpm, target: Option.some(to.value) };\n },\n });\n};\n\nconst keptWith = (\n kept: readonly TempoSegment[],\n segment: TempoSegment,\n): readonly TempoSegment[] => {\n const earlier = pipe(\n Arr.last(kept),\n Option.filter((last) => last.beat === segment.beat),\n Option.match({ onNone: () => kept, onSome: () => Arr.dropRight(kept, SINGLE) }),\n );\n const redundant = pipe(\n Arr.last(earlier),\n Option.exists(\n (last) =>\n Option.isNone(last.target) && Option.isNone(segment.target) && last.bpm === segment.bpm,\n ),\n );\n if (redundant) {\n return earlier;\n }\n return [...earlier, segment];\n};\n\nconst withoutRepeats = (segments: readonly TempoSegment[]): readonly TempoSegment[] => {\n let kept: readonly TempoSegment[] = [];\n for (const segment of segments) {\n kept = keptWith(kept, segment);\n }\n return kept;\n};\n\nexport const tempoSegmentsOf: From<readonly Point[], readonly TempoSegment[]> = (points) =>\n pipe(\n points,\n Arr.map((point, index) => ({ point, next: Arr.get(points, index + NEXT) })),\n Arr.filter(({ next }) =>\n Option.match(next, { onNone: () => true, onSome: (to) => to.beat > SONG_START }),\n ),\n Arr.map(({ point, next }) => segmentOf(point, next)),\n withoutRepeats,\n );\n\nconst meterOfId = (beat: number, id: number): Option.Option<MeterChange> =>\n pipe(\n Option.fromNullishOr(decodeTimeSignatureId(id)),\n Option.map((signature) => ({\n beat: Math.max(beat, SONG_START),\n numerator: signature.num,\n denominator: signature.den,\n })),\n );\n\nexport const metersOf: From<LiveSet, readonly MeterChange[]> = (liveSet) =>\n pipe(\n masterOf(liveSet),\n Option.flatMap((master) =>\n pipe(\n mixerOf(master),\n Option.map((mixer) => {\n const events = envelopeOf(master)(mixer.TimeSignature);\n const manual = Option.fromUndefinedOr(mixer.TimeSignature.Manual);\n if (events.length > SINGLE || Option.isNone(manual)) {\n return pipe(\n events,\n Arr.map((event) => meterOfId(event.Time, Number(event.Value))),\n Arr.getSomes,\n Arr.reverse,\n Arr.dedupeAdjacentWith((later, earlier) => later.beat === earlier.beat),\n Arr.reverse,\n );\n }\n return Option.toArray(meterOfId(SONG_START, manual.value.Value));\n }),\n ),\n ),\n Option.getOrElse((): readonly MeterChange[] => []),\n );\n\nconst byBeat = Order.mapInput(Order.Number, (locator: Locator) => locator.beat);\n\nexport const locatorsOf: From<LiveSet, readonly Locator[]> = (liveSet) =>\n pipe(\n Option.fromUndefinedOr(liveSet.Locators),\n Option.flatMap((locators) => Option.fromUndefinedOr(locators.Locators.Locator)),\n Option.getOrElse((): readonly AlsLocator[] => []),\n Arr.map((locator): Locator => ({ beat: locator.Time.Value, name: locator.Name.Value })),\n Arr.sortBy(byBeat),\n );\n","import type { From } from \"#/shared/lib/from.ts\";\nimport { TICKS_PER_WHOLE } from \"#/shared/lib/ticks.ts\";\n\nconst QUARTERS_PER_WHOLE = 4;\nconst TICKS_PER_BEAT = TICKS_PER_WHOLE / QUARTERS_PER_WHOLE;\n\nexport interface Tick {\n readonly tick: number;\n readonly exact: boolean;\n}\n\nexport const tickOf: From<number, Tick> = (beat) => {\n const exact = beat * TICKS_PER_BEAT;\n return { tick: Math.round(exact), exact: Number.isInteger(exact) };\n};\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport { MIXER_PARAMETERS } from \"#/entities/song/index.ts\";\nimport type {\n BusMix,\n Envelope,\n Level,\n Mix,\n MixParameter,\n MixPoint,\n TrackMix,\n TrackSend,\n} from \"#/entities/timeline/index.ts\";\nimport type { From } from \"#/shared/lib/from.ts\";\n\nimport type { AlsMidiTrack, AlsMixer, AlsReturnTrack, LiveSet, Parameter } from \"./live-set.ts\";\nimport { SONG_START, envelopeOf } from \"./tempo-map.ts\";\nimport type { Automated } from \"./tempo-map.ts\";\nimport { tickOf } from \"./ticks.ts\";\n\nconst DECIBELS_PER_DECADE = 20;\nconst SILENT_DECIBELS = -70;\nconst AUDIBLE_SEND = 0.001;\nconst NONE = 0;\nconst NEXT = 1;\n\nconst DECIMAL_BASE = 10;\nconst SILENT = DECIMAL_BASE ** (SILENT_DECIBELS / DECIBELS_PER_DECADE);\n\nconst decibelsOf: From<number, number> = (gain) =>\n DECIBELS_PER_DECADE * Math.log10(Math.max(gain, SILENT));\n\nconst [VOLUME, PAN] = MIXER_PARAMETERS;\n\nconst VALUES: Readonly<Record<MixParameter, From<number, number>>> = {\n volume: decibelsOf,\n pan: (pan) => pan,\n};\n\nconst RESTING: Readonly<Record<MixParameter, number>> = { volume: NONE, pan: NONE };\n\ntype Owned = Readonly<{ owner: Automated; parameter: MixParameter }>;\n\nconst pointsOf =\n ({ owner, parameter }: Owned): From<Parameter, readonly MixPoint[]> =>\n (control) =>\n pipe(\n envelopeOf(owner)(control),\n Arr.map((event) => ({\n tick: tickOf(Math.max(event.Time, SONG_START)).tick,\n value: VALUES[parameter](Number(event.Value)),\n })),\n Arr.filter((point) => Number.isFinite(point.value)),\n );\n\nconst startOf =\n (owned: Owned): From<Parameter, number> =>\n (control) =>\n pipe(\n pointsOf(owned)(control),\n Arr.head,\n Option.map((point) => point.value),\n Option.orElse(() =>\n pipe(\n Option.fromUndefinedOr(control.Manual),\n Option.map((manual) => VALUES[owned.parameter](manual.Value)),\n ),\n ),\n Option.getOrElse(() => RESTING[owned.parameter]),\n );\n\nconst levelOf =\n (owner: Automated): From<AlsMixer, Level> =>\n (mixer) => ({\n decibels: startOf({ owner, parameter: VOLUME })(mixer.Volume),\n pan: startOf({ owner, parameter: PAN })(mixer.Pan),\n muted: pipe(\n Option.fromUndefinedOr(mixer.Speaker),\n Option.flatMap((speaker) => Option.fromUndefinedOr(speaker.Manual)),\n Option.exists((manual) => manual.Value === \"false\"),\n ),\n });\n\nconst sendsOf: From<AlsMixer, readonly TrackSend[]> = (mixer) =>\n pipe(\n Option.fromUndefinedOr(mixer.Sends),\n Option.flatMap((sends) => Option.fromUndefinedOr(sends.TrackSendHolder)),\n Option.getOrElse(() => []),\n Arr.map((holder, bus) => ({\n bus,\n amount: pipe(\n Option.fromUndefinedOr(holder.Send.Manual),\n Option.match({ onNone: () => NONE, onSome: (manual) => manual.Value }),\n ),\n })),\n Arr.filter((send) => send.amount > AUDIBLE_SEND),\n );\n\nconst envelopesOf =\n (owner: Automated): From<AlsMixer, readonly Envelope[]> =>\n (mixer) =>\n pipe(\n [\n { parameter: \"volume\" as const, control: mixer.Volume },\n { parameter: \"pan\" as const, control: mixer.Pan },\n ],\n Arr.map(({ parameter, control }) => ({\n parameter,\n points: pointsOf({ owner, parameter })(control),\n })),\n Arr.filter((envelope) => envelope.points.length > NEXT),\n );\n\nconst trackMixOf: From<AlsMidiTrack, Option.Option<TrackMix>> = (track) =>\n pipe(\n Option.fromUndefinedOr(track.DeviceChain.Mixer),\n Option.map((mixer) => ({\n level: levelOf(track)(mixer),\n sends: sendsOf(mixer),\n envelopes: envelopesOf(track)(mixer),\n })),\n );\n\nconst NO_ENVELOPES: Automated = {};\n\nconst busOf =\n (nameOf: From<AlsReturnTrack[\"Name\"], Option.Option<string>>): From<AlsReturnTrack, BusMix> =>\n (track) => ({\n name: nameOf(track.Name),\n level: pipe(\n Option.fromUndefinedOr(track.DeviceChain.Mixer),\n Option.match({\n onNone: () => ({ decibels: NONE, pan: NONE, muted: false }),\n onSome: levelOf(NO_ENVELOPES),\n }),\n ),\n });\n\nexport const mixOf =\n (nameOf: From<AlsReturnTrack[\"Name\"], Option.Option<string>>): From<LiveSet, Mix> =>\n (liveSet) => ({\n tracks: new Map(\n pipe(\n liveSet.Tracks.MidiTrack ?? [],\n Arr.flatMap((track, index) =>\n pipe(\n trackMixOf(track),\n Option.map((mix) => [index, mix] as const),\n Option.toArray,\n ),\n ),\n ),\n ),\n buses: pipe(liveSet.Tracks.ReturnTrack ?? [], Arr.map(busOf(nameOf))),\n });\n","import { Array as Arr, Boolean as Bool, Option, pipe } from \"effect\";\n\nimport { microsecondsOf, sortedByTick, sortedNotes } from \"#/entities/timeline/index.ts\";\nimport type { Part, TempoChange, Timeline, TimelineNote } from \"#/entities/timeline/index.ts\";\nimport type { From } from \"#/shared/lib/from.ts\";\n\nimport { notesOfClip } from \"./clips.ts\";\nimport type { PlayedNote } from \"./clips.ts\";\nimport type { AlsMidiTrack, LiveSet } from \"./live-set.ts\";\nimport { mixOf } from \"./mix.ts\";\nimport { locatorsOf, metersOf, tempoPointsOf, tempoSegmentsOf } from \"./tempo-map.ts\";\nimport { tickOf } from \"./ticks.ts\";\n\nconst MELODIC_CHANNEL = 0;\nconst DRUM_CHANNEL = 9;\nconst NONE = 0;\nconst NEXT = 1;\n\nconst nameOf: From<AlsMidiTrack[\"Name\"], Option.Option<string>> = (label) =>\n pipe(\n [label.EffectiveName, label.UserName],\n Arr.map(Option.fromUndefinedOr),\n Arr.getSomes,\n Arr.map((name) => name.Value),\n Arr.findFirst((name) => name !== \"\"),\n );\n\nconst isDrumRack: From<AlsMidiTrack, boolean> = (track) =>\n pipe(\n Option.fromUndefinedOr(track.DeviceChain.DeviceChain),\n Option.flatMap((chain) => Option.fromUndefinedOr(chain.Devices)),\n Option.flatMap((devices) => Option.fromUndefinedOr(devices.DrumGroupDevice)),\n Option.isSome,\n );\n\ninterface TrackNotes {\n readonly notes: readonly TimelineNote[];\n readonly offGrid: number;\n}\n\nconst trackNotesOf: From<AlsMidiTrack, TrackNotes> = (track) => {\n const played: readonly PlayedNote[] = pipe(\n track.DeviceChain.MainSequencer.ClipTimeable.ArrangerAutomation.Events.MidiClip ?? [],\n Arr.flatMap(notesOfClip),\n );\n const placed = pipe(\n played,\n Arr.map((note) => ({\n note,\n start: tickOf(note.beat),\n end: tickOf(note.beat + note.length),\n })),\n );\n return {\n notes: sortedNotes(\n pipe(\n placed,\n Arr.map(({ note, start, end }): TimelineNote => ({\n tick: start.tick,\n end: end.tick,\n midi: note.midi,\n velocity: note.velocity,\n release: note.release,\n })),\n ),\n ),\n offGrid: Arr.countBy(placed, ({ start, end }) => !start.exact || !end.exact),\n };\n};\n\ninterface PartRead {\n readonly part: Part;\n readonly offGrid: number;\n}\n\nconst partOf = (track: AlsMidiTrack, index: number): PartRead => {\n const read = trackNotesOf(track);\n return {\n part: {\n track: index,\n channel: Bool.match(isDrumRack(track), {\n onFalse: () => MELODIC_CHANNEL,\n onTrue: () => DRUM_CHANNEL,\n }),\n name: nameOf(track.Name),\n program: Option.none(),\n notes: read.notes,\n controls: [],\n lyrics: [],\n },\n offGrid: read.offGrid,\n };\n};\n\nconst temposOf: From<LiveSet, readonly TempoChange[]> = (liveSet) =>\n pipe(\n tempoSegmentsOf(tempoPointsOf(liveSet)),\n Arr.map((segment): TempoChange => ({\n tick: tickOf(segment.beat).tick,\n microseconds: microsecondsOf(segment.bpm),\n target: pipe(segment.target, Option.map(microsecondsOf)),\n })),\n );\n\nconst lastOf: From<readonly number[], number> = (ticks) =>\n Arr.reduce(ticks, NONE, (latest, tick) => Math.max(latest, tick));\n\nexport const timelineOf: From<LiveSet, Timeline> = (liveSet) => {\n const reads = pipe(\n liveSet.Tracks.MidiTrack ?? [],\n Arr.map(partOf),\n Arr.filter((read) => Arr.isReadonlyArrayNonEmpty(read.part.notes)),\n );\n const parts = pipe(\n reads,\n Arr.map((read) => read.part),\n );\n const markers = sortedByTick(\n pipe(\n locatorsOf(liveSet),\n Arr.map((locator) => ({ tick: tickOf(locator.beat).tick, text: locator.name })),\n ),\n );\n const tempos = temposOf(liveSet);\n const meters = pipe(\n metersOf(liveSet),\n Arr.map((meter) => ({\n tick: tickOf(meter.beat).tick,\n numerator: meter.numerator,\n denominator: meter.denominator,\n })),\n );\n const noteEnds = pipe(\n parts,\n Arr.flatMap((part) => part.notes),\n Arr.map((note) => note.end),\n );\n const pointEnds = pipe(\n [...markers, ...tempos, ...meters],\n Arr.map((point) => point.tick + NEXT),\n );\n return {\n title: Option.none(),\n end: lastOf([...noteEnds, ...pointEnds]),\n offGrid: Arr.reduce(reads, NONE, (sum, read) => sum + read.offGrid),\n tempos,\n meters,\n markers,\n parts,\n mix: mixOf(nameOf)(liveSet),\n };\n};\n","import { Effect } from \"effect\";\n\nimport { writeFumx } from \"#/entities/timeline/index.ts\";\nimport type { Written } from \"#/entities/timeline/index.ts\";\n\nimport { readAlsDocument } from \"./live-set.ts\";\nimport { timelineOf } from \"./timeline.ts\";\n\nexport interface LiveSetFile {\n readonly bytes: Uint8Array;\n readonly title: string;\n}\n\nexport interface Fumx extends Written {\n readonly offGrid: number;\n}\n\nexport const alsToFumx = Effect.fn(\"alsToFumx\")(function* convert(input: LiveSetFile) {\n const document = yield* readAlsDocument(input.bytes);\n const timeline = yield* Effect.sync(() => timelineOf(document.Ableton.LiveSet)).pipe(\n Effect.withSpan(\"timelineOf\"),\n );\n const written = yield* Effect.sync(() => writeFumx({ timeline, title: input.title })).pipe(\n Effect.withSpan(\"writeFumx\"),\n );\n yield* Effect.annotateCurrentSpan({\n creator: document.Ableton.Creator ?? \"\",\n parts: written.plan.parts.length,\n bars: written.bars.length,\n });\n const fumx: Fumx = { ...written, offGrid: timeline.offGrid };\n return fumx;\n});\n"],"mappings":";;;;;;;AAGA,MAAM,cAAc,OAAO;AAE3B,IAAa,gBAAb,cAAmC,YAA8D,CAAC,CAChG,iBACA,EAAE,SAAS,OAAO,OAAO,GACzB,EAAE,YAAY,gBAAgB,CAChC,CAAC,CAAC,CAAC;AAEH,MAAM,2BAAW,IAAI,IAAI;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,aAAa;AAEnB,MAAM,SAAS,IAAI,UAAU;CAC3B,kBAAkB;CAClB,qBAAqB;C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M,MAAM,CAAC,CAAC,OAAO;CAC5B;AACF;;ACtIA,MAAa,YAAY,OAAO,GAAG,WAAW,CAAC,CAAC,UAAU,QAAQ,OAAoB;CACpF,MAAM,WAAW,OAAO,gBAAgB,MAAM,KAAK;CACnD,MAAM,WAAW,OAAO,OAAO,WAAW,WAAW,SAAS,QAAQ,OAAO,CAAC,CAAC,CAAC,KAC9E,OAAO,SAAS,YAAY,CAC9B;CACA,MAAM,UAAU,OAAO,OAAO,WAAW,UAAU;EAAE;EAAU,OAAO,MAAM;CAAM,CAAC,CAAC,CAAC,CAAC,KACpF,OAAO,SAAS,WAAW,CAC7B;CACA,OAAO,OAAO,oBAAoB;EAChC,SAAS,SAAS,QAAQ,WAAW;EACrC,OAAO,QAAQ,KAAK,MAAM;EAC1B,MAAM,QAAQ,KAAK;CACrB,CAAC;CAED,OAAO;EADc,GAAG;EAAS,SAAS,SAAS;CACzC;AACZ,CAAC"}
|
|
1
|
+
{"version":3,"file":"convert-als.mjs","names":["Arr","Rec","NONE","Arr","Arr","NEXT","pointsOf","NONE","NEXT","Arr","Arr","Bool"],"sources":["../src/features/convert-als/model/live-set.ts","../src/features/convert-als/model/clips.ts","../src/features/convert-als/model/tempo-map.ts","../src/features/convert-als/model/ticks.ts","../src/features/convert-als/model/mix.ts","../src/features/convert-als/model/timeline.ts","../src/features/convert-als/model/convert.ts"],"sourcesContent":["import { Array as Arr, Effect, Option, Record as Rec, Schema, pipe } from \"effect\";\nimport { XMLParser } from \"fast-xml-parser\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class UnreadableAls extends taggedError<UnreadableAls, { readonly brand: unique symbol }>()(\n \"UnreadableAls\",\n { message: Schema.String },\n { identifier: \"UnreadableAls\" },\n) {}\n\nconst REPEATED = new Set([\n \"MidiTrack\",\n \"AudioTrack\",\n \"GroupTrack\",\n \"ReturnTrack\",\n \"MidiClip\",\n \"AudioClip\",\n \"KeyTrack\",\n \"MidiNoteEvent\",\n \"Locator\",\n \"AutomationEnvelope\",\n \"FloatEvent\",\n \"EnumEvent\",\n \"BoolEvent\",\n \"TrackSendHolder\",\n]);\n\nconst ATTRIBUTES = \"@\";\n\nconst parser = new XMLParser({\n ignoreAttributes: false,\n attributeNamePrefix: \"\",\n attributesGroupName: ATTRIBUTES,\n parseTagValue: false,\n parseAttributeValue: false,\n jPath: false,\n isArray: (name: string): boolean => REPEATED.has(name),\n});\n\nconst Num = Schema.Struct({ Value: Schema.FiniteFromString });\nconst Text = Schema.Struct({ Value: Schema.String });\nconst Flag = Schema.Struct({ Value: Schema.Literals([\"true\", \"false\"]) });\n\nconst EventSchema = Schema.Struct({ Time: Schema.FiniteFromString, Value: Schema.String });\n\nexport type AutomationEvent = typeof EventSchema.Type;\n\nconst EventsSchema = Schema.Struct({\n FloatEvent: EventSchema.pipe(Schema.Array, Schema.optionalKey),\n EnumEvent: EventSchema.pipe(Schema.Array, Schema.optionalKey),\n BoolEvent: EventSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst EnvelopeSchema = Schema.Struct({\n EnvelopeTarget: Schema.Struct({ PointeeId: Num }),\n Automation: Schema.Struct({ Events: EventsSchema }),\n});\n\nexport type AutomationEnvelope = typeof EnvelopeSchema.Type;\n\nconst EnvelopeListSchema = Schema.Struct({\n AutomationEnvelope: EnvelopeSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst EnvelopesSchema = Schema.Struct({ Envelopes: EnvelopeListSchema });\n\nconst TargetSchema = Schema.Struct({ Id: Schema.FiniteFromString });\n\nconst ParameterSchema = Schema.Struct({\n Manual: Schema.optionalKey(Num),\n AutomationTarget: Schema.optionalKey(TargetSchema),\n ArrangerAutomation: Schema.optionalKey(Schema.Struct({ Events: EventsSchema })),\n});\n\nexport type Parameter = typeof ParameterSchema.Type;\n\nconst NoteSchema = Schema.Struct({\n Time: Schema.FiniteFromString,\n Duration: Schema.FiniteFromString,\n Velocity: Schema.FiniteFromString,\n OffVelocity: Schema.optionalKey(Schema.FiniteFromString),\n IsEnabled: Schema.optionalKey(Schema.Literals([\"true\", \"false\"])),\n Probability: Schema.optionalKey(Schema.FiniteFromString),\n VelocityDeviation: Schema.optionalKey(Schema.FiniteFromString),\n});\n\nconst NoteListSchema = Schema.Struct({\n MidiNoteEvent: NoteSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst KeyTrackSchema = Schema.Struct({ Notes: NoteListSchema, MidiKey: Num });\n\nconst LoopSchema = Schema.Struct({\n LoopStart: Num,\n LoopEnd: Num,\n StartRelative: Num,\n LoopOn: Flag,\n});\n\nconst KeyTracksSchema = Schema.Struct({\n KeyTrack: KeyTrackSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst ClipSchema = Schema.Struct({\n CurrentStart: Num,\n CurrentEnd: Num,\n Loop: LoopSchema,\n Disabled: Schema.optionalKey(Flag),\n Notes: Schema.Struct({ KeyTracks: KeyTracksSchema }),\n});\n\nexport type AlsClip = typeof ClipSchema.Type;\n\nconst NameSchema = Schema.Struct({\n EffectiveName: Schema.optionalKey(Text),\n UserName: Schema.optionalKey(Text),\n});\n\nconst DrumsSchema = Schema.Struct({ DrumGroupDevice: Schema.optionalKey(Schema.Unknown) });\n\nconst DevicesSchema = Schema.Struct({ Devices: Schema.optionalKey(DrumsSchema) });\n\nconst ClipEventsSchema = Schema.Struct({\n MidiClip: ClipSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst ArrangementSchema = Schema.Struct({\n ArrangerAutomation: Schema.Struct({ Events: ClipEventsSchema }),\n});\n\nconst SendHolderSchema = Schema.Struct({ Send: ParameterSchema });\n\nconst SendsSchema = Schema.Struct({\n TrackSendHolder: SendHolderSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst SpeakerSchema = Schema.Struct({ Manual: Schema.optionalKey(Flag) });\n\nconst TrackMixerSchema = Schema.Struct({\n Volume: ParameterSchema,\n Pan: ParameterSchema,\n Speaker: Schema.optionalKey(SpeakerSchema),\n Sends: Schema.optionalKey(SendsSchema),\n});\n\nexport type AlsMixer = typeof TrackMixerSchema.Type;\n\nconst TrackChainSchema = Schema.Struct({\n DeviceChain: Schema.optionalKey(DevicesSchema),\n Mixer: Schema.optionalKey(TrackMixerSchema),\n MainSequencer: Schema.Struct({ ClipTimeable: ArrangementSchema }),\n});\n\nconst MidiTrackSchema = Schema.Struct({\n Id: Schema.String,\n Name: NameSchema,\n AutomationEnvelopes: Schema.optionalKey(EnvelopesSchema),\n DeviceChain: TrackChainSchema,\n});\n\nexport type AlsMidiTrack = typeof MidiTrackSchema.Type;\n\nconst ReturnTrackSchema = Schema.Struct({\n Name: NameSchema,\n DeviceChain: Schema.Struct({ Mixer: Schema.optionalKey(TrackMixerSchema) }),\n});\n\nexport type AlsReturnTrack = typeof ReturnTrackSchema.Type;\n\nconst MixerSchema = Schema.Struct({ Tempo: ParameterSchema, TimeSignature: ParameterSchema });\n\nconst MasterSchema = Schema.Struct({\n AutomationEnvelopes: Schema.optionalKey(EnvelopesSchema),\n DeviceChain: Schema.optionalKey(Schema.Struct({ Mixer: MixerSchema })),\n MasterChain: Schema.optionalKey(Schema.Struct({ Mixer: MixerSchema })),\n});\n\nexport type AlsMaster = typeof MasterSchema.Type;\n\nconst LocatorSchema = Schema.Struct({ Time: Num, Name: Text });\n\nexport type AlsLocator = typeof LocatorSchema.Type;\n\nconst TracksSchema = Schema.Struct({\n MidiTrack: MidiTrackSchema.pipe(Schema.Array, Schema.optionalKey),\n ReturnTrack: ReturnTrackSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst LocatorListSchema = Schema.Struct({\n Locator: LocatorSchema.pipe(Schema.Array, Schema.optionalKey),\n});\n\nconst LiveSetSchema = Schema.Struct({\n Tracks: TracksSchema,\n MasterTrack: Schema.optionalKey(MasterSchema),\n MainTrack: Schema.optionalKey(MasterSchema),\n Locators: Schema.optionalKey(Schema.Struct({ Locators: LocatorListSchema })),\n});\n\nexport type LiveSet = typeof LiveSetSchema.Type;\n\nconst DocumentSchema = Schema.Struct({\n Ableton: Schema.Struct({\n MajorVersion: Schema.String,\n MinorVersion: Schema.String,\n Creator: Schema.optionalKey(Schema.String),\n LiveSet: LiveSetSchema,\n }),\n});\n\nconst decodeDocument = Schema.decodeUnknownEffect(DocumentSchema);\n\nconst isElement = Schema.is(Schema.Record(Schema.String, Schema.Unknown));\nconst isAttributes = Schema.is(Schema.Record(Schema.String, Schema.String));\n\nconst flattened = (node: unknown): unknown => {\n if (node === \"\") {\n return {};\n }\n if (Arr.isArray(node)) {\n return pipe(\n node,\n Arr.map((child) => flattened(child)),\n );\n }\n if (isElement(node)) {\n const { [ATTRIBUTES]: attributes, ...children } = node;\n const own = pipe(\n Option.liftPredicate(attributes, isAttributes),\n Option.getOrElse((): Readonly<Record<string, string>> => ({})),\n );\n return {\n ...pipe(\n children,\n Rec.map((child) => flattened(child)),\n ),\n ...own,\n };\n }\n return node;\n};\n\nconst gunzip = (bytes: Uint8Array): Effect.Effect<string, UnreadableAls> =>\n Effect.tryPromise({\n try: () =>\n new Response(\n new Blob([Uint8Array.from(bytes)]).stream().pipeThrough(new DecompressionStream(\"gzip\")),\n ).text(),\n catch: (cause) => UnreadableAls.make({ message: `Not a gzipped Live Set: ${String(cause)}` }),\n });\n\nexport type AlsDocument = typeof DocumentSchema.Type;\n\nexport const readAlsDocument: (bytes: Uint8Array) => Effect.Effect<AlsDocument, UnreadableAls> =\n Effect.fn(\"readAlsDocument\")(function* read(\n bytes: Uint8Array,\n ): Effect.fn.Return<AlsDocument, UnreadableAls> {\n const xml = yield* gunzip(bytes);\n const parsed = yield* Effect.try({\n try: () => flattened(parser.parse(xml)),\n catch: (cause) => UnreadableAls.make({ message: `Not XML: ${String(cause)}` }),\n });\n return yield* decodeDocument(parsed).pipe(\n Effect.mapError((issue) =>\n UnreadableAls.make({ message: `Not a Live Set this converter reads: ${String(issue)}` }),\n ),\n );\n });\n","import { Array as Arr, Option, Order, pipe } from \"effect\";\n\nimport type { From } from \"#/shared/lib/from.ts\";\n\nimport type { AlsClip } from \"./live-set.ts\";\n\nconst NONE = 0;\n\nexport interface PlayedNote {\n readonly beat: number;\n readonly length: number;\n readonly midi: number;\n readonly velocity: number;\n readonly release: number;\n}\n\ninterface Pass {\n readonly at: number;\n readonly from: number;\n readonly to: number;\n}\n\ninterface SourceNote {\n readonly time: number;\n readonly end: number;\n readonly midi: number;\n readonly velocity: number;\n readonly release: number;\n}\n\nconst DEFAULT_RELEASE = 64;\n\nconst modulo = (value: number, size: number): number => ((value % size) + size) % size;\n\nconst passesOf: From<AlsClip, readonly Pass[]> = (clip) => {\n const start = clip.CurrentStart.Value;\n const length = clip.CurrentEnd.Value - start;\n const loopStart = clip.Loop.LoopStart.Value;\n const loopLength = clip.Loop.LoopEnd.Value - loopStart;\n if (clip.Loop.LoopOn.Value === \"false\" || loopLength <= NONE) {\n return [{ at: start, from: loopStart, to: loopStart + length }];\n }\n const first = loopStart + modulo(clip.Loop.StartRelative.Value, loopLength);\n const walk = (elapsed: number, from: number, passes: readonly Pass[]): readonly Pass[] => {\n if (elapsed >= length) {\n return passes;\n }\n const span = Math.min(clip.Loop.LoopEnd.Value - from, length - elapsed);\n return walk(elapsed + span, loopStart, [\n ...passes,\n { at: start + elapsed, from, to: from + span },\n ]);\n };\n return walk(NONE, first, []);\n};\n\nconst releaseOf = (offVelocity: number | undefined): number =>\n pipe(\n Option.fromUndefinedOr(offVelocity),\n Option.filter((off) => off !== NONE),\n Option.match({ onNone: () => DEFAULT_RELEASE, onSome: Math.round }),\n );\n\nconst sourceNotesOf: From<AlsClip, readonly SourceNote[]> = (clip) =>\n pipe(\n clip.Notes.KeyTracks.KeyTrack ?? [],\n Arr.flatMap((keyTrack) =>\n pipe(\n keyTrack.Notes.MidiNoteEvent ?? [],\n Arr.filter((note) => note.IsEnabled !== \"false\"),\n Arr.map((note): SourceNote => ({\n time: note.Time,\n end: note.Time + note.Duration,\n midi: keyTrack.MidiKey.Value,\n velocity: Math.round(note.Velocity),\n release: releaseOf(note.OffVelocity),\n })),\n ),\n ),\n );\n\nconst inPass =\n (notes: readonly SourceNote[]): From<Pass, readonly PlayedNote[]> =>\n (pass) =>\n pipe(\n notes,\n Arr.filter((note) => note.time >= pass.from && note.time < pass.to),\n Arr.map((note): PlayedNote => ({\n beat: pass.at + note.time - pass.from,\n length: Math.min(note.end, pass.to) - note.time,\n midi: note.midi,\n velocity: note.velocity,\n release: note.release,\n })),\n );\n\nconst byStartThenPitch = Order.combine(\n Order.mapInput(Order.Number, (note: PlayedNote) => note.beat),\n Order.mapInput(Order.Number, (note: PlayedNote) => note.midi),\n);\n\nconst isDisabled: From<AlsClip, boolean> = (clip) =>\n Option.exists(Option.fromUndefinedOr(clip.Disabled), (flag) => flag.Value === \"true\");\n\nexport const notesOfClip: From<AlsClip, readonly PlayedNote[]> = (clip) => {\n if (isDisabled(clip)) {\n return [];\n }\n const notes = sourceNotesOf(clip);\n return pipe(passesOf(clip), Arr.flatMap(inPass(notes)), Arr.sortBy(byStartThenPitch));\n};\n","import { decodeTimeSignatureId } from \"ableton-als\";\nimport { Array as Arr, Option, Order, pipe } from \"effect\";\n\nimport type { From } from \"#/shared/lib/from.ts\";\n\nimport type {\n AlsLocator,\n AlsMaster,\n AutomationEnvelope,\n AutomationEvent,\n LiveSet,\n Parameter,\n} from \"./live-set.ts\";\n\nexport const SONG_START = 0;\n\nexport interface Point {\n readonly beat: number;\n readonly value: number;\n}\n\nexport interface TempoSegment {\n readonly beat: number;\n readonly bpm: number;\n readonly target: Option.Option<number>;\n}\n\nexport interface MeterChange {\n readonly beat: number;\n readonly numerator: number;\n readonly denominator: number;\n}\n\nexport interface Locator {\n readonly beat: number;\n readonly name: string;\n}\n\nconst masterOf: From<LiveSet, Option.Option<AlsMaster>> = (liveSet) =>\n Option.orElse(Option.fromUndefinedOr(liveSet.MasterTrack), () =>\n Option.fromUndefinedOr(liveSet.MainTrack),\n );\n\ninterface Mixer {\n readonly Tempo: Parameter;\n readonly TimeSignature: Parameter;\n}\n\nconst mixerOf: From<AlsMaster, Option.Option<Mixer>> = (master) =>\n pipe(\n Option.fromUndefinedOr(master.DeviceChain),\n Option.orElse(() => Option.fromUndefinedOr(master.MasterChain)),\n Option.map((chain) => chain.Mixer),\n );\n\nconst eventsOf = (events: {\n readonly FloatEvent?: readonly AutomationEvent[];\n readonly EnumEvent?: readonly AutomationEvent[];\n readonly BoolEvent?: readonly AutomationEvent[];\n}): readonly AutomationEvent[] => [\n ...(events.FloatEvent ?? []),\n ...(events.EnumEvent ?? []),\n ...(events.BoolEvent ?? []),\n];\n\nexport type Automated = Pick<AlsMaster, \"AutomationEnvelopes\">;\n\nconst automationEnvelopesOf = (owner: Automated): readonly AutomationEnvelope[] =>\n pipe(\n Option.fromUndefinedOr(owner.AutomationEnvelopes),\n Option.flatMap((envelopes) => Option.fromUndefinedOr(envelopes.Envelopes.AutomationEnvelope)),\n Option.getOrElse((): readonly AutomationEnvelope[] => []),\n );\n\nconst byTime = Order.mapInput(Order.Number, (event: AutomationEvent) => event.Time);\n\nexport const envelopeOf =\n (owner: Automated): From<Parameter, readonly AutomationEvent[]> =>\n (parameter) => {\n const inline = pipe(\n Option.fromUndefinedOr(parameter.ArrangerAutomation),\n Option.map((automation) => automation.Events),\n );\n const pointed = pipe(\n Option.fromUndefinedOr(parameter.AutomationTarget),\n Option.flatMap((target) =>\n pipe(\n automationEnvelopesOf(owner),\n Arr.findFirst((envelope) => envelope.EnvelopeTarget.PointeeId.Value === target.Id),\n ),\n ),\n Option.map((envelope) => envelope.Automation.Events),\n );\n return pipe(\n Option.orElse(pointed, () => inline),\n Option.map(eventsOf),\n Option.getOrElse((): readonly AutomationEvent[] => []),\n Arr.sortBy(byTime),\n );\n };\n\nconst SINGLE = 1;\nconst NEXT = 1;\n\ninterface Automation {\n readonly events: readonly AutomationEvent[];\n readonly manual: Option.Option<number>;\n}\n\nconst automationOf =\n (select: From<Mixer, Parameter>): From<LiveSet, Option.Option<Automation>> =>\n (liveSet) =>\n pipe(\n masterOf(liveSet),\n Option.flatMap((master) =>\n pipe(\n mixerOf(master),\n Option.map((mixer): Automation => {\n const parameter = select(mixer);\n return {\n events: envelopeOf(master)(parameter),\n manual: pipe(\n Option.fromUndefinedOr(parameter.Manual),\n Option.map((manual) => manual.Value),\n ),\n };\n }),\n ),\n ),\n );\n\nconst tempoAutomationOf = automationOf((mixer) => mixer.Tempo);\n\nconst pointsOf = (events: readonly AutomationEvent[]): readonly Point[] =>\n pipe(\n events,\n Arr.map((event): Point => ({ beat: event.Time, value: Number(event.Value) })),\n );\n\nconst tempoFrom =\n (resolve: From<Automation, readonly Point[]>): From<LiveSet, readonly Point[]> =>\n (liveSet) =>\n pipe(\n tempoAutomationOf(liveSet),\n Option.map(resolve),\n Option.getOrElse((): readonly Point[] => []),\n );\n\nexport const tempoEnvelopeOf = tempoFrom(({ events }) => pointsOf(events));\n\nconst manualPointsOf = tempoFrom(({ manual }) =>\n pipe(\n manual,\n Option.map((value): readonly Point[] => [{ beat: SONG_START, value }]),\n Option.getOrElse((): readonly Point[] => []),\n ),\n);\n\nexport const tempoPointsOf: From<LiveSet, readonly Point[]> = (liveSet) => {\n const envelope = tempoEnvelopeOf(liveSet);\n const manual = manualPointsOf(liveSet);\n if (envelope.length > SINGLE || !Arr.isReadonlyArrayNonEmpty(manual)) {\n return envelope;\n }\n return manual;\n};\n\nconst valueAt =\n (from: Point, to: Point): From<number, number> =>\n (beat) => {\n if (to.beat === from.beat) {\n return to.value;\n }\n return from.value + ((to.value - from.value) * (beat - from.beat)) / (to.beat - from.beat);\n };\n\nconst segmentOf = (from: Point, next: Option.Option<Point>): TempoSegment => {\n const start = Math.max(from.beat, SONG_START);\n return Option.match(next, {\n onNone: () => ({ beat: start, bpm: from.value, target: Option.none() }),\n onSome: (to) => {\n const bpm = valueAt(from, to)(start);\n if (to.beat <= start || to.value === bpm) {\n return { beat: start, bpm, target: Option.none() };\n }\n return { beat: start, bpm, target: Option.some(to.value) };\n },\n });\n};\n\nconst keptWith = (\n kept: readonly TempoSegment[],\n segment: TempoSegment,\n): readonly TempoSegment[] => {\n const earlier = pipe(\n Arr.last(kept),\n Option.filter((last) => last.beat === segment.beat),\n Option.match({ onNone: () => kept, onSome: () => Arr.dropRight(kept, SINGLE) }),\n );\n const redundant = pipe(\n Arr.last(earlier),\n Option.exists(\n (last) =>\n Option.isNone(last.target) && Option.isNone(segment.target) && last.bpm === segment.bpm,\n ),\n );\n if (redundant) {\n return earlier;\n }\n return [...earlier, segment];\n};\n\nconst withoutRepeats = (segments: readonly TempoSegment[]): readonly TempoSegment[] => {\n let kept: readonly TempoSegment[] = [];\n for (const segment of segments) {\n kept = keptWith(kept, segment);\n }\n return kept;\n};\n\nexport const tempoSegmentsOf: From<readonly Point[], readonly TempoSegment[]> = (points) =>\n pipe(\n points,\n Arr.map((point, index) => ({ point, next: Arr.get(points, index + NEXT) })),\n Arr.filter(({ next }) =>\n Option.match(next, { onNone: () => true, onSome: (to) => to.beat > SONG_START }),\n ),\n Arr.map(({ point, next }) => segmentOf(point, next)),\n withoutRepeats,\n );\n\nconst meterOfId = (beat: number, id: number): Option.Option<MeterChange> =>\n pipe(\n Option.fromNullishOr(decodeTimeSignatureId(id)),\n Option.map((signature) => ({\n beat: Math.max(beat, SONG_START),\n numerator: signature.num,\n denominator: signature.den,\n })),\n );\n\nexport const metersOf: From<LiveSet, readonly MeterChange[]> = (liveSet) =>\n pipe(\n automationOf((mixer) => mixer.TimeSignature)(liveSet),\n Option.map(({ events, manual }) => {\n if (events.length > SINGLE || Option.isNone(manual)) {\n return pipe(\n events,\n Arr.map((event) => meterOfId(event.Time, Number(event.Value))),\n Arr.getSomes,\n Arr.reverse,\n Arr.dedupeAdjacentWith((later, earlier) => later.beat === earlier.beat),\n Arr.reverse,\n );\n }\n return Option.toArray(meterOfId(SONG_START, manual.value));\n }),\n Option.getOrElse((): readonly MeterChange[] => []),\n );\n\nconst byBeat = Order.mapInput(Order.Number, (locator: Locator) => locator.beat);\n\nexport const locatorsOf: From<LiveSet, readonly Locator[]> = (liveSet) =>\n pipe(\n Option.fromUndefinedOr(liveSet.Locators),\n Option.flatMap((locators) => Option.fromUndefinedOr(locators.Locators.Locator)),\n Option.getOrElse((): readonly AlsLocator[] => []),\n Arr.map((locator): Locator => ({ beat: locator.Time.Value, name: locator.Name.Value })),\n Arr.sortBy(byBeat),\n );\n","import type { From } from \"#/shared/lib/from.ts\";\nimport { TICKS_PER_WHOLE } from \"#/shared/lib/ticks.ts\";\n\nconst QUARTERS_PER_WHOLE = 4;\nconst TICKS_PER_BEAT = TICKS_PER_WHOLE / QUARTERS_PER_WHOLE;\n\nexport interface Tick {\n readonly tick: number;\n readonly exact: boolean;\n}\n\nexport const tickOf: From<number, Tick> = (beat) => {\n const exact = beat * TICKS_PER_BEAT;\n return { tick: Math.round(exact), exact: Number.isInteger(exact) };\n};\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport { MIXER_PARAMETERS } from \"#/entities/song/index.ts\";\nimport type {\n BusMix,\n Envelope,\n Level,\n Mix,\n MixParameter,\n MixPoint,\n TrackMix,\n TrackSend,\n} from \"#/entities/timeline/index.ts\";\nimport type { From } from \"#/shared/lib/from.ts\";\n\nimport type { AlsMidiTrack, AlsMixer, AlsReturnTrack, LiveSet, Parameter } from \"./live-set.ts\";\nimport { SONG_START, envelopeOf } from \"./tempo-map.ts\";\nimport type { Automated } from \"./tempo-map.ts\";\nimport { tickOf } from \"./ticks.ts\";\n\nconst DECIBELS_PER_DECADE = 20;\nconst SILENT_DECIBELS = -70;\nconst AUDIBLE_SEND = 0.001;\nconst NONE = 0;\nconst NEXT = 1;\n\nconst DECIMAL_BASE = 10;\nconst SILENT = DECIMAL_BASE ** (SILENT_DECIBELS / DECIBELS_PER_DECADE);\n\nconst decibelsOf: From<number, number> = (gain) =>\n DECIBELS_PER_DECADE * Math.log10(Math.max(gain, SILENT));\n\nconst [VOLUME, PAN] = MIXER_PARAMETERS;\n\nconst VALUES: Readonly<Record<MixParameter, From<number, number>>> = {\n volume: decibelsOf,\n pan: (pan) => pan,\n};\n\nconst RESTING: Readonly<Record<MixParameter, number>> = { volume: NONE, pan: NONE };\n\ntype Owned = Readonly<{ owner: Automated; parameter: MixParameter }>;\n\nconst pointsOf =\n ({ owner, parameter }: Owned): From<Parameter, readonly MixPoint[]> =>\n (control) =>\n pipe(\n envelopeOf(owner)(control),\n Arr.map((event) => ({\n tick: tickOf(Math.max(event.Time, SONG_START)).tick,\n value: VALUES[parameter](Number(event.Value)),\n })),\n Arr.filter((point) => Number.isFinite(point.value)),\n );\n\nconst startOf =\n (owned: Owned): From<Parameter, number> =>\n (control) =>\n pipe(\n pointsOf(owned)(control),\n Arr.head,\n Option.map((point) => point.value),\n Option.orElse(() =>\n pipe(\n Option.fromUndefinedOr(control.Manual),\n Option.map((manual) => VALUES[owned.parameter](manual.Value)),\n ),\n ),\n Option.getOrElse(() => RESTING[owned.parameter]),\n );\n\nconst levelOf =\n (owner: Automated): From<AlsMixer, Level> =>\n (mixer) => ({\n decibels: startOf({ owner, parameter: VOLUME })(mixer.Volume),\n pan: startOf({ owner, parameter: PAN })(mixer.Pan),\n muted: pipe(\n Option.fromUndefinedOr(mixer.Speaker),\n Option.flatMap((speaker) => Option.fromUndefinedOr(speaker.Manual)),\n Option.exists((manual) => manual.Value === \"false\"),\n ),\n });\n\nconst sendsOf: From<AlsMixer, readonly TrackSend[]> = (mixer) =>\n pipe(\n Option.fromUndefinedOr(mixer.Sends),\n Option.flatMap((sends) => Option.fromUndefinedOr(sends.TrackSendHolder)),\n Option.getOrElse(() => []),\n Arr.map((holder, bus) => ({\n bus,\n amount: pipe(\n Option.fromUndefinedOr(holder.Send.Manual),\n Option.match({ onNone: () => NONE, onSome: (manual) => manual.Value }),\n ),\n })),\n Arr.filter((send) => send.amount > AUDIBLE_SEND),\n );\n\nconst envelopesOf =\n (owner: Automated): From<AlsMixer, readonly Envelope[]> =>\n (mixer) =>\n pipe(\n [\n { parameter: \"volume\" as const, control: mixer.Volume },\n { parameter: \"pan\" as const, control: mixer.Pan },\n ],\n Arr.map(({ parameter, control }) => ({\n parameter,\n points: pointsOf({ owner, parameter })(control),\n })),\n Arr.filter((envelope) => envelope.points.length > NEXT),\n );\n\nconst trackMixOf: From<AlsMidiTrack, Option.Option<TrackMix>> = (track) =>\n pipe(\n Option.fromUndefinedOr(track.DeviceChain.Mixer),\n Option.map((mixer) => ({\n level: levelOf(track)(mixer),\n sends: sendsOf(mixer),\n envelopes: envelopesOf(track)(mixer),\n })),\n );\n\nconst NO_ENVELOPES: Automated = {};\n\nconst busOf =\n (nameOf: From<AlsReturnTrack[\"Name\"], Option.Option<string>>): From<AlsReturnTrack, BusMix> =>\n (track) => ({\n name: nameOf(track.Name),\n level: pipe(\n Option.fromUndefinedOr(track.DeviceChain.Mixer),\n Option.match({\n onNone: () => ({ decibels: NONE, pan: NONE, muted: false }),\n onSome: levelOf(NO_ENVELOPES),\n }),\n ),\n });\n\nexport const mixOf =\n (nameOf: From<AlsReturnTrack[\"Name\"], Option.Option<string>>): From<LiveSet, Mix> =>\n (liveSet) => ({\n tracks: new Map(\n pipe(\n liveSet.Tracks.MidiTrack ?? [],\n Arr.flatMap((track, index) =>\n pipe(\n trackMixOf(track),\n Option.map((mix) => [index, mix] as const),\n Option.toArray,\n ),\n ),\n ),\n ),\n buses: pipe(liveSet.Tracks.ReturnTrack ?? [], Arr.map(busOf(nameOf))),\n });\n","import { Array as Arr, Boolean as Bool, Option, pipe } from \"effect\";\n\nimport { microsecondsOf, sortedByTick, sortedNotes } from \"#/entities/timeline/index.ts\";\nimport type { Part, TempoChange, Timeline, TimelineNote } from \"#/entities/timeline/index.ts\";\nimport type { From } from \"#/shared/lib/from.ts\";\n\nimport { notesOfClip } from \"./clips.ts\";\nimport type { PlayedNote } from \"./clips.ts\";\nimport type { AlsMidiTrack, LiveSet } from \"./live-set.ts\";\nimport { mixOf } from \"./mix.ts\";\nimport { locatorsOf, metersOf, tempoPointsOf, tempoSegmentsOf } from \"./tempo-map.ts\";\nimport { tickOf } from \"./ticks.ts\";\n\nconst MELODIC_CHANNEL = 0;\nconst DRUM_CHANNEL = 9;\nconst NONE = 0;\nconst NEXT = 1;\n\nconst nameOf: From<AlsMidiTrack[\"Name\"], Option.Option<string>> = (label) =>\n pipe(\n [label.EffectiveName, label.UserName],\n Arr.map(Option.fromUndefinedOr),\n Arr.getSomes,\n Arr.map((name) => name.Value),\n Arr.findFirst((name) => name !== \"\"),\n );\n\nconst isDrumRack: From<AlsMidiTrack, boolean> = (track) =>\n pipe(\n Option.fromUndefinedOr(track.DeviceChain.DeviceChain),\n Option.flatMap((chain) => Option.fromUndefinedOr(chain.Devices)),\n Option.flatMap((devices) => Option.fromUndefinedOr(devices.DrumGroupDevice)),\n Option.isSome,\n );\n\ninterface TrackNotes {\n readonly notes: readonly TimelineNote[];\n readonly offGrid: number;\n}\n\nconst trackNotesOf: From<AlsMidiTrack, TrackNotes> = (track) => {\n const played: readonly PlayedNote[] = pipe(\n track.DeviceChain.MainSequencer.ClipTimeable.ArrangerAutomation.Events.MidiClip ?? [],\n Arr.flatMap(notesOfClip),\n );\n const placed = pipe(\n played,\n Arr.map((note) => ({\n note,\n start: tickOf(note.beat),\n end: tickOf(note.beat + note.length),\n })),\n );\n return {\n notes: sortedNotes(\n pipe(\n placed,\n Arr.map(({ note, start, end }): TimelineNote => ({\n tick: start.tick,\n end: end.tick,\n midi: note.midi,\n velocity: note.velocity,\n release: note.release,\n })),\n ),\n ),\n offGrid: Arr.countBy(placed, ({ start, end }) => !start.exact || !end.exact),\n };\n};\n\ninterface PartRead {\n readonly part: Part;\n readonly offGrid: number;\n}\n\nconst partOf = (track: AlsMidiTrack, index: number): PartRead => {\n const read = trackNotesOf(track);\n return {\n part: {\n track: index,\n channel: Bool.match(isDrumRack(track), {\n onFalse: () => MELODIC_CHANNEL,\n onTrue: () => DRUM_CHANNEL,\n }),\n name: nameOf(track.Name),\n program: Option.none(),\n notes: read.notes,\n controls: [],\n lyrics: [],\n },\n offGrid: read.offGrid,\n };\n};\n\nconst temposOf: From<LiveSet, readonly TempoChange[]> = (liveSet) =>\n pipe(\n tempoSegmentsOf(tempoPointsOf(liveSet)),\n Arr.map((segment): TempoChange => ({\n tick: tickOf(segment.beat).tick,\n microseconds: microsecondsOf(segment.bpm),\n target: pipe(segment.target, Option.map(microsecondsOf)),\n })),\n );\n\nconst lastOf: From<readonly number[], number> = (ticks) =>\n Arr.reduce(ticks, NONE, (latest, tick) => Math.max(latest, tick));\n\nexport const timelineOf: From<LiveSet, Timeline> = (liveSet) => {\n const reads = pipe(\n liveSet.Tracks.MidiTrack ?? [],\n Arr.map(partOf),\n Arr.filter((read) => Arr.isReadonlyArrayNonEmpty(read.part.notes)),\n );\n const parts = pipe(\n reads,\n Arr.map((read) => read.part),\n );\n const markers = sortedByTick(\n pipe(\n locatorsOf(liveSet),\n Arr.map((locator) => ({ tick: tickOf(locator.beat).tick, text: locator.name })),\n ),\n );\n const tempos = temposOf(liveSet);\n const meters = pipe(\n metersOf(liveSet),\n Arr.map((meter) => ({\n tick: tickOf(meter.beat).tick,\n numerator: meter.numerator,\n denominator: meter.denominator,\n })),\n );\n const noteEnds = pipe(\n parts,\n Arr.flatMap((part) => part.notes),\n Arr.map((note) => note.end),\n );\n const pointEnds = pipe(\n [...markers, ...tempos, ...meters],\n Arr.map((point) => point.tick + NEXT),\n );\n return {\n title: Option.none(),\n end: lastOf([...noteEnds, ...pointEnds]),\n offGrid: Arr.reduce(reads, NONE, (sum, read) => sum + read.offGrid),\n tempos,\n meters,\n markers,\n parts,\n mix: mixOf(nameOf)(liveSet),\n };\n};\n","import { Effect } from \"effect\";\n\nimport { writeFumx } from \"#/entities/timeline/index.ts\";\nimport type { Written } from \"#/entities/timeline/index.ts\";\n\nimport { readAlsDocument } from \"./live-set.ts\";\nimport { timelineOf } from \"./timeline.ts\";\n\nexport interface LiveSetFile {\n readonly bytes: Uint8Array;\n readonly title: string;\n}\n\nexport interface Fumx extends Written {\n readonly offGrid: number;\n}\n\nexport const alsToFumx = Effect.fn(\"alsToFumx\")(function* convert(input: LiveSetFile) {\n const document = yield* readAlsDocument(input.bytes);\n const timeline = yield* Effect.sync(() => timelineOf(document.Ableton.LiveSet)).pipe(\n Effect.withSpan(\"timelineOf\"),\n );\n const written = yield* Effect.sync(() => writeFumx({ timeline, title: input.title })).pipe(\n Effect.withSpan(\"writeFumx\"),\n );\n yield* Effect.annotateCurrentSpan({\n creator: document.Ableton.Creator ?? \"\",\n parts: written.plan.parts.length,\n bars: written.bars.length,\n });\n const fumx: Fumx = { ...written, offGrid: timeline.offGrid };\n return fumx;\n});\n"],"mappings":";;;;;;;AAGA,MAAM,cAAc,OAAO;AAE3B,IAAa,gBAAb,cAAmC,YAA8D,CAAC,CAChG,iBACA,EAAE,SAAS,OAAO,OAAO,GACzB,EAAE,YAAY,gBAAgB,CAChC,CAAC,CAAC,CAAC;AAEH,MAAM,2BAAW,IAAI,IAAI;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,aAAa;AAEnB,MAAM,SAAS,IAAI,UAAU;CAC3B,kBAAkB;CAClB,qBAAqB;CACrB,qBAAqB;CACrB,eAAe;CACf,qBAAqB;CACrB,OAAO;CACP,UAAU,SAA0B,SAAS,IAAI,IAAI;AACvD,CAAC;AAED,MAAM,MAAM,OAAO,OAAO,EAAE,OAAO,OAAO,iBAAiB,CAAC;AAC5D,MAAM,OAAO,OAAO,OAAO,EAAE,OAAO,OAAO,OAAO,CAAC;AACnD,MAAM,OAAO,OAAO,OAAO,EAAE,OAAO,OAAO,SAAS,CAAC,QAAQ,OAAO,CAAC,EAAE,CAAC;AAExE,MAAM,cAAc,OAAO,OAAO;CAAE,MAAM,OAAO;CAAkB,OAAO,OAAO;AAAO,CAAC;AAIzF,MAAM,eAAe,OAAO,OAAO;CACjC,YAAY,YAAY,KAAK,OAAO,OAAO,OAAO,WAAW;CAC7D,WAAW,YAAY,KAAK,OAAO,OAAO,OAAO,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W,UAAU;EAAE;EAAU,OAAO,MAAM;CAAM,CAAC,CAAC,CAAC,CAAC,KACpF,OAAO,SAAS,WAAW,CAC7B;CACA,OAAO,OAAO,oBAAoB;EAChC,SAAS,SAAS,QAAQ,WAAW;EACrC,OAAO,QAAQ,KAAK,MAAM;EAC1B,MAAM,QAAQ,KAAK;CACrB,CAAC;CAED,OAAO;EADc,GAAG;EAAS,SAAS,SAAS;CACzC;AACZ,CAAC"}
|
package/dist/convert-midi.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as sortedNotes, n as NO_MIX, r as sortedByTick, t as writeFumx } from "./write-
|
|
1
|
+
import { i as sortedNotes, n as NO_MIX, r as sortedByTick, t as writeFumx } from "./write-CuDbIkpM.mjs";
|
|
2
2
|
import { t as TICKS_PER_WHOLE } from "./ticks-CXehHP2w.mjs";
|
|
3
3
|
import { Array, Effect, Match, Option, Order, Predicate, Record, Schema, pipe } from "effect";
|
|
4
4
|
import { parseMidi } from "midi-file";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { l as FumxGeneratedModule, r as registerChecks, t as FumxModule, u as FumxGeneratedSharedModule } from "./fumx-module-
|
|
2
|
+
import { l as FumxGeneratedModule, r as registerChecks, t as FumxModule, u as FumxGeneratedSharedModule } from "./fumx-module-CqxUe07y.mjs";
|
|
3
3
|
import { inject } from "langium";
|
|
4
4
|
import { createDefaultModule, createDefaultSharedModule, startLanguageServer } from "langium/lsp";
|
|
5
5
|
import { NodeFileSystem } from "langium/node";
|
|
@@ -10303,31 +10303,20 @@ const moduleFor = (use) => (plugin) => {
|
|
|
10303
10303
|
if (home.toString() === there.toString()) return plugin.module;
|
|
10304
10304
|
return pathFrom(home)(there)(plugin.module);
|
|
10305
10305
|
};
|
|
10306
|
-
const
|
|
10307
|
-
|
|
10308
|
-
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10306
|
+
const plain = (kind) => (amount) => Option.some({
|
|
10307
|
+
kind,
|
|
10308
|
+
value: amount.value
|
|
10309
|
+
});
|
|
10310
|
+
const pluginValueOf = (value) => Match.value(value).pipe(Match.discriminators("kind")({
|
|
10311
|
+
number: plain("number"),
|
|
10312
|
+
decibels: plain("decibels"),
|
|
10313
|
+
hertz: plain("hertz"),
|
|
10314
|
+
time: plain("milliseconds"),
|
|
10315
|
+
semitones: plain("semitones"),
|
|
10315
10316
|
percent: (amount) => Option.some({
|
|
10316
10317
|
kind: "share",
|
|
10317
10318
|
value: amount.value / HUNDRED
|
|
10318
10319
|
}),
|
|
10319
|
-
hertz: (amount) => Option.some({
|
|
10320
|
-
kind: "hertz",
|
|
10321
|
-
value: amount.value
|
|
10322
|
-
}),
|
|
10323
|
-
time: (amount) => Option.some({
|
|
10324
|
-
kind: "milliseconds",
|
|
10325
|
-
value: amount.value
|
|
10326
|
-
}),
|
|
10327
|
-
semitones: (amount) => Option.some({
|
|
10328
|
-
kind: "semitones",
|
|
10329
|
-
value: amount.value
|
|
10330
|
-
}),
|
|
10331
10320
|
duration: (duration) => Option.some({
|
|
10332
10321
|
kind: "ticks",
|
|
10333
10322
|
value: duration.ticks
|
|
@@ -10344,10 +10333,8 @@ const pluginValueOf = (value) => Match.value(value).pipe(Match.discriminatorsExh
|
|
|
10344
10333
|
bool: (truth) => Option.some({
|
|
10345
10334
|
kind: "flag",
|
|
10346
10335
|
value: truth.value
|
|
10347
|
-
})
|
|
10348
|
-
|
|
10349
|
-
none: () => Option.none()
|
|
10350
|
-
}));
|
|
10336
|
+
})
|
|
10337
|
+
}), Match.orElse(() => Option.none()));
|
|
10351
10338
|
const typedValueOf = ([param, literal]) => {
|
|
10352
10339
|
const wanted = scalar(param.type.name);
|
|
10353
10340
|
const read = literalValue(literal);
|
|
@@ -11474,20 +11461,10 @@ const ok = (value) => ({
|
|
|
11474
11461
|
ok: true,
|
|
11475
11462
|
value
|
|
11476
11463
|
});
|
|
11477
|
-
const amountOf = (value) => Match.value(value).pipe(Match.
|
|
11464
|
+
const amountOf = (value) => Match.value(value).pipe(Match.discriminators("kind")({
|
|
11478
11465
|
duration: (duration) => duration.ticks,
|
|
11479
|
-
pitch: (pitch) => pitch.midi + pitch.cents / CENTS
|
|
11480
|
-
|
|
11481
|
-
decibels: (amount) => amount.value,
|
|
11482
|
-
percent: (amount) => amount.value,
|
|
11483
|
-
hertz: (amount) => amount.value,
|
|
11484
|
-
time: (amount) => amount.value,
|
|
11485
|
-
semitones: (amount) => amount.value,
|
|
11486
|
-
string: () => NaN,
|
|
11487
|
-
bool: () => NaN,
|
|
11488
|
-
list: () => NaN,
|
|
11489
|
-
none: () => NaN
|
|
11490
|
-
}));
|
|
11466
|
+
pitch: (pitch) => pitch.midi + pitch.cents / CENTS
|
|
11467
|
+
}), Match.when({ value: Match.number }, (amount) => amount.value), Match.orElse(() => NaN));
|
|
11491
11468
|
const ARITHMETIC = {
|
|
11492
11469
|
"+": ([left, right]) => left + right,
|
|
11493
11470
|
"-": ([left, right]) => left - right,
|
|
@@ -11545,6 +11522,10 @@ const scalarOf = (type) => {
|
|
|
11545
11522
|
if (type.kind === "list" || type.kind === "unknown") return Option.none();
|
|
11546
11523
|
return Option.some(type.kind);
|
|
11547
11524
|
};
|
|
11525
|
+
const boolRule = (holds) => ({
|
|
11526
|
+
result: scalar("bool"),
|
|
11527
|
+
apply: (pair) => ok(boolValue(holds(pair)))
|
|
11528
|
+
});
|
|
11548
11529
|
const ruled = (kind) => (operator) => ({
|
|
11549
11530
|
result: scalar(kind),
|
|
11550
11531
|
apply: numeric(operator)(kind)
|
|
@@ -11587,29 +11568,17 @@ const joinRule = ({ operator, left, right }) => {
|
|
|
11587
11568
|
const equalityRule = ({ operator, left, right }) => {
|
|
11588
11569
|
if (operator !== "==" && operator !== "!=" || !fits(left)(right)) return Option.none();
|
|
11589
11570
|
const wanted = operator === "==";
|
|
11590
|
-
return Option.some({
|
|
11591
|
-
result: scalar("bool"),
|
|
11592
|
-
apply: ({ left: first, right: second }) => ok(boolValue(sameValue(first)(second) === wanted))
|
|
11593
|
-
});
|
|
11571
|
+
return Option.some(boolRule(({ left: first, right: second }) => sameValue(first)(second) === wanted));
|
|
11594
11572
|
};
|
|
11595
|
-
const orderRule = ({ operator, left, right }) => pipe(Option.fromNullishOr(COMPARE[operator]), Option.filter(() => left.kind === right.kind && Array.contains([...COUNTABLE, "pitch"], left.kind)), Option.map((compare) => ({
|
|
11596
|
-
result: scalar("bool"),
|
|
11597
|
-
apply: ({ left: first, right: second }) => {
|
|
11598
|
-
const holds = compare([amountOf(first), amountOf(second)]);
|
|
11599
|
-
return ok(boolValue(holds));
|
|
11600
|
-
}
|
|
11601
|
-
})));
|
|
11573
|
+
const orderRule = ({ operator, left, right }) => pipe(Option.fromNullishOr(COMPARE[operator]), Option.filter(() => left.kind === right.kind && Array.contains([...COUNTABLE, "pitch"], left.kind)), Option.map((compare) => boolRule(({ left: first, right: second }) => compare([amountOf(first), amountOf(second)]))));
|
|
11602
11574
|
const truthOf = (value) => value.kind === "bool" && value.value;
|
|
11603
11575
|
const logicRule = ({ operator, left, right }) => {
|
|
11604
11576
|
if (operator !== "and" && operator !== "or" || left.kind !== "bool" || right.kind !== "bool") return Option.none();
|
|
11605
11577
|
const both = operator === "and";
|
|
11606
|
-
return Option.some({
|
|
11607
|
-
|
|
11608
|
-
|
|
11609
|
-
|
|
11610
|
-
return ok(boolValue(truthOf(first) || truthOf(second)));
|
|
11611
|
-
}
|
|
11612
|
-
});
|
|
11578
|
+
return Option.some(boolRule(({ left: first, right: second }) => {
|
|
11579
|
+
if (both) return truthOf(first) && truthOf(second);
|
|
11580
|
+
return truthOf(first) || truthOf(second);
|
|
11581
|
+
}));
|
|
11613
11582
|
};
|
|
11614
11583
|
const RULES = [
|
|
11615
11584
|
additiveRule,
|
|
@@ -11831,15 +11800,18 @@ const computeType = (context) => (node) => Match.value(node).pipe(Match.discrimi
|
|
|
11831
11800
|
Index: indexType(context),
|
|
11832
11801
|
Binary: binaryType(context)
|
|
11833
11802
|
}));
|
|
11834
|
-
const declaredType = (context) =>
|
|
11835
|
-
|
|
11836
|
-
|
|
11837
|
-
|
|
11838
|
-
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11842
|
-
|
|
11803
|
+
const declaredType = (context) => {
|
|
11804
|
+
const element = (items) => pipe(elementOf(context.typeOf(items)), Option.getOrElse(() => UNKNOWN$1));
|
|
11805
|
+
return (binding) => Match.value(binding).pipe(Match.discriminatorsExhaustive("$type")({
|
|
11806
|
+
Param: (param) => typeOfRef(param.type),
|
|
11807
|
+
Let: (node) => pipe(Option.fromNullishOr(node.type), Option.match({
|
|
11808
|
+
onNone: () => context.typeOf(node.value),
|
|
11809
|
+
onSome: (type) => typeOfRef(type)
|
|
11810
|
+
})),
|
|
11811
|
+
For: (node) => element(node.items),
|
|
11812
|
+
Each: (node) => element(node.items)
|
|
11813
|
+
}));
|
|
11814
|
+
};
|
|
11843
11815
|
const checkerFor = (problems) => {
|
|
11844
11816
|
const memo = /* @__PURE__ */ new Map();
|
|
11845
11817
|
const visiting = /* @__PURE__ */ new Set();
|
|
@@ -12510,4 +12482,4 @@ const createFumxServices = () => {
|
|
|
12510
12482
|
};
|
|
12511
12483
|
export { importedUriOf as a, fractionOf as c, FumxGrammar as d, FumxTerminals as f, compileSong as i, FumxGeneratedModule as l, createFumxServices as n, isNamed as o, isSong as p, registerChecks as r, TICKS_PER_WHOLE as s, FumxModule as t, FumxGeneratedSharedModule as u };
|
|
12512
12484
|
|
|
12513
|
-
//# sourceMappingURL=fumx-module-
|
|
12485
|
+
//# sourceMappingURL=fumx-module-CqxUe07y.mjs.map
|