Extreme High Quality Sound Emulation

For anything related to sound (YM2612, PSG, Z80, PCM...)

Moderator: BigEvilCorporation

r57shell
Very interested
Posts: 475
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Extreme High Quality Sound Emulation

Post by r57shell » Tue Mar 04, 2014 6:59 pm

I want to remind this image
Image
From that thread: viewtopic.php?p=7516#7516

If everything is correct, then YM2612 output is multiplexed.
I don't know any emulator that is emulating it.
I made some changes to genplus-gx YM2612 core to generate PCM according to this image.

I'm testing all things on Streats of Rage intro and demonstration.
There is only FM part of sound. Forgive me about volume inconsistency of different data. Also, I know that SOR intro may be far away from best test data. It's just one of MegaDrive music.

Common way of emulating YM2612 is calculate sum of 6 channels. I don't know any emulator that's doing something different.

Here is simple sum of 6 channels RAW 53267 Hz output: Download
Here is original genplus-gx "High quality resample" output 44100 Hz: Download

First test was to just interleave 6 FM channels.
It means that each FM channel outputs one PCM sample. 6 FM channels = 6 PCM samples.
Raw data would be 53693175/7/6/4 = ~319602 Hz. Download
After resample into 44100 Hz I got: Download

It's really nice, but I don't hear notable difference with standard output. (without multiplexing...)

Then, according to get more precision...
I get 6 FM channels, each of them scaled to 24 PCM samples, where first five is output value, and other 19 is zero.
Here is RAW output chunk: Download
Then, I resample it from 7.67 MHz into 44100 Hz and what I got?
Here it is: Download

Conclusion? I don't know.
I want you to make conclusions yourself.
I just wondering. Is there any notable difference?

For resample I was using libsoxr.

Also, someone, please tell me about mixing YM2612 and PSG process on real Hardware. I want to simulate it too.

I don't want to make HIGH effort to achieve Extreme High Quality.
I just lurking around.

Also, It's already took for me about 8 hours. I'm not taking into account time for writing this post, and remake PCM data, and Upload it.
Image

GManiac
Very interested
Posts: 92
Joined: Thu Jan 29, 2009 2:05 am
Location: Russia

Post by GManiac » Tue Mar 04, 2014 7:40 pm

The most important difference between "digitally ideal" emulated sound and real sound is in analogue output:
1) 9-bit DAC
2) ladder effect from DAC level -1 to level 0
3) other analogue and mixing effects.

Changing multiplexion method won't give you too much, AFAIR I've said this some years ago on this forum. Right or wrong (in case of not digitally ideal emulation) order of operator calculation won't give you too much too.
Last edited by GManiac on Tue Mar 04, 2014 7:55 pm, edited 5 times in total.

r57shell
Very interested
Posts: 475
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Tue Mar 04, 2014 7:49 pm

GManiac wrote:The most important difference between "digitally ideal" emulated sound and real sound is in analogue output:
1) 9-bit DAC
2) ladder effect from DAC level -1 to level 0
3) other analogue and mixing effects.
I know, but it's not my goal. I just tested multiplexing vs sum. If you know about FFT and other harmonic things, you must know that different shapes behavior is different. And I don't know mathematical aspect too much, to predict how Multiplexing affects output signal.
GManiac wrote:Changing multiplexion method won't give you too much, AFAIR I've said this some years ago on this forum.
Do you know WHY it happens? If you know, then tell me.
GManiac wrote:Right or wrong (in case of not digitally ideal emulation) order of operator calculation won't give you too much too.
You definitely wrong in this statement. Chips using clock to update state. And wrong order may cause wrong state, then wrong next state and so on. And as result - different output.
Image

GManiac
Very interested
Posts: 92
Joined: Thu Jan 29, 2009 2:05 am
Location: Russia

Post by GManiac » Tue Mar 04, 2014 8:38 pm

Sorry, didn't notice your new message.
This is new part for my first message:
Points 1 and 2 make very notable difference on quiet sound making it sound louder. It's all because operators use ariphmetic shift, not logical. Let me show it on example. Copy-paste this text to Excel, delimiter = whitespace.

Code: Select all

 operator	DAC_14	operator_asr_5	DAC_9	DAC_9_w_ladder		DAC_9=operator_asr_5*32
-64	-64	-2	-64	-164		ladder_size=100
-32	-32	-1	-32	-132		
-16	-16	-1	-32	-132		
0	0	0	0	0		
16	16	0	0	0		
32	32	1	32	32		
						
						
-8	-8	-1	-32	-132		
-4	-4	-1	-32	-132		
0	0	0	0	0		
4	4	0	0	0		
8	8	0	0	0		
						
-2	-2	-1	-32	-132		
-1	-1	-1	-32	-132		
0	0	0	0	0		
1	1	0	0	0		
2	2	0	0	0		
I know enough about FFT to say that it won't give too much. Perform one test. Take any music record and its time-multiplexion on itself. We can consider record as sum-multiplexion of its halves, so we can examine its self-time-multiplexion. You need to repeat its every sample N times. For example, original wave is
abcdef
then new wave will be
aabbccddeeff
I don't know how to make it in sound editors, I wrote simple program for that.
And look to spectral view of new record. You will see vertical reflection of spectrum. It is just result of Fourier transform and characteristics of sine, cosine and complex plane. Indeed, when you calculate FFT on matrix of real numbers, you will get vector having size = FFT window, but it consists of two half-sized sub-vectors: real frequencies vector and reverted vector of phantom freqs. Sound editors show you only real freqs, of course. We can write these sub-vectors like
A | 'A
"|" - is reflection delimiter.
When you double your samples and calculate FFT on new matrix you will get:
A 'A | A 'A
You can observe this reflection in records made from real HW, its delimiter is 27 kHZ (so you need sound card with at least 96 kHZ ADC).
Lower part of doubled record will be similar to original record. You can perform this test on sweep from 0 Hz to 24 kHz, for example (with 48 kHZ sampling rate, so 24k will be the maximum). The most notable difference between original and doubled records will be on high frequencies - near top of reflection. For MD it's 53 kHz, that's why you don't hear any differnecies.
r57shell wrote:
GManiac wrote:Right or wrong (in case of not digitally ideal emulation) order of operator calculation won't give you too much too.
You definitely wrong in this statement. Chips using clock to update state. And wrong order may cause wrong state, then wrong next state and so on. And as result - different output.
Maybe we are talking about different things. Certainly my emulator has another order of operator calculation, because I saw differencies between Regen records spectrum (for example) and spectrum of my emulator, but they are not notable for ear.

This is song.
Image

This is doubled record.
Image

This is doubled sweep.
Image

r57shell
Very interested
Posts: 475
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Tue Mar 04, 2014 9:08 pm

I see reflection, and I know what it cause.
But I can't say anything about sound from it's spectrum.
And, by the way, I don't have software to show spectrum.
What is "sweep"?

But, this is not the case!
There all much worse in what I tested.
1) Channels interleaved != duplicated
2) -_ form (5 up, 19 low = zero) It's not just all 24 at same value.

About DAC, it's outputing this values. So, picture in start is output of DAC.
I didn't check code, generating DAC output.
I mean, I didn't check asr there or something else.
I just making waveform from its output.

Update: yeah, I was mixing carriers accumulators trimmed to 9 bits. Hmm... what mix then?
Update: I wanted to play with passband filters, and I noticed that there is already lowpass filter applied.
So all previous resampled data (except genplus-gx output) with lowpass applied at some frequency.
Here is what I got with fullband: Download
Image

GManiac
Very interested
Posts: 92
Joined: Thu Jan 29, 2009 2:05 am
Location: Russia

Post by GManiac » Wed Mar 05, 2014 12:55 pm

Блин, два грамотея ведут диалог на ломаном английском на импортном форуме.
Ты уверен, что знаешь, что вызывает зеркалирование? Я тебе говорю, это выходит при расчёте матрицы ДПФ над вещественными числами. Эту хрень ты и видишь на картинках и слышишь в ушах. Возьми посчитай ДПФ руками, чтобы понять, что там происходит.
Софт - Cool Edit, Adobe Audition Sound Forge.
Свип - это синусо со скользящей частотой от 0 в начале до макс. в конце.

Чтобы реально сравнить суммирование и дублирование, берёшь оригинал и делаешь из него два файла:
1) апсемплишь его по частоте в два раза. На спектрограмме наверху будет пусто
2) дублишь его по семплам. В задубленном оригинале наверху будет зеркало.
Вычитаешь в редакторе из файла 1 файл 2, или наоборот. В Cool Edit копируешь Paste -> Special, галочка Invert. Смотришь, что получилось. Максимальная разница будет на самых верних частотах. На спектре свипа отчётливо видно, что верхние частоты ослаблены.

Насчёт текста дальше: пиши ясней, а то монолог какой-то у тебя.

r57shell
Very interested
Posts: 475
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Wed Mar 05, 2014 2:12 pm

GManiac wrote:Блин, два грамотея ведут диалог на ломаном английском на импортном форуме.
Ничего особенного.
GManiac wrote:Ты уверен, что знаешь, что вызывает зеркалирование?
Я уверен что это возможно. Я не пробовал посчитать.
GManiac wrote:Я тебе говорю, это выходит при расчёте матрицы ДПФ над вещественными числами. Эту хрень ты и видишь на картинках и слышишь в ушах.
Вот именно, что слышу я спектр, а не то что ты там сравниваешь файлы. Нужно сравнивать спектры.

Ты же, на сколько я догадываюсь, хочешь сказать "зеркало" мы не слышим ибо частота выше 25 KHz, и как бы надо наложить мысленно Lowpass до 25 KHz, и получим тоже самое.

