littleBits for audio mods?

Here are a few experiments testing littleBits audio post-processing. In the first few cases, audio is produced by a Yamaha SHS-500 synthesizer fed into the LINE IN of a littleBits Microphone module. Outgoing audio is sent through a littleBits Speaker module connected to an external amplified speaker.

I did not draw the littleBits Power module into every example circuit. If you’re experimenting at home, hey, “One, Two, you know what to do…”

The first circuit filters incoming audio:

          PowerSnap 
|
V
Envelope <-- Button <-- PowerSnap
|
V
Mic --> Filter --> Speaker

The Filter modulation input is driven by a littleBits Envelope module. The (audio) input of the Envelope is connected to a littleBits PowerSnap which supplies a constant +5 Volts to the input of the Envelope. A littleBits Button module is connected to the Envelope’s trigger input. (The second PowerSnap assures a full 5 Volt ON signal through the Button.) The Envelope sweeps from 0 to 5 Volts when the Button is pressed. Of course, the Envelope is shaped by its attack and release settings.

The first circuit operates successfully. The audio is filtered according to the Filter’s cut-off and resonance settings. The Filter quacks (a very scientific term!) when the Button is pushed.

The second circuit replaces the Button with a littleBits Pulse module:

          PowerSnap 
|
V
Envelope <-- Pulse <-- PowerSnap
|
V
Mic --> Filter --> Speaker

The Pulse module repeatedly sends a trigger signal to the Envelope module. The triggers cause the Filter to quack correctly. However, there is an audible click when the Pulse module fires — even if no audio is playing. This noise is unacceptible and I don’t know why it is occurring. Power glitches perhaps?

At this point, I began experimenting with the littleBits Threshold module. The (third) simple test circuit below:

    Power --> Dimmer --> Threshold --> Number

demonstrated that my intuition about the Threshold behavior is correct: when the voltage into the Threshold exceeds the threshold setting, the Threshold turns ON and outputs +5 Volts. When the input voltage falls below the threshold setting, the Threshold output turns OFF (0 Volts).

Testing tip: The Number module has a “Voltage” setting in which Number displays the incoming input voltage. You can use a Number module as an in-circuit volt meter.

Given that, I couldn’t determine why the Threshold was not acting like a gate generator when driven by a littleBits audio signal, i.e., driven by the Microphone module in its “Sound” setting. Turns out, the littleBits Microphone module converts the incoming LINE IN signal into its own notion of audio — a signal centered around 2.5 Volts. I connected a Bargraph (or Number) module to the output of Microphone, and indeed, the Microphone sends 2.5 Volts when the audio is silent.

Arg! Once again bitten by the lack of signal documentation! When the Microphone is in its “Other” setting, it converts the input signal to swing from 0 to 5 Volts. Bad news, however. The Speaker module expects audio in the 2.5 Volt centered, littlebits convention and it distorts like a bandit when driven with the “Other” setting.

The 2.5 Volt convention also explains why some folks have observed only a 2.5 Volt sweep in the Envelope output. All of this has serious implications when mixing audio and control signals in littleBits. I need to think about this for a while…

The fourth test circuit demonstrates filtering of regular line level audio:

                              Powered Speaker 
LINE IN
|
Power --> Proto --> Filter --> Proto
|
Synthesizer
LINE OUT

This circuit filters incoming audio. Fortunately, the 2.5 Volt convention does not preclude a simplified signal chain, that is, a chain omitting the littleBits Microphone and Speaker modules. A filter is a filter is a filter, I guess.

Although the Filter module operates on a “regular” audio signal, the Delay module does not. Substituting the Delay module into the fourth test circuit produces nasty noise and a whine. It will process the audio (you can hear repeats, etc.), but the noise/whine is horrible. Screams like a banshee. Bummer.

Bottomline, the littleBits Filter module has potential as an add-in for a PSS-A50 mod (or any other mod) without Microphone and Speaker modules. The littleBits Delay is simply too noisy by itself; one needs the Microphone and Speaker to perform signal conversion. As to the Filter, I need to explore alternatives for modulation. Experiments with using the Oscillator module as an LFO were underwhelming. So far, I haven’t successfully cobbled together an envelope following or audio-trigger envelope. Stay tuned.

Interested in littleBits synth control signals?

Copyright © 2021 Paul J. Drongowski

Keystep for littleBits

My last blog post took a look at the Pitch and Gate control voltages (CV) generated by the Arturia Keystep. Keystep’s Pitch and Gate behave conventionally. I also took note of how they differ from the littleBits gate CV signal, which combines pitch and gate control into a single signal. I mentioned two potential approaches for interfacing Keystep to littleBits:

  • Driving littleBits with Keystep’s Pitch and Gate, and
  • Sending MIDI to a littleBits MIDI module that handles conversion to littleBits gated CV.

I tried each approach. Here’s what I learned.

Keystep Pitch and Gate circuit

In this approach, the littleBits Oscillator is always running, always generating an audio signal. The Oscillator tracks the Gate voltage generated by the Keystep. The trick is opening up and shutting off the audio signal. For that, I put a littleBite Envelope module after the Oscillator and triggered the Envelope with the Keystep Gate voltage.

The resulting circuit is:

            Keystep Pitch                Keystep Gate 
| |
V V
Power --> CV Module --> Oscillator --> Envelope --> Speaker

The Keystep Pitch output is connected to the “CV IN” connector on the CV Module. The CV Module routes the incoming control voltage to its output, which sends the pitch control voltage to the Oscillator Module. The Keystep Gate output is connected to the Envelop’s Trigger input.

littleBits Proto Module ins and outs
littleBits Proto Module and quick-and-dirty patch cable

The Pitch output to CV IN connection is a standard 3.5mm patch cable. But, how is the 3.5mm Gate jack connected to the Trigger bitSnap? The littleBits Proto Module provides the solution. I cut a (stereo) patch cable in two and connected the shield and tip wires to the littleBits Proto Module as shown above. The Proto Module sends the incoming trigger signal (the Keystep Gate) to the output bitSnap. From the output bitSnap, the trigger signal goes to the Envelope Trigger input.

Properly, I should have used a mono patch cable, but I didn’t have one to sacrifice. I connected the TIP and SHIELD wires, leaving the RING unconnected.

That’s the entire setup! For testing purposes, I attached oscilloscope probes to the trigger (Keystep Gate) and the Envelope’s audio output. I also verified correct operation at intermediate points along the main signal path.

Oscillator audio (top) and Keystep Gate (bottom)

The screenshot above shows two oscilloscope traces. The top trace (green) is the final audio signal. Note the attack-release envelope around the oscillator signal. The bottom trace (red) is the trigger (Keystep Gate) signal. If the trigger is dropped before the entire envelop completes, the audio cuts off (i.e., it’s truncated). If the trigger is held beyond the combined attack plus release time, the audio signal merely stays at zero. The audio signal remains shut off until another trigger (the rising edge of Gate) is received.

Although this circuit gives us the desired behavior, it wasn’t easy getting things to work reliably. I seemed to suffer more than the usual loose connections and other lab-bench gremlins.

MIDI Module circuit

The MIDI Module approach is very similar to driving the littleBits Oscillator Module by MIDI over USB from a PC DAW:

           Keystep MIDI OUT 
|
V
Power --> MIDI Module --> Oscillator --> Envelope --> Speaker

MIDI arrives on the MIDI Module’s 3.5mm connector instead of the USB port. Otherwise, the main signal flow is the same.

Keystep/littleBits test rig

I monitored the gated CV signal produced by the MIDI Module and the audio signal generated by the littleBits Envelope using the oscilloscope. I played two notes in quick succession. The second note is two octaves higher than the first note.

littleBits audio triggered by MIDI Module

In the screenshot above, the top oscilloscope trace is the gated CV signal. The bottom trace is the synthesized audio. Not any different than the Pitch and Gate control volltage approach, eh?

Since the final audio is much the same, I would go with the MIDI Module circuit. It is simpler and its wiring is less touchy. The circuit uses the littleBots modules pretty much as intended by the littleBits engineers.

The MIDI Module approach makes the Keystep Pitch, Gate and MOD outputs available for other duties such as key-scaling (i.e., varying the effect of a sound modifier by keyboard pitch), modulation and user control. Don’t forget to insert littleBits Dimmer Modules (potentiometers) along control paths in order to set modulation level and so forth.

Copyright © 2020 Paul J. Drongowski

littleBits envelope generator

In my last post, I investigated the gated CV signal produced by the littleBits MIDI Module. Now, let’s take a look at the Envelope Module.

littleBits Envelope Module

The littleBits Envelope Module is rather basic with only attack and release controls (no decay or sustain controls). The module has two inputs:

  • The primary input at the left end of the module typically receives the audio to be shaped by the envelope.
  • The trigger input receives an (alternative) trigger signal.

The Envelope Module triggers in one of two ways:

  • When the primary input transitions from zero to a positive voltage.
  • When the trigger input transitions from zero to a positive voltage, usually 5 Volts.

Allowing the primary input to trigger envelope generation simplifies connection. It is also easier to use conceptually. A beginner doesn’t need to understand envelope generators, voltage controlled amplifiers and how the two interact. A beginner doesn’t need to wire in a separate envelope generator. Everything happens along a single audio signal path and “it just works.”

The simple circuit below is all one needs to get started with synthesis:

    Power --> MIDI --> Oscillator --> Envelope --> Speaker

If you have is the basic Synth Kit, then the MIDI Module may be replaced by the Sequencer Module or Keyboard Module. As we saw in the last post, the Gated CV output from the MIDI Module turns the oscillator ON and OFF (gate) and sets the oscillator pitch (CV). When the Oscillator is generating audio, the audio signal triggers the Envelope Module which shapes the audio amplitude. The shaped audio (now with attack and release segments) is finally sent to the speaker.

I connected this simple circuit to a dual trace oscilloscope. I found that the attack and release phases are sequential without an intervening sustain phase. The duration of the entire envelope is the sum of the attack duration and release duration. There isn’t a decay phase either. In other words, holding the gated CV longer does not sustain a note! The maximum duration of the attack phase is about 1 second and the maximum duration of the release phase is about 2 seconds.

Envelope Module in action (max attack and max release)

The oscilloscope traces above show the final, shaped audio signal when attack and release are set to maximum. [Click images to enlarge.] The top trace (green) is the gated CV signal from the MIDI Module. The bottom trace (red) is the shaped audio signal. Each horizontal grid mark is 0.5 seconds. Please note that the gate must be as wide as the attack duration plus the release duration to obtain the full contour.

littleBits Filter Module

Skipping ahead to the Filter Module for a moment, the Filter has an input which allows cutoff frequency modulation. In a typical modular synth, this input is tied to a separate envelope generator. In keeping with the littleBits “It just works” philosophy, you can drive the cutoff input with the audio signal as seen in the circuit below:

                                                ---- 
| |
| V
Power --> MIDI --> Oscillator --> Envelope --> Filter --> Speaker

Yes, this actual works as shown in the oscilloscope traces below. The top trace is the gated CV signal from the MIDI Module. The bottom trace is the output of the Envelope Module which is connected to the Filter cutoff modulation input.

Modulating the filter with envelope shaped audio

littleBits envelope generator

I’ll bet that you’re wondering if the littleBits Envelope Module can be made into a conventional envelope generator. So did I. It would be great to have a conventional synthesis chain with separate envelopes for amplitude and filter with separate attack/release (AR) controls for each envelope.

Here’s one experimental solution:

               --> MIDI IN  --> Oscillator --> Filter --> Speaker 
| | ^
Power --> | | Trigger |
| V |
--> Envelope ----------------------

If you have a second Envelope Module, you can insert it between the Filter and Speaker Modules, forming a conventional OSC→VCF→VCA chain. I have only one Envelope Module and built the circuit shown above. I used a littleBits Split Module to send the Power output to the MIDI Module and Envelope Module. This is the ideal situation for powerSnaps, if you got ’em.

littleBits Power Module (old model)

How does this circuit work? The Power Module provides the +5V and ground power rails, of course. The Power signal output is tied to 5V. Thus, the Envelope Module sees a constant 5V signal at its primary input. The littleBits MIDI Module triggers the Envelope module. The envelope generator inside the Envelope Module triggers and shapes the constant +5V input signal into the familiar attack and release envelope contour.

Output from the “pure” envelope generator circuit

The oscilloscope traces above show the gated CV signal (top/green trace) and the output from the Envelope Module (bottom/red trace). Yep, the final audio sounds exactly as expected having the familiar wah-wah filter funk. The final audio sounds cleaner when the filter cut-off frequency is modulated by the “pure” envelope generator.

One final detail. The internal littleBits envelope generator is based on a 555 timer circuit. If you’re curious about the internal design of this or any of the littleBits modules, be sure to visit the littleBits Eagle file repository where you will find schematics.

Copyright © 2020 Paul J. Drongowski

littleBits Control Signals

I got the itch to experiment with analog audio processing and finally unpacked the old littleBits synth modules. Folks hack the Korg Monotron series, so why not hack littleBits modules instead? The modules are inexpensive when compared with Monotron and are easily reconfigurable while experimenting.

Since I last wrote about littleBits (circa 2017), Sphero purchased the littleBits company in 2019. Fortunately, they retained the littleBits forum.

Not so good, neither Sphero nor littleBits provide precise documentation about synth module functionality or the input and output signal characteristics. Precise information is needed especially when interfacing modules with the outside world including module synth gear. Timing information, in particular, is needed.

We do know a few things about littleBits, however. littleBits modules normalize input and output signals to a 0 to 5 Volt range. Both digital and analog signals are normalized. Normalization facilitates the plug-and-play module architecture and you can freely interchange analog for digital and vice verse.

Background

Before diving in, here is a little background information about the signal types and terminology commonly used in modular synthesis.

Control voltage (CV)” is an analog signal which controls continuous functions like oscillator pitch generation, envelope and filter modulation, etc. CV sweeps continuously across an operational range, e.g., 0 to 5 Volts.

