Jon,
After much (for the love of a jumper) frustration I got the vMusic2 player working tonight with my Prop2. The issue is, without pausing the code for the duration of playback it just stops playing the track. This of course renders it fairly useless, as you can't do anything while the track is playing.
Is there anything I can do to work around this?
I haven't used that device with a Prop-2 yet. Why don't you post your code and let me have a look.
It's basically just a couple lines of code:
SEROUT 0, 84, ["VSV 0", CR] 'starts volume at full
SEROUT 0, 84, ["VPF test.mp3", CR] 'play mp3
Pause 5000 'play for 5 seconds
Without that pause, it just stops playing. I can't have the Prop2 doing anything while the track is in progress. I'm hoping there is an obvious way to make this behave differently (like the AP8, wherein you tell it to play and it does its thing on it own as the Prop controller goes about the rest of it's business).
I've not had that problem, nor -- I believe -- has Scary Terry. ST has used that player with both the Prop-1 and Prop-2; I've only used it with a Prop-SX. Still, it shouldn't matter.
I need to find my player (still packed from HC) and connect it to a Prop-2; I may not be able to get the demo done before next week as I'm heading out to San Francisco (for Maker Faire) shortly.
ST hasn't had that issue (I assume) because his code has the pauses in there. It only plays for as many seconds as the pause command so far as I can tell from testing it for a while last night. Set the pause at 10000 and you get 10 seconds of MP3, 5000 you get 5 seconds, take it out and you'll see the vMusic poll the USB drive for a second, but thats it. I'm hoping someone can prove me wrong, because if so this is a great product.
The problem with "quickie" programs is they tend to quickly lead to problems. Here's the story: When the Prop-2 program is ending the TX line -- which is normally left high when idle -- drops; this creates a false input to the player which stops.
The solution is to use pins on the Prop-2 that have SETUP jumpers and move them to the UP position. Then use Open-True baud mode for transmitting. Problem solved; your program can end and the VMusic player will keep chugging right along. Yes, I tested this -- everything is on my bench and running this program (Note: You'll have to fix the DATA table names for your files):
' =========================================================================
'
' File...... VMusic.BS2
' Purpose...
' Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
' E-mail.... jwilliams@efx-tek.com
' Copyright (c) 2008 EFX-TEK
' Some Rights Reserved
' see: http://creativecommons.org/licenses/by/3.0/us/
' Started...
' Updated... 01 MAY 2008
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
' -----[ Revision History ]------------------------------------------------
' -----[ I/O Definitions ]-------------------------------------------------
Sio PIN 15 ' no ULN / no SETUP
Trigger PIN 14 ' no ULN / SETUP = DN
TX PIN 13 ' no ULN / SETUP = UP
RX PIN 12 ' no ULN / SETUP = UP
' -----[ Constants ]-------------------------------------------------------
IsOn CON 1 ' for active-high in/out
IsOff CON 0
Yes CON 1
No CON 0
VolMax CON $00
VolMin CON $FE
T2400 CON 396
T9600 CON 84
T19K2 CON 32
T38K4 CON 6
SevenBit CON $2000
Inverted CON $4000
Open CON $8000
Baud CON Open + T9600
' -----[ Variables ]-------------------------------------------------------
flags VAR Byte
rptMode VAR flags.BIT0
isPaused VAR flags.BIT1
theMP3 VAR Byte ' MP3 file pointer
char VAR Byte ' character value
eePntr VAR Word ' EEPROM memory pointer
volume VAR Byte
panCtrl VAR Word
lvlLeft VAR panCtrl.BYTE0
lvlRight VAR panCtrl.BYTE1
' -----[ Initialization ]--------------------------------------------------
Reset:
PAUSE 2250 ' let VMUSIC power up
SEROUT TX, Baud, [CR] ' ping (if no power-up)
GOSUB VM_Wait_Prompt
GOSUB VM_Stop ' stop if playing
GOSUB VM_Wait_Prompt
volume = VolMax ' reset volume level
GOSUB VM_Volume
flags = %00000000 ' clear flags
' -----[ Program Code ]----------------------------------------------------
Main:
DEBUG CLS, "Playing: Firefly theme.", CR
theMP3 = 0
GOSUB VM_Play
GOSUB VM_Wait_Start
DEBUG "-- file started", CR
PAUSE 5000
volume = 40
GOSUB VM_Volume
GOSUB VM_Wait_Prompt
DEBUG "-- volume reduced", CR
GOSUB VM_Wait_Prompt
DEBUG "-- ready for new command", CR, CR
Pan_Test:
DEBUG "Playing: Spalding.", CR
theMP3 = 4
GOSUB VM_Play
GOSUB VM_Wait_Start
lvlLeft = VolMax ' pan to left
lvlRight = VolMin
GOSUB VM_Pan
DEBUG "-- pan left", CR
PAUSE 3500 ' wait for dead spot
lvlLeft = VolMin ' pan to right
lvlRight = VolMax
GOSUB VM_Pan
DEBUG "-- pan right", CR
DEBUG "Good-bye"
END
' -----[ Subroutines ]-----------------------------------------------------
' Pass file # (index in DATA table) to play in "theMP3"
VM_Play:
rptMode = No
GOTO Play_MP3
' -------------------------------------------------------------------------
' Pass file # (index in DATA table) to play in "theMP3"
VM_Repeat:
rptMode = Yes
GOTO Play_MP3
' -------------------------------------------------------------------------
' Pass file # (index in DATA table) to play in "theMP3"
' -- add DATA label entries to LOOKUP as required
Play_MP3:
LOOKUP theMP3, [SFX0, SFX1, SFX2,
SFX3, SFX4, SFX5], eePntr ' get base address
Send_Play_Cmd:
IF (rptMode = No) THEN
SEROUT TX, Baud, ["VPF "] ' start play command
ELSE
SEROUT TX, Baud, ["VRF "] ' start repeat command
ENDIF
Send_Name: ' send file title
DO
READ eePntr, char
eePntr = eePntr + 1
IF (char = 0) THEN EXIT
SEROUT TX, Baud, [char]
LOOP
Finish_Cmd:
SEROUT TX, Baud, [".MP3", CR] ' send extention + CR
RETURN
' -------------------------------------------------------------------------
VM_Stop:
SEROUT TX, Baud, ["VST", CR]
RETURN
' -------------------------------------------------------------------------
VM_Pause:
IF (isPaused = No) THEN
SEROUT TX, Baud, ["VP", CR]
isPaused = Yes
ENDIF
RETURN
' -------------------------------------------------------------------------
VM_Resume:
IF (isPaused = Yes) THEN
SEROUT TX, Baud, ["VP", CR]
isPaused = No
ENDIF
RETURN
' -------------------------------------------------------------------------
' Pass volume (0 = loudest, 254 = muted) in "volume"
' -- credit to "Scary" Terry Simmons for discoving that the volume must
' be passed as text.
VM_Volume:
volume = volume MAX $FE ' limit per spec
SEROUT TX, Baud, ["VSV ", IHEX2 volume, CR]
RETURN
' -------------------------------------------------------------------------
' Pass levels (0 = loudest, 254 = muted) in "lvlLeft" and "lvlRight"
'
' NOTE: The VPF command seems to reset volume levels so you must use a
' pan command while the file is playing for it to work.
VM_Pan:
lvlLeft = lvlLeft MAX $FE ' limit per spec
lvlRight = lvlRight MAX $FE
SEROUT TX, Baud, ["VWR $0B", HEX4 panCtrl, CR]
RETURN
' -------------------------------------------------------------------------
VM_Wait_Prompt:
SERIN RX, Baud, [WAIT(">")]
RETURN
' -------------------------------------------------------------------------
VM_Wait_Start:
SERIN RX, Baud, [WAIT("T $00")]
RETURN
' -----[ User Data ]-------------------------------------------------------
' MP3 files are stored in root of USB memory stick
' Table below needs only name, followed by a zero
' Keep names short to conserve EE space
SFX0 DATA "Firefly", 0
SFX1 DATA "Serenity", 0
SFX2 DATA "Fruity", 0
SFX3 DATA "Angel", 0
SFX4 DATA "Spalding", 0
SFX5 DATA "Thunder", 0
Dear lord Jon! Could you make an example of playing a file any more complicated? :)
Thank god I've been at this a while and actually (shocking even myself) understood that code. Pity the poor soul just starting out that reads that.
I should be using P15 anyway, as I have a ULN2003 in that bank. So use P15 and set it to "up" and I should be all set with the simple example I supplied (with no pause needed)?
You can either do it right or you can have problems. I choose to do it right. ;D And... what's so hard about copying-and-pasting a program I took the time to write for you?... ;)
Follow the program above with the pin you want to use and it should work just fine. It's always a good idea to understand a device before using it. The VMUSIC player is a demo module for engineers, it's not really intended for casual users who want instantaneous plug-and-play.
BTW, I've found that the volume commands do not work as advertised (in the spec sheet). I've been in contact with FTDI engineers and they're looking into it.
I found that -- as in Scary Terry's demo (that I hadn't looked at) -- you have to send the volume numbers as text. I've updated the above listing to add volume and pan control. Note that you must send the pan control commands *after* the file is started as the VPF command seems to balance the volume levels. I used a terminal to talk to the VMUSIC player directly and read the volumes prior and after the VPF command. When you issue a VPF command it seems to read the volume registers (left and right) and then sets them both to the lowest level.
For this particular application I already have the prop2 using a ping to conditionally send the code to one of two different eprom tables with data for blending 4 servos (and 2 additional table values to vary repeats and servo speed), so the last thing I need is more complication :)
Basically I'm going to wait for a distance from the Ping, then send it to play an MP3, then send it on it's way to the applicable data table for the servo movements. It's all working quite nice so far except for the vMusic2 issues. I have to admit tweaking the servo movements for smooth animations has been challenging, and due to this my skull tends to move like a meth user, but I'm determined to do this with a Prop2 rather than VSA (just to say I did).
Have a look at the updated program (above). It works quite nicely as long as you follow the rules for dealing with the VMUSIC module.
wouldn't full low be $FF?
Nope. According the spec (hint, hint) that value "will activate analog powerdown mode" in the VS1003 (MP3 decoder).
In my experiments to discover the correct syntax for the pan control (writing to the VCI_VOL registers) I made all sorts of wierd noises come out of my MP3 player.