Category Archives: DSP

Fast and Efficient Pitch Detection: Double Trouble

      DSP, Electronics, Infinity, Pitch Detection, Software

This D string was driving my pitch detector nuts. It’s jumping from fundamental to octave and back all over the place. Can’t make up its mind! The effect is like a wacko version of Satch with a whammy pedal gone haywire.

What the hell am I talking about? Last month, I wrote about a fast and efficient software multichannel pitch detection scheme using dual peak-detectors. I needed it to be as efficient as possible, so I can run multiple detectors simultaneously using a small 32 bit microcontroller (MCU). Most of the time, it works really well, except in some cases, like that troublesome D string.

Continue reading

Fast and Efficient Pitch Detection

      DSP, Electronics, Infinity, Pitch Detection, Software

Phase Accurate Synthesizer (blue) Tracking Guitar (yellow)

I needed to implement real-time, multichannel pitch detection in software using a small ARM Cortex-M4 microcontroller (MCU). My all-time favorite is the STM32F4 family from STMicroelectronics. It has DSP and single precision FPU instructions and can reach up to 225 DMIPS/608 CoreMark at up to 180 MHz operating frequency. Not too bad, actually, especially for this class of MCUs, but it can easily get overwhelmed with complex DSP code we normally take for granted in a desktop or laptop machine with multi-cores running in the GHz range.

I’ve been working on this for quite some time now and I am quite pleased with the results. I now have a fast, accurate, low-latency, phase-correct and efficient multichannel pitch detection. I thought I’d like to share. In case you are wondering, no, it is not for note to MIDI conversion, although that is obviously one application.

Continue reading

Infinity Reloaded

      DSP, Infinity

Inf-Logo-2016Infinity… It’s all about sustain. Our goal is and will always be polyphonic sustain. Polyphonic sustain, plus extensive processing for each string, will give us musicians full control over the dynamics of the guitar. Sustain is one of the reasons why we drive amplifiers using excessive gain. We want to make the guitar sing, gently weep, or even scream like invading aliens about to decimate an entire population.

Yet, there’s still so much to be desired. We can only push the gain so much before noise dominates the trailing end of a sustained note. So we make it louder such that we induce feedback through the speakers. Or, we use sustain drivers such as the Ebow, the Sustainiac, or the Fernandez Sustainer. All of which can indefinitely sustain one note at a time (some say you can sustain more than one note, but I do not want to digress). What I want is controlled polyphonic sustain. It’s been done before, e.g. the Moog Guitar, or Keith McMillen’s StrongArm, but I’d like to offer an alternative solution with a modular architecture and an accessible open design.

Continue reading

Virtual Pickups Revisited

      Design, DSP, Effects, Evolution, Filters, Modeling, Nu Series, Open Source, Pickups, Software

A little background: I’ve written a series of articles before about Virtual Pickups and how they are implemented in software (DSP). It’s a three part series: Part 1, Part 2 and Part 3. I wrote about Standing Waves, Nodes, Antinodes and Pickup Position, Comb Filters, some underlying Math and Simulation in DSP code. I also presented what I thought was a minimal interface I really like.

Infinity_GUIIt has taken a while (I can’t believe it has been almost 2 years now!), and now I’m back to writing the software. What has transpired since then? Production of the XR and the Nu took the most of our time and I’m left with very little time to do what we I best: R&D. Now that the Nu is out, it makes sense to go back, pick up and continue where we left off, starting with the GUI.

Continue reading

Infinity goes FM

      DSP, Electronics, Evolution, Hardware, Infinity, Processing
fm

Testing the FM synthesizer

What do I do on Christmas eve? What else, but hack some C++ code. I got a new highly optimized sustain driver design that also acts as pickup! The power consumption is now at 20mA, each. With the new drivers, I upgraded to FM synthesis from simple additive synthesis. Now I will be driving the strings with FM waves, the same tech behind the 80s Yamaha DX7 synthesizer. FM synthesis was developed by John Chowning at Stanford University in the 70s. In the 80s up ’till the mid 90s, Yamaha virtually monopolized the market with their hardware implementation. The patent expired in 1995.

