November 23, 2024, 06:53:17 AM

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.


Simple AP-16+ Demo for Prop-1

Started by JonnyMac, May 04, 2010, 01:27:10 PM

Previous topic - Next topic

JonnyMac

May 04, 2010, 01:27:10 PM Last Edit: June 22, 2010, 11:17:26 AM by JonnyMac
Since we're very close to shipping the AP-16+ I thought I'd post a simple Prop-1 demo for it; the demo file includes all the syntax rules for the AP-16+.  So... if you have been using the AP-8 you will have to make some modifications, but we think you'll fine they're worth it.  

For example... if your prop plays a random file the AP-16+ can handle the random logic for you (see the "P?" command).

Obviously, this is just a start and we will have lots of demos and examples coming.

[Updated] : added syntax note regarding "S" (playback speed) command.


' =========================================================================
'
'   File....... AP-16_Test.BS1
'   Purpose.... AP-16+ Features Test
'   Author..... EFX-TEK
'   E-mail..... teamefx@efx-tek.com
'   Started....
'   Updated.... 01 JUN 2010
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Demonstration program for the AP-16+ Audio Player Board.  All commands are
' send to the AP-16 through a serial link at 2400 baud (OT2400 baudmode).
'
' Command syntax: "!AP16", address, cmd {, sub-cmd} {, data}
' -- where 'address' is %00 to %11
' -- 'cmd' and 'sub-cmd' is a single character
' -- optional 'data' is one or or bytes
'
' Valid commands:
'
'   "!AP16", address, "V"
'     -- requests version string from AP-16+
'     -- should be followed by SERIN to receive three-byte string
'
'   "!AP16", address, "G"
'     -- retrieves current AP-16+ status
'     -- should be followed by SERIN to receive one-byte status
'     -- status byte is bit-mapped:
'        * BIT7 : 0 = idle, 1 = playing
'        * BIT6 : 0 = single play, 1 = looping
'        * BIT5 : 0 = SFX or AUX, 1 = named WAV (PW command)
'        * BIT4 : 0 = SFX file, 1 = AUX file
'        * BIT3 : file #, bit3
'        * BIT2 : file #, bit2
'        * BIT1 : file #, bit1
'        * BIT0 : file #, bit0
'
' * "!AP16", address, "PS", file#, loops
'     -- plays selected sfx (0 - 15) file
'     -- loops is number of times to play (0 = loop forever)
'
' * "!AP16", address, "P?", file#, loops
'     -- plays random sfx (0 - file#) file
'     -- loops is number of times to play (0 = loop forever)
'
' * "!AP16", address, "PA", file#, loops
'     -- plays selected aux (1 - 8) file
'     -- loops is number of times to play (0 = loop forever)
'
' * "!AP16", address, "PW", "filename", 13, loops
'     -- plays named WAV file
'        > name must be 8 or fewer chracters
'        > ".wav" extension is optional (added by player if not present)
'        > file name must be terminated with CR (13)
'     -- loops is number of times to play (0 = loop forever)
'
' * "!AP16", address, "L", left, right
'     -- sets channel volume levels (0 to 100)
'
' * "!AP16", address, "S", speed
'     -- sets playback speed (50 to 200)
'     -- 44.1kHz files will not play faster than 100%
''
' * "!AP16", address, "X"
'     -- stops AP-16+ (if playing)
'
' Note: Commands marked with * will respond to global address (255)
'
' Note: ULN2803 interferes with serial transmission to AP-16+; remove and
'       replace with ULN2003 (7 channels), leaving P7 contacts open.


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


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

SYMBOL  Sio             = 7


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

SYMBOL  Baud            = OT2400                ' baud jumper out
SYMBOL  Addr            = %00                   ' both address jumpers out

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  status          = B0                    ' status (B0 for bit access)
SYMBOL   Playing        = BIT7                  ' 0 = idle, 1 = playing

SYMBOL  id0             = B2
SYMBOL  id1             = B3
SYMBOL  id2             = B4


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

Reset:
  SEROUT Sio, Baud, ("!AP16", Addr, "X")        ' stop if playing now
  DEBUG CLS


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

Main:
  SEROUT Sio, Baud, ("!AP16", Addr, "V")        ' get version
  SERIN  Sio, Baud, id0, id1, id2               ' receive ID string
  DEBUG "AP-16+ Version: ", #@id0, #@id1, #@id2 ' display it
  DEBUG CR
  PAUSE 1500

Test1:
  DEBUG CR, "Play SFX01.WAV", CR
  SEROUT Sio, Baud, ("!AP16", Addr, "PS", 1, 1) ' loop one time
  GOSUB Verify_Play
  PAUSE 1500

Test2:
  DEBUG CR, "Reduce volume", CR
  SEROUT Sio, Baud, ("!AP16", Addr, "L", 20, 20) ' set to 20%

Test3:
  DEBUG CR, "Play SFX01.WAV - low volume", CR
  SEROUT Sio, Baud, ("!AP16", Addr, "PS", 1, 1)  ' loop one time
  GOSUB Verify_Play
  PAUSE 1500

  SEROUT Sio, Baud, ("!AP16", Addr, "X")         ' reset volume

Test4:
  DEBUG CR, "Play random SFXnn.WAV", CR
  SEROUT Sio, Baud, ("!AP16", Addr, "P?", 15, 1)
  GOSUB Verify_Play
  PAUSE 1500

Test5:
  DEBUG CR, "Play WOLF.WAV", CR
  SEROUT Sio, Baud, ("!AP16", Addr, "PW", "wolf", 13, 1)
  GOSUB Verify_Play
  PAUSE 1500

Tests_Done:
  DEBUG CR, "Testing done."
  END


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

Get_Status:
  PAUSE 50
  SEROUT Sio, Baud, ("!AP16", Addr, "G")        ' get status
  SERIN  Sio, Baud, status
  RETURN

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

Verify_Play:
  GOSUB Get_Status
  IF Playing = NO THEN Play_No
    DEBUG "-- playing!", CR

Play_Wait:
  GOSUB Get_Status
  IF Playing = YES THEN Play_Wait
    GOTO VP_Exit

Play_No:
  DEBUG "-- whoops, no file!", CR

VP_Exit:
  RETURN


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

JackMan

Hey Jon,
    What's the latest on the AP-16?

JonnyMac

As of yesterday back orders are in transit and we're accepting and filling regular orders.
Jon McPhalen
EFX-TEK Hollywood Office