fixe network byte ordering, change audio dump to dumep 16 bit samples
This commit is contained in:
parent
0b8a9a1a4c
commit
75d5083f8e
|
@ -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])));
|
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 short out[170U]; // 85 * 2
|
||||||
unsigned int nOut = 0U;
|
unsigned int nOut = 0U;
|
||||||
|
|
||||||
// Repack the data (8-bit unsigned values containing unsigned 16-bit data)
|
// Repack the data (8-bit unsigned values containing unsigned 16-bit data)
|
||||||
for (unsigned int i = 0U; i < nSamples; i++) {
|
for (unsigned int i = 0U; i < nSamples; i++) {
|
||||||
unsigned short sample = (unsigned short)((samples[i] + 1.0F) * 32767.0F + 0.5F);
|
unsigned short sample = (unsigned short)((samples[i] + 1.0F) * 32767.0F + 0.5F);
|
||||||
out[nOut++] = (sample >> 8) & 0xFFU;
|
out[nOut++] = ((sample >> 8) & 0x00FFU) | ((sample << 8) & 0xFF00U);//change endianess to network order, transmit MSB first
|
||||||
out[nOut++] = (sample >> 0) & 0xFFU;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(DUMP_RF_AUDIO)
|
||||||
|
if(audiofile != NULL)
|
||||||
|
fwrite(out, sizeof(unsigned short), nOut, audiofile);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(DUMP_RF_AUDIO)
|
#if defined(DUMP_RF_AUDIO)
|
||||||
if(audiofile != NULL)
|
if(audiofile != NULL)
|
||||||
fclose(audiofile);
|
fclose(audiofile);
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
// Uncomment this to dump audio to a raw audio file
|
// Uncomment this to dump audio to a raw audio file
|
||||||
// The file will be written in same folder as executable
|
// 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
|
// #define DUMP_RF_AUDIO
|
||||||
|
|
||||||
class CFMControl {
|
class CFMControl {
|
||||||
|
|
Loading…
Reference in a new issue