GPSSoundFiles ?

wm.chatman

Well-Known Member
Licensed User
Longtime User
Hi Basic4 PPC Forum

I have been using the GPSDriver and testing this and that. I have been playing with this:

With the GPSDriver I use this code in Sub Globels.
Sub Globals
Dim Sounds As directions(0) 'Adds all the Directions using Sound Files
Dim sound
Dim soundDirection
...add the Sound Files 0-16
Dim directions(0)
Dim soundDirection '''Adds all the Directions in Sounds'''
sounds() = Array("sfNorth","sfNorth sfNortheast","sfNortheast","sfEast Northeast", _
"sfEast", "East Southeast", "sfSoutheast", "sfSouth Southeast", "sfSouth", "sfSouth Southwest", _
"sfSouthwest", "sfWest Southwest", "sfWest", "sfWest Northwest", "sfNorthwest", "sfNorth Northwest")

This runs.

Now, I would like to add 0-16 sound files to Play every 5-15 min Interval using a Timer Control. Option to set time (5-15 min), and sound off/on.

What would be the right code for this? Just don't know how to code it and put the time on it the correct way.

Thanks!!! for all kind help on this.

William
 
Last edited:

derez

Expert
Licensed User
Longtime User
Sound files cannot be stored in an array like images, so you have to call the actual files. name the wav files like the names in the array, or any other names as long as you know which is what, and put them in one directory so they will not mess with the program files.
create a timer and let it tick every 5 minutes (or 15 - you can change the interval from within the program).You can also turn the timer off and on again using the enabled method.
You need to select the direction by your other subs.

B4X:
Sub Globals
Dim sounds(0)
selected_direction = 1
End Sub

Sub App_Start
Form1.Show
sounds() = Array("N.wav","NNE.wav","NE.wav","ENE.wav", _ 
"E.wav", "ESE.wav", "SE.wav", "SSE.wav", "S.wav", "SSW.wav", _ 
"SE.wav", "WSW.wav", "W.wav", "WNW.wav", "NW.wav", "NNW.wav")

timer1.Interval = 300000   ' 1000 ms in second * 60 sec in min  * 5 min
timer1.Enabled = True
End Sub

Sub Timer1_Tick
' get the velue of selected_direction 
Sound(AppPath & "\sounds\" & sounds(selected_direction))
End Sub
 
Last edited:

wm.chatman

Well-Known Member
Licensed User
Longtime User
Sound files cannot be stored in an array like images, so you have to call the actual files. name the wav files like the names in the array, or any other names as long as you know which is what, and put them in one directory so they will not mess with the program files.
create a timer and let it tick every 5 minutes (or 15 - you can change the interval from within the program).You can also turn the timer off and on again using the enabled method.
You need to select the direction by your other subs.

B4X:
Sub Globals
Dim sounds(0)
selected_direction = 1
End Sub

Sub App_Start
Form1.Show
sounds() = Array("N.wav","NNE.wav","NE.wav","ENE.wav", _ 
"E.wav", "ESE.wav", "SE.wav", "SSE.wav", "S.wav", "SSW.wav", _ 
"SE.wav", "WSW.wav", "W.wav", "WNW.wav", "NW.wav", "NNW.wav")

timer1.Interval = 300000   ' 1000 ms in second * 60 sec in min  * 5 min
timer1.Enabled = True
End Sub

Sub Timer1_Tick
' get the velue of selected_direction 
Sound(AppPath & "\sounds\" & sounds(selected_direction))
End Sub
derez. "\sounds\" why must I code like this ?
 

derez

Expert
Licensed User
Longtime User
You don't have to, I just recomend to put the wav files in a separate directory, underneath the application. It can be in any other place, as long as you write the path correctly.
 

wm.chatman

Well-Known Member
Licensed User
Longtime User
And why do I need this special "" carector/korrector ? If that what its called .I forgot, I did search for the correct name of "". Please advice. I seen this on a PDF Format That I had downd to HD. But cant find and have forgotten since.
 
Last edited:

wm.chatman

Well-Known Member
Licensed User
Longtime User
derez.

thank you Sir,for your support!

I will report outcome, of post #3. asap.
 

wm.chatman

Well-Known Member
Licensed User
Longtime User
derez.

thank you Sir,for your support!

" <Quoted string. thats the name. Why is the QS needed?

edit:
If all sound files in Folder, just add sound files path right.
Sub Timer1_Tick
' get the velue of selected_direction
Sound(AppPath & " \DirectWav\sounds\" & sounds(selected_direction))
End Sub


I will report outcome, of post #3. asap.

hi klaus
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Your sound filenames are stored in the Sounds() variable in.
B4X:
Sounds() = Array("N.wav","NNE.wav","NE.wav","ENE.wav", _ 
"E.wav", "ESE.wav", "SE.wav", "SSE.wav", "S.wav", "SSW.wav", _ 
"SE.wav", "WSW.wav", "W.wav", "WNW.wav", "NW.wav", "NNW.wav")/
Sounds(0) = "N.wav"
Sounds(1) = "NNE.wav"
Sounds(2) = "NE.wav"
etc.

selected_direction is the variable containing the index of the selected sound file.

if selected_direction = 0 then N.wav is played
if selected_direction = 1 then NNW.wav is played
if selected_direction = 2 then NE.wav is played etc.

When you want to play the NE.wav file, just set
selected_direction = 2
that's it.

Best regards.
 

wm.chatman

Well-Known Member
Licensed User
Longtime User
Hi klaus, derez

I added the code just gave the timer a diff name.
Some code I had, a line or the other I did not have yet.

Sub Globals
Dim sounds(0)
selected_direction = 0
selected_direction = 1
selected_direction = 2
selected_direction = 3
selected_direction = 4
selected_direction = 5
selected_direction = 6
selected_direction = 7
selected_direction = 8
selected_direction = 9
selected_direction = 10
selected_direction = 11
selected_direction = 12
selected_direction = 13
selected_direction = 14
selected_direction = 15
'selected_direction = 16
End Sub

Sub App_Start
Form1.Show
sounds() = Array("N.wav","NNE.wav","NE.wav","ENE.wav", _
"E.wav", "ESE.wav", "SE.wav", "SSE.wav", "S.wav", "SSW.wav", _
"SE.wav", "WSW.wav", "W.wav", "WNW.wav", "NW.wav", "NNW.wav")

Sounds(0) = "N.wav"
Sounds(1) = "NNE.wav"
Sounds(2) = "NE.wav"
Sounds(3) = "ENE.wav"
Sounds(4) = "E.wav"
Sounds(5) = "ESE.wav"
Sounds(6) = "SE.wav"
Sounds(7) = "SSE.wav"
Sounds(8) = "S.wav"
Sounds(9) = "SSW.wav"
Sounds(10) = "SE.wav"
Sounds(11) = "WSW.wav"
Sounds(12) = "W.wav"
Sounds(13) = "WNW.wav"
Sounds(14) = "NW.wav"
Sounds(15) = "NNW.wav"

tmrWavFiles.Interval = 300000 ' 1000 ms in second * 60 sec in min * 5 min
tmrWavFiles.Enabled = True
End Sub

Sub tmrWavFiles_Tick
' get the velue of selected_direction
Sound(AppPath & "\sounds\" & sounds(selected_direction))
End Sub

Added File: sounds within all wav files for the App
I know this could be pretty simple, still am without a sound ? I can"t figure yet. Any Input for me? Is the selected_direction = 0 to 15 needed in SubGlobals?

Unable to upload sound files for tests, due to 1.6 MB.

Thank you.

William
 
Last edited:

mjcoon

Well-Known Member
Licensed User
Sub Globals
Dim sounds(0)
selected_direction = 0
selected_direction = 1
selected_direction = 2
selected_direction = 3
selected_direction = 4
selected_direction = 5
selected_direction = 6
selected_direction = 7
selected_direction = 8
selected_direction = 9
selected_direction = 10
selected_direction = 11
selected_direction = 12
selected_direction = 13
selected_direction = 14
selected_direction = 15
'selected_direction = 16
End Sub

I suppose the compiler does not complain about that because it ignores multiple declarations of the same variable. But it does not achieve anything, nevertheless. One variable "selected_direction" can only have one value at a time, so it just ends up with the value "15" (since the "=16" line is a comment) and the previous values are discarded and just waste resource.

Shome mishtake, shurely?

Mike.
 

wm.chatman

Well-Known Member
Licensed User
Longtime User
Hi mjcoon.

Sub Globals
Dim sounds(0)
selected_direction = 0

would this be better? Still no sounds.

Edit: been thinking I had it working, we had a sound. But then, one sound only and never again.
So, I guess this was negative input, can't catch my simple mistake...

Thanks for helping.
 
Last edited:

wm.chatman

Well-Known Member
Licensed User
Longtime User
Ok, seems something works now.

selected_direction = 1

but the only Song to hear from is the NNE sound (continues play). So how do we get the diff wav files playing to different Headings ?

what am I doing wrong please and why all sounds do not play, for each direction ? Please help.
 
Last edited:

derez

Expert
Licensed User
Longtime User
B4X:
Sub Globals
Dim sounds(0)
selected_direction = 0 
[COLOR="Red"]selected_direction = 1 
selected_direction = 2 
selected_direction = 3
selected_direction = 4 
selected_direction = 5 
selected_direction = 6 
selected_direction = 7 
selected_direction = 8
selected_direction = 9
selected_direction = 10 
selected_direction = 11
selected_direction = 12 
selected_direction = 13
selected_direction = 14 
selected_direction = 15 
'selected_direction = 16 [/COLOR]End Sub

Sub App_Start
Form1.Show
sounds() = Array("N.wav","NNE.wav","NE.wav","ENE.wav", _ 
"E.wav", "ESE.wav", "SE.wav", "SSE.wav", "S.wav", "SSW.wav", _ 
"SE.wav", "WSW.wav", "W.wav", "WNW.wav", "NW.wav", "NNW.wav")

[COLOR="red"]Sounds(0) = "N.wav"
Sounds(1) = "NNE.wav"
Sounds(2) = "NE.wav"
Sounds(3) = "ENE.wav"
Sounds(4) = "E.wav"
Sounds(5) = "ESE.wav"
Sounds(6) = "SE.wav"
Sounds(7) = "SSE.wav"
Sounds(8) = "S.wav"
Sounds(9) = "SSW.wav"
Sounds(10) = "SE.wav"
Sounds(11) = "WSW.wav"
Sounds(12) = "W.wav"
Sounds(13) = "WNW.wav"
Sounds(14) = "NW.wav"
Sounds(15) = "NNW.wav"[/COLOR]
tmrWavFiles.Interval = 300000 ' 1000 ms in second * 60 sec in min * 5 min
tmrWavFiles.Enabled = True
End Sub

Sub tmrWavFiles_Tick
[COLOR="Blue"]' get the velue of selected_direction [/COLOR]
Sound(AppPath & "\sounds\" & sounds(selected_direction))
End Sub

William
All the red part are redundant and should be deleted.
The blue line means that you have to give a number (0-15) to the variable selected_direction. You can add a textbox and read its content:
add a textbox named tb :
put this line instead of the blue line
selected_direction = tb.text

Then whenever you input a number 0-15 to the textbox the timer tick will sound the selected sound file.
I recommend for testing to decrease the time interval, otherwise you'll have to wait 5 minutes for each sound...
Then after this works you should replace this line with something that is defined by your GPS - the real direction, converted to numbers 0-15.
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Hi William,

I suppose that you get the direction from the Heading parameter of the GPS.

So the selected_direction variable will be
B4X:
[FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]selected_direction=[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2](((GPS1.Header+[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]371.75[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]) [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Mod [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]360[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])/[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]22.5[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[/SIZE][/FONT]

Otherwise, why don't you post your whole code, it is always easier for us to give a concrete answer or advise with the whole code rather than with code snippets?

Best regards.
 

mjcoon

Well-Known Member
Licensed User
I do a bit of yachting and also volunteer for the UK's institute for blind people. So I know that partially-sighted people go boating and use a "speaking compass" to help them steer.

I had wondered if a PDA+GPS could be programmed to be such a speaking compass, with the added benefit that it could use off-track error or even just the difference in heading wrt bearing to waypoint. Unfortunately most devices are very much not waterproof!

And I would expect that numbers rather than compass points would be what a user would want to hear. So I meant (but have not yet) to test of the text-to-speech library can cope with number well.

Mike.
 

klaus

Expert
Licensed User
Longtime User
Last edited:

wm.chatman

Well-Known Member
Licensed User
Longtime User
:) Hi all

I have been working on adding a few refinements like GPSSerial.dll and Sound Files, to the GPSLog App.

What we have done so far, with the App.

1. Added all the Sound Files needed.
2. Added option to set Sound Time Interval (need to be 5, 10, 15 minutes), on a panel. Also has option to set Off/On Function , for the Sounds.
3. Replaced the GPSDriver.dll with GPSSerial.dll.

Problems:
1. Getting GPSSerial working (pretty darn hard), for me.
2. Sound Files still need to be incorporated.

The GPSDriver.dll is still present I have not deleted yet.
It sure would make me very happy, if a wizard would take a look and maybe help on this project. All Sound Files needed are attached.

Thank you in advance for your help.

Best regards.
William
 

mjcoon

Well-Known Member
Licensed User
3. Replaced the GPSDriver.dll with GPSSerial.dll.

Problems:
1. Getting GPSSerial working (pretty darn hard), for me.

I recently discussed these two DLLs in a thread about GPSSerial (I am heavily "into" GPS4PPC ATM.)

I pointed out that it is possible to have a very short "Main" module which necessarily has all the component DLLs specified (because this is the way Basic4PPC works). It can also have just the two objects from whichever of those two DLLs mentioned above are being used, and also a Public Sub with the Gpsdriver.Open call with no parameters (if GPSDriver.dll in use) or the port and speed parameters (if GPSSerial.dll in use). This call is put in a Public Sub so it can be called from the other modules.

All the other modules can be common to multiple versions of the program. Each version has its own Main module. The GPS device is accessed from those other modules using Main.Gpsdriver and Main.GPSConverter which work with either of the two DLLs.

In that thread I posted a zipped version of GPS4PPC using the above scheme, to illustrate the technique.

I myself am using three versions, which allows me to have desktop and device versions, plus using GPSSerial.dll on the device. (This enables me to use an external serial GPS which allows me to do things I cannot with the built-in GPS, like "sailing" at 200 knots!)

HTH, Mike.
 

wm.chatman

Well-Known Member
Licensed User
Longtime User
:) Hello Mike

Thank you Sir for some very good info. I had seen and downd your version of Basic4ppc.

But, I really would like to get GPSLog to work, with the GPSSerial.dll if at all possible, with the Wav Sound Files.
It would be real cool, if you could check this out for me. And maybe get it to work. This would make me VERY HAPPY !!!

Best regards.
William
 
Last edited:

mjcoon

Well-Known Member
Licensed User
I really would like to get GPSLog to work, with the GPSSerial.dll if at all possible

That part is easy, just following AGraham's rules about using GPSSerial.dll, that is do not have GPSDriver.dll as a component at the same time (they are mutually incompatible). And have the parameters on gps.open(<port name>, <baud rate>).

What is the line:
B4X:
   If gps.SeaLevelAltitude <> gps.InvalidData Then AltDatLbl.Text = Round(gps.SeaLevelAltitude * ConvertAlt(CnvIndex)) & ConvertAltTxt(CnvIndex)
intended to do? This gave a crash (converting "*1" to numeric, 2nd time "*.32") when I tried to run the code and open a serial GPS. Inspecting the code I cannot see why this would happen. But I do not understand why the conversion array is needed (rather than simple variables).

I have not tried the sound files; they are rather large!

Mike.
 
Top