Commit Graph

72 Commits

Author SHA1 Message Date
5684185+vsariola@users.noreply.github.com
95af8da939 fix(vm)!: first modulate delay time, then notetracking
BREAKING CHANGE: the order of these operations was inconsistent
across the different VMs. Go VM was the only one to first modulate
and then apply note tracking multiplication. But that made most
sense. So now all different VM versions work in this same way.
2025-04-16 23:17:08 +03:00
5684185+vsariola@users.noreply.github.com
0e10cd2ae8 fix(amd64-386): sample oscillator hard crash
The sample-based oscillators converted the samplepos to an integer
and did samplepos < loop_end comparison to check if we are past
looping. Unfortunately, the < comparison was done in signed math.
Normally, this should never happen, but if the x87 FPU stack
overflowed exactly at right position, we then got 0x80000000 in
samplepos, which is equal to -2147483648. Thus, we considered that
sample is not looping and read the sample table at position
-2147483648, well out of bound. TL;DR changing jl to jb makes sure
we always wrap within to sample table, no matter what.

Fixes #149.
2024-09-22 09:04:47 +03:00
5684185+vsariola@users.noreply.github.com
012ed10851 test: add unit test for unisons with phase = 0
This demonstrates a bug found by Virgill:
the x86 templates optimize away the phase
modulation when all phases are set to 0,
but the unisons need the phase modulation
internally to offset the phase of the different
unison oscillators.
2024-08-17 11:06:17 +03:00
5684185+vsariola@users.noreply.github.com
04fbc9f6a7 feat(vm): add dbgain unit, where gain is defined in decibels
Closes #78
2023-10-23 21:57:29 +03:00
5684185+vsariola@users.noreply.github.com
e5691d670a feat(vm): add frequency modulation for oscillators
Closes #105
2023-10-07 21:48:03 +03:00
5684185+vsariola@users.noreply.github.com
00850c8001 code/text formatting and cleaning up whitespace 2023-09-24 10:47:54 +03:00
5684185+vsariola@users.noreply.github.com
f35f948118 fix(vm/compiler/templates/wasm): add support for mono out
Adds also a test case to make sure mono out also works.
2023-09-24 10:27:34 +03:00
5684185+vsariola@users.noreply.github.com
1ac2ad3c75 fix(vm/compiler): invert the logic of the release flag in the voices (closes #102)
This makes all envelopes released by default, instead of attacking. Add also test to demonstrate the buggy behaviour.
2023-09-23 15:56:46 +03:00
5684185+vsariola@users.noreply.github.com
b028fea59a build: make targets properly rebuild when templates or compiler changed 2023-09-02 20:14:52 +03:00
5684185+vsariola@users.noreply.github.com
70080c2b9d fix(templates/wasm): $WRK was modified by stereo oscillators, messing up all modulations targeting units after the unit
add also tests to make sure we don't mess it up again
2023-04-06 15:03:16 +03:00
5684185+vsariola@users.noreply.github.com
6129076e97 upgrade ilammy/setup-nasm to v1.4.0 and wat2wasm to v1.0.29
wat2wasm doesn't support --enable-bulk-memory anymore, presumably because it is part of the standard nowadays
2023-04-06 14:50:18 +03:00
vsariola
99dbdfe223 feat: add the ability to use Sointu as a sync-tracker
There is a new "sync" opcode that saves the top-most signal every 256 samples to the new "syncBuffer" output. Additionally, you can enable saving the current fractional row as sync[0], avoiding calculating the beat in the shader, but also calculating the beat correctly when the beat is modulated.
2021-03-09 23:52:33 +02:00
vsariola
5f7eed4194 fix(templates/amd64-386, tests): fix global stereo sends and add regression test for future
the send asm code is quite ugly atm (pushf & popf to save stereo flag), but the new regression test should ensure we don't break it again if we eventually refactor it
2021-02-15 14:48:16 +02:00
vsariola
69f236dbd3 fix(tests): wat-compilation was missing correct output filename 2021-01-05 18:30:47 +02:00
vsariola
1be75362d0 refactor(tests): remove copying files to output directory; tests accept path to expected instead 2021-01-05 18:18:48 +02:00
vsariola
588488ce54 feat(sointu): remove 16-bit output toggle from song; make it compile time option 2021-01-05 18:08:13 +02:00
Veikko Sariola
e4490faa2e feat(compiler): Add support for targeting WebAssembly.
The working principle is similar as before with x86, but instead of outputting .asm, it outputs .wat. This can be compiled into .wasm by using the wat2wasm assembler.
2020-12-26 23:16:18 +02:00
Veikko Sariola
7f049acf88 feat(cli): Re-engineer CLIs, split play & compile
Play depends on bridge and compile on compiler package. Before, the compiler depended on bridge, but we could not use the compiler to build the library, as the bridge depends on the library. Also, play can now start having slightly more options e.g. wav out etc.
2020-12-18 20:25:49 +02:00
Veikko Sariola
224b8dcb70 refactor(go): Move everything from go4k to root package sointu 2020-12-16 21:35:53 +02:00
Veikko Sariola
d0bd877b3f feat(asm&go4k): Rewrote both library & player to use text/template compiler
There is no more plain .asms, both library & player are created from the templates using go text/template package.
2020-12-16 17:23:50 +02:00
Veikko Sariola
2ad61ff6b2 feat(asm&go4k): Preprocess asm code using go text/template
The preprocessing is done sointu-cli and (almost) nothing is done by the NASM preprocessor anymore (some .strucs are still there.
Now, sointu-cli loads the .yml song, defines bunch of macros (go functions / variables) and passes the struct to text/template parses.
This a lot more powerful way to generate .asm code than trying to fight with the nasm preprocessor.

At the moment, tests pass but the repository is a bit of monster, as the library is still compiled using the old approach. Go should
generate the library also from the templates.
2020-12-14 15:44:16 +02:00
Veikko Sariola
92c8b70fd2 refactor(tests): Save .yml in the repo; auto-generate .asm when needed 2020-12-09 13:48:19 +02:00
Veikko Sariola
d19d513ea8 feat(sointu-cli): Merge the asmfmt and sointuplayer to generic command line utility for processing song files.
Currently supports: playing, exporting .asm (reformatting), exporting .h, exporting .raw (raw float32 buffer), exporting .json.
2020-12-05 00:01:24 +02:00
Veikko Sariola
efbcf1454e feat(go4k&sointu): Export .h C header files from the songs using go, also automatically during build for the tests.
The header files are automatically generated during build. No need to #define anything; everything is fixed by the .asm file. This adds go as a dependency to run the unit tests, but this is probably not a bad thing, as go is probably needed anyway if one wants to actually start developing Sointu.
2020-12-03 23:43:39 +02:00
Veikko Sariola
a1e7e82d6d refactor(song): Remove song length from Song and assume the user knows MAX_SAMPLES
Trying to force a specific song length other than the default never quite worked, so we'll only support the default MAX_SAMPLES & will calculate it for the user in the user in the exported .h header file.
2020-11-29 22:12:29 +02:00
Veikko Sariola
ccb6434fac Implement compile definition RUNTIME_TABLES, which enables putting the pointers to delay and sample tables to stack.
Useful for the eventual API to be able to modify the delay and sample tables during runtime.
2020-11-02 23:10:33 +02:00
Veikko Sariola
e0a793ea6d Reorganize the project folder structure and how go packages are organized.
Sointu.asm / lib stuff lives at the root folder. There is a folder called "go4k", which is where
all go stuff lives. Following the ideas from https://medium.com/@benbjohnson/standard-package-layout-7cdbc8391fc1
the go4k folder is the "domain-model" of the go side, and should have no dependencies.
It contains Unit, Instrument, Synth interface etc. Putting go4k under a sub-folder is actually
in the spirit of Ben, as go4k adds dependency to the go language.

Bridge ties the domain-model to the sointulib through cgo. It returns C.Synth, but
makes sure the C.Synth implements the Synth interface, so others are able to use the
Synth no matter how it actually is done. MockSynth and WebProxy synth are good
prospects for other implementations of Synth.

It is a bit fuzzy where methods like "Play" that have no dependencies other than domain
model structs should go. They probably should live in the go4k package as well.

The file-organization on the Go-side is not at all finalized. But how packages are broken
into files is mostly a documentation issue; it does not affect the users of the packages at
all.

BTW: The name go4k was chosen because Ben advocated naming the subpackages
according to the dependency they introduce AND because the prototype of 4klang was
called go4k (there are still some defines in the 4klang source revealing this). go4k thus
honors our roots but is also not so bad name: it's the main package of a 4k synth tracker,
written in go.
2020-10-31 22:05:47 +02:00
Veikko Sariola
6e85ff674a Change the sointu.h api to return -1, 0 or n>0 depending if buffer is full and/or row ended.
test_render_samples_api.c was added to test the api. bridge.go was modified to reflect that there is no need to check for row manually; su_render_samples already returns the information if a row has ended.
2020-10-24 13:00:08 +03:00
Veikko Sariola
7aac3917b7 Implement a bridge to call Sointu from Go language.
The main interface is render_samples function, which renders several samples in one call,
to limit the number of calls from Go to C. This is compiled into a library, which is then
linked and called from bridge.go.
2020-10-22 21:19:13 +03:00
Veikko Sariola
c5b6e6e28c Move su_load_gmdls into the responsibility of the intro to call, anticipating multicore rendering so it is called once before all the cores are spun up. 2020-05-27 18:54:34 +03:00
Veikko
5e05057240 Fix builds and tests to pass on Linux.
Builds on both 32-bit and 64-bit executables and all tests (except gm.dls stuff obviously, which was excluded) pass on 64-bit Linux. Cannot test the 32-bit executables, as WSL does not support running 32-bit.
2020-05-27 10:54:37 +03:00
Veikko Sariola
dac5afea60 Implement IN, OUTAUX and AUX opcodes, to conveniently input from or output to global ports. 2020-05-25 23:23:24 +03:00
Veikko Sariola
6f06306f0c Re-engineer delay, to use stack for the delay WRK pointer and to support note-syncing transpose. 2020-05-23 15:05:38 +03:00
Veikko Sariola
654e5868bc Implement support for 64-bit builds.
The implentation is through a few macros to handle the fact in 64-bit, all addresses have to be loaded first to register and only offsets are ok. Also, push only supports 64-bit registers in 64-bit, so we have _AX, _BX, _CX etc. defines, which are eax, ebx and ecx on 32bit and rax, rbx and rcx on 64bit.
2020-05-21 17:18:18 +03:00
Veikko Sariola
dc99157fbb Implement unison oscillators: multiple versions of slightly detuned oscillators that are added up to make a signal. 2020-05-19 22:52:21 +03:00
Veikko Sariola
adc4a6e45f Implement sample-based oscillators, with sample import from gm.dls. 2020-05-19 18:29:47 +03:00
Veikko Sariola
fc0ad4c011 Implement compressor. 2020-05-17 16:37:08 +03:00
Veikko Sariola
71a5a18257 Implement player speed modulation opcode for triplets and such. 2020-05-17 09:51:20 +03:00
Veikko Sariola
15717557f1 Split polyphony test into two tests. 2020-05-17 08:32:35 +03:00
Veikko Sariola
d87d2e22cf Implement new effect: bit-crusher.
Maybe a combined hold/bit-crusher effect is needed someday.
2020-05-16 23:27:29 +03:00
Veikko Sariola
ac5b4dd496 Make clip opcode working and add regression tests to it. 2020-05-16 22:49:59 +03:00
Veikko Sariola
5760f78201 Implement gain and inverse gain effects, for the moments when you just need them. 2020-05-16 22:29:08 +03:00
Veikko Sariola
87264c443c Add tests for opcode stereo variants, squashing several bugs in the process. Implement receive opcode to test stereo sending. 2020-05-16 21:23:41 +03:00
Veikko Sariola
f9388b028a Rename test files to represent better the new opcodes they correspond to. 2020-05-16 18:32:56 +03:00
Veikko Sariola
42ebc52c96 Remove trailing spaces and convert tabs to spaces. 2020-05-16 09:16:23 +03:00
Veikko Sariola
78d4cd50e8 Rewrote most of the synth to better support stereo signals and polyphony. VSTi removed as there is no plan to update the VSTi to support the new features.
The stereo opcode variants have bit 1 of the command stream set. The polyphony is split into two parts: 1) polyphony, meaning that voices reuse the same opcodes; 2) multitrack voices, meaning that a track triggers more than voice. They both can be flexible defined in any combinations: for example voice 1 and 2 can be triggered by track 1 and use instrument 1, and voice 3 by track 2/instrument 2 and voice 4 by track 3/instrument 2. This is achieved through the use of bitmasks: in the aforementioned example, bit 1 of su_voicetrack_bitmask would be set, meaning "the voice after voice #1 will be triggered by the same track". On the other hand, bits 1 and 3 of su_polyphony_bitmask would be set to indicate that "the voices after #1 and #3 will reuse the same instruments".
2020-05-16 08:25:52 +03:00
Veikko Sariola
212951c75d Make tests rebuild when 4klang.asm and 4klang.inc are changed. 2020-05-03 12:50:42 +03:00
Veikko Sariola
9546574f13 Add regression test for AUX output. 2020-05-03 11:21:09 +03:00
Veikko Sariola
660da68a48 Add regression test for polyphony (MAX_VOICES = 2). 2020-05-01 08:51:43 +03:00
Veikko Sariola
09c497fef6 Add regression tests for delay modulations. 2020-04-25 11:29:14 +03:00