erate final output */
static inline void noecho_output( struct Spc_Dsp* this, int global_muting,
    int global_vol_0, int global_vol_1, int chans_0, int chans_1, 
    int* out_0, int* out_1 )
{
    *out_0 = (chans_0 * global_vol_0) >> global_muting;
    *out_1 = (chans_1 * global_vol_1) >> global_muting;
    (void)this;
}
#endif /* SPC_DSP_GENERATE_OUTPUT */

#define mix_output(this, gm, gv0, gv1, ch0, ch1, fb_0, fb_1, o0, o1) \
    noecho_output( (this), (gm), (gv0), (gv1), (ch0), (ch1), (o0), (o1) )

#endif /* !SPC_NOECHO */


{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Rabin-Karp method\n",
    "\n",
    "If you think hard enough, there's nothing that diferrentiates piecs of text from numbers. You can think of letters as digits and base of the numbers as sufficently big to accomodate for all the digits. For example take the following text\n",
    "\n",
    "$$\n",
    "babacb\n",
    "$$\n",
    "\n",
    "it can be though of as a number base 26 (for all the english letters):\n",
    "\n",
    "$$\n",
    "(1,0,1,0,2,1)_{26}\n",
    "$$\n",
    "\n",
    "We can transform this number to base 10 using the following equation.\n",
    "\n",
    "$$\n",
    "1*26^5 + 0 * 26^4 + 1*26^3 + 0*26^2 + 2*26^1 + 1*26^0 = 11899005\n",
    "$$\n",
    "\n",
    "From the formulation above the following property should be clear.\n",
    "\n",
    "$$\n",
    "abba = abb * 26 + b\n",
    "$$\n",
    "\n",
    "in general we can write $concat(word, letter) = base * word + letter$ (1).\n",
    "\n",
    "There's also a small technicality. When we compare numbers then $0001$ and $001$ and $1$ are equivalent. This means that we cannot map any letter to 0 if we want to be able to successfuly compare the numbers. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Observation (1) allows us to quickly compute hashes for all the prefixes of a given word. Just like in class we are going to use modular arithmetic for our computations."
   ]
  },
  {
   "cell_typ