Saturday, 10 April 2021

Master clock / divider & multiplier - Millis() - OLED display

My third attempt at using an Arduino to make a master clock with dividers and multipliers.
This is a good beginners circuit.
 
 
My earlier attempts are here:
You can of course just buy a clock multiplier / divider, but where's the fun in that.
 
i'M USING  a basic Arduino Uno
The OLED communicates via i2c
PinWiring to Arduino Uno
Vin5V
GNDGND
SCLA5
SDAA4
 

 
The POT is wired thus:
centre (wiper) to A0
Right to GND
Left to 5V
 
The pot supplies an analog voltage which is converted into a digital
signal by the Arduino's ADCs.
Maybe an encoder would be better used??
 

 
 
The 4 LEDs
Cathode to gnd via 220 ohm resistors
Anode to pins 8, 9, 10, 11. 

I played around with the delay function, but the Millis function works much better.
 
I'm not a coder so if you can suggest any improvements, let me know.
Feel free to hack & improve the code.


The code:
 
 // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

/*
This is part of a project to build a Synth master clock module with multipliers and dividers
Hopefully will add MIDI later.
jondent808@gmail.com 
https://djjondent.blogspot.com/2018/03/arduino-index.html
 
*/
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

const int ledPin =  8;// the number of the LED pin 8
int ledState = LOW;             // ledState used to set the LED 8
const int ledPin9 =  9;// the number of the LED pin 9
int ledState9 = LOW;             // ledState used to set the LED 9
const int ledPin10 =  10;// the number of the LED pin 10
int ledState10 = LOW;             // ledState used to set the LED 10
const int ledPin11 =  11;// the number of the LED pin 11
int ledState11 = LOW;             // ledState used to set the LED 11

#define MIN_BPM 20      /*write here the min BPM that you want */
 #define MAX_BPM 300     /* write here the max BPM that you want */
 #define POT A0          // the potentiometer connects to analog pin A0

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

// Variables
int bpm;

unsigned long previousMillis = 0;        // will store last time LED was updated
unsigned long previousMillis9 = 0;        // will store last time LED9 was updated
unsigned long previousMillis10 = 0;        // will store last time LED10 was updated
unsigned long previousMillis11 = 0;        // will store last time LED11 was updated
 
const long interval = 60000;           // interval at which to blink (milliseconds)
const long interval2 = 30000;           // interval * 2
const long interval4 = 15000;           // interval * 4
const long interval8 = 7500;           // interval * 8

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
  pinMode(ledPin9, OUTPUT);
  pinMode(ledPin10, OUTPUT);
  pinMode(ledPin11, OUTPUT);
  digitalWrite(ledPin,ledState);// set initial state of pin 8 LED
  digitalWrite(ledPin9,ledState9);// set initial state of pin 9 LED
  digitalWrite(ledPin10,ledState10);// set initial state of pin 10 LED
  digitalWrite(ledPin11,ledState11);// set initial state of pin 11 LED
 
 
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C
  display.clearDisplay(); // Clear the buffer.
}

void loop() {

   bpm = map(analogRead(POT), 0, 1023, MIN_BPM, MAX_BPM);  
    display.clearDisplay();
    display.setTextSize(3);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.println(bpm);
    display.setTextSize(2);
    display.setTextColor(WHITE);
    display.println("    BPM");
    display.display();
    
 
unsigned long currentMillis = millis();
unsigned long currentMillis9 = millis();
unsigned long currentMillis10 = millis();
unsigned long currentMillis11 = millis();

  if (currentMillis - previousMillis >= interval/bpm) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED 8 is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }
 // set the LED 8 with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }

    // **********************************
    
 if (currentMillis9 - previousMillis9 >= interval2/bpm) {
    // save the last time you blinked the LED
    previousMillis9 = currentMillis9;
    
    // if the LED 9 is off turn it on and vice-versa:
    if (ledState9 == LOW) {
      ledState9 = HIGH;
    } else {
      ledState9 = LOW;
    }
    // set the LED 9 with the ledState of the variable:
    digitalWrite(ledPin9, ledState9);
  }
  // ********************************************
      
 if (currentMillis10 - previousMillis10 >= interval4/bpm) {
    // save the last time you blinked the LED
    previousMillis10 = currentMillis10;
    
    // if the LED 10 is off turn it on and vice-versa:
    if (ledState10 == LOW) {
      ledState10 = HIGH;
    } else {
      ledState10 = LOW;
    }
    // set the LED 10 with the ledState of the variable:
    digitalWrite(ledPin10, ledState10);
  }
  //*******************************************

  if (currentMillis11 - previousMillis11 >= interval8/bpm) {
    // save the last time you blinked the LED
    previousMillis11 = currentMillis11;
    
    // if the LED 11 is off turn it on and vice-versa:
    if (ledState11 == LOW) {
      ledState11 = HIGH;
    } else {
      ledState11 = LOW;
    }
    // set the LED 11 with the ledState of the variable:
    digitalWrite(ledPin11, ledState11);
}
}

// &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 



 ---------------------------------
-------------------------------------

coco cavoodle

 2

Wednesday, 7 April 2021

Vitalise - Upcoming synth meet & performances

 
 

  This is a nine week run of  live electronic music.
Held Thursday evenings, between 6pm and midnight.
 
Good Space 
33 Playfair St,
&
106-108 George St, The Rocks
 
Sydney
NSW AUSTRALIA


Facebook
 


 

Week 6

OLED - Displaying real time info

OLEDs are pretty cool .
This is the standard Adafruit splash screen.
I think it demonstrates well the capabilities of these little windows.
I'm sure you've seen OLEDs in plenty of synths.
 

To get a better understanding of this technology, I've started mucking around with Arduinos, and  various displays. LCDs are OK, but OLEDS are the bomb.



 
The Buchla logo is just lovely on this screen.


Up till now, all the images and text is part of the code.
In order to change the display, you need to change the code itself.
 
Thus this post.
It's actually a combination of two posts.
 
 The first post covered how to read & display the voltage on 
the output of an Arduino on a serial monitor.
The serial monitor is part of Arduino's IDE and communicates real time info.



The second post covered how to display info on a OLED screen.
 

So why not combine the two.
Though this may seem pretty basic, I think it's a important building block.
 
This is the code of how to read & display Arduino voltages on a OLED & the Serial monitor.
 
 

 
So so simple.
 
Feel free to copy, paste & hack

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

// set up variables
int myVoltPin=A2;
int readVal;
float V2;
 int delayT=250;


void setup()
{
  Serial.begin(9600);
  // initialize with the I2C addr 0x3C
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  

   // Clear the buffer.
  display.clearDisplay();
 
}

void loop()
{
  readVal=analogRead(myVoltPin);
  V2=(5./1023.)*readVal;
  // converts to a voltage -- remember to place the decimal
  // points after the 5 & 1023 ... these may be floating points
  Serial.println(V2);

  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("Voltage");
  display.println(" ");
  display.setTextSize(3);
  display.println(V2);
 
  display.display();
  delay(delayT);
  display.clearDisplay();
}

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

-------------------------------------------------------------------------------------------

 ---------------------------------
-------------------------------------

Tuesday, 6 April 2021

Ender's Game - Orson Scott Card

The book originated as a short story of the same name, published in the August 1977 issue of Analog Science Fiction and Fact.
Just 34 pages long.

 The novel was published on January 15, 1985.  
Its 324 pages long.
 
Ender's Game was recognized as "best novel" by the 1985 Nebula Award[3] and the 1986 Hugo Award[4

Its four sequels—Speaker for the Dead (1986), Xenocide (1991), Children of the Mind (1996), and Ender in Exile (2008)follow Ender's subsequent travels to many different worlds in the galaxy. In addition, the later novella A War of Gifts (2007) and novel Ender's Shadow (1999), plus other novels in the Shadow saga, take place during the same time period as the original

 

 



In order to develop a secure defense against a hostile alien race's next attack, government agencies breed child geniuses and train them as soldiers.  















--------------------------------------------

sci Fi Index

----------------------------------------------

Saturday, 3 April 2021

Friday, 2 April 2021

LCD Timer - i2c - Arduino

This is a nice simple timer circuit using an Arduino Uno, a LCD, two buttons, 
two LEDS and some resistors.
 

It's a stopwatch (and not directly synth related) , but the basic code is great for working out how an arduino clock works and how to display that info on a LCD.
Here is the instructables link:
 
 

 
I've changed the code a little to work with my LCD
And varied the resistors.
The switches are connected to gnd with 330 ohm resistors
The LEDs anodes connect to pins 2 & 3 via 220 ohm resistors.
Cathodes then connect straight to gnd.

Image made using Tinkercad

 

Many thanks to Jay 625549

The code is here:
//********************************
//Jay Raut Jean Augustine Secondary
//January 13 2020
//625549@pdsb.net
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup()
{
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
lcd.backlight();//turns on backlight
pinMode(8, INPUT);//setting up Pins on arduino for output and input from leds and buttons
digitalWrite(8, HIGH);
pinMode(9, INPUT);
digitalWrite(9, HIGH);
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
pinMode(3, OUTPUT);
digitalWrite(3, LOW);

}
double i = 0;//variables for recording time
double a = millis();
double c ;
void loop()
{
lcd.clear();
lcd.print("press the button");

 if(digitalRead(8) == LOW)//clears LCD when button is pressed
 {
    lcd.clear();
    a = millis();

   while(digitalRead(9) == HIGH)
   {
   c = millis();//function to start recording when the button was pressed to print on the LCD
   i = (c - a) / 1000;
   lcd.print(i);
   lcd.setCursor(7,0);
   lcd.print("Seconds");
   lcd.setCursor(0,0);
   digitalWrite(2, HIGH);//turns on green led
   digitalWrite(3, LOW);//turns off red led
   }
   if(digitalRead(9) == LOW)
   {
     while(digitalRead(8) == HIGH)//if other button is pressed then clear the LCD
     {
       lcd.setCursor(0,0);

       lcd.setCursor(11,0);
       lcd.print("");
       lcd.setCursor(0,0);
          digitalWrite(2, LOW);//turn off the green led
          digitalWrite(3, HIGH);//turn on the red led
     }
   }
 }
}

// *****************************
 

Links
+ Momentary push buttons & Pull down resistors  

 ---------------------------------
-------------------------------------

Alesis Andromeda - Part 5 - Envelopes

This is part 5 of my exploration of the A6
The previous parts are here:
 
The A6 provides lots of forms of modulation (keyboards, pedals, LFOs, mod wheels
ribbons, envelopes). It also incorporates a "Modulation Matrix" allowing you to route virtually
 any source to any destination. 
 

This post mostly covers the A6's envelopes. 
These envelopes are very flexible and quite complicated.
They offer endless possibilities.
 
This post really only covers the basics but should get you started.
Refer to the manual for more depth.

At it's most basic level, the Andromeda has three 7-stage loop-able envelope generators per voice.
 
 
The envelopes are essential modulation sources for every Program in the A6.
 
Envelopes can be used to effect many things like:
The VCO frequency (ENV 1)
The filter (ENV 2)
The loudness (ENV 3)... connected to the output VCA.
They can shape the amplitude of an LFO or alter the shape of a VCO’s waveform.
 

Default Modulation Paths.

Many of the modulation paths in the A6 are already routed in the instrument’s design.
These are called default modulation paths and are included because they are used so often.
Pre-routing makes setting them up much easier.
 
There are 3 basic default envelopes.

ENV 1 defaults to the frequency of OSC 1 and OSC 2 (It is Bipolar)
ENV 2 defaults to FILTER 1 FREQ and FILTER 2 FREQ (Also Bipolar)
ENV 3, which defaults to the A6’s amplifer -- (positive only)

Of course, you don’t have to use the default settings. 
You can route any of the default modulation sources to a whole slew of other destinations.
 
The A6 has three 7-stage loop-able envelope generators per voice. 
Normally, each of the A6’s three envelope generators has a start level of 0, 
and end at a level of 0. They have four target levels in between.
 
 
 
 
 
 
The 7 stages are: 

DELAY TIME
ATTACK TIME
Decay 1 TIME  (D1 time)
Decay 2 TIME  (D2 time)
SUSTAIN Stage
Release 1 TIME (R1 Time)
Release 2 TIME (R2 time)


Pressing a button or turning a knob on any of the three envelope areas displays that parameter. 
You can also press the VIEW button on the desired envelope and then use any of the
display’s soft knobs and buttons to work with a specific parameter as well as its dedicated panel controls.
The 8 Soft knobs (in the above pic) correspond to Delay, Attack, D1, D2, Shape, R1. R2, blank.
The 8 Soft buttons  correspond to Time, Level, Trig, Dym, Loop, Mod 1, Mod2, Mod3.
 

 

 Envelope Polarity

As mentioned earlier, ENV1 and ENV2 are bi-polar.  
(In the pic above, you can see ENV2 is negative, and R1 & D1 are off)
Each stage level setting has a user range of - 100 through +100. 
They can create unusual envelope shapes
Some synths like the Jupiter 6 allow you to invert  envelopes to -ve values
If the initial setting of the module is at the max , you can subtract from this.
 
ENV3 is positive only because it is hardwired to the final output of the voice. 
It's hard wired to the VCA -- thus you cant reduce loudness to below zero
Its stage level ranges, therefore, are 0 through +100. 

----------------------------------------------------------------------------------------------
As mentioned earlier, the A6's LED display breaks up the various envelope properties.
 
The 8 Soft knobs (in the above pic) correspond to Delay, Attack, D1, D2, Shape, R1. R2, blank.
The 8 Soft buttons  correspond to Time, Level, Trig, Dym, Loop, Mod 1, Mod2, Mod3.
Looking at the buttons, first.

Time Page

Press the TIME soft button to enter this page.
Use the soft knobs to adjust the time settings of the various stages ...
OR press the same button (TIME)  to jump between the various
stages eg Delay, attack, Decay 1, Decay 2, and Release 1 & R2. if you don't wish to touch the knobs.
 
TIME stages can be bypassed by setting their TIME page 
parameters to 0. 
Sustain Level is bypassed by setting its level on the LEVEL page to 0.
 

LEVEL Page Parameters

This page of parameters is where the four levels of the envelope are set. 
Notice that you can use a negative value for any or all of the levels in Envelopes 1 and 2.
 

The TIME & LEVEL page are most often used together to shape the envelope.
+ Level sets the amt of change the envelope will provide
+ Offset  produces fine adjustment of the level amt.
+ Polarity will establish whether the envelope is normal or inverted

 

 TRIG and RETRIG Pages Parameters

An envelope starts its cycle when it receives a trigger. 
The most typical and often used trigger source is the keyboard.
Triggers can also be generated from  incoming MIDI ,the A6’s Sequencer and Arpeggiator, 
and a slew of other trig sources. 
You can even trigger an envelope using the level of one of the other envelopes.
 
 
The TRIG and RETRIG pages let you determine:
 • where the trigger comes from – the keyboard/MIDI, another envelope,
    an LFO, the Sequencer and so forth
 • under what conditions an envelope responds to a received trigger
 • how an envelope proceeds through its cycle once a trigger is received 
  • if an envelope is re-triggered and how responds
 
There are seven modes.
(Turn soft knob 7 to access these) 

This parameter instructs the envelope how to execute 
its Attack, Decay, Sustain and Release stages.

The modes are:
NORM 1 
NORM 2 
FRERUN 
FR-SUS 
SUSREL 
MODTRG 
MOD-TG
 




NORM 1  --- triggers with Key ON. 
That is, the envelope will proceed through its cycle to the Sustain stage
as long as a key is being held down (Note On). 
But if the key is let go before the Sustain stage is reached,
 the envelope “jumps” to the Release 1 stage.

NORM 2 
The envelope jumps to the Release 2 stage (instead of the Release 1 stage in NORM 1)
 if the key is released before the Sustain stage is reached.
 
FRERUN (Free Run)
envelope plays through its (every stage) cycle even if the key or pedal is released before reaching the Sustain stage.
 
FR-SUS 
Free - sustain
 
SUSREL 
(Sustain-Release) envelope mode merges Sustain and Release 1 stages.
 
MODTRG 
(“modulation trigger”) envelope mode is very similar in function to FRERUN, except that the envelope is triggered by a user selectable modulation source instead of the keyboard or other “note source” (the A6’s Sequencer, Arpeggiator, or a received MIDI Note).
 
Trigger Polarity 
 

You can choose between six types of trigger polarity
negative
bipolar,
positive
ABS negative
ABS bipolar,
ABS positive

NEGATIVE The trigger will occur only when the source is “moving in a negative direction.

BIPOLAR The trigger occurs when the LEVEL is reached but the source can be either increasing or decreasing in amplitude.

POSITIVE The trigger will occur only when the source is “moving in a positive direction.”

ABS: Absolute – the following polarities treat positive and negative LEVEL settings as if they were all positive. Thus a value of -50 is treated the same as +50.


MOD-TG 

 (“modulation trigger-gate”) envelope mode is very similar in function to the NORM 1 mode, except that the envelope is triggered by a user selectable modulation input instead of the keyboard.
 

<PAGE>
TRIG  vs RETRIG 
Not only are envelopes triggered, they can also be configured to be re-triggered.
Use soft knob 8 to toggle between the TRIG page and the RETRIG pages of parameters.






 DYN Page Parameters 

The DYN or Dynamics functions permit you to modulate certain parameters of an
envelope “live” or as you are playing the A6. 
 
Access this page with soft button 4.

 
The parameters are
RESET - Normal, Legato, Re-assign, Analog (Soft knob 1)
              Determines what the envelop will do when new notes are played.
              Normal will always reset the note from the beginning.
              Legato will always maintain the current envelope stage, where-ever it may be.
               RE-ASSIGN …the envelope will behave as in Legato mode, with the exception
               that if the voice is being reassigned from a different Program in a Mix, it will
               continue on from the present stage according to the new Program's envelope.
               ANALOG …the envelope will start its attack stage from the present level, 
               not necessarily zero.
SUSPDL - Sustain Pedal Control (Soft knob 2)
                Turns Sustain Pedal control on and off for the envelope.
KEYTRK - Key Tracking (Soft knob 3)
                  adds and subtracts decay & release times depending on the Note Number 
                  that triggered this envelope.
KTBASE - Key Tracking Base Note (Soft knob 4)
                 sets the midpoint between the range of notes where adding time
                  to the envelope and subtracting time occurs.
LVLTRK - Level Tracking (Soft knob5)
                  You can alter the  overall output level – of the selected envelope
                   by the Note Number that triggered this envelope.
VELMOD Level Velocity Modulation (Soft knob 6)
                   You can alter the  overall output level – of the selected envelope
                   by the Velocity of the key that triggered this envelope.
RELMOD Release 2 Modulation (Soft knob7)
 
These parameters relate to how you are playing.
If you play short notes ... its called STACCATO.
Long smooth notes that blend into each other is called LEGATO.
Velocity relates to how fast or slow the key is pressed.

LOOP Page Parameters

Each of the three envelopes has the ability to loop – repeat selected stages over and over. 
The parameters in the Loop page allow you specify how the loop behaves.
 
Access this page with soft button 5.  

This is a great feature.
The envelope can be made to behave a bit like an LFO.
 

There are three conditions.
1.When it starts (eg you can set the envelope to start looping when 
    the DECAY 2 stage is complete)
2. Where it starts (eg which stage?)
3. How it continues. (eg does it repeat, and for how many times)

The page parameters are:
Start
End
Count - This parameter determines how many times the selected envelope will loop
Type (forward, reverse, rock-n-roll)
Smooth
SSshape - selects the slope (EXP/LOG 1, 2 & 3 and SCURV1 & 2)
 

SHAPE: Selecting the Stage Slope

Each time parameter of an envelope (except Delay) has a user-selectable property called slope. 
This term refers to how the attack, decay and release stages accelerate (speed up) or decelerate (slow down) as each stage approaches its target level.
 
The slopes can be 
1. Linear (Rising or falling)

 
 
 
 
 
 
 

2. Exponential 1 (Rising or falling)
    Exponential 2 (Rising or falling)
    Exponential 3 (Rising or falling)
 
3. Logarithmic 1 (Rising or falling)
     Logarithmic 2 (Rising or falling)
     Logarithmic 3 (Rising or falling)
 
 
 
4. S-Curve 1 (Rising or falling)
    S-curve 2  (Rising or falling)
   
The Attack, Decay and Release stages can have different slopes. 
You can mix and match slopes any way you want within the same envelope.


 MOD Pages

 In addition to the modifications offered by the TRIG and DYN pages, 
each envelope can be modulated by any of the A6’s 71 mod sources. 
 
 
In fact, three separate mod paths can be created per envelope from the
three MOD 1, MOD 2 and MOD 3 pages.