02.02.2013 Views

1. First steps in Reaktor Core - Native Instruments

1. First steps in Reaktor Core - Native Instruments

1. First steps in Reaktor Core - Native Instruments

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

There’s also another difference: <strong>in</strong> the analog world the tape is mov<strong>in</strong>g. If we<br />

want to move our digital tape we would need to copy all array elements to<br />

their neighbor positions at each audio clock, which is quite CPU <strong>in</strong>tensive.<br />

Instead, we will move the heads.<br />

From the preced<strong>in</strong>g, we can conclude that we will need the follow<strong>in</strong>g:<br />

array – to simulate our digital tape loop<br />

write <strong>in</strong>dex – this is our record head<br />

read <strong>in</strong>dex – this is our playback head<br />

The write and the read <strong>in</strong>dices will be mov<strong>in</strong>g through the array sample by<br />

sample. When either of them reaches the end of the array, it needs to be<br />

reset to the beg<strong>in</strong>n<strong>in</strong>g of the array (that corresponds to connect<strong>in</strong>g the open<br />

ends of the tape <strong>in</strong>to a loop). The difference between the write and the read<br />

position corresponds to the delay time measured <strong>in</strong> samples.<br />

This technique is quite common <strong>in</strong> programm<strong>in</strong>g and is called “circular<br />

buffer” or “r<strong>in</strong>g buffer”.<br />

We start by programm<strong>in</strong>g the record head. It operates similarly to the sawtooth<br />

oscillator we programmed earlier, except that the computations are done <strong>in</strong><br />

<strong>in</strong>teger mode. The value <strong>in</strong>crement is one per audio tick and the output value<br />

range is from 0 to N-1, where N is the size of the array. Let’s put the circuitry<br />

for comput<strong>in</strong>g the write <strong>in</strong>dex <strong>in</strong>to a RecordPos macro:<br />

The N <strong>in</strong>put should receive the number of elements <strong>in</strong> the array and the Pos<br />

output will carry the current writ<strong>in</strong>g position (<strong>in</strong>dex). Here is how this macro can<br />

be implemented (compare this to the sawtooth oscillator implementation):<br />

Note that the comparison module is set to >=. That was unimportant for the<br />

sawtooth oscillator, we could use >= or > there, but <strong>in</strong> <strong>in</strong>teger computations<br />

the difference is <strong>in</strong> most cases critical. Us<strong>in</strong>g >= condition ensures that the<br />

write <strong>in</strong>dex will never reach a value of N (which would be out of range).<br />

On the top-level, we create an array module and connect it to the RecordPos<br />

through the Size [] module (available <strong>in</strong> Built-In Module > Memory > Size []),<br />

which reports the size of the array:<br />

130 – REAKTOR CORE

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!