Implementing a logout function in Tapestry 5

I’m working on a couple Java projects right now and so I decided to jump in and give Tapestry 5 a try. So far I’m really liking it, although as many have griped with Tapestry in the past, the documentation is minimal.

As you might already be aware, Tapestry 4 had a RestartService that you could use straight from your page via a ServiceLink. I wasn’t able to find anything similar in T5, and a fair bit of Googling yielded no obvious results on how to implement a logout. Finally I found a way to get at the HttpSession, and from there it’s simply a matter of invalidating it.

Here’s the code for your page/component:

<t:actionlink id=”logout”>Logout</t:actionlink>

Here’s the code for your Java class:

import org.apache.tapestry5.ioc.annotations.Inject;
import com.yourapp.pages.Index;

public class Border {
  private RequestGlobals requestGlobals;
  public Object onActionFromLogout() {
    return Index.class;

Hopefully this will save somebody a bit of time.

How to make NES music

I like video games, music and synthesizers. Nothing brings these three things together quite like the soundtrack from a NES game. Sure, there’s the C64’s SID chip, but alas, I never owned a C64 (side note: check out Quadrasid and Sidstation).

So then, you say you want to write some original NES music? There are some good resources on the web (here’s a starting point), but I wanted to summarize the two main approaches and my experiences.

Use synthesizers

There are a couple important things to keep in mind when using modern synthesizers to write NES music:

  • The NES had 5 channels:
    • 1 triangle
    • 2 pulse (with only 4 duty cycles to choose from)
    • 1 noise
    • 1 D-PCM
  • The NES had no effects or filters, although basic chorus and echo effects could be achieved by using two channels

The triangle and pulse channels are easy enough to simulate, but the noise and D-PCM take a bit more work. My earlier attempts at writing NES music were done mostly with my workhorse subtractive synth, NI Pro53. I also played around with Waldorf Attack to simulate the noise channel, and Bitcrusher to simulate the D-PCM channel, with varying degrees of success.

I recently came across the NES VST pack. It consists of 3 plug-ins: pulse, triangle and noise. The pulse plug-in has a switch to toggle between the 4 duty cycles. The noise plug-in has 2 noise modes and allows you to “sweep” the noise. All 3 plug-ins are quite faithful to the original NES sound chip.

Here’s a little demo I whipped together with nothing but the NES VST pack and the default FL Studio limiter. Update Sept. 09: by popular demand here’s the FL project (you’ll need FL Studio 8 to open it)

Use the actual hardware (or emulation)

If you’ve got a bit of money to spend, Wayfar makes something called the MIDINES. It’s basically modified NES cartridge that runs custom software and provides a MIDI interface to the actual NES sound chip! Check out the demos!

Otherwise, take a look at trackers like Famitracker or Nerdtracker ii. These allow you to create NSF (NES sound format) files which can then be played back with an NSF player. If you’re not familiar with trackers then these will be a bit awkward to use at first, but next to the MIDINES they will give you the most convincing results.

I bought an amp

I picked up a Fender Vibro Champ XD this weekend! It’s part of Fender’s “modified” line, so basically they’ve taken the old Vibro Champ and added some new features.

  • 5 Watt tube “Class A” power amp
  • One 6V6 output tube
  • One 12AX7 preamp tube
  • 8 inch Special Design speaker
  • Voicing knob with 16 different amp voices delivering various clean and overdriven tones for any style of music: blues, rock, country, jazz, metal, and more.
  • 16 effects (some are variations/combinations)

I had been using software for the longest time (mostly Amplitube, but Simuanalog is also worth a mention), but was getting annoyed with always being tied to the computer whenever I wanted to play guitar (a wine red Mexican Strat, if you were wondering).

The great thing about this amp is that it has the warmth and characteristics of tubes, but with modern niceties like amp simulation (via the “voices” knob) and on-board digital effects.

Here are the 16 voices:

1 A vintage tone based on early Fender® Tweed Champ® amps.
2 A fat vintage tone based on early Fender® Tweed Bassman® amps.
3 Heavily overdriven Tweed tone.

4 A bright vintage tone based on early Fender® Blackface™ amplifiers.
5 A bright, slightly overdriven vintage tone based on early Fender® Blackface™ amplifiers.
6 A bright, heavily overdriven vintage tone based on early Fender® Blackface™ amplifiers.

7 A bright jangly tone reminiscent of early British combo amplifiers.
8 An overdriven vintage tone based on early high-gain British stack amplifiers.
9 A high-gain distorted tone based on modern British stack amplifiers.

10 A high-gain overdriven tone based on the Fender® Hod Rod® series of amplifiers.
11 A high-gain distorted tone based on specialized boutique amplifiers.
12 More gain, more sustain!

13 A darker super high-gain scooped metal tone.
14 A sustained super high-gain scooped metal tone based on modern heavy metal amplifiers like the Fender® Metalhead™.

15 A clean amplifier tone optimized for jazz styles with the character of the Fender® Jazz King™ amplifier.

16 A super clean amplifier tone with the character of an Acoustasonic™ amplifier
good for acoustic finger-picking.

Here’s a video that shows off some of the voices (the video was made with its bigger brother, the Super Champ XD, but the voices and effects are the same). There are also some clips on the Fender site.

As others have commented, an effects loop would have been nice. The on-board effects are decent enough, but limiting (i.e. 3 delay lengths, 2 chorus speeds, etc.). Either way I’m loving this amp, especially given the price ($250!). For a 5W with an 8″ it’s surprisingly loud. I haven’t been able to turn it up past 2, although I’m looking forward to it.

In case you were curious, the last time I owned an amp I was still in high school. It was an absolute beast – solid state Peavey Renown 2×12. Loud as hell.