laser500-wav
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -17,2 +17,5 @@ #!/usr/bin/env node | ||
{ name: 'samplerate', alias: 's', type: Number }, | ||
{ name: 'volume', alias: 'v', type: Number }, | ||
{ name: 'stereoboost', type: Boolean }, | ||
{ name: 'invert', type: Boolean }, | ||
{ name: 'turbo', alias: 'x', type: Boolean }, | ||
@@ -39,2 +42,5 @@ { name: 'turbo-address', type: Number }, | ||
console.log(" -s or --samplerate rate the samplerate of the WAV file (96000 default)"); | ||
console.log(" -v or --volume number volume between 0 and 1 (1.0 default)"); | ||
console.log(" --stereoboost boost volume for stereo cables by inverting the RIGHT channel"); | ||
console.log(" --invert inverts the polarity of the audio"); | ||
console.log(" -x or --turbo generates a turbo tape loadable file"); | ||
@@ -50,2 +56,3 @@ console.log(" --turbo-address hexaddress address in memory of the turbo tape file (0x8995 default)"); | ||
const SAMPLE_RATE = options.samplerate || 96000; | ||
const VOLUME = options.volume || 1.0; | ||
@@ -102,5 +109,11 @@ console.log(`sample rate is ${SAMPLE_RATE} Hz`); | ||
// invert audio samples if --invert option was given | ||
if(options.invert) samples = invertSamples(samples); | ||
samples = new Float32Array(samples); | ||
const samples_inv = new Float32Array(invertSamples(samples)); | ||
const wavData = { | ||
sampleRate: SAMPLE_RATE, | ||
channelData: [ new Float32Array(samples) ] | ||
channelData: !options.stereoboost ? [ samples ] : [ samples, samples_inv ] | ||
}; | ||
@@ -129,2 +142,7 @@ | ||
function invertSamples(samples) | ||
{ | ||
return samples.map(e=>-e); | ||
} | ||
function tapeStructure(tapeName, fileType, startAddress, program) { | ||
@@ -220,11 +238,11 @@ const bytes = []; | ||
if(tapeBits[t]==="S") { | ||
for(;ptr<BIT_0_SIZE; ptr++) samples.push(0.75); | ||
for(;ptr<BIT_0_SIZE; ptr++) samples.push(VOLUME); | ||
ptr -= BIT_0_SIZE; | ||
for(;ptr<BIT_0_SIZE; ptr++) samples.push(-0.75); | ||
for(;ptr<BIT_0_SIZE; ptr++) samples.push(-VOLUME); | ||
ptr -= BIT_0_SIZE; | ||
} | ||
else { | ||
for(;ptr<BIT_1_SIZE; ptr++) samples.push(0.75); | ||
for(;ptr<BIT_1_SIZE; ptr++) samples.push(VOLUME); | ||
ptr -= BIT_1_SIZE; | ||
for(;ptr<BIT_1_SIZE; ptr++) samples.push(-0.75); | ||
for(;ptr<BIT_1_SIZE; ptr++) samples.push(-VOLUME); | ||
ptr -= BIT_1_SIZE; | ||
@@ -405,3 +423,3 @@ } | ||
const b = tapeBits[t]; | ||
const s = (b == 0) ? -0.75 : 0.75; | ||
const s = (b == 0) ? -VOLUME : VOLUME; | ||
@@ -426,2 +444,1 @@ const pixelsize = TURBO_BIT_SIZE + elongations[t]; | ||
} | ||
{ | ||
"name": "laser500-wav", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Laser500 program to WAV (tape) converter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
72442
664