Skip to content
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

Cracked sound generated when modulation enabled at high frequency #101

Open
mckuhei opened this issue Oct 20, 2024 · 9 comments
Open

Cracked sound generated when modulation enabled at high frequency #101

mckuhei opened this issue Oct 20, 2024 · 9 comments

Comments

@mckuhei
Copy link

mckuhei commented Oct 20, 2024

2024-10-20.08-31-27.mp4

Test midi:
Crackedsound.zip

@jcmoyer
Copy link

jcmoyer commented Oct 20, 2024

Possibly caused by out of range values in pcm multi, but not sure what the fix would be.

Nuked-SC55/src/pcm.cpp

Lines 288 to 301 in 205ff94

inline int32_t multi(int32_t val1, int8_t val2)
{
if (val1 & 0x80000)
val1 |= ~0xfffff;
else
val1 &= 0x7ffff;
val1 *= val2;
if (val1 & 0x8000000)
val1 |= ~0x1ffffff;
else
val1 &= 0x1ffffff;
return val1;
}

EDIT: Can someone test this midi on real hardware and report what happens?

@Axis4s
Copy link

Axis4s commented Oct 23, 2024

Gui got more development?

@mckuhei
Copy link
Author

mckuhei commented Oct 23, 2024

No, this is my own branch.

@linoshkmalayil
Copy link

Possibly caused by out of range values in pcm multi, but not sure what the fix would be.

Nuked-SC55/src/pcm.cpp

Lines 288 to 301 in 205ff94

inline int32_t multi(int32_t val1, int8_t val2)
{
if (val1 & 0x80000)
val1 |= ~0xfffff;
else
val1 &= 0x7ffff;
val1 *= val2;
if (val1 & 0x8000000)
val1 |= ~0x1ffffff;
else
val1 &= 0x1ffffff;
return val1;
}

EDIT: Can someone test this midi on real hardware and report what happens?

I tested this out on my SC-88Pro and SC-55mkII, both do not produce this cracked sound.
Tested it on the Nuked SC-55 running SC-55mkII roms, produces this cracked sound
So it seems this is a Nuked SC-55 issue.

@jcmoyer
Copy link

jcmoyer commented Oct 23, 2024

Seems to fix the problem for mk2:

diff --git a/src/pcm.cpp b/src/pcm.cpp
index 0cd1c29..b048fb0 100644
--- a/src/pcm.cpp
+++ b/src/pcm.cpp
@@ -1410,7 +1410,9 @@ void PCM_Update(uint64_t cycles)
                 int v1 = v2 + (mult2 >> 13) + ((mult2 >> 12) & 1); // 10
                 int subvar = v1 + (mult3 >> 6) + ((mult3 >> 5) & 1); // 11

-                ram1[3] = v1;
+#define Clamp(v, x0, x1) (v < x0 ? x0 : v > x1 ? x1 : v)
+
+                ram1[3] = Clamp(v1, -0x80000, 0x7ffff);

                 int tests = test;
                 tests <<= 12;
@@ -1423,7 +1425,7 @@ void PCM_Update(uint64_t cycles)
                 int v4 = reg1 + (mult4 >> 6) + ((mult4 >> 5) & 1); // 14
                 int v5 = v4 + (mult5 >> 13) + ((mult5 >> 12) & 1); // 15

-                ram1[1] = v5;
+                ram1[1] = Clamp(v5, -0x80000, 0x7ffff);
             }

Here's an audio comparison before/after: CrackleFixRenders.zip

The crackling version seems to have a lot more noise overall but I think it's just reverb from the crackling. If you invert one of the tracks and play them simultaneously the only thing left is the crackling.

@Grieferus
Copy link

Kind of offtopic question: where did you get the version with GUI?

@MusicallyInspired
Copy link

He said it was his own branch.

@mckuhei
Copy link
Author

mckuhei commented Oct 26, 2024

Gui is in my fork and can be downloaded here: https://github.com/mckuhei/Nuked-SC55/releases/tag/gui-v1.0

@Grieferus
Copy link

Seems to fix the problem for mk2:

diff --git a/src/pcm.cpp b/src/pcm.cpp
index 0cd1c29..b048fb0 100644
--- a/src/pcm.cpp
+++ b/src/pcm.cpp
@@ -1410,7 +1410,9 @@ void PCM_Update(uint64_t cycles)
                 int v1 = v2 + (mult2 >> 13) + ((mult2 >> 12) & 1); // 10
                 int subvar = v1 + (mult3 >> 6) + ((mult3 >> 5) & 1); // 11

-                ram1[3] = v1;
+#define Clamp(v, x0, x1) (v < x0 ? x0 : v > x1 ? x1 : v)
+
+                ram1[3] = Clamp(v1, -0x80000, 0x7ffff);

                 int tests = test;
                 tests <<= 12;
@@ -1423,7 +1425,7 @@ void PCM_Update(uint64_t cycles)
                 int v4 = reg1 + (mult4 >> 6) + ((mult4 >> 5) & 1); // 14
                 int v5 = v4 + (mult5 >> 13) + ((mult5 >> 12) & 1); // 15

-                ram1[1] = v5;
+                ram1[1] = Clamp(v5, -0x80000, 0x7ffff);
             }

Here's an audio comparison before/after: CrackleFixRenders.zip

The crackling version seems to have a lot more noise overall but I think it's just reverb from the crackling. If you invert one of the tracks and play them simultaneously the only thing left is the crackling.

I'd propose merging this with master branch, no matter how specific this bug might be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants