Tag Archives: audio

Dynamic microphone preamplifier

via Dangerous Prototypes


Dilshan Jayakody published a new build, a microphone preamplifier:

This is single chip dynamic microphone preamplifier which is design to drive using commonly available 12V single rail power supplies. Preamplifier in this article is build around popular NE5532 dual low noise operational amplifier IC and this preamplifier is specifically constructed to drive professional 600Ω dynamic microphones.
This preamplifier consists with two amplifier stages and initial amplifier is design to get 36dB gain and final preamplifier is used to get 16dB of gain. Preamplifier gain controller is placed in between those two amplifiers and this separation allows reducing clipping in output waveform.

Project info at  Jayakody’s blog and  Elect.wikispaces.com.

48V Phantom power supply

via Dangerous Prototypes


Dilshan Jayakody has designed and built a 48V Phantom power supply:

Phantom power supply is widely used in audio industry to power the active microphones over single audio cable. Most of the phantom power supplies deliver 48V DC over the balanced audio link and power supply unit described in this article is also based on same technique.
Phantom power supply in this article is based on TL783 high voltage regulator IC and 230V – 50V step down transformer. Like most of the phantom power supplies this power supply is also design to connect in between active microphone and audio mixer devices.

Project info at  Dilshan Jayakody’s blog.


Calculator for audio output transformers

via Dangerous Prototypes


Dilshan Jayakody  writes:

    Audio output transformers are heavily used in vacuum tube and some (older) transistor base audio power amplifiers, but these days output transformer are quiet hard to find and expensive item. For homebrew projects the best option is to construct those transformers by ourselves and this script helps to calculate winding parameters for those transformers.
This “AF output transformer calculator” script is written using Python and it works with most of the commonly available Python interpreters.

The script is available at elect.wikispaces.com.

Details at Dilshan’s blog.

Twitter for dogs

via Raspberry Pi

Henry Conklin’s dog, Oliver, is one of those very vocal dogs who likes to try to let you know what he’s thinking. By barking. A lot. Henry says:

I decided that his thoughts and comments needed to be shared with the world. Thus the @OliverBarkBark project was born. By connecting a Rasberry Pi, a wifi dongle, and a microphone, I was able to make a system that automatically detected, filtered, and published each and every one of Oliver’s deafening vocalizations.

Screen Shot 2015-08-19 at 12.58.14

Henry has built a system around a Raspberry Pi that listens out for sounds over a certain volume, and triggers a recording when that constraint is met.


But there are things in Oliver the dog’s vicinity which are also pretty noisy, so a second, filtering step is needed. Henry says:

Oliver barking is by far the loudest thing within several miles, so the volume threshold should be sufficient. However, the recordings are still triggered occasionally by unwanted junk. To guard against this, I needed to perform a second step to filter the barks from the junk.

I took a machine learning approach to filter out the barks. I built a model using the pyAudioAnalysis library and around a day’s worth of barks (about 20). I then set up a bash script to run every ten minutes, classify each recorded sound, and forward the barks on to the next step.

The output is forwarded to the Twitter API, where they’re published by an account called @OliverBarkBark. Right now, a random string of barks, woofs, howls, and ruffs are published, but Henry is looking at adding some more sophistication by designing a dog-to-text translator which will say “bark” when Oliver barks, “ruff” when Oliver ruffs, and “woof”…you get the idea.


All the code you’ll need to replicate the scheme in your own house (you’ll need a dog first) is available on Henry’s GitHub at https://github.com/HenryWConklin/barkdetect. Thanks Henry, and please give Oliver a biscuit for us.

The post Twitter for dogs appeared first on Raspberry Pi.

Roberts R300 Reinvention

via Raspberry Pi

Liz: today’s guest post comes from Gordon at IQAudIO, who makes and sells audio accessories for the Pi, which we really, really like – with one of his DACs you can turn your Pi into a proper audiophile-approved piece of kit. Gordon had made a project we really liked the look (and sound) of when we last saw him, so I asked him to write it up. Over to Gordon:

When my grandmother passed away many years ago I was asked if there was anything of hers I’d like to have in order to remember her by. The choice at the time was pretty easy for me – her bright red Roberts radio. This radio sat on her kitchen worktop, and whenever we visited I was always being told off for touching it, tuning it to some other radio station and spinning the whole thing around on its turntable base far too quickly.

The radio, somewhat the worse for wear.

