Tuesday, November 3, 2015

Sooperlooper


I have been playing with SooperLooper, a pretty cool and simple looper application for Linux and Mac. I use ubuntu and installation there is simple, it is available in the software center if you use the gui or with sudo apt-get install sooperlooper if you are more hardcore. The application has 2 parts, a GUI and the server which communicate with each other using OSC, the standard aiming to replace Midi. You can run the server only with the command sooperlooper and you can run the GUI+server with slgui

My first tests were done with the GUI. You need to run slgui and make the right connections in JACK. I use QJackCtl and this are the connections I set up for redirecting audio input to slgui capture and its output to the audio output:



I am interested on running the looper headless, so I have been investigating on how to send OSC commands from the command line. I installed pyliblo-utils: sudo apt-get install pyliblo-utils which adds a tool called send_osc and dump_osc to send and receive OSC messages. Once I did that I opened 3 terminals running the following things on each:

Terminal 1: run sooperlooper (without GUI), this is listening OSC commands in port 9951 by default
Terminal 2: run dump_osc to receive OSC commands at port 9952: dump_osc 9952
Terminal 3: this is where things get interesting:
First I run the ping command:
send_osc 9951 /ping osc.udp://localhost:9952/ osc.udp://localhost:9952/
And I get the following in Terminal 2:
osc.udp://localhost:9952/ ,ssi osc.udp://berenjena:9951/ 1.7.0 1

then I tried other commands from the sooperlooper documentation here.

