Commit Graph

73 Commits

Author SHA1 Message Date
Veikko Sariola
6d883f43ab fix(test_renderer): Add include <string.h> as linux builds were giving warnings for implicit declaration of memset. 2020-11-12 19:50:59 +02:00
Veikko Sariola
1b1dabafb8 fix(asm): Change the scaling to 29 in the speed unti (29 increments = double speed).
The old speed scaling of 24 was ill-chosen so that triplets resulted in a minor buffer overflow error. This was never caught by anyone until Visual Studio 2019 in debug mode. Presumably all compilers allocate some extra space so this didn't matter. Now 29 increments = double speed and speeds with alternating 52 and 81 result in triplets that are just slightly faster then ordinary bpm i.e. the buffer will be slightly underrun, which probably is unnoticable to the user.
2020-11-12 19:46:37 +02:00
Veikko Sariola
f7017892a5 refactor(asm&go4k): Remove special treatment from stereo parameters; it's now just one parameter in the Unit map. 2020-11-10 20:45:41 +02:00
Veikko Sariola
01c39ffc15 format(tests): Autoformat all tests using the new asmfmt command. 2020-11-10 20:08:13 +02:00
Veikko Sariola
5ceab766cc refactor(asm&go4k): Remove double SU_SEND macros, voice(0) corresponding to local send and voice(n) corresponding to global. 2020-11-10 00:53:06 +02:00
Veikko Sariola
1c0ac08450 refactor(asm&go4k): Rename OSCILLAT and COMPRES macros to OSCILLATOR and COMPRESS.
Now the macro names correspond 1 - 1 to the unit names in go-side, allowing easier parsing.
2020-11-10 00:29:35 +02:00
Veikko Sariola
ae334a5dfe refactor(asm&go4k): Remove FLAGS from all units; they were the source of difficulty in parsing and fragile.
All units now take parameters according to flags. Only non-numeric parameter anymore is oscillator type.
2020-11-10 00:18:56 +02:00
Veikko Sariola
9209aa1cba Implement .asm parsing in go4k, and run succesfully almost all tests/ through the bridge.
Delays and samples are not implemented yet and thus the tests are skipped, as these require parsing the delay and sample tables also. Various macronames were changed to be more sensible and consistent i.e. ATTAC was changed to ATTACK. GatesLow and GatesHigh was removed for the time being and the tracker will just have to know they are the SHAPE and COLOR parameters. SU_SPEED was changed to take a parameter so the parser picks it up.
2020-11-07 21:05:55 +02:00
Veikko Sariola
f584138572 Remove expressions from parameters, so the future .asm parser does not need expression evaluator. 2020-11-04 23:31:08 +02:00
Veikko Sariola
df83001a64 Change delay macros to use FLAGS(NOTETRACKING) and FLAGS(NONE)
Previously it was + NOTETRACKING. This new way of using FLAGS(...) is more consistent with other macros, making the .asm format easier to parse.
2020-11-04 23:29:16 +02:00
Veikko Sariola
d99cfd92d9 Change LOCALPORT and GLOBALPORT macros so that SU_SEND commands are easier to parse.
The new format is to give either 5 or 6 parameters to SU_SEND, corresponding to local and global send, respectively. For example, a global send:
        SU_SEND     MONO,AMOUNT(128),VOICE(2),UNIT(0),PORT(1),FLAGS(SEND_POP)

The SU_SEND macro does the address packing into word.
2020-11-04 23:11:51 +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
dc88b885e9 Fix warnings when built using nasm.
Nasm gives warnings about labels without colons in the end; these were particularly prevalent in struc members: ".size" has be ".size:". Nasm also wasn't happy with extra trailing commas when calling macros.
2020-11-02 22:31:22 +02:00
Veikko Sariola
eb37d8123d Change include path in CMake file to point to include/ instead of include/sointu/ 2020-11-02 21:37:22 +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
8183c698da Separate Synth and SynthState: SynthState is the part that Render changes.
This should make testing easier, as Synth can be assumed to stay the same
during each call. Synth is also the part that we can parse from .asm/.json file
and a Patch can be compiled into a synth. Synth can be eventually made
quite opaque to the user. The user should not need to worry about opcodes
etc.
2020-10-28 19:47:59 +02:00
Veikko Sariola
64afa9fb48 Change the C-API to roughly match the new Go-API.
The parameter order is now so that all the in/out int parameters are in the end of the signature.
2020-10-27 21:58:56 +02:00
Veikko Sariola
1d07b4f192 Change the .asm song format so it's a bit easier to parse, by replacing PORT and GLOBALPORT macros with LOCALPORT and GLOBALPORT.
The LOCALPORT and GLOBALPORT just get numeric parameters (unit, port) and (voice, unit, port), respectively, which should be now quite intuitive as most of the time the port index is one of the parameters visible in the .asm file. Only a few units have extra ports beyond transformed variables. Overall, this should make the parsing of the .asm files a lot easier.
2020-10-26 12:55:15 +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
95b70018cc Fix all CMake tests passing on MinGW: consider minor (< 1e-6) errors in waveform shape successes.
Such errors are due to floating point rounding errors.
2020-10-22 21:19:14 +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
af14cd310b Change .asm files that are actually only ever included into .inc-files, and rename all files as _header.inc & _footer.inc, depending where they are included. 2020-10-21 11:01:09 +03:00
Veikko Sariola
7e3dc19c83 Add inverse gain to compressor. The inverse gain is applied to the signal before any compressor calculations. 2020-05-27 18:54:37 +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
e049bf2dce Change loadnote to load values from [-1,1], to allow using notes for both positive and negative modulations.
Also change SPEED to take this change into account.
2020-05-26 19:21:35 +03:00
Veikko Sariola
91b8912015 Rename all SU_BEGIN_* macros into BEGIN_*; there's no real risk of nameclash and makes the code more readable. 2020-05-26 17:45:37 +03:00
Veikko Sariola
efc6db71ab Reverse the logic of USE_SECTIONS (it's now DISABLE_SECTIONS) and then remove unnecessary defines. 2020-05-26 17:30:50 +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
6be7959cd1 Refactor the waveshaper function to save some bytes. 2020-05-03 17:02:08 +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
53a1be9b61 Refactor all values to have a universal support for modulations.
The modulation is now always added during value transformation.
With this, a lot of *_MOD defines could be removed.
The waveform for some tests changed slightly, because when the
value is saved to memory after modulating it, there is some
rounding errors.
2020-05-03 10:41:24 +03:00
Veikko Sariola
660da68a48 Add regression test for polyphony (MAX_VOICES = 2). 2020-05-01 08:51:43 +03:00
Veikko Sariola
f97cea2a17 Refactor 4klang to use cross-platform defines and 4klang.asm & .inc to work more like .c and .h. 2020-04-30 13:36:22 +03:00
Veikko Sariola
09c497fef6 Add regression tests for delay modulations. 2020-04-25 11:29:14 +03:00