Need Decimal equivalent of bitshift
T Chap
Posts: 4,223
In the code below, the Vincilum responds to a string as shown in VoiceIntro, where an mp3 on a thumbdrive named 1005 plays on demand.
I am setting up a human voice response system, and have a voice that counts 0 - 20, 30, 40, 100, 200....1000 etc, so that any combination of numbers can be spoken by putting together the fragments. For example, "100.mp3" + "20.mp3" + "2.mp3" + "degrees Fahrenheit" can be spoken in that order to say "one hundred twenty two degrees fahrenheit". Other uses where the system needs to respond with numbers are used as well. The possibilities are up to 1000. I am looking at an efficient way to speak the numbers on demand, without having to set up a method foe each number possibility, but it seems a bit challenging.
Since many of the mp3's have the number "0" in it, I substituted -1 as the end indicator, but the loop never finds -1, there is an infinite repeat.
Furthermore, I am not sure if it did find repeat if it would send the correct string, as it appears that it may send a string with 0's after the string, which will likely confuse matters. So this system is somewhat flawed.
Any suggestions to solve this are appreciated.
Using 4port FDS, port 2
Another idea:
Post Edited (Originator) : 11/14/2008 4:39:37 AM GMT
I am setting up a human voice response system, and have a voice that counts 0 - 20, 30, 40, 100, 200....1000 etc, so that any combination of numbers can be spoken by putting together the fragments. For example, "100.mp3" + "20.mp3" + "2.mp3" + "degrees Fahrenheit" can be spoken in that order to say "one hundred twenty two degrees fahrenheit". Other uses where the system needs to respond with numbers are used as well. The possibilities are up to 1000. I am looking at an efficient way to speak the numbers on demand, without having to set up a method foe each number possibility, but it seems a bit challenging.
Since many of the mp3's have the number "0" in it, I substituted -1 as the end indicator, but the loop never finds -1, there is an infinite repeat.
Furthermore, I am not sure if it did find repeat if it would send the correct string, as it appears that it may send a string with 0's after the string, which will likely confuse matters. So this system is somewhat flawed.
Any suggestions to solve this are appreciated.
Using 4port FDS, port 2
VAR byte VoiceData[noparse][[/noparse]15] PUB VoiceIntro 'This works ser.str(2, string("VPF 1005.mp3", CR)) 'command to play file 1005 on drive waitcnt(80_000_000 + cnt) waitcnt(80_000_000 + cnt) PUB SayTemp | indx 'goes into infinite repeat VoiceData := BYTE[noparse][[/noparse]@V70] Indx := 0 repeat VoiceData[noparse][[/noparse]indx++] := BYTE[noparse][[/noparse]@V70][noparse][[/noparse]Indx++] spk.beep(19, 2000, 200) 'test beep: detect if looping while VoiceData[noparse][[/noparse]indx] > -1 'Loop until end found ser.str(2, string(VoiceData, CR)) 'sends string to VMusic2 Vincilum/VLS1033 mp3 player obviously sends one byte not all bytes waitcnt(80_000_000 + cnt) waitcnt(80_000_000 + cnt) DAT V70 byte "VPF 70.mp3", -1
Another idea:
VAR byte VoiceData[noparse][[/noparse]15] PUB VoiceIntro 'This works ser.str(2, string("VPF 1005.mp3", CR)) 'command to play file 1005 on drive waitcnt(80_000_000 + cnt) waitcnt(80_000_000 + cnt) PUB SayTemp | indx 'not working VoiceData := BYTE[noparse][[/noparse]@V70] ser.tx(2, VoiceData) Indx := 0 repeat VoiceData[noparse][[/noparse]indx++] := BYTE[noparse][[/noparse]@V70][noparse][[/noparse]Indx++] ser.tx(2, VoiceData[noparse][[/noparse]indx]) ' tx(port,txbyte) while VoiceData[noparse][[/noparse]indx] > 0 '-1 goes into infinite loop ser.str(2, string(CR)) waitcnt(80_000_000 + cnt) waitcnt(80_000_000 + cnt) DAT V70 byte "VPF 70.mp3", 0 ' -1 goes into infinite loop
Post Edited (Originator) : 11/14/2008 4:39:37 AM GMT
Comments
Probably you should take out the ++ from that first line and add a new line that just increments indx:
Also, you need to sign-extend byte variables if they're signed:
Post Edited (mpark) : 11/14/2008 12:43:32 AM GMT
I need a method to extract each number from a decimal from 0 - 1000, so that I can command individual mp3's to speak each part:
speak the number 925:
900.mp3 then 20.mp3 then 5.mp3
Is there anything similar to bitshift to extract each number?
a := 925
x := (a / 100) * 100 ' This is 900
y := ((a / 10) // 10) * 10 ' This is 20
z := a // 10 ' This is 5