YM2612 Algorithms - How do you phase modulate an operator?
Posted: Wed Feb 11, 2009 11:58 pm
Hi all,
I'm having troubles getting operator phase modulation working in my YM2612 core emulator.
Basically, I'm following the excellent information in this thread:
viewtopic.php?t=386&postdays=0&postorder=asc&start=150
The problem is I'm not sure how to combine the output of one operator (which is 14 bits) to modulate the phase input (10 bits) of another operator as required by the YM2612 "Alogorithms".
Do I need to perform any shifts/manipulation on the 14 bit output before adding it to the 10 bit phase input? I've tried everything under the sun, but I can't get anything to work - I keep getting wierd hissing/distortion sound as soon as I try to combine operators.
Can anyone explain the math on how to do this in the "perfect" device code taken from the mentioned thread (see below).
cheers,
Steve
I'm having troubles getting operator phase modulation working in my YM2612 core emulator.
Basically, I'm following the excellent information in this thread:
viewtopic.php?t=386&postdays=0&postorder=asc&start=150
The problem is I'm not sure how to combine the output of one operator (which is 14 bits) to modulate the phase input (10 bits) of another operator as required by the YM2612 "Alogorithms".
Do I need to perform any shifts/manipulation on the 14 bit output before adding it to the 10 bit phase input? I've tried everything under the sun, but I can't get anything to work - I keep getting wierd hissing/distortion sound as soon as I try to combine operators.
Can anyone explain the math on how to do this in the "perfect" device code taken from the mentioned thread (see below).
cheers,
Steve
Code: Select all
//attenuationBitCount = 10
//phaseBitCount = 10
//operatorOutBitCount = 14
//phase = the output from the phase generator
//attenuation = the output from the envelope generator
//???????????????????????
// how do you modulate the 10 bit "phase" input by another operators 14 bit output?
// Something like this is not working for me:
// phase += otherOperatorOutput; // Modulate
// phase &= ( ( 1 << 10 ) -1 ); // Wrap
//???????????????????????
//Calculate the sine value
double phaseNormalized = ((double)phase / ((1 << phaseBitCount) - 1))
double sinResult = sin(phaseNormalized * M_PI * 2);
//Convert the attenuation to a linear representation of power
double attenuationIndividualBitWeighting = 48.0 / (1 << attenuationBitCount);
double attenuationInBels = (((double)attenuation * attenuationIndividualBitWeighting) / 10.0);
double powerLinear = pow(10.0, -attenuationInBels);
//Attenuate the result
double resultNormalized = sinResult * powerLinear;
//Calculate the 14-bit operator output
unsigned int maxOperatorOutput = ((1 << (operatorOutBitCount - 1)) - 1);
int result = (int)(resultNormalized * maxOperatorOutput);