Radio.TXAudioStreamAddedEventHandler ... really?

  • 1
  • Question
  • Updated 5 months ago
  • Answered
I have implemented a whole bunch of Event Handlers with no problem BUT have had NO luck with the TXAudioStream in that regard.

I set the code below and it compiles with no errors and causes no run time errors BUT it NEVER catches any fired off events.  From looking at the SmartSDR API it would appear the ONLY possible way to get the TXAudioStream ID ...

The TXAudioStreamAdded event is set up in the API_RadioAdded(Radio radio) section of code with most of the other event handler creations.

................

                radio.TXAudioStreamAdded += new Flex.Smoothlake.FlexLib.Radio.TXAudioStreamAddedEventHandler(radio_TXAudioStreamAdded);

.................

        void radio_TXAudioStreamAdded(TXAudioStream tx_audio_stream)
        {
             int test = 0;
        }

...................

Has anyone had ANY luck using this event handler and seeing an event be fired??

I don't have all that much hair on my head left - I'd like to keep it hihi

---Gary WB8ROL
Photo of Gary L. Robinson

Gary L. Robinson

  • 248 Posts
  • 48 Reply Likes

Posted 5 months ago

  • 1
Photo of Mark - WS7M

Mark - WS7M

  • 1026 Posts
  • 364 Reply Likes
Gary,

I cannot get it to trigger either.  I've not tried to use it before but I get no hits on the event handler and have tried various options in SSDR.

Think Flex will have to answer!
Photo of Gary L. Robinson

Gary L. Robinson

  • 248 Posts
  • 48 Reply Likes
Thanks Mark!  It's been driving me crazy for several days (XYL says that is my normal state hihi).  At least I am convinced that there is something wrong with the event handler OR it takes some "special sauce" to make it work.  If no one, including anyone from Flex, chimes in with some new pertinent information in a few days I will try an email to one of their programmers.

---Gary WB8ROL
Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
Eric would probably be the one to contact. He's helped me a lot in the past.
Photo of Wayne

Wayne

  • 614 Posts
  • 84 Reply Likes
Is this related to opus as i understand opus does the audio stream, once i was wrong but then discovered i was mistaken ;-)
Photo of Gary L. Robinson

Gary L. Robinson

  • 248 Posts
  • 48 Reply Likes
I am not sure this is related to opus.  I do know that there are Radio class members to set up event handlers just like I have done for many other objects - but perhaps audio streams are handled differently.

Hmmmm.  I may try and do the same with other audio stream objects and see if I get the same result. 

Thanks for the possible clue Wayne.  If I end up writing Flex (probably Eric as suggested by James in posting above) then I may get to the bottom of this or at least some sort of explanation of what is going on.

Thanks!  and Thanks to James also!

---Gary WB8ROL
Photo of Wayne

Wayne

  • 614 Posts
  • 84 Reply Likes
You might try searching "audio stream" in the search bar there are numerous interesting related posts which may offer some direction.
Photo of Gary L. Robinson

Gary L. Robinson

  • 248 Posts
  • 48 Reply Likes
I specifically searched for TXAudio BUT you are right.  Maybe a generic audio stream search will turn up some clues!
Photo of Doug - K3TZR

Doug - K3TZR

  • 112 Posts
  • 14 Reply Likes
Gary,

I've observed that the TX Audio Stream is created when the DAX application is started. If you have un-checked SmartSDR's option to start DAX, then the TX Audio Stream isn't started when SmartSDR starts. If you start DAX after starting SmartSDR, it will create the TX Audio Stream. If you have DAX running and close it (leaving SmartSDR running) the TX Audio Stream is closed.

An Opus Stream is started when SmartSDR starts regardless of whether DAX is started. Curiously, I've seen that the Opus Stream will be closed if you have DAX running and close DAX with SmartSDR still running.

I'm not sure how all of this interacts with the C# event handlers. I've been working on a Mac version of FlexLib where the event handling mechanisms are somewhat different. 

73's Doug
Photo of Gary L. Robinson

Gary L. Robinson

  • 248 Posts
  • 48 Reply Likes
Thanks Doug!   I had not thought about how DAX being auto started or not  - as to how that would affect when the TXAudioStream would be started. 

However, after reading your  reply I have played with it (starting DAX manually after the program is up and running and still not having any luck yet.  The TXAudioStreamAdded and TXAudioStreamRemoved event handlers aren't showing anything happening.  

Will play with it some more before I give up on it hihi  
Photo of Doug - K3TZR

Doug - K3TZR

  • 112 Posts
  • 14 Reply Likes
Are you able to see the status messages (with code or Wireshark) that the radio sends back to the client. When I watch them I see a status message like this when DAX is started:

tx_audio_stream 0x84000000 in_use=1 dax_tx=0 ip=10.0.1.100 port=4993

Looking at the FlexLib source code (TXAudioStream.cs, v2.3.9), it appears that the receipt of a tx_audio_stream status message with a valid ip address results in the execution of this line:

_radio.OnTXAudioStreamAdded(this);

Which I'm guessing, performs the notification that you're waiting for.
Photo of Gary L. Robinson

Gary L. Robinson

  • 248 Posts
  • 48 Reply Likes
Well, the good news is I can CREATE a TXAudioStream in code and my TXAudioStreamAddedEventHandler will detect it!   The bad news is my TXAudioStreamAddedEventHandler  will NOT see the TXAudioStream that the DAX program creates when I click on TX button in DAX (In TX Stream section) -- even though the stream itself performs just fine. 

It's times like this that make me wonder why I didn't take up needle point for a hobby ... :-)

---Gary WB8ROL
Photo of Doug - K3TZR

Doug - K3TZR

  • 112 Posts
  • 14 Reply Likes
"the TXAudioStream that the DAX program creates when I click on TX button in DAX"

I don't think that is correct, the stream is created when DAX is started (BTW it always seems to have the Stream ID 0x84000000). No data is sent but the stream is created.

Clicking the TX button seems to check that DAX is selected in the P/CW side panel. If not selected the button turns yellow. If it is selected the button turns blue. At that point your source of transmit audio (e.g. WSJT-X) can now provide audio to the "DAX Audio TX" Windows sound device to be sent to the radio to modulate the radio.

The fact that you can create one in code and see the event makes me think your issue is timing, maybe you aren't looking when the first event occurs, just a guess.

Needle point is boring....
Photo of Gary L. Robinson

Gary L. Robinson

  • 248 Posts
  • 48 Reply Likes
Agree on the needle point hihi

I had also thought it might be a timing issue.  So, I had initialized the TXAudioStream event handler as the very first item in the API_RadioAdded event handler section.  I don't think their is any other place that it can be initialized any sooner.  

I totally turned off the 6400 and then restarted it with my program already running (in debug mode) and still get nothing happening in the TXAudioStream event handler. 

I have also ran it with the DAX controls set to automatically start and with it set to NOT automatically start.

It is starting to make me think it may not be possible at this point to accomplish it.

However ..... in the (what I would think unlikely) event that the Stream ID is always the same I will test it tomorrow and see if I can affect the TXAdioStream with it  programmatically ...

For now I have to  hit the sack or fall asleep at the radio desk hihi

Thanks for the info and help Doug!

---Gary
Photo of Doug - K3TZR

Doug - K3TZR

  • 112 Posts
  • 14 Reply Likes
Gary,

I can sympathize with your pain, while writing a Mac-native version of Flexlib I went through many weeks of puzzling over things like this. I wish my knowledge of C# was good enough to help you figure this one out. I know that in my version of Flexlib, written in Swift, when I receive the tx_audio_stream status message I generate a Notification "TxAudioStreamAdded", for the client using my library to know that the stream was added.

Maybe you need to send a note to Eric (or one of the developers), they will understand your code and it's interaction with the C# Flexlib better than I do.

I did one additional test to better understand this. I monitored "when" the status message occurs relative to the start of the connection made by the Dax app. When I start Dax lots of status messages are sent. The tx_audio_stream message is the last one sent and in my system, that means it is sent about 200 milliseconds after The first Dax initiated message.

Doug
Photo of Doug - K3TZR

Doug - K3TZR

  • 112 Posts
  • 14 Reply Likes
Here's a link to the log of messages generated by starting Dax (without starting SmartSDR). These were captured with a tool I've created for use on the Mac. It uses my Mac version of Flexlib.

You can see the very last message is the tx_audio_stream message. The number at the beginning of each line is a timestamp (seconds . milliseconds).

https://www.dropbox.com/s/3ddh2vorooedclz/DaxStatusMessages.txt?dl=0
Photo of Mario - DL3LSM

Mario - DL3LSM

  • 63 Posts
  • 23 Reply Likes
Hi Gary,

if I read the code in FlexLib correctly the handler is called only if the tx stream belongs to (is created by) your client.. Because of this code in Radio.parseStatus:

                        if (tx_audio_stream == null)
                        {
                            if (s.Contains("in_use=0")) return;

                            if (!IsAudioStreamStatusForThisClient(s)) return;

                            add_new = true;
                            tx_audio_stream = new TXAudioStream(this);
                            tx_audio_stream.TXStreamID = stream_id;
                        }

So if the tx audio stream is created by SmartDAX IsAudioStreamStatusForThisClient will return false and a tx_audio_stream object will not be created..

73, Mario DL3LSM
(Edited)
Photo of Doug - K3TZR

Doug - K3TZR

  • 112 Posts
  • 14 Reply Likes
Mario,

I think you are correct. The xAPITester that I used to create the log ignores the isAudioStreamStatusForThisClient() method; it observes all streams.

So your explanation explains why Gary sees the event when he manually creates a TxAudioStream in his code but does not see the event when SmartDAX creates the TxAudioStream.
Photo of Gary L. Robinson

Gary L. Robinson

  • 248 Posts
  • 48 Reply Likes
Thanks Mario and Doug!  Well this is making me consider on possibly modifying the FlexLib code (TXAudioStream) slightly to add some public functionality to it that I want .

If, for instance, I modify the TXAudioStream.cs file and recompile the DLL and replace the one already installed on my Windows computer with mine - I believe SmartSDR will probably see it as an "update" and let me load it into the rig.  I may write Eric about that.  I assume it could affect my warranty but that does not bother me a lot. 

---Gary WB8ROL
Photo of James Whiteway

James Whiteway

  • 905 Posts
  • 222 Reply Likes
Those files in the Flex library don't get loaded into the radio. They are used by SSDR or any client program to communicate with the radio.
The firmware in the radio only gets modified by an official Flex Update. You won't be voiding your warranty by modifying the .cs files and recompiling them. Other than your own prigram responding to the changes, SSDR would ignore the new lines of code or crash.
James

(Been there done that when I dropped modified dll's into SSDR's folder in Program files in Windows)
(Edited)
Photo of Mario - DL3LSM

Mario - DL3LSM

  • 63 Posts
  • 23 Reply Likes
Hi Gary,

as the changes are needed only for your client there would be no need to drop the changed dll into SmartSDR's folder. Just use it for your app and SSDR will be unaffected..

73, Mario DL3LSM
Photo of Gary L. Robinson

Gary L. Robinson

  • 248 Posts
  • 48 Reply Likes
Thanks James and Mario for the additional info! 

---Gary WB8ROL