-
Notifications
You must be signed in to change notification settings - Fork 47
Fix sf2 volume control, note release, and sparse-bank patch fallback (#295) #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ab6dd42
0d9b1e0
b96ef17
bc4e834
d8e67a4
a6f6dca
370c363
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* assert-based test for _WM_get_patch_data()'s bank resolution order. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Regression guard for issue #295: a non-zero bank in a timidity.cfg is a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * sparse overlay on bank 0 (eawpats' "bank 8" defines one program, "drumset 8" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * one note), so a program the overlay does not define has to come from bank 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * and not from the nearest-patch search inside the overlay. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <assert.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <stdint.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <string.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "patches.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| struct _mdi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| extern struct _patch *_WM_get_patch_data(struct _mdi *mdi, uint16_t patchid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| static struct _patch b0_p0, b0_p24, b0_d38, b8_p80, b8_d54; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| static void add(struct _patch *p, uint16_t patchid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| memset(p, 0, sizeof(*p)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| p->patchid = patchid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| p->next = _WM_patch[patchid & 0x7F]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _WM_patch[patchid & 0x7F] = p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int main(void) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add(&b0_p0, 0x0000); /* bank 0, program 0 */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add(&b0_p24, 0x0018); /* bank 0, program 24 */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add(&b0_d38, 0x00a6); /* drumset 0, note 38 (0x26 | 0x80) */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add(&b8_p80, 0x0850); /* bank 8, program 80 - the whole overlay */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add(&b8_d54, 0x08b6); /* drumset 8, note 54 - the whole overlay */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* exact hits win */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert(_WM_get_patch_data(NULL, 0x0018) == &b0_p24); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert(_WM_get_patch_data(NULL, 0x0850) == &b8_p80); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert(_WM_get_patch_data(NULL, 0x08b6) == &b8_d54); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* a program the overlay lacks comes from bank 0, not from the overlay */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert(_WM_get_patch_data(NULL, 0x0818) == &b0_p24); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert(_WM_get_patch_data(NULL, 0x08a6) == &b0_d38); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* a bank nothing defines still falls back to bank 0 (SMAF selects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Yamaha's own 0x7c banks, which no GUS patch set has) */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert(_WM_get_patch_data(NULL, 0x7c00) == &b0_p0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* only when bank 0 has no such program either does the nearest one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stand in, rather than playing silence */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert(_WM_get_patch_data(NULL, 0x0017) == &b0_p24); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert(_WM_get_patch_data(NULL, 0x0819) == &b0_p24); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+33
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Keep regression checks active in Release builds. When Proposed fix-#include <assert.h>
`#include` <stdint.h>
`#include` <string.h>
`#include` "patches.h"
+#define CHECK(expr) do { if (!(expr)) return 1; } while (0)
+
@@
- assert(_WM_get_patch_data(NULL, 0x0018) == &b0_p24);
- assert(_WM_get_patch_data(NULL, 0x0850) == &b8_p80);
- assert(_WM_get_patch_data(NULL, 0x08b6) == &b8_d54);
+ CHECK(_WM_get_patch_data(NULL, 0x0018) == &b0_p24);
+ CHECK(_WM_get_patch_data(NULL, 0x0850) == &b8_p80);
+ CHECK(_WM_get_patch_data(NULL, 0x08b6) == &b8_d54);
@@
- assert(_WM_get_patch_data(NULL, 0x0818) == &b0_p24);
- assert(_WM_get_patch_data(NULL, 0x08a6) == &b0_d38);
+ CHECK(_WM_get_patch_data(NULL, 0x0818) == &b0_p24);
+ CHECK(_WM_get_patch_data(NULL, 0x08a6) == &b0_d38);
@@
- assert(_WM_get_patch_data(NULL, 0x7c00) == &b0_p0);
+ CHECK(_WM_get_patch_data(NULL, 0x7c00) == &b0_p0);
@@
- assert(_WM_get_patch_data(NULL, 0x0017) == &b0_p24);
- assert(_WM_get_patch_data(NULL, 0x0819) == &b0_p24);
+ CHECK(_WM_get_patch_data(NULL, 0x0017) == &b0_p24);
+ CHECK(_WM_get_patch_data(NULL, 0x0819) == &b0_p24);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.