Repository navigation
Conversation
6ca21dd to
b4d9ffd
Compare
| ;;; [-pi..pi], encoded as [0..0.6[. This serves as a base 8-bit fixed point | ||
| ;;; displacement for the tremolo FX (whose force is configured from [1..16] | ||
| .bndry 128 | ||
| volsine:: |
There was a problem hiding this comment.
Ah that's what I wanted to see! How did you decide to use (cos(x)+1)/2 ? And did you decide to not go above 0.6 to not break the sound?
There was a problem hiding this comment.
So the exact formula is not carved in stone yet (especially for the 0.6), it's no longer that. But here's the gist of it.
The driver has an internal representation of volume (not the same as the ym2610), from 0 (quietest/nosound) to loudest (0x7f for FM, 0xf for SSG...).
The tremolo is modeled as volume to be substracted from the nullsound volume, with bounds like:
-
0: no volume reduction.
-
1: biggest volume reduction.
We have a sine-like wave, but from [0..1] instead of [-1..1], so I lift it +1, and divide the result by 2. -
There are 128 elements in the precalc to match Furnace, so a full sine wave is done with f(x) = sin(2pix/128)
-
But the volume reduction must start from 0, so I found it convenient to use a shifted cos, like e.g. f(x) = cos(2pix/128)-pi
-
apply the translation and scaling above to get f(x) in the range of [0..1]
-
What's left to do is to scale it (it's 0.23 in this version of the PR), and map it to a single byte as a fractional number.
The 0.23 scaling is just a (bad) guess right now, I need to figure out either the real value from Furnace source, or a value that fit nicely once applied on the various channel types.
There was a problem hiding this comment.
Thanks for the explanation
There was a problem hiding this comment.
https://github.com/tildearrow/furnace/blob/master/src/engine/engine.cpp#L4434-L4436
https://github.com/tildearrow/furnace/blob/master/src/engine/playback.cpp#L2383-L2388
Oh.... the z80 has a 16bit register but an 8bit data bus! It's using 8.8 fixed point representation.
https://github.com/tildearrow/furnace/blob/master/src/engine/engine.h#L257
| jp vibrato_init | ||
|
|
||
|
|
||
| ;;; Disable trmolo for the current channel |
There was a problem hiding this comment.
I'd call it fx-oscillation.s because it does both vibrato and tremolo
| fm2_op4_instr:: | ||
| push iy | ||
| ld iy, #state_op4_pipeline | ||
| ld iy, #state_op2_pipeline |
There was a problem hiding this comment.
This is a WIP right this is not going to end in the final driver ?
| ;;; fixed-point volume sine precalc | ||
| ;;; ------ | ||
| ;;; a 128 entries (128bytes) fixed point precalc of (cos(x)+1)/2 for x in | ||
| ;;; [-pi..pi], encoded as [0..0.6[. This serves as a base 8-bit fixed point |
| ;;; ------ | ||
| ;;; ix: sample play config | ||
| ;;; [a modified - other registers saved] | ||
| ;;; |
There was a problem hiding this comment.
As a general comment the comments in this WIP are distracting the reader from the code that really changed. I'd say the comment change should land in its own PR
| .db 0x29, 0x2a, 0x2c, 0x2d, 0x2e, 0x2f, 0x31, 0x32 | ||
| .db 0x33, 0x34, 0x35, 0x36, 0x36, 0x37, 0x38, 0x39 | ||
| .db 0x39, 0x3a, 0x3a, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b | ||
| .db 0x3c, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3a, 0x3a |
There was a problem hiding this comment.
0x3c should not be part of the list according to your comments
| fm2_op3_vol:: | ||
| push ix | ||
| ld ix, #state_op3_pipeline | ||
| ld ix, #state_op2_pipeline |
| fm2_op4_vol:: | ||
| push ix | ||
| ld ix, #state_op4_pipeline | ||
| ld ix, #state_op2_pipeline |
There was a problem hiding this comment.
This file should be called something like precalc-tables.s or just data-tables.s
| jr nc, _t_post_bit1 | ||
| add hl, bc | ||
| _t_post_bit1: | ||
| ;; this 16bit shift might overflow now if the precalc is one full |
There was a problem hiding this comment.
I think this is copied from the vibrato. Which is a 2 bytes table.
The calculation here is different because the volume table is one byte. So the calculation in this section might be wrong and overflow looks impossible on paper.
There was a problem hiding this comment.
Absolutely, this is a bad copy'n'paste from the other function.
There is no overflow in this path, as the precalc is only 8bit.
The contract is that:
- when the scaling factor is maximum (=0x10, or 0xf in Furnace), the full precalc value flows in register H.
- when the scaling factor is lower (between 0x1 and 0x9), i multiply the fractional part (bits ...XXXXXXXX.... of BC), and keep the integer part of the result (register H).
The overflow is valid in the case of the note vibrato, because the highest pitch of the vibrato (0xf) must go oscillate exactly 1 semitone above and below the current note.
The semantics of the tremolo seems to be different. I need to double check that. Right now, I'm assuming the rightmost bound is excluded, so by construction there is no overflow.
I might be wrong though, I need to double check what Furnace is doing (though right now, the effect sounds pretty convincing to me).
| ;;; FM3 state tracker | ||
| ;;; { ... | ||
|
|
||
| .blkb 0x28 |
There was a problem hiding this comment.
It should go in align.inc because it is padding for fm3
There was a problem hiding this comment.
Any padding of this sort should go in align.inc
The sound driver assumes various memory area lands in specific memory location to speed up 16-bit operations. Right now, any update to the driver's global variables is asserted with check-bounds.py, but it's not easy to have a graphical representation of the allocated memory. Add a new tool build-layout.py to generate a SVG view of the allocated memory, to ease padding management.
b4d9ffd to
e62ba2d
Compare
|
The ram map looks much healthier than before and you have 3 spare pages for the stack which should account for a more stable driver. |
NSS: tremolo FX implementation