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.

FlexLib, Radio.CreateAudioStream DAX Audio Encode How To

N7BCP
N7BCP Member ✭✭
edited July 2017 in SmartSDR API
I know just enough to be dangerous with FlexLib.  I've managed to use FlexLib to get the radio to give me what I think is IEEE floating point audio via the Radio.CreateAudioStream and an RXDataReady event handler. The handler is being called and I'm getting my array of floats and what I'd like to do is encode this as MP3 (for use in an HTML5 audio element).  I'm looking at using the NAudio library to do this (better ideas?).  If anyone has tried something like this or has any guidance to offer I would appreciate it.  Rather than writing a native client for the Mac, Linux, or mobile device I'm developing a cross platform web based client.  MP3 seems to be the best supported audio format for HTML5.  I know Flex will be offering Opus but that won't help me.  Does anyone know what the samples per second and bit depth of this "DAX Audio" is?  A good way to encode this as MP3 in managed code?  I've found this awesome article http://www.codeproject.com/Articles/501521/How-to-convert-between-most-audio-formats-in-NET  

Thanks

-Larry

Answers

  • N7BCP
    N7BCP Member ✭✭
    edited July 2017
    I found Steve's notes on the DAX audio spec.
  • Eric-KE5DTO
    Eric-KE5DTO Administrator, FlexRadio Employee admin
    edited February 2017
    The samples come across as 2 channels of 32-bit floats in the range -1.0 to +1.0 at 24kHz.
  • N7BCP
    N7BCP Member ✭✭
    edited July 2017
    Thanks Eric - I've been successfull in getting this stream of floats to play in a web browser using WebSockets and Web Audio API (wrote a server app in C# that takes the UDP packets from the radio and writes them to a WebSockets connected web browser) and it sounds fine.  I've split the samples into two channels by alternating each, even numbered samples go to channel one and odd numbered samples go to channel two.  Is this how the sample are divided?  I may resample to reduce the amount of data going to the client.
  • Eric-KE5DTO
    Eric-KE5DTO Administrator, FlexRadio Employee admin
    edited February 2017
    Yes exactly.  They are interleaved LRLR...
  • Frank, HB9FXQ
    Frank, HB9FXQ Member ✭✭
    edited March 2017
    Maybe the wrong thread, but I've at least managed to get some kind of sound. Here is a recording: https://drive.google.com/file/d/0BwuiePIG9KVMc3pWR0FVb3VSRm8/view

    I've tried with both channels, speed is fine, but tone frequency is too high. Then isolated one cannel deinterleaved  (See screenshot) with the same results.... tone freq is strange. 

    Olso tried to import the raw bytes with audacity... same sound / [noise] 

    When I enable SmartSDR Dax on the same channel I hear the sound in sync, but dax has the right tone freq :) According to https://community.flexradio.com/flexradio/topics/iq_stream_from_6700_radio the Sample Radio of DAX Audio is 48k. 

    Does anyone see what I'm doing wrong?

    image
  • Walt - KZ1F
    Walt - KZ1F Member ✭✭
    edited November 2016
    Frank, you might want to consider moving your question to its own thread, rather than commingling your situation with Larry's.
  • Frank, HB9FXQ
    Frank, HB9FXQ Member ✭✭
    edited March 2017
    Sorry, dump mistake, I've had two subscriptions to this.stream.RXDataReady... no idea why, but audioStreamAdded might get called twice in 1.6.21??



    If anyone still has suggestions, let me know. the following code should work: 


    image
  • Frank, HB9FXQ
    Frank, HB9FXQ Member ✭✭
    edited November 2016
    Hi Walt, agreed. Should have done that.
  • James Whiteway
    edited March 2016
    Very nice. Are you connecting to DAX to get the audio or processing the raw audio bits?
    james
    WD5GWY

  • James Whiteway
    edited March 2016
    Sorry, I should have read your post better. I see you are using the IEEE audio. I have not tried to work with the audio yet. Still playing with the waterfall.
    james
    WD5GWY

  • Eric-KE5DTO
    Eric-KE5DTO Administrator, FlexRadio Employee admin
    edited December 2016
    Frank,

    I don't know of a reason why you would get 2 AudioStreamAdded events, but I have learned that just about anything is possible in software.  ;)  Please keep us posted if you continue to have this issue.

    The code for handling the data looks reasonable to me on a brief look.  I noticed that in this screenshot you show using 24kHz, which I think is the correct rate.  It looks like you are creating a new BufferedWaveProvider on every RxData event received.  This sounds like something you might do once (if _provider is null, perhaps).  Some googling says this may be in NAudio, which I am not all that familiar with.

    Keep at it and let us know how you're progressing.

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.