May 02, 2024, 03:33:30 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.


AP-16+ - Number of Files & Playback Length

Started by Traveler, July 17, 2015, 11:27:32 AM

Previous topic - Next topic

Traveler

Am I reading the AP-16+ documentation correctly? If I plan to use a PIR sensor to activate the unit when it's set to random file playback is the number of files that can utilized 16?

My second question is, is there a time limit on the length for each file? Of course there has to be some kind of limit just because the memory card can only hold so much data but barring that can each file play for as long or short as I want.

Kim

JonnyMac

In stand-alone mode the maximum number of files is 16 (SFX00.WAV through SFX15.WAV); you would set the SELECT switch to F (hex for 15) in this case.

There is a 2G file size limit; the amount of audio depends on the number of channels (stereo files require twice as much space as mono files) and the sample rate (a 44.1kHz file needs twice as much space as a 22.05kHz file).

I frequently recommend 32kHz mono files to customers that don't require stereo. Humans cannot distiguish between 32kHz sample rate and 44.1kHz sample rate. The lower rate and single channel make the resulting files smaller. We use Audacity to edit files. Remember that files must be canonical WAV file as well -- no meta data allowed.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

BTW... if you want to randomize more than 16 files, you can do that by inserting a Prop-1 controller between your PIR and the AP-16+. The Prop-1 would handle the randomizing logic and send play commands with named files so that you could have SFX16...SFX99 -- though these files won't work in stand-alone mode.
Jon McPhalen
EFX-TEK Hollywood Office

Traveler

Thank You JonnyMac! That is exactly the information I needed. I thought it was 16 but wasn't certain. That definitely help in the planning stages. And that is interesting about adding in a Prop-1.

JonnyMac

We have a customer in NorCal that wanted to randomize 300 files -- we did that using the Prop-1. Here's the code for that project.

' =========================================================================
'
'   File...... AP16_Jukebox300.BS1
'   Purpose... Randomizes up to 300 files
'   Author.... Jon Williams & John Barrowman EFX-TEK
'   E-mail....
'   Started...
'   Updated... 31 MAR 2012 - JW
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN; connect switch
                                                ' wires to P6.R and P6.W

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

SYMBOL  Baud            = OT2400                ' baud jumper out

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Pushed          = 1
SYMBOL  NotPushed       = 0

SYMBOL  FILES           = 300                   ' T000.WAV - T299.WAV


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

SYMBOL  id0             = B0                    ' version string
SYMBOL  id1             = B1
SYMBOL  id2             = B2


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

SYMBOL  timer           = B1                    ' button debounce timer

SYMBOL  fn100           = B2                    ' file number 100s
SYMBOL  fn010           = B3                    ' file number 10s
SYMBOL  fn001           = B4                    ' file number 1s

SYMBOL  lastFile        = W3                    ' last file played
SYMBOL   lfLow          =  B6
SYMBOL   lfHi           =  B7

SYMBOL  fileNum         = W4                    ' current file #
SYMBOL  lottery         = W5                    ' pseudo-random #


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

Power_Up:
  PAUSE 2500                                    ' let AP-16+ power up

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00000000

  READ 0, lfLow                                 ' read last file from EE
  READ 1, lfHi

  lottery = 1224                                ' seed random #

  SEROUT Sio, OT2400, ("!AP16", %00, "V")       ' get firmware version
  SERIN  Sio, OT2400, id0, id1, id2

  DEBUG CLS, "AP-16 Juke Box 300", CR
  DEBUG "-- Firmware: ", #@id0, #@id1, #@id2, CR, CR
  PAUSE 500


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

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  RANDOM lottery                                ' big stir
  RANDOM lottery
  RANDOM lottery
  PAUSE 5                                       ' scan delay
  IF Trigger = NotPushed THEN Main              ' check trigger input
    timer = timer + 5                           ' update timer
  IF timer < 250 THEN Check_Trigger             ' check timer


Set_Question:
  RANDOM lottery                                ' re-stir
  fileNum = lottery // FILES                    ' select file, 0..299
  IF fileNum = lastFile THEN Set_Question       ' do not replay last
    lastFile = fileNum                          ' save for next cycle
    WRITE 0, lfLow                              ' save last file
    WRITE 1, lfHi

  fn100 = fileNum  / 100      + "0"             ' convert # to characters
  fn010 = fileNum // 100 / 10 + "0"
  fn001 = fileNum //  10      + "0"


Ask_Question:
  SEROUT Sio, Baud, ("!AP16", %00, "PW", "T", fn100, fn010, fn001, 13, 1)

  DEBUG "Playing File: T", #@fn100, #@fn010, #@fn001, ".WAV", CR


Check_Status:
  PAUSE 100                                     ' don't crowd buffer
  SEROUT Sio, Baud, ("!AP16", %00, "G")         ' get status
  SERIN  Sio, Baud, status
  IF Playing = Yes THEN Check_Status            ' let song finish


Off_Delay:
  PAUSE 1000                                    ' 1s minimum between files
  GOTO Main


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


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

Data_Save:
  EEPROM ($FF, $FF)                             ' last file played
Jon McPhalen
EFX-TEK Hollywood Office