This commit is contained in:
Dragon Fire
2021-03-21 19:05:07 -04:00
parent ea0f976aae
commit e2ba47208e
+7 -7
View File
@@ -56,7 +56,7 @@ module.exports = class AnimaleseCommand extends Command {
]
});
this.library = new fs.readFileSync(path.join(__dirname, '..', '..', 'assets', 'sounds', 'animalese.wav'));
this.library = fs.readFileSync(path.join(__dirname, '..', '..', 'assets', 'sounds', 'animalese.wav'));
}
async run(msg, { pitch, text }) {
@@ -87,14 +87,14 @@ module.exports = class AnimaleseCommand extends Command {
const c = processedScript.toUpperCase()[cIndex];
if (c >= 'A' && c <= 'Z') {
const libraryLetterStart = librarySamplesPerLetter * (c.charCodeAt(0) - 'A'.charCodeAt(0));
for (var i = 0; i < outputSamplesPerLetter; i++) {
for (let i = 0; i < outputSamplesPerLetter; i++) {
const libIndex = this.library[44 + libraryLetterStart + Math.floor(i * pitch)];
data[cIndex * outputSamplesPerLetter + i] = libIndex;
}
data[(cIndex * outputSamplesPerLetter) + i] = libIndex;
}
} else {
for (var i = 0; i < outputSamplesPerLetter; i++) {
data[cIndex * outputSamplesPerLetter + i] = 127;
}
for (let i = 0; i < outputSamplesPerLetter; i++) {
data[(cIndex * outputSamplesPerLetter) + i] = 127;
}
}
}
const wav = new WaveFile();