show the unmodified and modified cables.
Once we’ve got things connected, the rest comes
pretty easy, though I did find a couple traps along the
way. Let’s start with simple playback.
SUB VM_PLAY
tmpW2
= __WPARAM12
TX_STR “VPF “
TX_STR tmpW2
TX_STR “.MP3”
TX_BYTE CR
isPaused = No
ENDSUB
code, we’re sending numeric values to the player in indicated
hex ($) mode; this is done using the TX_HEX2 subroutine.
What happens if we want to move the sound from
one side to the other? There is no easy command in the
VMUSIC2 command set to do this, but there is an
advanced command that lets us write to registers inside
the MP3 decoder. We must be very careful when doing
this — my VMUSIC2 made some really interesting and
really awful noises when I started experimenting with
direct register control.
SUB VM_PAN
tmpB3 = __PARAM1
tmpB4 = __PARAM2
With VM_PLAY, we send an inline file name (without
the .mp3 extension) or a label that has a z-string with the
file name. TX_STR and TX_BYTE take care of sending the
name, extension, and a carriage return to the player.
I’ve included a flag in the program that keeps track of the
paused state of the device, so this gets cleared on a new
play command. Keep in mind that if you send one play
command while another file is playing, the original file
will be stopped and the new one will play.
And speaking of stopping ... the VMUSIC2 player has
just one processor that handles serial I/O with its host (the
SX, in our case) and pulling data from the USB memory stick
to send to the MP3 decoder. So, if you send any command
when a file is playing this can interrupt the audio output. I
bring this up because there are commands that we may want
to send while a file is playing, specifically volume control.
tmpB3 = tmpB3 MAX $FE
tmpB4 = tmpB4 MAX $FE
TX_STR “VWR $0B”
TX_HEX2 tmpB4
TX_HEX2 tmpB3
TX_BYTE CR
ENDSUB
SUB VM_VOLUME
tmpB3 = __PARAM1
tmpB3 = tmpB3 MAX $FE
TX_STR “VSV $”
TX_HEX2 tmpB3
TX_BYTE CR
ENDSUB
The VM_VOLUME subroutine takes care of setting the
output volume of the VMUSIC2 player. It seems a little odd
at first that we use zero for the loudest volume; what we’re
actually setting inside the player is the attenuation from
maximum loudness. Note, too, that the player sets the left and
right channels to the same level. In order to simplify the SX
■ FIGURE 2. VMUSIC2 cable.
I’ve created a subroutine called VM_PAN that expects
levels for the left and right channels to be passed to it,
then writes those levels directly to the MP3 decoder chip.
It does this with the VWR (write to register) command;
the target is register $0B which is a 16-bit value holding
the channel levels. The tricky bit with the VM_PAN routine
is that its settings get wiped out by a play command —
this is something that the VMUSIC2 firmware does.
So, if we want to play a file from only one side, for
example, what we actually have to do is start the file and
then immediately call the VM_PAN subroutine to move
the audio as required. Unfortunately, if we do call
VM_PAN in the middle of audio, there may be a little
“click” in the audio output; this will depend on what’s in
the MP3 decoder buffer — and this is where one could
make an argument for a higher baud rate to minimize the
communications time to the VMUSIC2.
Vinculum supplies a program called VncFwMod.exe
that can be used to update the firmware file which is
where we change the baud rate. This program is available
on the Downloads page of the Vinculum site and is listed
as Vinculum Firmware Customizer. I actually keep a copy
of this on my memory stick so that I can plug the stick
into my computer at any time and
update the firmware file. It’s a good
idea to use a different revision code
when you change the firmware, and
do remember that you need to cycle
power to the VMUSIC2 for updated
firmware to be loaded.
EXPERIMENTING ON
MYSELF
■ FIGURE 3.
VMUSIC2 cable
— modified.
Let’s wrap up the Sleepnotizer
as this puts the VMUSIC2 code to use.
62
September 2008