58 lines
1.2 KiB
C
58 lines
1.2 KiB
C
|
|
#include <stdint.h>
|
|
#include "system.h"
|
|
#include "display.h"
|
|
#include "systick.h"
|
|
#include "button.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include "ui.h"
|
|
#include "timer.h"
|
|
#include "led.h"
|
|
#include "drone.h"
|
|
#include "drums.h"
|
|
#include "pot.h"
|
|
|
|
static struct drone_slot drone_pattern[MAX_PATTERN_LEN] = {
|
|
{ 28, 10 }, { 28, 20}, {36,20}, {40,20},
|
|
{ 40, 10 }, { 40, 10}, {36, 10}, {32,10}
|
|
};
|
|
|
|
void drone_beat(int pattern_pos)
|
|
{
|
|
struct drone_slot *key = &drone_pattern[pattern_pos];
|
|
static int test_lfo_step = 0;
|
|
static int test_lfo = 0;
|
|
int lfo_depth = 80;
|
|
int lfo_rate = 7;
|
|
int lfo_step = 2;
|
|
int tgt_env;
|
|
pot_set(0, 99);
|
|
|
|
if ((pattern_pos % lfo_step) == 0) {
|
|
if (test_lfo_step == 0) {
|
|
test_lfo+=lfo_rate;
|
|
if (test_lfo > lfo_depth)
|
|
test_lfo_step = 1;
|
|
} else {
|
|
test_lfo-=lfo_rate;
|
|
if (test_lfo < (0 - lfo_depth))
|
|
test_lfo_step = 0;
|
|
}
|
|
}
|
|
|
|
|
|
tgt_env = key->env + test_lfo;
|
|
if (tgt_env < 0) {
|
|
tgt_env = 0;
|
|
test_lfo_step = 0;
|
|
}
|
|
if (tgt_env > 99) {
|
|
tgt_env = 99;
|
|
test_lfo_step = 1;
|
|
}
|
|
|
|
pot_set(0, key->pitch);
|
|
pot_set(1, tgt_env);
|
|
}
|