The radio, somewhat the worse for wear.

My grandmother was affectionately called “Granny Hi-Tech”, simply because she was always the first to get hold of gadgets, most of which I assume she bought having seen them being demonstrated at the large department store in Glasgow where she worked during the 1960’s and 70’s.

The original intention on receiving the Roberts radio was to get it working again and keep everything authentic, but I really didn’t know where to start, so it was placed in a box and forgotten about. It’s moved house with us six times since, and was rediscovered, grubby and broken, during our last house move eight months ago.

A bit of a state

I did finally find a spare wet afternoon, but on taking the radio from the box and giving it a good look over, it was obvious I’d been seeing it through rose tinted glasses – it was much worse than expected, and although I may have been able to restore the inner workings, what stations can you pick up on Long and Medium Wave these days?

It was decided that a sympathetic transplant was called for, keeping the aesthetics of the original radio but delivering a modern music playback solution. Some parts of the radio were okay, some terrible and overall it had lost that lovely red colour that I fondly remembered. One of the dials had lost its brass cover, the grill was dented, the Roberts logo was yellow and broken, and the inside had corrosion in places.

A Roberts R300 with Airplay

I could have bought a cheap bluetooth speaker and transplanted the workings into the R300, but I wanted the original radio buttons to work as expected (on/off, volume) and wanted it to have some real musicality to surprise. I also wanted the ability to have synchronous playback across the house with my other HiFi systems. Overall it should look and feel like an original Vintage 1960s radio but in terms of audio performance I wanted it to sound awesome.

Enter the Raspberry Pi

There are several add-on boards for the Raspberry Pi, and we develop and sell a few of these ourselves. For this transplant I used our Pi-DigiAMP+. This Raspberry Pi HAT board takes the digital audio signals (I2S) from the Pi’s 40-way header, and delivers high-quality stereo audio up to 192MHz/24bit resolution – you just need to add speakers and a suitable power input to complete the job. The DigiAMP+ is designed to drive bookshelf or larger speakers – we usually pair it with QAcoustics 2010i or 3020 speakers, and it sounds simply brilliant. We demonstrated this very combination at the recent CamJam and also at the Recursion Computer show in Stratford-Upon-Avon.


The IQaudIO Pi-DigiAMP+ can run from 5v -> 18v, and has on-board circuitry to power the Raspberry Pi too. Here we have used a 15v/3.3amp power brick from XP Power – this will allow the Pi-DigiAMP+ to deliver 2x20watts into 4ohm speakers, with a little less into 8ohm drive units – more than enough for a bedroom or kitchen radio.

Using the Raspberry Pi allows us to take advantage of the many Linux-based music playback solutions available. We could have gone for Volumio, RuneAudio, Moode, PiCorePlayer, Pi MusicBox, Max2Play or others; but for this build we went with Mike Brady’s Shairport Sync. Mike is a computer science lecturer at Trinity College Dublin and has posted his source code on GitHub making it easy to build and modify if needed. We’ve been running Raspberry Pi-based Shairport Sync systems for a while with great reliability and ease of use. Thanks Mike!

Remove the unnecessary and rework the rest

Taking the radio to pieces was pretty simple; there were none of those annoying plastic clips you break when attempting to open a modern device. Here it’s mostly wood screws with the occasional brass nut and bolt. We carefully removed the innards and stripped down the radio to its bare components, unsoldered the 60s electronics and removed protruding and unnecessary metal that would make the overall transition more difficult.

Screen Shot 2015-07-22 at 12.39.25

Obviously, a 40-year-old paper mono speaker wasn’t going to cut the mustard, so we removed that too, replacing it with a pair (to give us both left and right channels) of full range Balanced Mode Radiator (BMRs) drive units – not only do these fit in the available space, but they sound good too.

Screen Shot 2015-07-22 at 12.42.21

Now left with a bare carcass, it needed a good old clean and polish, but what we didn’t expect was for the carrying handle’s leather strap to disintegrate, which was one of the key aesthetics, along with the base turntable, we really wanted to keep. A quick Google search and subsequent calls to Roberts themselves resulted in some replacement (but modern) parts being received next day, although we ended up only using the new silver “Roberts” logo, as the beautiful replacement red handle was just too big a colour difference.

Rebuilding the radio was just like a Haynes manual (refitting is the reverse sequence to removal). We cut an MDF support panel for the speaker drive units.