Gate” is a digital signal. It is an ON/OFF signal. A keyboard, for example, asserts gate when a key is pressed and drops gate when the key is released. Gate indicates a condition, e.g., a key is pressed. The leading and trailing edge of the gate indicates a change in the condition.

Trigger” is a digital signal similar to gate. However, trigger is usually a short digital pulse. Trigger is intended to indicate an event, like a clock tick, not just the presence or absence of a condition. Trigger signals often control synchronization.

Of course, electrons are electrons and one is free to combine CV, gate and tigger in any manner. Not all mixtures are meaningful (useful), however.

Details about CV, gate and trigger vary from manufacturer to manufacturer. Moog, for example, use the linear Volts per octave convention. On the other hand, old Yamaha and Korg synths use the Hertz per Volt convention. Maximum and minimum voltages level may differ by manufacturer and so on.

My goal here is understanding the convention used by littleBits.

littleBits MIDI and oscillator modules

I decided to start from the front of the synthesis signal chain and work back. The first stage in the synthesis chain is the littleBits MIDI module. A close look at the MIDI module signals in action should tell us how littleBits implement basic synthesizer control (CV, gate and trigger).

littleBits MIDI module

The MIDI module has a USB-B device port that presents itself to the USB-A host as a class-compliant MIDI device. The MIDI module supports both USB MIDI IN and USB MIDI OUT. However, the module operates in one mode (IN or OUT) at a time. The mode is selected by its mode switch (duh!).

  • IN mode: Receives MIDI messages from the host.
  • OUT mode: Sends MIDI messages to the host.

This blog post focuses on IN mode.

IN mode converts incoming MIDI note messages to two signals:

  • Gated control voltage (gated CV)
  • Trigger

Although littleBits call the digital output “Trigger,” it really is a gate signal, as we shall see.

littleBits Oscillator module

The littleBits Oscillator module is a pretty simple affair. The sole input is the (gated) control voltage which changes the pitch. The sole output is either square or saw wave as selected by the waveform switch.

The test rig

Here’s my test and measurement approach.

The littleBits signal chain consists of a power module connected to the MIDI module which drives a littleBits oscillator module. I split the gated CV signal sending it to both the oscillator and a proto module. The oscillator output is sent to a speaker module, giving me aural feedback. Hey, is this thing on?

MIDI module/Oscillator test circuit

The GND and gated CV signal are sent from the proto module to a Gabotronics Xminilab oscilloscope. I attached another proto module to the MIDI module “trigger out.” The GND and “trigger out” from that proto module are went to the second channel of the oscilloscope. Thus, I can monitor both the gated CV and “trigger out” and see the timing relationships between the signals.

SONAR/Oscilloscope test rig

The Xminilab front panel user interface is a little fiddly. So, I connected the oscilloscope to a PC running the Gabotronix oscilloscope application. This arrangement makes it sooooo much easier to configure the oscilloscope and to capture screen shots.

The USB MIDI comes from the PC, too. SONAR generates MIDI messages and sends them to the littleBits MIDI module. Test messages are produced from a repeating one measure loop (80 BPM or so). The repeating loop gives me good repeatability.

The signals under test

As noted by other experimenters, littleBits combine gate with CV functionality. When the MIDI module receives a note ON message, it:

  • Asserts the trigger signal, and
  • Drives the gated CV output with a positive voltage proportional to the MIDI note number.

The MIDI note range is C2 to C6 (4 octaves). MIDI note C2 generates a gate CV voltage of 0.2 Volts. From there, the output voltage increases by 1 Volt per octave (1V/oct). Each semi-tone step increases the voltage by 1/12 Volts. The module asserts trigger by raising its output voltage to 5V.

When the MIDI module receives the corresponding note OFF message, it:

  • Drops the trigger signal to 0V, and
  • Drops the gated CV output to 0V.

Notice that the gated CV output is asserted and dropped in parallel with the trigger output. Trigger is always driven to 5V while the gated CV voltage is positive and is proportional to the MIDI note number.

The screenshot below illustrates the operation of these two signals. The top trace (green) is the gate CV voltage. The bottom trace (red) is the trigger voltage. [Click images to enlarge.]

Gated CV (green/top trace) and “trigger” (red/bottom trace)

The MIDI test loop plays C2, C3, C4 and C5 in succession and repeats. The stair steps in the top trace show the effect of each successive note in the loop. The vertical display scale is 2.56V per grid division. You can see that each successive step is 1 Volt higher starting with C2 at 0.2V.

The trigger and gated CV traces are in temporal lock-stop, i.e., they rise and fall together. The width of the trigger signal is always the same width as the gated CV signal. Please recall that “trigger” in synth-speak is normally a fixed-width narrow pulse. That’s why I think the littleBits “trigger” signal is really a gate signal.

So, why do littleBits use a gated CV? Short answer: In conventional use cases, both gate and CV can be sent through a single wire (connection). The synthesist doesn’t have to route two separate wires (connections). The simplified wiring makes life easier for novice users (kids). The synthesist merely lines up a keyboard (sequencer, MIDI module) with an oscillator module and “it just works.” We will see other instances of the “It just works” philosophy in the envelope module, too.

C2, C3, etc. are MIDI note numbers and nice names. However, you’ll need to tune the Oscillator module to obtain the correct musical pitch.

Copyright © 2020 Paul J. Drongowski

Tuning up a littleBits oscillator

I’m starting to experiment with the littleBits oscillator and synth bits. I’d like to control the oscillators using an Arturia Keystep either through MIDI or through the Keystep’s control voltage (CV) and gate outputs.

Perusing the littleBits forum, I noticed several complaints about how difficult the oscillators are to tune. Setting the basic pitch is not a problem — just turn the PITCH knob. The issue is really intonation. Guitarists are very familiar with intonation, that is, being in tune along the fretboard. The keyboard equivalent is being in tune across the entire keyboard or a given range of keys.

For my initial testing, I assembled a simple littleBits circuit:

Power -> MIDI module -> Oscillator -> Dimmer -> Synth Speaker

The littleBits MIDI module was connected to an Arturia Keystep and for comparison’s sake, a Korg MicroKORG. The MIDI module translates incoming MIDI note on and note off messages into littleBits-compatible CV. The Dimmer is the volume control. I find it much easier to set volume levels, etc. with a full-size pot instead of a trimmer. Also, I strongly recommend putting knobs on the oscillator PITCH pot. It is much easier to set the oscillator pitch accurately when a knob is installed. (Funny how the little things make a big difference.)

My first concern was the actual control voltage being sent to the oscillator. I pulled out my trusty multimeter and measured the Keystep’s pitch (CV) over a wide range of keys (notes). I also measured the CV generated by the littleBits w5 MIDI module. The voltages all look reasonable for 1 volt per octave CV, modulo the limited 3 digit precision of the multimeter. Two notes separated by an octave produced a one Volt difference as expected.

The Keystep generates CV from 0 Volts to 10 Volts. littleBits signals are limited to the range from 0 Volts to 5 Volts. Rather than tempt fate and drive the littleBits oscillator from the Keystep CV output, I decided to put a littleBits CV interface module on order. The CV interface scales CV to the littleBits range — whatever that means. Stay tuned.

The voltage for each note as produced by each CV source (Keystep CV vs. MIDI module) is not the same. For example, the Keystep generates 4.03 Volts for MIDI note C2 while the MIDI module generates 1.20 Volts. Relax. This isn’t a big deal as the basic pitch is easily set by the oscillator’s PITCH control. It’s all relative, man.

