So the Noise Nugget is in final of the 2018 Hackaday Prize! That is amazing and I am very honored that my project was chosen.
I have a few ideas for the future of Noise Nugget. One of them is having a GUI that let the users to build their sounds with basic modules such as oscillators, filters, effects, etc. Similar to the teensy audio tools but in real-time, without any code involved for the users. This could make an interesting and versatile tiny synthesizer.
Noise Nugget is also a way for me to try some hardware design for another project: Wee Noise Maker. Because Noise Nugget is smaller, it cost less to have it manufactured so this allowed me to try different things before using them on a bigger project. For instance, this is my first 4 layers PCB. So I will probably use some of the prize reward to do a new iteration on the Wee Noise Maker project.
The software of the Noise Nugget is written in Ada. The Ada programming language is all about functional safety, that is, detect when the software is not doing what is supposed to do (bugs!). With Ada you know quickly and exactly what is going wrong instead of scratching you head for hours on a buffer overflow or uninitialized driver. This means less time spent debugging. And since I don't necessary have a lot time available to develop this software, every minutes counts.
The most important aspect of the software is to generate audio samples and send them to the DAC.
A sample is a 16bit signed integer that indicates the value of the audio signal at a given point in time.
The DAC is configured at 44_100 samples per seconds (CD quality). If the software fails to deliver the samples at the appropriate speed, the audio will glitch (loud pops and clicks). So this is a true real-time requirement of the system.
The samples are not sent one by one but in buffers of 512 samples * 2 bytes per samples * 2 channels (stereo), so 2048 bytes. Buffer B is filled while buffer A is transmitted, and vise versa (flip flop buffers). Samples coming from the audio input are received in a similar way. The transfer of the buffers is done via DMA so the CPU is not used during that operation, which means more time to generate the samples.
To ensure the real-time requirement, I use the Ada Ravenscar run-time. You can see it as a Real-Time Operating System (RTOS) integrated in the Ada programming language. I wrote a blog post about it if you want to see what it looks like: https://blog.adacore.com/theres-a-mini-rtos-in-my-language
There are two tasks in the system:
In terms of dependency, the drivers come from the Ada_Drivers_Library, a project I stared a couple years ago to encourage the use of Ada on micro-controllers. The audio synth is based on ada-synth-lib by Raphael Amiard.
The main goals of the hardware design are simplicity and small footprint.
The heart of the system is obviously the STM32F446 micro-controller. It is based on an ARM Cortex-M4 core with floating point unit running at 180MHz, and a ton of peripherals.
Around the STM32F4 we have:
I could have used the DACs of the STM32F4, but on one hand they are only 12bits vs 16bits for a proper audio DAC, and on the other hand it would have required extra circuitry to drive headphone. So using the SGTL5000 provides higher sound quality and simplicity. The SGTL5000 also have a lot of options for IOs:
This means a lot of options for different applications.
On the rev-B of Noise Nugget I didn't use the microphone input. I think this is a mistake because there is some room on the board for a MEMS mic, and that would open even more possibilities. For instance real-time voice effects or sample recording.
The design of the DFU button is inspired by the Numworks open calculator. If the button is pressed when you plug the USB cable, the STM32F4 automatically enters DFU mode. It is then very easy to install a different firmware without using any debug probe. With WebUSB, it is even possible to install from a
My TODO list for the next revision is:
I implemented a sampler mode for the Noise Nugget. It plays a single audio clip at different speeds to give the illusion of different notes.
For the moment the audio clip is stored in the main flash memory, with the code. There's not a lot of space available so I am limited to one sample of a couple hundreds kilobytes. In the future I will implement the drivers for the external flash chip that has 8MBytes of memory, that is 1 minute 30 seconds of audio. It might seem small, but samples are only a couple seconds long at most , so 1m30s is plenty.
I finally managed to make the Noise Nugget play notes from MIDI commands over USB!
I took me some time because there was no USB support in the driver library I'm using, so I had to write a USB stack from scratch :)
The synth code is based on ada-synth-lib from my friend Raphael. I used it to make a simple pulse wave sound with ADSR envelope.
One of the example projects that I wanted to do with the Noise Nugget was to use it as an audio effect.
This is what I demonstrate in this video:
The music in produced by the PO-20 (left), then goes through the Noise Nugget (center) and finally comes out of the small speaker (right). The flanging effect is enabled and disabled by pressing on the button of the Noise Nugget. The LED is lit when the effect is enabled.
Flanger/Flanging is a simple effect achieved by mixing a incoming signal with its echo, and slowly changing the period of the echo.
I did a first test on the board using the software of another project and it does work :)
Very short demo here: https://twitter.com/DesChips/status/1036333202028331008
Now, what's next with this little thing? There are multiple directions possible:
I think I will pick one or two ideas an implement them before the end of the month.
I received my assembled 1 square inch board from MacroFab yesterday:
It is the second time I use this service and I'm happy once again. It is quite expensive, but when you take into account the shipping for low quantity of parts (20 euros for Mouser), the cost of the 4 layers PCB and the difficulty of soldering a QFN20 part, I think it is worth the price.
This project started from the failure of the last iteration of my Wee Noise Maker board. Since the Wee Noise Maker board is relatively big an complicated, I decided to pack the main components in a simpler design to speed up the prototyping time and lower the cost. Turns out that this smaller board is quite interesting in itself.
The first iteration of Noise Nugget was designed around a 2xAAA battery holder :
When I saw the announcement of The Return of the Square Inch Project competition I decided to make a new version that would fit the requirements (1x1 inch board).
There's no real build instruction for Noise Nugget hardware because it only consist of a small electronic circuit.
You can assemble it by soldering each components according to the board design available in the repository.
However, some of the components are very small and difficult to solder by hand. So I recommend using PCB assembly services such as MarcroFab.
The Noise nugget software is developed in Ada, so you will need an the arm-elf GNAT Ada compiler. You can get and install the community edition from here: https://www.adacore.com/download
The sources are hosted on GitHub so you can get them with the git tool:
Go into the directory:
Get the dependencies with the git submodule command:
git submodule update --init --recursive