-
Notifications
You must be signed in to change notification settings - Fork 19
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
[BUG] Aliasing noise #18
Comments
Thanks for your info. Is the waves of M8P2 are rendered directly from DAWs? M8P's audio rendering is no simpler than any waveform generation algorithm. And as a matter of fact, the waveform rendered directly from DAW(mine is Logic Pro X) looks like this. I know this is an extreme waveform which is not likely to happen with ordinary instruments, and it's likely that converting it to any other format will cause some distortion as it's too edgy. |
One possible case is that a margin of sampling error causes the alias noises. |
We should clarify about what "aliasing" means here. Usually in the audio domain "aliasing" means the one in the sampling theorem. That is, having an analog signal at the first place, and then trying to "sample" it in a discrete way, there will be unwanted jumps in the resulted waveform. M8P doesn't sample any analog signal but just generate a digital waveform from scratch in pure digital way. So in this context discussing about "aliasing" doesn't make sense. On the other hand, the word "aliasing" can be used in a different way. By analogy to the graphic domain, "aliasing" can refer to any untamed sharp digital edge (the etymology is the same though). I believe @sdhizumi is saying "aliasing" in this context. If it is really a problem, the solution will be applying a high-pass filter. |
I'm also interested in this problem, so I'd like to provide some additional information.
It seems the M8P's oscillator produces "aliasing" in the sense of folding noise. The implementation in return angle < rate * MathConstants<float>::pi ? -1.0 : 1.0; The formulation is as same as the definition of an analog square wave (which has infinite harmonic components). Roughly speaking, the implicit harmonics above the Suppression by low-pass/high-pass filtering is difficult because aliasing components already lie between the "true" harmonics. In my opinion, generating an anti-aliased waveform is reasonable in general. Although, I also like the fat/edgy sound of the current M8P. (I'm wondering if it's possible to add the same aliasing at any sampling rate, even 44.1 kHz or 192 kHz!) |
Thanks, @nakakq It's an interesting discussion. It doesn't necessarily means that it deals with sinusoidal waveform only because having the constant PI in the formula. The synthesizer core loops a sort of timing value which ranges from 0 to a certain maximum value. And while the value is under the half of the maximum it produces -1, and then +1 for the rest. The maximum value is set to 2*PI just because it's convenient when you are working with sinusoidal waves, not because there underlies a sinusoidal wave. Saying that, it's also true that the folding happens with above algorithm. But the note height to make it happen is pretty high. As @nakakq pointed out, at the point it exceeds the To summarize, a PI constant appears in the code but there isn't an implicit sin wave. The folding still can happen but the note height to make it happen is extremely high. |
Maybe my explanation about implicit harmonics was unclear, so let me explain in detail. FormulationWe're going to generate a square wave (50% duty) with period Then, the periodic wave As you can see, this formula contains infinite number of sine waves with frequency multiplied by DemonstrationI wrote a C++ program to demonstrate the aliasing effect (source code). This program outputs 3 WAV files; they are all square waves but are generated by different methods. The note frequency gradually changes from C3 (130.81 Hz) to C10 (16744.04 Hz). The The 3 generation methods are:
Results (spectrogram): The spectrogram of Here's a graphical explanation for the folding of the overtones: To sum up, the implicit overtones make the aliasing. I hope this comment is useful! |
Thanks. I have two questions.
|
Here's the original files: pulse.zip My spectrogram settings in Audacity (the window size was 1024): |
@yokemura here is some info on reducing aliasing waves. essentially, some trickery needs to be done at the discontinuities, otherwise harmonics will reflect back down from half the sampling rate, becoming weird inharmonics. id recommend polyblep; its computationally quick and usually the fastest to code into the oscillators |
@nakakq Sorry for my long silence. I've been busy in making my music. Before moving forward the discussion we have to think about what NOISE is, what DISTORTION is. And as another point of view, we have to be aware that the analysis process can produce a noise. In short, analysis may lie. The analysis methods like spectrogram uses FFT/wavelet-based algorithm involve the process to decompose the waveform into sine waves, and it means any waveforms that is difficult to represent as a sinusoidal composition can result in an unexpected expression. My understanding is like this:
|
@yokemura Thank you! I'd like to reply line-by-line. My opinion in a nutshell:
In my opinion, it's difficult to discuss the sound quality using the time-domain waveform. Indeed the m8p's waveform is cleaner than the "Sines" in the waveform, but the frequency-domain characteristics are more important for the sound. Human hears mainly in the frequency domain (recall the cochlea of the ear), so we should evaluate them on the frequency domain.
I believe that such a frequency analysis is appropriate for evaluating. The reasons are the below:
You may hear the obvious aliasing in the last half of the "M8P2" audio file compared to "Sines" (in the audio samples previously sent, please be careful with the volume), or playing high-pitched notes with vibrato on m8p. Note that the sampling theorem (which causes the aliasing) is a limitation of the digital signal itself, not a limitation of the analysis.
I agree that the "Sine" is an approximated square wave, which is designed to avoid artifacts in the frequency domain. However, I think that the m8p also generates approximated waveform; it has another kind of "distortion", which is about the pitch period. For example, assuming that the sampling rate is Such switching can cause a kind of weird sound. The switching leads some false components in the frequency domain, and our ears perceive it as the aliasing noise. To improve the perceived sound, alias-free oscillators are reasonable (so many digital synthesizers use them). But in m8p, there's maybe a room for thought considering that the chip-tune music needs some Lo-Fi sound. Sometimes aliasing makes sound powerful (e.g. synth leads), and sometimes undesirable. It's not necessary to replace m8p completely with alias-free oscillators, but it's nice to add alias-free oscillators as an option I think. EDIT: clarified the comment, and sorry about such a long reply! |
Describe the bug
Magical8bitPlug2 has an aliasing noise, increase or decrease depending on the frequency rate of the host.
I think this is not a correct sound of an old 8bit game console.
To Reproduce
Expected behavior
Played something note but it includes an aliasing noise.
This noise affects the impression of the high frequencies, decreases with higher sampling rates.
I tried to compare it with the actual Gameboy's waveform. (Sorry I can't test with FC/NES quickly.)
Screenshots
All images captured by Voxengo SPAN Plus with these settings:
Window = HANN
Overlap = 50.0
Avg Time = 500
Type = RT AVG
Block Size = 2048
ANTI-ALIAS = OFF
ALIGN 0 DB = OFF
Offset = OFF
Smooth = OFF
Freq Lo = 20.0
Freq Hi = 20.0k
Range Lo = -96.0
Range Hi = 0.0
Slope = 4.50
(Probably it can be setting the same settings on SPAN, free edition.)
Played 440Hz 50% Pulse note -
on 44.1kHz:
M8P2
Gameboy APU
on 48kHz:
M8P2
Gameboy APU
on 192kHz:
M8P2
Gameboy APU
NOTE - Gameboy APU has a hissing noise. It looks like this:
Audio
I uploaded some samples on my drive. It contains a plain text file that wrote some descriptions of samples.
https://drive.google.com/file/d/10BwRPw2CkZUchpEji6YLlRW1o4-M2OeP/view?usp=sharing
Your environment (please complete the following information):
(and my friend has tested on Logic, same issue.)
Additional context
It looks like anti-aliasing is needed.
The text was updated successfully, but these errors were encountered: