mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-26 17:04:40 -04:00
Mac OSX player and Single tick rendering
- Use SINGLE_TICK_RENDERING mode for rendering one tick per invocation of _4klang_render - Example for running player on Mac OSX
This commit is contained in:
4
4klang_source/playosx/.gitignore
vendored
Normal file
4
4klang_source/playosx/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
4klangrender
|
||||
4klang.asm
|
||||
4klang.inc
|
||||
4klang.o
|
33
4klang_source/playosx/4klangrender.c
Normal file
33
4klang_source/playosx/4klangrender.c
Normal file
@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
|
||||
extern void _4klang_render(void*) __attribute__ ((stdcall));
|
||||
extern int _4klang_current_tick;
|
||||
|
||||
#define SAMPLE_RATE 44100
|
||||
#define MAX_INSTRUMENTS 9
|
||||
#define MAX_VOICES 1
|
||||
#define HLD 1 ; // can be adjusted to give crinkler some other possibilities
|
||||
#define BPM 100
|
||||
#define MAX_PATTERNS 62
|
||||
#define PATTERN_SIZE_SHIFT 4
|
||||
#define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT)
|
||||
#define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE)
|
||||
#define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16))
|
||||
#define DEF_LFO_NORMALIZE 0.000038
|
||||
#define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS)
|
||||
|
||||
float buf[SAMPLES_PER_TICK * 2];
|
||||
|
||||
int main() {
|
||||
FILE *fp;
|
||||
|
||||
_4klang_current_tick = 0;
|
||||
|
||||
fp = fdopen(fileno(stdout), "wb");
|
||||
for(int n=0;n<MAX_TICKS;n++) {
|
||||
fprintf(stderr,"\nRender %d %d\n",n,_4klang_current_tick);
|
||||
_4klang_render(buf);
|
||||
fwrite(buf, sizeof(buf), 1, fp);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
11
4klang_source/playosx/README.md
Normal file
11
4klang_source/playosx/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# 4klang rendering example for Mac OSX
|
||||
|
||||
In here you'll find `4klangrender.c` which will call the `4klang.asm` library and render one tick
|
||||
at the time (using the `AUTHORING` flag in `4klang.inc`).
|
||||
|
||||
The `runosx.sh` shell script contains the commands to compile the asm and link with the c example code, and create
|
||||
an executable that will ouput a stream of 32 bit floating point samples. By piping into [SOX](http://sox.sourceforge.net/) we'll get sound output.
|
||||
|
||||
You also need [YASM](http://yasm.tortall.net/) and gcc (XCode) installed, and if everything is right you should get sound output by simply typing in your terminal (from this folder):
|
||||
|
||||
`sh runosx.sh`
|
9
4klang_source/playosx/runosx.sh
Normal file
9
4klang_source/playosx/runosx.sh
Normal file
@ -0,0 +1,9 @@
|
||||
echo "Copying 4klang.asm and 4klang.inc from parent dir"
|
||||
echo "Enabling SINGLE_TICK_RENDERING (and AUTHORING) flag for rendering example"
|
||||
echo "You need sox installed to get audio output"
|
||||
sed -e 's/\;\%define SINGLE_TICK_RENDERING/\%define SINGLE_TICK_RENDERING/' ../4klang.inc | \
|
||||
sed -e 's/\;\%define AUTHORING/\%define AUTHORING/' > 4klang.inc
|
||||
cp ../4klang.asm .
|
||||
yasm -f macho 4klang.asm
|
||||
gcc -Wl,-no_pie -m32 4klang.o 4klangrender.c -o 4klangrender
|
||||
./4klangrender | sox -t raw -b 32 -e float -r 44100 -c 2 - -d
|
Reference in New Issue
Block a user