revert fb8e77bb68
Local Build and Deploy / deploy (push) Successful in 1m11s
Local Build and Deploy / deploy (push) Successful in 1m11s
revert style: clean up code with prettier and eslint
This commit is contained in:
1 parent
27de078f54
commit
e85e4d74ea
378 files changed
+20710
-22428
No files matched your search
+19
-19
@@ -15,32 +15,32 @@
|
||||
* length equals the max per-channel tick-sum × 2 seconds.
|
||||
*/
|
||||
|
||||
export const TRAX_TICK_SECONDS = 2;
|
||||
export const TRAX_TICK_SECONDS = 2
|
||||
|
||||
export interface TraxEvent {
|
||||
sampleId: number;
|
||||
ticks: number;
|
||||
sampleId: number
|
||||
ticks: number
|
||||
}
|
||||
|
||||
export interface TraxChannel {
|
||||
channel: number;
|
||||
events: TraxEvent[];
|
||||
channel: number
|
||||
events: TraxEvent[]
|
||||
}
|
||||
|
||||
/** Split a raw track string into per-channel event lists. */
|
||||
export function parseTraxChannels(track: string | null | undefined): TraxChannel[] {
|
||||
if (!track) return [];
|
||||
const channels: TraxChannel[] = [];
|
||||
if (!track) return []
|
||||
const channels: TraxChannel[] = []
|
||||
for (const m of track.matchAll(/(\d+):([^:]+)/g)) {
|
||||
const channel = Number(m[1]);
|
||||
const events: TraxEvent[] = [];
|
||||
for (const raw of m[2].split(";")) {
|
||||
const pair = raw.match(/^(\d+),(\d+)$/);
|
||||
if (pair) events.push({ sampleId: Number(pair[1]), ticks: Number(pair[2]) });
|
||||
const channel = Number(m[1])
|
||||
const events: TraxEvent[] = []
|
||||
for (const raw of m[2].split(';')) {
|
||||
const pair = raw.match(/^(\d+),(\d+)$/)
|
||||
if (pair) events.push({ sampleId: Number(pair[1]), ticks: Number(pair[2]) })
|
||||
}
|
||||
if (events.length > 0) channels.push({ channel, events });
|
||||
if (events.length > 0) channels.push({ channel, events })
|
||||
}
|
||||
return channels;
|
||||
return channels
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,15 +48,15 @@ export function parseTraxChannels(track: string | null | undefined): TraxChannel
|
||||
* Returns [] for empty or unparseable tracks (i.e. single-sample song disks).
|
||||
*/
|
||||
export function parseTrackSamples(track: string | null | undefined): number[] {
|
||||
const set = new Set<number>();
|
||||
const set = new Set<number>()
|
||||
for (const ch of parseTraxChannels(track)) {
|
||||
for (const ev of ch.events) {
|
||||
if (ev.sampleId > 0) set.add(ev.sampleId);
|
||||
if (ev.sampleId > 0) set.add(ev.sampleId)
|
||||
}
|
||||
}
|
||||
return [...set].sort((a, b) => a - b);
|
||||
return [...set].sort((a, b) => a - b)
|
||||
}
|
||||
|
||||
export function detectSoundtrackKind(track: string | null | undefined): "single" | "composition" {
|
||||
return parseTrackSamples(track).length > 0 ? "composition" : "single";
|
||||
export function detectSoundtrackKind(track: string | null | undefined): 'single' | 'composition' {
|
||||
return parseTrackSamples(track).length > 0 ? 'composition' : 'single'
|
||||
}
|
||||
Reference in new issue
Block a user