How to emulate PSG and SCC in Windows applications.
check the source in openMSX or blueMSX
By Google
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.
Very nice idea, Huey !!!
Keep up the good work !
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
)
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
)
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).
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;
}
}
is it possible to make a vsti out of it?
what is a vsti ?
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.
VSTi are plug-ins for use in trackers etc.
@ wouter_: that seems like some very valuable info, thanks!

By Huey
Prophet (2132)
09-03-2011, 17:36