Но даже это не правда.
GManiac wrote:Возьми посчитай ДПФ руками, чтобы понять, что там происходит.
Image
x0 = x1,
x2 = x3,
...
xn = xn+1
Найдём период синуса в "дублированном" соответствующий в "недублированном" X1. Почти очевидно, что это будет X2.
Image
из этого можно СРАЗУ сделать вывод, что X2 далеко не тот что X1 в не дублированном. А так же X4 в дублированном не соответствует X2 в не дублированном. А это, если что, низкие частоты!
То есть, спектр низких частот будет не совпадать. И это очевидно, ибо ДПФ обратимая операция, т.е. биекция. Другой вопрос в том, что различие могло быть только среди высоких частот, но это не так.
GManiac wrote:Чтобы реально сравнить суммирование и дублирование, берёшь оригинал и делаешь из него два файла:
То же самое, только не смотришь на картинки, а выводишь спектр в файл, и сравниваешь файлы. И то, я даже в этом случае, не знаю какие делать выводы из таких данных.
GManiac wrote:Насчёт текста дальше: пиши ясней, а то монолог какой-то у тебя.
Я сказал что у меня далеко не дублирование, а хитрое преобразование. Шесть каналов поочередно выдают -__ форму как на картинке в самом начале темы. Разных каналов! А ты мне про дублирование. :? Мультиплексирование это не просто дублирование, а чередование, напоминает чем-то interleaving в видео. Мультиплексирование бывает другого типа, тут конкретно временное.

Ты мне о DAC что-то говорил... по поводу DAC, картинка в начале темы это сигнал с DAC. Ядро genplus-gx YM2612 эмулирует значение DAC для каждого из 6 FM каналов, и обрезает до 9 битов (asr 5). Вот именно из этих значений, я и строю нужный мне waveform.

Я хотел поиграть с passband filter и обнаружил что libsoxr применяет lowpass фильтр при resampling. Убрал его и залил fullband версию.
(Это частично перевод моего поста + дополнение).
Image

feos
Newbie
Posts: 2
Joined: Wed Oct 16, 2013 7:02 pm

Post by feos » Wed Mar 05, 2014 3:06 pm

"orig" sounds the most filtered and bassy. "interleaved" and "masterclock" sound completely identical. "fullband" sounds the most mega drive-ish and familiar.

r57shell
Very interested
Posts: 475
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Wed Mar 05, 2014 5:14 pm

For complete picture...
SOR rawsum fullband: Download
SOR interleaved fullband: Download

Also
Time Trax PAL rawsum fullband: Download
Time Trax PAL masterclock fullband: Download

So, there is no reason to simulate 7.67 Hz output if you planning to apply only resampling and passband filters.
Also, I don't think that MD2 saw waveform make any difference, after this test.

It would be cool to know exact values of YM2612 DAC output.
Image

Chilly Willy
Very interested
Posts: 2591
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Wed Mar 05, 2014 6:48 pm

All you are doing is going from the original signal (the pcm and the fm outputs) to a PWM version of the outputs where the frequency of the PWM is never varied. All you are doing is adding a third and fifth harmonic of the pcm and fm at the fundamental frequency of the pulses. With proper filtering, the result is the same as simply summing the pcm and fm. Any differences are those harmonics leaking through the filter.

r57shell
Very interested
Posts: 475
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Wed Mar 05, 2014 7:05 pm

Chilly Willy wrote:With proper filtering, the result is the same as simply summing the pcm and fm.
I don't split FM and PCM, PCM is going through FM6 channel as FM signal.
I now (from tests) understand why there is same result.
What can you say which filters must be applied to achieve Hardware-like sound?
And, is there way to get full 53 KHz bandwidth from MD by modding it?
Because I like such high frequency sound, as in Time Trax test.
Image

Chilly Willy
Very interested
Posts: 2591
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Mar 06, 2014 6:52 pm

You'd need to check the schematics to determine the filter used. That also varies according to the model, so you'd probably want to imitate the Model 1 filter since most folks thinks it sounds better.

User avatar
TmEE co.(TM)
Very interested
Posts: 2316
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Mar 06, 2014 6:59 pm

Slap simple first order LPF on the output with cutoff at 13...16KHz.
I personally find that horrible (too muffled for my taste) and mod my machines to have cutoff beyond audible range.
http://www.tmeeco.eu/BitShit/TimeTraxIntro.flac
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

r57shell
Very interested
Posts: 475
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Thu Mar 06, 2014 7:35 pm

I don't familar with filter schematics.
I trust you, so I asking about info about filters that you know.

TmEE co.(TM) Is it from your modded MD? Is it MD without filters?
It sounds a little smoother than my emulation.

Update: Also, your bass is much louder. Some equalizer? Argh, it may be PSG :S. Less distorsion on solo.

By the way, how PSG is added to YM2612?
Image

User avatar
TmEE co.(TM)
Very interested
Posts: 2316
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Mar 06, 2014 8:08 pm

Its my modded MD, and there is filtering but only in inaudible range (at around 23KHz).
No equalisation, it is full flat audible range, with no measurable or audible distortion.

PSG is added to YM sound with a simple external mixer, same for MegaCD and 32X sound.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest