Jump to content

DIY Sound Box


mrp

Recommended Posts

(Instead of hijacking JR 500系’s “Station Sounds” thread, I thought it would be better to start a new topic here for this project.)

 
I’ve been collecting various station sound effects for a project I’m working on building a real-time sound generator around a $35 Raspberry Pi.
 
For testing I’ve programmed 8 buttons (eventually I want it to trigger automatically as trains arrive and leave the stations):
1 - announcement
2 - train arriving
3 - brake/flange squeal
4 - door open & announce
5 - warning chime, announce & door close
6 - brake release & train departing
7 - horn
8 - station jingle
 
Here’s a quick demo:
 
 
One thing I like about doing it on the Raspberry Pi is that there’s enough horsepower to mix raw PCM sound samples on the fly, so any number of sounds can play at the same time.  That seems to be a problem with that fancy Taiwanese PCM / VVVF controller that was discussed a while ago.  If you listen carefully to the demo, you can hear the current sound effect abruptly cut off as soon as the button for the next effect is pressed.
 
  • Like 2
Link to comment

This is seriously cool. Since it's a linux based pc, the possibilities are almost endless. I would like to ask what kind of input circuit do you use for the buttons and if the software and the samples will be open source in the future? (i have a surplus pi laying around at my workplace that was used as a signal generator in a previous project)

 

 

Hi kvp,

 
The buttons are just contact closures to ground wired directly to eight Pi GPIO inputs (which by default already have weak pullups enabled).  To break out the pins, I’m using a T-Cobbler from Adafruit.
 
post-2339-0-08016600-1434512753_thumb.jpg
 
I saw your comment on the lighting thread, where you wrote: “It's more or less understandable if someone wants to keep their sources secret, otherwise everyone would have the same cool things.  It's the same as with closed and open source.”  I guess I buy in to that way of thinking a bit.  :)
 
Also, I snagged my sound samples from a number of different places - some more dubious than others - for strictly personal use.  To make an open source Sound Box, I assume you’d need to include a full set of open source sound samples with copyrights, etc.
 
Anyway - all that being said - I’m more than happy to send a copy of my development directory (including source code and sound samples) using PM to anyone who wants to try it out.  I’d just prefer not to post it directly to the forum.
 
Note that it’s very much a “work in progress”.  Unfortunately I’ve been snowed under with real-life work for the last few months so my modelling projects have pretty much ground to a halt.
 
The audio samples are all stored as raw little-endian (Intel) 16-bit signed 16000bps.  (I convert them first on my Mac using Switch).
 
When the player application starts up, it loads a buttons.txt file which defines the sequences for each of the buttons.  For example, the entry for button no. 5 is:
 
; bell / announce / door close
[b5]
P 93
W 3
P 104
W 3
P 110
W 3
P 57
 
This means:
P)lay sound 93 (JR Bell A)
W)ait 3 seconds
P)lay sound 104 (Announce Line 3 - Male)
W)ait 3 seconds
P)lay sound 110 (Announce Door Close - Male)
W)ait 3 seconds
P)lay sound 57 (Door Closing)
 
Edit:  Hi kvp, I’ve sent you a DropBox link to the source code and sound samples using PM.  Anyone else who wants a copy, just send me a message.  Thanks, mrp
Edited by mrp
Link to comment

Brilliant MRP, brilliant!

 

The rasberry pi has a lot of offer! Amazing what video it can do as well!

 

Jeff

Edited by cteno4
Link to comment

I've just read through the source and it was a huge work. Hardware and audio i/o, sound resampling and real time mixing and even an event driven script language. Thanks for this great work! I'll check it out live as soon as i can get the required hardware in shape. From the looks of it, i think the button inputs should be Tomix TCS sensor compatible without serious code modifications. This solution is a great idea and i think the functionality could be extended further. (like support for external event buses and other features)

 

ps: I think you should add a copyright message (like Creative Commons or GPL) to each source file, so it can't be turned into a commercial product without your permission. Then the source could be distributed even without the sound samples or with a few free examples only as people interested in non japanese themes could use it too. Then maybe you could pack the japanese sounds into a sound library for the base player and have a 'personal use only if the local law allows' notification on those files.

Link to comment

I guess I'm a bit skeptical that simply adding a copyright notice would stop anyone turning it into a commercial product.  I’m guessing most open source software eventually ends up hidden away unattributed in commercial products.  :(

 

I forgot to mention - when you start up the player it forks a console reader so you can test it out without having any physical buttons connected.
 
The commands are:
add <sound index> [repeats] [volume]
- add a sound to the mix; if repeats = zero, sound will loop indefinitely (defaults to 1);
- optional volume is +/-
del <sound index>
- remove looping sound from mix
B <button id>
- simulate button press
 
I spent some time with a sample editor making sure that the background sounds can loop continuously without any clicks or pops - for example, the background platform hum (082) 082_hum.wav, the motor noise (099) 099_motor.wav, and the various compressor loops (025-029).
 
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...