mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
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
This commit is contained in:
parent
61c2e980a2
commit
70080c2b9d
@ -106,6 +106,10 @@
|
||||
(func $su_op_oscillator (param $stereo i32) (local $flags i32) (local $detune f32) (local $phase f32) (local $color f32) (local $amplitude f32)
|
||||
{{- if .SupportsParamValueOtherThan "oscillator" "unison" 0}}
|
||||
(local $unison i32) (local $WRK_stash i32) (local $detune_stash f32)
|
||||
{{- end}}
|
||||
{{- if .Stereo "oscillator"}}
|
||||
(local $WRK_stereostash i32)
|
||||
(local.set $WRK_stereostash (global.get $WRK))
|
||||
{{- end}}
|
||||
(local.set $flags (call $scanValueByte))
|
||||
(local.set $detune (call $inputSigned (i32.const {{.InputNumber "oscillator" "detune"}})))
|
||||
@ -189,7 +193,7 @@
|
||||
(f32.const 0.08333333) ;; 1/12, add small phase shift so all oscillators don't start in phase
|
||||
)
|
||||
)
|
||||
(global.set $WRK (i32.add (global.get $WRK) (i32.const 8))) ;; WARNING: this is a bug. WRK should be nonvolatile, but we are changing it. It does not cause immediate problems but modulations will be off.
|
||||
(global.set $WRK (i32.add (global.get $WRK) (i32.const 8)))
|
||||
(local.set $detune (f32.neg (f32.mul
|
||||
(local.get $detune) ;; each unison oscillator has a detune with flipped sign and halved amount... this creates detunes that concentrate around the fundamental
|
||||
(f32.const 0.5)
|
||||
@ -202,9 +206,12 @@
|
||||
{{- end}}
|
||||
{{- if .Stereo "oscillator"}}
|
||||
(local.set $detune (f32.neg (local.get $detune))) ;; flip the detune for secon round
|
||||
(global.set $WRK (i32.add (global.get $WRK) (i32.const 4))) ;; WARNING: this is a bug. WRK should be nonvolatile, but we are changing it. It does not cause immediate problems but modulations will be off.
|
||||
(global.set $WRK (i32.add (global.get $WRK) (i32.const 4)))
|
||||
(br_if $stereoLoop (i32.eqz (local.tee $stereo (i32.eqz (local.get $stereo)))))
|
||||
end
|
||||
(global.set $WRK (local.get $WRK_stereostash))
|
||||
;; TODO: all this "save WRK to local variable, modify it and then restore it" could be better thought out
|
||||
;; however, it is now done like this as a quick bug fix to the issue of stereo oscillators touching WRK and not restoring it
|
||||
{{- end}}
|
||||
)
|
||||
|
||||
|
@ -115,7 +115,8 @@ regression_test(test_oscillat_detunemod "VCO_SINE;ENVELOPE;FOP_MULP;FOP_PUSH;SEN
|
||||
regression_test(test_oscillat_phasemod "VCO_SINE;ENVELOPE;FOP_MULP;FOP_PUSH;SEND")
|
||||
regression_test(test_oscillat_colormod "VCO_SINE;ENVELOPE;FOP_MULP;FOP_PUSH;SEND")
|
||||
regression_test(test_oscillat_shapemod "VCO_SINE;ENVELOPE;FOP_MULP;FOP_PUSH;SEND")
|
||||
regression_test(test_oscillat_gainmod "VCO_SINE;ENVELOPE;FOP_MULP;FOP_PUSH;SEND")
|
||||
regression_test(test_oscillat_gainmod OSCGAINMOD "VCO_SINE;ENVELOPE;FOP_MULP;FOP_PUSH;SEND")
|
||||
regression_test(test_oscillat_gainmod_stereo "" OSCGAINMOD)
|
||||
|
||||
regression_test(test_distort ENVELOPE)
|
||||
regression_test(test_distort_mod "VCO_SINE;ENVELOPE;SEND")
|
||||
|
BIN
tests/expected_output/test_oscillat_gainmod_stereo.raw
Normal file
BIN
tests/expected_output/test_oscillat_gainmod_stereo.raw
Normal file
Binary file not shown.
43
tests/test_oscillat_gainmod_stereo.yml
Normal file
43
tests/test_oscillat_gainmod_stereo.yml
Normal file
@ -0,0 +1,43 @@
|
||||
bpm: 100
|
||||
rowsperbeat: 4
|
||||
score:
|
||||
rowsperpattern: 16
|
||||
length: 1
|
||||
tracks:
|
||||
- numvoices: 1
|
||||
order: [0]
|
||||
patterns: [[80, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]]
|
||||
patch:
|
||||
- numvoices: 1
|
||||
units:
|
||||
- type: envelope
|
||||
parameters: {attack: 80, decay: 80, gain: 128, release: 80, stereo: 0, sustain: 64}
|
||||
- type: oscillator
|
||||
parameters: {color: 128, detune: 64, gain: 32, lfo: 0, phase: 0, shape: 64, stereo: 0, transpose: 64, type: 0, unison: 0}
|
||||
id: 1
|
||||
- type: oscillator
|
||||
parameters: {color: 128, detune: 62, gain: 32, lfo: 0, phase: 0, shape: 64, stereo: 1, transpose: 64, type: 0, unison: 0}
|
||||
id: 2
|
||||
- type: addp
|
||||
parameters: {stereo: 0}
|
||||
- type: addp
|
||||
parameters: {stereo: 0}
|
||||
- type: oscillator
|
||||
parameters: {color: 128, detune: 60, gain: 32, lfo: 0, phase: 0, shape: 64, stereo: 0, transpose: 64, type: 0, unison: 0}
|
||||
id: 3
|
||||
- type: addp
|
||||
parameters: {stereo: 0}
|
||||
- type: mulp
|
||||
parameters: {stereo: 0}
|
||||
- type: push
|
||||
parameters: {stereo: 0}
|
||||
- type: oscillator
|
||||
parameters: {color: 128, detune: 64, gain: 128, lfo: 1, phase: 64, shape: 64, stereo: 0, transpose: 70, type: 0, unison: 0}
|
||||
- type: send
|
||||
parameters: {amount: 68, port: 5, sendpop: 0, stereo: 0, target: 1}
|
||||
- type: send
|
||||
parameters: {amount: 68, port: 5, sendpop: 0, stereo: 0, target: 2}
|
||||
- type: send
|
||||
parameters: {amount: 68, port: 5, sendpop: 1, stereo: 0, target: 3}
|
||||
- type: out
|
||||
parameters: {gain: 128, stereo: 1}
|
Loading…
Reference in New Issue
Block a user