Shop OBEX P1 Docs P2 Docs Learn Events
Making music — Parallax Forums

Making music

TnadzTnadz Posts: 14
edited 2007-02-08 18:04 in BASIC Stamp
Hello all. I'm making a robot for my art class that will sit on the floor or some raised structure and monitor its surrounding to see if anyone is standing nearby (using Ultrasonic sensors). If no one is within a certain distance, let's say 5ft, it will play music, dance, and do a little light show using LEDs. The dancing will probably just be a sequence of spinning and a few forward and backwards commands. At certain intervals the bot will stop briefly and check to make sure no one is nearby with the music and light show still going. If someone is there it will stop cold until they leave, possibly while making some sort of small frightened animal noises.

To get a visual, I'm going to use a piece of plywood for the base with a large colander on top which will have LEDS, the Ultrasonic sensors and a hairy lattice on top. Basically a 1ft diameter hairy hemisphere.

Now, my main question is, how can I get it to play sound (ie possible code or pseudo code as well as the physical process)? I know that's a big question but here's what I got. My instructor suggested using a Radio Shack mini solid state sound memory good for 20secs of sound. I want to record an mp3 onto the relay to be activated by the stamp. Then the relay could send the signal to an amped speaker (like a computer desktop speaker). In case I can't get a hold of one of these relays, does anyone have any suggestions for making this process better? easier? cheaper even?

Aside from that I think I've got most of the work figured out but if anyone could offer other suggestions or ideas for me I will gladly take them.

Some other things that might be useful. I'm going to use a 12V 7HA SLA battery with two of these wheels http://www.solutions-cubed.com/solutions cubed/EZR2003.htm driven by two 35RPM motors (controlled by a motor controller) and casters to provide skid steering.

I only have about 4 weeks to see this project realized so I need to get work done as quick as possible. I thank you all for any and all help. PS - I'm a bit of a noob but I can pick up on things pretty fast.

EDIT: The DC motors come with the wheels which are 200RPM 12V motors that run on relatively low amps.

Post Edited (Tnadz) : 2/5/2007 11:22:34 PM GMT

Comments

  • ZootZoot Posts: 2,227
    edited 2007-02-05 22:23
    There a lots of ways of getting audio out of your Stamp. The issues you have to decide (and balance in terms of desire/budget) are:

    - do you want to mathematially generate music from scores (and sound effects?) -- a la ringtone and cheap video games.
    pros: cheeeeeeeap, clean, easy to integrate other programming (like LEDs) into each note as it is played
    cons: tedious scoring and coding process, sounds like ringtones, mono

    - do you want prerecorded mp3s or wav files?
    pros: sounds nice, stereo
    cons: much trickier to program and/or adds hardware costs (there are micro controlled mp3 players out there as well as cards that let you pre-record files for micro controlled playback -- also having a host PC program use it's own player/soundcard in response to serial commands from the Stamp could be an option)

    - midi?
    pros: sounds nice, stereo, cheap
    cons: tricky programming

    There is a circuit in the Stamp Manual under FREQOUT for hooking up a 40ohm speaker with just a few capacitors. This probably won't cover the volume needs for your exhibit, but it's a quick and cheap way to get some audio out and see how it sounds before worrying about amplification per se.

    Then checkout "What's a Microcontroller" from Parallax which has a great discussion of generating musical scores and ringtones from a Stamp:
    www.parallax.com/dl/docs/books/edu/Wamv2_2.pdf

    Also this thread has a revision of the above music score engine that is a bit easier on the variable requirements:
    http://forums.parallax.com/showthread.php?p=619826

    This thread has two postings of Stamp code with pretty interesting "R2D2" type sound effects that are nice way to get started in perhaps constructing your own mathematical sound effects:
    http://forums.parallax.com/showthread.php?p=582602

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • ZootZoot Posts: 2,227
    edited 2007-02-05 22:26
    P.S. -- once you have some kind of audio, then amplifying it is not so tricky. You can either filter the audio out for intput into a regular stereo or boombox, or you can build 1W-4W amplifier out of a few dollars in parts and an op-amp IC. But first decide on what your audio source will be so you know what it is that will need (or not need) amplifying to begin with. I will say that a $1.50 op-amp chip and an 8-ohm speaker can make a Stamp FREQOUT pretty loud if the speaker is enclosed properly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • TnadzTnadz Posts: 14
    edited 2007-02-05 23:20
    Wow thanks for the quick feedback Zoot. Actually I was hoping to use an Mp3 as I have a complex audio studio and given the time restraints I think it would be easier for me if I could make the mp3 (or wav doesn't really matter unless memory is an issue) and then from my computer, record/transfer that file onto a separate module/relay/memory that can send a signal (analog) to a speaker which will probably just be chopped out of a cheap computer speaker.

    Synching the lights with the sound won't be an issue right now because I just want them both to work, first separately, and then if I have time at the end, I can easily whip up code to make it look like the lights are going in time with the music. I know this is inefficent but I don't know if I can afford the time to mess around otherwise. Unless, of course, I find something real simple and affordable that will work.

    I ideally would like to have the "player" separate from my computer, similar to the way you can download BSP files straight from the computer via USB or Serial to the stamp, and then have the stamp process the code separate from the computer. I don't know exactly how I'll do this because I don't really know what's out there and it's very difficult to get an idea of the range of options I have while just searching through various sites. Hopefully that helps
  • ZootZoot Posts: 2,227
    edited 2007-02-06 00:10
    www.roguerobotics.com/products/electronics/ump3

    Above is a micro controlled mp3 player. You load mp3 files onto an SD data card, then put the card into the device. A Stamp can playback files when you want, control volume, etc.

    Also, some former Parallax employees offer an audio module that plays back 8 pre-recorded sounds under micro control: www.efx-tek.com/topics/ap-8.html

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • TnadzTnadz Posts: 14
    edited 2007-02-06 01:34
    NICE! Well done Zoot. You are quite the life saver. I was hoping something a little more inexpensive, but I know I ask the improbable. I at least have SOMETHING! Again thank you very much.
  • ZootZoot Posts: 2,227
    edited 2007-02-06 01:46
    Don't thank me -- thank the folks who come up with this cool stuff smile.gif Mike Green made one comment in another post about this mp3 player drifting over several days and requiring an occasional reset to keep it sync...here's the post: http://forums.parallax.com/showthread.php?p=625515

    $99 is a bit much but having a card reader alone on your Stamp is pretty cool. The cheapest route, btw, would be to write an applet for a host PC (laptop?) and have the Stamp send commands to the applet via SEROUT and the RS-232 port, but that requires a knowledge of PC programming and techniques.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • TnadzTnadz Posts: 14
    edited 2007-02-06 18:09
    For anyone else checking this out, I did find a cheaper solution. It's a lovely integrated chip from winbond. http://www.winbond-usa.com/mambo/content/view/36/140/

    Certainly not as impressive as the playback module but it gets the job done in a much more affordable fashion. smilewinkgrin.gif
    However, I'm probably going to go with the module instead. Seeya $100. cry.gif

    Post Edited (Tnadz) : 2/6/2007 7:08:32 PM GMT
  • AImanAIman Posts: 531
    edited 2007-02-07 14:46
    IF you are still looking the WAM book does go into programing notes. You can use several piezio's (sp?) and run notes at the same time, VERY cheap and easy to do. I got bored one day and programmed mine to do a song from Sound of Music. For my next music project there will be 6 piezio's to simulate normal paino playing for doing to the Entertainer.

    Sounds like a computer sound though.
  • TnadzTnadz Posts: 14
    edited 2007-02-07 23:16
    yes they are most cheap, but they aren't quite as good as sound files are at making funky bass and drum sounds. burger.gif
  • Vern GranerVern Graner Posts: 337
    edited 2007-02-08 17:32
    Tnadz said...
    yes they are most cheap, but they aren't quite as good as sound files are at making funky bass and drum sounds.
    New item for making funky sounds:

    http://www.soundgin.com

    I ordered one of these after reading the review in servo magazine. Its pretty sweet. Check out the sounds it can make here.

    Harkens back to the 80's and the sid player songs that were making the rounds on BBS systems.. smile.gif hmm maybe showing my age a bit here.. tongue.gif

    Vern

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
    Senior Systems Engineer    | obviously incompetent so why are we
    Texas Information Services | paying you? Of course,if the network
    http://www.txis.com        | is up, then we obviously don't need
    Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG
    
    
  • TnadzTnadz Posts: 14
    edited 2007-02-08 18:04
    Genius!
Sign In or Register to comment.