Author Topic: Sourcecode for EFx (.MOD only)  (Read 1752 times)

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 6,795
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 10 x64
Sourcecode for EFx (.MOD only)
« on: January 27, 2009, 19:41:03 »
Quote from: "Fraggie"

"Invert loop" effect replaces (!) sample data bytes within loop with their bitwise complement (NOT). The parameter sets speed of altering the samples. This effectively trashes the sample data. Because of that this effect was supposed to be removed in the very next ProTracker versions, but it actually survived until ProTracker 3.0 was never removed.

It should go something like this (called every tick)...
Code: [Select]
il_speed = parameter_of_EFx;
...
il_table = {0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128};

il_delay += il_table[il_speed];

if (current_sample_has_loop && (il_delay >= 128))
{
  il_delay = 0;

  if (++il_pos > current_sample_loop_length)
    il_pos = 0;

  current_sample_pcm[current_sample_loop_start + il_pos] = ~current_sample_pcm[current_sample_loop_start + il_pos];
}


This is EFx implementation since ProTracker 1.1A. Prior to this version this effect is called "Funk Repeat" and it moves loop of the instrument (just the loop information - sample data is not altered). The parameter is the speed of moving the loop.

It should go something like this (called every tick)...
Code: [Select]
fr_speed = parameter_of_EFx;

...

fr_table = {0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128};

fr_delay += fr_table[fr_speed];

if (current_sample_has_loop && (fr_delay >= 128))
{
  fr_delay = 0;

  current_sample_loop_start += current_sample_loop_length;

  if (current_sample_loop_start > current_sample_length)
    current_sample_loop_start = original_current_sample_loop_start;
}


As Ian mentioned, to make things more confusing ProTracker replay routines kept "Funk" label names for "Invert Loop" effect.

Both implementations work best with very short loops, so they are usable mostly for "chiptunes".

ยป No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.