Waveform modeling

This is a bit new. Having discovered some interesting things about the two top bits of $804, there are some exploits you can do.

First and foremost, the most important thing is that you can now sync the channel waveform to any cpu cycle. That is, you can both re-initialized the period counter and the waveform pointer. This opens up a whole new system of channel waveform manipulation.

If we take the 7khz TIRQ interrupt, we can ‘sync’ the channel to whatever cycle in that interrupt frequency. Using the 7khz interrupt for audio generation isn’t new. I’ve used it before to create soft channels (square/triangle/etc). But the problem original was that you need to output the waveform data manually with DDA writes. You do this by tying the interrupt routine to a phase accumulator, and use the overflow bits to clock a pointer into a waveform in ram/rom. You could even add multipliers on the top bits, but this causes frequency aliasing due to sample skipping (how bad it sounds depends on the multiplier value and the desired waveform). There’s a varying amount of techniques to get around this, but they include using a waveform table with multiple re- sampled variations of the same waveform. You cut down on nyquist aliasing, but your waveform output resolution is still a bit low. That’s not to say that isn’t useful and usable, because it is. It’s just that there is now another method of doing instrument synthesis.

This new method requires the latest discoveries (to me, at least).  Looking at this example I made here, you can see some methods of providing waveform distortion over time.

The setup requires a two phase system to run off the TIMER interrupt. The first phase starts before and ends at the pink bar. The second phase starts at the pink bar and ends where phase one would start again. We can label these as P1 and P2. The frequency of the note would be 7000/P1+P2.

Looking at the different methods:

Sync+cut‘. P1 = reset waveform pointer, reset period counter, set counter length. P2 = reset waveform pointer and reset period counter, leave the channel in DDA mode, write the sample offset to DDA port, set counter length. Repeat.  By varying ratio between P1 and P2, you get a timbre control over the sound. This is the easiest of the methods. But has the side effect that the waveform gets louder as it gets sharper on some waveform types (like the one shown).

Sync+cut+frequency stepping‘. This is very similar to the above, but with the distinction of having a full waveform inside of P1. As you increase the length of P1 (and shorten P2), you decrease the period counter value of the channel. This gives a less of a sharp increase in amplitude across the timbre control. It also has the benefit of having a higher resolution sample on P1, than the above, because the whole sample is playing in P1.

Sync+reset+frequency stepping‘. A more complex version of the above. Instead of writing a single sample value for P2 length; the channel waveform and period counter is reset and a new frequency value is set to the channel. A sample is still written at the end of P1 to bring the DAC back into place. For timbre control, as the ratio of P1 and P2 lengths change so does the corresponding frequency settings of P1 and P2. In the example given, the total waveform length is actually higher resolution than what the PCE normally gives. Because you have 1/2*32+32. This form of waveform distortion is very-very close to Phase Distortion Synthesis.

Sync+frequency stepping‘. Even though this is the last example, it’s not the most complex method. Sync happens at the start of P1, but *not* on P2 – which makes it different from the rest of the methods. Instead, the only thing that happens on P2 is a frequency channel to the channel. This basically is Phase Distortion Synthesis.

And there you have it. The nice thing about these methods, is that you don’t need a large 24bit phase accumulator function on each TIRQ call. Just one 8bit counter per call(which is actually overkill), irregardless of the phase it’s in. Some of the frequency settings of 6991/P1+P2 don’t exactly line up with actual note frequencies in the upper end. Most are damn close. To solve that problem, you vary between two P1+P2 accumulations. Say, if you want P1+P2=21.5 or such. There’s no harsh stepping.

The benefit of these methods, is that you can control the sharpness/brightness/timbre of a sound over time. On a normal PCE audio channel, you really can’t (at least not without using multiple channels for doing Additive Synthesis, or less effective single channel techniques). The downside is that frequency sliding between notes, won’t have as high of resolution steps as native channels. But frequency sliding isn’t used a whole lot and the trade off is worth it. The other downside is that these methods will require lookup tables for precalculated note frequencies. I can’t say for sure how big, but nothing more than 1-2k per ‘instrument’ if you include all the timbre changes.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: