From 3686d2ddc907f86f816fc6441e6bb429b222ee9c Mon Sep 17 00:00:00 2001 From: MCJack123 Date: Thu, 8 Aug 2024 00:42:19 -0400 Subject: [PATCH] Fixed linting --- .../lua/rom/modules/main/cc/audio/wav.lua | 16 ++++++++-------- .../test-rom/spec/modules/cc/audio/wav_spec.lua | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/projects/core/src/main/resources/data/computercraft/lua/rom/modules/main/cc/audio/wav.lua b/projects/core/src/main/resources/data/computercraft/lua/rom/modules/main/cc/audio/wav.lua index 2bcc670de..93db86ca2 100644 --- a/projects/core/src/main/resources/data/computercraft/lua/rom/modules/main/cc/audio/wav.lua +++ b/projects/core/src/main/resources/data/computercraft/lua/rom/modules/main/cc/audio/wav.lua @@ -14,7 +14,7 @@ This function takes in the binary data from a WAV file, and outputs a more usable table format with all the metadata and file audio inside. It also has a [`readWAVFile`] function to simplify reading from a single file. -@see cc.audio.play To play the chunk decoded by this module. +@see speaker.playAudio To play the chunks decoded by this module. @since 1.113.0 @usage Reads "data/example.wav" into a table, prints its codec, sample rate, and length in seconds, and plays the audio on a speaker. @@ -53,7 +53,7 @@ local wavExtensible = { alaw = uuidBytes "06000000-0000-1000-8000-00aa00389b71", ulaw = uuidBytes "07000000-0000-1000-8000-00aa00389b71", adpcm = uuidBytes "11000000-0000-1000-8000-00aa00389b71", - pcm_float = uuidBytes "03000000-0000-1000-8000-00aa00389b71" + pcm_float = uuidBytes "03000000-0000-1000-8000-00aa00389b71", } local wavMetadata = { @@ -77,7 +77,7 @@ local wavMetadata = { IGNR = "genre", ICMT = "comment", ICOP = "copyright", - ILNG = "language" + ILNG = "language", } --[[- Read WAV data into a table. @@ -99,13 +99,13 @@ Channel data is in the same format as `speaker.playAudio` takes: 8-bit signed nu ]] local function readWAV(data) expect(1, data, "string") - local bitDepth, length, dataType, blockAlign, coefficients + local bitDepth, dataType, blockAlign local temp, pos = str_unpack("c4", data) if temp ~= "RIFF" then error("bad argument #1 (not a WAV file)", 2) end pos = pos + 4 temp, pos = str_unpack("c4", data, pos) if temp ~= "WAVE" then error("bad argument #1 (not a WAV file)", 2) end - local retval = {metadata = {}} + local retval = { metadata = {} } while pos <= #data do local size temp, pos = str_unpack("c4", data, pos) @@ -159,7 +159,7 @@ local function readWAV(data) return table.unpack(res) end else - local format = (dataType == "unsigned" and "I" .. (bitDepth / 8) or (dataType == "signed" and "i" .. (bitDepth / 8) or "f")) + local format = dataType == "unsigned" and "I" .. (bitDepth / 8) or (dataType == "signed" and "i" .. (bitDepth / 8) or "f") local transform if dataType == "unsigned" then function transform(n) return n - 128 end @@ -172,7 +172,7 @@ local function readWAV(data) end function retval.read(samples) if pos > #data then return nil end - local chunk = {("<" .. format:rep(math.min(samples * channels, (#data - pos + 1) / (bitDepth / 8)))):unpack(data, pos)} + local chunk = { ("<" .. format:rep(math.min(samples * channels, (#data - pos + 1) / (bitDepth / 8)))):unpack(data, pos) } pos = table.remove(chunk) local res = {} for i = 1, channels do @@ -221,4 +221,4 @@ local function readWAVFile(path) return readWAV(data) end -return {readWAV = readWAV, readWAVFile = readWAVFile} +return { readWAV = readWAV, readWAVFile = readWAVFile } diff --git a/projects/core/src/test/resources/test-rom/spec/modules/cc/audio/wav_spec.lua b/projects/core/src/test/resources/test-rom/spec/modules/cc/audio/wav_spec.lua index 5b2d8c769..52c372b28 100644 --- a/projects/core/src/test/resources/test-rom/spec/modules/cc/audio/wav_spec.lua +++ b/projects/core/src/test/resources/test-rom/spec/modules/cc/audio/wav_spec.lua @@ -67,4 +67,4 @@ describe("cc.audio.wav", function() for i = 1, #chunk do expect(chunk[i]):describe("Item at #" .. i):eq(output[i]) end end) end) -end) \ No newline at end of file +end)