Added usage examples in C; Added asm include file with track info to sointu-compile.

This commit is contained in:
Alexander Kraus
2023-08-28 22:19:40 +02:00
committed by Veikko Sariola
parent dff484739c
commit d0efcc3001
11 changed files with 407 additions and 11 deletions

View File

@ -81,7 +81,7 @@ func (com *Compiler) Song(song *sointu.Song) (map[string]string, error) {
}
var templates []string
if com.Arch == "386" || com.Arch == "amd64" {
templates = []string{"player.asm", "player.h"}
templates = []string{"player.asm", "player.h", "player.inc"}
} else if com.Arch == "wasm" {
templates = []string{"player.wat"}
}

View File

@ -2,8 +2,9 @@
#ifndef SU_RENDER_H
#define SU_RENDER_H
#define SU_CHANNEL_COUNT 2
#define SU_LENGTH_IN_SAMPLES {{.MaxSamples}}
#define SU_BUFFER_LENGTH (SU_LENGTH_IN_SAMPLES*2)
#define SU_BUFFER_LENGTH (SU_LENGTH_IN_SAMPLES*SU_CHANNEL_COUNT)
#define SU_SAMPLE_RATE 44100
#define SU_BPM {{.Song.BPM}}
@ -24,23 +25,25 @@
#include <stdint.h>
#if UINTPTR_MAX == 0xffffffff
#if defined(__clang__) || defined(__GNUC__)
#define SU_CALLCONV __attribute__ ((stdcall))
#elif defined(_WIN32)
#define SU_CALLCONV __stdcall
#endif
#if defined(__clang__) || defined(__GNUC__)
#define SU_CALLCONV __attribute__ ((stdcall))
#elif defined(_WIN32)
#define SU_CALLCONV __stdcall
#endif
#else
#define SU_CALLCONV
#define SU_CALLCONV
#endif
{{- if .Output16Bit}}
typedef short SUsample;
#define SU_SAMPLE_RANGE 32767.0
#define SU_SAMPLE_PCM16
#define SU_SAMPLE_SIZE 2
{{- else}}
typedef float SUsample;
#define SU_SAMPLE_RANGE 1.0
#define SU_SAMPLE_FLOAT
#define SU_SAMPLE_SIZE 4
{{- end}}

View File

@ -0,0 +1,49 @@
; auto-generated by Sointu, editing not recommended
%ifndef PLAYER_INC
%define PLAYER_INC
%define SU_CHANNEL_COUNT 2
%define SU_LENGTH_IN_SAMPLES {{.MaxSamples}}
%define SU_BUFFER_LENGTH (SU_LENGTH_IN_SAMPLES*SU_CHANNEL_COUNT)
%define SU_SAMPLE_RATE 44100
%define SU_BPM {{.Song.BPM}}
%define SU_ROWS_PER_BEAT {{.Song.RowsPerBeat}}
%define SU_ROWS_PER_PATTERN {{.Song.Score.RowsPerPattern}}
%define SU_LENGTH_IN_PATTERNS {{.Song.Score.Length}}
%define SU_LENGTH_IN_ROWS (SU_LENGTH_IN_PATTERNS*SU_PATTERN_SIZE)
%define SU_SAMPLES_PER_ROW (SU_SAMPLE_RATE*60/(SU_BPM*SU_ROWS_PER_BEAT))
{{- if or .RowSync (.HasOp "sync")}}
{{- if .RowSync}}
%define SU_NUMSYNCS {{add1 .Song.Patch.NumSyncs}}
{{- else}}
%define SU_NUMSYNCS {{.Song.Patch.NumSyncs}}
{{- end}}
%define SU_SYNCBUFFER_LENGTH ((SU_LENGTH_IN_SAMPLES+255)>>8)*SU_NUMSYNCS
{{- end}}
{{- if .Output16Bit}}
%define SU_SAMPLE_SIZE 2
%define SU_SAMPLE_RANGE 32767.0
%define SU_SAMPLE_PCM16
{{- else}}
%define SU_SAMPLE_SIZE 4
%define SU_SAMPLE_RANGE 1.0
%define SU_SAMPLE_FLOAT
{{- end}}
{{- if or .RowSync (.HasOp "sync")}}
%define SU_SYNC
{{- end}}
section _su_symbols text
_su_symbols:
extern _su_render_song@4
{{- if gt (.SampleOffsets | len) 0}}
extern _su_load_gmdls
%define SU_LOAD_GMDLS
{{- end}}
%endif ; PLAYER_INC