I used a Snark guitar tuner to set the pitch and to test intonation. The Snark is an inexpensive small tuner with a microphone input. I like the Snark because it shows the detected note (C, C#, D, etc.) and whether the note is flat or sharp. I don’t like the Snark because the clip-on thingy breaks off almost immediately! The clip-on thingy isn’t necessary for desktop testing, however.

I first tried setting the pitch and intonation by ear. This is where the MicroKORG was really handy. I sent the MicroKORG’s MIDI out to the MIDI-to-CV module and routed the MicroKORG’s audio output to the mixer feeding the studio monitors. I also patched the littleBits audio into the mixer, so I could easily dial up the MicroKorg audio as a pitch reference. Hit a single key on the MicroKORG and both the oscillator and MicroKORG attempt to play the same note. Adjust the PITCH and TUNE knobs appropriately.

The Snark tuner method is much better. The Snark’s display shows when things are sharp or flat. I recommend using a tuner like the Snark instead of matching pitch by ear.

At first I couldn’t get satisfactory intonation beyond a one octave range. This is disappointing and appears to be the place where most forum members gave up. I read the Korg littleBits Synth booklet paying particular attention to the tuning procedure on page 21. One of my biggest complaints about the littleBits system is the lack of detailed documentation and the Synth book was kind of sketchy about tuning and intonation. However, a light did turn on in my head.

I decided to turn the TUNE trimmer fully clockwise (thinking “OFF”). Then, I set the base pitch, i.e., the lowest pitch in the desired range. Next, I checked the highest note in the desired range — about two octaves. Natch, the intonation was bad, so I slowly turned the TUNE trimmer clockwise until the pitch of the highest note was correct. This disturbed the pitch of the lowest note and I had to find a balance between pitchiness at the low and high ends.

The result is fairly playable. I played the chromatic scale from lowest to highest and checked the Snark at each step. The intonation was acceptable.

To make sure this procedure wasn’t a fluke, I tuned the second oscillator using the same method and got the same result. Finally, I wired up the MIDI module driving both oscillators and mixed the audio:

                             |-> Osc ->|
Power -> MIDI -> Split ->|         |-> Mix -> Dimmer -> Speaker
                             |-> Osc ->|

The pitches were danged close and the intonation of the individual oscillators matched quite well. I just needed to adjust the relative tuning to get a good phat sound.

Not bad for “cheap” $16 USD oscillators! It’s rather unfair to blame the oscillator design at this price. Plus, you did say that you want analog synthesis, right? We’ve gotten spoiled by decades of pitch-perfect digital synths. Making the tuning and intonation right is all part of the analog game.

One final thought. The littleBits CV signal driving the oscillators is somewhat under-documented. Voltage Control Lab have a nice analysis. They explain the littleBits OUT signal from the Korg SQ-1. They say that the CV signal plays two roles as a combined gate and pitch control. When the CV is asserted, i.e., the gate is high, the voltage level sets the pitch.

Here’s a more MIDI-centric interpretation. When a MIDI note is off, the CV signal is 0 Volts. The oscillator is silent at 0 Volts. When a MIDI note is on and held, the CV signal sets the pitch. When the MIDI note goes off, the CV signal returns to 0 Volts and silences the oscillator. This appears to be the behavior of the MIDI module (when it is in MIDI IN mode).

The Arduino combo organ is back

If you have a taste for cheesy 1960s combo organ sounds, I just posted the littleBits MIDI organ project. This project is an updated littleBits take on my old Combo Organ project. It uses the same “bottom octave generator” technique to squeeze five sample playback voices out of an Arduino.

Here’s an MP3 demo of the Farfisa voice and a demo of the Vox voice. I drove the MIDI organ from SONAR on a PC.

Here’s why you should prefer the littleBits version. The original project uses the MidiVox shield which is out of production. The littleBits version replaces the MidiVox with two breadboard-based circuits: a MIDI input interface and a Small Peripheral Interface (SPI) digital-to-analog converter (DAC). Easy to build and functionally equivalent. The new sketch incorporates improvements made to the Arduino SPI library and PROGMEM. The current SPI library uses a different convention for sending data to the DAC. PROGMEM is way different now; the old code won’t compile. The newer version of PROGMEM is stricter about typing and const.

The littleBits MIDI organ could form the basis of a sample playback synthesizer. Just replace the Farfisa and Vox waveforms with single cycle samples of your favorite synth or retro keyboard. Waveform space in PROGMEM is still tight, but hey, this is science. It’s supposed to be fun!

You’ll need to add a few headers to the littleBits Arduino module in order to use SPI. Here are some simple directions and tips:

Add SPI to littleBits Arduino Part 1
Add SPI to littleBits Arduino Part 2
Add SPI to littleBits Arduino Part 3

You’ll also find the SPI DAC and MIDI interface designs in parts 2 and 3, respectively.

While you’re at the littleBits site, check out f.j2’s Solina string synthesizer. Retro is bustin’ out all over!

I need to switch gears for a little while and be a musician again. So, I’ll be taking a short break from Arduino projects. More to come on the music side of things…

Sing “Do Re Mi” using an Arduino SPI DAC

After a few months away from electronics, I dusted off the littleBits Arduino project that I completed way back in September. Just as I completed the project, we took a short vacation trip — just enough time away to break the creative flow and to procrastinate about a write-up.

The old-new project uses the Arduino SPI digital-to-analog converter which I sketched out in two earlier posts: How to add SPI to a littleBits Arduino and the Arduino SPI DAC design. The SPI DAC greatly improves audio quality over the el-cheapo PWM+filter approach. It adds a little extra hardware, but it’s worth it.

The SPI DAC project adds a 12-bit digital-to-analog converter (DAC) to the littleBits Arduino. The DAC is a Microchips Technology MCP4921. The design is fairly simple and could be whipped together by a novice. I built the circuit on a solderless breadboard in order to avoid soldering. You still need to solder a 2×3 header to the littleBits Arduino. Can’t avoid it unless littleBits decides to sell Arduino modules with pre-installed headers.

I wanted to make the project “kid friendly.” So, rather than geeking out with MIDI, synthesis, etc., the sketch sings a song in Solege (i.e., “Do, re, mi). The Arduino’s program memory (PROGMEM) holds the waveforms (samples) for the eight syllables of the C major scale. The song is represented in an array where each row of the array contains the pitch and duration of a note. The sketch steps through the song array and sings each note (a Solfege syllable). Check out the MP3 demo.

As you might guess, it took a fair bit of effort to fit the waveforms into 28K bytes of PROGMEM! For more information, read about the waveform development process.

I posted the full design and code on the littleBits web site. I want to move ahead to new projects and frontiers and I won’t be posting the detailed design here. I do want to use the SPI DAC in future projects.

While you’re at the littleBits site, please check out the Mini Pops Drumcomputer. This is a very nice update on the Lo-fi Beat Box project. The developer, f.j2, fabricated the low pass filter as a littleBits module using the littleBits Hardware Development Kit (HDK). He also added new waveforms. Great job!

Arduino lo-fi beat box

Here’s another Arduino-based music project for ya — the Beat Box — a lo-fi, TR-808 drum machine. If you ever wanted to try your hand at DIY electronics, this one is a good starting point. Here is a short list of features:

  • 16 grungy, TR808-like rhythm instruments
  • Up to eight instruments per pattern
  • Up to five selectable patterns
  • Adjustable tempo (60 BPM to 188 BPM)
  • Full source code available including waveforms (samples)
  • Write and compile your own patterns, drum kits and waveforms
  • Built-in PWM signal generation into an external low pass filter
  • 22,050Hz, 8-bit signed, mono waveforms for true lo-fi grunge

The Beat Box uses the Arduino’s internal high resolution timer (TIMER1) to produce audio. The timer converts samples to a pulse-width modulated (PWM) bit stream which is sent into a simple low pass filter. The filter converts the PWM bit stream into an audio signal to be sent to a powered speaker, LINE IN, or what have you. This is absolutely the cheapest way to generate digital audio with an Arduino and it only requires four simple components, a solderless breadboard and a few jumper wires.

If you want to make assembly even easier, start with the littleBits Arduino Coding Kit, a Proto module and a Synth Speaker Module. I built the Beat Box using the littleBits Arduino Coding Hit and assembly was, literally, a snap.

The Beat Box source code includes drum waveforms and several classic drum patterns. With a 22,050Hz sampling rate and 8-bit samples, you get genuine lo-fi, bit-crunched TR-808 grunge. Purely optional, I added a littleBits synth Filter module and Delay module to the audio signal chain. Listen to the MP3 demo. In the demo, I sweep the filter frequency from low to open. At about 10 seconds in, you hear what is essentially the unfiltered sound of the Beat Box. Then, I increase the delay feedback level which adds echoes in time with the original pattern.

This pattern forever reminds me of riding the RTA #48 bus to work in Cleveland circa 1982.

Per standard operating procedure, I have provided the full design and source code.

Get your beat on! Build it now!

Connect a MIDI shield to littleBits Arduino

My do-it-yourself MIDI interface for littleBits Arduino probably isn’t for everyone. Constructing the DIY interface requires circuit layout skills and not everyone wants to whip up a board from scratch and a schematic.

Fortunately, there are a couple of alternatives: the Olimex SHIELD-MIDI and the Sparkfun MIDI Shield. I don’t have any direct experience with the Olimex, but I have built and used the Sparkfun MIDI Shield (Sparkfun product number DEV-12898) and the now retired MIDI Breakout Board. The Olimex SHIELD-MIDI is very similar to the retired breakout board. In this post, I show how to hookup the Sparkfun MIDI Breakout Board to the littleBits Arduino. The wiring is the same for the Sparkfun MIDI Shield. That’s the neat thing about the standard Arduino form factor.

I would demonstrate with a Sparkfun MIDI Shield, but all of my MIDI Shields are customized in some way! The Sparkfun MIDI Breakout Board is basically the same as the MIDI Shield except that it doesn’t have the potentiometers and tactile switches. The image below is a picture of the Sparkfun MIDI Breakout board. (Click on the image to get higher resolution.) The two 5-pin DIN connectors are the MIDI IN and MIDI OUT ports. The long pins extending below the breakout board plug into a standard Arduino like an UNO or Leonardo.

sparkfun_midi_breakout

The Sparkfun MIDI breakout board (or shield) arrives as a kit, so you still need to do some assembly. Sparkfun has already installed and soldered the tough stuff like the optoisolator, resistors and so forth. The MIDI Shield is a good beginner’s kit because the components to be installed are large and easy to solder. If you skip installing the potentiometers and tactile switches, the job is even easier!

You might want to add an Arduino Stackable Header Kit (PRT-10007), however. With the header kit, you’ll be able to interconnect using standard jumper wires. Once the headers are installed, no further soldering is necessary. Just plug the jumpers into the headers and play. Mistakes are easier to correct with jumper wires, too.

Here is the top-view of the MIDI breakout board, an Arduino UNO processor board and a Sparkfun MIDI Shield. Click the image for higher resolution. You’ll want to take a closer look at the three boards in order to see the signal name associated with each header pin. (You can really zoom in if you download the image and load it into a paint program.)

midi_bob_uno_shield

The breakout board has a position for a MIDI THRU connector. This position is empty as the headers would block the opening of the 5-pin DIN connector. We don’t need the THRU port, so this isn’t a deal-breaker.

As I mentioned before, the long pins extending below the headers normally plug into a standard Arduino processor board (e.g., UNO or Leonardo). Each header pin effectively mirrors the electrical signals of the underlying Arduino board. So, in order to hookup to the littleBits Arduino, we just need to connect the appropriate Arduino board signals to the corresponding bitSnaps on the littleBits Arduino. That’s why you really want to zoom in and see the signal names. The board labels tell us where to plug in jumper wires.

We need four connections:

  • +5 Volts: Red wire
  • Ground: Black wire
  • RX (digital pin D0): Yellow wire
  • TX (digital pin D1): Blue wire

Our old high school shop teacher would yell at us if we didn’t use the right color wire for power, ground, etc. I will say, different wire colors make it easier to check and debug wiring!

So, how do we make connections to the littleBits Arduino? I used two littleBits proto modules: one proto module for the MIDI input side and one proto module for the MIDI output side. The other end of each jumper terminates in a screw connector on a proto module. Please see the image below. (Click to enlarge.)

sparkfun_midi_littlebits_arduino

RX is connected to RX, TX to TX, +5 Volts to +5 Volts, and Ground to Ground. The MIDI IN goes to the Arduino’s RX pin and the the Arduino’s TX pin goes to MIDI OUT.

You must configure the jumpers on each proto module. The MIDI OUT side is easy; just leave all three jumpers installed. One the MIDI IN side, remove the center jumper on the proto module. This breaks the connection from the proto board input to the proto board output. You must remove this jumper or the input signal will interfere with the incoming MIDI data.

Once all of the connections are made, you’ll need sketches to test the connections. Please see my article about testing an Arduino MIDI interface. The article describes a simple testing process. The article also has links to a simple MIDI sequencer sketch and the source code for a MIDI IN to MIDI OUT sketch. The MIDI sequencer sketch checks the MIDI OUT side. Once you know the MIDI OUT is good, then the MIDI IN to MIDI OUT sketch checks the MIDI IN side. (The sketch echoes MIDI IN to MIDI OUT.)

That’s it! You should now have your 5-pin MIDI equipment talking with the littleBits Arduino. If this project has bolstered your confidence with hardware — and I hope that it has — then please take a look at the DIY 5-pin MIDI interface project.

littleBits Arduino tone sequencer

The littleBits Arduino module has the potential to be a MIDI-driven tone generator for a mono or paraphonic synthesizer. After getting the module, I was anxious to try it out even though I haven’t built a MIDI interface for it (yet).

Here is a picture of the littleBits hardware. (Click the image to get full resolution.) The Arduino module is in the middle between the controls at the left (button and dimmers) and the synth speaker at the right. The controls on the left hand side don’t do anything at the moment. I put a dimmer between the output pin (D5) and the synth speaker in order to control audio volume. It’s just more convenient to control the volume with a dimmer than the tiny trim pot on the synth speaker module. The knobs on the dimmers are my own touch; they aren’t standard-issue with the littleBits dimmers.

arduino_dimmer_speaker

To keep things simple, I wrote a sketch that implements a basic note sequencer. Each note has a pitch (frequency) and a duration (milliseconds). The notes are stored in an array. The Arduino loop() function steps through the array of notes and plays one note at a time. After the loop plays the last note in the array, it goes back to the beginning of the array. The loop has a delay() in it and the loop keeps track of the remaining duration of the currently playing note. The sketch calls the Arduino tone() function to play notes by sending a square wave at the desired frequency to output pin D5.

If you would like to learn more about this project, then read about the design of this simple Arduino-based sequencer and tone generator. Here are links to the source code:

ToneTest.ino: Main sketch
ToneFreq.h: Note frequencies
ToneNote.h: Note durations

The D5 and D9 output pins on the littleBits Arduino module have a switch that enables or disables low pass filtering. The “analog” switch position turns on the filtering. The “pwm” position turns filtering off. Should you build this project yourself, try both switch positions. The “pwm” position doesn’t filter the square wave and you will hear it loud and nasty. The “analog” position produces a quieter, mellower timbre thanks to the low pass filter. Be sure to try the littleBits synth filter, envelope and delay modules, too.

One more tidbit. Pictures of the littleBits envelope, filter and delay modules usually show the top-view. The picture below flips the modules over and shows the bottom-view.

envelope_filter_delay

From left to right, the modules are the envelope, filter and delay, respectively. There is some serious electronics on these boards! (Click the image for full resolution.) I hope to use these modules to mangle audio, not just synthesis.

All the best.

Update: 28 June 2016. If you enjoyed this project and have the littleBits Synth Kit, then check out an expanded version of the tone sequencer which drives the filter and envelope modules.