Added pcm converter.
This commit is contained in:
		
							parent
							
								
									49ff45df7b
								
							
						
					
					
						commit
						45031c07dd
					
				| 
						 | 
				
			
			@ -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")
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue