FlexLib, Radio.CreateAudioStream DAX Audio Encode How To

  • 1
  • Question
  • Updated 2 years ago
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
Photo of Larry da Ponte

Larry da Ponte

  • 158 Posts
  • 15 Reply Likes

Posted 3 years ago

  • 1
Photo of Larry da Ponte

Larry da Ponte

  • 158 Posts
  • 15 Reply Likes
I found Steve's notes on the DAX audio spec.
Photo of Eric - KE5DTO

Eric - KE5DTO, Official Rep

  • 653 Posts
  • 198 Reply Likes
The samples come across as 2 channels of 32-bit floats in the range -1.0 to +1.0 at 24kHz.
Photo of Larry da Ponte

Larry da Ponte

  • 158 Posts
  • 15 Reply Likes
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.
(Edited)
Photo of Eric - KE5DTO

Eric - KE5DTO, Official Rep

  • 653 Posts
  • 198 Reply Likes
Yes exactly.  They are interleaved LRLR...
Photo of Frank, HB9FXQ

Frank, HB9FXQ

  • 56 Posts
  • 25 Reply Likes
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?

(Edited)
Photo of Walt - KZ1F

Walt - KZ1F

  • 3040 Posts
  • 640 Reply Likes
Frank, you might want to consider moving your question to its own thread, rather than commingling your situation with Larry's.
Photo of Frank, HB9FXQ

Frank, HB9FXQ

  • 56 Posts
  • 25 Reply Likes
Hi Walt, agreed. Should have done that.
Photo of Frank, HB9FXQ

Frank, HB9FXQ

  • 56 Posts
  • 25 Reply Likes
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: 


(Edited)
Photo of Eric - KE5DTO

Eric - KE5DTO, Official Rep

  • 653 Posts
  • 198 Reply Likes
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.
Photo of James Whiteway

James Whiteway

  • 831 Posts
  • 181 Reply Likes
Very nice. Are you connecting to DAX to get the audio or processing the raw audio bits?
james
WD5GWY
Photo of James Whiteway

James Whiteway

  • 831 Posts
  • 181 Reply Likes
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