Synthesizer!

Love Legowelt, but this video is too funny to pass up! The full studio tour is an interesting watch (assuming you’re into that kinda thing).

How to fix intonation problems on a fixed-bridge biscuit resonator guitar or: How I Learned to Stop Worrying and Love the Eastwood Airline Folkstar.

Hear ye, hear ye my tale of woe and redemption concerning the Eastwood Guitars Airline Folkstar.

So there I was lusting after a resonator guitar and came across this interesting specimen online, and found a shop that would sell it to me for a more than seemingly decent knock-down price.

Being the innocent lad (and mostly because I was drunk – both with enthusiasm and literally), and having read the positive reviews, I poked-in my credit card details and took the punt.

Sure enough, next day the package arrived.

First-off, what a beauty!. I can’t deny that the look of this guitar contributed to my lust. Buying on the internet and all that.

IMG_20170318_233015

My camera can’t do better than the stock photos above, but it’s quite dazzling in real life. Closer inspection did reveal some rather surprising construction flaws, however. Doubts creep in.

Sound-wise: Long story short, when plugged-in to an amp this guitar sounds wonderful. Mixing between the Humbucker and the Piezo pickups with the blend knob produces a huge range of tones, from chugging rock, jazz and the high-frequency zing of delta blues. Played with a slide in open D tuning, and with a touch of overdrive and reverb – great fun.

Plugged-out it retains the bluesy vibe with a touch of banjo, which sounds pretty nice, isn’t too loud, and yet entices to fondle.

HOWEVER….

…although the guitar seemed to be well setup out-of-the-box, and according to these instructions, it was immediately obvious to my uncultured bony ass that the intonation was waaaaay off.

Essentially, although the open strings are tuned correctly, moving up the fretboard caused notes to become progressively sharper. At the 12th fret the 3rd string is a full semitone sharp when fretted (harmonic is OK though), and it doesn’t sound good. I re-checked the neck and action (which is low anyway), I tried different strings and angled the bridge as much as possible…

No joy.

No matter what, the strings always sounded sharp up the fretboard, and some more than others. OK then, onward to Google, the chief answerer of all these periodic inane questions.

What I found online was mostly guitar-geek forum posts where opinion lazily conceded that resonator guitars were always destined to sound a little out of tune at the higher frets (due to high action), and that intonation problems on fixed-bridge guitars are generally intractable without the surgical intervention of an experienced luthier.

The construction flaws I can live with, the intonation problems not. Do I send it back for a refund?

Being a stubborn bastard and not wanting to give-up, I did take it to a luthier. After less than 30 seconds of inspection he sighed and gave that disappointed look of ‘poor child, what a dumbass’.

But even this didn’t calm my hubris. Why? Because Youtube always comes to the rescue!:

