sent patterns and freq_table to programspace to fix #1

This commit is contained in:
bigalex 2012-08-13 20:41:23 +02:00
parent 7e1f6c835b
commit 6d2d1eae1e
2 changed files with 9 additions and 5 deletions

View File

@ -1,4 +1,6 @@
const uint16_t freq_table[] = {
#include <avr/pgmspace.h>
const uint16_t freq_table[] PROGMEM = {
/*0x00*/ 39,
/*0x01*/ 41,
/*0x02*/ 43,

View File

@ -1,6 +1,8 @@
#include <inttypes.h>
#include "synth.h"
#include "freq_table.h"
#include <avr/pgmspace.h>
// sample rate is 8M / (3 * 64)
enum {
@ -43,7 +45,7 @@ static const uint8_t wave_table[][2] = {
};
static const uint8_t patterns[][pattern_length][2] = {
static const uint8_t patterns[][pattern_length][2] PROGMEM = {
{},
{
{ 33 - 12, 0 },
@ -204,7 +206,7 @@ uint16_t synth_mix(void)
// enter new row
if(tick == 0) {
uint8_t pattern_nr = pattern_table[seq][i];
uint8_t note = patterns[pattern_nr][row][0];
uint8_t note = pgm_read_byte(&patterns[pattern_nr][row][0]);
if(note) { // new note, maybe?
if(note == 0xff) {
@ -212,7 +214,7 @@ uint16_t synth_mix(void)
} else {
chan->level = 80; // TODO: less?
chan->note = note;
chan->inst_nr = patterns[pattern_nr][row][1];
chan->inst_nr = pgm_read_byte(&patterns[pattern_nr][row][1]);
inst = &instruments[chan->inst_nr];
chan->pos = inst->wave_table_pos;
if(inst->pulse_width) chan->pulse_width = inst->pulse_width;
@ -240,7 +242,7 @@ uint16_t synth_mix(void)
synth_channel_t* chan = &channels[i];
const synth_instrument_t* inst = &instruments[chan->inst_nr];
chan->phase += freq_table[(uint8_t)(chan->note + wave_table[chan->pos][0])];
chan->phase += pgm_read_word(&freq_table[(uint8_t)(chan->note + wave_table[chan->pos][0])]);
uint8_t amp;
switch(wave_table[chan->pos][1]) {