November 25, 2024, 02:19:22 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Cycling through sounds on a AP8

Started by livinlowe, October 12, 2007, 06:09:13 PM

Previous topic - Next topic

livinlowe

Jon-
I am trying to just cycle through some sounds I have recorded onto my AP8. They play fine (well some are cutoff, but I am not worried I think I just released the record button early) when on manual loop (all switches closed, loop closed). I wrote the following program:


' =========================================================================
'
'   File......Test_sounds1.bs1
'   Purpose...To cycle through sounds recorded on my AP-8
'   Author....Shawn Lowe (with help from EFX-TEK!)
'   E-mail....
'   Started...12 OCT 07
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'This is just a demo to show for co-workers on AP-8 capabilities

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


' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL  Sio     =         PIN7

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


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

SYMBOL   tix       =         W4   ' 1/10 second timer
SYMBOL   file      =         B2   ' File index


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

Reset:
DIRS     =         %10000000      ' Set Pin 7 as output

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

Main:
   SEROUT Sio,OT2400,("!!!!AP8",%00,"x")
   tix    =         20             ' Wait 2 seconds
   GOSUB Run_Timer

Play_files:
   FOR file=0 TO 5
        SEROUT Sio, OT2400, ("!AP8", %00, "P", file)
        tix       =         150    'Wait 15 seconds
        GOSUB     Run_Timer
   NEXT
GOTO main


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

Run_Timer:
 IF tix = 0 THEN Timer_Done
   PAUSE 100
   tix = tix - 1
   GOTO Run_Timer

Timer_Done:
 RETURN





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


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


I have the jumper on the prop-1 set on the dn jumpers, I am sure I have the AP8 set to %00 (both jumpers off), and sw0-2 are open, as well as L (loop).

Any ideas? (He asks,knowing he's asking the god of programming)

Shawn
Shawn
Scaring someone with a prop you built -- priceless!

JonnyMac

God? Cool cherub, maybe!  ;D

Here's a little program that will cycle through the sounds in an AP-8 -- make sure you follow the setup notes in the file regarding jumpers, etc.

' =========================================================================
'
'   File...... AP-8_Cycler.BS1
'   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 ]---------------------------------------------

' Configuration
'
' -- remove SETUP jumper from P7
' -- replace ULN2803 with ULN2003 (or clip pin 1 on ULN2803)
' -- remove B/R, A1, and A0 jumpers from AP-8
' -- move L, 2, 1, 0 switches on AP-8 to "off" or "open" position


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN


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

SYMBOL  Baud            = OT2400

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  status          = B0
SYMBOL   playing        =  BIT7

SYMBOL  sfx             = B2


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

Reset:
  PAUSE 250                                     ' let AP-8 power-up
  SEROUT Sio, Baud, ("!!!!!!!AP8", %00, "X")    ' stop on reset

  DEBUG CLS


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

Main:
  FOR sfx = 0 TO 7
    PAUSE 100                                   ' gap between sounds
    DEBUG "Playing #", #sfx, CR
    GOSUB Start_AP8
    GOSUB Let_AP8_Finish
  NEXT

The_End:
  GOTO The_End


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

' Put segment number (0 to 7) into 'sfx' before calling

Start_AP8:
  SEROUT Sio, Baud, ("!AP8", %00, "P", sfx)     ' play segment
  RETURN

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

' Holds program until AP-8 is finished playing current segment

Let_AP8_Finish:
  SEROUT Sio, Baud, ("!AP8", %00, "G")          ' get status
  SERIN  Sio, Baud, status
  IF playing = Yes THEN Let_AP8_Finish
  RETURN

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


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


The reason your program doesn't run is that you used "PIN7" instead of "7" in the SYMBOL definition of Sio -- this is a subtle error, and takes some time to explain, so I'm covering it in detail in the Prop-1 programming book.  Just know that SERIN and SEROUT (and many other commands) need the pin number, not the pin I/O bit register.
Jon McPhalen
EFX-TEK Hollywood Office

Creepy Carla

I realize this was posted back when I was a baby, but I'm having problems following the final code.  The variable "playing" never gets set to anything.  Unless I'm missing something.  And when I display the variable "status" (via DEBUG) then it gives me a value of "135."  Is that decimal or string?  I'm confused.

By the way I searched for an updated version of this code and couldn't find anything entitled "Cycling through sounds..."

Thanks, CC.

JonnyMac

QuoteUnless I'm missing something.

Playing is one of the bits in status -- it gets updated when we get the status byte back from the AP-8.

Since Playing is BIT7 it will have a value of 128 when displayed as decimal.   Put %status in your DEBUG statement to show the bits as 1s and 0s.
Jon McPhalen
EFX-TEK Hollywood Office