[youtube https://www.youtube.com/watch?v=8qq451ZXoDg&w=400&h=255]

Paco’s brilliantly simple solution rang a bell, flashed a light, and struck a chord. I would try this.

And indeed it works! Instead of the metal screws used by Paco, I wanted to use something softer to avoid possible fretboard damage. A quick dig around my junk stash came up with using only the plastic parts from header pins. Just cut to size and yank out the pins. Comes with a complimentary built-in string notch!

IMG_20170319_030228

IMG_20170318_232945

IMG_20170318_232940

And there you go, a quick ‘n easy way to fix intonation on any fixed-bridge guitar. Thanks Paco!

One minor, concern is that these ‘floating nuts’ will move when bending, so periodic checks and readjustments are advised. None needed here so far.

This is not to excuse the poor quality control at Eastwood. Judging by the the adjustments needed, the guitar seems to have some fundamental issues and thus it will sent back. Shame really.

Using a Raspberry Pi as USB MIDI Host

Wheeeeeeeee! I have some money again, though not a lot of time, but I’m determined to finish and further expand the projects I started with such gusto last year.

Both the Tempest and FS1r are blurred memories, and I’ve been getting my kicks, whenever possible, with a Monomachine/Blofeld Combo.

The great thing about this pairing is that I can sequence 6 channels of Blofeld multimode goodness alongside 5 Monomachine tracks, with the 6th track acting as the FX machine for the Blofeld, which is routed back through the MnM inputs. A nice, self contained, and gloriously digital setup. Did I mention that MnM does killer drum synthesis?

RPi_USB_MIDI_Host_MnM

On the the MnM it is possible to input chords using an external MIDI keyboard for the Arps and external sequencing.

I have an cheapo Akai LPK USB mid keyboard that would make a nice compliment to this mini setup. But MnM only accepts 5-pin DIN MIDI. One existing option is the Kenton USB MIDI Host, but that goes for over 100 euro.

I got to thinking that I could use my similarly-abandoned and superseded Raspberry Pi 1, and a MIDI 1×1 USB MIDI cable that never got used because it kept causing bluescreens on my Windows PC. What if I could use the Pi to route the output of the LPK through the 1×1?

Well yes, it’s possible, works perfectly, and is really easy to get running.

Any flavour of linux will do, in my case I’m using a Raspberry Pi v1 with an optimised Raspbian Wheezy image I downloaded from here. I’ve also got this to work on a Rpi2 using the official Ubuntu ARMv7 distro.
The instructions for both are the same.

EDIT: Georgios Says:

By the way, on the latest raspbian, it works out of the box. No need to install anything 🙂

Obviously, with only 2 USB ports on the Pi v1, there is no room for wireless, so I needed to login over ethernet.

Once a command prompt is available, it’s a matter of installing Alsa:

sudo apt-get install alsa alsa-utils

Now connect the *class compliant* MIDI devices, in my case the Akai LPK25 and E-mu USB MIDI 1×1.

To show all connected MIDI devices:

sudo amidi -l

Show connection status and port numbers of connected MIDI devices

sudo aconnect -i -o

Look for the device ID, which is in the format x:0. In my case, the LPK25 was 20:0 and the Emu 1×1 was 16:0. So to connect the output of the LPK to the output of the Emu, just go:

sudo aconnect 20:0 16:0

…and voila! Works a treat here, no latency and I’ve sent boatloads of MIDI through it.

To dump all midi message to the screen,
sudo amidi -d

Naturally, we will want this connection to happen automatically every time we start the Pi. Of the several ways to do this, I opted for the laziest, which was to make a root crontab.
If you’re not root already,

sudo su
crontab -e

at the end of the file, enter the aconnect command that works for you to run at reboot, e.g.

@reboot aconnect 20:0 16:0

🙂

Bjorklund: First Session – Simple Rhythms

Here’s Bjorklund. He’s been dropped, stood-on and attacked by cats, yet survives. I was pissed drunk when I made this but hopefully it will provide a first inkling of the little fella’s potential:

[embedyt] https://www.youtube.com/watch?v=xupqW1Cyig8[/embedyt]

Blurb:

Euclid’s algorithm (circa 300 BC) describes a method for computing the greatest common divisor (GCD) of two integers. It is one of the oldest numerical algorithms still in common use.

In 2003 Eric Bjorklund extended the Euclidean algorithm to address timing issues in Neutron Accelerators. He wanted to solve the following problem:

‘distribute n pulses over m “timing slots” in the most even way possible, even though n may not necessarily be an even divisor of m.’

See: https://ics-web.sns.ornl.gov/timing/Rep-Rate%20Tech%20Note.pdf

In 2004, Godfried Toussaint demonstrated that the resulting binary patterns mirrored many familiar ostinatos (repeating rhythmic phrases) heard in diverse range of musical styles.
African rhythms are well represented and, naturally, have since appeared in South American music, modern jazz, pop, rock and dance.

See: http://aatpm.com/banff.pdf

Bjorklund is a Bjorklundean sequencer.

8 independent tracks, each with their own:

– Tracklength of 1- 64 steps
– 1-64 Pulses, feeding into the algorithm.
– Full control over current playback position (rotation).
– Clock dividers (Whole note to 1/32 ).
– Solo/Mute.
– Velocity.
– Random Velocity offset – Humanisation (+/-)
– Accented notes every 1-16 steps (max velocity)
– Assignable MIDI Note.
– Assignable MIDI Channel.
– Randomization per track or all tracks.

Fine control over Master BPM (+/- 3, 1, 0.1).

Next version will bump-up to Teensy 3.1 and will feature…
USB MIDI
Performance Controls
Groove – Tick Quantization and Tick shift
Extensive preset management and fast switching
Track groupings
Touchstrip
Proximity sensors/D-beam
Tap Tempo

Apologies for the shitty video quality. But does it matter?

Bjorklund: Hardware Notes

I’ve got the beer on ice, so tonight I will make a video demonstration of the finished item, and it has far surpassed my expectations! 🙂

Some quick snippets…

But first, here’s a catch-up on construction and materials used. Rather than explain in minute detail each step, I will for now just point to the resources that provided the most direct and useful information. They are the nuggets gleaned from numerous trawls through crappy/broken code and bad schematics. :/

I keep the power supply on a separate board. It’s a common diode-protected, RC filtered 5v regulated design…

http://www.noisylittlebugger.net/diy/arduino/power-supply-5v.gif

MIDI output is easy-peasy…(but remember to map the pins of the ATMega)
http://www.noisylittlebugger.net/diy/arduino/arduino_MIDI_out_breadboard.png

The LED matrices are just too big for the breadboard, so I propped-them up on stackable headers to allow me access to the pins. I’m using 2 x MAX7219 driver chips. Connecting these to the ATMega and to each other was a breeze, however wiring the matrices themselves was a little tricky. I mostly followed the instructions here, however this wiring was not correct for my particular LED matrix (common cathode – from Tayda). I found the wiring diagram here to work for me.

bjorklund_view1

The encoders were connected and via the MCP23017 I/O port expander. I got these encoders from Reichelt – they are quite stiff and they have been problematic.

bjorklund_encoders

Firstly they wouldn’t stay on the breadboard (legs too short!) so I made a breakout. Those funny protrustions are my attempt at hardware ‘debouncing’. I soldered sockets to the pins so that I could experiment with different capacitor values. In the end, 100n capacitors connected between each pin and common ground were best, although the encoders were still somewhat jumpy. I used a healthy dose of contact cleaner on each and this helped significantly. These encoders need to be ‘broken-in’.

In the code I am polling these controls according to this helpful post. This works well but is quite the resource drain. To circumvent this I tried using interrupts, however they proved even more problematic because they were detecting even the slightest tap of the encoders. Also, setting-up interrupts via the MCP23017 is no trivial task. I managed to fry two chips for my troubles. Interrupts are for another day….

In the next version I will abandon the mechanical encoders in favour of optical. I think the additional cost will be more than compensated by time spent, in frustration, fixing a problem that is beyond my control.

Finally there is a RGB LED which provides instant access to 7 colours as menu indicators. I’ve coded a state machine that allows me to turn 4 encoders into 40 controls, depending on what sequence of buttons is pressed. The mode is indicated by the single-or-mixed colours of the RGB. Thus there is always a clear visual indication of which menu is currently in use.

bjorklund_view2

Overall, a fairly small parts count, easily obtained. Here is the Bill of Materials and sources:

Main Board:
1 x ATMega 328-PU
1 x 16MHz Quartz Crystal
2 x 22n Ceramic Capacitors
3 x 47K Resistors
1 x MCP23017 I/O Port Expander
2 x 8×8 Dot Matrix LED display – Common Cathode
2 x MAX7219 LED Display Drivers (Tayda’s are much cheaper, but apparently counterfeit. They work!)
4 x 24/24 Encoders (optical would be sooo much nicer)
10 x 100n Ceramic Capacitors
2 x 10uf Electrolytic Capacitors
1 x RGB LED 5mm Common Anode
3 x 220 Ohm Resistors
1 x 27K Resistor
Lots of jumper wire!

MIDI Output:
1 x MID DIN Socket
1 x 220 Ohm resistor

When I finish the code I will publish it, along with a proper schematic (hey, I’m still learning).

Bjorklund: The Algorithm in C

Read it and weep. I know I am 😛

This was the most challenging piece of code to date. Outwardly simple, and with many existing examples in other languages, not to mention the C code example in Bjorklund’s paper, it should have been a doddle to implement on the Arduino, right?

But no. I realised the big downside to using the AVRISP: no access to the serial interface, which makes debugging impossible. Thankfully I could use the Teensy 3.1 to test my Code. But this in itself brought heartache, as there were some library conflicts with Teensyarduino. A troubling story to be sure, but In brief, I battled through ’til dawn and eventually cracked the bastard.

My overriding concern was – how much of the ATmega’s CPU time would be taken-up by using recursive function? I would have expected this to be a resource hog, and I worried that it wouldn’t handle 8 tracks simultaneously, slowing everything down. I’m happy with the current state of the MIDI clock (99.98% accurate), and this was something I didn’t want to compromise. I also witnessed some talk on the forums about Arduino’s limited stack size.

In the end, performance wildly exceeded my expectations. See the example outputs below.

Note that I have reversed the order or the patterns in alignment with the examples in Toussaint’s paper. See chapter 4 for many more examples. An interesting read for sure.

In the end, the pattern directions don’t matter, because I’ve implemented track rotation and track reverse in the main application. So…

For 8 steps and 3 pulses, the pattern is:
10010010

Bjorklund took 8.00 microseconds.

Cuban tresillo / Habanera rhythm. “It can often be heard in early rock-and-roll hits in the left-hand patterns of the piano, or played on the string bass or saxophone. A good example is the bass rhythm in Elvis Presley’s Hound Dog.

The tresillo pattern is also found widely in West African traditional music. For example, it is played on the atoke bell in the Sohu, an Ewe dance from Ghana. The tresillo can also be recognized as the first bar of the ubiquitous two-bar clave Son given by [x . . x . . x . . . x . x . . .].

For 8 steps and 5 pulses, the pattern is:
01101101

Bjorklund took 10.00 microseconds.

Cuban cinquillo. Used extensively in jazz, 50’s rockabilly and West African traditional music. e.g hand-clapping pattern ‘Hound Dog’.

For 12 steps and 4 pulses, the pattern is:
100100100100

Bjorklund took 10.00 microseconds.

The 12/8-time Fandango clapping pattern. (I know, I know)

For 3 steps and 2 pulses, the pattern is:
011

Bjorklund took 5.00 microseconds.

E(2,3) = [x . x] is a common Afro-Cuban drum pattern. For example, it is the conga rhythm of the (6/8)-time Swing Tumbao. It is also common in Latin American music, as for example in the Cueca.

Lastly, a silly example to check performance again:

For 83 steps and 56 pulses, the pattern is:
01110110110110110110110110110110110110110111011011011011011011011011011011011011011

Bjorklund took 63.00 microseconds.

IMG_4240

This is going to be damn sweet.
🙂

Bjorklund: It lives!

I’m usually the one to grumble when I come across all those meaningless, grubby 20-second videos on Youtube. But today I’m adding my own. What the hell.

Here is Bjorklund just come to life:

[embedyt] https://www.youtube.com/watch?v=tJSJNcvy3vM[/embedyt]

At this moment I have a tight MIDI clock running on the ATMega328 at 24ppqn, with the option to go to a higher resolution if and when I trade-up to a better processor(Teensy 3.1 here I come!).

The 4 encoders and buttons are multiplexed using a single MCP2317, and the LED matrices are driven by 2 MAX7219s (both apparently counterfeit but working perfectly).

What you see are the available tempo divisions from slowest (each quarter note) to fastest (each MIDI tick) flashing across the screen.

I’ve come-up with an elegant way to deal with the note queues, rotation and sending MIDI. I can send notes on 8 tracks, remaining stable to master BPM of >300.  All Looking good so far!

All that’s left to do is implement Bjorklund’s algorithm and feed it’s output to the note queue.

Then finally the controls/menu system and that’s it! It’s all optimization from there. It seems the most challenging part is documenting the process, but I’m gathering my notes…

🙂

Bjorklund: Breadboarding an Euclidean sequencer using Arduino / Sanguino with AVRISPmkii in Win7 and Linux.

I should be wiring-up the 4x4pole, but here I am fiddling with breadboards. Suddenly got it into my head that I must build an Euclidean Rhythm based MIDI/CV sequencer. Bjorklund’s algorithm will be used:

The problem reduces to the following: construct a binary sequence of n bits with k one’ s, such that the k one’ s are distributed as evenly as possible among the zero’ s. If k divides evenly (without remainder) into n, then the solution is obvious. For example, if n = 16 and k = 4, the solution is [1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0]. The problem of primary interest is when k and n are relatively prime numbers [23], i.e., when k and n are evenly divisible only by 1.

Toussaint discovered (only in 2004!) that the resulting patterns of spaced pulses often represent the rhythms of many word music styles. This presents a simple way to generate new and interesting drum patterns.

There are already other Euclidean generators out there, and even one in the MIDIbix Seq4, but I have my own nascent ideas, even if I only a little knowledge on how to implement them. Another distraction! 🙂

The logical conclusion to this effort should be a PCB for a unit that can act as a standalone MIDI/CV sequencer in a box, and one that is small enough to be integrated into a Eurorack setup. After some research I decided to start with Arduino. It comes with MDI libraries as standard, and already there are lots of interesting projects out there to reference.

In keeping with the DIY philosophy, I forewent the purchase of an Arduino board and instead opted to set-up a development environment using ATmega microcontroller and the Arduino libraries: – essentially to create an Arduino clone on a breadboard.

I am using the ‘standard’ Arduino chip – the ATmega328p (used in the MIDpal). As I had a spare ATmega644 (used in the Shruthi-1), I decided to breadboard it as well. The 644 is not officially supported by Arduino, however there is an Arduino-compatible bootloader called Sanguino.

IMG_4218

There is plenty of information out there on how to breadboard these chips. The most useful video I found was this one from Notes and Volts, which helped me setup the 328p in no time.

[youtube https://www.youtube.com/watch?v=ufQZnAAxZ7A&w=400&h=255]

In the process, the concept and function of the pins became clear, and I could easily map the ATmega pins to their Arduino equivalents using the following diagram:

atmega328-pinout

For the 644 I used this reference and this pinout diagram:

atmega644-pinout

Once hooked-up, I needed a way to program the chips. Fortuitously I had an Atmel AVRISPmkii to hand. I bought this to program my Shruthi chips and used it for all of 5 minutes a few years ago.

avrispmkii

There are some issues to watch out for when using the AVRIPSMKii with Arduino:

  • The various sources I referenced all used a 10K pull-up resistor on the reset pin, however for the AVRISPMkii to work properly, this pull-up resistor must not have a value higher that 4.7KOhm. See P26 of this document.
  • In Win7, the Atmel USB driver conflicts with the Arduino IDE. A different driver must be installed. Full details here.
  • On Linux, the toolchain and associated libraries need to be installed. Further, to get the Arduino IDE working, the correct USB device permissions must be set specifically for the AVRISPMKii. This is achieved by updatinbg the UDEV rules. See P12 of this document. Note: I had to use ATTR{idProduct} instead of SYSFS{idProduct}.
  • If using avrdude we must always specify that we are using the the port (-P usb). See the tutorial here.
  • A green status LED on AVR indicates that connections are good. With the AVRISP, the board MUST be separately powered (5v) in order for the AVR to detect and program the chip.

OK, so after overcoming the AVRISP driver issues, the next task was to set the fuses and install the Arduino boatloader onto the virgin chips. This requires hooking-up the AVRISP to the correct Arduino/Sanguino Pins. Referencing the pinout diagrams above, making the connections is an easy task, but one that must be approached slowly.

Referencing the AVRISPmkii pinouts:

avrispmkii_pinout

Just to be clear, this is pin 1:

IMG_4210

I made a little breadboard adaptor for it…

IMG_4176

IMG_4178

Ending-up with something like this:

IMG_4197

After triple-checking the connections, I fired-up Arduino IDE. After many failed attempts, I was still not able to bootload the damn things. Attempts at querying with avrdude always returned the following error:

avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.

A web trawl suggested that this was due to the crystal not oscillating. Switching-out the crystal and trying instead a 16Mhz resonator returned the same error.

As it turned out, the default avrdude transfer speed is too fast for the virgin chips, therefore it’s necessary to adjust the baudrate (-B option in avrdude) to allow the initial communication. I didn’t realise this until after I solved it, and this was the problem that soaked-up most of my troubleshooting time. Bah!

The desperate answer in my case was to install Atmel AVR studio 6.2 – an overly torturous and bloated product (1.5Gb install), but one that bore immediate results when following this blog post.

Later, I realised that I could have done this much more quickly with Linux, and without the need for that massive Atmel install. Here are the required commands (Ubuntu).

Now fire-up Arduino IDE. No serial port is recognized on the AVRISPMKii, therefore trying to upload a sketch will return a ‘no Com port‘ error. It took me a few minutes to figure-out that you must instead ‘Upload using Programmer’ i.e press shift when sending the sketch (or just  cntrl-Shift-U). Also, it’s important to ensure you are uploading to the correct board type in the Arduino IDE (Arduino UNO vs Sanguin 644).

I attached a MIDI out port and an LCD, loaded-up a simple MIDI sketch to test it.

IMG_4206

It worked first time. A great start!

Next steps will be to wire-up some pots and buttons, and start writing the code.