From 75d5083f8e20ad32a7e52c720a6c0fa86e0f3ef3 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Sat, 30 May 2020 19:59:15 +0200 Subject: [PATCH] fixe network byte ordering, change audio dump to dumep 16 bit samples --- FMControl.cpp | 13 ++++++------- FMControl.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/FMControl.cpp b/FMControl.cpp index fadf005..1e460b7 100644 --- a/FMControl.cpp +++ b/FMControl.cpp @@ -118,21 +118,20 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length) samples[i] = m_filterStage3->filter(m_filterStage2->filter(m_filterStage1->filter(samples[i]))); } -#if defined(DUMP_RF_AUDIO) - if(audiofile != NULL) - fwrite(samples, sizeof(float), nSamples, audiofile); -#endif - unsigned short out[170U]; // 85 * 2 unsigned int nOut = 0U; // Repack the data (8-bit unsigned values containing unsigned 16-bit data) for (unsigned int i = 0U; i < nSamples; i++) { unsigned short sample = (unsigned short)((samples[i] + 1.0F) * 32767.0F + 0.5F); - out[nOut++] = (sample >> 8) & 0xFFU; - out[nOut++] = (sample >> 0) & 0xFFU; + out[nOut++] = ((sample >> 8) & 0x00FFU) | ((sample << 8) & 0xFF00U);//change endianess to network order, transmit MSB first } +#if defined(DUMP_RF_AUDIO) + if(audiofile != NULL) + fwrite(out, sizeof(unsigned short), nOut, audiofile); +#endif + #if defined(DUMP_RF_AUDIO) if(audiofile != NULL) fclose(audiofile); diff --git a/FMControl.h b/FMControl.h index c7af709..1647010 100644 --- a/FMControl.h +++ b/FMControl.h @@ -25,7 +25,7 @@ // Uncomment this to dump audio to a raw audio file // The file will be written in same folder as executable -// Toplay the file : aplay -f FLOAT_LE -c1 -r8000 -t raw audiodump.bin +// Toplay the file : ffplay -autoexit -f u16be -ar 8000 audiodump.bin // #define DUMP_RF_AUDIO class CFMControl {