Skip to content

Commit

Permalink
Add folder issues for audio
Browse files Browse the repository at this point in the history
  • Loading branch information
Geomitron committed Nov 6, 2023
1 parent 28348c3 commit 354e68b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-queens-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"scan-chart": patch
---

Add folder issues for audio
18 changes: 9 additions & 9 deletions src/audio/audio-scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { parse } from 'path'
import { CachedFile } from 'src/cached-file'
import { FolderIssueType } from '../interfaces'
import { hasAudioExtension, hasAudioName } from '../utils'
import { AudioParser } from './audio-parser'

class AudioScanner {

Expand All @@ -20,15 +19,16 @@ class AudioScanner {
const audioFiles = this.getAudioFiles(chartFolder)
if (audioFiles.length === 0) { return }

const audioParser = new AudioParser(max_threads)
const { audioHash, audioLength, errors } = await audioParser.getAudioFingerprint(audioFiles)
// TODO: Implement this when determining the best audio fingerprint algorithm
// const audioParser = new AudioParser(max_threads)
// const { audioHash, audioLength, errors } = await audioParser.getAudioFingerprint(audioFiles)

if (errors.length) {
this.addFolderIssue('badAudio', `This chart's audio couldn't be parsed:\n${errors.join('\n')}`)
} else {
this.audioHash = audioHash
this.audioLength = audioLength
}
// if (errors.length) {
// this.addFolderIssue('badAudio', `This chart's audio couldn't be parsed:\n${errors.join('\n')}`)
// } else {
// this.audioHash = audioHash
// this.audioLength = audioLength
// }
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import EventEmitter from 'events'
import { Dirent } from 'fs'
import { readdir } from 'fs/promises'
import * as _ from 'lodash'
import { cpus } from 'os'
import { join, parse, relative } from 'path'

import { scanAudio } from './audio'
import { CachedFile } from './cached-file'
import { scanChart } from './chart'
import { scanImage } from './image'
Expand Down Expand Up @@ -223,9 +225,8 @@ class ChartsScanner {
}
}

// TODO: Implement this when determining the best audio fingerprint algorithm
// const audioData = await scanAudio(chartFolder, cpus().length - 1)
// chart.folderIssues.push(...audioData.folderIssues)
const audioData = await scanAudio(chartFolder, cpus().length - 1)
chart.folderIssues.push(...audioData.folderIssues)

if (!chartData.notesData /* TODO: || !audioData.audioHash */) {
chart.playable = false
Expand Down

0 comments on commit 354e68b

Please sign in to comment.