November 26, 2024, 09:36:23 AM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Ambient Looping

Started by ScaryTinker, October 17, 2007, 06:47:56 AM

Previous topic - Next topic

ScaryTinker

I'd like to use two AP-8's controlled by a Prop-2.  One AP-8 will be used to loop a 60 sec ambient track and the other AP-8 will store several sound effects.
Do you think the following would be a good approach?

Set the ambient AP-8 to loop mode using the DIP switch, so it would come on and play the ambient track at power up.  The program has the standard 'watch the PIR, go to main until triggered routine'.  When triggered the first command in the Main: portion of the program would be to send the X command to the ambient AP-8.  The program would then execute using the second AP-8 for various sfx.  At the bottom of the main program just before it loops back to the top of Main I'll insert a P command and wait for the next victim.

JonnyMac

October 17, 2007, 08:29:28 AM #1 Last Edit: October 17, 2007, 08:31:25 AM by JonnyMac
Yep, that will work.  Just make sure that you record you "ambient" track to slot 0, keep it under 60 secs (do not record past the end of the AP-8 memory), and close all DIP switches (L-2-1-0) on this AP-8.  The other AP-8, after recording your sounds, should have all DIP switches open and the A0 jumper inserted.

' =========================================================================
'
'   File......
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2007 EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  Baud            = OT2400


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

SYMBOL  sfx             = B2                    ' sound to play
SYMBOL  last            = B3                    ' last played
SYMBOL  timer           = W4                    ' debounce/event timer
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00000000                              ' configure output pins

  SEROUT Sio, Baud, ("!!!!!!!AP8", 255, "X")    ' stop all AP-8s
  PAUSE 30                                      ' reset delay
  SEROUT Sio, Baud, ("!AP8", %00, "P", 0)       ' start ambient

  PAUSE 20000                                   ' PIR warm-up delay
  timer = 0                                     ' clear debounce timer


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

Main:
  RANDOM lottery                                ' stir random value
  PAUSE 10
  timer = timer + 10 * Trigger
  IF timer < 250 THEN Main                      ' wait for valid trigger

  SEROUT Sio, Baud, ("!AP8", %00, "X")          ' stop ambient AP-8

Select_SFX:
  RANDOM lottery
  sfx = lottery // 8
  IF sfx = last THEN Select_SFX
    last = sfx                                  ' save for next cycle

  SEROUT Sio, Baud, ("!AP8", %01, "P", sfx)     ' play sound effect


  ' other code here (allow AP-8.%01 to finish)


  GOTO Reset


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


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


' -----[ User Data ]-------------------------------------------------------


Jon McPhalen
EFX-TEK Hollywood Office