Writing alternating single cycle-ish waveforms to disk

Aug 17, 2011 at 12:17am

Writing alternating single cycle-ish waveforms to disk

I am writing an app that requires writing square waves of two different frequencies to an audio file. The audio file alternates these frequencies frequently, and at very precise times – often just a few cycles (2 cycles of the lower frequency (1300 Hz), 4 cycles of the higher frequency (2100 Hz)) at a time.

No big deal so far – I can just peek~ the samples for single cycles of the two waveforms into a buffer~. The challenge though is that it turns out that I don’t need *exactly* 2 cycles or 4 cycles of the waveforms at a time, but fractional amounts – like 2.75 cycles and 3.75 cycles for example. What this does is to create discontinuities in the resulting waveform of the audio file when these partial cycle waveforms are appended to each other.

So how can I write say, 2.75 cycles of 1300 Hz, then 3.75 cycles of 2100 Hz, then 2.75 cycles of 1300 Hz to a buffer~, but have the result be a continuous, “smooth”, audio file?

#58509

You must be logged in to reply to this topic.