Thursday, January 29, 2015

Building a Joystick Controller


Recycling old joysticks for synths.

I modified this old joystick controller to give me an X-Y control over some of my synth parameters. I use this a lot with my MS-20 where X controls High Pass and Y controls the lowpass. This project is super easy to build and these old joysticks are generally pretty cheap on ebay or thrift stores. 


Details:
  • IN - Any input signal. You can feed in straight DC signal or output from an LFO. You can even use it a just a simple attenuator since thats really all it its.
  • X- the x axis output
  • Y- the y axis output
  • B - Black button output
  • R - Red button output
Things needed:
  • An old analog joystick
  • 2 resistors
  • A small breakout box. (easy found at radio shack)
  • A soldering iron.
The operation of IN, X, and Y should be obvious. B and R are just like triggers. They send 0 volts out until the button is pressed and then emits what your receiving on the IN. This works pretty well but i need to replace the switches on mine. They are old and don't work so well.


Here is how to rewire it (the header on the right represents the striped end of the joystick controller):
  1. Cut off the connector end of the joystick and strip the wires out.
  2. Find the wire that will be your IN. This is usually a red wire and would have previously been wired to the power pins. You may need to use a volt meter to find this. The Power wire will be wired to one end of both of the joystick pots and the GND will be wired to the other end. Center pins of the pots are the outputs.
  3. Find the Ground wire. This one is usually black.
  4. In your breakout box start connecting the Ground wire is on the sleeves of all the jacks in your breakout box.
  5. Wire each jack's tip to the proper wire as shown above.
  6. I added two 100k Resistors to the inputs of each button (this could be anything really. I just had them laying around though 1k would be better i guess). These are solely to ensure that the IN does not go to ground for any reason when the buttons are pressed. Wire them as in the diagram below.

Mine looks like this:

The big green wire above connected to the resistors is  added by me  to bridge the IN wire back around to these resistors. The IN (red) wire is connected to one end of both potentiometers in the joystick controller.


That's pretty much it!. 


Here is how it sounds. Button pressing changes the pitch so that it sounds kinda like an arpeggiator. X and Y are connector the the CVs of the High and Low pass inputs.


Wednesday, January 28, 2015

BitCrushing with the Arduino

Now that I have the previous examples working fairly easily its time to do some more interesting effects with the Arduino due. Time to make a bit crusher! This blog will be all about downsampling the input signal in real time. This creates an effect called aliasing. Aliasing happens when then audio frequency being processed is below the Nyquist rate. It creates really grainy distorted sounds. I personally love this effect. I like digital effects that try to sound digital but hate digital effects that try to sound analog.


Here is the code:


#define MAX_ADC_RESOLUTION 12 void setup() { // Serial.begin(9600); REG_ADC_MR = (REG_ADC_MR & 0xFFF0FFFF) | 0x00020000; analogReadResolution(MAX_ADC_RESOLUTION); // analogWriteResolution(MAX_ADC_RESOLUTION); //adc_init(ADC, SystemCoreClock, ADC_FREQ_MAX*2, 3); pinMode(ADC0,INPUT); pinMode(DAC0,OUTPUT); } void loop() { int value = sampleAndHold(analogRead(ADC0), lfo()); analogWrite(DAC0, value); } int i=0; int hold; int sampleAndHold(int input, int holdTime){ if(i==0){ hold=input; i++; }else if(i < holdTime){ i++; }else if(i >= holdTime){ i=0; } return hold; } int _lfo=0; int wait=0; int lfo(){ if(wait==0){ _lfo++; wait++; if(_lfo >= 500){ _lfo=0; } }else{ wait++; if(wait >= 1000){ wait=0; } } return _lfo; } Above a created a really simple sawtooth LFO to change the sample rate time. This controls the rate of the sampleAndHold function that basically stores and replays previous samples until the holdTime is reached. Once the holdTime is reached it samples again and will continue replaying the new sample. Here is what it sounds like:

Tuesday, January 27, 2015

Arduino Due Audio Tests


I have had this Arduino due for a while and have wanted to make a music project out of it. It has been hard to find any really good examples of using this thing for audio. I finally found these few sites that have helped me speed up the ADC conversions so they are good for audio.

http://forum.arduino.cc/index.php?topic=156849.0

http://www.djerickson.com/arduino/


So from those two posts I was able to build these two projects and I'm overall impressed with the results:


Simple Audio Delay with Feedback

Note that the ADC's only track ~0-3V and most audio signals go negative  (example: -1V to 1V). You will mostly likely need to add a DC offset to your input to avoid clipping the signal. (cutting off the lower half of the waveform). You can do this in many of different ways. I happen to have some modular synth gear and one module in particular is the MATHS by Make Noise. I use this to amplify and offset the input signal. In a later post I might build a circuit to perform the DC offset. They are very simple but right now I want to just do some simple tests without spending too much time if it sounds terrible. For now here is an image of a DC offset amplifier:






Here is the code to create a very simple audio delay with feedback using the Arduino Due. Not all of this code will run on other Arduino's as they might be to slow or not have enough memory and setting of the ADC registers is specific to this version.





#define MAX_ADC_RESOLUTION 12 #define L 20000 int array[L]; // audio buffer to store previous input levels. This makes the delay line. int p=0; int d=0; void setup() { Serial.begin(9600); REG_ADC_MR = (REG_ADC_MR & 0xFFF0FFFF) | 0x00020000; analogReadResolution(MAX_ADC_RESOLUTION); analogWriteResolution(MAX_ADC_RESOLUTION); adc_init(ADC, SystemCoreClock, ADC_FREQ_MAX*2, 3); pinMode(ADC0,INPUT); pinMode(DAC0,OUTPUT); } void loop() { int value = analogRead(ADC0) + array[p]; analogWrite(DAC0, value); array[p++]=value>>1; // bit shift to fade out over time if(p > L) p=0; }
Here is an example of what it sounds like. Not bad but there is a lot of room for improvement. The noise is the first issue that needs to be addressed. I found that this comes from the delay line and I will most likely need to add some type of filter to overcome this.



If you take the loop function above and change it to just the following code then this will simply pass the signal through without modification. Notice that the signal output is much cleaner.






void loop() { int value = analogRead(ADC0); analogWrite(DAC0, value); }
In my next post I will try to clean this up. But for right now this at least gets me started.

LFO for CV Control 

The below application uses a potentiometer on A0 to control the speed of the LFO. One end of the pot is tied to the 3.3 V header, center is tied to A0, and the other end is tied to GND. This is just a test as this is a terrible CV controller since the output only goes to about 3 volts while most CV signals can get up to 10 volts. I may try to put an amplifier on the end to get the voltage to real CV levels.

 








#define MAX_ADC_RESOLUTION 12 void setup() { REG_ADC_MR = (REG_ADC_MR & 0xFFF0FFFF) | 0x00020000; analogReadResolution(MAX_ADC_RESOLUTION); adc_init(ADC, SystemCoreClock, ADC_FREQ_MAX*2, 3); pinMode(DAC0,OUTPUT); pinMode(ADC0,INPUT); } int i=0; void loop() { int val = analogRead(ADC0); analogWrite(DAC0, sinx(val)); } float sinx(int skip){ float x = (125.0*sin(2*PI*i/90000.0))+125.0; // 125.0 is my DC offset. You need to get the sine wave so it does not ever go negative or it will clip i=i+skip/125+1; // The 125 in this skip is arbitrary and not at all related to the dc offset. if(i >= 90000) i=0; return x; } Below is the board i use for these projects:
Arduino Due

Thursday, January 15, 2015

Hello World

Welcome to lolofi. This blog will be my site for archiving DIY kits I've built for my own modular synths and guitar effects. These rage from simple electronic circuits with just one or two chips to some Arduino audio projects I've put together. There are a few circuit bent projects I use as well. This site will mostly archive those projects cause I've been terrible at keeping up with my own notes and research in my journals.

Let me explain where I'm coming from when it comes to making music. I like to experiment. I've been striving to create a tone and layering of sounds that is unique. I care far less about a player's ability than how they put the pieces together. A song with 3 chords can be more inspirational to me that someone that can play overly complex arrangements without a glitch. I also tend to like music that is not overly produced and you can hear the imperfections. No auto-tune for me!

My current setup involves a few modular synths, analog and digital drum machines, an arsenal of guitar pedals, feedback loops, and some software that lets me do almost infinite guitar loops live. I'll share more about this set up later since several of the effects I use are all DIY and can be built in a few hours at most with very little electronics background.