diff --git a/song.go b/song.go index 4fe93d6..46274fa 100644 --- a/song.go +++ b/song.go @@ -11,11 +11,12 @@ import ( // playback speed, but this could be changed to a floating point in future if // finer adjustments are necessary. type Song struct { - BPM int - RowsPerBeat int - Score Score - Patch Patch - CreateEmptyPatterns bool + BPM int + RowsPerBeat int + Score Score + Patch Patch + CreateEmptyPatterns bool + WasmDisableRenderOnStart bool } // Copy makes a deep copy of a Score. diff --git a/templates/wasm/player.wat b/templates/wasm/player.wat index 0a84667..222a2be 100644 --- a/templates/wasm/player.wat +++ b/templates/wasm/player.wat @@ -880,7 +880,9 @@ (export "render_128_samples" (func $render_128_samples)) (export "update_voices" (func $su_update_voices)) +{{- if .RenderOnStart }} (start $render) ;; we run render automagically when the module is instantiated +{{- end}} (func $render (param) {{- if .Output16Bit }} (local $channel i32) {{- end }} diff --git a/tests/test_diff_wasm_x86.yml b/tests/test_diff_wasm_x86.yml index 14d0fe5..797614d 100644 --- a/tests/test_diff_wasm_x86.yml +++ b/tests/test_diff_wasm_x86.yml @@ -1,6 +1,7 @@ bpm: 120 rowsperbeat: 4 createemptypatterns: true +wasmdisablerenderonstart: false score: length: 1 rowsperpattern: 16 diff --git a/vm/compiler/compiler.go b/vm/compiler/compiler.go index 8049c41..6e02958 100644 --- a/vm/compiler/compiler.go +++ b/vm/compiler/compiler.go @@ -126,7 +126,8 @@ func (com *Compiler) Song(song *sointu.Song) (map[string]string, error) { PatternLength int SequenceLength int Hold int - }{compilerMacros, featureSetMacros, wasmMacros, songMacros, encodedPatch, patterns, sequences, len(patterns[0]), len(sequences[0]), 1} + RenderOnStart bool + }{compilerMacros, featureSetMacros, wasmMacros, songMacros, encodedPatch, patterns, sequences, len(patterns[0]), len(sequences[0]), 1, !song.WasmDisableRenderOnStart} populatedTemplate, extension, err = com.compile(templateName, &data) } if err != nil {