While going through drum pad practice yesterday, I noticed that my iPhone metronome app was broken after the latest update as it was ticking up on the second beat, not the first anymore. It was a small thing, but quite annoying, so I deleted the app and wrote my own Metronome app in Glimmer DSL for SWT in under 10 minutes for the initial working 4/4 rhythm version.
Afterwards, I decided to add more rhythm/bpm variations and include this app as a Glimmer DSL for SWT "Elaborate Sample". It is in fact the first Glimmer DSL for SWT internal sample to demonstrate use of the cross-platform Java Sound API via JRuby, a very practical and useful feature to have (though there is a Glimmer "External Sample" that makes use of the Java Sound API called Timer).
Here is a video of the Glimmer Metronome app with sound (I increment spinners with the arrows and with Page Up and Page Down keyboard button presses, which increment/decrement 10 at a time).
The code relied mainly on a separate `Thread` loop that checked what the bpm and beat count were and ticked sound accordingly using `wav` files for the metronome up and down sounds played by the Java Sound API. The `Thread` loop used an implicit `sync_exec` call in causing changes for the GUI to ensure that the lighting of on and off for both changed beats are rendered in the same go by SWT (not as separate rendering events to avoid a slight delay, which might not be perceptible anyways, but I chose to use sync_exec just in case). As for laying out the beats, I used a hybrid composite layout/canvas approach to avoid having to calculate the locations of every beat on the screen while still taking advantage of the Canvas Shape DSL. One last thing I wanted to ensure is that if I decrease or increase the number of beats (beat count), the window resizes accordingly to keep all beats on one line horizontally. This was accomplished by relying on the app body root (`shell` widget representing window) layout and pack methods, which refresh the layout and packed sizing of the window completely if you pass true for their arguments.
I did not do any crazy assurances of perfect real time in this very quick version of the Metronome. It is good enough for my needs though it could have been written in a handful of ways (using the new `animation` keyword, using data-binding based animation, heavy use of canvas math instead of grid layout, etc...). That said, I am sure that Metronome apps traditionally took months to build. Just imagine what you could do with all this extra time if you've built it in less than a day like I did. How many more features would you be able to add thanks to the productivity of Glimmer DSL for SWT, how many more client projects would you be able to handle, what else would you be able to do with your extra time or remaining months once you've delivered an app this quickly?
Glimmer DSL for SWT is the most productive cross-platform desktop development framework, bar none! I don't know anything as productive as Glimmer no matter the programming language or technology stack. All other solutions are either too cumbersome and imperative (as opposed to Glimmer's Domain Specific Language for SWT), too bureaucratic and ritualistic (as opposed to smart defaults and convention over configuration in Glimmer DSL for SWT), mix confusing or unproductive paradigms like XML/HTML (as opposed to the one-language approach of Glimmer DSL for SWT), or are based on a statically typed programming language not optimally productive for GUI (as opposed to dynamically typed Ruby, which is perfect for dynamic GUI authoring). I am not saying that different languages and technologies don't have their place. For example, Java is perfect for providing high-performance and robust cross-platform algorithm implementations. However, for practical application day-to-day development, software engineers benefit greatly in productivity and extensibility from a domain-specific language written on top of it in a dynamically typed language like Ruby, such as Glimmer DSL for SWT.
Otherwise, I added yet another sample demonstrating data-binding of the animation "every" property called Hello, Canvas Animation Data Binding!
Here is an animated screenshot of it.
Happy Glimmering!
p.s. For hardcore music buffs out there who are shocked at my reversal or wrong usage of Up beat and Down beat, here are a few explanations to keep in mind. First of all, I am a drumkit (Rock) drummer, not a melodic musician. As such, drumkit drummers call every beat on the rhythm count a DOWNBEAT (i.e. 1, 2, 3, 4). Next, I am a Punk Rocker and I've been known to do some Punk drumming. What do I mean by that!? Punk drummers have a complete lack of respect for music rules. In fact, they write their own rules every day, and OFTEN IN TOTAL OPPOSITION TO MUSIC RULES. So, I just came up with the idea of calling the first beat the UPBEAT because the Metronome makes this HIGHER note shrill sound when it clicks on the first beat. Thank you for your understanding and have an awesome Punk Rocking day while at it!
No comments:
Post a Comment