Shop OBEX P1 Docs P2 Docs Learn Events
Sound Module AppMod Rev B — Parallax Forums

Sound Module AppMod Rev B

merlinmerlin Posts: 40
edited 2005-08-15 02:26 in Robotics
Dear friends:
Few weeks ago I have posted some basic question about addressing messages in Sound Module AppMod Rev B, not only for listening but also for recording purposes.
The two responses I received this time was not very helpful, so instead fo asking, I decided to work it by myself...After two weeks· spending some hours with the module, I'd like to share my conclusions with you, in order to contribute with the forum for anyone who is interested in this particular Module.
Bottom line, the Module is a very good module poorly documented as far I as see. In fact, you can record up to 60 secs of sound (music, noise or voice) via included microphone or line input, jumper selection. I have decided to use the Line Input solution, because it permits more control on recording process.
In my case, I· decided to use the module with my Robot, to provide it with some kind of interaction·with the enviroment in order to give·me some feedback, so I have·selected some general phrases· as "Ok", "Roger",·"Forward", "Going Back", "Battery Low" and so on.
I·recorded the voices on my PC, applied to the voice some FX to "convert" the voice to nice robotic appealing and then save the result in a .wav file.

After this, I connected the line input to the line out of my PC and connected the Sound Module to BS2 using only One I/O (a big advantage) for Serial control.

The module uses two variables to record a message:

1.- The position of the pointer in the whole space available. You can use any position from 0 to 149, wich represents the 60 seconds total. Each number stands for 0,4 secs, so a typical 2 secs message will use 5 memory slots and the pointer has to be moved according to this scheme. You set the pointer position via Serial Command
2.- After you give the Module the record command also via Serial Command, you have to provide it the necessary Pause Command time to execute the given instruction. So, if you expect to record a 2 secs message, you have to include a Pause 2000 line after to complete the recording process.

Finally, you have to setup a EOF signal (End Of File) to instruct the Sound Module to close the recording process just there.
The only thing you have to care is the position of the pointer, wich is the same of address of each message, regarding each separate message, building a list like this:

OK= Pointer Position 0
Roger= Pointer Position 5
Forward= Pointer Position 10
Going Back= Pointer Position 15
Battery Low= Pointer Position 15

After the recording porcess has been done, you can play any message, in any order, only addressing the pointer to proper position, previously listed above.
I have used this routine to record seven separated messages of the the wav file into Sound module:

' {$STAMP BS2}
' {$PBASIC 2.0}

port CON 1
cicle VAR Byte
Pointer_Position VAR Nib
PAUSE 500
Pointer_Position=5·········

SEROUT puerto,84+$8000,[noparse][[/noparse]"!SM0N"]·· ' Enable·for recording ; Be aware, the SM0N include a CERO, not an O
PAUSE 500

· FOR cicle=0 TO 6
····· SEROUT puerto,84+$8000,[noparse][[/noparse]"!SM0R",(cicle*Pointer_Position)]
····· PAUSE·2000································ '·time to record message
····· SEROUT puerto,84+$8000,[noparse][[/noparse]"!SM0E"]·········· ' setting end of file
····· PAUSE 1000·········································· ' time to wait
····· SEROUT puerto,84+$8000,[noparse][[/noparse]"!SM0P",(cicle*Pointer_Position)] '·Play the message recorded
····· PAUSE 1600
····· DEBUG DEC (cicle*Pointer_Position),CR··· ' This line gives you·on screen the·address of each message
· NEXT

· END

I have used the Windows Player to play each message, pausing the play during the reproduction of messages and press the play button to resume the playing, getting a very decent record timming after 2 or 3 tries.
For playing the messages, you have to keep close the list you built, using the correct address to locate and play each message with the follow Serial command:

SEROUT puerto,84+$8000,[noparse][[/noparse]"!SM0P",Pointer_Position]

Of course, you can play all the messages in a For Next command using the Step option to jump from one address to another.
I hope all this explanation will be helpful to people in using the Sound Module, as I said, a very good module with a very poor documentation.
regards

merlin

english is NOT my natural lenguage
·
Sign In or Register to comment.