November 15, 2024, 04:34:37 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Dr. Shocker's House of Horror

Started by JonnyMac, October 20, 2007, 09:44:11 PM

Previous topic - Next topic

JonnyMac

October 20, 2007, 09:44:11 PM Last Edit: October 20, 2007, 09:53:24 PM by JonnyMac
My good friend, Daniel Roebuck (yes, he's the host on Chuck's DVD), asked if I could help with his museum: Dr. Shocker's House of Horrors.  He has these life-sized figures at one end of what is his working office:



What Dan asked me to do is come up with a control that would play four, 30-second audio files while controlling lamps that accentuate the individual figures.  Hmmm.... sounds  like a good project for Prop-1 (control), FC-4 (lamps), and uMP3 player (audio).  I had a plastic panel left over from a trade show display that would accept all the parts -- here are my panelized components.



And, finally, here's the code.  I learned two things today:
-- the uMP3 has a small serial input buffer (18 bytes), so you have to be careful with long file names
-- it doesn't like to get a constant stream of bytes; I 'fixed' this by padding queries with a short delay

Here's the code.  Note that my files are called SFX1.MP3, SFX2.MP3, etc., so starting an MP3 is simple (and easy) -- takes less space, too.  Since I know all the audio files are 30 seconds long with a fade-out at the end, I use the status info from the uMP3 to sync the fade-out of the associated lamp.  Note, too, that I use the volume command of the uMP3 to move the stereo image over the associated figure; it's not perfect, but worked well enough to have Dan call me "genius"!

' =========================================================================
'
'   File....... Dans_Gallery.BS1
'   Purpose....
'   Author..... Jon McPhalen
'   E-mail..... jon.mcphalen@gmail.com
'   Started....
'   Updated.... 20 OCT 2007
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  TX              = 5                     ' to UMP3.R; no ULN
SYMBOL  RX              = 4                     ' to UMP3.T; no ULN


' -----[ Constants ]-------------------------------------------------------

SYMBOL  Baud            = OT2400

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  idx             = B2
SYMBOL  char            = B3
SYMBOL  chan            = B4
SYMBOL  pos             = B5
SYMBOL  junk            = B6
SYMBOL  lVol            = B7
SYMBOL  rVol            = B8


' -----[ Initialization ]--------------------------------------------------

Reset:
  GOSUB Stop_uMP3                               ' stop uMP3 on reset
  SEROUT Sio, Baud, ("!!!!!!!FC4", %00, "X")    ' shut down FC-4
  PAUSE 2000                                    ' let uMP3 start

  GOSUB Prod_uMP3                               ' make sure uMP3 is ready


' -----[ Program Code ]----------------------------------------------------

Main:
  FOR idx = 0 TO 3
    LOOKUP idx, (  0, 15, 7, 100), lVol
    LOOKUP idx, (100, 7, 15,   0), rVol
    SEROUT TX, Baud, ("ST V ", #lVol, " ", #rVol, 13)
    GOSUB Prod_uMP3
    LOOKUP idx, (1, 3, 2, 4), chan
    SEROUT TX, Baud, ("PC F /SFX", #chan, ".MP3", 13)

Fade_Up:
    SEROUT Sio, Baud, ("!FC4", %00, "F", chan, 0, 255, 8)
    PAUSE 2100

Check_MP3:
    GOSUB Get_Status
    IF pos > 26 THEN Fade_Down
    IF char = "P" THEN Check_MP3

Fade_Down:
    SEROUT Sio, Baud, ("!FC4", %00, "F", chan, 255, 0, 12)
    PAUSE 4000
    GOSUB Stop_uMP3
  NEXT

  PAUSE 30000
  GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------

Stop_uMP3:
  SEROUT TX, Baud, ("PC S", 13)
  PAUSE 100
  RETURN

' -------------------------------------------------------------------------

Prod_uMP3:
  PAUSE 100
  SEROUT TX, Baud, (13)                         ' send CR
  SERIN  RX, Baud, char                         ' get response
  IF char <> ">" THEN Prod_uMP3                 ' wait for ">"
    RETURN

' -------------------------------------------------------------------------

Get_Status:
  PAUSE 100
  SEROUT TX, Baud, ("PC Z", 13)                 ' request status
  SERIN  RX, Baud, char, #pos, #junk
  RETURN

' -----[ EEPROM Data ]-----------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

clinefx1

I herd Mr Roebuck had an interesting collection.  Cool project to work on.

Chris

JonnyMac

He does, and I believe he'll be opening it to the public soon (he's in Burbank).
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

October 25, 2007, 03:39:24 PM #3 Last Edit: October 25, 2007, 06:14:13 PM by JonnyMac
Okay, so I get a panicky e-mail from Dan this morning -- the show had gone "crazy."  I packed up my computer and went over to find that things were a bit out of whack.  I changed the controller and FC-4; still bad.  The only thing left was the uMP3.  It took a few minutes to figure out, but what happened is the uMP3 had been set to infinite repeat mode, and my software was not equipped to deal with that.  I believe this may have happened when power was cut in the middle of another message, but there's no way to be sure.

I re-crafted the program so that:
-- the uMP3 gets the loops count reset to 1 any time I stop the uMP3 player
-- I use a simple delay to start the FC-4 fade-out sequence; no longer using status from uMP3
-- I make sure that there are delays in between commands to the uMP3 so it doesn't get overrun (it has a pretty small buffer, just 18 bytes)

In the end, I actually had better control over when the fade-out starts because it simply comes after a PAUSE and that was easy to tune.  Granted, it took an hour of watching to get it just right, but now it is and it's spectacular.  Dan is smiling once again.  The show was running non-stop for more than an hour before I headed back to the bat cave -- I'm sure it's going to be fine for the grand opening on Saturday night.

At any rate, heres the final code -- it may be useful for those of you with the uMP3 player.


' =========================================================================
'
'   File....... Dans_Gallery.BS1
'   Purpose....
'   Author..... Jon McPhalen
'   E-mail..... jon.mcphalen@gmail.com
'   Started....
'   Updated.... 25 OCT 2007
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Light/Audio controller for Dan's Dr. Shocker museum
'
' Audio files:
' * SFX1.MP3 - Bride of Frankenstein
' * SFX2.MP3 - Creature from the Black Lagoon
' * SFX3.MP3 - Dracula
' * SFX4.MP3 - Phantom of the Opera


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  TX              = 5                     ' to UMP3.R; no ULN
SYMBOL  RX              = 4                     ' to UMP3.T; no ULN


' -----[ Constants ]-------------------------------------------------------

SYMBOL  Baud            = OT2400

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  char            = B0                    ' char to/from uMP3
SYMBOL  idx             = B1                    ' loop control
SYMBOL  chan            = B2                    ' mp3 / lighting channel
SYMBOL  junk            = B3                    ' filter for uMP3 data
SYMBOL  fade            = B4                    ' face cyle time (ms)

SYMBOL  volume          = W4                    ' uMP3 volume
SYMBOL   rVol           =  B8
SYMBOL   lVol           =  B9

SYMBOL  delay           = W5


' -----[ Initialization ]--------------------------------------------------

Power_On:
  PAUSE 100                                     ' let everything power up

Reset:
  GOSUB Stop_uMP3                               ' stop uMP3 on reset
  SEROUT Sio, Baud, ("!FC4", %00, "X")          ' shut down FC-4
  PAUSE 2000                                    ' let uMP3 start
  GOSUB Prod_uMP3                               ' make sure uMP3 is ready


' -----[ Program Code ]----------------------------------------------------

Main:
  FOR idx = 0 TO 3
    LOOKUP idx, (1, 4, 2, 3), chan              ' re-order figures

Pan_Audio:
    LOOKUP chan, (0, 254, 15,  6,   0), lVol
    LOOKUP chan, (0,   0,  7, 19, 254), rVol
    SEROUT TX, Baud, ("ST V ", #lVol, " ", #rVol, 13)

Start_Audio:
    GOSUB Prod_uMP3
    SEROUT TX, Baud, ("PC F /SFX", #chan, ".MP3", 13)

Fade_Up:
    LOOKUP chan, (0, 1, 6, 16, 3), fade
    SEROUT Sio, Baud, ("!FC4", %00, "F", chan, 0, 255, fade)

Hold_For_Audio:
    LOOKUP chan, (0, 24000, 21500, 26000, 22000), delay
    PAUSE delay

Fade_Down:
    LOOKUP chan, (0, 8, 16, 12, 8), fade
    SEROUT Sio, Baud, ("!FC4", %00, "F", chan, 255, 0, fade)

Post_Fade_Delay:
    ' fade time plus 3 seconds
    LOOKUP chan, (0, 5000, 7000, 6000, 5000), delay
    PAUSE delay
    GOSUB Stop_uMP3
  NEXT

Inter_Show_Delay:
  FOR idx = 1 TO 120                            ' two minutes
    PAUSE 1000
  NEXT

  GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------

Stop_uMP3:
  PAUSE 25
  SEROUT TX, Baud, ("PC S", 13)                 ' stop playing
  PAUSE 25
  SEROUT TX, Baud, ("ST O 1", 13)               ' set loops to 1

  ' drop through to Prop_uMP3

' -------------------------------------------------------------------------

Prod_uMP3:
  PAUSE 25
  SEROUT TX, Baud, (13)                         ' send CR
  SERIN  RX, Baud, char                         ' get response
  IF char <> ">" THEN Prod_uMP3                 ' wait for ">"
    RETURN

' -------------------------------------------------------------------------

Get_Status:
  PAUSE 25
  SEROUT TX, Baud, ("PC Z", 13)                 ' request status
  SERIN  RX, Baud, char, #junk, #junk
  RETURN


' -----[ EEPROM Data ]-----------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office