Hi all.
Here's a fix to get the xHE superframe interface working using the FDK xHE-AAC codec. I can't actually build Dream here due to Qt issues, but the fix is working with the KiwiSDR port of the Dream code. To test go to kiwisdr.com/public, bring up any Kiwi running v1.370 or later, click DRM mode, then click the "Test 2" button. A sample file recorded from Bengaluru, India will be looped (621 kHz AM MW, mode A, 9 kHz).
I think these should be all the required changes if someone wants to try them with Dream:
Index: src/MSC/xheaacsuperframe.cpp===================================================================--- src/MSC/xheaacsuperframe.cpp (revision 1338)+++ src/MSC/xheaacsuperframe.cpp (working copy)@@ -109,8 +109,8 @@
break;
default: // boundary in this superframe
borders[0] += start;
- if(borders[0]<2) return false;- borders[0] -= 2; // header not in payload+ //if(borders[0]<2) return false;+ //borders[0] -= 2; // header not in payload
frameSize[0] = borders[0];
//cerr << "border 0 is " << borders[0] << " bytes from start of payload" << endl;
break;
@@ -117,12 +117,17 @@
}
for(unsigned i=1; i<borders.size(); i++) {
borders[i] += start;
- borders[i] -= 2; // header not in payload+ //borders[i] -= 2; // header not in payload
unsigned bytes = borders[i]-borders[i-1];
frameSize[i] = bytes;
//cerr << "border " << i << " is " << borders[i] << " bytes from start of payload" << endl;
}
+ } else {+ // frameBorderCount == 0: spans entire ASF payload or bad data in header+ audioFrame.resize(0);+ return ok;
}
+
size_t bytesInFrames = 0; for(size_t i=0; i<frameSize.size(); i++) bytesInFrames+=frameSize[i];
size_t next = payload.size()-bytesInFrames;
//cerr << "payload is " << payload.size() << " bytes of which " << bytesInFrames << " are for this superframe and " << next << " are for the next superframe" << endl;
Index: src/sourcedecoders/AudioSourceDecoder.cpp===================================================================--- src/sourcedecoders/AudioSourceDecoder.cpp (revision 1338)+++ src/sourcedecoders/AudioSourceDecoder.cpp (working copy)@@ -356,6 +356,7 @@
/* Since we do not do Mode E or correct for sample rate offsets here (yet), we do not
have to consider larger buffers. An audio frame always corresponds to 400 ms */
iMaxLenResamplerOutput = int(_REAL(outputSampleRate) * 0.4 /* 400ms */ * 2 /* for stereo */ );
+ iMaxLenResamplerOutput *= 2; // to prevent buffer overruns with xHE-AAC (as detected by clang asan)
if(inputSampleRate != outputSampleRate) {
_REAL rRatio = _REAL(outputSampleRate) / _REAL(inputSampleRate);
@@ -364,7 +365,11 @@
ResampleObjR.Init(iLenDecOutPerChan, rRatio);
}
- int iResOutBlockSize = outputSampleRate * iLenDecOutPerChan / inputSampleRate;+ int iResOutBlockSize;+ if (inputSampleRate == 0)+ iResOutBlockSize = iLenDecOutPerChan;+ else+ iResOutBlockSize = outputSampleRate * iLenDecOutPerChan / inputSampleRate;
//cerr << "output block size per channel " << iResOutBlockSize << " = samples " << iLenDecOutPerChan << " * " << Parameters.GetAudSampleRate() << " / " << iAudioSampleRate << endl;
Regards,
John, ZL/KF6VO
KiwiSDR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, John. Did you get the decoded audio produced properly?
Months ago, when I attempted to use the FDK source on the test file, frame decoder always spitted out either "AAC_DEC_PARSE_ERROR" or "AAC_DECODE_UNKNOWN" error flag, even when frame CRC is OK.
zhongfanyang
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for you speedy response. After I make the necessary patch to the source code as you provided, I DO succeed decoding xHE-AAC frames, FINALLY! Again really appreciated for your contribution to the Dream project.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can report success under Linux as well. In addition to patches above, I had to modify dream.pro (for fdk-aac to be discovered under Linux) src/sourcedecoders/fdk_aac_codec.cpp (to get rid of "no codec found" error for xHE-AAC codec).
What is the very latest version of the code? Quite possible the additional tweaks I had to do are already in the newest code but if not, I am more than happy to contribute.
Last edit: Tarmo Tanilsoo 2020-01-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks. I forgot about HAVE_USAC. Because it appears in two other places in that file, one of which is likely important, I would suggest adding the define to the project file. But I can't build Dream with Qt so I don't know if this actually works. But I think it should:
Just recompiled with restored #ifdef HAVE_USAC, and modified dream.pro. Looks to work indeed. Although I can't seem to hear any higher frequencies that one would expect from SBR. That at least on the New Delhi test file I've been using.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have now identified why I was only hearing low frequencies despite SBR and the Decoded audio spectrum only went to 4 kHz. Dream.ini for some reason set the audio output sample rate to 8 kHz, and changing it from the Sound card settings menu had no effect. For now, the fix would be to change a line in Dream.ini from
samplerateaud=8000
to
samplerateaud=48000
Last edit: Tarmo Tanilsoo 2020-01-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for these patches - I applied them to the latest git and managed to receive my first live transmission - from Voice of Nigeria on 13675 kHz on Sunday afternoon around 1615 UTC. This transmission was not on any of the lists I had. It was 9.1kbps AAC mono but quite strong here in the UK. I piped from gqrx via Pulse Audio. :-) My PC was running Debian Bullseye (testing) plus the multimedia distro which gives fdk-aac v2.
Having problems compiling Revision 1339 using Ubuntu 18.04.4 LTS
Trying to build and after running:
qmake - result is OK
make - the following problem apparently with src/resample/speexresampler.cpp
In file included from src/resample/speexresampler.cpp:1:0:
src/resample/speexresampler.h:4:10: fatal error: speex/speex_resampler.h: No such file or directory
#include <speex speex_resampler.h="">
^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:5316: recipe for target 'obj/speexresampler.o' failed
make: *** [obj/speexresampler.o] Error 1</speex>
Can anybody help me out?
Many thanks,
-Zyg-
Last edit: Zygmunt Skrobanski 2020-02-15
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Also I had to add libspeex-dev and libspeexdsp-dev.
Happy compiling!
Cheers, Chris
On 2020-02-15 15:39, Zygmunt Skrobanski wrote:
Having problems compiling Revision 1339 using Ubuntu 18.04.4 LTS
Trying to build and after running:
qmake - result is OK
make - the following problem apparently with src/resample/speexresampler.cpp
In file included from src/resample/speexresampler.cpp:1:0:
src/resample/speexresampler.h:4:10:fatal error:speex/speex_resampler.h:No such file or directory
#include <speex speex_resampler.h="">
^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:5316:recipe for target 'obj/speexresampler.o' failed
make:*** [obj/speexresampler.o]Error 1</speex>
Read the error:
speex/speex_resampler.h: No such file or directory
So install the missing dependency. In a Debian based system, do:
sudo apt-get install libspeex-dev libspeexdsp-dev
Rafael
On 2/15/20 12:39 AM, Zygmunt Skrobanski wrote:
Having problems compiling Revision 1339 using Ubuntu 18.04.4 LTS
Trying to build and after running:
qmake - result is OK
make - the following problem apparently with src/resample/speexresampler.cpp
In file included from src/resample/speexresampler.cpp:1:0:
src/resample/speexresampler.h:4:10: fatal error: speex/speex_resampler.h: No such file or directory
#include <speex speex_resampler.h="">
^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:5316: recipe for target 'obj/speexresampler.o' failed
make: *** [obj/speexresampler.o] Error 1</speex>
Unfortunately I don't think adding those files will help in this case. There is an apparent error in not recognizing the file speexresampler.cpp. Particularly since I did not touch anything within that particular folder.
-Zyg-
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, all. I put together a script that might simplify installing in Ubuntu. There's also basic instructions for installing WSL with sound when running in Windows 10. It shouldn't make too much of a mess hopefully. Enjoy! (Thanks Rafael)
Well I've got it working, sort of, the DRM Main screen shows up but the program slows down on the Ubuntu Terminal and doesn't come to an end.
The Dream program does receive the VOA signal, at a 21 dB SNR, but shows that there is no codec. So the XHe-AAC decoding is not yet functional.
A situation akin to the operation was a success but the patient died!
Being an infrequent Linux user I'm still battling elementary stuff. I recently set up this computer to force myself to get better aquainted with this OS.
Did you installed fdk-aac 2?
From which svn Dream branch you are compiling?
Rafael
On 2/15/20 4:27 PM, Zygmunt Skrobanski wrote:
Progress...
Well I've got it working, sort of, the DRM Main screen shows up but the
program slows down on the Ubuntu Terminal and doesn't come to an end.
The Dream program does receive the VOA signal, at a 21 dB SNR, but shows
that there is no codec. So the XHe-AAC decoding is not yet functional.
A situation akin to the operation was a success but the patient died!
Being an infrequent Linux user I'm still battling elementary stuff. I
recently set up this computer to force myself to get better aquainted
with this OS.
Apparently no - I thought it was part of the SVN package. I notice that that there are a number of packages located in "Helper Files" on the Dream Receiver page. Do I need to install it seperately?
From which svn Dream branch you are compiling?
The one from the main Source Forge Dream DRM receiver site.
Thank you again for your help,
-Zyg-
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Apparently no - I thought it was part of the SVN package. I notice that
that there are a number of packages located in "Helper Files" on the
Dream Receiver page. Do I need to install it seperately?
FromwhichsvnDreambranchyouarecompiling?
The one from the main Source Forge Dream DRM receiver site.
Hi all.
Here's a fix to get the xHE superframe interface working using the FDK xHE-AAC codec. I can't actually build Dream here due to Qt issues, but the fix is working with the KiwiSDR port of the Dream code. To test go to kiwisdr.com/public, bring up any Kiwi running v1.370 or later, click DRM mode, then click the "Test 2" button. A sample file recorded from Bengaluru, India will be looped (621 kHz AM MW, mode A, 9 kHz).
I think these should be all the required changes if someone wants to try them with Dream:
Regards,
John, ZL/KF6VO
KiwiSDR
Hi, John. Did you get the decoded audio produced properly?
Months ago, when I attempted to use the FDK source on the test file, frame decoder always spitted out either "AAC_DEC_PARSE_ERROR" or "AAC_DECODE_UNKNOWN" error flag, even when frame CRC is OK.
zhongfanyang
The KiwiSDR test decoding works fine on my own KiwiSDRs. I just wish the Dream developers had as much enthusiasm as the KiwiSDR team do at the moment!
Thanks for you speedy response. After I make the necessary patch to the source code as you provided, I DO succeed decoding xHE-AAC frames, FINALLY! Again really appreciated for your contribution to the Dream project.
Hello all.
I can report success under Linux as well. In addition to patches above, I had to modify dream.pro (for fdk-aac to be discovered under Linux) src/sourcedecoders/fdk_aac_codec.cpp (to get rid of "no codec found" error for xHE-AAC codec).
What is the very latest version of the code? Quite possible the additional tweaks I had to do are already in the newest code but if not, I am more than happy to contribute.
Last edit: Tarmo Tanilsoo 2020-01-12
@Tarmo I just do a svn checkout http://svn.code.sf.net/p/drm/code/dream to get the latest sources (at svn-1338 currently I think). The latest Kiwi version is always at https://github.com/jks-prv/Beagle_SDR_GPS/tree/master/extensions/DRM/dream But it's difficult to diff that against Dream as I've been removing all the unrelated stuff (e.g. Qt) to simplify things.
Last edit: KiwiSDR 2020-01-12
Thanks. Here are the additional changes that I had to do get the latest SVN code to work on my Kubuntu machine.
Your mileage may vary.
Thanks. I forgot about HAVE_USAC. Because it appears in two other places in that file, one of which is likely important, I would suggest adding the define to the project file. But I can't build Dream with Qt so I don't know if this actually works. But I think it should:
Just recompiled with restored #ifdef HAVE_USAC, and modified dream.pro. Looks to work indeed. Although I can't seem to hear any higher frequencies that one would expect from SBR. That at least on the New Delhi test file I've been using.
I have now identified why I was only hearing low frequencies despite SBR and the Decoded audio spectrum only went to 4 kHz. Dream.ini for some reason set the audio output sample rate to 8 kHz, and changing it from the Sound card settings menu had no effect. For now, the fix would be to change a line in Dream.ini from
to
Last edit: Tarmo Tanilsoo 2020-01-13
Thank you for these patches - I applied them to the latest git and managed to receive my first live transmission - from Voice of Nigeria on 13675 kHz on Sunday afternoon around 1615 UTC. This transmission was not on any of the lists I had. It was 9.1kbps AAC mono but quite strong here in the UK. I piped from gqrx via Pulse Audio. :-) My PC was running Debian Bullseye (testing) plus the multimedia distro which gives fdk-aac v2.
Last edit: Peter Whisker 2020-02-05
Thats amazing!!! I'll try and find some time on Sunday to review and adopt this into the system. Thanks everyone!
I can confirm xHE-AAC is working. I commited the changes to my branch:
https://sourceforge.net/p/drm/code/HEAD/tree/branches/dream-rafa/
Having problems compiling Revision 1339 using Ubuntu 18.04.4 LTS
Trying to build and after running:
qmake - result is OK
make - the following problem apparently with src/resample/speexresampler.cpp
In file included from src/resample/speexresampler.cpp:1:0:
src/resample/speexresampler.h:4:10: fatal error: speex/speex_resampler.h: No such file or directory
#include <speex speex_resampler.h="">
^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:5316: recipe for target 'obj/speexresampler.o' failed
make: *** [obj/speexresampler.o] Error 1</speex>
Can anybody help me out?
Many thanks,
-Zyg-
Last edit: Zygmunt Skrobanski 2020-02-15
From one of Jayson's earlier emails:
Happy compiling!
Cheers, Chris
On 2020-02-15 15:39, Zygmunt Skrobanski wrote:
--
Chris Mackerell, Sandy Bay-Marahau Road, Marahau
RD 2, Motueka 7197, New Zealand chris@owdjim.gen.nz
Read the error:
speex/speex_resampler.h: No such file or directory
So install the missing dependency. In a Debian based system, do:
sudo apt-get install libspeex-dev libspeexdsp-dev
Rafael
On 2/15/20 12:39 AM, Zygmunt Skrobanski wrote:
Hi Chris,
Unfortunately I don't think adding those files will help in this case. There is an apparent error in not recognizing the file speexresampler.cpp. Particularly since I did not touch anything within that particular folder.
-Zyg-
These are packages, not files. I am also using 18.04 LTS, and I was able to compile. Install these two packages with apt and then try again.
Hi, all. I put together a script that might simplify installing in Ubuntu. There's also basic instructions for installing WSL with sound when running in Windows 10. It shouldn't make too much of a mess hopefully. Enjoy! (Thanks Rafael)
https://github.com/keyboarderror/DreamBuild
Tarmo, Rafael, and Chris:
Thank you for the help it is very much appreciated!. My only excuse is that I'm a beginner with Linux.
By adding sudo apt-get install libspeex-dev libspeexdsp-dev the error problem went away!
Now I have to do some more work:
zygmunt@OptiPlex-7010:~/dream$ sudo cp dream /usr/local/bin/dream
zygmunt@OptiPlex-7010:~/dream$ dream
Got FAAD2 library
No usable FAAC aac encoder library found
Got Opus library
dummy: _init called
This was followed by a whole lot of rig_register lines
Thanks again,
-Zyg-
Why is it that "No usable FAAC aac encoder library found" when it is meant to be decoding not encoding?
I'm probably missing something that is obvious to everybody else.
Progress...
Well I've got it working, sort of, the DRM Main screen shows up but the program slows down on the Ubuntu Terminal and doesn't come to an end.
The Dream program does receive the VOA signal, at a 21 dB SNR, but shows that there is no codec. So the XHe-AAC decoding is not yet functional.
A situation akin to the operation was a success but the patient died!
Being an infrequent Linux user I'm still battling elementary stuff. I recently set up this computer to force myself to get better aquainted with this OS.
Any help will continue to be greatly appreciated!
-Zyg-
Did you installed fdk-aac 2?
From which svn Dream branch you are compiling?
Rafael
On 2/15/20 4:27 PM, Zygmunt Skrobanski wrote:
Hi Rafael,
Apparently no - I thought it was part of the SVN package. I notice that that there are a number of packages located in "Helper Files" on the Dream Receiver page. Do I need to install it seperately?
The one from the main Source Forge Dream DRM receiver site.
Thank you again for your help,
-Zyg-
So, you need to install fdk-aac 2:
http://www.telemidia.puc-rio.br/~rafaeldiniz/public_files/fdk-aac/
and use my svn branch (branches/dream-rafa) to compile, please follow
instruction at:
https://github.com/keyboarderror/DreamBuild
Rafael
On 2/15/20 5:20 PM, Zygmunt Skrobanski wrote: