Last active
April 6, 2023 14:03
-
-
Save petersalomonsen/c800cc66558f559b4036d68db8532e4b to your computer and use it in GitHub Desktop.
sointu renderer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
../sointu/sointu-compile -arch amd64 ../sointu/temp_song_file.yml | |
# if you just want to redner a short version | |
# node rendershort.mjs | |
yasm -f macho64 -a x86 temp_song_file.asm --objfile=temp_song_file.o | |
MACOSX_DEPLOYMENT_TARGET=11 gcc -Wl,-no_pie -arch x86_64 temp_song_file.o test.c -o test | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
../sointu/sointu-compile -arch amd64 ../sointu/temp_song_file.yml | |
# if you just want to redner a short version | |
# node rendershort.mjs | |
yasm -f elf64 temp_song_file.asm --objfile=temp_song_file.o | |
# MACOSX_DEPLOYMENT_TARGET=11 gcc -Wl,-no_pie -arch x86_64 temp_song_file.o test.c -o test | |
gcc temp_song_file.o test.c -o test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { readFile, writeFile } from 'fs/promises'; | |
const file = await readFile('./temp_song_file.asm').then(f => f.toString()); | |
const lines = file.split('\n'); | |
const rowlooplineindex = lines.findIndex(line => line.indexOf('jl su_render_rowloop')>-1); | |
lines[rowlooplineindex-1] = ' cmp eax, 16'; | |
await writeFile('./temp_song_file.asm', lines.join('\n')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "./temp_song_file.h" | |
#include <stdio.h> | |
float buffer[SU_BUFFER_LENGTH]; | |
extern char syncBuf[SU_SYNCBUFFER_LENGTH]; | |
char syncBuf[SU_SYNCBUFFER_LENGTH] = { 0 }; | |
int main() { | |
printf("rendering!\n"); | |
su_render_song(buffer); | |
printf("writing file\n"); | |
FILE* file = fopen("music.raw", "wb"); | |
if (!file) { | |
perror("fopen failed"); | |
return 1; | |
} | |
for (size_t i = 0; i < SU_BUFFER_LENGTH; i++) { | |
float value = buffer[i]; | |
fwrite(&value, sizeof(float), 1, file); | |
} | |
printf("closing\n"); | |
fclose(file); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment