How to emulate PSG and SCC in Windows applications.

Pagina 1/6
| 2 | 3 | 4 | 5 | 6

Door Huey

Prophet (2694)

afbeelding van Huey

09-03-2011, 17:36

I am currently trying to make a sort of Vortex Tracker II clone using my limited C and windowsAPI knowledge.

The plan is simple: Reimplement the VTII functionalities and expand them with 5 new SCC channels without the PSG specific attributes (envelope etc.). So that we can finally produce real 8 channel music in our projects.

But I am wondering if there are some Out-of-the-Box PSG and SCC emulation solutions available. I have taken a look a Meisei and Marat's EMUlib for examples. But I am a 'bit' clueless on how to make it work. I was hoping to find a solution where I was only to write the PSG and SCC registers and that the rest is done by the libraries.

It would be a shame to loose any more time coding the emulation myself while all those projects are piling up Wink

img856.imageshack.us/img856/2561/98348361.th.png

Aangemeld of registreer om reacties te plaatsen

Van Vampier

Prophet (2409)

afbeelding van Vampier

09-03-2011, 18:58

check the source in openMSX or blueMSX

Van syn

Prophet (2113)

afbeelding van syn

09-03-2011, 20:48

there is also msxplug, a plugin for winamp and some other media player. It has scc, fmpac, music module, psg. I am not sure whether it is open source or whatever.

Van Metalion

Paragon (1622)

afbeelding van Metalion

10-03-2011, 10:08

Very nice idea, Huey !!!
Keep up the good work !

Smile

Van AuroraMSX

Paragon (1902)

afbeelding van AuroraMSX

14-03-2011, 23:28

I am currently trying to make a sort of Vortex Tracker II clone using my limited C and windowsAPI knowledge.

The plan is simple: Reimplement the VTII functionalities and expand them with 5 new SCC channels without the PSG specific attributes (envelope etc.). So that we can finally produce real 8 channel music in our projects.Erhm, would it be possible to do it in Java and add FM-PAC and Music Moulde support? (Java for cross-platformness so I could use it on my maccie Hannibal )

Van Huey

Prophet (2694)

afbeelding van Huey

15-03-2011, 10:44

Erhm, would it be possible to do it in Java and add FM-PAC and Music Moulde support? (Java for cross-platformness so I could use it on my maccie Hannibal )

Sorry. ATM we only need PSG+SCC support. But I already have taken in mind further chip support when designing the framework. But that is no guarantee for implementation as I am personally not able to implement sound emulation (I am not a coder).

Van ARTRAG

Enlighted (6923)

afbeelding van ARTRAG

09-04-2011, 18:08

I need help in PSG emulation. The major problems are in emulating the psg noise
Mixing tones and noise is a sort of mistery...
I cannot find a clear explanation in docs on how real HW works
Can anyone have a look to the following code and tell me where I am wrong?


SHORT R01 = 0;
SHORT R23 = 0;
SHORT R45 = 0;

char R6 = 31;
char R7 = 0;

char R8 = 15;
char R9 = 15;
char R10= 15;

char R15 =0;

#define playback_frequency     44100.0
#define psg_master_frequency   (1.7897725e6/16.0)

unsigned char volume_table[] = {0,2,3,4,6,8,11,16,23,32,45,64,90,128,180,255};

void psg_generator(LPSTR data, int size)
{
    static float PhaseA,PhaseB,PhaseC;    // state counters for ch A, B and C
    static SHORT LA,LB,LC;                // output state for ch A, B and C

    static float PhaseN;                 // state counters for Noise Generator
    static SHORT LN;                     // state for Noise Generator

    SHORT VA = volume_table[R8 & 15] * !(R7 & 0x01);     // output volume for ch A, B and C
    SHORT VB = volume_table[R9 & 15] * !(R7 & 0x02);
    SHORT VC = volume_table[R10& 15] * !(R7 & 0x04);

    float hPeriodA = ((R01 & 0x0FFF)+0)*128.0*playback_frequency/psg_master_frequency;
    float hPeriodB = ((R23 & 0x0FFF)+0)*128.0*playback_frequency/psg_master_frequency;
    float hPeriodC = ((R45 & 0x0FFF)+0)*128.0*playback_frequency/psg_master_frequency;

    float PeriodN = ((R6 & 0x1F)+0)*256.0*playback_frequency/psg_master_frequency;

    PSHORT b = (PSHORT) data;

    for (int i=0;i<(int)size/sizeof(SHORT);i++)
    {
        SHORT Level = 0;

        PhaseN-=256;
        if (PhaseN<=0)
        {
            PhaseN += PeriodN;			// 8 bit of fractional part
//            LN = ((rand()+1)>>1) & 1;
            LN = AY8910_NoiseGenerator();   // 17 bit random generator
        }

		PhaseA-=256;					// 8 bit of fractional part
		if (PhaseA<=0)
        {
            PhaseA += hPeriodA;			// 8 bit of fractional part
            LA = (LA>=0) ? (-VA):(VA);
        }
		PhaseB-=256;					// 8 bit of fractional part
		if (PhaseB<=0)
        {
            PhaseB += hPeriodB;			// 8 bit of fractional part
            LB = (LB>=0) ? (-VB):(VB);
        }
		PhaseC-=256;					// 8 bit of fractional part
		if (PhaseC<=0)
        {
            PhaseC += hPeriodC;			// 8 bit of fractional part
            LC = (LC>=0) ? (-VC):(VC);
        }


        if (!(R7 & 0x08) && (LN==0))
			Level += -VA;
        else
            Level += LA;

        if (!(R7 & 0x10) && (LN==0))
			Level += -VB;
        else
            Level += LB;

        if (!(R7 & 0x20) && (LN==0))
			Level += -VC;
        else
            Level += LC;

        b[i] = Level*16;
    }
}

Van Sarcasmic

Master (149)

afbeelding van Sarcasmic

09-04-2011, 20:22

is it possible to make a vsti out of it?

Van ARTRAG

Enlighted (6923)

afbeelding van ARTRAG

09-04-2011, 20:30

what is a vsti ?

Van wouter_

Champion (508)

afbeelding van wouter_

09-04-2011, 20:58

Can anyone have a look to the following code and tell me where I am wrong?
If I read your code correctly, you _add_ the noise and the tone, right? Instead you should _multiply_ both. This should happen before the volume of the channel is applied. But at that point the output of the tone square wave is either 0 or 1 and the same for the noise, so multiplication is actually the same as an AND operation.

You can also take a look at emulator source code like mame, meisei, blueMSX or openMSX. The code of mame seems simplest (may be easiest to understand). The code of openMSX is highly optimized, so likely most difficult to understand.

Van JohnHassink

Ambassador (5655)

afbeelding van JohnHassink

09-04-2011, 21:04

VSTi are plug-ins for use in trackers etc.

@ wouter_: that seems like some very valuable info, thanks!

Pagina 1/6
| 2 | 3 | 4 | 5 | 6