Screen Shot 2015-07-22 at 12.42.21


The analog volume potentiometer of the original was replaced with a simple 3-pin rotary encoder, wired to the Pi’s GPIO.  We used the sample code from the IQaudio GitHub repository to take the Rotary Encoder pulses and convert them into Linux ALSA volume commands.

Adding the Raspberry Pi and Pi-DigiAMP+ was the easiest part. The speakers were connected to the Pi-DigiAMP+ and the Official Raspberry Pi WiFi Dongle was added.


From the outside you wouldn’t know anything had changed, and to keep the functionality of the radio’s Off/Long Wave/Medium Wave selector, we wired it in-line to the positive power from the external power brick. Selecting either Long Wave or Medium Wave powers the Pi-DigiAMP+ and Pi, while selecting Off cuts the power to both – we added a simple power barrel connector onto the back of the radio so it wasn’t always tethered and didn’t have a flying lead.

Screen Shot 2015-07-22 at 12.50.42

Finally, we replaced the wooden wedges and measured up the display window (ordering another to be laser-cut from www.podbox.co.uk at the same time). We also added some sound damping from an old speaker we had lying around. The handle was repaired using some similar covered vinyl.


As with all good builds, there were a few extra pieces left over…


How does it sound?

Surprisingly good, way better than expected. It really makes us smile streaming Deezer/Apple Music to radio that’s nearly half a century old. Having the physical volume control just adds an extra retro feel too.

What’s left to do?

Having used the Raspberry Pi/IQaudio Radio for a while now, we’ve decided there are a few additional tweaks to perform when we find the time. These include:

  • Tuning Knob: We need to make the tuning dial do something. This may end up driving some RGB LEDs, delivering mood lighting OR capturing the dial’s position (via ADC), and converting that into one of several fixed radio streams, selecting each in turn simply by “re-tuning.”
  • Power LED: Although we do tend to leave the radio powered up permanently, it would be good to know if the kids have turned it off rather than the toaster.
  • The radio’s handle/strap needs work and this is where we’ll likely take the modern replacement purchased from Roberts Radio and re-colour it to match the original radio’s dulled finish. We’ve even found a shop called RevivedRadios on Etsy who can recover the Roberts radio in your chosen fabric. [Liz interjects – goddammit, I wish I hadn’t clicked that link. I really want one of those now.]
  • Better WiFi signal: Although we’ve got good range already with the Official USB dongle placed in the radio’s enclosure, it may be worth exposing the Raspberry Pi’s USB socket on the back of the radio case (for better signal reception) along with the Ethernet socket, allowing for direct network connection in suitable locations.
  • EQ/Bass boost: We could look at diving into the Pi-DigiAMP+’s integrated DSP and program it to get the best from the BMR drive units in the Roberts Radio case.
  • Battery operation: I’m thinking of adding a battery power source and charging circuit. It’s just too nice a radio to have it tied to a mains socket – it also stops me being able to spin the radio around and around listening to music as I did 40 years ago!

Parts list

  • Your Gran’s vintage radio
  • 1x Raspberry Pi
  • 1x Official Raspberry Pi USB WiFi adapter
  • 1x IQaudIO Pi-DigiAMP+
  • 1x XP Power 15v power supply (VEH60US15 / VEF50US15 or similar)
  • 1x ALPHA 3 pin Rotary Encoder (RE160F-40E3-20A-24P)
  • 2x HiWave 2x12w BMR speakers (RS Online stock no: 761-4265)
  • 1x 2.5mm / 5.5mm Barrel power socket ( DC-008-B-R)
  • SD card with Mike Brady’s Shairport Sync (available pre-configured with rotary encoder volume support from iqaudio.com/downloads)
  • Some wire
  • Some basic soldering skills

The post Roberts R300 Reinvention appeared first on Raspberry Pi.

RADIX-4 FFT (integer math).

via coolarduino

Updates on 30 Sept. 2014:

Everything below is correct, and may worth to read. But new  code based on Split Radix Real is published. Faster, lower memory demands, both version for UNO and DUE available as libraries.  New algorithm makes it possible to run FFT_SIZE =  512 on UNO board in less than 9.6 milliseconds.


