Page 1 of 1

Convert PCM to XGM

Posted: Fri Jan 24, 2020 7:05 pm
by cloudstrifer
Hi.

I want to convert PCM to XGM, just 1 channel, is it possible?

Thank you!

Re: Convert PCM to XGM

Posted: Fri Jan 24, 2020 9:31 pm
by Stef
Not sure what you mean exactly by converting PCM to XGM.
At least you ca declare your PCM resource as WAV resource then use the XGM driver to play it (whatever PCM channel you use for that).

Re: Convert PCM to XGM

Posted: Sat Jan 25, 2020 10:52 am
by cero
I suppose he wants to emulate a WAV using either synth or PSG, like those ancient speech synthesizers did. It'd sound bad/metallic/robotic/etc, and I don't think any such kit exists for Genesis.

Re: Convert PCM to XGM

Posted: Mon Jan 27, 2020 3:07 pm
by Stef
If that is really what he want then yeah, you don't have tools for that and honestly i think that results won't be good anyway.
I tried long a time ago to make a tool which could convert a PCM sample (single sound obviously) into a FM patch (kind of). It's definitely *very* complicated to develop that kind of tool (involve many mathematics and my maths aren't that great) and that would come with many limitations.

Re: Convert PCM to XGM

Posted: Tue Jan 28, 2020 11:36 pm
by haroldoop
There's a tool like that designed for the Sega Master System:
https://github.com/maxim-zhao/wav_to_psg

Re: Convert PCM to XGM

Posted: Wed Jan 29, 2020 11:50 am
by Stef
Oh no that is something completely different here, the tool you show just convert a WAV/PCM to PSG data taking in consideration the PSG constraints to filter/process the PCM data and obtain the best quality out of it (from the PSG). The resulting PSG data size is close to the PCM data, it's just downgraded PCM.
Converting PCM to FM is a complete different beast, at least if you intend to convert a PCM sound (which is probably about some KB of data) to a FM patch (only a few bytes of data) otherwise there is no use in trying to output raw PCM sample data with FM channel as the YM2612 does have a PCM channel.

Re: Convert PCM to XGM

Posted: Wed Jan 29, 2020 5:11 pm
by Sik
Well, you could attempt to add up sine waves (so size still tied to length, but still much smaller than full blown PCM)… but even if it was reduced to a single sound (e.g. speech) I'm not sure how far you can get with just a few sine waves (unless you want to start eating multiple FM channels). I recall Streets of Rage doing some weird stuff with channel 3 with sound effects though…

That said, I think the original post was about converting PCM into a XGM-friendly format :​P (which it already does for sound effects)

Re: Convert PCM to XGM

Posted: Wed Jan 29, 2020 11:59 pm
by haroldoop
One way to translate PCM to FM would be to treat it as a seq2seq machine learning problem.

The training sets could be generated by generating random sequences of FM commands and the corresponding PCMs; then the model could be trained to do the reverse mapping from the examples.

Re: Convert PCM to XGM

Posted: Thu Jan 30, 2020 12:05 pm
by Stef
haroldoop wrote:
Wed Jan 29, 2020 11:59 pm
One way to translate PCM to FM would be to treat it as a seq2seq machine learning problem.

The training sets could be generated by generating random sequences of FM commands and the corresponding PCMs; then the model could be trained to do the reverse mapping from the examples.
Interested in experimenting it ? :D

Re: Convert PCM to XGM

Posted: Thu Jan 30, 2020 10:53 pm
by haroldoop
Stef wrote:
Thu Jan 30, 2020 12:05 pm
haroldoop wrote:
Wed Jan 29, 2020 11:59 pm
One way to translate PCM to FM would be to treat it as a seq2seq machine learning problem.

The training sets could be generated by generating random sequences of FM commands and the corresponding PCMs; then the model could be trained to do the reverse mapping from the examples.
Interested in experimenting it ? :D
Maybe. :P

i did start planing something like that a few years ago, though with the objective of converting sound into chiptunes; any way, I never got beyond the initial planning phase. In fact, that's one of the reasons why I had implemented txt2vgm; the idea was to convert a bunch of VGM files into both wave files (which would be further processed into spectrograms) and vgm2txt files; the model would be trained to translate spectrograms into text files, which could then, finally, be converted into VGM using txt2vgm.

Re: Convert PCM to XGM

Posted: Fri Jan 31, 2020 9:40 am
by Stef
I think that is an interesting project :) When i was looking to develop my "PCMtoFM" tools i started to read some scientific literatures about it. I found some interesting articles but never got to time to investigate them in depth unfortunately, at this time IA or genetic algorithm weren't as efficient as today so i think things get better and better. You can have a look on them as some are definitely replicating what you want to do (genetic algo to find best FM parameters):

Genetic algorithm to improve FM parameters:
http://citeseerx.ist.psu.edu/viewdoc/do ... 1&type=pdf
https://ieeexplore.ieee.org/abstract/document/701371
https://www.tandfonline.com/doi/abs/10. ... 2000150852

FM Synthesis-Based Audio Coding:
http://www.aes.org/e-lib/browse.cfm?elib=8434

Speech synthesis with FM:
https://www.sciencedirect.com/science/a ... 8485901112

FM Synthesis of Real Instruments (just a synthesizer manual here):
http://www.javelinart.com/FM_Synthesis_ ... uments.pdf

Re: Convert PCM to XGM

Posted: Fri Jan 31, 2020 11:15 pm
by haroldoop
Interesting concept; I imagine that the genetic algorithm could be either be used directly, or to provide training data for other ML; I intend to take a look at some of them. :)