Final Project
Final project Initial conception (Febuary 2022) Learning to play any musical instrument takes a very long time and a lot of effort. To enjoy music …
Computer Aided Design forms an important part in digital design and digital fabrication. My history with computer aided design began in 1994 with 3d Studio R1 for DOS. Later I learned about Rhinoceros and 3dsMax, worked with AutoCad during college and finally settled on a workflow combining the features of Blender, Rhinoceros and OpenSCAD for modelling. Some parts of computer aided design I hardly touch:
For each of these I will have to learn something new.
Because the text below will be quite long, it’s probably best to first show what this week’s work has lead to.
The instrument that can not play a wrong note. (which still needs a better name) |
If the video doesn’t work: watch on youtube.
I will use FreeCAD to draw an initial sketch of my final product.
By importing the FreeCAD model to blender I hope to assign fitting materials and textures to my object
Blender will also be used to animate and possibly simulate parts of the model. Animation would be particularly useful to show how I might make force sensitive buttons that still can be back-lit.
Because my design will feature back-lit buttons, I will add realistic lighting to my final renders.
Rhinoceros3d is familiar terrain form me. It allows for very fast previews of final products. Unfortunately, its destructive modelling workflow makes it cumbersome to iterate on previously constructed models. If measurements need to be altered once the model is made, parts of the geometry have to be deleted and rebuilt. For a first visualization, the free-form modelling workflow is great, so that’s what I used.
Base shape constructed from two circles and tangent lines | Used the trim command to delete lines |
Base shape duplicated and offset to indicate height |
Used the loft command to create the 3d shape of the base |
A single key was made using two circles, connected by 2 lines | _ExtrudeCrv command used to extrude to a solid |
Key shape duplicated 24 times with ArrayPolar command |
3d keys |
Used a boolean to cut keys from the top plate | Gave the top-plate a wood texture, for now |
The final render from within Rhino gives a nice impression of what the end-result could be |
To start a part in FreeCAD, one has to select the option “part design” in the combobox at the to of the screen. The first part I want to make is the circular keyboard.
To make the design parametric, I will start a spreadsheet. |
The keyboard will consist of buttons that describe 1/24th of a ring.
Two circles where made and two lines were drawn from the center to the edge of the outer circle.A horizontal construction line was made to keep the two outer edges of the button fixed in the horizontal center |
By trimming, a 2d sketch of the key was constructed… | … and turned 3d by making a pad |
Using the PolarPattern command the key was copied in a circular pattern to make up the keyboard |
FAILURE |
---|
As it turns out, using the trim function in a constrained sketch will lead to unconstrained geometry." |
The key shape could be deformed and follow-up calculations weren’t executed correctly. |
The second mistake was to confuse PolarPattern
with PolarArray
. PolarPattern
joins copied geometry into one single mesh. I deeded PolarArray
from the draft
menu.
Solution |
---|
I was approaching this the Rhino way, where destructive modelling is the main approach. In programs like FreeCAD you draw construction lines that help you draw the actual sketch. I added three more construction lines as anchor points for the endpoints of the inner and outer arc that make up the circular edges of the key. |
Now I was able to draw the key and it stayed fully constrained. |
To parametrically have spaces between the keys I had to calculate the angle between keys based on the desired spacing.
x: the desired spacing between keys, r1: the inner radius, alpha: the desired angle |
which led to the equation:
\[ \alpha=\arcsin{x \over r_1}\]
to calculate the angle of the spacing.
Entered the formulas into the spreadsheet |
Adjusting the spacing in my spreadsheet directly changes this in the sketch, therefore changing it in the 3d object. The main keyboard is now fully parametric.
The top panel of the instrument will be a flat, milky-white (opal) acrylic plate. For now the plate is designed only with the keys cut, using the keyboard part, previously described. The sketch for the top-panel:
Top panel sketch | Top panel |
The command Cut
command from the part
workbench was used to make cut out the keys from the panel.
I decided to return to FreeCad at a later stage of the project because I really wanted to try rendering an animation in Blender.
Rhino is great for creating accurate but organic like models. It has a nice renderer but to generate a realistic image, Blender with it’s Cycles renderer would be a much better choice. Blender allows has some nice features I wanted to use and learn more about:
The final keyboard will partially communicate its state using RGB LEDs that are lighting an opal acrylic plate from the back. To visualize how that might look, an experiment was conducted in Blender, using the Cycles rendering engine and the Sub Surface Scattering material property.
A grid of thin, scaled cubes was constructed to act as walls that keep light from bleeding | The grid was set to have a high value for sub-surface scattering |
A sphere with an emission material was used to simulate an RGB LED | The sphere was set to follow a circular path |
The camera was animated to show the underside and the top-side of the geometry |
The final render was set to denoise the images using hardware desnoising using the compositor |
The final result |
If the video doesn’t work: watch on youtube
I chose to export the model as an .obj
object, because it would let me integrate the textures and keep texture mapping. First I tried to export it as a NURBS object but blender didn’t like it.
I selected to export the object as a mesh | Rhino allows you to determine the mesh detail generated from the NURBS objects |
Blender assumes that one unit is one meter, while most CAD software will assume that one unit is one millimeter. This always leads to having huge objects in Blender.
The imported objects are so large they fall outside of the z-buffer range and disappear | Scaling the object brings it back in visible range |
Furthermore, Rhino exports all the loose parts of an object as one single object.
Blender has an option to separate all meshes |
When separating meshes in loose parts, some surfaces may become separated.
Objects can be reconstructed from their loose parts using the weld modifier and applying it. |
The final scene graph looked like this |
Two tricks were used to simulate realistic lighting
Using a HDRI image to light the scene | As an HDRI lightmap I chose an image of an indoor, industrial looking storage facility. |
The added benefit was that this would also serve as the background of the animation.
For extra lighting I added two light planes, which also reflect on the wood surface |
To create a glossy, slightly bumpy wood material I used the shader graph
The wood shader-graph | The final material, reflecting the light planes |
Using the results of the backlight experiment I made the LEDs from spheres with a highly emissive material.
I made two sets of LED’s to simulate two chords being played |
The two sets of LEDs were interfering with each other so I had to hide and show them in during the animation by setting animation keys for object visibility
The resulting timeline for the LEDs looks like this, changing the emission value and the visibility of the LEDs over time |
To show the LED’s reacting to the audio, four chords were extracted from the original youtube video.
OBS studio was used to rip the audio track from the youtube video. Audacity was used to extract four chord pairs .wav file was loaded into blender |
The animation sequence would show a couple of chord progressions being played on the device. Each different progression would show another camera angle, slowly panning before making a jump cut to the next angle.
To have more control over the camera a Track To constraint was added to the camera object, making it point towards another object as the target. |
A single camera was used to simulate multiple shots by making the camera jump from one position to another and then track slowly to another position. |
Bezier path interpolation make the camera motion look more naturally |
But I didn’t like that so I made all movements linear, which gave a more controlled feel |
The OLED display had to change text once in a while.
I found a nice font for the OLED display. |
Using the GIMP I made a couple of diplay states in one file, as separate layers
First as separate text objects… | …and then merged to have 10 text states |
Storing all LED states to one separate numbered files allowed me to have an image sequence as a shader
An image sequence texture can point to any numbered image file |
But to have the texture change for a determined amount of frames proved challenging and I had to make a “driver”, linking multiple variables together |
When everything was moving the way I wanted it to I wanted something to make clear that the LEDs and the OLED were actually light sources. This was achieved by adding a glow in the compositor.
Linking the denoised image to the glow filter allows you to add glow to specific parts of the image |
Rendering 900 frames of animation resulted in 900 separate images. Using ffmpeg
I could easily convert those images into an mp4 file
ffmpeg -r 24 -i %04d.png -vcodec libx264 -b:v 768k -vf scale=-2:720 -an instrument_previz.mp4
And lastly, I had to add the audio to the final animation. This didn’t succeed at first because the animation was rendered at a different framerate as ffmpeg
was set to, but in the end it matched up nicely.
I used KDENLive to add the sound to the final animation |
A lot of 2d vector drawing software exists. The most familiar open source solution is InkScape. I am not fond of InkScape, as it is very slow on most systems, due to the lack of GPU support. Most 3d software have powerful 2d drawing capabilities and of the 3d packages I know it is my opinion that Rhino3D has one of the most capable 2d drawing capabilities. It has freeform capabilities that rival 2d drawing software but with tools that are often found in classic CAD software packages. I once bought Rhino3D because of it’s excellent 2d capabilities.
To show my proficiency in drawing 2d vector images, I decided to dust of an old project I created 13 years ago, but never published before. It is a set of KiCAD footprints that are essentially a set of coins, drawn at 1:1 scale, that can be loaded into any PCB design as a size reference. For this I needed vector drawings of coins. I tried to get these by converting bitmaps to vector drawings but the results weren’t good enough, so I proceeded to draw them by hand.
Rhino3D had good options for loading in background bitmaps to act as a reference. I traced all common US and EU coins using NURBS splines, circles and the trim operation. |
In the KiCAD footprint editor there is an option to load .dxf files | This results in a clean footprint to be used in a project. |
Most common US and EU coins are represented |
The resulting footprint library can be found here.
Did I achieve my goals for this week?
I will use FreeCAD to draw an initial sketch of my final product.
It took me some time to get used to the parametric modelling mindset. I am confident now I will be able to model the rest of the device in FreeCAD but I wasn’t able to do the entire design using this workflow. Ultimately I resorted to my old tricks to proceed animating and lighting. This goal is half reached but will be a big part in future work.
By importing the FreeCAD model to blender I hope to assign fitting materials and texturemaps to my object
Which turned out to be the Rhino model, but nevertheless I think I was able to nicely visualize a glossy, blinky instrument.
Blender will also be used to animate and possibly simulate parts of the model. Animation would be particularily useful to show how I might make force sensitive buttons that still can be back-lit.
Although simulation hasn’t been part of the animation, I’m still happy how it turned out. The final animation quit glossy and glowy and gives a sort of tranquil feeling to the user. Due to the slow camera movements but probably als due to the isolated chords being played. It conveys nicely how the instrument should look but I’m not convinced this animation shows the entire purpose of the device. For that you still need my explanation.
Because my design will feature back-lit buttons, I will add realistic lighting to my final renders.
It’s glowy!
I set out to do parametric modelling but really liked having a chance to do some animation and visualization. I am happy with the end result but putting more time into modelling would probably have helped me out better in the course of the project.
Final project Initial conception (Febuary 2022) Learning to play any musical instrument takes a very long time and a lot of effort. To enjoy music …
What I did. I created the enclosure and designed and milled all the PCBs. TODO Hardware Priority 1 20 x Button LED caps 8x Octave1 8x Octave2 4x chord …