Compare commits

..

2 Commits

Author SHA1 Message Date
Mike Lynch f6abdd7c2b Changes to README and TODO 2024-10-19 10:45:12 +11:00
Mike Lynch 41870f2d5e Added changes to 14, plus 19 and 20 2024-10-19 10:45:01 +11:00
5 changed files with 231 additions and 8 deletions

View File

@ -16,8 +16,8 @@ int note = 0;
// int pitch[] = { 8, 4, 5, -1, 4, 3, -1, 2, 3, 4, -1, 6, 3, 4, 5, -1 }; // int pitch[] = { 8, 4, 5, -1, 4, 3, -1, 2, 3, 4, -1, 6, 3, 4, 5, -1 };
// float dur[] = { 0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25, }; // float dur[] = { 0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,0.25, };
int pitch[] = { 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 0, -1, -1, -1 }; int pitch[] = { 12, -1, 11, -1, 12, -1, 15, -1, 12, -1, 11, -1, -1, -1, -1, -1 };
float dur[] = { 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0 }; float dur[] = { 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0 };
int phrase = 16; int phrase = 16;
@ -43,7 +43,7 @@ void setup() {
//OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536) //OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536)
//OCR1A = 7812;// = (16*10^6) / (1*1024) - 1 (must be <65536) //OCR1A = 7812;// = (16*10^6) / (1*1024) - 1 (must be <65536)
//OCR1A = 15624; //OCR1A = 15624;
OCR1A = 31248; OCR1A = 48000;
// turn on CTC mode // turn on CTC mode
TCCR1B |= (1 << WGM12); TCCR1B |= (1 << WGM12);
// Set CS10 and CS12 bits for 1024 escaler // Set CS10 and CS12 bits for 1024 escaler

View File

@ -0,0 +1,88 @@
// Basic demo for configuring the MCP4728 4-Channel 12-bit I2C DAC
#include <Adafruit_MCP4728.h>
#include <Wire.h>
Adafruit_MCP4728 mcp;
// idea behind this - sequence a cloud of gate events
float hexany[] = { 0.12928301694496647, 0.32192809488736235, 0.3923174227787603, 0.5849625007211562, 0.8073549220576041, 0.9068905956085185 };
float tuning[18];
int chord[10] = { 0, 2, 4, 6, 8, 7, 11, 15, 14, 10 };
int bpm = 60;
float beat_s = 60.0 / (float)bpm;
int beat_m = round(1000.0 * beat_s);
float mod_b = 3.141592653589793 / 4.0;
float voltrange = 4.85; // measured this, probably not accurate
float octave = 4096.0 / voltrange; // number of DAC steps in an octave
int gate = 0;
int gatel = 1000;
int tick = 16;
long init_t;
float p_gate = 0.0;
void setup(void) {
Serial.begin(115200);
while (!Serial)
delay(10); // will pause Zero, Leonardo, etc until serial console opens
if (!mcp.begin(0x64)) {
Serial.println("Failed to find MCP4728 chip");
while (1) {
delay(10);
}
Serial.println("MCP4728 initialised");
}
float n0 = 0;
for( int o = 0; o < 3; o++ ) {
for( int i = 0; i < 18; i++ ) {
tuning[o * 6 + i] = round(n0 + octave * (o + hexany[i]));
}
}
init_t = millis();
mcp.setChannelValue(MCP4728_CHANNEL_B, 0);
}
void loop() {
int note;
int k = 0;
if( gate > 0 ) {
gate--;
if( gate == 0 ) {
mcp.setChannelValue(MCP4728_CHANNEL_B, 0);
}
} else {
long now = millis();
long mod_t = now - init_t;
tick--;
if( tick == 0 ) {
tick = 32;
p_gate = sin(mod_b * (float)mod_t / (float)beat_m);
}
if( (float)random(10000) / 20.0 < abs(p_gate)) {
if( p_gate > 0 ) {
note = random(5);
} else {
note = 5 + random(5);
}
mcp.setChannelValue(MCP4728_CHANNEL_B, 4095);
mcp.setChannelValue(MCP4728_CHANNEL_A, tuning[note]);
gate = gatel;
}
}
}

View File

@ -0,0 +1,109 @@
// can fibomod make an interesting noise?
#include <Adafruit_MCP4728.h>
#include <Wire.h>
Adafruit_MCP4728 mcp;
#define nsamp 1500
#define dacmax 256
unsigned int phase = 0;
unsigned int fibo = 3;
unsigned int scale = 0;
unsigned int fibi = 0;
unsigned int gate = 4095;
unsigned int pmax = nsamp;
unsigned int beat = 0;
unsigned int fibosort[] = { 4,3,11,8,29,7,21,19,38,76,5,55,199,6,9,12,16,18,24,36,48,72,144,13,22,31,44,62,124,47,141,17,34,68,136,152,15,33,41,123,165,205,58,116,211,89,139,14,23,28,32,42,46,56,63,69,84,92,96,112,126,138,161,168,184,207,224,252,101,151,233,39,87,59,10,20,40,61,88,110,122,155,220,244,248,71,27,51,54,57,102,107,108,114,153,171,204,214,216,228,37,113,79,158,35,77,105,231,26,52,104,232,43,129,181,209,64,94,188,192,25,53,106,109,212,218,121,49,91,147,203,229,30,45,60,66,80,82,90,93,99,120,132,164,176,180,183,186,198,240,246,131,178,67,201,65,143,145,119,133,189,238,73,149,202,111,235,78,83,117,156,166,174,208,234,249,118,236,179,85,95,170,187,190,191,128,97,75,103,142,81,159,162,74,148,226,177,239,70,115,140,154,160,210,217,230,241,253,251,221,247,127,86,172,137,195,213,219,50,100,200,237,157,163,242,98,167,182,196,173,135,255,169,185,193,197,175,134,130,215,146,223,222,227,125,245,194,150,225,206,243,254,250 };
byte waveform[nsamp];
void setup() {
cli();
//set timer1 interrupt at 1Hz
TCCR1A = 0;// set entire TCCR1A register to 0
TCCR1B = 0;// same for TCCR1B
TCNT1 = 0;//initialize counter value to 0
// set compare match register for 1hz increments
//OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536)
//OCR1A = 7812;// = (16*10^6) / (1*1024) - 1 (must be <65536)
OCR1A = 3200;
// turn on CTC mode
TCCR1B |= (1 << WGM12);
// Set CS10 and CS12 bits for 1024 prescaler
TCCR1B |= (1 << CS12) | (1 << CS10);
// enable timer compare interrupt
TIMSK1 |= (1 << OCIE1A);
sei();
Serial.begin(115200);
if (!mcp.begin(0x64)) {
while (1) {
delay(100);
}
}
mcp.setSpeed(800000L);
for( int i = 0; i < nsamp; i++ ) {
waveform[i] = 1;
}
fibi = 3;
fibo = 3; //fibosort[fibi];
setwave();
}
void setwave(){
waveform[0] = 0;
waveform[1] = 1;
fibo = fibi; // fibosort[fibi];// + 3;
pmax = nsamp;
for (int i=2; i<nsamp; ++i){
waveform[i] = (waveform[i - 1] + waveform[i - 2]) % fibo;
if( waveform[i - 1] == 0 && waveform[i] == 1 ) {
pmax = i - 1;
break;
}
}
float scale = 256 / fibo;
for( int i = 0; i < nsamp; ++i ) {
waveform[i] *= scale;
}
}
ISR(TIMER1_COMPA_vect){//timer1
fibi++;
if( fibi == 67 ) {
fibi = 3;
}
setwave();
phase = 0;
beat++;
if ( beat == 4 ) {
gate = 4095;
beat = 0;
}
}
void loop() {
mcp.fastWrite(waveform[phase] << 4, gate, 0, 0);
phase += 1;
if( phase == pmax ) {
phase = 0;
gate = 0;
}
}

View File

@ -3,4 +3,6 @@ Looptober 2024
This year for Looptober I decided to use my Arduino (in combination with my This year for Looptober I decided to use my Arduino (in combination with my
modular synth rack) for every track. The source code for each day's track modular synth rack) for every track. The source code for each day's track
is here and the tracks are on [my Funkwhale server](https://music.mikelynch.org/library/albums/31/) is here and the tracks are on [my Funkwhale server](https://music.mikelynch.org/library/albums/31/)

32
TODO.md
View File

@ -1,11 +1,35 @@
## TODO ## TODO
6 October
Sunday 6 October
s 6 - Wavetable updates s 6 - Wavetable updates
m 7 - Change a sequence while it's playing m 7 - Change a sequence while it's playing
t 8 - Sound clouds t 8 - Sound clouds
w 9 - 7TET groove w 9 - 7TET groove
t 10 - Drum pattern t 10 - Drum pattern
f 11 - FM f 11 - Scratchy karplus-strong beats
s 12 - Karplus-Strong s 12 - sequencer 2
s 13 - accidental FM synth
m 14 - slow dank
t 15 - rattatat
w 16 -
t 17
f 18
s 19
s 20
m 21
t 22
w 23
t 24
f 25
s 26
s 27
m 28
t 29
w 30
t 31
More ideas
deliberate FM synthesis
KR to AR modulation and back
Envelopes