Next steps: I might think of a way to interface sooperlooper from a keyboard by converting keystrokes to OSC. I also would like to see how it performs in a raspberry pi (EDIT: Seems like someone has been having similar thoughts: http://journeytounknownsoundscapes.blogspot.com.es/2015/05/a-new-looper-in-town-raspberry-pi-with.html?view=classic )

Tuesday, September 22, 2015

Kula6: Schematic mistake

From the beginning of this project I had a mistake in my schematic that I was too embarrassed to recognize. My AVR ADCs were not working!!! I originally thought that I had somehow broken my processor, but turns out that I was wrong. If you see my schematic in this post you will notice that the AREF is connected to ground... wrong!!! it needs to be connected to VCC (or whichever is your reference for the analog signals). Here is a picture of how the connection should be:

 
I actually added a 100nF capacitor to ground also, which is not pictured in the schematic.

I was only planning on using the ADC for debug purposes, don't have much plans on using it on the final result, but it was frustrating that I could not get it to work.

And here is the code to read from the ADC connected to ADC0 in pin40:

#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdio.h>

void adc_init()
{
 // Select Vref=AVcc
 ADMUX |= (1<<REFS0);
 //set prescaller to 128 and enable ADC
 ADCSRA |= (1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0)|(1<<ADEN);
}


uint16_t adc_read(uint8_t ADCchannel)
{
 //select ADC channel with safety mask
 ADMUX = (ADMUX & 0xF0) | (ADCchannel & 0x0F);
 //single conversion mode
 ADCSRA |= (1<<ADSC);
 // wait until ADC conversion is complete
 while( ADCSRA & (1<<ADSC) );
 return ADC;
}

int main(void)
{
    adc_init();

    DDRC |= (1<<0);     //Set PortC Pin0 as an output
    PORTC |= (1<<0);        //Set PortC Pin0 high to turn on LED

    _delay_ms(500);
    PORTC ^= (1<<0);

    while(1) {
        uint16_t adc_result0 = adc_read(0);      // read adc value at PA0

        if(adc_result0>512) {
            PORTC |= (1<<0);
        }
        else {
            PORTC &= ~(1<<0);
        }

        _delay_ms(500);
    }

    return 0;
}

Sunday, August 30, 2015

Kula6: Midi IO

I have extended my platform to include midi IO, a button and a potentiometer. Here is the schematic of my platform as it is now:


And this is how the board looks:



The code it is simple, just takes Midi input, buffers it and sends it to the output. The purpose of the code was just to test that the hardware was OK.

#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>


unsigned char data[256];
int readPtr = 0;
int writePtr = 0;
int elements = 0;

#define BAUDRATE 31250
#define UBRR 5

void uart_init(int baudrate)
{
  // calculate division factor for requested baud rate, and set it
unsigned short bauddiv = ((F_CPU+(baudrate*8L))/(baudrate*16L)-1);
UBRRL = bauddiv;
#ifdef UBRRH
UBRRH |= bauddiv>>8;
#endif

    UCSRB = ((1<<RXEN) | (1<<TXEN) | (1<<RXCIE));   // Enable Receiver, Transmitter, Receive Interrupt
    UCSRC = ((1<<URSEL) | (1<<UCSZ1) | (1<<UCSZ0));     // 8N1 data frame
}

void uart_putc(unsigned char c)
{
    // wait until UDR ready
    while(!(UCSRA & (1 << UDRE)));
    UDR = c;    // send character
}

ISR(USART_RXC_vect)
{
    unsigned char c = UDR;

    data[writePtr] = c;
    writePtr++;
    elements++;
    if(writePtr == 256){
        writePtr = 0;
    }
}

int main(void)
{
    //Setup the clock
    cli();            //Disable global interrupts
    uart_init(BAUDRATE);
    sei();            //Enable global interrupts

    while(1){
        if(elements > 0){
            uart_putc(data[readPtr]);
            readPtr++;
            elements--;
            if(readPtr>=256){
                readPtr = 0;
            }
        }
        else {
            _delay_ms(10);
        }
    }
    return 0;
}

Thursday, June 11, 2015

My new project: Kula6

So I have started a new project... as usual for a procrastinator like me without finishing the previous one (cloudClock).

I checked my suitcase full of components to find that there were plenty of parts which I had bought and never used. I had Atmega32, DACs, PT2399 digital delay chip, ssm2164 VCA chip... so I had to do something with all that, what? definately something noisy!!!

So far my thought is doing a 6 voiced paraphonic synth with square wave oscillators and frequency dividers to get an organ type sound but with a cool 24dB/oct VCF to give it a cool synth sound. Well, that is the idea, we will see what I come up with, experimentation is the key this time. The name: Kula6, why? why not... 

Anyway, so I started with the power supply: a bipolar power supply with +/- 12V and 5V outputs and the basic circuitry for the Atmega32. I added an LED on one of the Atmega outputs for testing the usual blinky LED example. Schematic here:


And the code for the blinky LED, from hackday:

#include <avr/io.h>
#include <avr/interrupt.h>

int main(void)
{

  //Setup the clock
  cli();            //Disable global interrupts
  TCCR1B |= 1<<CS11 | 1<<CS10;  //Divide by 64
  OCR1A = 15624;        //Count 15624 cycles for 1 second interrupt
  TCCR1B |= 1<<WGM12;     //Put Timer/Counter1 in CTC mode
  TIMSK |= 1<<OCIE1A;        //enable timer compare interrupt
  sei();            //Enable global interrupts

  //Setup the I/O for the LED

  DDRC |= (1<<0);     //Set PortC Pin0 as an output
  PORTC |= (1<<0);        //Set PortC Pin0 high to turn on LED

  while(1) { }          //Loop forever, interrupts do the rest
}

ISR(TIMER1_COMPA_vect)      //Interrupt Service Routine
{
  PORTC ^= (1<<0);        //Use xor to toggle the LED
}

And this is how my prototype board looks like:



Thursday, January 1, 2015

cloudClock: ArduinoJson or python json

I am planning on having all data from the cloudClock stored in files in json format, so I looked for a json library for arduino. I found ArduinoJson, downloaded it, imported the library in the arduino 1.5 IDE and... not working... it complained about missing core-dependencies. Some research and I found the file:
~/Arduino/libraries/ArduinoJson/library.properties

Which has the following content:

name=ArduinoJson
version=4.0
author=Benoit Blanchon <http://blog.benoitblanchon.fr/>
maintainer=Benoit Blanchon <http://blog.benoitblanchon.fr/>
sentence=An efficient and elegant JSON library for Arduino
paragraph=Supports JSON parsing and formatting. Uses fixed memory allocation.
url=https://github.com/bblanchon/ArduinoJson
architectures=*

I had to add the lines in red bellow to the file to get the library to work in the arduino 1.5 IDE:

name=ArduinoJson
version=4.0
author=Benoit Blanchon <http://blog.benoitblanchon.fr/>
maintainer=Benoit Blanchon <http://blog.benoitblanchon.fr/>
sentence=An efficient and elegant JSON library for Arduino
paragraph=Supports JSON parsing and formatting. Uses fixed memory allocation.
url=https://github.com/bblanchon/ArduinoJson
architectures=*
core-dependencies=
dependencies=
email=

After much thought I decided to leave the responsibility of parsing json to python scripts running on the linino side, so that arduino would just call the python script and read its stdout. I will be uploading my scripts to github at some point.