Sound analyzer

SGDK only sub forum

Moderator: Stef

Post Reply
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Sound analyzer

Post by alko » Thu May 19, 2016 11:19 am

How to make a sound analysis when playing VGM-music?

https://youtu.be/7VP2YwJen9w?t=14
Image

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: Sound analyzer

Post by alko » Thu May 19, 2016 7:48 pm

I guess only by this function
u8 YM2612 read (const u16 port)
Image

mikejmoffitt
Very interested
Posts: 86
Joined: Fri Sep 25, 2015 4:16 pm

Re: Sound analyzer

Post by mikejmoffitt » Thu May 19, 2016 9:34 pm

If you can read the digital output data, you're still going to have to implement a fast-fourier transform and generate visuals with that. You would be better off reading the registers of the YM2612, and reading the frequency and multipliers of all modulators to determine mathematically the response of different frequencies.

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: Sound analyzer

Post by alko » Fri May 20, 2016 5:23 am

I would at least make an analysis of whether there is a signal from generator's or not.
at least make any reaction.
I can't do it at this moment.
I do not know which parameter is to assign a function.
YM2612_read (const u16 port)

port=0,1,2,3 - value return 0
Image

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Sound analyzer

Post by Stef » Fri May 20, 2016 12:00 pm

I wrote a XGM player displaying chip state (YM2612 and PSG), the project is in standby currently as i want to deliver a new SGDK version soon but i will bring it back. Still it just display channel / operator state and not directly the output waveform (nor the frequency spectrum which require FFT calculation).
If you really want the sample output level it seems you can read it from the YM2612 using the test register :
viewtopic.php?f=24&t=386&start=705

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: Sound analyzer

Post by alko » Fri May 20, 2016 1:56 pm

Not necessary frequency spectrum.
at least something.
even banal check for PSG or FM signal.
https://youtu.be/b-bkMvSSII0?t=281


I just want to synchronize animation with music
Image

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Sound analyzer

Post by Stef » Fri May 20, 2016 6:32 pm

So maybe trying to read the YM2612 sample out from test register or you need to "simulate" YM state to know its current output level (i'm using the second solution in my XGM player).

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: Sound analyzer

Post by alko » Sat May 21, 2016 5:36 am

Stef wrote:So maybe trying to read the YM2612 sample out from test register or you need to "simulate" YM state to know its current output level (i'm using the second solution in my XGM player).
But I do not know how to read registers.
What function do it?
Image

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Sound analyzer

Post by Stef » Sat May 21, 2016 9:20 am

You have to use YM2612_read(0) as it seems than others ports always return 0.

Then you have to set some special value in test register $21, you can see the description here :
http://www.atkinsoft.com/datasheets/ym2612.txt

Basically you should do something like that :

Code: Select all

u16 output;

YM2612_write(0, 0x21);
// enable serial data read from status register
YM2612_write(1, 0x40);
// read LSB
output = YM2612_read(0);
YM2612_write(1, 0xC0);
// read MSB
output |= YM2612_read(0) << 8;
// restore default state
YM2612_write(1, 0x00);
Note that it won't work on emulator, only on real hardware... I didn't tested the code but it should be close to that :p

troudki
Interested
Posts: 18
Joined: Sun Dec 20, 2015 10:31 am

Re: Sound analyzer

Post by troudki » Sun Jul 17, 2016 9:30 pm

HI stef,
Have you used your snippet code in your XGM/VGM player demo ?
Can you explain or make a simple code for illustrate ?
Thx :)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Sound analyzer

Post by Stef » Mon Jul 18, 2016 8:24 am

No i didn't used that as this method only give you current output level from the YM2612 chip. Also XGM is played from Z80 so unfortunately the 68000 is not aware of the YM2612 and PSG instant state as it does not update them itself. The only thing the 68000 control is how many XGM frame has been done so basically what i'm doing in the XGM player is the following:
- Request Z80 to compute a frame of XGM music.
- Parse the next XGM frame to update a virtual YM2612 (containing current state of the YM chip), do the same with a virtual PSG.
- Update envelop of each YM2612 channel for 1 frame length
- Use current envelop levels and chip states from the virtual YM2612 and PSG to display chips status at bottom.

So definitely not a straightforward method but i don't have the choice if you want an accurate chip state (specially for the YM2612 envelop level).

Post Reply