RemiHiyama wrote: ↑Sun Nov 24, 2019 6:05 am
Okay, that was enough to get me started. Spent an embarrassingly long time banging my head on the problem of preserving the timing of the amplitude modulation, but I think I've got that settled.
You may take a look into
MPSourceParam for an example implementation.
Not being able to change frequency modulation independently of channel means I'm back to needing to generate separately and mix, but that doesn't seem like it'll be a huge hardship.
If channels connected to a common electrode different frequencies per channel is equivalent to a carrier frequency equal to weighted average of the channel frequencies plus periodic phase modulation with frequency equal to the difference of the channel frequencies.
Without a common electrode the situation is different because there is no channel mixing: phase modulation has no effect but different frequencies per channel makes sense. This is not supported directly by MPGenerator, but you can use tools like ffmpeg for channel combining.
There doesn't really seem to be an ideal place to put a limit check on frequency modulation that I can tell. Handling it in the MPSource seems like it would give better results, but since that object doesn't know the pulse width, it can't tell whether it's getting into frequencies that are too high or too low.
The normal main frequency component (the only one if you disable
power saving) is equal to 1/(4*<
pulse width>). By default it is 833 Hz. The default sample width (parameter dt0 of the
getSample method) is calculated from this setting and from a few other constraints. By stretching this sample width up to factor two (actual sample with is the value returned by getSample) the carrier frequencies are lowered by the same factor. With
confPulseWidth=300 this results in frequencies between 833Hz and 417Hz.
IMHO feasible carrier frequencies should be in the range of 400Hz to 1000Hz.
I tested it again and also added frequency modulation support to the script language (see
Changes.md). For me, frequency modulation mainly feels like amplitude modulation and the theoretical effect I described in my previous post ("balance shifting") is only very weak. In order to extract this effect amplitude would have to be compensated. But this compensation is probably very individual.
If someone is interested in new sound packs from the library, please send me a note. (In the past there was no interest)