There’s a lot of flexibility in how you can use authorisation rules in Razor components*, but a frustration of this approach is that it seems like you have to slap @attribute [Authorize(Policy = "PolicyName")] at the top or every page with no clear way of applying a given policy to a whole folder of .razor files. After much research and testing, I’ve found how to go about it!
I’ve noticed an issue recently after upgrading a few Blazor projects from .NET 5 to .NET 6 where the UI flashes after every call to StateHasChanged. Something like this:
Yeah, that’s not annoying at all. Unfortunately it was happening in quite a few different places and was pretty darn noticeable, so it looked like I was going to have to dive in and figure out what exactly was causing this to go wrong (despite working perfectly in .NET 5)!
Part 4 – Final Implementation (you’re already here!)
So SoundFloored is now working just like I wanted it to with buttons and a screen, but the current build isn’t exactly what I would call robust. As such, the final part of the build involves moving what I’ve built so far into a more permanent home, one that can withstand the rigours of live performance and is far more practical to move around.
Since there were going to be four footswitches across the length of the pedal, it would need to be 28cm long (3 x 7cm for the gaps between each switch, plus 2 x 3.5cm for the gaps between the outer switches and the edge). Similar maths for the two footswitches going across the width of the pedal gives us 14cm (7cm for the gap plus 2 x 3.5cm for the edges).
I wanted to find something with these dimensions (or near enough) that I could use to house everything, so I started by looking at “project boxes” (plastic boxes designed for maker projects like this). Unfortunately, the largest project box I could easily order was barely half the size that I needed and I wasn’t interested in putting in a custom order to create one. The only option left at this point was to build something myself!
I figured that wood would be the best material for this project; although not the traditional material for a pedal, I could make it pretty much whatever size I wanted, it’s readily available, cheap and I already have some basic experience in woodworking.
At this point even though I had the dimensions I wanted to get a better perspective of how big the pedal was going to be before I started building anything. Mediocre arts and crafts to the rescue!
So this project has really been gaining some steam! I’ve figured out the design and managed to get a software implementation with two separate interfaces. Now though, I’m entering uncharted territory; the world of hardware electronics.
Now I say uncharted territory, but I’d be remiss if I didn’t mention that I’ve previously watched a Pluralsight course called something like “Introduction to Electronics” or “Electronics Fundamentals”, although it’s also worth mentioning that I remember approximately 5% of the content. Actually, one of the few things I did remember was how a breadboard works, which is a place to start at least!
So although I’ve owned a number of Raspberry Pis over the years and have a lot of HATs/pHATs to go with them, I’ve never ventured far enough into the hardware electronics side of things to have bought any components. As such, I ordered a pretty generic looking “Electronics Fun Kit” that had pretty much everything I might need for this project; a breadboard, wires (especially wires that I could use to connect the Pi directly to the breadboard), buttons, LEDs, resistors etc. I’m sure there are higher quality components out there, but since this is all for prototyping I decided that in this case cheap and cheerful was what I was looking for.
So now that I’ve prepared what I can, it’s now the step that can often derail the whole project: implementation.
For context the “Plan” section of this post was written before I started writing any code and “Implementation” was written shortly after I’d put the first version together.
I know, I know, I’ve already done the planning in the first part, “when are you actually going to start writing code“?
Well, except for tiny projects (usually single file, one-off scripts) I like to spend some time considering how the different parts will interact. The reasoning is that as soon as you start working with multiple modules and classes you’ve really got to consider how the parts will hang together, including what should “own” which parts of the logic, what the different interfaces should be and how the code should be laid out.
So I’m a guitarist in a band (shout-out to #DemocracyManifest). Not a particularly good guitarist, but nonetheless it’s a whole lot of fun and a great excuse to hang out with some friends for our weekly practice.
One of the issues that we have is that there are only three of us in the band; a guitarist, a bassist and a drummer. This is the dream when it comes to planning practices, but we’ve always had trouble with feeling our sound is “full” enough since a lot of the songs we cover have way more instruments and numerous subtle elements like small synth riffs, choir aahs and audio clips that we can’t really replicate in any appreciable way while trying to also play our instruments.
So “hey” I thought, “let’s try to over-engineer build something that can”!