May 01, 2024, 06:27:05 PM

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.


VMUSIC Programming help..

Started by Dark Shadows, August 22, 2010, 01:32:43 PM

Previous topic - Next topic

Dark Shadows

I have a basic program written up for a prop I'm making, but I want to activate the VMUSIC once the monster jumps out.. I have the track on the flash drive titled "a.mp3". Its a scream that only lasts 3 seconds and I want it to activate twice while the prop is jumping out... Heres the code I have now, can someone show me where to insert the VMUSIC Code into my program? I have the Vmusic wired up Pin 5/6.. Thanks Let me know if Im missing anything..

' =========================================================================
'
'   File...... table.BS1
'   Purpose...
'   Author.... Mike Yazumbek
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  doors    = 0        ' pin 0
SYMBOL  monster  = 1        ' pin 1
SYMBOL  Trigger  = PIN7     ' trigger input


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

SYMBOL  IsOn   = 1
SYMBOL  IsOff  = 0

SYMBOL  RecLen = 3      ' record length
SYMBOL  EOS    = 255    ' end of show marker
SYMBOL  SNOOZE = 100    ' Wait 1/10th of a second
'SYMBOL  SNOOZE = 1000   ' Wait 1 second


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

SYMBOL  record = B0    ' movement record
SYMBOL  pntr   = B1    ' table byte pointer
SYMBOL  pin    = B2    ' Pin to change
SYMBOL  state  = B3    ' On or off
SYMBOL  delay  = B4    ' amount of time to sleep before next command
SYMBOL  wait   = W5    ' calculated amount of time to sleep before next command

  PAUSE 20000     ' If you want a delay before program resets, remove the quote at start of line (delay is set for 2 second)

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

Reset:
  DIRS = %01111111   ' make all pins output but 7
  PINS = %00000000

  record = 0      ' Start at the beginning of the table

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

Main:
  IF Trigger = IsOff THEN Main  ' wait for trigger

Move_Engine:
  GOSUB GetNextCommand          ' get the next command to execute
  IF pin = EOS THEN Reset       ' abort if at end
  wait = delay * SNOOZE         ' calcute pause time
  IF state = IsOn THEN SetHigh  ' if the state says turn it on
                                ' otherwise turn it off
  LOW pin                       ' Turn the pin OFF

BumpRecord:
  PAUSE wait                    ' wait a while before executing the next command
  record = record + 1           ' point to the next record
  GOTO Move_Engine

SetHigh:
  HIGH pin                      ' Turn the pin ON
  GOTO BumpRecord               ' OK, what do I do next?

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

' Call with "record" set to table line to read

GetNextCommand:
  pntr = record * RecLen ' point into table
  READ pntr, pin         ' read pin number
  pntr = pntr + 1        ' point to state
  READ pntr, state       ' read state
  pntr = pntr + 1        ' point to delay (in 100s of a second)
  READ pntr, delay       ' read delay
  RETURN


' -----[ EEPROM Data ]-----------------------------------------------------

' There are 3 parameters to this table.
' 1 is the pin number to change
' 2 is the state (IsOn or IsOff)
' 3 is the amount of time (in 100ths of a second) to wait before executing the next command (cant be greater than 65)
'
' Don't forget to have an EOS at the end of the table!
'         pin, state, delay
'The delay is set to 100ms,
'         so 1 = 1/10 of a second
'         and 10 = 1 second

Move_Table:
  EEPROM (doors,   IsOn,  20) ' Open the doors and wait 2 seconds before the monster jumps
  EEPROM (monster, IsOn,  10) ' Push the monster out
  EEPROM (monster, IsOff, 5) ' Pull the monster back
  EEPROM (monster, IsOn,  10) ' Push the monster out
  EEPROM (monster, IsOff, 5) ' Pull the monster back
  EEPROM (monster, IsOn,  10) ' Push the monster out
  EEPROM (monster, IsOff, 20) ' Pull the monster back
  EEPROM (doors,   IsOff, 65) ' Close the doors and wait 6.5 seconds
  EEPROM (EOS, EOS, EOS)      ' last available EE space

bsnut

I would suggest that you look under the audio section of this site(Audio+VMusic). Start with this is topic "VMusic Demo Program for Prop1" first. It shows you the basic program for the prop1 and of course Jon wrote it. He also started the "VMusic connection" topic and it goes over the connections that you will need to do.

I will be happy to show you where you need to insert it in your program or write one for you, but I am posting this on my phone.
William Stefan
The Basic Stamp Nut

Dark Shadows

Ah thanks! I didnt even know there was a Vmusic section... Thanks for the help I'll check out those posts and mess around with it!