Tweaking the FFT code, that I’ve published earlier in my series of blogs, I hit a “stone wall”. There are nothing could be improved in the “musical note recognition” version of the code, in order to make it faster. At least, nothing w/o completely switching to assembler language, what I’m trying to avoid for now.  I’m sure, it’s the fastest C algorithm. Looking around it didn’t take long to find out that there is other option: change RADIX-2 algorithm for RADIX with higher order, 4, 8, or split-radix approach. Putting split-radix aside, (would it be my next adventure?), RADIX-4 looks promising, with theoretically 1/4 reduction in number of multiplications (what I believe is an “Achilles heel”).

Googling for awhile, I couldn’t find fixed point version in plain C or C++ language. There is TI’s “Autoscaling Radix-4 FFT for MS320C6000TM” application report, which I find useful , but the problem is it’s “bind” with TI microprocessors hardware multiplier, and any attempt to re-write code would, probably, make it’s performance even worse than RADIX-2. Having “tweaking” experience with fix_fft source code from:  http://www.jjj.de/             I decide to follow same path, as I did before, adapting fix_fft for arduino: take their floating point source, disassemble it to the pieces, and than combine all parts back as fixed point or integer math components.    And you know what ? Thanks God, I successed!!!

I decided not all parts to re-assemble back again, this is why fft_size has to be power of 4 ( 16, 64, 256, 1024 etc.). Next, the software is “adjustable” for different level of the optimization. Trade is always the same, accuracy against speed. I’d highlight 3 level at this point:

1. No optimization, all math operation 15-bits.   The slowest version. Not tested at all.

2. Compromise version.  Switches: 12-bits Sine table, regular multiplication (long) right shifted >>12, Half-Scaling in the sum_dif_I (RSL) >>1. Recorded measurements result:  24 milliseconds with N = 256 fft_size.

3. Maximum optimization. Switches: 8-bits Sine table, macro assembler multiplication short cut, no scaling in the core. Timing 10.1 millisecond!!!

Fastest. Best of the Best Ever written FFT code for 8-bit microprocessor.   Enjoy the meal:   https://docs.google.com/open?id=0Bw4tXXvyWtFVMldRT3NFMGNTZVN0Y0d4eVRsenVZdw

Here is slightly modified copy, where I moved sine table from RAM to FLASH memory using progmem utility. For someone, who was curious to find the answer: how much progmem slower compare to access data in the RAM, there is an answer. 10.16 milliseconds become 10.28, or 120 usec slower. Divide by 84 x 6 = 504 number of readings, each progmem costs 0.24 useconds. Its about 4 cycles CPU.


Screenshot from the running application, signal generator running on the computer, feeding audio wave to OPA and than analog input 0. Look for hardware setup configuration on the “color organ” blog-post.

8080 8080sa 15000sa

BTW, there is one more important thing, I missed to emphasize in my short introductory paragraph, code offers FLEXIBILITY over SNR ratio. Basic FFT algorithm has an intrinsic “build-in” GAIN: G(in) = FFT_SIZE / 2 . (in) stands for intrinsic. That is perfect value for fft_size = 64 ( Gain = 64 / 2 = 32) and arduino (Atmel AtMega328)  10-bit ADC ( max value = 1023 ). FFT output would be 32 x 1023 = 32736, exactly 15 bit + sign. In other words, scaling in the algorithm core doesn’t required at all! That alone improve speed and lower rounding noise error significantly. The same time G(in)  grows too high with FFT_SIZE = 256, when G = 256 / 2 = 128 and output of the FFT would overflow size of 16-bit integer math. But again, scaling don’t have to be 100%, as long as there is a way to keep it in balance with ADC data. In this particular case, with 10-bit ADC, we can keep gain just below 32, it’s not necessary to make it exactly “1”.  For 12-bit ADC upper G limit would be 8, still not “1”. To manipulate the gain, division by 2 (>> 1) in the “sum_dif_I” could be set, to prevent overflow with fft_size > 64. Right shift “gain limiter” creates a square root adjustment, according to new formula: G(rsl) = SQRT (FFT_SIZE) / 4 . (rsl) stands for right-shift-limiter.

  1.  G = 1 for fft_size = 16,
  2.  G = 2 for fft_size = 64,
  3.  G = 4 for fft_size = 256,
  4.  G = 8 for fft_size = 1024.

Summing up, for using RADIX-4 with arduino ADC and FFT_SIZE <= 64, keep division by 2 (>> 1) in the “sum_dif_I” commented out. In any other circumstances, >10 bits external ADC, >64 fft_size, uncomment it.

To be continue…..