Skip to content

Instantly share code, notes, and snippets.

@petersalomonsen
Last active April 6, 2023 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petersalomonsen/c800cc66558f559b4036d68db8532e4b to your computer and use it in GitHub Desktop.
Save petersalomonsen/c800cc66558f559b4036d68db8532e4b to your computer and use it in GitHub Desktop.
sointu renderer
../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
../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
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'));
#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