Welcome to the new FlexRadio Community! Please review the new Community Rules and other important new Community information on the Message Board.
If you are having a problem, please refer to the product documentation or check the Help Center for known solutions.
Need technical support from FlexRadio? It's as simple as Creating a HelpDesk ticket.

Radio.TXAudioStreamAddedEventHandler ... really?

Gary L. Robinson
Gary L. Robinson Member ✭✭
edited October 2018 in SmartSDR API
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

Answers

  • Mark_WS7M
    Mark_WS7M Member ✭✭✭
    edited July 2018
    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!
  • Gary L. Robinson
    Gary L. Robinson Member ✭✭
    edited July 2018
    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
  • James Whiteway
    edited July 2018
    Eric would probably be the one to contact. He's helped me a lot in the past.
  • Wayne
    Wayne Member ✭✭
    edited July 2018
    Is this related to opus as i understand opus does the audio stream, once i was wrong but then discovered i was mistaken ;-)
  • Gary L. Robinson
    Gary L. Robinson Member ✭✭
    edited July 2018
    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
  • Wayne
    Wayne Member ✭✭
    edited October 2018
    You might try searching "audio stream" in the search bar there are numerous interesting related posts which may offer some direction.
  • Gary L. Robinson
    Gary L. Robinson Member ✭✭
    edited July 2018
    I specifically searched for TXAudio BUT you are right.  Maybe a generic audio stream search will turn up some clues!
  • Doug - K3TZR
    Doug - K3TZR Member
    edited July 2018
    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
  • Gary L. Robinson
    Gary L. Robinson Member ✭✭
    edited July 2018
    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  
  • Doug - K3TZR
    Doug - K3TZR Member
    edited July 2018
    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.
  • Gary L. Robinson
    Gary L. Robinson Member ✭✭
    edited July 2018
    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
  • Doug - K3TZR
    Doug - K3TZR Member
    edited July 2018
    "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....

  • Gary L. Robinson
    Gary L. Robinson Member ✭✭
    edited July 2018
    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
  • Doug - K3TZR
    Doug - K3TZR Member
    edited July 2018
    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
  • Doug - K3TZR
    Doug - K3TZR Member
    edited July 2018
    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
  • Mario_DL3LSM
    Mario_DL3LSM Member ✭✭
    edited July 2018
    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
  • Doug - K3TZR
    Doug - K3TZR Member
    edited July 2018
    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.
  • Gary L. Robinson
    Gary L. Robinson Member ✭✭
    edited July 2018
    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


  • James Whiteway
    edited July 2018
    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)
  • Mario_DL3LSM
    Mario_DL3LSM Member ✭✭
    edited July 2018
    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
  • Gary L. Robinson
    Gary L. Robinson Member ✭✭
    edited July 2018
    Thanks James and Mario for the additional info! 

    ---Gary WB8ROL

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.