FM is cool! I think FM synthesis is the best fit for the Infinity project.

Merry Christmas Everyone!

 

Computational Hexaphonic Guitar

      Design, DSP, Electronics, Innovation, Nu Series, Pickups

It’s nice to see our pickups in the academe. Chengxiang Ren and Jeffrey Huang, Cornell University, Electrical and Computer Engineering, used the Cycfi Neo (now Nu) polyphonic pickups in their Master’s project. I’ll try to learn more about this project and these cool people. Their ideas are perfectly aligned with mine.

RenHuang-2In this project, we designed a computational guitar that consists of a hexaphonic pickup and a digital signal processor (DSP). As an example application, we implemented a pitch correction algorithm that corrects the pitch of each string in real-time, which enables us to play the guitar “in-tune” when it is not. Our pitch correction algorithm operates in real time on a Texas Instrument DSP board (TI DSK6713) and combines frequency-domain pitch detection and time-domain pitch shifting.

Continue reading

Easy Peasy Lemon Squeezy

      Electronics, Filters, Nu Series, Pickups, Side Winder

neo-hd-set

 

“Make things as simple as possible, but not simpler.” Ah my favourite Einstein quote. Apart from the Infinity project, here’s what we’ve been working on for the past couple of months: Coming very soon, an easy to use Neo setup. This solderless system includes everything you will need to get an extended response pickup system up and running as quickly as possible. This setup shown is for a Fender Stratocaster S-S-S configuration, but various customisations are possible. For example, the bridge pickup can be paired with a Neo6 multichannel pickup (my favourite setup!). Dual humbuckers? Sure, that’s two pairs (four pickups). The tonal combinations would be awesome if you combine four pickups in various ways. Or how about 6 pickups!

In addition to 6 string pickups, available on request, we will also offer pickups for 7, 8 and 9 strings (we are committed to the ERG crowd!). We use premium components only (Bourns potentiometers, Switchcraft jacks, gold-plated headers and connectors etc).

If you wish for a highly customised setup, don’t hesitate to send us a message. Basic customisation options include:

  1. Volume control
  2. 5-way switch
  3. Passive low-pass filter
  4. Passive high-pass filter
  5. Active resonant filter with variable Q and sweepable frequency
  6. Lithium-Ion battery pack and charger (not shown)
  7. Single-coil or Sidewinder

Here’s the system on a Fender Stratocaster. I love it so much I decided to keep it permanent! I’ll post some sound clips soon.

neo-hd-set-strat

Cycfi Extended Response pickup set

 

neo-strat

Extended Response pickups on a Strat!

Virtual Pickups Part 3

      DSP, Electronics, Filters, Nu Series, Pickups

This is the third and final instalment of the Virtual Pickups series. I changed the title from Virtual Pickup Placement to better express the actual subject which will now go beyond pickup placement. This time, we will talk about simulating pickup width —its aperture. We will also talk about compensating for the actual pickup’s comb filter effect using an inverse comb filter. Finally, we’ll deal with the electrical characteristics of pickups.

Feel free to review the previous articles:

Pickup Width

Referring to J. Donald Tillman’s article again, we will simulate the effect of pickup width. Pickups sense the string over an area spanning the width of the pickup’s magnetic field. This sensing area is the “aperture” of the pickup. Various pickups have different widths. The article mentions 1 inch for the typical single-coil and 2.5 inches for the typical PAF style humbucker.

If you read the first article in this series, you know that a single pickup point can be simulated using a feedforward comb filter. To simulate pickup width, we want to average all the points over the aperture of the pickup. Here are the computed frequency response of a 1 inch single-coil pickup and a 2.5 inch humbucker-stype pickup.

The filtering effect of a 1.0 inch wide pickup on the low E string. -3dB point 1820 Hz, first null 4200 Hz.

The filtering effect of a 2.5 inch wide pickup on the low E string. -3dB point 728 Hz, first null, 1680 Hz.

Notice the low-pass response with a 6dB per octave slope with unity gain at D.C. This is the effect of integration. I was able to replicate this frequency response using an integrator and a comb filter.

Integrator plus Feedforward Comb Filter.

Integrator plus Feedforward Comb Filter.

The filter integrates (accumulates) all the incoming signal and subtracts the delayed signal with a delay time proportional to the ½ the aperture size of the pickup. With a sampling frequency of 44100 samples per second, the delay line for the entire length of the E string will be 535.12 samples (44100 / 82.41). For a scale length of 25.5 inches and a pickup aperture of 2.5 inches, the delay line required will be: 535.12 x 2.5 / 25.5 = 52.46 samples.

Here’s the actual frequency response given the comb-filter configuration above for a 1 inch single-coil pickup and a 2.5 inch humbucker-type pickup.

1 inch wide pickup response.

1 inch wide pickup response.

2.5 inch pickup response.

2.5 inch pickup response.

These frequency graphs are exactly as expected. Now all we have to do is cascade that with our previous filters.

After some listening tests (I’ll share some more sound clips hopefully soon), I find the pickup width filters make the sound too muddy. The details are somehow lost. I think there are a couple of issues with the model Mr. Tillman proposes in his article. In this model, for example, he assumes that averaging the point response over the aperture length, while isn’t completely accurate, makes a fine first approximation. I don’t think I agree with that. The sensitivity near the poles is crucial. For actual pickups, the response falls off very rapidly beyond 0.4” (10 mm) from the poles (see Practical Pickup Measurements). Also, the aperture width of 2.5 inches for a humbucker and 1.0 inch for a single coil are too wide. I had better results with a 1.25 inch wide aperture for a humbucker. I’m not sure how he derived the 2.5 inch wide aperture. I measured the pickup width of a humbucker and it is indeed 1.25 inch wide. I also think that a zero (or close to zero) aperture width for a single coil sounds best.

In the end, for a humbucker, I find that simply placing two pickups side by side, spaced 0.68” apart, gives the best results. 0.68” happens to be the pole spacing of a typical PAF style humbucker. Here’s the frequency response I got:

Double Coil Pickup Response

Double Coil Pickup Response

Double virtual coils, plus a resonant low-pass filter (see Pickup Electrical Characteristics section below), sound very convincing for a humbucker.

Inverse Comb

Want to go further? The astute reader will ask: OK, but how about the response of the actual (non-virtual) pickup? Wouldn’t that have its own comb notches that imparts its own colour? Yes it will! And to compensate for that, we need an inverse comb filter. That can be done using a feedback comb filter. Recall:

comb-filters

The frequency response of a feedforward and a feedback comb filter, for the open E string, are as follows:

Feedforward Comb Filter Spectrum

Feedforward Comb Filter Spectrum.

Feedback Comb Filter Spectrum.

Feedback Comb Filter Spectrum.

Notice that the Feedback Comb Filter Spectrum is the inverse of the Feedforward Comb Filter Spectrum. We can use a feedback comb as a pre-filter to negate the effect of the actual pickup. The amount of signal being fed back should be less than 100% for this to be stable, otherwise, you will get infinite repeats.

Pickup Electrical Characteristics

Finally, what we haven’t covered yet is the effect of the actual pickups’s electrical characteristics. This is the easy part! The guitar pickup is equivalent to this circuit (lifted from The Secrets of Electric Guitar Pickups by Helmuth E. W. Lemme):

Electrical equivalent circuit of a magnetic pickup.

Electrical equivalent circuit of a magnetic pickup.

This is a simple resonant low-pass filter (adjustable frequency and Q with a 12db per octave slope). The effect is independent from the scale length and string tuning and can therefore be placed after everything else. Ideally, you will need one of these per virtual pickup. More if you want multiple resonant peaks.

Here’s a link to a table of different resonant frequencies of some well-know pickups. The graph below is the EQ settings for a resonant low-pass filter set at 3.3 kHz and a Q of 2.5:

Resonant Low Pass Filter

Resonant Low Pass Filter

Photographs and Paintings

starry-nightLet me reiterate that I am not aiming for exact emulation of specific guitars. I want to use emulation only as a starting point so the user will have something familiar to start with.

Accurate emulations can be achieved using convolution from sampled impulse responses of various instruments. Convolution with Impulse Responses can accurately capture anything: expensive microphones, vintage EQs, speaker cabinet response, full cathedral reverberations, etc. Essentially, anything that can be modeled as a filter can be captured. And yes, the guitar pickup as well as the guitar body are just filters!

One major drawback of convolution is that it is computationally expensive. Of course, we now live in a world full of very powerful multi-core processors, so that’s not really a problem anymore. Later, we’ll definitely take advantage of convolution. The math and the algorithms are already well established. We’ll have more on that soon!

Another drawback of convolution is the lack of intuitive control. With convolution, we work with sampled impulse responses which are basically raw waveforms in memory. It is possible to tweak an impulse response in the frequency domain (its spectrum), but that’s it. Doing so is like tweaking a very detailed EQ (much like editing a terrain map). The EQ’s frequency response does not say anything about pickup positions, pickup width, combining pickups, body resonance, etc.

The process of capturing an impulse response is sampling. A friend asked me once about the difference between a synthesiser (analog, FM, etc.) and a sampler. My analogy: the sound generated by synthesisers and samplers are analogous to paintings and photographs. Sampler files are like photographs. They are snapshots of the real world. On the other hand, sound generation using various forms of synthesis are like paintings. The artist uses various tools like brushes and paint to capture the real (or unreal!) world.

So here, I am donning a painter’s hat. I want to paint the sound, instead of taking a photograph of the sound. Later, I’ll wear a photographer’s hat and combine the best of both worlds.

There you go! Next time, I will present some C++ code! We’ll also see some more audio samples with combinations of these filters in action.

Get Rad and Prosper!

Further Reading

  1. Convolution
  2. Convolution Processing with Impulse Responses
  3. Response Effects of Guitar Pickup Position and Width
  4. The Secrets of Electric Guitar Pickups
  5. Measuring Impedance and Frequency Response
  6. Resonant frequencies of some well-know pickups
    for various parallel capacitors
  7. Practical Pickup Measurements

 

Virtual Pickups Part 2

      DSP, Electronics, Filters, Nu Series, Pickups

Last week, I stated that given a multichannel pickup with a wide and flat frequency response such as the Neo, it is possible to reproduce the frequency response of various pickup positions (bridge, neck, middle —anywhere from the nut to the bridge) without actually moving the pickup. But we can do better! We can actually emulate multiple pickups using multiple comb filters. Scroll down for some sound clips!

To be clear, I am not aiming for emulation of specific guitars (On Emulation, July 2013). I want to use emulation only as a starting point so the user will have something familiar to start with. Once that is established, we can move on to explore entirely new tonal palette —timbres we’ve never heard before. It’s just one of the filtering possibilities, and one that we guitar players are familiar with.

To recap, we can use comb filters to simulate pickup placement. A Feedforward comb filter with a delay of 133.78 samples (at 44100 samples per second) can simulate the neck pickup for the low-E string. By varying the delay line, you can simulate various pickup placements.

Feedforward Comb Filter

Feedforward Comb Filter

Again, if you want to learn the math, read the splendid article by J. Donald Tillman: Response Effects of Guitar Pickup Position and Width. I am using that as reference in this article.

Delay lines and comb filters are quite powerful beasts. They are the fundamental building blocks of Waveguide and Karplus-Strong Synthesis, which we’ll explore in the future. To give you a hint, we’ll be combining processing and direct manipulation of sound together with synthesis.

Two Pickups

I particularly like the neck plus middle pickups on a Strat or Super-strat (e.g. SSS, HSH), especially when playing clean. I love the glassy, chime-like timbre. It’s the interaction between the two pickups that gives it its nice flavour (it is well known that this switch setting was discovered by accident). Here’s the computed frequency response of the neck plus middle pickup on the Strat. This graph was lifted from another Donald Tillman article about Response Effects of Guitar Pickup Mixing.neck-middle-spectrum

Following the article, I was able to build the comb-filter configuration in the figure below:

Cascaded comb filters

Cascaded comb filters

Where D1 is the average pickup delay of two pickups: (P2 + P1) / 2 and D2 is the distance between the two pickups divided by two: (P2 – P1) / 2. I won’t bore you with the math. Again, if you want to know more, read up on the articles mentioned above.

