fwiw,

i've played around with this for a few minutes today and it's easy enough to get something more closely resembling FM behaviour by 1/ making mod an int32_t, 2/ scaling it and 3/ simply adding it to the phase increment.

/// ... from synth_sine.cpp :

Code:

mod = signed_multiply_32x16b(_mod_index, modinput->data[i]);
//mod += signed_multiply_32x16b(_feedback, block->data[i]);
ph += inc + mod; // (multiply_32x32_rshift32(inc, mod << 16) << 1);

that's not very scientific, but what i've noticed with the larger values of "mod" is that the waveform drifts. that seems to be the case for the present sineFM object, too; it's barely noticeable, because the modulation is so subtle but watching it on a scope, it does slowly morph.

my test sketch is simply:

(note i'm using a pcm5102a codec, not SGTL5000, so there's none of the i2c stuff. you'd have to add this)

Code:

#include <Audio.h>
#include <SD.h>
#include <SPI.h>
#include <SerialFlash.h>
AudioSynthWaveformSine modulator;
AudioSynthWaveformSineModulated carrier;
AudioOutputI2S codec;
AudioConnection patchCord0(modulator, carrier);
AudioConnection patchCord1(carrier, 0, codec, 0);
AudioConnection patchCord2(carrier, 0, codec, 1);
uint32_t _wait;
uint16_t _freq = 220;
float _index = 0;
void setup(void)
{
AudioMemory(12);
carrier.amplitude(0.8f);
carrier.frequency(_freq);
/* uncomment line below */
//carrier.mod_index(1.0f);
modulator.amplitude(1.0f);
modulator.frequency(_freq*2);
}
void loop(void)
{
if (millis() - _wait > 5)
{
_wait = millis();
/* uncomment line below */
//carrier.mod_index(_index++);
}
}

so, using the default library object, the above will exhibit what seems to be the maximum modulation possible (= modulator.amplitude(1.0f)), which isn't very much.

uncommenting the two lines where it says carrier.mod_index( ) is just a quick and dirty hack to make things more FM-like, that's all.

to try and see or hear the difference, class AudioSynthWaveformSineModulated needs an additional method:

Code:

void mod_index(float n) {
if (n < 0) n = 0;
else if (n > 65535.0) n = 65535.0;
_mod_index = n * 65536.0;
}

and corresponding private variable: int32_t _mod_index;

finally, lines 180-181 in synth_sine.cpp in turn need modification:

Code:

mod = signed_multiply_32x16b(_mod_index, modinput->data[i]);
ph += inc + mod;

where mod is now an int32_t, not int16_t