Summary:
The push button starts the sequence and the Red light is switched on and the idle tone is played. Then the Green light is switched on and the 'chirp' sound plays with the woodpecker sound following that. This continues for 10 seconds and then the Red light starts to flash (don't walk phase) while the idle tone plays in sequence with the flashing. Finally a solid Red light completes the cycle, with a few more idle tones to follow. As I didn't want the idle tone playing indefinitely, the sound stops after three or so times. If there is some demand for a continuous tone loop, then I may add this to the source as a flag.
Circuit:
See the schematic for the basic wiring. I use a 12v PSU for the main DC that runs the lamps connected via the relay modules. A DC-DC convertor is used to bring the voltage down to the Arduino's 5V operational level.
Arduino source:
The source is deliberately simple so as many people as possible could follow along. No classes / objects are used, its just straight procedural C. The major functions are defined for convenience over saving available code space on the device. This makes it super easy in case you need to adjust your relays to active HIGH instead of active LOW. These high level settings are in just one common function per relay, that is shared by the rest of the program.
Details on the sound:
After getting the source audio into the analysis software, there were three distinct sequences that were required. I called these audio functions: playIdle, playChirp and playWoodpecker.
Play Idle uses a 973Hz tone that runs for 25ms, followed by an 1800ms delay in between pulses.
The Chirp sound consists of 11 separate tones, each played for 11ms, totalling 121ms. I calculated 125ms from the spectral analysis so this was close enough. The tones are stored in an array and play in order within a for loop that cycles through each one.
Play Woodpecker is a fast 500Hz beat. Each tone lasts a very short 30ms, with a delay of 117ms between beats. This lasts a generous 10 seconds, which is frankly a lot longer than most crossings in real life!
The idle tone is used again during the final red flashing sequence and subsequent wait sequence.
The walk and don't walk pictographs in the first photo are reversed - the red lamp has the walk pictograph, and the green lamp has the don't walk pictograph.