The cascaded comb filters are basically the same as before, but notice that the gain of the second comb filter is +1. It is called a Cosine Comb filter. The first is a Sine Comb filter. They behave differently in terms of frequency response. The Cosine Comb filter has unity gain at D.C. and has nodes that only occur at odd multiples instead of at all multiples.

With that configuration wired up in C++ code, I was able to get the expected frequency response:

7-neck-middle-mix

Neck plus middle pickups frequency response.

Take note that these are actual frequency response plots. I am using Blue Cat’s FreqAnalyst, a realtime spectrum analyser plug-in, to monitor the output using a sine sweep from 20Hz to 20kHz as input to the filter. These graphs correspond exactly to the computed plots in the Response Effects of Guitar Pickup Mixing article.

Three or more Pickups

Alas, the two pickup configuration above does not extend to three or more pickups. That’s where the article stopped with a rather unfulfilling conclusion: “It’s pretty complicated; I will not be going in an analysis of this here”. So it took quite a bit of time for me to figure out how to implement mixing multiple pickups. You can’t just run the filters in parallel and mix the results, no! If you add two sine waves, both 1kHz, the result will not necessarily be 2x sine wave at 1kHz. If the sine waves are out of phase, you will get 0! They will cancel out. We need to account for the phase! Now, we are going into the Superposition territory.

To cut the long story short, the bottom line is that you need to adjust for the additional phase (delays) for each pickup relative to a fixed reference point. That reference point is arbitrary. I chose the middle of the neck as my reference point. That way, I can dynamically move the pickups anywhere from the bridge to the 12th fret (Say again? A pickup in the 12th fret?), in realtime, while performing!

The diagram below depicts the three comb configuration for simulating three pickups:

triple-comb

Three pickup emulation using comb filters

This configuration can be extended for any number of pickups. What’s really nice about this configuration is that it is also possible to do all sorts of nifty things such as reverse phase connections and arbitrary control of mix levels for each pickup. Adjusting the mix between the two pickups makes it possible to cancel the fundamental, for example.

D1, D2 and D3 are the individual pickup delays as usual. D1C, D2C and D3C are the phase compensation delays. They are there to normalise the phase of each pickup to a common reference point at ½ the full length of the guitar from the nut to the bridge (i.e. the 12th fret). Given Ref, the reference point delay, D1C, D2C and D3C are computed as follows:

D1C = (Ref – D1) / 2
D2C = (Ref – D2) / 2
D3C = (Ref – D3) / 2

For example, for the low E string (at 82.406889 Hz), and a sampling frequency at 44100 samples per second, the reference delay, Ref, is (44100 / 82.406889) / 2 = 267.574717. D1, D2 and D3 are computed as ratios using the actual pickup positions of a Strat with a 25.5 inch scale:

Neck Pickup: 6.375 inches from bridge = 133.7873585 samples delay
Middle Pickup: 3.875 inches from bridge = 81.3217277 samples delay
Bridge Pickup: 1.625 inches from bridge = 34.10266001 samples delay

The observant reader will notice the fractional delays used here. They are needed for accurate frequency computations.

So, finally, with this three comb filter configuration, I was able to recreate the graph near the bottom of the Response Effects of Guitar Pickup Mixing article. Here’s the computed frequency response:

Frequency response plot for an even 33/33/33 mix of the neck, middle and bridge pickups.

Here’s the actual frequency response:

8-neck-middle-bridge-mix

Neck plus middle plus bridge pickups frequency response.

Sound Samples

Finally, here are some audio samples. These are all recorded without effects (except the comb filters of course) from a Neo6 master sample (sustained E string). Yes, all these timbres came from a single source pickup!

Raw Neo (No filter)
Neck
Neck + Middle
Neck + Bridge
Neck + Middle + Bridge
Middle
Middle + Bridge
Bridge
Pickup at the 12th fret

‘Till Next Week

Okidoki, that’s it for today. Next time, we’ll wrap up this three part article with a few more bits and pieces such as simulation of pickup aperture and compensation for the comb filter notches of the actual pickup. We’ll also cover emulation of humbuckers. Also, we might touch up a bit on user interfaces and real time control.

Further Reading