Added pcm converter.

This commit is contained in:
Andrew Lalis 2023-01-01 23:32:25 +01:00
parent 49ff45df7b
commit 45031c07dd
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,5 @@
local monitorMainRight = peripheral.wrap("monitor_16")
local monitorMainLeft = peripheral.wrap("monitor_17")
local monitorTopRight = peripheral.wrap("monitor_19")
local monitorTopLeft = peripheral.wrap("monitor_18")

30
pcmToLua.d Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env rdmd
/**
* Converts a signed 8-bit PCM audio file into a Lua table list.
*/
module pcm_to_lua;
import std.stdio;
import std.file;
int main(string[] args) {
if (args.length < 2) {
stderr.writeln("Missing required file.");
return 1;
}
string audioFilename = args[1];
if (!exists(audioFilename)) {
stderr.writefln!"File %s doesn't exist."(audioFilename);
return 1;
}
byte[] contents = cast(byte[]) std.file.read(audioFilename);
stdout.writeln("local audio = {");
foreach (byte sample; contents) {
stdout.writefln!" %d,"(sample);
}
stdout.writeln("}");
return 0;
}