热度 32
2014-12-8 15:26
1552 次阅读|
0 个评论
I must say I am in a bit of a quandary. Things are racing merrily along with regard to several of my hobby projects, including my Vetinari Clock and my Inamorata Prognostication Engine , but now I've hit a stumbling block. The thing is that I'm planning on equipping both of the above projects with sound effects, but I'm not sure how to go about achieving the effects I require. In the case of the Vetinari Clock, for example, I'm going to want a "tick-tock" sound. When we reach the turn of the hour, I'm going to want a straining sound ending in a "Ker-thump" as the hour hand moves to its new position. I'm also going to want a variety of mechanical clockwork sounds, along with some hydraulic and pneumatic sounds. Similarly, in the case of the Inamorata Prognostication Engine, when someone flicks a switch, for example, I want to have sounds like clockwork gears grinding, ball bearings rolling down slopes and dropping through tubes, and all sorts of other effects. All of these projects are being powered by Arduino microcontroller development boards. My first thought was to use a GinSing Shield . I have one of these little beauties and it may well end up being used in one of these projects at some stage, but only for the occasional effect. However, for my projects, in the majority of cases, real-world sounds simply sound superior (try saying that quickly). In some cases, I might decide to record these sounds myself; alternatively, there are a variety of websites from whence one can download free sound snippets, such as FreeSound.org . The next point is how to play these sound snippets. Originally I was planning on using a Wave Shield from Adafruit. On the bright side, this little scamp can play uncompressed 22KHz, 12-bit, mono Wave (.wav) files of any size, and it sounds really good, but... it doesn't really do what I want it to. First of all it uses a lot of the Arduino's pins, which is a pain. Also, it pretty much ties to the Arduino -- you can't do much else while you are playing a sound. My initial plan was to use a dedicated slave Arduino to drive the Wave Shield, and to have a master Arduino to control everything, including telling the slave Arduino what sound file to play. But this still doesn't address all of my requirements, the largest of which is that I might want to play (and mix) multiple sounds simultaneously. In the case of the Vetinari Clock, for example, I might want to set the "tick-tock" sound playing continuously in the background, and then superimpose one or more other sounds on top depending on the current time and on what's happening in the outside world and so forth. What I want for Christmas I was brain-stem-storming this topic with my chum Duane Benson earlier today. Duane also has a number of Arduino-based projects on the go that will eventually require some sound effects capabilities. Following my discussions with Duane, here's what I would like in an ideal world. As a starting point, I want an Arduino Shield with an Arduino Uno form factor. I want this shield to have a lot of memory so as to be able to store a lot of sound effects -- let's say 4GBytes of Flash Memory. In addition to downloading sound snippets to my PC from places like FreeSound.org, I want to be able to create and edit my own sound files on my PC using some program like Audacity . (Note that I don't mind having an 8.3 file naming convention limitation; also, I don't mind being limited to using uncompressed WAV files.) Now, here's an important point -- I want my shield to have a mini-USB port. I want to be able to use a USB cable to connect the shield to my PC, and for the shield to look like a regular USB memory stick. In particular, I want to be able to drag-and-drop sound files from my PC to the shield. The shield should provide any necessary processing capabilities. The communication between the Arduino and the shield should be via I2C (in addition to the shield having a default I2C address, this address should be modifiable via solder links on the shield). The two I2C pins are the only ones the shield should use. All of the Aduino's other pins should be left free for other tasks. A sketch running on the Arduino should be able to issue commands to the shield over the I2C buss. At a minimum, these commands should include something like "Play sound file xxxxxxxx.xxx" (which plays the file once) and "Loop sound file xxxxxxxx.xxx" (which plays the file over and over again). In the case of the Loop command, the default would be to start replaying the file as soon as we reach the end, but it should also be possible to add an optional time parameter like "Every 60 seconds," so a 10-second sound file would play once every 60 seconds, for example. It would also be nice for the sketch running on the Arduino to be able to query the shield with regard to the state of a particular sound file to see if it's still playing and -- if so -- how long it still has to run. It should also be possible for the Arduino to terminate the playing of a particular sound file, where said termination can be qualified by a specified fade time in seconds (a value of 0 would be the same as the default, which is to simply stop playing that file immediately). Perhaps the most important aspect of all this is that the Arduino must be able to request that multiple sound files be played simultaneously -- the shield would be responsible for mixing the various audio streams. I'm not sure what limitations this would place on the system. I presume that there will be some limit to the number of channels that can be streamed depending on the memory access time and other factors that I haven’t wrapped my brain around as yet. For my projects, a mono system would be sufficient. I'm open to suggestions as to whether a stereo capability would be required; if so, when the Arduino requests that a particular sound file be played, it would need to be able to specify to which channel the sound should be directed (the default would be "Both"). Ideally the shield would have its own power supply and will include on-board amplification that can directly drive the speaker(s), but it should also be possible to disable this amplifier and to feed the output to an external amplifier if required. So, are you aware of anything like this that's already available? If not, do you think other people would be interested in having such a capability for their hobby projects? I must admit that Duane and I were wondering if this would make a suitable Kickstarter project. Last but not least, do you have any thoughts as to the way in which all of this could be implemented? Is there a specific processor (or other device) we should use for the shield? What about a multi-stream sound mixing chip? Any suggestions would be gratefully received.