Turning Sounds From A Flute Into Sheet Music

Composing music can be quite difficult – after all, you have to keep in mind all of the elements of musical theory, from time signature and key signature to the correct length for all of the notes. A team of students from Cornell University’s Designing with Microcontrollers class developed a solution for this problem by transcribing sounds from a flute into sheet music.

The project doesn’t simply detect the notes played – it is able to convert the raw audio into a standardized music score complete with accurate note timings and beats per minute. Before transcribing the music, some audio processing was necessary. The team chose to use a Sallen-Key filter to amplify the raw audio input due to its complex conjugate poles. They then used a fast Fourier Transform (FFT) to determine the frequency for the input note, converting the signal from the time domain to the frequency domain.

The algorithm samples the data to generate an input signal, using the ADC on the microcontroller to receive input from the microphone. It takes the real and imaginary components of the sampled signals and outputs a pair of real and imaginary amplitude components corresponding to the sampled frequency, evenly spaced from 0 to the Nyquist rate (half the sampling rate). The spacing of these bins and the bin with the largest amplitude are used to convert the signal back to a real frequency and a MIDI note.

The system uses a PIC32 for the logic. The circuitry for the microphone amplification uses a non-inverting op-amp with a gain of 50 to increase the microphone output signal amplitude from 15 mV to 750 mV to use by the microcontroller’s ADC. The signal is then sent to the anti-aliasing Sallen-Key filter, with a pole at 2.5 kHz and a Q of 1. The frequency was chosen since the FFT samples at 8 kHz and the frequency corresponds to a note out of the range of a flute. As for the filters, only the low pass filter was implemented in hardware.  While a bandpass filter could have been implemented in hardware, the team decided on a cleaner software approach.

The project is well-documented on the team’s project page, and it’s certainly worth checking out for more detailed discussions on the keypad controls and the software side of the audio processing. If you want to learn more about the FFT, check out this 2016 Hackaday Prize entry for an FFT spectrum analyezer.

Continue reading “Turning Sounds From A Flute Into Sheet Music”

Getting An RF Low-Pass Filter Right

If you are in any way connected with radio, you will have encountered the low pass filter as a means to remove unwanted harmonics from the output of your transmitters. It’s a network of capacitors and inductors usually referred to as a pi-network after the rough resemblance of the schematic to a capital Greek letter Pi, and getting them right has traditionally been something of a Black Art. There are tables and formulae, but even after impressive feats of calculation the result can often not match the expectation.

The 30MHz low-pass filter, as QUCS delivered it.
The 30MHz low-pass filter, as QUCS delivered it.

Happily as with so many other fields, in recent decades the advent of affordable high-power computing has brought with it the ability to take the hard work out of filter design, Simply tell some software what the characteristics of your desired filter are, and it will do the rest. The results are good, and anyone can become a filter designer, but as is so often the case there remains a snag. The software calculates ideal inductances and capacitances for the desired cut-off and impedance, and in selecting the closest preferred values we modify the characteristics of the result and possibly even ruin our final filter. So it’s worth taking a look at the process here, and examining the effect of tweaking component values in this way.

The idealised graph produced by QUCS for our filter.
The idealised graph produced by QUCS for our filter.

The filter we’re designing is simple enough, a 5th-order Bessel filter, and the software is the easy-to-use QUCS package on an Ubuntu Linux machine. Plug in the required figures and it spits out a circuit diagram, which we can then simulate to show a nice curve with a 3dB point right on 30MHz. It’s an extremely idealised graph, and experience has taught me that real-world filters using these designs have a lower-frequency cut-off point, but for our purposes here it’s a good enough start.

As previously mentioned, the component values are not preferred ones from a commercially available series, so I can’t buy them off the shelf. I can wind my own inductors, but therein lies a whole world of pain of its own and I’d rather not go there. RS, Mouser, Digikey, Farnell et al exist to save me from such pits of electronic doom, why on earth would I do anything else but buy ready-made?

My revised filter circuit with off-the-shelf component values.
My revised filter circuit with off-the-shelf component values.

So each of the components in the above schematic needs moving up or down a little way to a preferred value. What effect will that have on the performance of my filter? Changing each value and re-running the simulation shows us the graph changing subtly each time, and it can sometimes be a challenge to adjust them without destroying the filter entirely. Particularly with the higher-order filters with more components in the network you can observe the effect of individual components on the gradient at different parts of the graph, but as a rule of thumb making values higher reduces the cut-off frequency and making them lower increases it. In my case I always pick higher values for that reason: my nearest harmonic I wish to filter is at double the frequency so I have quite some headroom to play with.

The revised curve from the filter with preferred values.
The revised curve from the filter with preferred values.

Having replaced my component values with preferred ones I can run the simulation again, and I can see from the resulting graph that I’ve been quite fortunate in not damaging its characteristics too much. As expected the cut-off frequency has shifted up a little, but the same curve shape has been preserved without any ripples appearing or it being made shallower.

If I were using this filter with a real transmitter I would ensure that I designed it with a cut-off at least a quarter higher than the transmission frequency. In practice I find the cut-off to be sharper and lower than the simulation leads one to expect, and for example, were I to use this one with a 30 MHz transmitter I’d find it attenuated the carrier by more than I’d consider acceptable. It must also be admitted that changing the component values in this way will also change the impedance of the filter from the calculated 50 ohms, however in practice this does not seem to be significant enough to cause a problem as long as the value changes are modest.

We haven’t made this filter, but in the past we’ve featured another one I did make, and by coincidence it was in the same frequency range. When I wrote a feature on automating oscilloscope readings, the example I used was the characterisation of a 7th-order 30 MHz low-pass filter. It might even be one of the ones in the header image, pulled from my random bag of filter boards for the occasion.

Logic Noise: Filters And Drums

Filters and Drums

Logic Noise is an exploration of building raw synthesizers with CMOS logic chips. This session, we continue to abuse the 4069UB as an amplifier. We’ll turn the simple unity-gain buffer of last session into a single-pole active lowpass filter with a single part. (Spoiler: it’s a capacitor.)

While totally useful, this simple filter is a bit boring and difficult to make dynamic. So we’ll look into an entirely different filter, the Twin-T notch filter, that turns out to be sharp enough to build a sine-wave oscillator on, and tweakable enough that we’ll make a damped-oscillator drum sound out of it.

Here’s a quick demo of where we’re heading. Read on to see how we get there.

Continue reading “Logic Noise: Filters And Drums”

Universal Active Filters part 2 for Hackaday by Bil Herd

Universal Active Filters: Part 2

An easy way to conceptualize active filters is thinking about audio speakers. A speaker crossover has a low-pass, high-pass and band-pass effect breaking a signal into three components based upon frequency. In the previous part of this series I took that idea and applied it to a Universal Active Filter built with a single chip opamp based chip known as the UAF-42. By the way, it’s pretty much an older expensive chip, just one I picked out for demonstration.

Using a dual-ganged potentiometer, I was able to adjust the point at which frequencies are allowed to pass or be rejected. We could display this behavior by sweeping the circuit with my sweep frequency function generator which rapidly changes the frequency from low to high while we watch what can get through the filter.

In this installment I’ll test the theory that filtering out the harmonics which make up a square wave results in a predictable degradation of the waveform until at last it is a sine wave. This sine wave occurs at the fundamental frequency of the original square wave. Here’s the video but stick with me after the break to walk through each concept covered.

Continue reading “Universal Active Filters: Part 2”

Universal Active Filters Part 1

Universal Active Filters: Part 1

Today I am experimenting with a single chip Universal Active Filter, in this case I made a small PCB for the UAF-42 from Texas Instruments. I chose this part in particular as it facilitates setting the filter frequency by changing just a pair of resistors and the somewhat critical values that are contained on the chip have been laser trimmed for accuracy. This type of active filter includes Operational Amplifiers to supply gain and it supports various configurations including simultaneous operating modes such as Band Pass, Low Pass and High Pass make it “Universal”.

Filter Basics

Speaker Crossover Example
Speaker Crossover Example

Looking at the block diagram you can see where I have inserted a dual-ganged potentiometer to change both resistors simultaneously which should allow a straight forward adjustment for our purposes here.

Looking into the components of a simple RC filter which can easily implement a simple Low Pass or High Pass filter, we see that the math is fairly straight forward and swapping the components with each other is all that is needed to change the type of filter. Continue reading “Universal Active Filters: Part 1”

Passive Filters, Data Transmission And Equalization Oh My!

[Shahriar] is back with a new “The Signal Path” video. It has been a few months but it is okay because his videos are always packed full of good information. Some new equipment has been added to his lab and as an added bonus a quick tour of the equipment is included at the start, which is great if you like drooling over sweet machines.

The real focus of the video is high speed data communications, getting up into the GHz per second range. [Shahriar] covers filtering techniques from simple RC low pass filters to pretty complex microwave filters. Explaining frequency and time domain measurements of a 1.5Gbps signal through a low bandwidth channel. He also shows how equalization can be used to overcome low bandwidth limitations.

It is an hour long video jam packed with information, so you might want to set aside some time and have a pencil on hand before going in. It is well worth it though, so join us after the break.

Continue reading “Passive Filters, Data Transmission And Equalization Oh My!”