text2index

converts a text into the index-numbers (see library in the "local data", you can change this library yourself! Just make sure the amount of characters is within the array size (now it's d[128] for max 128 characters). Use a selector, pattern generator or counter to step through the text. Each character (even space!-> index 0) counts as 1 step. The counter reads the index-position within the text, converts the character into a value by comparing it to the library and outputs the index-value from that character within the library. This can be used to control presets for example. Best example would be a "talking synth" where each character stands for a preset making a distinct sound.
Author: Remco van der Most
License: BSD
Github: sss/sel/text2index.axo

Inlets

int32 count

Outlets

int32 out

Attributes

text text

Declaration
int length = strlen("attr_text");
char c[512] = ("attr_text");
char d[128] = (" aáàäâbcdeéèëêfghiíìïîjklmnoóòöôpqrstuúùüûvwxyzABCDEFGHIJKLMNOP"
               "QRSTUVWXYZ0123456789~!@#$%^&*()-=[];',./_+{}:|<>?");
int32_t V;
int i;
int32_t C;
Control Rate
C = inlet_count;
C = C - (C / length) * length;
C = C < 0 ? C + length : C;

for (i = 0; i < 128; i++) {
  if (d[i] == c[C]) {
    V = i;
  }
}
outlet_out = V;

Privacy

© 2024 Zrna Research