PDA

View Full Version : Sioc trim sound problem



themax222
05-02-2010, 03:40 AM
Hello,

I'm a beginner in sioc and I'm trying to play a sound when moving the trim. This is what I tried :


Var 0091
{
V0091 = V0092
}

Var 0092, Link FSUIPC_IN, Offset $0BC2, Length 2 // pitch trim indicator
{
IF V0092 <> V0091
{
V0093 = 1
V0091 = V0092
}
ELSE
{
V0093 = 0
}
}

Var 0093
{
IF v0093 = 1
{
&PLAY_SOUND = 2
&PLAY_SOUND = 0
}
ELSE
{
&STOP_SOUND = 2
&STOP_SOUND = 0
}
}

When sioc starts, the sound is playing, that's not good :roll: What am I doing wrong ? Does someone have a better code ?

Thanks,

Maxime.

kiek
05-02-2010, 04:37 AM
Hallo Maxime,

There are two problems with your code.

1st: Initialisation, when SIOC starts your script, the body of Var 0091 will not execute (because you do not assign a value to Var 0091)

2nd: When the code of Var 0092 is executed the value of Var 0092 is always not equal to Var 0091 (otherwise the code in the body of Var 0092 was not executed at all ...). This is a design principle of the SIOC language, the statements in the body attached to a variable are only executed if the variable changes value.

Observation: Note that the pitch trim value is not stable, it will always fluctuate a little, so it is not a good trigger for a sound signal (unless you smooth the values and start a sound only when big delta's are detected. Difficult, imho. You bettter look for another trigger, a change in the rotary or potmeter controlling your pitch would be better.

regards,
Nico

fordgt40
05-02-2010, 04:41 AM
Maxime

The following link explains how to code SIOC for using the SOUND function, the last post is the best example.

http://www.opencockpits.com/modules.php?op=modload&name=Forums&file=viewtopic&topic=1825&forum=13

Are you using the correct FSUIPC offset? suggest you try this one:-

Offset 3370
4 Four single byte PFC driver ―alive‖ counters:

3370 = COM port read thread alive and running
3371 = Elevator trim motor action (0=off, 1=up, 2=dn)
3372 = COM port write thread alive
3373 = Main FS chain alive
N.B. without the main FS chain running the other three aren‘t maintained in any case, so mean nothing

David

themax222
05-03-2010, 11:42 AM
Hello,

thanks for help but as I'm a newbie in sioc programming I don't know what to do with these offset(s). These are Project magenta offsets, isn't it a problem if I don't use it ? Do I have to use the 4 variables (3370,3371,...) ?

Can somebody help and make a little code ?

Thanks a lot,

Maxime.

fordgt40
05-03-2010, 12:06 PM
Maxime

These are not Project Magenta offsets but native FSUIPC ones. I only suggested trying the one in red as this offset appears to signal when the trim motor is moving! If you incorporate the suggestions made by Nico and change the offset reference then give it a try. Also bear in mind the advice and example given in the thread pointer to the OC site as you will need to amend your sioc.ini file

The best way to learn is to try it yourself

David

themax222
05-03-2010, 12:24 PM
Hello,

I already use sioc sounds so I know how to use them but I can't find to make a code working for trim. When I use this offset 3371, what is the length ? :roll:


Var 0906, Link FSUIPC_IN, Offset $3371, Length ??
{
IF V0906 = 0
{
&STOP_SOUND = 2
&STOP_SOUND = 0
}
ELSE
{
&PLAY_SOUND = 2
&PLAY_SOUND = 0
}
}

Is this correct to get the value if the trim is up or down ?

Thanks,

Maxime.

kiek
05-03-2010, 12:30 PM
You can find the definitions of all FSUIPC offsets in the FSUIPC for Programmers.pdf, available in the FSUIPC SDK (downloadable at Pete Dowson's page (http://www.schiratti.com/dowson.html))

fordgt40
05-03-2010, 12:37 PM
Maxime

I gave you the length earlier!
Offset 3370
4 Four single byte PFC driver ―alive‖ counters:

3370 = COM port read thread alive and running
3371 = Elevator trim motor action (0=off, 1=up, 2=dn)
3372 = COM port write thread alive
3373 = Main FS chain alive

Single byte at offset 3371 !!!

David

themax222
05-03-2010, 12:47 PM
Ok Thanks but it is more easy with just a simple offset 0 or 1. What do I need to use ? Length 4 ? length 1 ? offset 3370 ? offset 3371 ?

Don't find manuals or tutorials wich explains how to use such offsets. I tested the above code with length 1 but it doesn't work.

Thanks,

Maxime.

kiek
05-03-2010, 12:50 PM
Don't find manuals or tutorials wich explains how to use such offsets. I tested the above code with length 1 but it doesn't work.

It bit of googling and you would have found how to read from FSUIPC offset (http://www.lekseecon.nl/howto.html#readFSUIPC)

fordgt40
05-03-2010, 12:54 PM
Maxime

Again, Offset 3371 length 1, which according to Pete Dowson returns a trim motor value of (0=off, 1=up, 2=dn)
Have you used IOCPconsole to check the variables state and also the log function so that you can trace what your code is doing and indeed whether the offset is returning the correct value. The link provided by Nico directs you to the documentation you seek

David

themax222
05-03-2010, 01:13 PM
Hello,

I already found this but all these examples or with 1 offset that takes value 0 or 1. What I don't understand here is that the offset 3370 is divided into 3370,3371,3372,3373. What do I have to use in my code ? the 3370 length 4 or one the the others with length 1 ?

I'm wasting my time here in searching a solution for a small simple code that mayby you already have the solution. I will never use sioc because I don't need it exept now for a small trim code. You can understand that I don't want to read 5 manuals just for a small code...

Thanks,

Maxime.

EDIT : Didn't see your last post David, will check this ;-) Thanks.

themax222
05-03-2010, 01:32 PM
Tried IOCPconsole but I can't get it working correctly.

I give it up, if nobody can help to make a code for trim, I'll not be busy some hours on some OC programs just to get some trim sounds.

Anyway thanks for help,

Maxime.

kiek
05-03-2010, 01:33 PM
I'm wasting my time here in searching a solution for a small simple code that mayby you already have the solution. I will never use sioc because I don't need it exept now for a small trim code. You can understand that I don't want to read 5 manuals just for a small code...

Your waisting our time too ;-)
If you do not want to spend some time to learn SIOC you better not try to use it.