Procedurally Generated Trees

As the leaves fall from the trees here in the Northern Hemisphere, we are greeted with a clear view of the branches and limbs that make up the skeleton of the tree. [Nicolas McDonald] made a simple observation while looking at trees, that the sum of the cross-sectional area is conserved when a branch splits. This observation was also made by Leonardo Da Vinci (according to Pamela Taylor’s Da Vinci’s Notebooks). Inspired by the observation, [Nicolas] decided to model a tree growing for his own curiosity.

The simulation tries to approximate how trees spread nutrients. The nutrients travel from the roots to the limbs, splitting proportionally to the area. [Nicolas’] model only allows for binary splits but some plants split three ways rather than just two ways. The decision on where to split is somewhat arbitrary as [Nicolas] hasn’t found any sort of rule or method that nature uses. It ended up just being a hardcoded value that’s multiplied by an exponential decay based on the depth of the branch. The direction of the split is determined by the density of the leaves, the size of the branch, and the direction of the parent branch. To top it off, a particle cloud was attached at the end of each branch past a certain depth.

By tweaking different parameters, the model can generate different species like evergreens and bonsai-like trees. The code is hosted on GitHub and we’re impressed by how small the actual tree model code is (about 250 lines of C++). The power of making an observation and incorporating it into a project is clear here and the results are just beautiful. If you’re looking for a bit more procedurally generation in your life, check out this medieval city generator.

Procedurally Generated Retrocomputer Emulators

[Marquis de Geek] has a profound love of old systems. Tired of writing new emulators from scratch for each project, his newest project EMF generates the emulator for him. An XML document describes the layout of the memory, CPU description, and screen handler. The output is currently a single-page Javascript emulator application with an assembly and a dissembler. However, but that backend can easily be swapped to another language such as Rust or C++.

Since EMF is a framework that provides a common way to describe the emulated machine, you get a common emulator user interface for free. There’s a lot of flexibility offered here as well. Opcodes can be implemented as a large switch statement or individual functions, depending on the target language’s performance. Self-modifying code can be detected and handled separately. Custom features or hardware can be injected easily by writing a module in the target language.

While the source code for the EMF hasn’t been released yet, several of the machines that [Marquis de Geek] has built with EMF are open-source on GitHub. So far the list includes Dragon32, Sinclair ZX80, Sinclair ZX81, Sinclair ZX Spectrum, Elliott 903, Chip8, Cosmac VIP, and the MegaProcessor. Each has a live emulator that runs in your browser.

While [Marquis de Geek] hopes to release a binary version of the EMF soon, we’re very much looking forward to the EMF source coming out once the code has been cleaned up. We love the trend towards creating easier and more accessible emulators, such as this Twitter bot that runs Atari programs.

Continue reading “Procedurally Generated Retrocomputer Emulators”

Procedural Barcode Synth Is As Simple As Black And White

We are no stranger to peculiar and wonderful musical instruments here at Hackaday. [James Bruton] has long been fascinated with barcode scanners as an input source for music and now has a procedural barcode-powered synth to add to his growing collection of handmade instruments. We’ve previously covered his barcode guitar, which converts a string of numbers from the PS/2 output to pitches. This meant having a large number of barcodes printed as each pitch required a separate barcode. As you can imagine, this makes for a rather unwieldy and large instrument.

Rather than looking at the textual output of the reader, [James] cracked it open and put it to the oscilloscope. Once inside, he found a good source that outputs a square wave corresponding to the black and white lines that the barcode sees. Since the barcodes [James] is using don’t have the proper start and stop codes, the barcode reader continuously scans.  Normally it would stop the laser to send the text over the USB or PS/2 connection. A simple 5v to 3.3v level shifter feeds that square wave into a Teensy board, which outputs the audio.

A video showcasing a similar technique inspired [James] with this project. The creators of that video have a huge wall of different patterns of black and white lines. [James’s] next stroke of brilliance was to have a small HDMI display to generate the barcodes on the fly. A Raspberry Pi 4 reads in various buttons via GPIO and displays the resulting barcode on the screen. A quick 3d printed shell rounds out the build nicely, keeping things small and compact. All the code and CAD files are up on GitHub.

Continue reading “Procedural Barcode Synth Is As Simple As Black And White”