Index: apps/plugins/CATEGORIES
===================================================================
--- apps/plugins/CATEGORIES	(revision 28849)
+++ apps/plugins/CATEGORIES	(working copy)
@@ -25,6 +25,7 @@
 dict,apps
 disktidy,apps
 doom,games
+drumkit,apps
 euroconverter,apps
 fft,demos
 fire,demos
Index: apps/plugins/SOURCES
===================================================================
--- apps/plugins/SOURCES	(revision 28849)
+++ apps/plugins/SOURCES	(working copy)
@@ -4,6 +4,7 @@
 cube.c
 dict.c
 jackpot.c
+rockout.c
 keybox.c
 logo.c
 lrcplayer.c
Index: apps/plugins/SUBDIRS
===================================================================
--- apps/plugins/SUBDIRS	(revision 28849)
+++ apps/plugins/SUBDIRS	(working copy)
@@ -2,6 +2,7 @@
 shortcuts
 text_viewer
 
+
 /* For various targets... */
 
 #if CONFIG_RTC
Index: apps/plugins/rockout.c
===================================================================
--- apps/plugins/rockout.c	(revision 0)
+++ apps/plugins/rockout.c	(revision 0)
@@ -0,0 +1,4228 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ *
+ * 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ * Author: James MacLean    selectohh @ that google mail serivce . com
+ * This work is licensed under a Creative Commons Attribution-NonCommercial-
+ * ShareAlike 3.0 Unported License.
+ * http://creativecommons.org/licenses/by-nc-sa/3.0/
+ * 
+ *
+ ****************************************************************************/
+#include "plugin.h"
+#include <string.h>
+#include "stdio.h"
+#include "stdlib.h"
+#include "random.c"
+/* PLUGIN_HEADER
+PLUGIN_IRAM_DECLARE */
+#if (HW_SAMPR_CAPS & SAMPR_CAP_22)
+    #define SAMPLE_RATE SAMPR_22  
+/* 44100 22050 11025 */
+# else
+    #define SAMPLE_RATE SAMPR_44  
+/* 44100 22050 11025 */
+#endif
+#if (CONFIG_KEYPAD == SANSA_C200_PAD) 
+/* 1=up 2=down 3=left 4=right 5=select 6=vol+ 7=vol- 8=sleep 9=rec x=on/off */
+#define SAMPLE_1      BUTTON_UP
+#define SAMPLE_2      BUTTON_DOWN
+#define SAMPLE_3      BUTTON_LEFT
+#define SAMPLE_4      BUTTON_RIGHT
+#define SAMPLE_5      BUTTON_SELECT
+#define SAMPLE_6      BUTTON_VOL_DOWN
+#define SAMPLE_7      BUTTON_VOL_UP
+#define SAMPLE_8      0x00000200
+#define SAMPLE_9      BUTTON_REC 
+#define SYS_MMC_INSERTED  ((SYS_EVENT | ((long)6 << 27)))
+#define SYS_MMC_EXTRACTED ((SYS_EVENT | ((long)5 << 27)))
+#define POWER          BUTTON_POWER
+#elif (CONFIG_KEYPAD == SANSA_E200_PAD) 
+#define SAMPLE_1      BUTTON_UP
+#define SAMPLE_2      BUTTON_DOWN
+#define SAMPLE_3      BUTTON_LEFT
+#define SAMPLE_4      BUTTON_RIGHT
+#define SAMPLE_5      BUTTON_SELECT
+#define SAMPLE_6      BUTTON_SCROLL_BACK      
+#define SAMPLE_7      BUTTON_SCROLL_FWD  
+#define SAMPLE_8      0x00000200
+#define SAMPLE_9      BUTTON_REC
+#define SYS_MMC_INSERTED  ((SYS_EVENT | ((long)6 << 27)))
+#define SYS_MMC_EXTRACTED ((SYS_EVENT | ((long)5 << 27)))
+#define POWER          BUTTON_POWER
+#endif
+static int buffsize=512;
+int slowdown=0;
+int tester=0;
+int whatt=0;
+int howmanysaved=0;
+int hellocounter = 0;
+int flangedirection = 0;
+signed int flangey;
+int clearingbuffercounter = 0;
+int recordedbefore = 0;
+int firstpartofloop = 1;
+int howmanytaps;
+int volumesnapper = 0;
+int chunksize = 128;
+/*2048   this is for the longbuffer long samples */
+int changehappening[7];
+int howmuchloaded[7] IBSS_ATTR;
+int howmuchloadedjustnow[7];
+int howmuchloadederrorcheck[7];
+signed int samplespeed[7] IBSS_ATTR;
+signed int realspeed IBSS_ATTR;
+int argh = 0;
+int recisdown = 0;
+int hihatprogress;
+int savesamplehappening = 0;
+int howmuchsaved = 0;
+int howmuchsavedjustnow = 0;
+int bankno = 2;
+int kfo IBSS_ATTR;
+int glitchcounter[7];
+int jazz = 50;
+int hihats=1;
+int speedflick = 0;
+int glitch_on IBSS_ATTR;
+int firstbuffer = 0;
+int keepstereo = 0;
+int howmanydirectories = 0;
+int hundredz = 0;
+int glitchstopsending = 0;
+int jz;
+int fd;
+int holdingawhile = 0;
+int justsavednewsample = 0;
+int speedchange[7] IBSS_ATTR;
+int zaa=0;
+int firstlockdown[7];
+int thisisthenewzeropoint[7];
+int wacky;
+int shazam = 0;
+int bitcrush[7];
+int backwards[7];
+int flanger[7];
+int backwardsniblit[7];
+int volume[7] = {
+    100, 100, 100, 100, 100, 100
+}
+;
+int effecton = 0;
+/*the following is the sequencer for the glitching.  think if it as a sequence 
+of 64 beats.  think of the sample as a loopbeat. if you want (when glitching) 
+to have a kick in the first beat (which you probably do), put 0 in the first 
+area below.  this tells the sequencer to play the sample slice 0 (ie: offset 0 
+samples into the sample).  ie) the very beginning of the sample. then after the 
+comma, you are in the second part of the sequence (the second 1/16th of a beat 
+for nerdy people, or something like that) if you don't want it to play anything 
+and continue playing whatever was in the previous period, put a -1. if you want 
+an effect (see list of effects below), add that amount to the slice you want 
+(again, for the first kick, you'd want 0, and if you wanted that kick to be 
+backwards, you'd do 0 + 100 = 100.  so put 100 for a backwards kick. now do 64 
+of these and you have a full beat.  just use the format i already did, don't 
+forget the { } etc. if you want more beats than 12 just change howmanybeats = 
+xxxx and int beat[xxxx]64 to however many beats you have. */
+int howmanybeats = 12;
+/*  0+ regular, 100+ backwards, 200+ snapper, 300+ crush, 400+ rewind, 
+500+ flange, 600+ lockdown here 1000+ random (first digit, unimportant, second 
+digit, how often (higher the less often), final digit, offset) */
+int beat[12][64] = { {   /* rewind nice */
+        0, -1, 1308, -1, 0, -1, -1, -1, 8, -1, -1, -1, 0, -1,  0, -1, 
+        0, -1,  8, -1, 0, -1, -1, -1, 8, -1, -1, -1,-1, -1, -1, -1, 
+        0, -1, -1, -1, 0, -1, -1, -1, 8, -1,  0, -1, 0, -1, -1, -1, 
+        4, -1,  8, -1, 0, -1, -1, -1, 470, -1, -1, -1,-1, -1, -1, -1
+    }
+    , {                   /* knows where you are */
+        600, -1, 600, -1, 600, -1, 608, -1, 602, -1, 602, -1, 608, -1,  600, -1,  
+        600, -1, -1, -1, 608, -1, -1, -1, -1, -1, -1, -1, 600, -1,  -1, -1, 
+        600, -1, -1, -1, 608, -1, -1, -1, 608, -1, -1, -1, 616, -1,  -1, -1, 
+        616,  -1,  608, -1, 608, -1, -1, -1, 608, -1, -1, -1,600, -1, -1, -1
+    }
+    , {                 /*  randomy  */
+        0, -1, 1104, -1, 0, -1, -1, -1, 8, -1, -1, -1, -1, -1,  0, -1,  
+        1400, -1,  1408, -1, -1, -1, -1, -1, 8, -1, -1, 1111,-1, -1, -1, -1, 
+        1100, -1, -1, -1, 1100, -1, -1, -1, 8, -1,  1100, -1, 1100, -1, -1, -1, 
+        -1, -1, 1104, -1, 0, -1, -1, -1, 8, -1, -1, -1,1104, 1104, 1108, 1108
+    }
+    , {   /*   forbackforback */
+        0, -1, -1, -1, -1, -1, -1, -1, 108, -1, -1, -1, -1, -1,  -1, -1,  
+        0, -1, -1, -1, -1, -1, -1, -1, 108, -1, -1, -1, -1, -1,  -1, -1,  
+        0, -1, -1, -1, -1, -1, -1, -1, 108, -1, -1, -1, -1, -1,  -1, -1,  
+        0, -1, -1, -1, -1, -1, -1, -1, 108, -1, -1, -1, -1, -1,  -1, -1,
+    }
+    , {   /* good */
+        16, -1, -1, -1, -1, -1, 16, -1, 24, -1, -1, -1, -1, -1,  16, -1,  
+        16, -1,  16, -1, -1, -1, 16, -1, 24, -1, -1, -1,-1, -1, 0, -1, 
+        16, -1, -1, -1, 16, -1, -1, -1, 24, -1, 16, -1, 24, -1,  24, -1, 
+        -10,  -1,  16, -1, 24, -1, 16, -1, 24, -1, -1, -1,-1, -1, 116, -1
+    }
+    , {      /* choppy */
+       200, -1, 204, -1, 204, -1, 200, -1, 208, -1, 204, -1, 204, -1,  200, -1,  
+       200, -1,  200, -1, 204, -1, 200, -1, 208, -1, 204, 204,204, -1, 200, -1, 
+       200, -1, 204, -1, 200 -1, 200, 200, 208, -1, 200, -1, 208, 204,  208, -1, 
+       200,  -1,  200, -1, 208, -1, 200, -1, 208, -1, 204, -1,204, -1, 116, -1
+    }
+    , {      /* mad crazy */
+        0,  0, 0, 0, 4, 4, 4, 4, 8, 8, -1, 8, -1, 8,  0, -1,      
+        0, 1112,  308, 1108, 300, 1108, -1, 1108, 
+        208, -1, 1116, 1132,112, 1118, 12, 12, 
+        0, 0, 0, 0, 4, 4, 4, 4, 8, 108, -1, 108,12, -1, 312, -1,
+        300,  -1,  308, 1111, 300, 0, 500, 0, 8, -1, 1132, -1,432, -1, -1, -1
+    }
+    , {   /* hihatty */
+        0, 12, 12, -1, 12, -1, 12, 12, 8, -1, 12, -1, 12, -1,  0, -1,  
+        0, -1, 12, 12, 12, -1, 22, -1, 8, -1, 12, -1, 12, -1,  12, -1, 
+        0, 12, 12, 12, 12, -1, 12, -1, 8, 0, 12, -1, 416, -1,  12, -1, 
+        16,  12,  8, 12, 18, 0, 12, 0, 8, -1, 12, -1,12, -1, 12, -1
+    }
+    , {   /* normal */
+        0, -1, -1, -1, 0, -1, -1, -1, 8, -1, -1, -1, 0, -1,  0, -1,
+        0, -1,  8, -1, 0, -1, -1, -1, 8, -1, -1, -1,-1, -1, -1, -1, 
+        0, -1, -1, -1, 0, -1, -1, -1, 8, -1,  0, -1, 0, -1, -1, -1, 
+        -1, -1,  8, -1, 0, -1, -1, -1, 8, -1, -1, -1,-1, -1, -1, -1
+    }
+    , {  /* fun timestretch */
+        100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,   
+        0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7,  
+        12, -1, -1, -1, 12, -1, -1, -1, 16, -1, -1, -1, 12, -1, 0, -1, 
+        0, -1, -1, -1, 0, -1, -1, -1, 8, -1, -1, -1, 104, -1, -1, -1
+    }
+    , {   /* backwards choppy */
+        100, -1, -1, -1, -1, -1, 100, -1,108, -1, 100, -1, 100, -1, -1, -1, 
+        100, -1, -1, -1, -1, -1, -1, -1, 108, -1, -1, -1, 100, -1, -1, -1, 
+        100, -1, -1, -1, 104, -1, 100, -1, 108, -1, 108, -1, -1, -1, 100, -1, 
+        100, -1, -1, -1, 100, -1, 100, -1, 108, -1, -1, -1, 116, -1, -1, -1
+    }
+    , {    /* complete beat backwards */
+        132, -1, -1, -1, -1, -1, -1, -1,-1, -1, -1, -1, -1, -1, -1, -1, 
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 
+        132, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
+    }
+}
+;
+int effectswitch = 1;
+int echo_on = 0;
+int echoinbetween[12];
+int switchsamplehappening[7];
+int echolength = 0;
+int realprogress[7];
+int savenum;
+int remainder = 0;
+int whichsamp = 1;
+int howmanyfiles[30];
+int drumset = 0;
+int quit = 0;
+int lockdown = 0;
+int raw_file IBSS_ATTR;
+int raw_file1 IBSS_ATTR;
+int raw_file2 IBSS_ATTR;
+int raw_file3 IBSS_ATTR;
+int raw_file4 IBSS_ATTR;
+int raw_file5 IBSS_ATTR;
+int raw_file6 IBSS_ATTR;
+int raw_file7 IBSS_ATTR;
+int numberofsamplesatonce = 1;
+int speed = 1;
+int glitchsequence = 0;
+int record;
+int recposition;
+int hihatapart;
+int progress = 1;
+int whichh = 0;
+int buffersdone = 0;
+int whichbuffer = 0;
+int buttondown[7] IBSS_ATTR;
+int buttondownprogress[7] IBSS_ATTR;
+int echooo;
+short chunk[7] IBSS_ATTR;
+short megachunk[7] IBSS_ATTR;
+short *stolen_audio_buffer = NULL;
+short *stolen_audio_buffer1 = NULL;
+short *stolen_audio_buffer2 = NULL;
+short *stolen_audio_buffer3 = NULL;
+short *stolen_audio_buffer4 = NULL;
+short *stolen_audio_buffer5 = NULL;
+short *stolen_audio_buffer6 = NULL;
+short *stolen_audio_buffer7 = NULL;
+short audiobuffer1[6000] IBSS_ATTR;
+short audiobuffer2[6000] IBSS_ATTR;
+short echobuffer[40000];
+/* PUT BACK TO 6000000 */
+int echoprogress;
+int echoecho;
+int maxtimeout;
+void switchit(void) ICODE_ATTR;
+char str_buffer[255];
+char arr_filenames[25][88][128];
+/* this should be 256 if we had more memory */
+char arr_directories[30][256];
+/* tbis should be 256 */
+int length_of_samples  IBSS_ATTR;
+/* 1874944   another 3/4 is 921600 */
+int length_of_files[9] IBSS_ATTR;
+int glitchwhich[7];
+int switchmenow = 0;
+int usb_is_on = 0;
+int howfarapart = 5120;
+char *drum_dir = "/.rockbox/rocks/apps/rockout/";
+char full_dir[255];
+/* Function Prototypes */
+int rockout_main(void);
+bool find_raw_files(void);
+void change_volume(void);
+void draw_display(void);
+void rockout_draw(struct screen* display);
+void rockout_draw2(struct screen* display);
+bool is_raw_file(const char* file);
+bool is_directory(const char* file);
+int shut;
+int shut2;
+void load_to_mem(void);
+void pcm_callback(unsigned char** start, size_t* size) ICODE_ATTR;
+void initcleanbuffer(void);
+int timer[8];
+/* Plugin entry point */
+enum plugin_status plugin_start(const void* file) {
+    (void)file;
+    int retval = 0;
+    /*  PLUGIN_IRAM_INIT(rb); */
+    /* Prevent idle poweroff */
+    rb->reset_poweroff_timer();
+    stolen_audio_buffer = rb->plugin_get_audio_buffer(&shut);
+    /*30500000    steals buffer from api.  */
+    length_of_samples = 819200;
+    /*1638400;1638400;1638400;1638400;1638400;1638400;1638400;1638400;*/
+    #if defined(HAVE_ADJUSTABLE_CPU_FREQ)
+        rb->cpu_boost(true);
+    #endif
+        rb->pcm_play_stop();
+    #if INPUT_SRC_CAPS != 0
+    /* Select playback */
+    rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
+    /* Recordable targets can play back from other sources */
+    rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
+    #endif
+        rb->pcm_set_frequency(44100);
+    /* 44100 22050 11025 */
+    if (!find_raw_files()) {
+        rb->splash(200, "Dir not found");
+        return PLUGIN_OK;
+    }
+    // int j;
+    stolen_audio_buffer6 = &stolen_audio_buffer[(length_of_samples * 6)];
+    /*stolen audio buffer 6 is a container for 1) recording hihat 
+      2) another recording hihat and 3) the recording buffer. */
+    clearingbuffercounter = 0;
+    /* make the recording buffer 0 */
+    rb->snprintf(str_buffer, sizeof(str_buffer), "%s/donotdelete/hihat.wav",  
+    drum_dir);
+    /*these hihats count for you when you're recording */
+    raw_file6 = rb->open(str_buffer, O_RDONLY);
+    rb->lseek(raw_file6,  48, SEEK_SET);
+    rb->read(raw_file6, stolen_audio_buffer6, (length_of_samples));
+    length_of_files[7]=((rb->filesize(raw_file6))/2 - 560);
+    rb->snprintf(str_buffer, sizeof(str_buffer), "%s/donotdelete/hihat2.wav",  
+    drum_dir);
+    raw_file7 = rb->open(str_buffer, O_RDONLY);
+    rb->lseek(raw_file7,  48, SEEK_SET);
+    rb->read(raw_file7, stolen_audio_buffer6 + length_of_files[7], 
+    (length_of_samples));
+    length_of_files[8]=((rb->filesize(raw_file7))/2 - 560);
+    load_to_mem();
+    initcleanbuffer();
+    draw_display();
+    change_volume();
+    /* Main program loop */
+    rb->pcm_play_data(pcm_callback, NULL, 0);
+    retval = rockout_main();
+    /* Wind down */
+    rb->pcm_play_stop();
+    rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
+    #if defined(HAVE_ADJUSTABLE_CPU_FREQ)
+        rb->cpu_boost(false);
+    #endif
+        if(retval == -1)
+            return PLUGIN_ERROR;
+    return PLUGIN_OK;
+    /* End */
+}
+bool find_raw_files() {
+    DIR* dir = NULL;
+    struct dirent *entry;
+    dir = rb->opendir(drum_dir);
+    /*entry = readdir(dir);*/
+    int i = 0;
+    if(!dir)
+            return false;
+    while((entry = rb->readdir(dir)) != 0) /*CHECK FOR DIRECTORIES */{
+        struct dirinfo info = rb->dir_get_info(dir, entry);
+        if (info.attribute & ATTR_DIRECTORY) {
+            rb->strcpy(arr_directories[howmanydirectories],entry->d_name);
+            howmanydirectories++;
+        }
+    }
+    bool swapped = true;
+    /*SORT DIRECTORIES*/
+    int jzz = 0;
+    while (swapped) {
+        swapped = false;
+        jzz++;
+        int iiz;
+        for (iiz=0; (iiz < (howmanydirectories - jzz)); iiz++) {
+            if (rb->strcasecmp(arr_directories[iiz], arr_directories[iiz+1]) 
+            >= 0) {
+                rb->strcpy(arr_directories[howmanydirectories + 1], 
+                arr_directories[iiz]);
+                rb->strcpy(arr_directories[iiz], arr_directories[(iiz + 1)]);
+                rb->strcpy(arr_directories[iiz + 1], 
+                arr_directories[howmanydirectories + 1]);
+                swapped = true;
+            }
+        }
+    }
+    rb->closedir(dir);
+    int xx = 0; /* LOOK FOR AUDIO FILES IN EACH DIRECTORY */
+    for (xx = 0; xx <= howmanydirectories; xx++)  {
+        rb->snprintf(full_dir, sizeof(full_dir), "%s%s/", drum_dir, 
+        arr_directories[xx]);
+        dir = rb->opendir(full_dir);
+        i=0; /* what about when there's less than 5 files..? */
+        while((entry = rb->readdir(dir)) != 0) {
+            if (is_raw_file(entry->d_name)) {
+                /* Store the filenames in an array */
+                rb->strcpy(arr_filenames[xx][i], entry->d_name);
+                i++;
+                howmanyfiles[xx]++;
+                rb->pcm_play_stop();
+            }
+        }
+        rb->closedir(dir);
+    }
+    rb->closedir(dir);
+    dir = NULL;
+    entry = NULL;
+    i = 0;
+    int z = 0;
+    for (z = 0; z <= howmanydirectories; z++)  /*SORT FILES NOW */{
+        bool swapped = true;
+        int j = 0;
+        while (swapped) {
+            swapped = false;
+            int ii;
+            for (ii=0; (ii < (howmanyfiles[z] - j)); ii++) {
+                if (rb->strcasecmp(arr_filenames[z][ii], arr_filenames[z][ii+1]) 
+                >= 0) {
+                    rb->strcpy(arr_filenames[z][howmanyfiles[z] + 1], 
+                    arr_filenames[z][ii]);
+                    rb->strcpy(arr_filenames[z][ii], arr_filenames[z][(ii + 1)]);
+                    rb->strcpy(arr_filenames[z][ii + 1], 
+                    arr_filenames[z][howmanyfiles[z] + 1]);
+                    swapped = true;
+                }
+            }
+            j++;
+        }
+    }
+    return true;
+}
+bool is_raw_file(const char* file) {
+    char *extension = rb->strrchr(file, '.');
+    if (!rb->strcasecmp(extension, ".wav"))
+            return true; else
+            return false;
+}
+bool is_directory(const char* file) {
+    char *extension = rb->strrchr(file, '.');
+    if (!rb->strcasecmp(extension, ".")) {
+        zaa++;
+        return true;
+    } else
+            return false;
+}
+
+/* disk_buffer  buffers from the disk every so often for longer samples.  it 
+does it in "chunksize" amounts (small) so as not to freeze playback. 
+there is a voodoo trick of only loading 0 bytes on the first try (chunksize=0) 
+to avoid clicks.  don't ask */
+void disk_buffer(int j) ICODE_ATTR;
+void disk_buffer(int j)  {
+    if (j==0) {
+        rb->lseek(raw_file, (length_of_samples) + (howmuchloaded[j]) + 48, 
+        SEEK_SET);
+        rb->read(raw_file, ( &stolen_audio_buffer[(length_of_samples / 2) + 
+        (howmuchloadedjustnow[j]) ] ), chunksize);
+    } else if (j==1) {
+        rb->lseek(raw_file1, (length_of_samples) + (howmuchloaded[j])+ 48, 
+        SEEK_SET);
+        rb->read(raw_file1, (&stolen_audio_buffer1[(length_of_samples / 2) 
+        + (howmuchloadedjustnow[j]) ] ), chunksize);
+    } else if (j==2) {
+        rb->lseek(raw_file2, (length_of_samples) + (howmuchloaded[j]+ 48), 
+        SEEK_SET);
+        rb->read(raw_file2, (&stolen_audio_buffer2[(length_of_samples / 2) 
+        + (howmuchloadedjustnow[j]) ] ), chunksize);
+    } else if (j==3) {
+        rb->lseek(raw_file3, (length_of_samples) + (howmuchloaded[j]+ 48), 
+        SEEK_SET);
+        rb->read(raw_file3, (&stolen_audio_buffer3[(length_of_samples / 2) 
+        + (howmuchloadedjustnow[j]) ] ), chunksize);
+    } else if (j==4) {
+        rb->lseek(raw_file4, (length_of_samples) + (howmuchloaded[j]+ 48), 
+        SEEK_SET);
+        rb->read(raw_file4, (&stolen_audio_buffer4[(length_of_samples / 2) 
+        + (howmuchloadedjustnow[j]) ] ), chunksize);
+    } else if (j==5) {
+        rb->lseek(raw_file5, (length_of_samples) + (howmuchloaded[j]+ 48), 
+        SEEK_SET);
+        rb->read(raw_file5, (&stolen_audio_buffer5[(length_of_samples / 2) 
+        + (howmuchloadedjustnow[j]) ] ), chunksize);
+    }
+    howmuchloaded[j] = howmuchloaded[j] + chunksize;
+    howmuchloadedjustnow[j] += (chunksize / 2);
+    //}
+    chunksize = 2048;
+    if (howmuchloadedjustnow[j] >= length_of_samples / 4) {
+        if ((howmuchloadedjustnow[j] - (length_of_samples / 4)) > 0) {
+            howmuchloaded[j] -= (howmuchloadedjustnow[j] - 
+            (length_of_samples / 4));
+        }
+        howmuchloadedjustnow[j]=0;
+        changehappening[j]=0;
+        howmuchloadederrorcheck[j] += (length_of_samples/2);
+        howmuchloaded[j] = howmuchloadederrorcheck[j];
+    }
+}
+void disk_buffer2(int j) ICODE_ATTR;
+void disk_buffer2(int j) {
+    if (j==0) {
+        rb->lseek(raw_file, (length_of_samples) + (howmuchloaded[j]) + 48, 
+        SEEK_SET);
+        rb->read(raw_file, ( &stolen_audio_buffer[(length_of_samples / 2) 
+        + (length_of_samples / 4) + (howmuchloadedjustnow[j]) ] ), chunksize);
+    } else if (j==1) {
+        rb->lseek(raw_file1, (length_of_samples) + (howmuchloaded[j])+ 48, 
+        SEEK_SET);
+        rb->read(raw_file1, (&stolen_audio_buffer1[(length_of_samples / 2) 
+        + (length_of_samples / 4) + (howmuchloadedjustnow[j]) ] ), chunksize);
+    } else if (j==2) {
+        rb->lseek(raw_file2, (length_of_samples) + (howmuchloaded[j])+ 48, 
+        SEEK_SET);
+        rb->read(raw_file2, (&stolen_audio_buffer2[(length_of_samples / 2) 
+        + (length_of_samples / 4) + (howmuchloadedjustnow[j]) ] ), chunksize);
+    } else if (j==3) {
+        rb->lseek(raw_file3, (length_of_samples) + (howmuchloaded[j])+ 48, 
+        SEEK_SET);
+        rb->read(raw_file3, (&stolen_audio_buffer3[(length_of_samples / 2) 
+        + (length_of_samples / 4) + (howmuchloadedjustnow[j]) ] ), chunksize);
+    } else if (j==4) {
+        rb->lseek(raw_file4, (length_of_samples) + (howmuchloaded[j])+ 48, 
+        SEEK_SET);
+        rb->read(raw_file4, (&stolen_audio_buffer4[(length_of_samples / 2) 
+        + (length_of_samples / 4) + (howmuchloadedjustnow[j]) ] ), chunksize);
+    } else if (j==5) {
+        rb->lseek(raw_file5, (length_of_samples) + (howmuchloaded[j])+ 48, 
+        SEEK_SET);
+        rb->read(raw_file5, (&stolen_audio_buffer5[(length_of_samples / 2) 
+        + (length_of_samples / 4) + (howmuchloadedjustnow[j]) ] ), chunksize);
+    }
+    howmuchloaded[j] = howmuchloaded[j] + chunksize;
+    howmuchloadedjustnow[j] += (chunksize / 2);
+    chunksize = 2048;
+    if (howmuchloadedjustnow[j] >= length_of_samples / 4) {
+        if ((howmuchloadedjustnow[j] - (length_of_samples / 4)) > 0) {
+            howmuchloaded[j] -= (howmuchloadedjustnow[j] - 
+            (length_of_samples / 4));
+        }
+        howmuchloadedjustnow[j]=0;
+        changehappening[j]=0;
+        howmuchloadederrorcheck[j] += (length_of_samples/2);
+        howmuchloaded[j] = howmuchloadederrorcheck[j];
+    }
+}
+/* individual_saver saves recorded elements to disk, and then loads them again
+to a sample spot */
+void individual_saver(void)   {
+    chunksize=(howfarapart * 4 * 32);
+   
+    int ii = 0;
+    for (ii=0; ii < chunksize; ii++) {
+        stolen_audio_buffer6[length_of_files[7] + length_of_files[8] + 1000 
+        + ii] += (stolen_audio_buffer6[length_of_files[7] + length_of_files[8] 
+        + 1000 + ii]) >> 2;
+    }
+    rb->snprintf(str_buffer, sizeof(str_buffer), "%s%d.wav",  drum_dir, 
+    howmanysaved);
+    rb->remove(str_buffer);
+    fd = rb->open(str_buffer,O_RDWR | O_CREAT);
+    
+   
+    rb->write(fd,  &stolen_audio_buffer6[length_of_files[7] + length_of_files[8] 
+    + 1000], chunksize);
+    howmuchsavedjustnow += (chunksize / 2);
+   
+    firstbuffer = 0;
+    howmuchsavedjustnow=0;
+    savesamplehappening=0;
+    rb->close(fd);
+    justsavednewsample=1;
+    recordedbefore = 0;
+    switchsamplehappening[howmanysaved] = 1;
+    howmanysaved++;
+    if (howmanysaved>6) {
+        howmanysaved = 0;
+    }
+    clearingbuffercounter = 0;
+    recposition = 0;
+    record=0;
+    		   
+}
+
+/* this is the(buffering system) to change samples, when you want to load a 
+new sample.  again, in small chunks, to avoid cutting off playback. */ 
+void individual_changer(int j){
+    chunksize=2048;
+    /*it also restarts playback of sample when it's done, which i kind of hate 
+    and should change. */
+    if (firstbuffer==0) {
+        firstbuffer=1;
+        howmuchloaded[j]=48;
+        howmuchloadedjustnow[j]=0;
+        if (whichsamp >= howmanyfiles[bankno]) {
+            whichsamp = 1;
+        }
+        if (justsavednewsample==0) {
+            rb->snprintf(str_buffer, sizeof(str_buffer), "%s%s/%s",
+           drum_dir, arr_directories[bankno], arr_filenames[bankno][whichsamp]);
+        }
+        justsavednewsample=0;
+        if (j==0) {
+            rb->close(raw_file);
+            raw_file = rb->open(str_buffer, O_RDONLY);
+            length_of_files[1]=((rb->filesize(raw_file))/2 - 560);
+        }
+        if (j==1) {
+            rb->close(raw_file1);
+            raw_file1 = rb->open(str_buffer, O_RDONLY);
+            length_of_files[2]=((rb->filesize(raw_file1))/2 - 560);
+        }
+        if (j==2) {
+            rb->close(raw_file2);
+            raw_file2 = rb->open(str_buffer, O_RDONLY);
+            length_of_files[3]=((rb->filesize(raw_file2))/2 - 560);
+        }
+        if (j==3) {
+            rb->close(raw_file3);
+            raw_file3 = rb->open(str_buffer, O_RDONLY);
+            length_of_files[4]=((rb->filesize(raw_file3))/2 - 560);
+        }
+        if (j==4) {
+            rb->close(raw_file4);
+            raw_file4 = rb->open(str_buffer, O_RDONLY);
+            length_of_files[5]=((rb->filesize(raw_file4))/2 - 560);
+        }
+        if (j==5) {
+            rb->close(raw_file5);
+            raw_file5 = rb->open(str_buffer, O_RDONLY);
+            length_of_files[6]=((rb->filesize(raw_file5))/2 - 560);
+        }
+    }
+    if (j==0) {
+        rb->lseek(raw_file, (howmuchloaded[j]), SEEK_SET);
+        rb->read(raw_file, ( &stolen_audio_buffer[howmuchloadedjustnow[j]] ), chunksize);
+    }
+    if (j==1) {
+        rb->lseek(raw_file1, (howmuchloaded[j]), SEEK_SET);
+        rb->read(raw_file1, (&stolen_audio_buffer1[howmuchloadedjustnow[j]] ), chunksize);
+    }
+    if (j==2) {
+        rb->lseek(raw_file2, (howmuchloaded[j]), SEEK_SET);
+        rb->read(raw_file2, (&stolen_audio_buffer2[howmuchloadedjustnow[j]] ), chunksize);
+    }
+    if (j==3) {
+        rb->lseek(raw_file3, (howmuchloaded[j]), SEEK_SET);
+        rb->read(raw_file3, (&stolen_audio_buffer3[howmuchloadedjustnow[j]] ), chunksize);
+    }
+    if (j==4) {
+        rb->lseek(raw_file4, (howmuchloaded[j]), SEEK_SET);
+        rb->read(raw_file4, (&stolen_audio_buffer4[howmuchloadedjustnow[j]] ), chunksize);
+    }
+    if (j==5) {
+        rb->lseek(raw_file5, (howmuchloaded[j]), SEEK_SET);
+        rb->read(raw_file5, (&stolen_audio_buffer5[howmuchloadedjustnow[j]] ), chunksize);
+    }
+    howmuchloadedjustnow[j] += (chunksize / 2);
+    howmuchloaded[j] += (chunksize) ;
+    if (howmuchloadedjustnow[j] >= (length_of_samples / 2)) {
+        whichsamp++;
+        firstbuffer = 0;
+        howmuchloadedjustnow[j]=0;
+        switchsamplehappening[j]=0;
+        buttondown[j]=1;
+        buttondownprogress[j+1]=0;
+    }
+}
+/* load_to_mem loads the samples at bootup of the sampler */
+void load_to_mem(void)  {
+    int j;
+    stolen_audio_buffer1 = &stolen_audio_buffer[(length_of_samples)];
+    stolen_audio_buffer2 = &stolen_audio_buffer[(length_of_samples * 2)];
+    stolen_audio_buffer3 = &stolen_audio_buffer[(length_of_samples * 3)];
+    stolen_audio_buffer4 = &stolen_audio_buffer[(length_of_samples * 4)];
+    stolen_audio_buffer5 = &stolen_audio_buffer[(length_of_samples * 5)];
+    for (j = 0; j < (7); j++) {
+        rb->snprintf(str_buffer, sizeof(str_buffer), "%s%s/%s",
+                    drum_dir, arr_directories[bankno], arr_filenames[bankno][j 
+                    + 2]);
+        if (j==0) {
+            raw_file = rb->open(str_buffer, O_RDONLY);
+            rb->lseek(raw_file, 48, SEEK_SET);
+            rb->read(raw_file, stolen_audio_buffer, (length_of_samples));
+            length_of_files[1]=((rb->filesize(raw_file))/2 - 560);
+        }
+        if (j==1) {
+            raw_file1 = rb->open(str_buffer, O_RDONLY);
+            rb->lseek(raw_file1,  48, SEEK_SET);
+            rb->read(raw_file1, stolen_audio_buffer1, (length_of_samples));
+            length_of_files[2]=((rb->filesize(raw_file1))/2 - 560);
+        }
+        if (j==2) {
+            raw_file2 = rb->open(str_buffer, O_RDONLY);
+            rb->lseek(raw_file2, 48, SEEK_SET);
+            rb->read(raw_file2, stolen_audio_buffer2, (length_of_samples));
+            length_of_files[3]=((rb->filesize(raw_file2))/2 - 560);
+        }
+        if (j==3) {
+            raw_file3 = rb->open(str_buffer, O_RDONLY);
+            rb->lseek(raw_file3,  48, SEEK_SET);
+            rb->read(raw_file3, stolen_audio_buffer3, (length_of_samples));
+            length_of_files[4]=((rb->filesize(raw_file3))/2 - 560);
+        }
+        if (j==4) {
+            raw_file4 = rb->open(str_buffer, O_RDONLY);
+            rb->lseek(raw_file4,  48, SEEK_SET);
+            rb->read(raw_file4, stolen_audio_buffer4, (length_of_samples));
+            length_of_files[5]=((rb->filesize(raw_file4))/2 - 560);
+        }
+        if (j==5) {
+            raw_file5 = rb->open(str_buffer, O_RDONLY);
+            rb->lseek(raw_file5,  48, SEEK_SET);
+            rb->read(raw_file5, stolen_audio_buffer5, (length_of_samples));
+            length_of_files[6]=((rb->filesize(raw_file5))/2 - 560);
+        }
+        if (j==6) {
+        }
+        whichsamp += 6;
+        if (whichsamp >= howmanyfiles[bankno]) {
+            whichsamp = 1;
+        }
+    }
+}
+void tapthetempo(void) {
+    clearingbuffercounter = 0;
+    recposition = 0;
+    if (echolength<80000) {
+        echoinbetween[howmanytaps]=echolength;
+        echolength = 0;
+        howmanytaps++;
+        int i;
+        howfarapart = 0;
+        for (i = 0; i < howmanytaps; i++) {
+            howfarapart += echoinbetween[i];
+        }
+        howfarapart = howfarapart / howmanytaps;
+        howfarapart = howfarapart / 8;
+    } else if (echolength>80000) {
+        int i;
+        for (i = 0; i < howmanytaps; i++) {
+            echoinbetween[i] = 0;
+        }
+        howmanytaps=0;
+    }
+    echolength = 0;
+}
+void initcleanbuffer(void) {
+    int j;
+    for (j = 0; j < 510; j++) {
+        audiobuffer1[j] = 0;
+    }
+    for (j = 510; j < 1020; j++) {
+        audiobuffer2[j-510] = 0;
+    }
+}
+void nofx(void) ICODE_ATTR;
+void nofx(void) {
+    /*this makes sure everthing is off (effects etc) */
+    speedflick=0;
+    speedchange[0]=0;
+    speedchange[1]=0;
+    speedchange[2]=0;
+    speedchange[3]=0;
+    speedchange[4]=0;
+    speedchange[5]=0;
+    speedchange[6]=0;
+    realspeed=0;
+    volumesnapper=0;
+    flanger[0]=0;
+    flanger[1]=0;
+    flanger[2]=0;
+    flanger[3]=0;
+    flanger[4]=0;
+    flanger[5]=0;
+    flanger[6]=0;
+    backwardsniblit[0]=0;
+    backwardsniblit[1]=0;
+    backwardsniblit[2]=0;
+    backwardsniblit[3]=0;
+    backwardsniblit[4]=0;
+    backwardsniblit[5]=0;
+    backwardsniblit[6]=0;
+    backwards[0]=0;
+    backwards[1]=0;
+    backwards[2]=0;
+    backwards[3]=0;
+    backwards[4]=0;
+    backwards[5]=0;
+    backwards[6]=0;
+    bitcrush[0]=0;
+    bitcrush[1]=0;
+    bitcrush[2]=0;
+    bitcrush[3]=0;
+    bitcrush[4]=0;
+    bitcrush[5]=0;
+    bitcrush[6]=0;
+    volume[0]=100;
+    volume[1]=100;
+    volume[2]=100;
+    volume[3]=100;
+    volume[4]=100;
+    volume[5]=100;
+    volume[6]=100;
+}
+/* this is my drum and bass rewind shazzle.  or part of it.  its mostly in 
+the playback part and not here */
+void reewind(int i) {
+    speedchange[i] = 1;
+    speedflick = 1;
+    realspeed = 25;
+    backwards[i]=1;
+    samplespeed[i] = realspeed;
+}
+void glitchtime(int i) ICODE_ATTR;
+void glitchtime(int i) {
+    /*this is the glitch sequencer.  
+    draw_display2();
+    int wacky = rand() % 2;
+    int wackyultimate = rand() % 500;
+    rb->splash(HZ, "hello"); */
+    if ((chunk[i]==0) && (glitchwhich[i]==1)) {
+        if (beat[glitchsequence][megachunk[i]] >= 1000) {
+            /* RANDOM OFTENNESS, SPECIFIC SAMPLE CHUNK */
+            hundredz = ( beat[glitchsequence][megachunk[i]] - 1000 ) / 100;
+            wacky = rand() % (hundredz + 1);
+            /* do something once every x times, x being 1x00  */
+            if (wacky == 1) {
+                buttondownprogress[i]=((beat[glitchsequence][megachunk[i]] 
+                - 1000 - (hundredz * 100)) * howfarapart);
+            }
+        } else if (beat[glitchsequence][megachunk[i]] >= 600) {
+            /* FLANGE */
+            if (firstlockdown[i]==0) {
+                thisisthenewzeropoint[i] = buttondownprogress[i];
+                firstlockdown[i]=1;
+            }
+            buttondownprogress[i]=((beat[glitchsequence][megachunk[i]] - 600) 
+            * howfarapart) + thisisthenewzeropoint[i];
+        } else if (beat[glitchsequence][megachunk[i]] >= 500) {
+            /* FLANGE */
+            flanger[i]=1;
+            /* buttondownprogress[i]=((beat[glitchsequence][megachunk[i]] - 500)
+            * howfarapart);*/
+        } else  if (beat[glitchsequence][megachunk[i]] >= 400) {
+            /* SELECTAH REWIND */
+            reewind(i);
+            buttondownprogress[i]=((beat[glitchsequence][megachunk[i]] - 400) 
+            * howfarapart);
+        } else if (beat[glitchsequence][megachunk[i]] >= 300) {
+            /* BITCRUSH */
+            nofx();
+            bitcrush[i]=1;
+            buttondownprogress[i]=((beat[glitchsequence][megachunk[i]] - 300) 
+            * howfarapart);
+        } else if (beat[glitchsequence][megachunk[i]] >= 200) {
+            /* VOLUME SNAPPER */
+            nofx();
+            volumesnapper=1;
+            volume[i]=100;
+            buttondownprogress[i]=((beat[glitchsequence][megachunk[i]] - 200) 
+            * howfarapart);
+        } else  if (beat[glitchsequence][megachunk[i]] >= 100){ 
+           /* BACKWARDS */
+            nofx();
+            backwards[i]=1;
+            buttondownprogress[i]=((beat[glitchsequence][megachunk[i]] - 100) 
+            * howfarapart);
+            buttondownprogress[i]+=13000;
+        } else if (beat[glitchsequence][megachunk[i]] != -1){ 
+        /* regular (forwards) */
+            nofx();
+            buttondownprogress[i]=(beat[glitchsequence][megachunk[i]] 
+            * howfarapart);
+        }
+        if (volumesnapper==1) {
+            volume[i]=100;
+            if (beat[glitchsequence][megachunk[i]] == -1) {
+                volume[i]=0;
+            }
+        }
+    }
+    /*only runs for glitchon[i]*/
+    if (buttondown[i]==0) {
+        backwards[i]=0;
+        flanger[i]=0;
+        backwardsniblit[i]=0;
+        glitchwhich[i]=0;
+    }
+    /*cleanup so won't reglitch*/
+}
+void pcm_callback(unsigned char** start, size_t* size) ICODE_ATTR;
+void pcm_callback(unsigned char** start, size_t* size) {
+    /*this is the main callback (playback).  */
+    
+    if (progress == buffsize) {
+        switchmenow = 1;
+    }
+    if (progress > ((buffsize * 2) - 2)) {
+        if (whichbuffer == 0) {
+            whichbuffer = 1;
+            progress = 0;
+        }
+    }
+    if (progress > ((buffsize * 2) - 2)) {
+        if (whichbuffer == 1) {
+            whichbuffer = 0;
+            progress = 0;
+        }
+    }
+    if (whichbuffer == 0) {
+        *start = &audiobuffer1[progress/2];
+    }
+    if (whichbuffer == 1) {
+        *start = &audiobuffer2[progress/2];
+    }
+    *size = buffsize;
+    progress = progress + buffsize;
+}
+void change_volume(void) {
+    /*i don't think this is called or it doesn't work or something*/
+    int vol = rb->global_settings->volume;
+    vol++;
+    vol++;
+    vol++;
+    vol++;
+    vol++;
+    rb->global_settings->volume = vol;
+    rb->sound_set(SOUND_VOLUME, vol);
+}
+void change_volumeback(void) {
+    /*same as above*/
+    int vol = rb->global_settings->volume;
+    vol--;
+    vol--;
+    vol--;
+    vol--;
+    vol--;
+    rb->global_settings->volume = vol;
+    rb->sound_set(SOUND_VOLUME, vol);
+}
+void draw_display(void) {
+    int i;
+    FOR_NB_SCREENS(i)
+            rockout_draw(rb->screens[i]);
+}
+void draw_display2(void) {
+    int i;
+    FOR_NB_SCREENS(i)
+            rockout_draw2(rb->screens[i]);
+}
+void rockout_draw2(struct screen* display) {
+    display->clear_display();
+    display->puts(0, 0, "rockout");
+    rb->snprintf(str_buffer, sizeof(str_buffer), "tester: %d     %d", wacky, 
+    hundredz);
+    display->puts(0, 2, str_buffer);
+    display->update();
+}
+void rockout_draw(struct screen* display) {
+    display->clear_display();
+    display->puts(0, 0, "_rockout_");
+    rb->snprintf(str_buffer, sizeof(str_buffer), "BANK: %s", 
+    arr_directories[bankno]);
+    display->puts(0, 1, str_buffer);
+    display->puts(0, 3, "POWER + SEL + REC: quit");
+    display->puts(0, 4, "U/D/L/R/SEL/VOLDOWN: samples 1-6");
+    display->puts(0, 5, "POWER: record on/off");
+    display->puts(0, 6, "POWER + REC: save recorded loop");
+    display->puts(0, 7, "hold REC: clear record buffer");
+    display->puts(0, 8, "hold sample + tap POWER: tap tempo");
+    display->puts(0, 9, "hold sample + REC: glitch sample");
+    display->puts(0, 10, "REC: change glitch pattern");
+    display->puts(0, 11, "VOL UP: change sample folder");
+    display->puts(0, 12, "hold sample + VOL UP: change sample");
+    display->puts(0, 13, "REC + VOLUP: effect mode (echo, glitchmode)");
+    display->update();
+}
+/*int rockout_main() ICODE_ATTR;*/
+int rockout_main() {
+    while(!quit) {
+        rb->yield();
+        switch(rb->button_get(false)) {
+            case SAMPLE_1: {
+                buttondownprogress[1]=0;
+                timer[1]= 0;
+                buttondown[1]=1;
+                break;
+            }
+            case SAMPLE_1 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                break;
+            }
+            case SAMPLE_1 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondownprogress[1]=0;
+                break;
+            }
+            case SAMPLE_2: {
+                buttondownprogress[2]=0;
+                timer[2]= 0;
+                buttondown[2]=1;
+                break;
+            }
+            case SAMPLE_2 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                break;
+            }
+            case SAMPLE_2 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondownprogress[2]=0;
+                break;
+            }
+            case SAMPLE_3: {
+                buttondownprogress[3]=0;
+                timer[3]= 0;
+                buttondown[3]=1;
+                break;
+            }
+            case SAMPLE_3 | BUTTON_REPEAT: {
+                timer[3]= 0;
+                break;
+            }
+            case SAMPLE_3 | BUTTON_REL: {
+                buttondown[3]=0;
+                buttondownprogress[3]=0;
+                break;
+            }
+            case SAMPLE_4: {
+                buttondownprogress[4]=0;
+                timer[4]= 0;
+                buttondown[4]=1;
+                break;
+            }
+            case SAMPLE_4 | BUTTON_REPEAT: {
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_4 | BUTTON_REL: {
+                buttondown[4]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_5: {
+                buttondownprogress[5]=0;
+                timer[5]= 0;
+                buttondown[5]=1;
+                break;
+            }
+            case SAMPLE_5 | BUTTON_REPEAT: {
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_5 | BUTTON_REL: {
+                buttondown[5]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_6: {
+                buttondownprogress[6]=0;
+                timer[6]= 0;
+                buttondown[6]=1;
+                break;
+            }
+            case SAMPLE_6 | BUTTON_REPEAT: {
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_6 | BUTTON_REL: {
+                buttondown[6]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            /*doubles*/
+            case SAMPLE_1 | SAMPLE_2: {
+                timer[1]= 0;
+                timer[2]= 0;
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3: {
+                timer[1]= 0;
+                timer[3]= 0;
+                buttondown[1]=1;
+                buttondown[3]=1;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[3]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[3]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_4: {
+                timer[1]= 0;
+                timer[4]= 0;
+                buttondown[1]=1;
+                buttondown[4]=1;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_4 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_4 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[4]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_5: {
+                timer[1]= 0;
+                timer[5]= 0;
+                buttondown[1]=1;
+                buttondown[5]=1;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_6: {
+                timer[1]= 0;
+                timer[6]= 0;
+                buttondown[1]=1;
+                buttondown[6]=1;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[6]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3: {
+                timer[2]= 0;
+                timer[3]= 0;
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondownprogress[1]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[3]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4: {
+                timer[2]= 0;
+                timer[4]= 0;
+                buttondown[2]=1;
+                buttondown[4]=1;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[4]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_5: {
+                timer[2]= 0;
+                timer[5]= 0;
+                buttondown[2]=1;
+                buttondown[5]=1;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[5]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_6: {
+                timer[2]= 0;
+                timer[6]= 0;
+                buttondown[2]=1;
+                buttondown[6]=1;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[6]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4: {
+                timer[3]= 0;
+                timer[4]= 0;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | BUTTON_REPEAT: {
+                timer[3]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | BUTTON_REL: {
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_5: {
+                timer[3]= 0;
+                timer[5]= 0;
+                buttondown[3]=1;
+                buttondown[5]=1;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[3]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[3]=0;
+                buttondown[5]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_6: {
+                timer[3]= 0;
+                timer[6]= 0;
+                buttondown[3]=1;
+                buttondown[6]=1;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[3]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[3]=0;
+                buttondown[6]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_5: {
+                timer[4]= 0;
+                timer[5]= 0;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_6: {
+                timer[4]= 0;
+                timer[6]= 0;
+                buttondown[4]=1;
+                buttondown[6]=1;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[4]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[4]=0;
+                buttondown[6]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            case SAMPLE_5 | SAMPLE_6: {
+                timer[5]= 0;
+                timer[6]= 0;
+                buttondown[5]=1;
+                buttondown[6]=1;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                break;
+            }
+            case SAMPLE_5 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[5]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_5 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[5]=0;
+                buttondown[6]=0;
+                buttondownprogress[5]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            //triples
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[3]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[4]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[4]= 0;
+                buttondownprogress[3]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[4]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_5: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[5]= 0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_6: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[6]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[6]= 0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[6]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4: {
+                buttondown[1]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                buttondownprogress[2]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_5: {
+                buttondown[1]=1;
+                buttondown[3]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[5]= 0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[3]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_6: {
+                buttondown[1]=1;
+                buttondown[3]=1;
+                buttondown[6]=1;
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[6]= 0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[3]=0;
+                buttondown[6]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_4 | SAMPLE_5: {
+                buttondown[1]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_4 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_4 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_4 | SAMPLE_6: {
+                buttondown[1]=1;
+                buttondown[4]=1;
+                buttondown[6]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_4 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[4]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_4 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[4]=0;
+                buttondown[6]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4: {
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                buttondownprogress[1]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_5: {
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[5]=1;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[5]= 0;
+                buttondownprogress[1]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[5]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_6: {
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[6]=1;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[6]= 0;
+                buttondownprogress[1]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[6]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | SAMPLE_5: {
+                buttondown[2]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[2]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | SAMPLE_6: {
+                buttondown[2]=1;
+                buttondown[4]=1;
+                buttondown[6]=1;
+                timer[2]= 0;
+                timer[4]= 0;
+                timer[6]= 0;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[4]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[4]=0;
+                buttondown[6]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | SAMPLE_5: {
+                buttondown[3]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | SAMPLE_6: {
+                buttondown[3]=1;
+                buttondown[4]=1;
+                buttondown[6]=1;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[6]= 0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondown[6]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            //fours
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_5: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[5]= 0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_6: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[6]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[6]= 0;
+                buttondownprogress[4]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[6]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5: {
+                buttondown[1]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                buttondownprogress[2]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | SAMPLE_6: {
+                buttondown[1]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                buttondown[6]=1;
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[6]= 0;
+                buttondownprogress[2]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondown[6]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5: {
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                buttondownprogress[1]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_6: {
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                buttondown[6]=1;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[6]= 0;
+                buttondownprogress[1]=0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondown[6]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | SAMPLE_5: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                buttondownprogress[3]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | SAMPLE_5 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | SAMPLE_6: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[4]=1;
+                buttondown[6]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[4]= 0;
+                timer[6]= 0;
+                buttondownprogress[3]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[4]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | SAMPLE_6 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[4]=0;
+                buttondown[6]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 
+            | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5  
+            | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 
+            | SAMPLE_6: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                buttondown[6]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5  
+            | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 
+            | SAMPLE_6 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondown[6]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                buttondownprogress[6]=0;
+                break;
+            }
+            /*now, everything again with backwards */
+            case SAMPLE_9 : {
+                recisdown=1;
+                glitchsequence++;
+                if (glitchsequence >= howmanybeats) {
+                    glitchsequence = 0;
+                }
+                break;
+            }
+            case SAMPLE_9 | BUTTON_REPEAT: {   /*record clear erase */
+                recisdown=1;
+                holdingawhile++;
+                if (holdingawhile > 13) {
+                    clearingbuffercounter=0;
+                    recposition = 0;
+                    holdingawhile = 0;
+                    glitchsequence--;
+                }
+                /*if he's holdng a while record, clear delete erase 
+                the recording loop.  */
+                break;
+            }
+            case SAMPLE_9 | BUTTON_REL: {
+                recisdown=0;
+                if (timer[7]<10000) {
+                }
+                /*this is so the e200 cna use SAMPLE_9 | REC together 
+                (scroll wheel probz) */
+                else {
+                }
+                effecton = 0;
+                for (jz = 1; jz < 6; jz++) {
+                    backwards[jz]=0;
+                    backwardsniblit[jz]=0;
+                }
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9: {
+                timer[1]= 0;
+                buttondown[1]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9| BUTTON_REPEAT: {
+                timer[1]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondownprogress[1]=0;
+                effecton = 0;
+                for (jz = 1; jz < 6; jz++) {
+                    backwards[jz]=0;
+                    backwardsniblit[jz]=0;
+                }
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_9: {
+                timer[2]= 0;
+                buttondown[2]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondownprogress[2]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_9: {
+                timer[3]= 0;
+                buttondown[3]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[3]= 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[3]=0;
+                buttondownprogress[3]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_9: {
+                timer[4]= 0;
+                buttondown[4]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[4]=0;
+                buttondownprogress[4]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_5 | SAMPLE_9: {
+                timer[5]= 0;
+                buttondown[5]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_5 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_5 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[5]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_6 | SAMPLE_9: {
+                timer[6]= 0;
+                buttondown[6]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_6 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_6 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[6]=0;
+                buttondownprogress[6]=0;
+                effecton = 0;
+                break;
+            }
+            //doubles
+            case SAMPLE_1 | SAMPLE_9 | SAMPLE_2: {
+                timer[1]= 0;
+                timer[2]= 0;
+                buttondown[1]=1;
+                buttondown[2]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9 | SAMPLE_2 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9 | SAMPLE_2 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9 | SAMPLE_3: {
+                timer[1]= 0;
+                timer[3]= 0;
+                buttondown[1]=1;
+                buttondown[3]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9 | SAMPLE_3 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[3]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9 | SAMPLE_3 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[3]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9 | SAMPLE_4: {
+                timer[1]= 0;
+                timer[4]= 0;
+                buttondown[1]=1;
+                buttondown[4]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9 | SAMPLE_4 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9 | SAMPLE_4 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[4]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[4]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9 | SAMPLE_5: {
+                timer[1]= 0;
+                timer[5]= 0;
+                buttondown[1]=1;
+                buttondown[5]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9 | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_5  | SAMPLE_9| BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9 | SAMPLE_6: {
+                timer[1]= 0;
+                timer[6]= 0;
+                buttondown[1]=1;
+                buttondown[6]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_9 | SAMPLE_6 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_6  | SAMPLE_9| BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[6]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[6]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_9: {
+                timer[2]= 0;
+                timer[3]= 0;
+                buttondown[2]=1;
+                buttondown[3]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[3]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | SAMPLE_9: {
+                timer[2]= 0;
+                timer[4]= 0;
+                buttondown[2]=1;
+                buttondown[4]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[4]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_5 | SAMPLE_9: {
+                timer[2]= 0;
+                timer[5]= 0;
+                buttondown[2]=1;
+                buttondown[5]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_5 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_5 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[5]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_6 | SAMPLE_9: {
+                timer[2]= 0;
+                timer[6]= 0;
+                buttondown[2]=1;
+                buttondown[6]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_6 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_6 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[6]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[6]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | SAMPLE_9: {
+                timer[3]= 0;
+                timer[4]= 0;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[3]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_5 | SAMPLE_9: {
+                timer[3]= 0;
+                timer[5]= 0;
+                buttondown[3]=1;
+                buttondown[5]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_5 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[3]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_5 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[3]=0;
+                buttondown[5]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_6 | SAMPLE_9: {
+                timer[3]= 0;
+                timer[6]= 0;
+                buttondown[3]=1;
+                buttondown[6]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_6 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[3]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_6 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[3]=0;
+                buttondown[6]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[6]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_5 | SAMPLE_9: {
+                timer[4]= 0;
+                timer[5]= 0;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_5 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_5 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_6 | SAMPLE_9: {
+                timer[4]= 0;
+                timer[6]= 0;
+                buttondown[4]=1;
+                buttondown[6]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_6 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[4]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_4 | SAMPLE_6 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[4]=0;
+                buttondown[6]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[6]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_5 | SAMPLE_6 | SAMPLE_9: {
+                timer[5]= 0;
+                timer[6]= 0;
+                buttondown[5]=1;
+                buttondown[6]=1;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_5 | SAMPLE_6 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[5]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_5 | SAMPLE_6 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[5]=0;
+                buttondown[6]=0;
+                buttondownprogress[5]=0;
+                buttondownprogress[6]=0;
+                effecton = 0;
+                break;
+            }
+            //triples
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_9: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[3]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | SAMPLE_9: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[4]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[4]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[4]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_5 | SAMPLE_9: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[5]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_5 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_5 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_6 | SAMPLE_9: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[6]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[6]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_6 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[6]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_6 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[6]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[6]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | SAMPLE_9: {
+                buttondown[1]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_5 | SAMPLE_9: {
+                buttondown[1]=1;
+                buttondown[3]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[5]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_5 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_5 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[3]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9: {
+                buttondown[1]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_9: {
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_5 | SAMPLE_9: {
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[5]=1;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[5]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_5 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_5 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[5]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9: {
+                buttondown[2]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[2]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9: {
+                buttondown[3]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9 | BUTTON_REL: {
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            //fours
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_9: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_9 
+            | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_9 
+            | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_5 | SAMPLE_9: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[5]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_5 | SAMPLE_9 
+            | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_5 | SAMPLE_9 
+            | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9: {
+                buttondown[1]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9 
+            | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9 
+            | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9: {
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9 
+            | BUTTON_REPEAT: {
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9 
+            | BUTTON_REL: {
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | SAMPLE_5 | SAMPLE_9 
+            | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_4 | SAMPLE_5  | SAMPLE_9 
+            | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 
+            | SAMPLE_9: {
+                buttondown[1]=1;
+                buttondown[2]=1;
+                buttondown[3]=1;
+                buttondown[4]=1;
+                buttondown[5]=1;
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                effecton = 1;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 
+            | SAMPLE_9 | BUTTON_REPEAT: {
+                timer[1]= 0;
+                timer[2]= 0;
+                timer[3]= 0;
+                timer[4]= 0;
+                timer[5]= 0;
+                break;
+            }
+            case SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4 | SAMPLE_5 
+            | SAMPLE_9 | BUTTON_REL: {
+                buttondown[1]=0;
+                buttondown[2]=0;
+                buttondown[3]=0;
+                buttondown[4]=0;
+                buttondown[5]=0;
+                buttondownprogress[1]=0;
+                buttondownprogress[2]=0;
+                buttondownprogress[3]=0;
+                buttondownprogress[4]=0;
+                buttondownprogress[5]=0;
+                effecton = 0;
+                break;
+            }
+            case SAMPLE_7 | SAMPLE_1: {
+                switchsamplehappening[0] = 1;
+                break;
+            }
+            case SAMPLE_7 | SAMPLE_2: {
+                switchsamplehappening[1] = 1;
+                break;
+            }
+            case SAMPLE_7 | SAMPLE_3: {
+                switchsamplehappening[2] = 1;
+                break;
+            }
+            case SAMPLE_7 | SAMPLE_4: {
+                switchsamplehappening[3] = 1;
+                break;
+            }
+            case SAMPLE_7 | SAMPLE_5: {
+                switchsamplehappening[4] = 1;
+                break;
+            }
+            case SAMPLE_7 | SAMPLE_6: {
+                switchsamplehappening[5] = 1;
+                break;
+            }
+            case SAMPLE_9 | SAMPLE_7: {
+                effectswitch++;
+                if (effectswitch >= 5) {
+                    effectswitch = 1;
+                }
+                break;
+            }
+           
+           
+            case SYS_USB_CONNECTED: {
+                /*return PLUGIN_USB_CONNECTED; */
+                usb_is_on = 1;
+                /* SYS_USB_DISCONNECTED; */
+                if (usb_is_on == 1) {
+                    rb->usb_acknowledge(SYS_USB_CONNECTED_ACK);
+                }
+                break;
+            }
+            case SYS_USB_DISCONNECTED: {
+                int shzz;
+                rb->usb_acknowledge(SYS_USB_DISCONNECTED_ACK);
+                usb_is_on = 0;
+                stolen_audio_buffer = rb->plugin_get_audio_buffer(&shzz);
+                load_to_mem();
+                initcleanbuffer();
+                rb->pcm_play_data(pcm_callback, NULL, 0);
+                /*start the playback */
+                rockout_main();
+                break;
+            }
+            /**                case SYS_MMC_INSERTED:
+                 {
+                   buttondownprogress[2]=0;
+                     buttondown[2]=1;
+                    break;
+                 }
+                    case SYS_MMC_EXTRACTED:
+                 {
+                   buttondownprogress[2]=0;
+                     buttondown[2]=1;
+                    break;
+                 }
+    **/     /*this is just for e200 so it can use scroll wheel with 
+              another button.  for some reason it doesn't recognize both being 
+              buttondowns. */
+            case SAMPLE_7:   {
+                timer[7]=0;
+                if (recisdown == 1) {
+                    if (timer[7]<10000) {
+                        effectswitch++;
+                        glitchsequence--;
+                        if (effectswitch >= 5) {
+                            effectswitch = 1;
+                        }
+                        break;
+                    }
+                    /*this is so the e200 cna use SAMPLE_9 | REC together 
+                    (scroll wheel probz) */
+                } else {
+                    if (timer[1]<10000) {
+                        switchsamplehappening[0] = 1;
+                    } else if (timer[2]<10000) {
+                        switchsamplehappening[1] = 1;
+                    } else if (timer[3]<10000) {
+                        switchsamplehappening[2] = 1;
+                    } else if (timer[4]<10000) {
+                        switchsamplehappening[3] = 1;
+                    } else if (timer[5]<10000) {
+                        switchsamplehappening[4] = 1;
+                    } else if (timer[6]<10000) {
+                        switchsamplehappening[5] = 1;
+                    } else {
+                        if (bankno >= (howmanydirectories - 1)) {
+                            bankno = 1;
+                        }
+                        /*bank 0 and 1 are . and .. i think */                 
+                        whichsamp = 1;
+                        bankno++;
+                        draw_display();
+                        int jz;
+                        for (jz = 0; jz < 6; jz++) {
+                            switchsamplehappening[jz] = 1;
+                        }
+                    }
+                }
+                break;
+            }
+            case SAMPLE_7 | BUTTON_REPEAT: {
+                timer[7]=0;
+                break;
+            }
+            case SAMPLE_7 | BUTTON_REL: {
+                break;
+            }
+            /*tempo */
+            case POWER | SAMPLE_1:  {
+                tapthetempo();
+                break;
+            }
+            case POWER | SAMPLE_1 | BUTTON_REPEAT: {
+                timer[1]=0;
+                break;
+            }
+            case POWER | SAMPLE_2: {
+                tapthetempo();
+                break;
+            }
+            case POWER | SAMPLE_2 | BUTTON_REPEAT: {
+                timer[2]=0;
+                break;
+            }
+            case POWER | SAMPLE_3: {
+                tapthetempo();
+                break;
+            }
+            case POWER | SAMPLE_3 | BUTTON_REPEAT: {
+                timer[3]=0;
+                break;
+            }
+            case POWER | SAMPLE_4: {
+                tapthetempo();
+                break;
+            }
+            case POWER | SAMPLE_4 | BUTTON_REPEAT: {
+                timer[4]=0;
+                break;
+            }
+            case POWER | SAMPLE_5: {
+                tapthetempo();
+                break;
+            }
+            case POWER | SAMPLE_5 | BUTTON_REPEAT: {
+                timer[5]=0;
+                break;
+            }
+            case POWER | SAMPLE_9: {
+                savesamplehappening = 1;
+                break;
+            }
+            case POWER: {
+                if (record == 0) {
+                    record = 1;
+                    rb->splash(HZ/10000, "record ON");
+                    if (recordedbefore == 0) {
+                        hihats = 130;
+                        hihatapart = (howfarapart * 4 * 2) + 1;
+                        recordedbefore = 1;
+                    }
+                } else {
+                    record = 0;
+                    rb->splash(HZ/10000, "record OFF");
+                }
+                break;
+            }
+            case POWER | SAMPLE_9 | SAMPLE_5: {
+                rb->close(raw_file);
+                rb->close(raw_file1);
+                rb->close(raw_file2);
+                rb->close(raw_file3);
+                rb->close(raw_file4);
+                rb->close(raw_file5);
+                rb->close(raw_file6);
+                rb->close(raw_file7);
+                change_volumeback();
+                rb->pcm_play_stop();
+                rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
+                quit = 1;
+                /* if (usb_is_on = 0) { quit = 1;} */
+                break;
+            }
+            default:
+                
+            break;
+        }
+        /*NOTES: THIS NEXT PART is the effects processing part, or at least the 
+        setup part. there's quite a bit of stuff  related to "is this the 
+        first time pressed, or a button_repeat".. cuz let's say the glitch, you 
+        weant it to start a glitch sequence when you first start pressing the 
+        button, but then afterwards not start it over when you're continuously 
+        still holding the glitch button */
+        if ((effectswitch == 2) || (effectswitch == 4)) {
+            /*echo comes on even if you haven't pressed effecton */
+            echo_on = 1;
+        } else {
+            echo_on = 0;
+        }
+        if (effecton == 1) {
+            if ((effectswitch == 1) || (effectswitch == 2)) {
+                /*if glitch is selected, and fly on, */
+                glitch_on = 1;
+                if (argh == 0) {
+                    /*if it's the first time the glitch button is pressed (and 
+                    not just button_repeats) */
+                    
+                    argh =1;
+                    int i=0;
+                    for (i = 0; i < 6;i++) {
+                        if (buttondown[i]==1) {
+                            chunk[0]=7;
+                            /*this will trigger the glitch counter..*/
+                            chunk[1]=7;
+                            chunk[2]=7;
+                            chunk[3]=7;
+                            chunk[4]=7;
+                            chunk[5]=7;
+                            megachunk[0]=0;
+                            megachunk[1]=0;
+                            megachunk[2]=0;
+                            megachunk[3]=0;
+                            megachunk[4]=0;
+                            megachunk[5]=0;
+                            glitchcounter[0] = howfarapart + 1;
+                            /*this will trigger the glitch counter.. since i 
+                            want it to be at sequence 0 when you hit glitch */
+                            glitchcounter[1] = howfarapart + 1;
+                            glitchcounter[2] = howfarapart + 1;
+                            glitchcounter[3] = howfarapart + 1;
+                            glitchcounter[4] = howfarapart + 1;
+                            glitchcounter[5] = howfarapart + 1;
+                            glitchwhich[i]=1;
+                            /*and in the routine it needs chunk = 8 and 
+                            glitchcounter to be more than howfarapart / 8 + 1 */
+                        }
+                    }
+                }
+            }
+            if ((effectswitch == 3) || (effectswitch == 4)) {
+                for (jz = 1; jz < 7; jz++) {
+                    if (backwards[jz]==0) {
+                        backwards[jz]=1;
+                        if (buttondownprogress[jz]==0) {
+                            backwardsniblit[jz]=1;
+                        }
+                    }
+                    if ((backwardsniblit[jz]==1) && (buttondownprogress[jz]==0))
+                    {
+                        buttondownprogress[jz]=18000;
+                    }
+                    /*play the sample in reverse starting from near the 
+                    beginning */
+                    if ((buttondown[jz]==1) && (speedflick==1)) {
+                        reewind(jz);
+                    }
+                }
+            }
+        }
+        if (effecton == 0) {
+            if (argh==1) {
+                glitch_on = 0;
+                int i=0;
+                /*cleanup*/
+                for (i = 0; i < 7;i++) {
+                    glitchwhich[i]=0;
+                    chunk[i]=0;
+                    flanger[i]=0;
+                    firstlockdown[i]=0;
+                    megachunk[i]=0;
+                    backwardsniblit[i]=0;
+                    volumesnapper = 0;
+                    bitcrush[i]=0;
+                    speedflick=0;
+                    speedchange[i]=0;
+                    realspeed=0;
+                }
+                /*glitchsequence++; */
+                for (jz = 1; jz < 7; jz++) {
+                    backwards[jz]=0;
+                    backwardsniblit[jz]=0;
+                }
+                volumesnapper = 0;
+                if (glitchsequence >= howmanybeats) {
+                    glitchsequence = 0;
+                }
+                argh=0;
+            }
+            speedflick=0;
+            realspeed=0;
+            for (jz = 1; jz < 7; jz++) {
+                backwards[jz]=0;
+            }
+            speedchange[jz]=0;
+            backwardsniblit[jz]=0;
+        }
+        if (rb->button_hold ()) {
+            effectswitch++;
+            if (effectswitch >= 5) {
+                effectswitch = 1;
+            }
+        }
+        timer[1]= timer[1] + 1;
+        /*NOTES: all this is related to the fact that the rockbox/player 
+        doesn't seem to catch all the BUTTON_RELEASE events.  sooooo.. i have a 
+        timer that increases when it doesn't get any button_repeats.. when it 
+        gets to like x value, it says "i haven't got a button repeat in a while, 
+        so the button must be no longer pressed" and stops the sample.  bugfix, 
+        
+        */
+        timer[2]= timer[2] + 1;
+        timer[3]= timer[3] + 1;
+        timer[4]= timer[4] + 1;
+        timer[5]= timer[5] + 1;
+        timer[6]= timer[6] + 1;
+        timer[7]= timer[7] + 1;
+        maxtimeout = 28450;
+        if (CONFIG_KEYPAD == SANSA_C200_PAD) {
+            maxtimeout = 18450;
+        }
+        int k;
+        /* NOTES: this next part is the max acceptable period that the program 
+        can go without hearing a BUTTON_REPEAT event.  this is dependant on a) 
+        which player you use and b) how fast you set your button_repeatrate to 
+        be in whatever rockbox settings file.  if your samples truncate, you 
+        should try increasing the below numbers where  it says "timer[k] > 
+        xxxx".. try doubling it or something.  worst case once in a while you'll 
+        have a stuck note.
+         bug 12345 */
+        for (k = 0; k < 6; k++) {
+            if (echo_on == 0) {
+                if (timer[k] > 58450)  /*should be 18450!!!!!!28450WORKS ON E200
+                    actually in dec 2010 i had this at 38450*/                
+                    {
+                    
+                    buttondown[k]=0;
+                    
+                    buttondownprogress[k]=0;
+                }
+            }
+            if (echo_on == 1) {
+                if (timer[k] > 58450) {
+                    buttondown[k]=0;
+                    
+                    buttondownprogress[k]=0;
+                }
+            }
+        }
+        if (switchmenow == 1) {
+            switchit();
+            switchmenow = 0;
+        }
+        int z = 0;
+        
+         /* NOTES: this is the essential triggers for disk buffering.  basically 
+         this part here is when the sample is just starting, it says, 
+         "changehappening = 1" which triggers the porgram to start buffering the 
+         second chunk of the sample.  really the sample buffer space is split up 
+         into 3: the 1/2st have which always stays (so you can easily retrigger 
+         the sample without any buffering needed, the 2nd part is from 1/2 to 
+         3/4, and the 3rd part from 3/4 to 4/4 of the recording buffer zone.  
+         basically the 1st part stays constant, then it bounces back between 
+         part 2 and 3 over and over (when in part 2, it loads part 3, when in 
+         part 3, it loads part 2.this section, below, is loading part 2 so it's 
+         ready.
+                         */
+        for (z = 0; z < 6; z++) {
+            if (buttondownprogress[z+1] == 63488)  {
+                howmuchloaded[z]=0;
+                howmuchloadedjustnow[z]=0;
+                chunksize = 0;
+                howmuchloadederrorcheck[z]=0;
+                changehappening[z] = 1;
+                realprogress[z+1] = 0;
+            } else if (buttondownprogress[z+1] == ((length_of_samples / 2) )){
+                whatt = 5;
+                /* NOTES: this part is where it's in part 2, to load part 3.
+                */
+                chunksize = 0;
+                int wastetime = 0;
+                for (wastetime = 0; wastetime < 10000; wastetime++) {
+                }
+                /*this somehow prevents one track from skipping.  don't ask me 
+                why.		*/
+                howmuchloadedjustnow[z]=0;
+                changehappening[z] = 2;
+            } else if (buttondownprogress[z+1] == ((length_of_samples / 2) 
+            + (length_of_samples / 4)  )) {
+                /*NOTES: this part is when it's already in part 3, to load part
+                2. */
+                int wastetime = 0;
+                for (wastetime = 0; wastetime < 10000; wastetime++) {
+                }
+                chunksize = 0;
+                howmuchloadedjustnow[z]=0;
+                changehappening[z] = 1;
+            } else if (buttondownprogress[z+1] == length_of_samples )  {
+                /* NOTES: this is where it is at the end of part 3, to tell the 
+                pointer to go to part 2. */
+                realprogress[z+1] += (length_of_samples / 2);
+                buttondownprogress[z+1] = length_of_samples / 2;
+            }
+        }
+        slowdown++;
+        int zz = 0;
+        numberofsamplesatonce=1;
+        for (zz = 0; zz < 6; zz++) {
+            /*NOTES:  i noticed the buffering makes a background noise, from 
+            the disk running, so i made it so if there's only one sample 
+            loading, to do the buffering ultra slow so that the background 
+            noise is less apparent.  */ 
+            if (buttondownprogress[zz+1] > 0) {
+                numberofsamplesatonce++;
+            }
+           
+        }
+        if (numberofsamplesatonce > 4) {
+            speed=1;
+        } else if (numberofsamplesatonce == 4) {
+            speed=100;
+        } else if (numberofsamplesatonce == 3) {
+            speed=250;
+        } else if (numberofsamplesatonce == 2) {
+            speed=600;
+        }
+        if (numberofsamplesatonce == 1) {
+            int ff = 0;
+            for (ff = 0; ff < 6; ff++) {
+                changehappening[ff]=0;
+            }
+        }
+        /*stop loading cuz it's dumb loading when nothings playing	*/
+        if (savesamplehappening ==1 ) {
+            clearingbuffercounter = 0;
+            individual_saver();
+        }
+        if (switchsamplehappening[0] == 1) {
+            individual_changer(0);
+        } else if (switchsamplehappening[1] == 1) {
+            individual_changer(1);
+        } else if (switchsamplehappening[2] == 1) {
+            individual_changer(2);
+        } else if (switchsamplehappening[3] == 1) {
+            individual_changer(3);
+        } else if (switchsamplehappening[4] == 1) {
+            individual_changer(4);
+        } else if (switchsamplehappening[5] == 1) {
+            individual_changer(5);
+        } else {
+            if (slowdown >= speed) {
+                if (changehappening[0] == 1) {
+                    /*it only buffers one sample at a time no matter what. */  
+                    disk_buffer(0);
+                } else   if (changehappening[1] == 1) {
+                    disk_buffer(1);
+                } else  if (changehappening[2] == 1) {
+                    disk_buffer(2);
+                } else   if (changehappening[3] == 1) {
+                    disk_buffer(3);
+                } else   if (changehappening[4] == 1) {
+                    disk_buffer(4);
+                } else   if (changehappening[5] == 1) {
+                    disk_buffer(5);
+                }
+                if (changehappening[0] == 2) {
+                    disk_buffer2(0);
+                } else    if (changehappening[1] == 2) {
+                    disk_buffer2(1);
+                } else   if (changehappening[2] == 2) {
+                    disk_buffer2(2);
+                } else    if (changehappening[3] == 2) {
+                    disk_buffer2(3);
+                } else   if (changehappening[4] == 2) {
+                    disk_buffer2(4);
+                } else   if (changehappening[5] == 2) {
+                    disk_buffer2(5);
+                }
+                slowdown = 0;
+            }
+        }
+    }
+    return 0;
+}
+void switchit(void) {
+    int j;
+    /*NOTES: this is to load the already loaded buffer into the callback (super 
+    small callback).  1 or 2 switching back and forth.  */
+    
+    if (whichbuffer == 1)   {
+        for (j = 0; j < buffsize; j++) {
+            audiobuffer1[j] = 0;
+        }
+        int jk = 0;
+        for (jk = 1; jk < 7; jk++)  {
+        /*this part is quite ugly to optimize the least amount of IF's.  please 
+        if you change anything in this section, your code MUST BE ABLE TO PLAY 
+        ALL 6 SAMPLES WITHOUT ANY "CLICKS" AFTER 2 SECONDS OR STATIC ANGRINESS 
+        FROM BUFFERING PROBLEMS. the "CLICKS" can only be tested by using VERY 
+        quiet samples or some other method (you will not notice them with 
+        beats). */
+            if ((buttondown[jk] == 1) && ((volume[jk] > 0) || (glitchwhich[jk] 
+            == 0))) {
+                if (speedchange[jk] == 0) {
+                    if ((bitcrush[jk]==0) && (backwards[jk] == 0) && 
+                    (flanger[jk]==0)) {
+                        /*NORMAL */
+                        for (j = 0; j < buffsize; j++) {
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer1[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]) >> 1);
+                            }
+                        }
+                    } else if ((bitcrush[jk]==1) && (backwards[jk] == 0) && 
+                    (flanger[jk]==0)) {
+                        /*BITCRUSH*/
+                        for (j = 0; j < buffsize; j++) {
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer1[j] += (*((stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]))>>12 << 12 >>1);
+                            }
+                        }
+                    } else if ((bitcrush[jk]==1) && (backwards[jk] == 1) && 
+                    (flanger[jk]==0)) {
+                        /*BITCRUSH AND BACKWARDS	*/
+                        for (j = 0; j < buffsize; j++) {
+                            if (((buttondownprogress[jk]  + realprogress[jk] ) 
+                            > 1024) && (buttondownprogress[jk] < 
+                            length_of_files[jk])) {
+                                audiobuffer1[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) - j + 
+                                buttondownprogress[jk])>>12<<12 >>1);
+                            }
+                        }
+                    } else if ((bitcrush[jk]==0) && (backwards[jk] == 1) && 
+                    (flanger[jk]==0)) {
+                        /* BACKWRADS */
+                        for (j = 0; j < buffsize; j++) {
+                            if (((buttondownprogress[jk] + realprogress[jk] ) 
+                            > 1024) && (buttondownprogress[jk] < 
+                            length_of_files[jk])) {
+                                audiobuffer1[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) - j + 
+                                buttondownprogress[jk]) >> 1);
+                            }
+                        }
+                    } else if (flanger[jk]==1) {
+                        for (j = 0; j < buffsize; j++) {
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer1[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]) >> 1);
+                                audiobuffer1[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + flangey 
+                                + buttondownprogress[jk]) >> 1);
+                                hellocounter++;
+                                if (hellocounter >=200) {
+                                    if (flangedirection==0) {
+                                        flangey++;
+                                    } else {
+                                        flangey--;
+                                    }
+                                    if (flangey>1400) {
+                                        flangedirection=1;
+                                    } else if (flangey<0) {
+                                        flangedirection=0;
+                                    }
+                                    hellocounter = 0;
+                                }
+                            }
+                        }
+                    }
+                } else if (speedchange[jk] == 1){  
+                /* NOTES: this whole speedchange / realspeed is all for the 
+                drum and bass rewind. nothing else. */
+                    if ((realspeed >= 0) && (backwards[jk] == 0)) {
+                        for (j = 0; j < buffsize; j++) {
+                            samplespeed[jk]=samplespeed[jk] - 1;
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer1[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]) >> 1);
+                                if (samplespeed[jk] <= 0) {
+                                    buttondownprogress[jk] += 2;
+                                    samplespeed[jk] = (20 - realspeed);
+                                }
+                            }
+                        }
+                    } else if ((realspeed >= 0) && (backwards[jk] == 1)) {
+                        for (j = 0; j < buffsize; j++) {
+                            samplespeed[jk]=samplespeed[jk] - 1;
+                            if (((buttondownprogress[jk] + realprogress[jk] ) 
+                            > 1024) && (buttondownprogress[jk] < 
+                            length_of_files[jk])) {
+                                audiobuffer1[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) - j + 
+                                buttondownprogress[jk]) >> 1);
+                                if (samplespeed[jk] <= 0) {
+                                    buttondownprogress[jk] -= 4;
+                                    samplespeed[jk] = (20 - realspeed);
+                                }
+                            }
+                        }
+                    }
+                    if ((realspeed > -17) && (realspeed < 0) && (backwards[jk] 
+                    == 0)) {
+                        for (j = 0; j < buffsize; j++) {
+                            samplespeed[jk]=samplespeed[jk] - 1;
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer1[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]) >> 1);
+                                if (samplespeed[jk] <= 0) {
+                                    buttondownprogress[jk] -= 2;
+                                    samplespeed[jk] = (20 + realspeed);
+                                }
+                            }
+                        }
+                    } else if ((realspeed > -17) && (realspeed < 0) && 
+                    (backwards[jk] == 1)) {
+                        for (j = 0; j < buffsize; j++) {
+                            samplespeed[jk]=samplespeed[jk] - 1;
+                            if (((buttondownprogress[jk] + realprogress[jk] ) > 
+                            1024) && (buttondownprogress[jk] < 
+                            length_of_files[jk])) {
+                                audiobuffer1[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) - j + 
+                                buttondownprogress[jk]) >> 1);
+                                if (samplespeed[jk] <= 0) {
+                                    buttondownprogress[jk] += 2;
+                                    samplespeed[jk] = (20 + realspeed);
+                                }
+                            }
+                        }
+                    }
+                    if ((realspeed <= -17)  && (backwards[jk] == 0)) {
+                        for (j = 0; j < buffsize; j++) {
+                            samplespeed[jk]=samplespeed[jk] - 1;
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer1[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]) >> 1);
+                                if (shazam > 1) {
+                                    if (keepstereo == 1) {
+                                        if (samplespeed[jk] != 0) {
+                                            buttondownprogress[jk] -= 2;
+                                        }
+                                        keepstereo++;
+                                    } else {
+                                        keepstereo = 1;
+                                    }
+                                }
+                                if ((samplespeed[jk] <= 0)) {
+                                    samplespeed[jk] = -14 - realspeed;
+                                }
+                                shazam--;
+                                if (shazam < 0) {
+                                    shazam = 16;
+                                }
+                            }
+                        }
+                    } else if ((realspeed <= -17) && (backwards[jk] == 1)) {
+                        for (j = 0; j < buffsize; j++) {
+                            samplespeed[jk]=samplespeed[jk] - 1;
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer1[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]) >> 1);
+                                if (shazam > 1) {
+                                    if (keepstereo == 1) {
+                                        if (samplespeed[jk] != 0) {
+                                            buttondownprogress[jk] += 2;
+                                        }
+                                        keepstereo++;
+                                    } else {
+                                        keepstereo = 1;
+                                    }
+                                }
+                                if ((samplespeed[jk] <= 0)) {
+                                    samplespeed[jk] = -14 - realspeed;
+                                }
+                                shazam--;
+                                if (shazam < 0) {
+                                    shazam = 16;
+                                }
+                            }
+                        }
+                        /*NOTES: all of the previous stuff was for the drum and 
+                        bass rewind. */
+                    }
+                }
+            }	
+            if (glitchwhich[jk]==1) {
+               
+                glitchcounter[jk]+=buffsize;
+                if (glitchcounter[jk] >= (howfarapart + 1)) {
+                    chunk[jk] = 0;
+                    glitchcounter[jk]-=(howfarapart + 1);
+                    glitchtime(jk);
+                    megachunk[jk]++;
+                    if (megachunk[jk]>=64) {
+                        megachunk[jk]=0;
+                    }
+                    if (speedflick == 1) {
+                        if ((realspeed > -14)) {
+                            realspeed=realspeed-3;
+                            kfo = 0;
+                        }
+                    }
+                }
+            }
+           
+        }
+        
+        if (echo_on == 1) {
+            for (j = 0; j < buffsize; j++) {
+                audiobuffer1[j] = (audiobuffer1[j]) + (echobuffer[echooo] >> 
+                1);
+                echobuffer[echooo]= audiobuffer1[j];
+                echooo++;
+                if (echooo > ((howfarapart * 4) + 1)) {
+                    echooo  = 0;
+                }
+            }
+        }
+        if (hihatapart > ((howfarapart * 4 * 2) )) {
+            hihats++;
+            if (hihats >= 9) {
+                hihats = 1;
+                recposition = 0;
+               
+            }
+            hihatprogress = 0;
+            hihatapart -= ((howfarapart * 4 * 2));
+        }
+        if (record == 0) {
+            //recording mode
+            for (j = 0; j < buffsize; j++) {
+                if (clearingbuffercounter < (howfarapart * 4 * 2 * 8)) {
+                    *(stolen_audio_buffer6 + length_of_files[7] + 
+                    length_of_files[8] + 1000 + recposition) = 0;
+                }
+                audiobuffer1[j] = ((audiobuffer1[j]) + *(stolen_audio_buffer6 + 
+                length_of_files[7] + length_of_files[8] + 1000 + recposition));
+                recposition++;
+                hihatapart++;
+            }
+        } else if (record == 1) {
+            for (j = 0; j < buffsize; j++) {
+                if (clearingbuffercounter < (howfarapart * 4 * 2 * 8)) {
+                    *(stolen_audio_buffer6 + length_of_files[7] + 
+                    length_of_files[8] + 1000 + recposition) = 0;
+                }
+                audiobuffer1[j] = ((audiobuffer1[j]) + (*(stolen_audio_buffer6 
+                + length_of_files[7]  + length_of_files[8] + 1000 + 
+                recposition)));
+                *(stolen_audio_buffer6 + length_of_files[7] + length_of_files[8]
+                + 1000 + recposition) = audiobuffer1[j];
+                recposition++;
+                hihatapart++;
+                if (hihats > 1) {
+                    if (hihatprogress < (length_of_files[7] - 1000) ) {
+                        audiobuffer1[j] += (*(stolen_audio_buffer6  + j + 
+                        hihatprogress) ) >> 3;
+                    }
+                } else {
+                    if (hihatprogress < length_of_files[8] ) {
+                        audiobuffer1[j] += (*(stolen_audio_buffer6 + 
+                        length_of_files[7]  + j + hihatprogress) ) >> 3;
+                    }
+                }
+            }
+        }
+        hihatprogress += buffsize;
+    }
+   /*NOTES: all of the following is the same as "whichbuffer == 1" above.  
+   i'm a bad programmer i know.  i'm sure you could put a fancy array or 
+   something and have less code. */
+   
+
+    if (whichbuffer == 0){
+        for (j = 0; j < buffsize; j++) {
+            audiobuffer2[j] = 0;
+        }
+        int jk = 0;
+        for (jk = 1; jk < 7; jk++) {
+            if ((buttondown[jk] == 1) && ((volume[jk] > 0) || 
+            (glitchwhich[jk] == 0))) {
+                if (speedchange[jk] == 0) {
+                    if ((bitcrush[jk]==0) && (backwards[jk] == 0) && 
+                    (flanger[jk]==0)) {
+                       /* NORMAL */
+                        for (j = 0; j < buffsize; j++) {
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer2[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]) >> 1);
+                            }
+                        }
+                    } else if ((bitcrush[jk]==1) && (backwards[jk] == 0) && 
+                    (flanger[jk]==0)) {
+                        for (j = 0; j < buffsize; j++) {
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer2[j] += (*((stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]))>>12 << 12 >>1);
+                            }
+                        }
+                    } else if ((bitcrush[jk]==1) && (backwards[jk] == 1) && 
+                    (flanger[jk]==0)) {
+                        for (j = 0; j < buffsize; j++) {
+                            if (((buttondownprogress[jk] + realprogress[jk] ) 
+                            > 1024) && (buttondownprogress[jk] < 
+                            length_of_files[jk])) {
+                                audiobuffer2[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) - j + 
+                                buttondownprogress[jk])>>12<<12 >>1);
+                            }
+                        }
+                    } else if ((bitcrush[jk]==0) && (backwards[jk] == 1) && 
+                    (flanger[jk]==0)) {
+                        for (j = 0; j < buffsize; j++) {
+                            if (((buttondownprogress[jk]  + realprogress[jk] )
+                            > 1024) && (buttondownprogress[jk] < 
+                            length_of_files[jk])) {
+                                audiobuffer2[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) - j + 
+                                buttondownprogress[jk]) >> 1);
+                            }
+                        }
+                    } else if (flanger[jk]==1) {
+                        for (j = 0; j < buffsize; j++) {
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer2[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]) >> 1);
+                                audiobuffer2[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + flangey + 
+                                buttondownprogress[jk]) >> 1);
+                                hellocounter++;
+                                if (hellocounter >=200) {
+                                    if (flangedirection==0) {
+                                        flangey++;
+                                    } else {
+                                        flangey--;
+                                    }
+                                    if (flangey>1400) {
+                                        flangedirection=1;
+                                    } else if (flangey<0) {
+                                        flangedirection=0;
+                                    }
+                                    hellocounter = 0;
+                                }
+                            }
+                        }
+                    }
+                }
+                 else if (speedchange[jk] == 1) {
+                    if ((realspeed >= 0) && (backwards[jk] == 0)) {
+                        for (j = 0; j < buffsize; j++) {
+                            samplespeed[jk]=samplespeed[jk] - 1;
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer2[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]) >> 1);
+                                if (samplespeed[jk] <= 0) {
+                                    buttondownprogress[jk] += 2;
+                                    samplespeed[jk] = (20 - realspeed);
+                                }
+                            }
+                        }
+                    } else if ((realspeed >= 0) && (backwards[jk] == 1)) {
+                        for (j = 0; j < buffsize; j++) {
+                            samplespeed[jk]=samplespeed[jk] - 1;
+                            if (((buttondownprogress[jk] + realprogress[jk] ) > 
+                            1024) && (buttondownprogress[jk] < 
+                            length_of_files[jk])) {
+                                audiobuffer2[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) - j + 
+                                buttondownprogress[jk]) >> 1);
+                                if (samplespeed[jk] <= 0) {
+                                    buttondownprogress[jk] -= 4;
+                                    samplespeed[jk] = (20 - realspeed);
+                                }
+                            }
+                        }
+                    }
+                    if ((realspeed > -17) && (realspeed < 0) && (backwards[jk] 
+                    == 0)) {
+                        for (j = 0; j < buffsize; j++) {
+                            samplespeed[jk]=samplespeed[jk] - 1;
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer2[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]) >> 1);
+                                if (samplespeed[jk] <= 0) {
+                                    buttondownprogress[jk] -= 2;
+                                    samplespeed[jk] = (20 + realspeed);
+                                }
+                            }
+                        }
+                    } else if ((realspeed > -17) && (realspeed < 0) && 
+                    (backwards[jk] == 1)) {
+                        for (j = 0; j < buffsize; j++) {
+                            samplespeed[jk]=samplespeed[jk] - 1;
+                            if (((buttondownprogress[jk] + realprogress[jk] ) >
+                            1024) && (buttondownprogress[jk] < 
+                            length_of_files[jk])) {
+                                audiobuffer2[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) - j + 
+                                buttondownprogress[jk]) >> 1);
+                                if (samplespeed[jk] <= 0) {
+                                    buttondownprogress[jk] += 2;
+                                    samplespeed[jk] = (20 + realspeed);
+                                }
+                            }
+                        }
+                    }
+                    if ((realspeed <= -17)  && (backwards[jk] == 0)) {
+                        for (j = 0; j < buffsize; j++) {
+                            samplespeed[jk]=samplespeed[jk] - 1;
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer2[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]) >> 1);
+                                if (shazam > 1) {
+                                    if (keepstereo == 1) {
+                                        if (samplespeed[jk] != 0) {
+                                            buttondownprogress[jk] -= 2;
+                                        }
+                                        keepstereo++;
+                                    } else {
+                                        keepstereo = 1;
+                                    }
+                                }
+                                if ((samplespeed[jk] <= 0)) {
+                                    samplespeed[jk] = -14 - realspeed;
+                                }
+                                shazam--;
+                                if (shazam < 0) {
+                                    shazam = 16;
+                                }
+                            }
+                        }
+                    } else if ((realspeed <= -17) && (backwards[jk] == 1)) {
+                        for (j = 0; j < buffsize; j++) {
+                            samplespeed[jk]=samplespeed[jk] - 1;
+                            if ((buttondownprogress[jk] + realprogress[jk] + 
+                            500) < length_of_files[jk]) {
+                                audiobuffer2[j] += (*(stolen_audio_buffer + 
+                                ((length_of_samples * (jk - 1))) + j + 
+                                buttondownprogress[jk]) >> 1);
+                                if (shazam > 1) {
+                                    if (keepstereo == 1) {
+                                        if (samplespeed[jk] != 0) {
+                                            buttondownprogress[jk] += 2;
+                                        }
+                                        keepstereo++;
+                                    } else {
+                                        keepstereo = 1;
+                                    }
+                                }
+                                if ((samplespeed[jk] <= 0)) {
+                                    samplespeed[jk] = -14 - realspeed;
+                                }
+                                shazam--;
+                                if (shazam < 0) {
+                                    shazam = 16;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+           	
+            if (glitchwhich[jk]==1) {
+                glitchcounter[jk]+=buffsize;
+                if (glitchcounter[jk] >= (howfarapart ) + 1) {
+                    chunk[jk] = 0;
+                    glitchcounter[jk]-=(howfarapart + 1);
+                    glitchtime(jk);
+                    megachunk[jk]++;
+                    if (megachunk[jk]>=64) {
+                        megachunk[jk]=0;
+                    }
+                    if (speedflick == 1) {
+                        if ((realspeed > -14)) {
+                            realspeed=realspeed-3;
+                            kfo = 0;
+                        }
+                    }
+                }
+            }
+        }
+        if (echo_on == 1) {
+            for (j = 0; j < buffsize; j++) {
+                audiobuffer2[j] = (audiobuffer2[j]) + (echobuffer[echooo] >> 
+                1);
+                echobuffer[echooo]= audiobuffer2[j];
+                echooo++;
+                if (echooo > ((howfarapart * 4) + 1)) {
+                    echooo  = 0;
+                }
+            }
+        }
+        if (hihatapart > ((howfarapart * 4 * 2) )) {
+            hihats++;
+            if (hihats >= 9) {
+                hihats = 1;
+                recposition = 0;
+              
+            }
+            hihatprogress  =0;
+            hihatapart -= ((howfarapart * 4 * 2));
+        }
+        if (record == 0) {
+            /* recording stuff */
+            for (j = 0; j < buffsize; j++) {
+                if (clearingbuffercounter < (howfarapart * 4 * 2 * 8)) {
+                    *(stolen_audio_buffer6 + length_of_files[7] + 
+                    length_of_files[8] + 1000 + recposition) = 0;
+                }
+                audiobuffer2[j] = ((audiobuffer2[j]) + (*(stolen_audio_buffer6 
+                + length_of_files[7] + length_of_files[8] + 1000 + 
+                recposition)));
+                recposition++;
+                hihatapart++;
+            }
+        } else if (record == 1) {
+            for (j = 0; j < buffsize; j++) {
+                if (clearingbuffercounter < (howfarapart * 4 * 2 * 8)) {
+                    *(stolen_audio_buffer6 + length_of_files[7] + 
+                    length_of_files[8] + 1000 + recposition) = 0;
+                }
+                audiobuffer2[j] = ((audiobuffer2[j]) + (*(stolen_audio_buffer6 + 
+                length_of_files[7] + length_of_files[8]  + 1000 + 
+                recposition))) ;
+                *(stolen_audio_buffer6 + length_of_files[7] + length_of_files[8] 
+                + 1000 + recposition) = audiobuffer2[j];
+                recposition++;
+                hihatapart++;
+                if (hihats > 1) {		
+                    if (hihatprogress < (length_of_files[7] - 1000) ) {
+                        audiobuffer2[j] += (*(stolen_audio_buffer6  + j + 
+                        hihatprogress) ) >> 3;
+                    }
+                } else {
+                    if (hihatprogress < length_of_files[8] ) {
+                        audiobuffer2[j] += (*(stolen_audio_buffer6 + 
+                        length_of_files[7]  + j + hihatprogress) ) >> 3;
+                    }
+                }
+            }
+        }
+        hihatprogress += buffsize;
+        clearingbuffercounter += buffsize;
+    }
+   
+    echolength=echolength + buffsize;
+    int ii = 0;
+    for (ii = 1; ii < 7; ii++) {
+        if (buttondown[ii] == 1) {
+            if (backwards[ii] == 0) {
+                buttondownprogress[ii] += buffsize;
+            } else if (backwards[ii] == 1) {
+                 if (buttondownprogress[ii] == 256) {
+                    buttondownprogress[ii] = 3;
+                }
+                buttondownprogress[ii] -= buffsize ;
+            }
+            if (buttondownprogress[ii] < 0) {
+                buttondownprogress[ii]=2;
+            }
+        
+        }
+    }
+}
\ No newline at end of file

